@oliasoft-open-source/charts-library 5.1.0 → 5.1.1-beta-2

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 (32) hide show
  1. package/dist/assets/{Color-YHDXOIA2-Cf20dAz7.js → Color-YHDXOIA2-DK-zvEp4.js} +1 -1
  2. package/dist/assets/{DocsRenderer-CFRXHY34-BLg8W1W2.js → DocsRenderer-CFRXHY34-Bg8MQWAR.js} +3 -3
  3. package/dist/assets/{bar-chart.stories-BYQyquXm.js → bar-chart.stories-C41de-ei.js} +1 -1
  4. package/dist/assets/{entry-preview-BZo_8q_9.js → entry-preview-BFBa1CWR.js} +1 -1
  5. package/dist/assets/{get-draggableData-dkvBi0Bl.js → get-draggableData-DPTQjrFS.js} +1 -1
  6. package/dist/assets/{iframe-DQBiGpMD.js → iframe-CpYKaSFw.js} +2 -2
  7. package/dist/assets/{legend-Dsh-gS4D.js → legend-D-2OZtHn.js} +1 -1
  8. package/dist/assets/{legend-context-9xqNf4cB.js → legend-context-BDAlvkJS.js} +12 -12
  9. package/dist/assets/line-chart-BMOGGJ6G.js +1 -0
  10. package/dist/assets/{line-chart.stories-B40-dAYL.js → line-chart.stories-CXTeCdqs.js} +76 -69
  11. package/dist/assets/{line-chart.test-case.stories-DtULjl6w.js → line-chart.test-case.stories-D2DsX-6x.js} +1 -1
  12. package/dist/assets/{pie-chart.stories-Birt17VG.js → pie-chart.stories-CUYoikIz.js} +1 -1
  13. package/dist/assets/{preview-C_VJ39RO.js → preview-CrH-Kwuw.js} +1 -1
  14. package/dist/assets/{preview-BxIF5cTA.js → preview-HxUexXep.js} +2 -2
  15. package/dist/assets/{scatter-chart.stories-BoOuwmMg.js → scatter-chart.stories--WaN2oN8.js} +1 -1
  16. package/dist/common/common.interface.d.ts +3 -0
  17. package/dist/common/helpers/get-chart-annotation.d.ts +1 -0
  18. package/dist/common/plugins/ellipsis-annotation-plugin/compute-ellipse-geometry.d.ts +9 -0
  19. package/dist/common/plugins/ellipsis-annotation-plugin/ellipsis-annotation-plugin.d.ts +18 -0
  20. package/dist/iframe.html +1 -1
  21. package/dist/index.js.js +27 -100
  22. package/dist/index.js.js.map +1 -1
  23. package/dist/index.json +1 -1
  24. package/dist/line-chart/hooks/use-chart-state.d.ts +1 -5
  25. package/dist/line-chart/utils/axis-scales/axis-scales.d.ts +1 -3
  26. package/dist/line-chart/utils/line-chart-utils.d.ts +5 -0
  27. package/dist/project.json +1 -1
  28. package/dist/src/components/line-chart/hooks/use-chart-state.d.ts +1 -5
  29. package/dist/src/components/line-chart/utils/axis-scales/axis-scales.d.ts +1 -3
  30. package/dist/src/components/line-chart/utils/line-chart-utils.d.ts +5 -0
  31. package/package.json +1 -1
  32. package/dist/assets/line-chart-r9Mg5Qcy.js +0 -1
@@ -0,0 +1 @@
1
+ import{j as _}from"./jsx-runtime-Y5Ju2SGo.js";import{r as O}from"./index-eCxJ45ll.js";import{$ as Xn,a0 as Ze,a1 as J,x as U,a2 as Yn,v as D,A as k,P as oe,C as Q,a3 as Re,a4 as Hn,g as we,N as qn,S as Wn,y as $n,O as Zn,a5 as ie,a6 as ue,Q as ee,a7 as ge,E as Ae,R as Kn,T as Jn,L as Ke,a as Qn,U as be,V as et,W as Z,d as nt,r as tt,B as Je,a8 as st,f as rt,a9 as lt,I as ot,aa as j,ab as Be,ac as le,D as it,ad as K,b as ut,s as at,F as ct,ae as dt,h as ft,i as gt,J as mt,Y as bt,j as yt,k as pt,p as ht,m as _t,n as xt,o as Tt,q as Et,t as Pt}from"./legend-context-BDAlvkJS.js";import{r as Oe,M as Ue,p as ye,B as X,s as Lt,v as Ct,w as Qe,x as Ot,y as St,z as Dt,A as Nt,E as wt,N as en,G as At,S as Mt,g as Ft,e as vt,F as It,T as hn,J as kt,K as jt,D as Gt,O as zt,Q as Vt,k as Rt,q as Bt,U as Ut,u as Xt,j as Yt,Z as Ht,t as qt,R as Wt,m as $t,H as Zt,L as Kt,n as Jt,o as Qt}from"./legend-D-2OZtHn.js";import{c as es,C as ns,f as nn,a as ts,b as ss}from"./get-draggableData-DPTQjrFS.js";import{e as rs}from"./index-B-BONL6g.js";const ls=(e,n,t)=>{const[r,s]=e.major,[o,l]=e.minor,i=(r.x+s.x+o.x+l.x)/4,u=(r.y+s.y+o.y+l.y)/4,c=s.x-r.x,a=s.y-r.y,d=Math.atan2(t.getPixelForValue(u+a/2)-t.getPixelForValue(u-a/2),n.getPixelForValue(i+c/2)-n.getPixelForValue(i-c/2)),y=Math.hypot(n.getPixelForValue(r.x)-n.getPixelForValue(s.x),t.getPixelForValue(r.y)-t.getPixelForValue(s.y))/2,m=Math.hypot(n.getPixelForValue(o.x)-n.getPixelForValue(l.x),t.getPixelForValue(o.y)-t.getPixelForValue(l.y))/2,p=n.getPixelForValue(i),b=t.getPixelForValue(u);return{cx:p,cy:b,radiusX:y,radiusY:m,angle:d}},os={id:"ellipsisAnnotationPlugin",afterDatasetsDraw(e){var o,l;const n=e==null?void 0:e.ctx,t=(o=e==null?void 0:e.scales)==null?void 0:o.x,r=(l=e==null?void 0:e.scales)==null?void 0:l.y;n.save();const s=e==null?void 0:e.chartArea;s&&(n.beginPath(),n.rect(s.left,s.top,s.right-s.left,s.bottom-s.top),n.clip()),e.data.datasets.forEach(i=>{const u=i;u.data.forEach(c=>{const{ellipsePoints:a}=c;if(!a)return;const{cx:d,cy:y,radiusX:m,radiusY:p,angle:b}=ls(a,t,r);n.save(),n.beginPath(),n.ellipse(d,y,m,p,b,0,2*Math.PI),n.strokeStyle=u.borderColor||Xn,n.lineWidth=u.borderWidth||1,n.stroke(),n.restore()})})}},is="_chart_e3qdd_1",us="_canvas_e3qdd_11",as="_fixedHeight_e3qdd_20",cs="_stretchHeight_e3qdd_26",ds="_squareAspectRatio_e3qdd_32",fs="_table_e3qdd_62",Se={chart:is,canvas:us,fixedHeight:as,stretchHeight:cs,squareAspectRatio:ds,table:fs};var _n=Symbol.for("immer-nothing"),tn=Symbol.for("immer-draftable"),M=Symbol.for("immer-state");function v(e,...n){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ne=Object.getPrototypeOf;function te(e){return!!e&&!!e[M]}function q(e){var n;return e?xn(e)||Array.isArray(e)||!!e[tn]||!!((n=e.constructor)!=null&&n[tn])||Pe(e)||Le(e):!1}var gs=Object.prototype.constructor.toString();function xn(e){if(!e||typeof e!="object")return!1;const n=ne(e);if(n===null)return!0;const t=Object.hasOwnProperty.call(n,"constructor")&&n.constructor;return t===Object?!0:typeof t=="function"&&Function.toString.call(t)===gs}function pe(e,n){Ee(e)===0?Reflect.ownKeys(e).forEach(t=>{n(t,e[t],e)}):e.forEach((t,r)=>n(r,t,e))}function Ee(e){const n=e[M];return n?n.type_:Array.isArray(e)?1:Pe(e)?2:Le(e)?3:0}function Me(e,n){return Ee(e)===2?e.has(n):Object.prototype.hasOwnProperty.call(e,n)}function Tn(e,n,t){const r=Ee(e);r===2?e.set(n,t):r===3?e.add(t):e[n]=t}function ms(e,n){return e===n?e!==0||1/e===1/n:e!==e&&n!==n}function Pe(e){return e instanceof Map}function Le(e){return e instanceof Set}function H(e){return e.copy_||e.base_}function Fe(e,n){if(Pe(e))return new Map(e);if(Le(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const t=xn(e);if(n===!0||n==="class_only"&&!t){const r=Object.getOwnPropertyDescriptors(e);delete r[M];let s=Reflect.ownKeys(r);for(let o=0;o<s.length;o++){const l=s[o],i=r[l];i.writable===!1&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(r[l]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[l]})}return Object.create(ne(e),r)}else{const r=ne(e);if(r!==null&&t)return{...e};const s=Object.create(r);return Object.assign(s,e)}}function Xe(e,n=!1){return Ce(e)||te(e)||!q(e)||(Ee(e)>1&&(e.set=e.add=e.clear=e.delete=bs),Object.freeze(e),n&&Object.entries(e).forEach(([t,r])=>Xe(r,!0))),e}function bs(){v(2)}function Ce(e){return Object.isFrozen(e)}var ys={};function W(e){const n=ys[e];return n||v(0,e),n}var ae;function En(){return ae}function ps(e,n){return{drafts_:[],parent_:e,immer_:n,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function sn(e,n){n&&(W("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=n)}function ve(e){Ie(e),e.drafts_.forEach(hs),e.drafts_=null}function Ie(e){e===ae&&(ae=e.parent_)}function rn(e){return ae=ps(ae,e)}function hs(e){const n=e[M];n.type_===0||n.type_===1?n.revoke_():n.revoked_=!0}function ln(e,n){n.unfinalizedDrafts_=n.drafts_.length;const t=n.drafts_[0];return e!==void 0&&e!==t?(t[M].modified_&&(ve(n),v(4)),q(e)&&(e=he(n,e),n.parent_||_e(n,e)),n.patches_&&W("Patches").generateReplacementPatches_(t[M].base_,e,n.patches_,n.inversePatches_)):e=he(n,t,[]),ve(n),n.patches_&&n.patchListener_(n.patches_,n.inversePatches_),e!==_n?e:void 0}function he(e,n,t){if(Ce(n))return n;const r=n[M];if(!r)return pe(n,(s,o)=>on(e,r,n,s,o,t)),n;if(r.scope_!==e)return n;if(!r.modified_)return _e(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const s=r.copy_;let o=s,l=!1;r.type_===3&&(o=new Set(s),s.clear(),l=!0),pe(o,(i,u)=>on(e,r,s,i,u,t,l)),_e(e,s,!1),t&&e.patches_&&W("Patches").generatePatches_(r,t,e.patches_,e.inversePatches_)}return r.copy_}function on(e,n,t,r,s,o,l){if(te(s)){const i=o&&n&&n.type_!==3&&!Me(n.assigned_,r)?o.concat(r):void 0,u=he(e,s,i);if(Tn(t,r,u),te(u))e.canAutoFreeze_=!1;else return}else l&&t.add(s);if(q(s)&&!Ce(s)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;he(e,s),(!n||!n.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(t,r)&&_e(e,s)}}function _e(e,n,t=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Xe(n,t)}function _s(e,n){const t=Array.isArray(e),r={type_:t?1:0,scope_:n?n.scope_:En(),modified_:!1,finalized_:!1,assigned_:{},parent_:n,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let s=r,o=Ye;t&&(s=[r],o=ce);const{revoke:l,proxy:i}=Proxy.revocable(s,o);return r.draft_=i,r.revoke_=l,i}var Ye={get(e,n){if(n===M)return e;const t=H(e);if(!Me(t,n))return xs(e,t,n);const r=t[n];return e.finalized_||!q(r)?r:r===De(e.base_,n)?(Ne(e),e.copy_[n]=je(r,e)):r},has(e,n){return n in H(e)},ownKeys(e){return Reflect.ownKeys(H(e))},set(e,n,t){const r=Pn(H(e),n);if(r!=null&&r.set)return r.set.call(e.draft_,t),!0;if(!e.modified_){const s=De(H(e),n),o=s==null?void 0:s[M];if(o&&o.base_===t)return e.copy_[n]=t,e.assigned_[n]=!1,!0;if(ms(t,s)&&(t!==void 0||Me(e.base_,n)))return!0;Ne(e),ke(e)}return e.copy_[n]===t&&(t!==void 0||n in e.copy_)||Number.isNaN(t)&&Number.isNaN(e.copy_[n])||(e.copy_[n]=t,e.assigned_[n]=!0),!0},deleteProperty(e,n){return De(e.base_,n)!==void 0||n in e.base_?(e.assigned_[n]=!1,Ne(e),ke(e)):delete e.assigned_[n],e.copy_&&delete e.copy_[n],!0},getOwnPropertyDescriptor(e,n){const t=H(e),r=Reflect.getOwnPropertyDescriptor(t,n);return r&&{writable:!0,configurable:e.type_!==1||n!=="length",enumerable:r.enumerable,value:t[n]}},defineProperty(){v(11)},getPrototypeOf(e){return ne(e.base_)},setPrototypeOf(){v(12)}},ce={};pe(Ye,(e,n)=>{ce[e]=function(){return arguments[0]=arguments[0][0],n.apply(this,arguments)}});ce.deleteProperty=function(e,n){return ce.set.call(this,e,n,void 0)};ce.set=function(e,n,t){return Ye.set.call(this,e[0],n,t,e[0])};function De(e,n){const t=e[M];return(t?H(t):e)[n]}function xs(e,n,t){var s;const r=Pn(n,t);return r?"value"in r?r.value:(s=r.get)==null?void 0:s.call(e.draft_):void 0}function Pn(e,n){if(!(n in e))return;let t=ne(e);for(;t;){const r=Object.getOwnPropertyDescriptor(t,n);if(r)return r;t=ne(t)}}function ke(e){e.modified_||(e.modified_=!0,e.parent_&&ke(e.parent_))}function Ne(e){e.copy_||(e.copy_=Fe(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ts=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(n,t,r)=>{if(typeof n=="function"&&typeof t!="function"){const o=t;t=n;const l=this;return function(u=o,...c){return l.produce(u,a=>t.call(this,a,...c))}}typeof t!="function"&&v(6),r!==void 0&&typeof r!="function"&&v(7);let s;if(q(n)){const o=rn(this),l=je(n,void 0);let i=!0;try{s=t(l),i=!1}finally{i?ve(o):Ie(o)}return sn(o,r),ln(s,o)}else if(!n||typeof n!="object"){if(s=t(n),s===void 0&&(s=n),s===_n&&(s=void 0),this.autoFreeze_&&Xe(s,!0),r){const o=[],l=[];W("Patches").generateReplacementPatches_(n,s,o,l),r(o,l)}return s}else v(1,n)},this.produceWithPatches=(n,t)=>{if(typeof n=="function")return(l,...i)=>this.produceWithPatches(l,u=>n(u,...i));let r,s;return[this.produce(n,t,(l,i)=>{r=l,s=i}),r,s]},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)||v(8),te(e)&&(e=Es(e));const n=rn(this),t=je(e,void 0);return t[M].isManual_=!0,Ie(n),t}finishDraft(e,n){const t=e&&e[M];(!t||!t.isManual_)&&v(9);const{scope_:r}=t;return sn(r,n),ln(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,n){let t;for(t=n.length-1;t>=0;t--){const s=n[t];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}t>-1&&(n=n.slice(t+1));const r=W("Patches").applyPatches_;return te(e)?r(e,n):this.produce(e,s=>r(s,n))}};function je(e,n){const t=Pe(e)?W("MapSet").proxyMap_(e,n):Le(e)?W("MapSet").proxySet_(e,n):_s(e,n);return(n?n.scope_:En()).drafts_.push(t),t}function Es(e){return te(e)||v(10,e),Ln(e)}function Ln(e){if(!q(e)||Ce(e))return e;const n=e[M];let t;if(n){if(!n.modified_)return n.base_;n.finalized_=!0,t=Fe(e,n.scope_.immer_.useStrictShallowCopy_)}else t=Fe(e,!0);return pe(t,(r,s)=>{Tn(t,r,Ln(s))}),n&&(n.finalized_=!1),t}var F=new Ts,Ps=F.produce;F.produceWithPatches.bind(F);F.setAutoFreeze.bind(F);F.setUseStrictShallowCopy.bind(F);F.applyPatches.bind(F);F.createDraft.bind(F);F.finishDraft.bind(F);const Cn="TOGGLE_ZOOM",On="TOGGLE_PAN",Sn="TOGGLE_POINTS",Dn="TOGGLE_LINE",Nn="TOGGLE_LEGEND",wn="TOGGLE_TABLE",Ge="RESET_AXES_RANGES",ze="UPDATE_AXES_RANGES",An="TOGGLE_DRAG_POINTS",Mn="TOGGLE_DRAG_ANNOTATION",Fn="DISABLE_DRAG_OPTIONS",me="UPDATE_EDITED",Ls=(e,n)=>Ps(e,t=>{switch(n.type){case Cn:{t.zoomEnabled=!t.zoomEnabled,t.panEnabled&&(t.panEnabled=!1),t.enableDragPoints&&(t.enableDragPoints=!1),t.enableDragAnnotation&&(t.enableDragAnnotation=!1);break}case On:{t.panEnabled=!t.panEnabled,t.zoomEnabled&&(t.zoomEnabled=!1),t.enableDragPoints&&(t.enableDragPoints=!1),t.enableDragAnnotation&&(t.enableDragAnnotation=!1);break}case Sn:{t.pointsEnabled=!t.pointsEnabled;break}case Dn:{t.lineEnabled=!t.lineEnabled;break}case Nn:{t.legendEnabled=!t.legendEnabled;break}case wn:{t.showTable=!t.showTable;break}case ze:{const{axes:r}=n.payload;t.axes=r;break}case Ge:{const{axes:r}=n.payload;t.axes=r;break}case An:{t.enableDragPoints=!t.enableDragPoints,t.panEnabled&&(t.panEnabled=!1),t.zoomEnabled&&(t.zoomEnabled=!1),t.enableDragAnnotation&&(t.enableDragAnnotation=!1);break}case Mn:{t.enableDragAnnotation=!t.enableDragAnnotation,t.panEnabled&&(t.panEnabled=!1),t.zoomEnabled&&(t.zoomEnabled=!1);break}case Fn:{(t.enableDragAnnotation||t.enableDragPoints||t.panEnabled||t.zoomEnabled)&&(t.enableDragAnnotation=!1,t.enableDragPoints=!1,t.panEnabled=!1,t.zoomEnabled=!1);break}case me:{t.edited=n.payload;break}}}),Cs=e=>{if(!e)return null;const n=`line-chart-state-${e}`,t=localStorage.getItem(n);return t?JSON.parse(t).state:null},Os=(e=72)=>{const n=new Date().getTime(),t=e*60*60*1e3;for(let r=0;r<localStorage.length;r++){const s=localStorage.key(r);if(s!=null&&s.includes("line-chart-state-")){const o=localStorage.getItem(s);if(o){const i=JSON.parse(o).timestamp;i&&n-i>t&&localStorage.removeItem(s)}}}},Ss=(e,n)=>{if(!n)return;const t=new Date().getTime(),r=`line-chart-state-${n}`,s={state:e,timestamp:t};localStorage.setItem(r,JSON.stringify(s)),Os()},Ds=({options:e,persistenceId:n})=>{const{chartOptions:{enableZoom:t,enablePan:r,showPoints:s,showLine:o,enableDragAnnotation:l},legend:{display:i},dragData:u}=e,{zoomEnabled:c,panEnabled:a,pointsEnabled:d,lineEnabled:y,legendEnabled:m,enableDragPoints:p,enableDragAnnotation:b}=Cs(n)||{};return{zoomEnabled:l??b?!1:c??t,panEnabled:a??r,pointsEnabled:d??s,lineEnabled:y??o,legendEnabled:m??i,axes:[],showTable:!1,enableDragPoints:(u==null?void 0:u.enableDragData)&&p,enableDragAnnotation:l??b,edited:!1}},Ns=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"}))),ws=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})),As=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 Ms({lineEnabled:e,onToggleLine:n,onTogglePoints:t,pointsEnabled:r,translations:s}){return[{type:"Option",label:s.pointsLines,icon:_.jsx(Oe,{icon:_.jsx(As,{})}),selected:r&&e,onClick:()=>{r||t(),e||n()}},{type:"Option",label:s.linesOnly,icon:_.jsx(Oe,{icon:_.jsx(Ns,{})}),selected:!r&&e,onClick:()=>{r&&t(),e||n()}},{type:"Option",label:s.pointsOnly,icon:_.jsx(Oe,{icon:_.jsx(ws,{})}),selected:r&&!e,onClick:()=>{r||t(),e&&n()}}]}const vn=({options:e})=>{const[n,t]=O.useState(!1),r=e.find(s=>s.selected);return _.jsx(Ue,{open:n,setOpen:t,menu:{sections:e,trigger:"Component",component:_.jsx(ye,{display:"inline-flex",text:r==null?void 0:r.label,placement:"bottom-start",enabled:!n,children:_.jsx(X,{colored:"muted",basic:!0,small:!0,round:!0,icon:r==null?void 0:r.icon})})}})};vn.__docgenInfo={description:"",methods:[],displayName:"LineOptions",props:{options:{required:!0,tsType:{name:"Array",elements:[{name:"IMenuSection"}],raw:"IMenuSection[]"},description:""}}};function Fs({onTogglePan:e,onToggleZoom:n,panEnabled:t,zoomEnabled:r,enableDragPoints:s,enableDragAnnotation:o,isDragDataAllowed:l,isDragAnnotationAllowed:i,onToggleDragAnnotation:u,onToggleDragPoints:c,onDisableDragOptions:a,translations:{dragToZoom:d,doubleClickToReset:y,dragToPan:m,dragToMovePoints:p,dragDisabled:b,dragToMoveAnnotation:x}}){return[{label:d,description:y,icon:_.jsx(Lt,{}),selected:r,type:"Option",onClick:()=>{r||n()}},{label:m,description:y,icon:_.jsx(Ct,{}),selected:t,type:"Option",onClick:()=>{t||e()}},...l?[{label:p,icon:_.jsx(Qe,{}),selected:s,type:"Option",onClick:()=>{s||c()}}]:[],...i?[{label:x,icon:_.jsx(Qe,{}),selected:o,type:"Option",onClick:()=>{o||u()}}]:[],{label:b,icon:_.jsx(Ot,{}),selected:!r&&!t&&!s&&!o,type:"Option",onClick:a}]}const In=({options:e})=>{const n=e.find(t=>t.selected);return _.jsx(Ue,{menu:{sections:e,trigger:"Component",component:_.jsx(X,{colored:"muted",basic:!0,small:!0,label:n==null?void 0:n.label,icon:n==null?void 0:n.icon})}})};In.__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 vs="_controls_1edjs_1",Is="_buttons_1edjs_6",un={controls:vs,buttons:Is},ks=e=>{const n=O.useCallback(t=>()=>{e({type:t})},[e]);return{onToggleLegend:n(Nn),onToggleLine:n(Dn),onTogglePan:n(On),onTogglePoints:n(Sn),onToggleTable:n(wn),onToggleZoom:n(Cn),onToggleDragPoints:n(An),onToggleDragAnnotation:n(Mn),onDisableDragOptions:n(Fn)}},js=(e,n)=>e===void 0||n===void 0||Number(e)<Number(n),Gs=(e,n)=>e===void 0||n===void 0||Number(e)>Number(n),kn=(e,n=0,t=!1)=>{const r=t&&n!==0?n+1:"";return`${e}${r}`},zs=e=>{var n;return((n=e==null?void 0:e.match(/[^0-9/]+/gi))==null?void 0:n[0])??""},Vs=e=>e.join(""),Yr=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null,Rs=(e,n)=>{const t=((e==null?void 0:e.axes)||[]).map(({id:r,min:s,max:o})=>`${r}:${s}-${o}`).join("|");return Vs([t,e==null?void 0:e.enableDragPoints,e==null?void 0:e.enableDragAnnotation,e==null?void 0:e.zoomEnabled,e==null?void 0:e.panEnabled,e==null?void 0:e.edited,n])},He=({chartRef:e,state:n,options:t,dispatch:r,generatedDatasets:s})=>{const{interactions:{onHover:o,onUnhover:l},axes:i}=t,u=O.useCallback(()=>{var E,g;const f=e==null?void 0:e.current;f&&(n!=null&&n.edited)&&((E=f==null?void 0:f.resetZoom)==null||E.call(f),(g=f==null?void 0:f.reset)==null||g.call(f),r({type:Ge,payload:{axes:[]}}),r({type:me,payload:!1}))},[e==null?void 0:e.current,r,n]),c=O.useCallback((f,E,g)=>(h,P)=>{var L,C;if(!(P!=null&&P.length)&&l&&f&&(E(null),l(h),(L=e==null?void 0:e.current)==null||L.update()),P!=null&&P.length&&o){const{index:S,datasetIndex:N}=P[0],A=g[N],w=A==null?void 0:A.data[S];w&&!rs(f,w)&&(E(w),o(h,N,S,g),(C=e==null?void 0:e.current)==null||C.update())}},[o,l,s]),a=O.useCallback(()=>es(e),[e==null?void 0:e.current]),d=O.useCallback(f=>{var E,g,h,P,L;if(f.key===Ze.Shift){const C=e.current,S=(h=(g=(E=C==null?void 0:C.config)==null?void 0:E.options)==null?void 0:g.plugins)==null?void 0:h.zoom;(P=S==null?void 0:S.zoom)!=null&&P.mode&&((L=S==null?void 0:S.pan)!=null&&L.mode)&&(S.zoom.mode=J.Y,S.pan.mode=J.Y,C==null||C.update())}},[e==null?void 0:e.current]),y=O.useCallback(f=>{var E,g,h,P,L;if(f.key===Ze.Shift){const C=e.current,S=(h=(g=(E=C==null?void 0:C.config)==null?void 0:E.options)==null?void 0:g.plugins)==null?void 0:h.zoom;(P=S==null?void 0:S.zoom)!=null&&P.mode&&((L=S==null?void 0:S.pan)!=null&&L.mode)&&(S.zoom.mode=J.XY,S.pan.mode=J.XY,C==null||C.update())}},[e==null?void 0:e.current]),m=O.useCallback(f=>{var g;if(!((g=Object.keys(f))!=null&&g.length))return[];const E=(h,P)=>{var L;return!h[P]||!((L=h[P])!=null&&L.length)?[]:h[P].map((C,S)=>({id:kn(P,S,h[P].length>1),label:(C==null?void 0:C.label)||""}))};return[...E(f,U.X),...E(f,U.Y)]},[i]),p=O.useCallback(()=>{var g;const{scales:f={}}=(e==null?void 0:e.current)||{},E=(g=Object.entries(f))==null?void 0:g.map(([h,{min:P,max:L}])=>({id:h,min:P??0,max:L??0}));r({type:ze,payload:{axes:E}})},[i]),b=O.useCallback(()=>{var E,g;const f=e==null?void 0:e.current;f&&n.edited&&((E=f==null?void 0:f.resetZoom)==null||E.call(f),(g=f==null?void 0:f.reset)==null||g.call(f),r({type:Ge,payload:{axes:[]}}),r({type:me,payload:!1}))},[e==null?void 0:e.current]),x=O.useCallback(({axes:f})=>{r({type:ze,payload:{axes:f}})},[]),T=O.useCallback(f=>{r({type:me,payload:f})},[n]);return{resetZoom:u,onHover:c,handleDownload:a,handleKeyDown:d,handleKeyUp:y,controlsAxesLabels:m(i),updateAxesRangesFromChart:p,onResetAxes:b,onUpdateAxes:x,onUpdateEdited:T}},an=(e,n,t)=>{const r=[];return Yn(e)&&r.push("mustHaveAValue"),t==="min"&&!js(e,n)?r.push("mustBeLessThanMax"):t==="max"&&!Gs(e,n)&&r.push("mustBeGreaterThanMin"),r},Bs=e=>{const n=e.map(({id:r,min:s,max:o})=>({id:r,min:an(String(s),String(o),"min"),max:an(String(o),String(s),"max")})),t=n.every(r=>r.min.length===0&&r.max.length===0);return{errors:n,valid:t}},cn=1,dn=({chartRef:e,state:n})=>{const t=e==null?void 0:e.current;if(!t)return[];const r=(t==null?void 0:t.getInitialScaleBounds())??{};return Object.entries(r).map(([s,{min:o="",max:l=""}])=>{var a;let i=Number(o),u=Number(l);isNaN(i)&&(i=0),isNaN(u)&&(u=i+cn),i===u&&(u+=cn);const{unit:c}=((a=n==null?void 0:n.axes)==null?void 0:a.find(d=>d.id===s))??{};return{id:s,min:i,max:u,unit:c}})},Us=e=>{var E;const{state:n,controlsAxesLabels:t,onUpdateAxes:r,onResetAxes:s,onUpdateEdited:o,depthType:l,translations:i,close:u,chartRef:c}=e??{},[a,d]=O.useState({localAxes:dn({chartRef:c,state:n}),depthType:l==null?void 0:l.selectedDepthType,edited:n.edited}),{errors:y,valid:m}=Bs(a.localAxes),p=({name:g,value:h,id:P})=>{d(L=>({...L,localAxes:L.localAxes.map(C=>C.id===P?{...C,[g]:h}:C),edited:!0}))},b=({name:g,value:h,id:P})=>{d(L=>({...L,localAxes:L.localAxes.map(C=>C.id===P&&typeof C.unit=="object"?{...C,unit:{...C.unit,[g]:h}}:C),edited:!0}))},x=g=>{g.preventDefault(),m&&(r({axes:a.localAxes}),u==null||u()),l&&(l!=null&&l.setSelectedDepthType)&&(l==null||l.setSelectedDepthType(a.depthType)),o(a.edited)},T=()=>{d({localAxes:dn({chartRef:c,state:n}),depthType:l==null?void 0:l.selectedDepthType,edited:!1}),s(),o(!1),u==null||u()},f=g=>g.target.select();return _.jsxs("form",{onSubmit:x,children:[a.localAxes.map(g=>{var C,S;const h=t.find(N=>N.id===g.id),P=(h==null?void 0:h.label)||D.startCase(g.id),L=y.find(N=>N.id===g.id);return _.jsx(Nt,{label:P,children:_.jsxs(wt,{small:!0,width:"300px",children:[_.jsx(en,{name:"min",value:g.min,error:(C=L==null?void 0:L.min)!=null&&C[0]?i[L.min[0]]:null,width:"100%",onChange:N=>p({name:N.target.name,value:N.target.value,id:g.id}),onFocus:f}),_.jsx(At,{children:"to"}),_.jsx(en,{name:"max",value:g.max,error:(S=L==null?void 0:L.max)!=null&&S[0]?i[L.max[0]]:null,width:"100%",onChange:N=>p({name:N.target.name,value:N.target.value,id:g.id}),onFocus:f}),g.unit?_.jsx(Mt,{name:"selectedUnit",options:typeof g.unit!="string"?g.unit.options:[],value:typeof g.unit!="string"?g.unit.selectedUnit:void 0,onChange:N=>b({name:N.target.name,value:N.target.value,id:g.id}),autoLayerWidth:!0,width:"15%"}):null]})},g.id)}),((E=l==null?void 0:l.options)==null?void 0:E.length)>0&&_.jsxs(_.Fragment,{children:[_.jsx(Ft,{items:l.options.map((g,h)=>({key:h,label:g})),onSelected:g=>{d(h=>({...h,depthType:l.options[g],edited:!0}))},small:!0,value:l.options.indexOf(a.depthType)}),_.jsx(vt,{})]}),_.jsxs(It,{gap:"8px",alignItems:"center",children:[_.jsx(X,{type:"submit",small:!0,colored:!0,label:i.done,disabled:!m||!a.edited}),_.jsx(X,{small:!0,name:"resetAxes",label:i.resetAxes,onClick:T}),_.jsx(hn,{small:!0,muted:!0,children:i.orDoubleClickToCanvas})]})]})},jn=e=>_.jsx(St,{placement:"bottom-start",overflowContainer:!0,content:_.jsx(Us,{...e}),children:_.jsx(ye,{text:e.translations.axesOptions,placement:"bottom-start",display:"inline-flex",children:_.jsx(X,{small:!0,basic:!0,colored:"muted",round:!0,icon:_.jsx(Dt,{})})})});jn.__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:""},onUpdateEdited:{required:!0,tsType:{name:"signature",type:"function",raw:"(edited: boolean) => void",signature:{arguments:[{type:{name:"boolean"},name:"edited"}],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 Gn=({table:e,headerComponent:n,subheaderComponent:t,chartRef:r,state:s,options:o,dispatch:l,generatedDatasets:i,translations:u,controlsPortalId:c})=>{const{enableDragPoints:a,lineEnabled:d,panEnabled:y,pointsEnabled:m,showTable:p,zoomEnabled:b,enableDragAnnotation:x}=s,{dragData:T,depthType:f,annotations:E}=o,{onToggleLine:g,onTogglePan:h,onTogglePoints:P,onToggleTable:L,onToggleZoom:C,onToggleDragPoints:S,onToggleDragAnnotation:N,onDisableDragOptions:A}=ks(l),{handleDownload:w,controlsAxesLabels:$,onResetAxes:G,onUpdateAxes:se,onUpdateEdited:z}=He({chartRef:r,state:s,options:o,dispatch:l,generatedDatasets:i}),[V,{width:re}]=kt(),Y=re<200,R=O.useMemo(()=>Ms({lineEnabled:d,onToggleLine:g,onTogglePoints:P,pointsEnabled:m,translations:u}),[d,m]),B=O.useMemo(()=>Fs({onTogglePan:h,onToggleZoom:C,panEnabled:y,zoomEnabled:b,enableDragPoints:a,enableDragAnnotation:x,isDragDataAllowed:T==null?void 0:T.enableDragData,isDragAnnotationAllowed:E==null?void 0:E.enableDragAnnotation,onToggleDragAnnotation:N,onToggleDragPoints:S,onDisableDragOptions:A,translations:u}),[b,y,a,T==null?void 0:T.enableDragData,E==null?void 0:E.enableDragAnnotation]);return _.jsxs(_.Fragment,{children:[_.jsxs("div",{className:un.controls,children:[!!o.title&&_.jsx(hn,{bold:!0,children:o.title}),n,_.jsx(ns,{controlsPortalId:c??"",children:_.jsxs("div",{className:un.buttons,ref:V,children:[!p&&_.jsxs(_.Fragment,{children:[_.jsx(jn,{chartRef:r,state:s,controlsAxesLabels:$,onUpdateAxes:se,onResetAxes:G,onUpdateEdited:z,depthType:f,translations:u}),Y?_.jsx(Ue,{menu:{placement:"bottom-end",sections:[...R,{type:"Divider"},...B,{type:"Divider"},{icon:"download",label:u.downloadAsPNG,type:"Option",onClick:w}],trigger:"Component",component:_.jsx(X,{colored:"muted",basic:!0,small:!0,round:!0,icon:"menu"})}}):_.jsxs(_.Fragment,{children:[_.jsx(vn,{options:R}),_.jsx(ye,{display:"inline-flex",text:u.downloadAsPNG,placement:"bottom-end",children:_.jsx(X,{small:!0,basic:!0,colored:"muted",round:!0,icon:"download",onClick:w})}),_.jsx(In,{options:B})]})]}),e?_.jsx(ye,{display:"inline-flex",text:p?u.showChart:u.showTable,placement:"bottom-end",children:_.jsx(X,{small:!0,basic:!0,colored:"muted",round:!0,icon:p?"chart":"table",onClick:L})}):null]})})]}),t]})};Gn.__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 I={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"},fn=e=>({label:"",position:e,color:"",unit:{options:[],selectedUnit:"",setSelectedUnit:()=>{}}}),Xs=e=>({x:(e==null?void 0:e.x)||[fn("bottom")],y:(e==null?void 0:e.y)||[fn("left")]}),Ys=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}}),qs=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}),Ws=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}),$s=e=>e?e.map(n=>({...n,display:(n==null?void 0:n.display)??!0})):[],Zs=e=>{var n,t,r,s,o,l,i,u;return{labelAnnotation:{showLabel:((n=e==null?void 0:e.labelAnnotation)==null?void 0:n.showLabel)??!1,text:((t=e==null?void 0:e.labelAnnotation)==null?void 0:t.text)??"",position:((r=e==null?void 0:e.labelAnnotation)==null?void 0:r.position)??I.BOTTOM_RIGHT,fontSize:((s=e==null?void 0:e.labelAnnotation)==null?void 0:s.fontSize)??12,xOffset:((o=e==null?void 0:e.labelAnnotation)==null?void 0:o.xOffset)??5,yOffset:((l=e==null?void 0:e.labelAnnotation)==null?void 0:l.yOffset)??5,maxWidth:((i=e==null?void 0:e.labelAnnotation)==null?void 0:i.maxWidth)??300,lineHeight:((u=e==null?void 0:e.labelAnnotation)==null?void 0:u.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:$s(e==null?void 0:e.annotationsData)}},Ks=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)??k.Center,customLegend:(e==null?void 0:e.customLegend)??{customLegendPlugin:null,customLegendContainerID:""},usePointStyle:(e==null?void 0:e.usePointStyle)??!0}),Js=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}),Qs=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}),er=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}),zn=e=>{const n=(e==null?void 0:e.chart)||{},t=(n==null?void 0:n.options)||{};return{persistenceId:(n==null?void 0:n.persistenceId)??"",controlsPortalId:(n==null?void 0:n.controlsPortalId)??"",testId:(n==null?void 0:n.testId)??void 0,data:(n==null?void 0:n.data)??{datasets:[]},options:{title:(t==null?void 0:t.title)??"",scales:(t==null?void 0:t.scales)??{},axes:Xs(t==null?void 0:t.axes),additionalAxesOptions:Ys(t==null?void 0:t.additionalAxesOptions),chartStyling:Hs(t==null?void 0:t.chartStyling),tooltip:qs(t==null?void 0:t.tooltip),graph:Ws(t==null?void 0:t.graph),annotations:Zs(t==null?void 0:t.annotations),legend:Ks(t==null?void 0:t.legend),chartOptions:Js(t==null?void 0:t.chartOptions),interactions:Qs(t==null?void 0:t.interactions),dragData:er(t==null?void 0:t.dragData),depthType:(t==null?void 0:t.depthType)??{}}}},nr=(e,n)=>{if(D.isEmpty(e)||D.isEmpty(n))return!1;const t=r=>typeof n=="string"?r&&D.has(r,n):D.isArray(n)?r&&D.some(n,s=>r&&D.has(r,s)):r&&D.some(Object.values(n),s=>r&&D.has(r,s));return D.isArray(e)?D.some(e,t):t(e)};var Vn=(e=>(e.showLine="showLine",e.showPoints="showPoints",e))(Vn||{});const tr=(e,n,t,{label:r})=>{const s=[...e??[]],{annotations:o,graph:l}=t??{},{controlAnnotation:i,showAnnotations:u,annotationsData:c=[]}=o??{};if(i&&u){const a=c.map((d,y)=>{const{type:m,...p}=d,b=p.color??Q[y],x=Hn,T=Re.INITIAL;return{...p,isAnnotation:!0,annotationType:m,label:p.label,annotationIndex:y,backgroundColor:b,pointBackgroundColor:b,borderColor:b,borderDash:x,borderWidth:T,data:[{}]}});s.push(...a)}return s==null?void 0:s.map((a,d)=>{var B,qe;const{formation:y,data:m=[],pointRadius:p,pointHoverRadius:b,borderWidth:x,borderColor:T,backgroundColor:f,pointBackgroundColor:E,borderDash:g,showPoints:h,showLine:P}=a??{},{lineEnabled:L,pointsEnabled:C,axes:S=[]}=n??{},{lineTension:N,spanGaps:A}=l??{},w=Array.isArray(m)?m:[];if(y&&(w!=null&&w.length)){const We=Number((B=S[0])==null?void 0:B.min),$e=Number((qe=S[0])==null?void 0:qe.max),[de,fe]=w;We&&(de!=null&&de.x)&&(w[0].x=Math.max(We,de.x)),$e&&(fe!=null&&fe.x)&&(w[2].x=Math.min($e,fe.x))}const $=nr(a,Vn),G=(w==null?void 0:w.filter(Boolean))||[],se=(G==null?void 0:G.length)===1;let z,V;h!==void 0?z=h:P===!1?z=!0:z=C||se,P!==void 0?V=P:h===!1?V=!0:V=L;const re=parseFloat(p)||Gt,Y=parseFloat(b)||jt,R=Q[d];return{...a,label:(a==null?void 0:a.label)??`${r} ${d+1}`,data:G,showLine:V,lineTension:(a==null?void 0:a.lineTension)??N,spanGaps:A,borderWidth:parseFloat(x)||Rt,borderDash:g||[],borderJoinStyle:Vt,borderColor:T??R??we(Q),backgroundColor:f??zt,pointBackgroundColor:E??R??we(Q),pointRadius:z?re:0,pointHoverRadius:Y,pointHitRadius:(a==null?void 0:a.pointHitRadius)??Y,...$?{hasCustomOpt:$}:{}}})},Ve=(e,n,t,r,s=0)=>{var a,d,y,m,p,b,x;const o=r||e.axes[n][0]||{},l=t==null?void 0:t.axes.filter(T=>{var f;return(f=T==null?void 0:T.id)==null?void 0:f.startsWith(n)})[s],i=(d=(a=e==null?void 0:e.scales)==null?void 0:a[`${s===0?n:n+s}`])==null?void 0:d.ticks,{additionalAxesOptions:u}=e,c=()=>{const T=(u==null?void 0:u.chartScaleType)===Wn.Logarithmic,f=(h,P,L)=>T?Zn.includes(h)?nn(h,L):"":nn(h,L);return{...T?{}:{stepSize:o.stepSize??(n===U.Y?u.stepSize:null)},callback:f,includeBounds:!1,...i,font:{size:$n}}};return{display:!0,type:u.chartScaleType,position:o.position,beginAtZero:u.beginAtZero,reverse:n===U.Y?u.reverse:!1,suggestedMax:u.suggestedMax,suggestedMin:u.suggestedMin,min:(l==null?void 0:l.min)??((m=(y=u==null?void 0:u.range)==null?void 0:y[n])==null?void 0:m.min),max:(l==null?void 0:l.max)??((b=(p=u==null?void 0:u.range)==null?void 0:p[n])==null?void 0:b.max),title:{display:(x=o.label)==null?void 0:x.length,text:o.label,padding:0},ticks:c(),grid:{...o.gridLines}}},gn=(e,n,t)=>e.axes[n].reduce((o,l,i)=>{const u=l;u.color=l.color||Q[i]||we(Q),u.position=l.position||qn(n,i);const c=Ve(e,n,t,u,i),a=kn(n,i,!0);return{...o,[a]:c}},{}),sr=(e,n)=>{var l,i;const t=((l=e.axes.x)==null?void 0:l.length)>1,r=((i=e.axes.y)==null?void 0:i.length)>1,s=t?gn(e,U.X,n):{x:Ve(e,U.X,n)},o=r?gn(e,U.Y,n):{y:Ve(e,U.Y,n)};return{...s,...o}},rr=e=>{var t;if(!Array.isArray(e)||!(e!=null&&e.length))return!1;const n=e==null?void 0:e.reduce((r,s)=>{var u,c,a,d;const o=(s==null?void 0:s.xAxisID)??"x",l=(s==null?void 0:s.yAxisID)??"y",i=(s==null?void 0:s.data)??[];if(i&&(i!=null&&i.length)){const{x:y,y:m}=(i==null?void 0:i[0])??{},{x:p=0,y:b=0}=(i==null?void 0:i.at(-1))??{},x=((u=r==null?void 0:r[o])==null?void 0:u.xFirst)??y,T=((c=r==null?void 0:r[o])==null?void 0:c.xLast)??p,f=((a=r==null?void 0:r[l])==null?void 0:a.yFirst)??m,E=((d=r==null?void 0:r[l])==null?void 0:d.yLast)??b,g=Math.min(y,x),h=Math.max(p,T),P=Math.min(m,f),L=Math.max(b,E);r={...r,[o]:{...r[o],xFirst:g,xLast:h},[l]:{yFirst:P,yLast:L}}}return r},{});return(t=Object.values(n))==null?void 0:t.some(({xFirst:r,xLast:s,yFirst:o,yLast:l})=>ie(r,s,{absoluteDiff:ue})||ie(o,l,{absoluteDiff:ue}))},mn=.05,lr={min:-1,max:1},or=({data:e,beginAtZero:n=!1,autoAxisPadding:t=!1})=>{const r=Math.min(...e.filter(m=>m!=null&&!isNaN(m))),s=Math.max(...e.filter(m=>m!=null&&!isNaN(m))),o=Math.sign(r)===-1||Math.sign(s)===-1,l=ie(r,0,{absoluteDiff:ue})&&ie(s,0,{absoluteDiff:ue});if(!(e!=null&&e.length)||l)return lr;if(ie(r,s,{absoluteDiff:ue})){const m=s,p=m*mn,b=n&&!o?0:m-p,x=n&&o?0:m+p,T=ee(x,ge),f=ee(b,ge);return{min:T<0?T:f,max:f<0?f:T}}if(!t)return{min:void 0,max:void 0};const i=r===0||s===0||n,u=Math.sign(r)===-1&&Math.sign(s)===1,c=Math.abs(s-r),a=t?c*mn:0,d=!u&&i&&n&&!o?0:r-a,y=!u&&i&&n&&o?0:s+a;return{min:ee(d,ge),max:ee(y,ge)}},ir=e=>e==null?void 0:e.reduce((n,t)=>({...n,[t.annotationAxis]:[...n[t.annotationAxis]||[],+t.value]}),{}),ur=(e,n,t)=>{if(!Array.isArray(e)||!Array.isArray(n))return{};const r=ir(t);return n.reduce((s,o)=>{const l=zs(o),i=e.filter(c=>(c[`${l}AxisID`]??l)===o).flatMap(c=>((c==null?void 0:c.data)??[]).map(d=>d[l])),u=(r==null?void 0:r[o])??[];return s[o]=[...new Set([...i,...u])],s},{})},bn=(e,n)=>!D.isNil(e)||!D.isNil(n),ar=(e,n,t)=>{const{additionalAxesOptions:r,annotations:{annotationsData:s=[],controlAnnotation:o=!1}={}}=e||{},l=sr(e,n)||{},i=o?t.filter(({isAnnotation:d})=>!d):t;if(!(r!=null&&r.autoAxisPadding)&&!rr(i))return l;const u=Object.keys(l)??[],c=ur(t,u,s);return(c&&(u==null?void 0:u.reduce((d,y)=>{const m=l[y],{min:p=void 0,max:b=void 0}=m,{min:x,max:T}=or({data:c[y],beginAtZero:r==null?void 0:r.beginAtZero,autoAxisPadding:r==null?void 0:r.autoAxisPadding}),f={[y]:{...m,min:p??(bn(p,b)?void 0:x),max:b??(bn(p,b)?void 0:T)}};return{...d,...f}},{})))??l},cr=(e,n,t,r,s)=>{const l=e??0,i=n??0,u=t??0,c=r??0,a=s??0,d=l-100<=u,y=l+100>=c,m=l+100>=u&&l+100<c&&i+100>=a;return{overLeftSide:d,overRightSide:y,overBottomSide:m}},dr=e=>{var y,m;const n=e==null?void 0:e.chart,t=(e==null?void 0:e.dataIndex)??0,r=(e==null?void 0:e.datasetIndex)??0,s=(n==null?void 0:n.chartArea)??{},{left:o=null,right:l=null,bottom:i=null}=s,u=(y=n==null?void 0:n.getDatasetMeta)==null?void 0:y.call(n,r),c=(m=u==null?void 0:u.data)==null?void 0:m[t],a=(c==null?void 0:c.x)??null,d=(c==null?void 0:c.y)??null;return{x:a,y:d,left:o,right:l,bottom:i}},fr=()=>e=>{const{x:n,y:t,left:r,right:s,bottom:o}=dr(e),{overLeftSide:l=!1,overRightSide:i=!1,overBottomSide:u=!1}=cr(n,t,r,s,o);return l&&k.Right||i&&k.Left||u&&k.End||k.Start},gr=e=>{var n;return(n=e==null?void 0:e.graph)!=null&&n.showDataLabels?{display:Ae,align:fr(),formatter:(t,r)=>{var o,l;const s=(l=(o=r==null?void 0:r.dataset)==null?void 0:o.data)==null?void 0:l[r.dataIndex];return!s||s.label==null?"":typeof s.label=="string"?s.label:Array.isArray(s.label)?s.label.map(String):String(s.label)}}:{display:!1}},mr=e=>{const n=e==null?void 0:e.match(/\[(.*)\]/g);return n&&(n==null?void 0:n.length)>0?n==null?void 0:n[0]:""},yn=(e,n)=>{let t={};return n?(Math.abs(e)<Bt||Math.abs(e)>Ut)&&(t={roundScientificCoefficient:3}):t={scientific:!1},nt(tt(e),t)},br=e=>{var o,l,i,u,c;if(!((l=(o=e==null?void 0:e.axes)==null?void 0:o.x)!=null&&l.length)||!((u=(i=e==null?void 0:e.axes)==null?void 0:i.y)!=null&&u.length))return console.warn("Tooltip config fallback: missing axes",e),{enabled:!1,callbacks:{}};const{scientificNotation:n}=(e==null?void 0:e.tooltip)??{},t=({xAxisID:a="",yAxisID:d=""})=>{var x,T,f,E,g,h,P;const y=(a==null?void 0:a.length)>1?Number(a==null?void 0:a[1])-1:0,m=(d==null?void 0:d.length)>1?Number(d==null?void 0:d[1])-1:0,p=(T=(x=e==null?void 0:e.axes)==null?void 0:x.x)==null?void 0:T[y],b=(E=(f=e==null?void 0:e.axes)==null?void 0:f.y)==null?void 0:E[m];return((P=(h=(g=e==null?void 0:e.axes)==null?void 0:g.x)==null?void 0:h[0])==null?void 0:P.position)===oe.Top?{titleAxisLabel:(b==null?void 0:b.label)||"",valueAxisLabel:(p==null?void 0:p.label)||"",titleLabel:Z.Y,valueLabel:Z.X}:{titleAxisLabel:(p==null?void 0:p.label)||"",valueAxisLabel:(b==null?void 0:b.label)||"",titleLabel:Z.X,valueLabel:Z.Y}},r=a=>{var x,T,f,E;if(!(a!=null&&a[0]))return"";const d=t(a[0].dataset),{titleLabel:y="",titleAxisLabel:m=""}=d??{},p=y===Z.Y?(T=(x=a==null?void 0:a[0])==null?void 0:x.parsed)==null?void 0:T.y:(E=(f=a==null?void 0:a[0])==null?void 0:f.parsed)==null?void 0:E.x;return`${yn(p,n)} ${m}`},s=a=>{var g;const{showLabelsInTooltips:d}=(e==null?void 0:e.tooltip)??{};let y=((g=a==null?void 0:a.dataset)==null?void 0:g.label)||"";const m=t(a==null?void 0:a.dataset),{valueLabel:p="",valueAxisLabel:b=""}=m??{},T=(()=>{var P,L;const h=p===Z.X?(P=a==null?void 0:a.parsed)==null?void 0:P.x:(L=a==null?void 0:a.parsed)==null?void 0:L.y;return yn(h,n)})(),f=mr(b),E=et(a,d);return`${y}: ${T} ${f} ${E}`};return{enabled:(c=e==null?void 0:e.tooltip)==null?void 0:c.tooltips,mode:be.Nearest,intersect:!0,padding:Qn,usePointStyle:!0,boxWidth:Ke,boxHeight:Ke,boxPadding:Jn,callbacks:{title:r,label:s,afterLabel:Kn}}},yr=({chartRef:e,state:n,options:t,dispatch:r,generatedDatasets:s})=>{const{interactions:{onAnimationComplete:o},annotations:{labelAnnotation:{showLabel:l,text:i,position:u,fontSize:c,xOffset:a,yOffset:d,maxWidth:y,lineHeight:m}={}},chartStyling:{layoutPadding:p}}=t,{enableDragPoints:b,zoomEnabled:x,panEnabled:T,lineEnabled:f}=n,[E,g]=O.useState(null),{updateAxesRangesFromChart:h,onHover:P,onUpdateEdited:L}=He({chartRef:e,state:n,options:t,dispatch:r,generatedDatasets:s}),{legend:C,customLegendPlugin:S}=Xt({chartRef:e,options:t})??{},{state:N}=Yt()??{},{annotation:A}=N??{},w=gr(t)??{},$=br(t)??{},G=O.useMemo(()=>ar(t,n,s),[t,n,s,e]),se=O.useMemo(()=>b&&ts(t),[b,t]),z=O.useMemo(()=>({enabled:T,mode:J.XY,onPanComplete(){h(),L(!0)}}),[T]),V=O.useMemo(()=>({mode:J.XY,drag:{enabled:x,threshold:3,backgroundColor:Ht,borderColor:Je,borderWidth:1},onZoomComplete(){h(),L(!0)}}),[x]),re={datalabels:w,annotationDraggerPlugin:{enabled:n==null?void 0:n.enableDragAnnotation},annotation:qt(A),zoom:{pan:z,zoom:V},tooltip:$,legend:{...C,display:!1,events:[]},customLegendPlugin:S,chartAreaBorder:{borderColor:Je},chartAreaText:{showLabel:l,text:i,position:u,fontSize:c,xOffset:a,yOffset:d,maxWidth:y,lineHeight:m},...se};return O.useMemo(()=>{var Y,R,B;return{layout:{padding:p},onHover:P(E,g,s),maintainAspectRatio:(Y=t==null?void 0:t.chartStyling)==null?void 0:Y.maintainAspectRatio,aspectRatio:(R=t==null?void 0:t.chartStyling)!=null&&R.squareAspectRatio?1:0,animation:(B=t==null?void 0:t.chartStyling)!=null&&B.performanceMode?!1:{duration:rt.FAST,onComplete:o},hover:{mode:be.Nearest,intersect:!0},elements:{line:{pointStyle:st.Circle,showLine:f,tension:0}},scales:G,plugins:re,events:Object.values(lt)}},[n,t,e,s])},pr=({options:e,resetZoom:n})=>{const{graph:t,legend:r}=e,s=O.useCallback((o,l)=>{const{event:i}=l;return i.type===Wt?(n(),!1):!0},[n]);return O.useMemo(()=>[...ot(t,r),{id:"customEventCatcher",beforeEvent:s}],[s])},hr=(e,n)=>{var t,r;O.useEffect(()=>{var s,o;if((o=(s=n==null?void 0:n.legend)==null?void 0:s.customLegend)!=null&&o.customLegendPlugin){const l=document.getElementById(n.legend.customLegend.customLegendContainerID);l!==null&&(l.style.visibility=e.legendEnabled?"visible":"hidden")}},[(r=(t=n==null?void 0:n.legend)==null?void 0:t.customLegend)==null?void 0:r.customLegendPlugin,e.legendEnabled])},_r=(e,n)=>{O.useEffect(()=>{Ss(e,n)},[e.panEnabled,e.lineEnabled,e.pointsEnabled,e.legendEnabled,e.enableDragPoints,e.zoomEnabled])},xr=({options:e,state:n,persistenceId:t})=>{const r=O.useMemo(()=>n,[n]),s=O.useMemo(()=>e,[e]);_r(r,t),hr(r,s)},xe=" ",Tr="rgba(0, 0, 0, 0.5)",Er=e=>{var n;return(n=Array.isArray(e)?e.join(xe):e)==null?void 0:n.split(xe)},Pr=({ctx:e,lines:n,lineHeight:t,x:r,y:s,position:o})=>{n==null||n.forEach((l,i)=>{const u=o!=null&&o.includes("top")?s+t*(i+1)-5:s-(n.length-1-i)*t;e==null||e.fillText(l,r,u)})},Lr=(e,n)=>{const s=n<500?.5:n<700?.7:1;return e*s},Cr=e=>{var s,o,l,i,u,c,a;const{legend:n}=e??{},t=n&&(n!=null&&n.display)&&((s=n==null?void 0:n.options)==null?void 0:s.position)==="left"?(n==null?void 0:n.width)+((l=(o=n==null?void 0:n.options)==null?void 0:o.labels)==null?void 0:l.padding)*2:0,r=n&&n.display&&(((i=n==null?void 0:n.options)==null?void 0:i.position)==="top"||((u=n==null?void 0:n.options)==null?void 0:u.position)==="bottom")?(n==null?void 0:n.height)+((a=(c=n==null?void 0:n.options)==null?void 0:c.labels)==null?void 0:a.padding)*2:0;return{legendWidth:t,legendHeight:r}},Or=(e,n,t,r)=>{const{chartArea:s,width:o}=n??{},l=o-8,{legendWidth:i,legendHeight:u}=Cr(n)??{};switch(e){case I.TOP_LEFT:return[(s==null?void 0:s.left)+t+i,(s==null?void 0:s.top)+r+u];case I.TOP_CENTER:return[(s==null?void 0:s.left)+(s==null?void 0:s.width)/2,(s==null?void 0:s.top)+r+u];case I.TOP_RIGHT:return[l-t,(s==null?void 0:s.top)+r+u];case I.MIDDLE_LEFT:return[(s==null?void 0:s.left)+t+i,(s==null?void 0:s.top)+(s==null?void 0:s.height)/2];case I.MIDDLE_CENTER:return[(s==null?void 0:s.left)+(s==null?void 0:s.width)/2,(s==null?void 0:s.top)+(s==null?void 0:s.height)/2];case I.MIDDLE_RIGHT:return[l-t-i,(s==null?void 0:s.top)+(s==null?void 0:s.height)/2];case I.BOTTOM_LEFT:return[(s==null?void 0:s.left)+t+i,(s==null?void 0:s.bottom)-r-u];case I.BOTTOM_CENTER:return[(s==null?void 0:s.left)+(s==null?void 0:s.width)/2,(s==null?void 0:s.bottom)-r-u];case I.BOTTOM_RIGHT:default:return[l-t-i,(s==null?void 0:s.bottom)-r-u]}},Sr=e=>e!=null&&e.includes(k.Center)?k.Center:e!=null&&e.includes(k.Left)?k.Left:k.Right,Dr=(e,n,t)=>{let r="",s=[];for(let o=0;o<e.length;o++){const l=`${r}${e==null?void 0:e[o]}${xe}`,{width:i}=(t==null?void 0:t.measureText(l))??{};i>n?(s.push(r==null?void 0:r.trim()),r=`${e==null?void 0:e[o]}${xe}`):r=l}return s.push(r.trim()),s},Nr=(e,n)=>{var d,y;if(!e)return;const{text:t,maxWidth:r,fontSize:s,lineHeight:o,x:l,y:i,position:u}=n??{},c=Er(t),a=Dr(c,r,e);(d=e==null?void 0:e.save)==null||d.call(e),e.font=`${s}px Arial`,e.fillStyle=Tr,e.textAlign=Sr(u),Pr({ctx:e,lines:a,lineHeight:o,x:l,y:i,position:u}),(y=e==null?void 0:e.restore)==null||y.call(e)},wr={id:"chartAreaText",beforeDraw:(e,n,t)=>{const{showLabel:r,text:s,fontSize:o,xOffset:l,yOffset:i,lineHeight:u,maxWidth:c,position:a}=t??{};if(!r||!s)return;const{ctx:d,chartArea:y}=e??{};if(!d||!y)return;const m=Lr(c,y.width),[p,b]=Or(a,e,l,i);Nr(d,{text:s,maxWidth:m,fontSize:o,lineHeight:u,x:p,y:b,position:a})}},Rn=(e,n,t,r,s)=>{const o=n.getBoundingClientRect(),l=e.clientX-o.left,i=e.clientY-o.top,u=t==null?void 0:t[r],c=t==null?void 0:t[s],a=(u==null?void 0:u.getValueForPixel(l))??-1,d=(c==null?void 0:c.getValueForPixel(i))??-1;return{x:a,y:d}},Te=e=>{const{xMin:n,xMax:t,yMin:r,yMax:s,xValue:o,yValue:l,type:i}=e??{};let u,c,a,d;return!D.isNil(n)&&!D.isNil(t)&&!D.isNil(r)&&!D.isNil(s)&&i===j.BOX?(u=(n+t)/2,c=(r+s)/2,a=t-n,d=s-r):!D.isNil(o)&&!D.isNil(l)&&i===j.POINT&&(u=o,c=l,a=0,d=0),{centerX:u,centerY:c,width:a,height:d}},Bn=(e,n,t,r)=>{const{xMin:s,xMax:o,yMin:l,yMax:i,xValue:u,yValue:c,type:a}=e??{};let d,y,m,p;const b=n==null?void 0:n[t],x=n==null?void 0:n[r];if(!b||!x)return{centerX:-1,centerY:-1,width:0,height:0};if(!D.isNil(s)&&!D.isNil(o)&&!D.isNil(l)&&!D.isNil(i)&&a===j.BOX){const T=(s+o)/2,f=(l+i)/2,E=(b==null?void 0:b.getPixelForValue(s))??0,g=(b==null?void 0:b.getPixelForValue(o))??0,h=(x==null?void 0:x.getPixelForValue(l))??0,P=(x==null?void 0:x.getPixelForValue(i))??0;m=E-g,p=h-P,d=(b==null?void 0:b.getPixelForValue(T))??-1,y=(x==null?void 0:x.getPixelForValue(f))??-1}else!D.isNil(u)&&!D.isNil(c)&&a===j.POINT&&(m=0,p=0,d=(b==null?void 0:b.getPixelForValue(u))??-1,y=(x==null?void 0:x.getPixelForValue(c))??-1);return{centerX:d,centerY:y,width:m,height:p}},Ar=({x:e,y:n,chartArea:t,scales:r,metrics:s,resizable:o=!1,dragRange:l,annotationType:i,xScaleID:u,yScaleID:c})=>{if(o&&!l)return!0;if(l){const x=e!==void 0&&l.x?e>=l.x[0]&&e<=l.x[1]:!0,T=n!==void 0&&l.y?n>=l.y[0]&&n<=l.y[1]:!0;return x&&T}const a=r==null?void 0:r[u],d=r==null?void 0:r[c];if(!(r!=null&&r[u])||!(r!=null&&r[c]))return!1;const y=(a==null?void 0:a.getValueForPixel(t.left))??Number.NEGATIVE_INFINITY,m=(a==null?void 0:a.getValueForPixel(t.right))??Number.POSITIVE_INFINITY,p=(d==null?void 0:d.getValueForPixel(t.bottom))??Number.NEGATIVE_INFINITY,b=(d==null?void 0:d.getValueForPixel(t.top))??Number.POSITIVE_INFINITY;if(i===j.POINT){const x=e!==void 0?e>=y&&e<=m:!0,T=n!==void 0?n>=p&&n<=b:!0;return x&&T}if(i===j.BOX&&s.width!==void 0&&s.height!==void 0){const x=e!==void 0?e-s.width/2:void 0,T=e!==void 0?e+s.width/2:void 0,f=n!==void 0?n-s.height/2:void 0,E=n!==void 0?n+s.height/2:void 0,g=x!==void 0&&T!==void 0?x>=y&&T<=m:!0,h=f!==void 0&&E!==void 0?f>=p&&E<=b:!0;return g&&h}return!0},pn=(e,n,t,r,s,o,l,i)=>{if(!(r!=null&&r.chartArea))return;const{resizable:u,dragRange:c=null}=t??{};Ar({[e]:n,chartArea:r.chartArea,scales:s,resizable:u,dragRange:c,metrics:i||{},annotationType:t.type,xScaleID:o,yScaleID:l})&&(t.type===j.POINT?e==="x"?t.xValue=n:e==="y"&&(t.yValue=n):t.type===j.BOX&&i&&(e==="x"&&i.width&&(t.xMin=n-i.width/2,t.xMax=n+i.width/2),e==="y"&&i.height&&(t.yMin=n-i.height/2,t.yMax=n+i.height/2)))},Un=(e,n,t)=>{var s,o,l;if(!n)return;const r=(l=(o=(s=e==null?void 0:e.options)==null?void 0:s.plugins)==null?void 0:o.annotation)==null?void 0:l.annotations;r&&n&&r[n]&&(r[n].borderWidth=t)},Mr=(e,n,t,r,s,o)=>{const l=o?r==null?void 0:r[o]:null;if(!l)return;const{xScaleID:i="x",yScaleID:u="y"}=l,{x:c,y:a}=Rn(e,n,t,i,u),d=Te(l);if(l&&l.enableDrag&&!D.isNil(d.centerY)&&!D.isNil(d.centerX)){!D.isNil(n)&&!D.isNil(n.style)&&(n.style.cursor=Be.Move);const y=c-d.centerX,m=a-d.centerY;s(!0,l,y,m),l!=null&&l.onDragStart&&l.onDragStart({x:c,y:a},l)}},Fr=(e,n,t,r,s,o,l,i)=>{if(r&&s){!D.isNil(n)&&!D.isNil(n.style)&&(n.style.cursor=Be.Move);const u=s==null?void 0:s.id;Un(i,u,Re.HOVERED);const c=(s==null?void 0:s.dragAxis)??le.Both,{xScaleID:a="x",yScaleID:d="y"}=s,{x:y,y:m}=Rn(e,n,t,a,d),p=Te(s);let b=y-o,x=m-l;c!==le.Y&&pn(le.X,b,s,i,t,a,d,p),c!==le.X&&pn(le.Y,x,s,i,t,a,d,p),i.update(),s!=null&&s.onDrag&&s.onDrag({x:y,y:m},s);const{ctx:T,width:f,height:E}=i,{centerX:g,centerY:h}=Te(s)??{},{centerX:P,centerY:L}=Bn(s,t,a,d);if(!D.isNil(g)&&!D.isNil(h)&&!D.isNil(P)&&!D.isNil(L)&&(T.save(),T.clearRect(0,0,f,E),i.draw(),T.font=it,T.fillStyle="black",s!=null&&s.displayDragCoordinates)){let C=P-45,S=L-20;const N=`X: ${ee(g,2)}, Y: ${ee(h,2)}`,A=14;S-A<0&&(S=L+A+15),S>E&&(S=E-7),T.fillText(N,C,S),T.restore()}}},vr=(e,n,t,r,s)=>{if(e&&n){const o=n==null?void 0:n.id;Un(t,o,Re.ZERO);const{centerX:l=-1,centerY:i=-1}=Te(n)??{};D.isNil(n==null?void 0:n.onDragEnd)||n==null||n.onDragEnd({x:l,y:i},n),!D.isNil(r)&&!D.isNil(r.style)&&(r.style.cursor=Be.Pointer),s(!1,null)}},Ir=(e,n,t)=>{Object.values(n).forEach(r=>{var s;if(r.type===j.POINT&&!D.isNil(r==null?void 0:r.label)&&((s=r==null?void 0:r.label)!=null&&s.display)){const{content:o,font:l,color:i,position:u,padding:c}=(r==null?void 0:r.label)??{},{xScaleID:a="x",yScaleID:d="y"}=r;e.save(),e.font=l,e.fillStyle=i;const{centerX:y=-1,centerY:m=-1}=Bn(r,t,a,d),p=e.measureText(o).width;let b=y-p/2,x=m+20;switch(u){case oe.Top:x=m-20;break;case oe.Left:b=y-p-c,x=m;break;case oe.Right:b=y+c,x=m;break}e.fillText(o,b,x),e.restore()}})},kr={id:"annotationDraggerPlugin",beforeDraw(e){var s,o,l,i,u,c,a,d;const n=e==null?void 0:e.ctx;let t=((o=(s=e.options.plugins)==null?void 0:s.annotation)==null?void 0:o.annotations)??{};if(!t||!n||!t)return;Ir(e.ctx,t,e.scales),(((i=(l=e==null?void 0:e.options)==null?void 0:l.plugins)==null?void 0:i.annotationDraggerPlugin)||{enabled:!1}).enabled?((c=(u=e==null?void 0:e.options)==null?void 0:u.plugins)!=null&&c.tooltip&&(e.options.plugins.tooltip.enabled=!1),e.options.hover={mode:void 0,intersect:!1}):((d=(a=e==null?void 0:e.options)==null?void 0:a.plugins)!=null&&d.tooltip&&(e.options.plugins.tooltip.enabled=!0),e.options.hover={mode:be.Nearest,intersect:!0})},afterUpdate(e){var y,m,p,b,x,T,f,E;const{canvas:n,scales:t,hoveredAnnotationId:r}=e??{},s=((m=(y=e==null?void 0:e.options)==null?void 0:y.plugins)==null?void 0:m.annotationDraggerPlugin)||{enabled:!1};if(!n||!t||!s)return;const o={...t,x:t.x,y:t.y};let l=((b=(p=e.options.plugins)==null?void 0:p.annotation)==null?void 0:b.annotations)??{};if(!e&&!l)return;s.enabled?((T=(x=e==null?void 0:e.options)==null?void 0:x.plugins)!=null&&T.tooltip&&(e.options.plugins.tooltip.enabled=!1),e.options.hover={mode:void 0,intersect:!1}):((E=(f=e==null?void 0:e.options)==null?void 0:f.plugins)!=null&&E.tooltip&&(e.options.plugins.tooltip.enabled=!0),e.options.hover={mode:be.Nearest,intersect:!0});let i=!1,u,c,a=null;const d=(g,h,P,L)=>{i=g,a=h,P!==void 0&&L!==void 0&&(u=P,c=L)};!n.dataset.annotationDraggerInitialized&&s.enabled&&r&&(n.addEventListener(K.MOUSEDOWN,g=>{var h,P,L;Mr(g,n,o,(L=(P=(h=e==null?void 0:e.options)==null?void 0:h.plugins)==null?void 0:P.annotation)==null?void 0:L.annotations,d,e.hoveredAnnotationId)}),n.addEventListener(K.MOUSEMOVE,g=>{D.debounce(()=>Fr(g,n,o,i,a,u,c,e),5)()}),n.addEventListener(K.MOUSEUP,g=>{const h=g.currentTarget;vr(i,a,e,h,d)}),n.dataset.annotationDraggerInitialized="true"),s.enabled||(n.removeEventListener(K.MOUSEDOWN,()=>{}),n.removeEventListener(K.MOUSEMOVE,()=>{}),n.removeEventListener(K.MOUSEUP,()=>{}),n.dataset.annotationDraggerInitialized="")}};ft.register(gt,mt,bt,yt,pt,ht,_t,xt,Tt,Et,Pt,Qt,wr,kr,os);const jr=e=>{var N,A;at();const n=O.useRef(null),{table:t,headerComponent:r,subheaderComponent:s}=e??{},{translations:o,languageKey:l}=ss(),i=zn(e),{data:{datasets:u}={datasets:[]},options:c,testId:a,persistenceId:d,controlsPortalId:y}=i,{annotations:m,axes:p,chartStyling:b,graph:x}=c??{},T=!((A=(N=c==null?void 0:c.legend)==null?void 0:N.customLegend)!=null&&A.customLegendContainerID),[f,E]=O.useReducer(Ls,{options:c,persistenceId:d,chartRef:n},Ds),g=O.useMemo(()=>tr(u,f,c,o),[f.lineEnabled,f.pointsEnabled,u,p,m,x]);xr({options:c,state:f,persistenceId:d});const{resetZoom:h,handleKeyDown:P,handleKeyUp:L}=He({chartRef:n,state:f,options:c,dispatch:E,generatedDatasets:g}),C=yr({chartRef:n,state:f,options:c,dispatch:E,generatedDatasets:g}),S=pr({options:c,resetZoom:h});return _.jsxs("div",{className:ct(b,Se),style:{width:b.width||Ae,height:b.height||Ae},tabIndex:0,onKeyDown:P,onKeyUp:L,"data-testid":a,children:[_.jsx(Gn,{table:t,headerComponent:r,subheaderComponent:s,chartRef:n,state:f,options:c,dispatch:E,generatedDatasets:g,translations:o,controlsPortalId:y}),t&&f.showTable?_.jsx("div",{className:Se.table,children:t}):_.jsx($t,{backend:Zt,context:window,children:_.jsxs("div",{className:Se.canvas,id:"canvas",children:[_.jsx(dt,{ref:n,data:{datasets:g},options:C,plugins:S}),T&&!!g.length&&_.jsx(Kt,{chartRef:n,legendConfig:{options:c,generatedDatasets:g,chartType:Jt.LINE}})]})})]},Rs(f,l))},Gr=e=>{const{options:n}=zn(e);return _.jsx(ut,{options:n,children:_.jsx(jr,{...e})})};Gr.__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{Gr as L,Yr as i};