@oliasoft-open-source/charts-library 5.1.1 → 5.1.2-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.
- package/dist/assets/{Color-YHDXOIA2-BMZgyHAN.js → Color-YHDXOIA2-D1T4LLq8.js} +1 -1
- package/dist/assets/{DocsRenderer-CFRXHY34-CbvfojdO.js → DocsRenderer-CFRXHY34-D6Q7Fl4L.js} +4 -4
- package/dist/assets/bar-chart.stories-5CuN6VFG.js +136 -0
- package/dist/assets/chunk-XP5HYGXS-D5tuasO7.js +1 -0
- package/dist/assets/{client-9BU5HM4U.js → client-DnE3718B.js} +1 -1
- package/dist/assets/entry-preview-D2nZ6Uy3.js +2 -0
- package/dist/assets/{entry-preview-docs-z3mMcuG4.js → entry-preview-docs-Cet2djRm.js} +1 -1
- package/dist/assets/{get-draggableData-6sYCK0Sg.js → get-draggableData-eD2Xdq-6.js} +2 -2
- package/dist/assets/{iframe-BMP-xuj2.js → iframe-BRmCfBZj.js} +15 -15
- package/dist/assets/{index-D3-0uUTW.js → index-BhTLYoCu.js} +1 -1
- package/dist/assets/{index-B-BONL6g.js → index-CgYGpm1H.js} +1 -1
- package/dist/assets/index-DHw5ixvP.js +1 -0
- package/dist/assets/index-YTOF1_EJ.js +9 -0
- package/dist/assets/{index-CVdx34fM.js → index-uDG1oqxT.js} +1 -1
- package/dist/assets/jsx-runtime-W3oueGCa.js +9 -0
- package/dist/assets/legend-Cgq98xea.js +1367 -0
- package/dist/assets/{legend-context-CuYQJx0k.js → legend-context-PSa8HhGj.js} +22 -22
- package/dist/assets/line-chart-DQPiqg-c.js +1 -0
- package/dist/assets/{line-chart.stories-CCmSDSVh.js → line-chart.stories-yZbOjEZw.js} +16 -13
- package/dist/assets/{line-chart.test-case.stories-tBreUWeJ.js → line-chart.test-case.stories-KRbhVyto.js} +1 -1
- package/dist/assets/{pie-chart.stories-cGmfyrjX.js → pie-chart.stories-C3l9VGYJ.js} +1 -1
- package/dist/assets/{preview-DjxCxm3j.js → preview-OTEdgn42.js} +2 -2
- package/dist/assets/{preview-cjTsgsnd.js → preview-THptAU8l.js} +1 -1
- package/dist/assets/{react-18-DZY5LW1V.js → react-18-BdgjDjvZ.js} +1 -1
- package/dist/assets/{scatter-chart.stories-BK0zwTCK.js → scatter-chart.stories-U-tLziOZ.js} +6 -6
- package/dist/assets/test-utils-BBHUGUfi.js +9 -0
- package/dist/iframe.html +1 -1
- package/dist/index.js +34 -110
- package/dist/line-chart/hooks/use-chart-state.d.ts +1 -5
- package/dist/line-chart/state/initial-state.d.ts +0 -3
- package/dist/line-chart/utils/axis-scales/axis-scales.d.ts +1 -3
- package/dist/line-chart/utils/line-chart-utils.d.ts +6 -1
- package/dist/project.json +1 -1
- package/dist/sb-manager/globals-runtime.js +1 -1
- package/dist/src/components/line-chart/hooks/use-chart-state.d.ts +1 -5
- package/dist/src/components/line-chart/utils/axis-scales/axis-scales.d.ts +1 -3
- package/dist/src/components/line-chart/utils/line-chart-utils.d.ts +6 -1
- package/package.json +1 -1
- package/dist/assets/bar-chart.stories-BxoeoHbp.js +0 -153
- package/dist/assets/entry-preview-BsyjCx5f.js +0 -10
- package/dist/assets/index-BGqSdrBK.js +0 -1
- package/dist/assets/index-eCxJ45ll.js +0 -9
- package/dist/assets/jsx-runtime-Y5Ju2SGo.js +0 -9
- package/dist/assets/legend-DOpGXAxK.js +0 -1346
- package/dist/assets/line-chart-BWgI7lqL.js +0 -1
- package/dist/assets/react-CxVRKATl.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as _}from"./jsx-runtime-Y5Ju2SGo.js";import{r as O}from"./index-eCxJ45ll.js";import{$ as qn,a0 as Wn,a1 as Ze,a2 as J,x as U,a3 as $n,v as D,A as j,P as oe,C as Q,a4 as Re,a5 as Zn,g as we,N as Kn,S as Jn,y as Qn,O as et,a6 as ie,a7 as ae,Q as ee,a8 as ge,E as Me,R as nt,T as tt,L as Ke,a as st,U as be,V as rt,W as Z,d as lt,r as ot,B as Je,a9 as it,f as at,aa as ut,I as ct,ab as k,ac as Be,ad as le,D as dt,ae as K,b as ft,s as gt,F as mt,af as bt,h as yt,i as pt,J as ht,Y as xt,j as _t,k as Tt,p as Et,m as Pt,n as Lt,o as Ot,q as Ct,t as St}from"./legend-context-CuYQJx0k.js";import{r as Se,M as Ue,p as ye,B as X,s as Dt,v as Nt,w as Qe,x as At,y as wt,z as Mt,A as Ft,E as vt,N as en,G as It,S as jt,g as kt,e as Gt,F as zt,T as hn,J as Vt,K as Rt,D as Bt,O as Ut,Q as Xt,k as Yt,q as Ht,U as qt,u as Wt,j as $t,Z as Zt,t as Kt,R as Jt,m as Qt,H as es,L as ns,n as ts,o as ss}from"./legend-DOpGXAxK.js";import{c as rs,C as ls,f as nn,a as os,b as is}from"./get-draggableData-6sYCK0Sg.js";import{e as xn}from"./index-B-BONL6g.js";const as=(e,n,t)=>{const[r,s]=e.major,[o,l]=e.minor,i=(r.x+s.x+o.x+l.x)/4,a=(r.y+s.y+o.y+l.y)/4,c=s.x-r.x,u=s.y-r.y,d=Math.atan2(t.getPixelForValue(a+u/2)-t.getPixelForValue(a-u/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(a);return{cx:p,cy:b,radiusX:y,radiusY:m,angle:d}},us={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 a=i;a.data.forEach(c=>{const{ellipsePoints:u}=c;if(!u)return;const{cx:d,cy:y,radiusX:m,radiusY:p,angle:b}=as(u,t,r);n.save(),n.beginPath(),n.ellipse(d,y,m,p,b,0,2*Math.PI),n.strokeStyle=a.borderColor||qn,n.lineWidth=a.borderWidth||1,n.stroke(),n.restore()})})}},cs="_chart_e3qdd_1",ds="_canvas_e3qdd_11",fs="_fixedHeight_e3qdd_20",gs="_stretchHeight_e3qdd_26",ms="_squareAspectRatio_e3qdd_32",bs="_table_e3qdd_62",De={chart:cs,canvas:ds,fixedHeight:fs,stretchHeight:gs,squareAspectRatio:ms,table:bs};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?Tn(e)||Array.isArray(e)||!!e[tn]||!!((n=e.constructor)!=null&&n[tn])||Le(e)||Oe(e):!1}var ys=Object.prototype.constructor.toString();function Tn(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)===ys}function pe(e,n){Pe(e)===0?Reflect.ownKeys(e).forEach(t=>{n(t,e[t],e)}):e.forEach((t,r)=>n(r,t,e))}function Pe(e){const n=e[M];return n?n.type_:Array.isArray(e)?1:Le(e)?2:Oe(e)?3:0}function Fe(e,n){return Pe(e)===2?e.has(n):Object.prototype.hasOwnProperty.call(e,n)}function En(e,n,t){const r=Pe(e);r===2?e.set(n,t):r===3?e.add(t):e[n]=t}function ps(e,n){return e===n?e!==0||1/e===1/n:e!==e&&n!==n}function Le(e){return e instanceof Map}function Oe(e){return e instanceof Set}function H(e){return e.copy_||e.base_}function ve(e,n){if(Le(e))return new Map(e);if(Oe(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const t=Tn(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)||(Pe(e)>1&&(e.set=e.add=e.clear=e.delete=hs),Object.freeze(e),n&&Object.entries(e).forEach(([t,r])=>Xe(r,!0))),e}function hs(){v(2)}function Ce(e){return Object.isFrozen(e)}var xs={};function W(e){const n=xs[e];return n||v(0,e),n}var ue;function Pn(){return ue}function _s(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 Ie(e){je(e),e.drafts_.forEach(Ts),e.drafts_=null}function je(e){e===ue&&(ue=e.parent_)}function rn(e){return ue=_s(ue,e)}function Ts(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_&&(Ie(n),v(4)),q(e)&&(e=he(n,e),n.parent_||xe(n,e)),n.patches_&&W("Patches").generateReplacementPatches_(t[M].base_,e,n.patches_,n.inversePatches_)):e=he(n,t,[]),Ie(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 xe(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,a)=>on(e,r,s,i,a,t,l)),xe(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&&!Fe(n.assigned_,r)?o.concat(r):void 0,a=he(e,s,i);if(En(t,r,a),te(a))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)&&xe(e,s)}}function xe(e,n,t=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Xe(n,t)}function Es(e,n){const t=Array.isArray(e),r={type_:t?1:0,scope_:n?n.scope_:Pn(),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(!Fe(t,n))return Ps(e,t,n);const r=t[n];return e.finalized_||!q(r)?r:r===Ne(e.base_,n)?(Ae(e),e.copy_[n]=Ge(r,e)):r},has(e,n){return n in H(e)},ownKeys(e){return Reflect.ownKeys(H(e))},set(e,n,t){const r=Ln(H(e),n);if(r!=null&&r.set)return r.set.call(e.draft_,t),!0;if(!e.modified_){const s=Ne(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(ps(t,s)&&(t!==void 0||Fe(e.base_,n)))return!0;Ae(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 Ne(e.base_,n)!==void 0||n in e.base_?(e.assigned_[n]=!1,Ae(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 Ne(e,n){const t=e[M];return(t?H(t):e)[n]}function Ps(e,n,t){var s;const r=Ln(n,t);return r?"value"in r?r.value:(s=r.get)==null?void 0:s.call(e.draft_):void 0}function Ln(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 Ae(e){e.copy_||(e.copy_=ve(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ls=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(a=o,...c){return l.produce(a,u=>t.call(this,u,...c))}}typeof t!="function"&&v(6),r!==void 0&&typeof r!="function"&&v(7);let s;if(q(n)){const o=rn(this),l=Ge(n,void 0);let i=!0;try{s=t(l),i=!1}finally{i?Ie(o):je(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,a=>n(a,...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=Os(e));const n=rn(this),t=Ge(e,void 0);return t[M].isManual_=!0,je(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 Ge(e,n){const t=Le(e)?W("MapSet").proxyMap_(e,n):Oe(e)?W("MapSet").proxySet_(e,n):Es(e,n);return(n?n.scope_:Pn()).drafts_.push(t),t}function Os(e){return te(e)||v(10,e),On(e)}function On(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=ve(e,n.scope_.immer_.useStrictShallowCopy_)}else t=ve(e,!0);return pe(t,(r,s)=>{En(t,r,On(s))}),n&&(n.finalized_=!1),t}var F=new Ls,Cs=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",Sn="TOGGLE_PAN",Dn="TOGGLE_POINTS",Nn="TOGGLE_LINE",An="TOGGLE_LEGEND",wn="TOGGLE_TABLE",ze="RESET_AXES_RANGES",_e="UPDATE_AXES_RANGES",Mn="TOGGLE_DRAG_POINTS",Fn="TOGGLE_DRAG_ANNOTATION",vn="DISABLE_DRAG_OPTIONS",me="UPDATE_EDITED",Ss=(e,n)=>Cs(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 Sn:{t.panEnabled=!t.panEnabled,t.zoomEnabled&&(t.zoomEnabled=!1),t.enableDragPoints&&(t.enableDragPoints=!1),t.enableDragAnnotation&&(t.enableDragAnnotation=!1);break}case Dn:{t.pointsEnabled=!t.pointsEnabled;break}case Nn:{t.lineEnabled=!t.lineEnabled;break}case An:{t.legendEnabled=!t.legendEnabled;break}case wn:{t.showTable=!t.showTable;break}case _e:{const{axes:r}=n.payload;t.axes=r;break}case ze:{const{axes:r}=n.payload;t.axes=r;break}case Mn:{t.enableDragPoints=!t.enableDragPoints,t.panEnabled&&(t.panEnabled=!1),t.zoomEnabled&&(t.zoomEnabled=!1),t.enableDragAnnotation&&(t.enableDragAnnotation=!1);break}case Fn:{t.enableDragAnnotation=!t.enableDragAnnotation,t.panEnabled&&(t.panEnabled=!1),t.zoomEnabled&&(t.zoomEnabled=!1);break}case vn:{(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}}}),Ds=e=>{if(!e)return null;const n=`line-chart-state-${e}`,t=localStorage.getItem(n);return t?JSON.parse(t).state:null},Ns=(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)}}}},As=(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)),Ns()},ws=({options:e,persistenceId:n})=>{const{chartOptions:{enableZoom:t,enablePan:r,showPoints:s,showLine:o,enableDragAnnotation:l},legend:{display:i},dragData:a}=e,{zoomEnabled:c,panEnabled:u,pointsEnabled:d,lineEnabled:y,legendEnabled:m,enableDragPoints:p,enableDragAnnotation:b}=Ds(n)||{};return{zoomEnabled:l??b?!1:c??t,panEnabled:u??r,pointsEnabled:d??s,lineEnabled:y??o,legendEnabled:m??i,axes:[],showTable:!1,enableDragPoints:(a==null?void 0:a.enableDragData)&&p,enableDragAnnotation:l??b,edited:!1}},Ms=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"}))),Fs=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})),vs=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 Is({lineEnabled:e,onToggleLine:n,onTogglePoints:t,pointsEnabled:r,translations:s}){return[{type:"Option",label:s.pointsLines,icon:_.jsx(Se,{icon:_.jsx(vs,{})}),selected:r&&e,onClick:()=>{r||t(),e||n()}},{type:"Option",label:s.linesOnly,icon:_.jsx(Se,{icon:_.jsx(Ms,{})}),selected:!r&&e,onClick:()=>{r&&t(),e||n()}},{type:"Option",label:s.pointsOnly,icon:_.jsx(Se,{icon:_.jsx(Fs,{})}),selected:r&&!e,onClick:()=>{r||t(),e&&n()}}]}const In=({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})})}})};In.__docgenInfo={description:"",methods:[],displayName:"LineOptions",props:{options:{required:!0,tsType:{name:"Array",elements:[{name:"IMenuSection"}],raw:"IMenuSection[]"},description:""}}};function js({onTogglePan:e,onToggleZoom:n,panEnabled:t,zoomEnabled:r,enableDragPoints:s,enableDragAnnotation:o,isDragDataAllowed:l,isDragAnnotationAllowed:i,onToggleDragAnnotation:a,onToggleDragPoints:c,onDisableDragOptions:u,translations:{dragToZoom:d,doubleClickToReset:y,dragToPan:m,dragToMovePoints:p,dragDisabled:b,dragToMoveAnnotation:x}}){return[{label:d,description:y,icon:_.jsx(Dt,{}),selected:r,type:"Option",onClick:()=>{r||n()}},{label:m,description:y,icon:_.jsx(Nt,{}),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||a()}}]:[],{label:b,icon:_.jsx(At,{}),selected:!r&&!t&&!s&&!o,type:"Option",onClick:u}]}const jn=({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})}})};jn.__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 ks="_controls_1edjs_1",Gs="_buttons_1edjs_6",an={controls:ks,buttons:Gs},zs=e=>{const n=O.useCallback(t=>()=>{e({type:t})},[e]);return{onToggleLegend:n(An),onToggleLine:n(Nn),onTogglePan:n(Sn),onTogglePoints:n(Dn),onToggleTable:n(wn),onToggleZoom:n(Cn),onToggleDragPoints:n(Mn),onToggleDragAnnotation:n(Fn),onDisableDragOptions:n(vn)}},Vs=(e,n)=>e===void 0||n===void 0||Number(e)<Number(n),Rs=(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}`},Bs=e=>{var n;return((n=e==null?void 0:e.match(/[^0-9/]+/gi))==null?void 0:n[0])??""},Us=e=>e.join(""),$r=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null,Xs=e=>e?Object.values(e).some(n=>!Wn(n)):!1,He=({chartRef:e,state:n,options:t,dispatch:r,generatedDatasets:s})=>{const{interactions:{onHover:o,onUnhover:l},axes:i}=t,a=O.useCallback(()=>{var T,g;const f=e==null?void 0:e.current;f&&(n!=null&&n.edited)&&((T=f==null?void 0:f.resetZoom)==null||T.call(f),(g=f==null?void 0:f.reset)==null||g.call(f),r({type:ze,payload:{axes:[]}}),r({type:me,payload:!1}))},[e==null?void 0:e.current,r,n]),c=O.useCallback((f,T,g)=>(h,P)=>{var L,C;if(!(P!=null&&P.length)&&l&&f&&(T(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],w=g[N],A=w==null?void 0:w.data[S];A&&!xn(f,A)&&(T(A),o(h,N,S,g),(C=e==null?void 0:e.current)==null||C.update())}},[o,l,s]),u=O.useCallback(()=>rs(e),[e==null?void 0:e.current]),d=O.useCallback(f=>{var T,g,h,P,L;if(f.key===Ze.Shift){const C=e.current,S=(h=(g=(T=C==null?void 0:C.config)==null?void 0:T.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 T,g,h,P,L;if(f.key===Ze.Shift){const C=e.current,S=(h=(g=(T=C==null?void 0:C.config)==null?void 0:T.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 T=(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[...T(f,U.X),...T(f,U.Y)]},[i]),p=O.useCallback(()=>{var g;const{scales:f={}}=(e==null?void 0:e.current)||{},T=(g=Object.entries(f))==null?void 0:g.map(([h,{min:P,max:L}])=>({id:h,min:P??0,max:L??0}));r({type:_e,payload:{axes:T}})},[i]),b=O.useCallback(()=>{var T,g;const f=e==null?void 0:e.current;f&&n.edited&&((T=f==null?void 0:f.resetZoom)==null||T.call(f),(g=f==null?void 0:f.reset)==null||g.call(f),r({type:ze,payload:{axes:[]}}),r({type:me,payload:!1}))},[e==null?void 0:e.current]),x=O.useCallback(({axes:f})=>{r({type:_e,payload:{axes:f}})},[]),E=O.useCallback(f=>{r({type:me,payload:f})},[n]);return{resetZoom:a,onHover:c,handleDownload:u,handleKeyDown:d,handleKeyUp:y,controlsAxesLabels:m(i),updateAxesRangesFromChart:p,onResetAxes:b,onUpdateAxes:x,onUpdateEdited:E}},un=(e,n,t)=>{const r=[];return $n(e)&&r.push("mustHaveAValue"),t==="min"&&!Vs(e,n)?r.push("mustBeLessThanMax"):t==="max"&&!Rs(e,n)&&r.push("mustBeGreaterThanMin"),r},Ys=e=>{const n=e.map(({id:r,min:s,max:o})=>({id:r,min:un(String(s),String(o),"min"),max:un(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 u;let i=Number(o),a=Number(l);isNaN(i)&&(i=0),isNaN(a)&&(a=i+cn),i===a&&(a+=cn);const{unit:c}=((u=n==null?void 0:n.axes)==null?void 0:u.find(d=>d.id===s))??{};return{id:s,min:i,max:a,unit:c}})},Hs=e=>{var T;const{state:n,controlsAxesLabels:t,onUpdateAxes:r,onResetAxes:s,onUpdateEdited:o,depthType:l,translations:i,close:a,chartRef:c}=e??{},[u,d]=O.useState({localAxes:dn({chartRef:c,state:n}),depthType:l==null?void 0:l.selectedDepthType,edited:n.edited}),{errors:y,valid:m}=Ys(u.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:u.localAxes}),a==null||a()),l&&(l!=null&&l.setSelectedDepthType)&&(l==null||l.setSelectedDepthType(u.depthType)),o(u.edited)},E=()=>{d({localAxes:dn({chartRef:c,state:n}),depthType:l==null?void 0:l.selectedDepthType,edited:!1}),s(),o(!1),a==null||a()},f=g=>g.target.select();return _.jsxs("form",{onSubmit:x,children:[u.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(Ft,{label:P,children:_.jsxs(vt,{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(It,{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(jt,{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)}),((T=l==null?void 0:l.options)==null?void 0:T.length)>0&&_.jsxs(_.Fragment,{children:[_.jsx(kt,{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(u.depthType)}),_.jsx(Gt,{})]}),_.jsxs(zt,{gap:"8px",alignItems:"center",children:[_.jsx(X,{type:"submit",small:!0,colored:!0,label:i.done,disabled:!m||!u.edited}),_.jsx(X,{small:!0,name:"resetAxes",label:i.resetAxes,onClick:E}),_.jsx(hn,{small:!0,muted:!0,children:i.orDoubleClickToCanvas})]})]})},Gn=e=>_.jsx(wt,{placement:"bottom-start",overflowContainer:!0,content:_.jsx(Hs,{...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(Mt,{})})})});Gn.__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 zn=({table:e,headerComponent:n,subheaderComponent:t,chartRef:r,state:s,options:o,dispatch:l,generatedDatasets:i,translations:a,controlsPortalId:c})=>{const{enableDragPoints:u,lineEnabled:d,panEnabled:y,pointsEnabled:m,showTable:p,zoomEnabled:b,enableDragAnnotation:x}=s,{dragData:E,depthType:f,annotations:T}=o,{onToggleLine:g,onTogglePan:h,onTogglePoints:P,onToggleTable:L,onToggleZoom:C,onToggleDragPoints:S,onToggleDragAnnotation:N,onDisableDragOptions:w}=zs(l),{handleDownload:A,controlsAxesLabels:$,onResetAxes:G,onUpdateAxes:se,onUpdateEdited:z}=He({chartRef:r,state:s,options:o,dispatch:l,generatedDatasets:i}),[V,{width:re}]=Vt(),Y=re<200,R=O.useMemo(()=>Is({lineEnabled:d,onToggleLine:g,onTogglePoints:P,pointsEnabled:m,translations:a}),[d,m]),B=O.useMemo(()=>js({onTogglePan:h,onToggleZoom:C,panEnabled:y,zoomEnabled:b,enableDragPoints:u,enableDragAnnotation:x,isDragDataAllowed:E==null?void 0:E.enableDragData,isDragAnnotationAllowed:T==null?void 0:T.enableDragAnnotation,onToggleDragAnnotation:N,onToggleDragPoints:S,onDisableDragOptions:w,translations:a}),[b,y,u,E==null?void 0:E.enableDragData,T==null?void 0:T.enableDragAnnotation]);return _.jsxs(_.Fragment,{children:[_.jsxs("div",{className:an.controls,children:[!!o.title&&_.jsx(hn,{bold:!0,children:o.title}),n,_.jsx(ls,{controlsPortalId:c??"",children:_.jsxs("div",{className:an.buttons,ref:V,children:[!p&&_.jsxs(_.Fragment,{children:[_.jsx(Gn,{chartRef:r,state:s,controlsAxesLabels:$,onUpdateAxes:se,onResetAxes:G,onUpdateEdited:z,depthType:f,translations:a}),Y?_.jsx(Ue,{menu:{placement:"bottom-end",sections:[...R,{type:"Divider"},...B,{type:"Divider"},{icon:"download",label:a.downloadAsPNG,type:"Option",onClick:A}],trigger:"Component",component:_.jsx(X,{colored:"muted",basic:!0,small:!0,round:!0,icon:"menu"})}}):_.jsxs(_.Fragment,{children:[_.jsx(In,{options:R}),_.jsx(ye,{display:"inline-flex",text:a.downloadAsPNG,placement:"bottom-end",children:_.jsx(X,{small:!0,basic:!0,colored:"muted",round:!0,icon:"download",onClick:A})}),_.jsx(jn,{options:B})]})]}),e?_.jsx(ye,{display:"inline-flex",text:p?a.showChart:a.showTable,placement:"bottom-end",children:_.jsx(X,{small:!0,basic:!0,colored:"muted",round:!0,icon:p?"chart":"table",onClick:L})}):null]})})]}),t]})};zn.__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:()=>{}}}),qs=e=>({x:(e==null?void 0:e.x)||[fn("bottom")],y:(e==null?void 0:e.y)||[fn("left")]}),Ws=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}),$s=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}}),Zs=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}),Ks=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}),Js=e=>e?e.map(n=>({...n,display:(n==null?void 0:n.display)??!0})):[],Qs=e=>{var n,t,r,s,o,l,i,a;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:((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:Js(e==null?void 0:e.annotationsData)}},er=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}),nr=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}),tr=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}),sr=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}),Vn=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:qs(t==null?void 0:t.axes),additionalAxesOptions:Ws(t==null?void 0:t.additionalAxesOptions),chartStyling:$s(t==null?void 0:t.chartStyling),tooltip:Zs(t==null?void 0:t.tooltip),graph:Ks(t==null?void 0:t.graph),annotations:Qs(t==null?void 0:t.annotations),legend:er(t==null?void 0:t.legend),chartOptions:nr(t==null?void 0:t.chartOptions),interactions:tr(t==null?void 0:t.interactions),dragData:sr(t==null?void 0:t.dragData),depthType:(t==null?void 0:t.depthType)??{}}}},rr=(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 Rn=(e=>(e.showLine="showLine",e.showPoints="showPoints",e))(Rn||{});const lr=(e,n,t,{label:r})=>{const s=[...e??[]],{annotations:o,graph:l}=t??{},{controlAnnotation:i,showAnnotations:a,annotationsData:c=[]}=o??{};if(i&&a){const u=c.map((d,y)=>{const{type:m,...p}=d,b=p.color??Q[y],x=Zn,E=Re.INITIAL;return{...p,isAnnotation:!0,annotationType:m,label:p.label,annotationIndex:y,backgroundColor:b,pointBackgroundColor:b,borderColor:b,borderDash:x,borderWidth:E,data:[{}]}});s.push(...u)}return s==null?void 0:s.map((u,d)=>{var B,qe;const{formation:y,data:m=[],pointRadius:p,pointHoverRadius:b,borderWidth:x,borderColor:E,backgroundColor:f,pointBackgroundColor:T,borderDash:g,showPoints:h,showLine:P}=u??{},{lineEnabled:L,pointsEnabled:C,axes:S=[]}=n??{},{lineTension:N,spanGaps:w}=l??{},A=Array.isArray(m)?m:[];if(y&&(A!=null&&A.length)){const We=Number((B=S[0])==null?void 0:B.min),$e=Number((qe=S[0])==null?void 0:qe.max),[de,fe]=A;We&&(de!=null&&de.x)&&(A[0].x=Math.max(We,de.x)),$e&&(fe!=null&&fe.x)&&(A[2].x=Math.min($e,fe.x))}const $=rr(u,Rn),G=(A==null?void 0:A.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)||Bt,Y=parseFloat(b)||Rt,R=Q[d];return{...u,label:(u==null?void 0:u.label)??`${r} ${d+1}`,data:G,showLine:V,lineTension:(u==null?void 0:u.lineTension)??N,spanGaps:w,borderWidth:parseFloat(x)||Yt,borderDash:g||[],borderJoinStyle:Xt,borderColor:E??R??we(Q),backgroundColor:f??Ut,pointBackgroundColor:T??R??we(Q),pointRadius:z?re:0,pointHoverRadius:Y,pointHitRadius:(u==null?void 0:u.pointHitRadius)??Y,...$?{hasCustomOpt:$}:{}}})},Bn=e=>e==null?void 0:e.reduce((n,t)=>({...n,[t.annotationAxis]:[...n[t.annotationAxis]||[],+t.value]}),{}),Un=(e,n,t)=>{if(!e||!e.current)return null;const r=e.current.getSortedVisibleDatasetMetas(),s=Bn(t)[n]??[];let o=[];if(r.forEach(a=>{const c=a._parsed.map(u=>u[n]).filter(u=>u!=null&&!isNaN(u));o=o.concat(c)}),o=o.concat(s),o.length===0)return null;const l=Math.min(...o),i=Math.max(...o);return{min:l,max:i}},Ve=(e,n,t,r,s=0)=>{var u,d,y,m,p,b,x;const o=r||e.axes[n][0]||{},l=t==null?void 0:t.axes.filter(E=>{var f;return(f=E==null?void 0:E.id)==null?void 0:f.startsWith(n)})[s],i=(d=(u=e==null?void 0:e.scales)==null?void 0:u[`${s===0?n:n+s}`])==null?void 0:d.ticks,{additionalAxesOptions:a}=e,c=()=>{const E=(a==null?void 0:a.chartScaleType)===Jn.Logarithmic,f=(h,P,L)=>E?et.includes(h)?nn(h,L):"":nn(h,L);return{...E?{}:{stepSize:o.stepSize??(n===U.Y?a.stepSize:null)},callback:f,includeBounds:!1,...i,font:{size:Qn}}};return{display:!0,type:a.chartScaleType,position:o.position,beginAtZero:a.beginAtZero,reverse:n===U.Y?a.reverse:!1,suggestedMax:a.suggestedMax,suggestedMin:a.suggestedMin,min:(l==null?void 0:l.min)??((m=(y=a==null?void 0:a.range)==null?void 0:y[n])==null?void 0:m.min),max:(l==null?void 0:l.max)??((b=(p=a==null?void 0:a.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 a=l;a.color=l.color||Q[i]||we(Q),a.position=l.position||Kn(n,i);const c=Ve(e,n,t,a,i),u=kn(n,i,!0);return{...o,[u]:c}},{}),or=(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}},ir=e=>{var t;if(!Array.isArray(e)||!(e!=null&&e.length))return!1;const n=e==null?void 0:e.reduce((r,s)=>{var a,c,u,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=((a=r==null?void 0:r[o])==null?void 0:a.xFirst)??y,E=((c=r==null?void 0:r[o])==null?void 0:c.xLast)??p,f=((u=r==null?void 0:r[l])==null?void 0:u.yFirst)??m,T=((d=r==null?void 0:r[l])==null?void 0:d.yLast)??b,g=Math.min(y,x),h=Math.max(p,E),P=Math.min(m,f),L=Math.max(b,T);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:ae})||ie(o,l,{absoluteDiff:ae}))},mn=.05,ar={min:-1,max:1},ur=({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:ae})&&ie(s,0,{absoluteDiff:ae});if(!(e!=null&&e.length)||l)return ar;if(ie(r,s,{absoluteDiff:ae})){const m=s,p=m*mn,b=n&&!o?0:m-p,x=n&&o?0:m+p,E=ee(x,ge),f=ee(b,ge);return{min:E<0?E:f,max:f<0?f:E}}if(!t)return{min:void 0,max:void 0};const i=r===0||s===0||n,a=Math.sign(r)===-1&&Math.sign(s)===1,c=Math.abs(s-r),u=t?c*mn:0,d=!a&&i&&n&&!o?0:r-u,y=!a&&i&&n&&o?0:s+u;return{min:ee(d,ge),max:ee(y,ge)}},cr=(e,n,t)=>{if(!Array.isArray(e)||!Array.isArray(n))return{};const r=Bn(t);return n.reduce((s,o)=>{const l=Bs(o),i=e.filter(c=>(c[`${l}AxisID`]??l)===o).flatMap(c=>((c==null?void 0:c.data)??[]).map(d=>d[l])),a=(r==null?void 0:r[o])??[];return s[o]=[...new Set([...i,...a])],s},{})},bn=(e,n)=>!D.isNil(e)||!D.isNil(n),dr=(e,n,t,r)=>{const{additionalAxesOptions:s,annotations:{annotationsData:o=[],controlAnnotation:l=!1}={}}=e||{},i=or(e,n)||{},a=l?t.filter(({isAnnotation:y})=>!y):t;if(!(s!=null&&s.autoAxisPadding)&&!ir(a))return i;const c=Object.keys(i)??[],u=cr(t,c,o);return(u&&(c==null?void 0:c.reduce((y,m)=>{const p=i[m],{min:b=void 0,max:x=void 0}=p,{min:E,max:f}=Un(r,m,o)??{},{min:T,max:g}=ur({data:u[m],beginAtZero:s==null?void 0:s.beginAtZero,autoAxisPadding:s==null?void 0:s.autoAxisPadding}),h={[m]:{...p,min:b??(bn(b,x)?E:T),max:x??(bn(b,x)?f:g)}};return{...y,...h}},{})))??i},fr=(e,n,t,r,s)=>{const l=e??0,i=n??0,a=t??0,c=r??0,u=s??0,d=l-100<=a,y=l+100>=c,m=l+100>=a&&l+100<c&&i+100>=u;return{overLeftSide:d,overRightSide:y,overBottomSide:m}},gr=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,a=(y=n==null?void 0:n.getDatasetMeta)==null?void 0:y.call(n,r),c=(m=a==null?void 0:a.data)==null?void 0:m[t],u=(c==null?void 0:c.x)??null,d=(c==null?void 0:c.y)??null;return{x:u,y:d,left:o,right:l,bottom:i}},mr=()=>e=>{const{x:n,y:t,left:r,right:s,bottom:o}=gr(e),{overLeftSide:l=!1,overRightSide:i=!1,overBottomSide:a=!1}=fr(n,t,r,s,o);return l&&j.Right||i&&j.Left||a&&j.End||j.Start},br=e=>{var n;return(n=e==null?void 0:e.graph)!=null&&n.showDataLabels?{display:Me,align:mr(),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}},yr=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)<Ht||Math.abs(e)>qt)&&(t={roundScientificCoefficient:3}):t={scientific:!1},lt(ot(e),t)},pr=e=>{var o,l,i,a,c;if(!((l=(o=e==null?void 0:e.axes)==null?void 0:o.x)!=null&&l.length)||!((a=(i=e==null?void 0:e.axes)==null?void 0:i.y)!=null&&a.length))return console.warn("Tooltip config fallback: missing axes",e),{enabled:!1,callbacks:{}};const{scientificNotation:n}=(e==null?void 0:e.tooltip)??{},t=({xAxisID:u="",yAxisID:d=""})=>{var x,E,f,T,g,h,P;const y=(u==null?void 0:u.length)>1?Number(u==null?void 0:u[1])-1:0,m=(d==null?void 0:d.length)>1?Number(d==null?void 0:d[1])-1:0,p=(E=(x=e==null?void 0:e.axes)==null?void 0:x.x)==null?void 0:E[y],b=(T=(f=e==null?void 0:e.axes)==null?void 0:f.y)==null?void 0:T[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=u=>{var x,E,f,T;if(!(u!=null&&u[0]))return"";const d=t(u[0].dataset),{titleLabel:y="",titleAxisLabel:m=""}=d??{},p=y===Z.Y?(E=(x=u==null?void 0:u[0])==null?void 0:x.parsed)==null?void 0:E.y:(T=(f=u==null?void 0:u[0])==null?void 0:f.parsed)==null?void 0:T.x;return`${yn(p,n)} ${m}`},s=u=>{var g;const{showLabelsInTooltips:d}=(e==null?void 0:e.tooltip)??{};let y=((g=u==null?void 0:u.dataset)==null?void 0:g.label)||"";const m=t(u==null?void 0:u.dataset),{valueLabel:p="",valueAxisLabel:b=""}=m??{},E=(()=>{var P,L;const h=p===Z.X?(P=u==null?void 0:u.parsed)==null?void 0:P.x:(L=u==null?void 0:u.parsed)==null?void 0:L.y;return yn(h,n)})(),f=yr(b),T=rt(u,d);return`${y}: ${E} ${f} ${T}`};return{enabled:(c=e==null?void 0:e.tooltip)==null?void 0:c.tooltips,mode:be.Nearest,intersect:!0,padding:st,usePointStyle:!0,boxWidth:Ke,boxHeight:Ke,boxPadding:tt,callbacks:{title:r,label:s,afterLabel:nt}}},hr=({chartRef:e,state:n,options:t,dispatch:r,generatedDatasets:s})=>{const{interactions:{onAnimationComplete:o},annotations:{labelAnnotation:{showLabel:l,text:i,position:a,fontSize:c,xOffset:u,yOffset:d,maxWidth:y,lineHeight:m}={}},chartStyling:{layoutPadding:p}}=t,{enableDragPoints:b,zoomEnabled:x,panEnabled:E,lineEnabled:f}=n,[T,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}=Wt({chartRef:e,options:t})??{},{state:N}=$t()??{},{annotation:w}=N??{},A=br(t)??{},$=pr(t)??{},G=O.useMemo(()=>dr(t,n,s,e),[t,n,s,e]),se=O.useMemo(()=>b&&os(t),[b,t]),z=O.useMemo(()=>({enabled:E,mode:J.XY,onPanComplete(){h(),L(!0)}}),[E]),V=O.useMemo(()=>({mode:J.XY,drag:{enabled:x,threshold:3,backgroundColor:Zt,borderColor:Je,borderWidth:1},onZoomComplete(){h(),L(!0)}}),[x]),re={datalabels:A,annotationDraggerPlugin:{enabled:n==null?void 0:n.enableDragAnnotation},annotation:Kt(w),zoom:{pan:z,zoom:V},tooltip:$,legend:{...C,display:!1,events:[]},customLegendPlugin:S,chartAreaBorder:{borderColor:Je},chartAreaText:{showLabel:l,text:i,position:a,fontSize:c,xOffset:u,yOffset:d,maxWidth:y,lineHeight:m},...se};return O.useMemo(()=>{var Y,R,B;return{layout:{padding:p},onHover:P(T,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:at.FAST,onComplete:o},hover:{mode:be.Nearest,intersect:!0},elements:{line:{pointStyle:it.Circle,showLine:f,tension:0}},scales:G,plugins:re,events:Object.values(ut)}},[n,t,e,s])},xr=({options:e,resetZoom:n})=>{const{graph:t,legend:r}=e,s=O.useCallback((o,l)=>{const{event:i}=l;return i.type===Jt?(n(),!1):!0},[n]);return O.useMemo(()=>[...ct(t,r),{id:"customEventCatcher",beforeEvent:s}],[s])},_r=1,Tr=(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])},Er=(e,n)=>{O.useEffect(()=>{As(e,n)},[e.panEnabled,e.lineEnabled,e.pointsEnabled,e.legendEnabled,e.enableDragPoints,e.zoomEnabled])},Pr=({chartRef:e,range:n,state:t,dispatch:r,annotationsData:s})=>{const o=O.useRef(t.axes);O.useEffect(()=>{if(n&&Xs(n)){const l=Object.entries(n).map(([a,{min:c,max:u}])=>{const{min:d=void 0,max:y=void 0}=Un(e,a,s)??{};let m=c??d,p=u??y;return m===p&&(p+=_r),{id:a,min:m,max:p}}),i=[...o.current??[]].map(a=>{const c=l.find(u=>u.id===a.id);return c?{...a,...c}:a});xn(i,o.current)||(r({type:_e,payload:{axes:i}}),o.current=i)}},[n])},Lr=({chartRef:e,options:n,state:t,dispatch:r,persistenceId:s})=>{const o=O.useMemo(()=>t,[t]),l=O.useMemo(()=>n,[n]),{additionalAxesOptions:{range:i=void 0},annotations:{annotationsData:a=[]}={}}=l;Er(o,s),Tr(o,l),Pr({range:i,state:o,dispatch:r,chartRef:e,annotationsData:a})},Te=" ",Or="rgba(0, 0, 0, 0.5)",Cr=e=>{var n;return(n=Array.isArray(e)?e.join(Te):e)==null?void 0:n.split(Te)},Sr=({ctx:e,lines:n,lineHeight:t,x:r,y:s,position:o})=>{n==null||n.forEach((l,i)=>{const a=o!=null&&o.includes("top")?s+t*(i+1)-5:s-(n.length-1-i)*t;e==null||e.fillText(l,r,a)})},Dr=(e,n)=>{const s=n<500?.5:n<700?.7:1;return e*s},Nr=e=>{var s,o,l,i,a,c,u;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"||((a=n==null?void 0:n.options)==null?void 0:a.position)==="bottom")?(n==null?void 0:n.height)+((u=(c=n==null?void 0:n.options)==null?void 0:c.labels)==null?void 0:u.padding)*2:0;return{legendWidth:t,legendHeight:r}},Ar=(e,n,t,r)=>{const{chartArea:s,width:o}=n??{},l=o-8,{legendWidth:i,legendHeight:a}=Nr(n)??{};switch(e){case I.TOP_LEFT:return[(s==null?void 0:s.left)+t+i,(s==null?void 0:s.top)+r+a];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+a];case I.TOP_RIGHT:return[l-t,(s==null?void 0:s.top)+r+a];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-a];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-a];case I.BOTTOM_RIGHT:default:return[l-t-i,(s==null?void 0:s.bottom)-r-a]}},wr=e=>e!=null&&e.includes(j.Center)?j.Center:e!=null&&e.includes(j.Left)?j.Left:j.Right,Mr=(e,n,t)=>{let r="",s=[];for(let o=0;o<e.length;o++){const l=`${r}${e==null?void 0:e[o]}${Te}`,{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]}${Te}`):r=l}return s.push(r.trim()),s},Fr=(e,n)=>{var d,y;if(!e)return;const{text:t,maxWidth:r,fontSize:s,lineHeight:o,x:l,y:i,position:a}=n??{},c=Cr(t),u=Mr(c,r,e);(d=e==null?void 0:e.save)==null||d.call(e),e.font=`${s}px Arial`,e.fillStyle=Or,e.textAlign=wr(a),Sr({ctx:e,lines:u,lineHeight:o,x:l,y:i,position:a}),(y=e==null?void 0:e.restore)==null||y.call(e)},vr={id:"chartAreaText",beforeDraw:(e,n,t)=>{const{showLabel:r,text:s,fontSize:o,xOffset:l,yOffset:i,lineHeight:a,maxWidth:c,position:u}=t??{};if(!r||!s)return;const{ctx:d,chartArea:y}=e??{};if(!d||!y)return;const m=Dr(c,y.width),[p,b]=Ar(u,e,l,i);Fr(d,{text:s,maxWidth:m,fontSize:o,lineHeight:a,x:p,y:b,position:u})}},Xn=(e,n,t,r,s)=>{const o=n.getBoundingClientRect(),l=e.clientX-o.left,i=e.clientY-o.top,a=t==null?void 0:t[r],c=t==null?void 0:t[s],u=(a==null?void 0:a.getValueForPixel(l))??-1,d=(c==null?void 0:c.getValueForPixel(i))??-1;return{x:u,y:d}},Ee=e=>{const{xMin:n,xMax:t,yMin:r,yMax:s,xValue:o,yValue:l,type:i}=e??{};let a,c,u,d;return!D.isNil(n)&&!D.isNil(t)&&!D.isNil(r)&&!D.isNil(s)&&i===k.BOX?(a=(n+t)/2,c=(r+s)/2,u=t-n,d=s-r):!D.isNil(o)&&!D.isNil(l)&&i===k.POINT&&(a=o,c=l,u=0,d=0),{centerX:a,centerY:c,width:u,height:d}},Yn=(e,n,t,r)=>{const{xMin:s,xMax:o,yMin:l,yMax:i,xValue:a,yValue:c,type:u}=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)&&u===k.BOX){const E=(s+o)/2,f=(l+i)/2,T=(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=T-g,p=h-P,d=(b==null?void 0:b.getPixelForValue(E))??-1,y=(x==null?void 0:x.getPixelForValue(f))??-1}else!D.isNil(a)&&!D.isNil(c)&&u===k.POINT&&(m=0,p=0,d=(b==null?void 0:b.getPixelForValue(a))??-1,y=(x==null?void 0:x.getPixelForValue(c))??-1);return{centerX:d,centerY:y,width:m,height:p}},Ir=({x:e,y:n,chartArea:t,scales:r,metrics:s,resizable:o=!1,dragRange:l,annotationType:i,xScaleID:a,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,E=n!==void 0&&l.y?n>=l.y[0]&&n<=l.y[1]:!0;return x&&E}const u=r==null?void 0:r[a],d=r==null?void 0:r[c];if(!(r!=null&&r[a])||!(r!=null&&r[c]))return!1;const y=(u==null?void 0:u.getValueForPixel(t.left))??Number.NEGATIVE_INFINITY,m=(u==null?void 0:u.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===k.POINT){const x=e!==void 0?e>=y&&e<=m:!0,E=n!==void 0?n>=p&&n<=b:!0;return x&&E}if(i===k.BOX&&s.width!==void 0&&s.height!==void 0){const x=e!==void 0?e-s.width/2:void 0,E=e!==void 0?e+s.width/2:void 0,f=n!==void 0?n-s.height/2:void 0,T=n!==void 0?n+s.height/2:void 0,g=x!==void 0&&E!==void 0?x>=y&&E<=m:!0,h=f!==void 0&&T!==void 0?f>=p&&T<=b:!0;return g&&h}return!0},pn=(e,n,t,r,s,o,l,i)=>{if(!(r!=null&&r.chartArea))return;const{resizable:a,dragRange:c=null}=t??{};Ir({[e]:n,chartArea:r.chartArea,scales:s,resizable:a,dragRange:c,metrics:i||{},annotationType:t.type,xScaleID:o,yScaleID:l})&&(t.type===k.POINT?e==="x"?t.xValue=n:e==="y"&&(t.yValue=n):t.type===k.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)))},Hn=(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)},jr=(e,n,t,r,s,o)=>{const l=o?r==null?void 0:r[o]:null;if(!l)return;const{xScaleID:i="x",yScaleID:a="y"}=l,{x:c,y:u}=Xn(e,n,t,i,a),d=Ee(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=u-d.centerY;s(!0,l,y,m),l!=null&&l.onDragStart&&l.onDragStart({x:c,y:u},l)}},kr=(e,n,t,r,s,o,l,i)=>{if(r&&s){!D.isNil(n)&&!D.isNil(n.style)&&(n.style.cursor=Be.Move);const a=s==null?void 0:s.id;Hn(i,a,Re.HOVERED);const c=(s==null?void 0:s.dragAxis)??le.Both,{xScaleID:u="x",yScaleID:d="y"}=s,{x:y,y:m}=Xn(e,n,t,u,d),p=Ee(s);let b=y-o,x=m-l;c!==le.Y&&pn(le.X,b,s,i,t,u,d,p),c!==le.X&&pn(le.Y,x,s,i,t,u,d,p),i.update(),s!=null&&s.onDrag&&s.onDrag({x:y,y:m},s);const{ctx:E,width:f,height:T}=i,{centerX:g,centerY:h}=Ee(s)??{},{centerX:P,centerY:L}=Yn(s,t,u,d);if(!D.isNil(g)&&!D.isNil(h)&&!D.isNil(P)&&!D.isNil(L)&&(E.save(),E.clearRect(0,0,f,T),i.draw(),E.font=dt,E.fillStyle="black",s!=null&&s.displayDragCoordinates)){let C=P-45,S=L-20;const N=`X: ${ee(g,2)}, Y: ${ee(h,2)}`,w=14;S-w<0&&(S=L+w+15),S>T&&(S=T-7),E.fillText(N,C,S),E.restore()}}},Gr=(e,n,t,r,s)=>{if(e&&n){const o=n==null?void 0:n.id;Hn(t,o,Re.ZERO);const{centerX:l=-1,centerY:i=-1}=Ee(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)}},zr=(e,n,t)=>{Object.values(n).forEach(r=>{var s;if(r.type===k.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:a,padding:c}=(r==null?void 0:r.label)??{},{xScaleID:u="x",yScaleID:d="y"}=r;e.save(),e.font=l,e.fillStyle=i;const{centerX:y=-1,centerY:m=-1}=Yn(r,t,u,d),p=e.measureText(o).width;let b=y-p/2,x=m+20;switch(a){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()}})},Vr={id:"annotationDraggerPlugin",beforeDraw(e){var s,o,l,i,a,c,u,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;zr(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=(a=e==null?void 0:e.options)==null?void 0:a.plugins)!=null&&c.tooltip&&(e.options.plugins.tooltip.enabled=!1),e.options.hover={mode:void 0,intersect:!1}):((d=(u=e==null?void 0:e.options)==null?void 0:u.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,E,f,T;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?((E=(x=e==null?void 0:e.options)==null?void 0:x.plugins)!=null&&E.tooltip&&(e.options.plugins.tooltip.enabled=!1),e.options.hover={mode:void 0,intersect:!1}):((T=(f=e==null?void 0:e.options)==null?void 0:f.plugins)!=null&&T.tooltip&&(e.options.plugins.tooltip.enabled=!0),e.options.hover={mode:be.Nearest,intersect:!0});let i=!1,a,c,u=null;const d=(g,h,P,L)=>{i=g,u=h,P!==void 0&&L!==void 0&&(a=P,c=L)};!n.dataset.annotationDraggerInitialized&&s.enabled&&r&&(n.addEventListener(K.MOUSEDOWN,g=>{var h,P,L;jr(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(()=>kr(g,n,o,i,u,a,c,e),5)()}),n.addEventListener(K.MOUSEUP,g=>{const h=g.currentTarget;Gr(i,u,e,h,d)}),n.dataset.annotationDraggerInitialized="true"),s.enabled||(n.removeEventListener(K.MOUSEDOWN,()=>{}),n.removeEventListener(K.MOUSEMOVE,()=>{}),n.removeEventListener(K.MOUSEUP,()=>{}),n.dataset.annotationDraggerInitialized="")}};yt.register(pt,ht,xt,_t,Tt,Et,Pt,Lt,Ot,Ct,St,ss,vr,Vr,us);const Rr=e=>{var N,w;gt();const n=O.useRef(null),{table:t,headerComponent:r,subheaderComponent:s}=e??{},{translations:o,languageKey:l}=is(),i=Vn(e),{data:{datasets:a}={datasets:[]},options:c,testId:u,persistenceId:d,controlsPortalId:y}=i,{annotations:m,axes:p,chartStyling:b,graph:x}=c??{},E=!((w=(N=c==null?void 0:c.legend)==null?void 0:N.customLegend)!=null&&w.customLegendContainerID),[f,T]=O.useReducer(Ss,{options:c,persistenceId:d,chartRef:n},ws),g=O.useMemo(()=>lr(a,f,c,o),[f.lineEnabled,f.pointsEnabled,a,p,m,x]);Lr({chartRef:n,options:c,state:f,dispatch:T,persistenceId:d});const{resetZoom:h,handleKeyDown:P,handleKeyUp:L}=He({chartRef:n,state:f,options:c,dispatch:T,generatedDatasets:g}),C=hr({chartRef:n,state:f,options:c,dispatch:T,generatedDatasets:g}),S=xr({options:c,resetZoom:h});return _.jsxs("div",{className:mt(b,De),style:{width:b.width||Me,height:b.height||Me},tabIndex:0,onKeyDown:P,onKeyUp:L,"data-testid":u,children:[_.jsx(zn,{table:t,headerComponent:r,subheaderComponent:s,chartRef:n,state:f,options:c,dispatch:T,generatedDatasets:g,translations:o,controlsPortalId:y}),t&&f.showTable?_.jsx("div",{className:De.table,children:t}):_.jsx(Qt,{backend:es,context:window,children:_.jsxs("div",{className:De.canvas,id:"canvas",children:[_.jsx(bt,{ref:n,data:{datasets:g},options:C,plugins:S}),E&&!!g.length&&_.jsx(ns,{chartRef:n,legendConfig:{options:c,generatedDatasets:g,chartType:ts.LINE}})]})})]},Us([...Object.values(f),l]))},Br=e=>{const{options:n}=Vn(e);return _.jsx(ft,{options:n,children:_.jsx(Rr,{...e})})};Br.__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{Br as L,$r as i};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var u=Object.create,_=Object.defineProperty,c=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,s=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,O=(e,r)=>function(){return e&&(r=(0,e[a(e)[0]])(e=0)),r},b=(e,r)=>function(){return r||(0,e[a(e)[0]])((r={exports:{}}).exports,r),r.exports},v=(e,r)=>{for(var t in r)_(e,t,{get:r[t],enumerable:!0})},p=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of a(r))!l.call(e,o)&&o!==t&&_(e,o,{get:()=>r[o],enumerable:!(n=c(r,o))||n.enumerable});return e},y=(e,r,t)=>(t=e!=null?u(s(e)):{},p(!e||!e.__esModule?_(t,"default",{value:e,enumerable:!0}):t,e)),P=e=>p(_({},"__esModule",{value:!0}),e);const i=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{y as _,b as a,O as b,P as c,v as d,i as r};
|