(function(M,C){typeof exports=="object"&&typeof module<"u"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(M=typeof globalThis<"u"?globalThis:M||self,C(M.savyg={}))})(this,function(M){"use strict";var C=(t=>(t.CIRCLE="circle",t.DEFS="defs",t.G="g",t.LINE="line",t.LINEAR_GRADIENT="linearGradient",t.PATH="path",t.POLYGON="polygon",t.RADIAL_GRADIENT="radialGradient",t.RECT="rect",t.STOP="stop",t.SVG="svg",t.FOREIGN_OBJECT="foreignObject",t.TEXT="text",t.CLIP_PATH="clipPath",t.USE="use",t.MARKER="marker",t.ARROW="arrow",t))(C||{}),ee=(t=>(t.XMLNS="http://www.w3.org/2000/svg",t))(ee||{});function fe(t){const e=t.split(" ");return{startX:+e[0],startY:+e[1],width:+e[2],height:+e[3]}}function se(t,e){let d;return e?d=t.flatMap(n=>n.values.map(r=>H(r)).filter((r,u)=>u>=e.start&&u<=e.end).filter(r=>r!==null)):d=t.flatMap(n=>n.values.map(r=>H(r)).filter(r=>r!==null)),{max:Math.max(...d),min:Math.min(...d)>=0?0:Math.min(...d)}}function he(t,e){return e?{maxSeriesLength:Math.max(...t.map(d=>d.values.map(n=>H(n)).filter((n,r)=>r>=e.start&&r<=e.end).length))}:{maxSeriesLength:Math.max(...t.map(d=>d.values.length))}}function ie(t,e,d){const n=$e(e-t,!1),r=$e(n/(d-1),!0),u=Math.floor(t/r)*r,a=Math.ceil(e/r)*r,l=[];for(let c=u;c<=a;c+=r)l.push(c);return{min:u,max:a,tickSize:r,ticks:l}}function $e(t,e){const d=Math.floor(Math.log10(t)),n=t/Math.pow(10,d);let r;return e?n<1.5?r=1:n<3?r=2:n<7?r=5:r=10:n<=1?r=1:n<=2?r=2:n<=5?r=5:r=10,r*Math.pow(10,d)}function ge(t,e){return t/e}function J(){const t=new Uint8Array(16);return window.crypto.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128,"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e,d){const n=t[d>>1];return(e==="x"?n&15:n&3|8).toString(16)})}function Ne(t){return[[Math.cos(t),-Math.sin(t)],[Math.sin(t),Math.cos(t)]]}function Me([t,e],[d,n]){return[t+d,e+n]}function Ee([[t,e],[d,n]],[r,u]){return[t*r+e*u,d*r+n*u]}function be([t,e],[d,n],[r,u],a,l=360,c=2,f=!1){u=u%(c*Math.PI);const h=Ne(a),[y,p]=Me(Ee(h,[d*Math.cos(r),n*Math.sin(r)]),[t,e]),[x,A]=Me(Ee(h,[d*Math.cos(r+u),n*Math.sin(r+u)]),[t,e]),L=u>Math.PI?1:0,Y=u>0?f?0:1:f?1:0;return{startX:f?x:y,startY:f?A:p,endX:f?y:x,endY:f?p:A,path:`M${f?x:y} ${f?A:p} A ${[d,n,a/(c*Math.PI)*l,L,Y,f?y:x,f?p:A].join(" ")}`}}function Te({series:t,cx:e,cy:d,rx:n,ry:r,piProportion:u=1.99999,piMult:a=2,arcAmpl:l=1.45,degrees:c=360,rotation:f=105.25,size:h=0}){if(!t)return{...t,proportion:0,ratio:0,path:"",startX:0,startY:0,endX:0,endY:0,center:{}};const y=[...t].map(A=>A.value).reduce((A,L)=>A+L,0),p=[];let x=0;for(let A=0;Ac===0?`${l.x},${l.y} `:`${a} ${r(l,c,f)} `,"")}function $(t){const e=document.createElementNS(ee.XMLNS,t.el);return Object.keys(t.options).length&&Object.entries(t.options).forEach(([d,n])=>{const r=d;d==="className"&&t.options.className&&t.options.className!==""?t.options.className.split(" ").forEach(u=>{e.classList.add(u)}):!["className","content","xlink:href"].includes(d)&&![void 0,null].includes(n)&&e.setAttribute(r,String(n))}),t.options.content&&(e.innerHTML=t.options.content),t.options["xlink:href"]&&e.setAttributeNS(ee.XMLNS,"xlink:href",t.options["xlink:href"]),t.parent&&t.parent.appendChild(e),e}function te(t){return $({el:C.CIRCLE,options:t.options,parent:t.parent})}function j(t){return $({el:C.LINE,options:t.options,parent:t.parent})}function me(t){return $({el:C.RECT,options:t.options,parent:t.parent})}function Be(t){return $({el:C.POLYGON,options:t.options,parent:t.parent})}function K(t){return $({el:C.PATH,options:t.options,parent:t.parent})}function Oe(t){return $({el:C.CLIP_PATH,options:t.options,parent:t.parent})}function Ye(t){return $({el:C.USE,options:t.options,parent:t.parent})}function D(t){return $({el:C.TEXT,options:t.options,parent:t.parent})}function Ce(t){return $({el:C.MARKER,options:t.options,parent:t.parent})}function De(t){const e=J(),d=$({el:C.G,options:{className:"savyg-arrow"}}),n=$({el:C.DEFS,options:{},parent:d}),r=t.options.size??10,u=`0 0 ${r} ${r}`,a=r/2,l=r/2,c=a*1.2,f=l*1.2;if(["end","both"].includes(t.options.marker)){const h=Ce({options:{id:`marker-end-${e}`,orient:"auto",viewBox:u,refX:a,refY:l,markerHeight:t.options.markerHeight??f,markerWidth:t.options.markerWidth??c},parent:n});K({options:{d:`M 0 0 L ${r} ${a} L 0 ${r} z`,fill:t.options.stroke},parent:h})}if(["start","both"].includes(t.options.marker)){const h=Ce({options:{id:`marker-start-${e}`,orient:"auto-start-reverse",viewBox:u,refX:a,refY:l,markerHeight:t.options.markerHeight??f,markerWidth:t.options.markerWidth??c},parent:n});K({options:{d:`M 0 0 L ${r} ${a} L 0 ${r} z`,fill:t.options.stroke},parent:h})}return j({options:{x1:t.options.x1,y1:t.options.y1,x2:t.options.x2,y2:t.options.y2,stroke:t.options.stroke,"stroke-width":t.options["stroke-width"],"stroke-dasharray":t.options["stroke-dasharray"],"stroke-dashoffset":t.options["stroke-dashoffset"],"stroke-linecap":t.options["stroke-linecap"],"stroke-linejoin":t.options["stroke-linejoin"],"shape-rendering":t.options["shape-rendering"],"marker-end":["end","both"].includes(t.options.marker)?`url(#marker-end-${e})`:"","marker-start":["start","both"].includes(t.options.marker)?`url(#marker-start-${e})`:""},parent:d}),t.parent&&t.parent.appendChild(d),d}function Pe({centerX:t,centerY:e,outerPoints:d,radius:n,rotation:r}){const u=Math.PI/d,a=r;let l="";for(let c=0;c{const r=document.createElementNS(ee.XMLNS,C.STOP);r.setAttribute("offset",n.offset),r.setAttribute("stop-color",n["stop-color"]),n["stop-opacity"]&&r.setAttribute("stop-opacity",String(n["stop-opacity"])),d.appendChild(r)}),e.appendChild(d),t.parent&&t.parent.appendChild(e),e}function Ge(t){const e=document.createElementNS(ee.XMLNS,C.DEFS),d=document.createElementNS(ee.XMLNS,C.RADIAL_GRADIENT);return d.setAttribute("id",t.id),t.cx&&d.setAttribute("cx",t.cx),t.cy&&d.setAttribute("cy",t.cy),t.fx&&d.setAttribute("fx",t.fx),t.fy&&d.setAttribute("fy",t.fy),t.fr&&d.setAttribute("fr",t.fr),t.gradientUnits&&d.setAttribute("gradientUnits",t.gradientUnits),t.spreadMethod&&d.setAttribute("spreadMethod",t.spreadMethod),t.stops.forEach(n=>{const r=document.createElementNS(ee.XMLNS,C.STOP);r.setAttribute("offset",n.offset),r.setAttribute("stop-color",n["stop-color"]),n["stop-opacity"]&&r.setAttribute("stop-opacity",String(n["stop-opacity"])),d.appendChild(r)}),e.appendChild(d),t.parent&&t.parent.appendChild(e),e}function de(t){const e=t.getTotalLength();let d=0,n=e,r=e/2;const u=.01;for(;n-d>u;){const c=(d+n)/2,h=t.getPointAtLength(c).x;if(Math.abs(h-r)e-d&&te+d:return"left";case te-d&&te+d:return"start";case t({...i,values:i.values.map(s=>H(s)),"stroke-dasharray":i["stroke-dasharray"]??null,"stroke-dashoffset":i["stroke-dashoffset"]??null,"stroke-linecap":i["stroke-linecap"]??"round","stroke-linejoin":i["stroke-linejoin"]??"round","stroke-width":i["stroke-width"]??1.5,color:i.stroke??Le[m],dataLabelOffsetY:i.dataLabelOffsetY??0,dataLabelsColor:i.dataLabelsColor??"#000000",dataLabelsFontSize:i.dataLabelsFontSize??10,fill:i.fill??"none",gradientDirection:i.gradientDirection??"vertical",gradientFrom:i.gradientFrom??null,gradientTo:i.gradientTo??null,plotRadius:i.plotRadius??1,rounding:i.rounding??0,rx:i.rx??null,ry:i.ry??null,showDataLabels:i.showDataLabels??!0,type:i.type??"line",uid:J()})),u=[...r],a={axisColor:(e==null?void 0:e.axisColor)??"#000000",backgroundColor:(e==null?void 0:e.backgroundColor)??"#FFFFFF",barSpacing:(e==null?void 0:e.barSpacing)??0,fontFamily:(e==null?void 0:e.fontFamily)??"inherit",gridColor:(e==null?void 0:e.gridColor)??"#CCCCCC",interactive:(e==null?void 0:e.interactive)??!0,legendColor:(e==null?void 0:e.legendColor)??"#000000",legendFontSize:(e==null?void 0:e.legendFontSize)??10,paddingBottom:(e==null?void 0:e.paddingBottom)??48,paddingLeft:(e==null?void 0:e.paddingLeft)??48,paddingRight:(e==null?void 0:e.paddingRight)??24,paddingTop:(e==null?void 0:e.paddingTop)??48,selectorColor:(e==null?void 0:e.selectorColor)??"#00000010","shape-rendering":(e==null?void 0:e["shape-rendering"])??"auto",showAxis:(e==null?void 0:e.showAxis)??!0,showGrid:(e==null?void 0:e.showGrid)??!0,showLegend:(e==null?void 0:e.showLegend)??!0,title:(e==null?void 0:e.title)??"",titleColor:(e==null?void 0:e.titleColor)??"#000000",titleFontSize:(e==null?void 0:e.titleFontSize)??18,titlePosition:(e==null?void 0:e.titlePosition)??"start",tooltipBackgroundColor:(e==null?void 0:e.tooltipBackgroundColor)??"rgb(255,255,255,0.9)",tooltipColor:(e==null?void 0:e.tooltipColor)??"#000000",viewBox:(e==null?void 0:e.viewBox)??"0 0 512 341",xAxisLabelsColor:(e==null?void 0:e.xAxisLabelsColor)??"#000000",xAxisLabelsFontSize:(e==null?void 0:e.xAxisLabelsFontSize)??12,xAxisLabelsOffsetY:(e==null?void 0:e.xAxisLabelsOffsetY)??0,yAxisLabelsColor:(e==null?void 0:e.yAxisLabelsColor)??"#000000",yAxisLabelRounding:(e==null?void 0:e.yAxisLabelRounding)??1,yAxisLabelsFontSize:(e==null?void 0:e.yAxisLabelsFontSize)??12,zoomColor:(e==null?void 0:e.zoomColor)??"#00FF0010"},l=J(),c=ne({options:{viewBox:a.viewBox,className:(e==null?void 0:e.className)??"",id:(e==null?void 0:e.id)??`xy_${l}`}});c.dataset.savyg="line",c.style.fontFamily=a.fontFamily,c.style.background=a.backgroundColor;const{width:f,height:h}=fe(a.viewBox),y={left:a.paddingLeft,top:a.paddingTop,right:f-a.paddingRight,bottom:h-a.paddingBottom};let p=!1,x=[],{maxSeriesLength:A}=he(t);const L={start:0,end:A};function Y(){A=he(t,L).maxSeriesLength}let U,V;function N(){U=se(t,L).min<0?se(t,L).min:0,V=se(t,L).max}N();let v;function B(){v={min:ie(U,V,10).min,max:ie(U,V,10).max,ticks:ie(U,V,10).ticks}}B();function E(i){return y.bottom-(h-a.paddingBottom-a.paddingTop)*ge(i+I,q)}let I,q,Q,o;function w(){I=Math.abs(v.min),q=Math.abs(v.max+I),Q=y.bottom-(h-a.paddingBottom-a.paddingTop)*ge(I,q),o=(f-y.left-a.paddingRight)/A}w(),a.title&&D({options:{x:a.titlePosition==="middle"?f/2:a.titlePosition==="start"?y.left:y.right,y:a.paddingTop/2,"text-anchor":a.titlePosition,content:a.title,"font-weight":"bold",fill:a.titleColor,className:"savyg-title"},parent:c});const g=$({el:C.G,options:{className:"savyg-grid"},parent:c});function S(){if(a.showGrid){g.innerHTML="",v.ticks.forEach(i=>{const m=E(i);j({options:{x1:y.left,x2:y.right,y1:m,y2:m,stroke:a.gridColor,"stroke-linecap":"round","stroke-width":.6,"shape-rendering":a["shape-rendering"]},parent:g})});for(let i=1;i<=A;i+=1)j({options:{x1:y.left+o*i,x2:y.left+o*i,y1:y.top,y2:y.bottom,stroke:a.gridColor,"stroke-linecap":"round","stroke-width":.6,"shape-rendering":a["shape-rendering"]},parent:g})}if(a.showAxis){const i=j({options:{x1:y.left,x2:y.left,y1:y.top,y2:y.bottom,stroke:a.axisColor,"stroke-linecap":"round","shape-rendering":a["shape-rendering"]},parent:g});if([j({options:{x1:y.left,x2:y.right,y1:Q,y2:Q,stroke:a.axisColor,"stroke-linecap":"round","shape-rendering":a["shape-rendering"]},parent:g}),i].forEach(s=>s.dataset.savyg="axis"),v.ticks.forEach(s=>{const F=E(s);j({options:{x1:y.left,x2:y.left-5,y1:F,y2:F,stroke:a.axisColor,"stroke-linecap":"round","shape-rendering":a["shape-rendering"]},parent:g}),D({options:{x:y.left-7,y:F+a.yAxisLabelsFontSize/3,"text-anchor":"end","font-size":a.yAxisLabelsFontSize,content:G(s,a.yAxisLabelRounding),fill:a.yAxisLabelsColor},parent:g})}),e!=null&&e.xAxisLabels&&e.xAxisLabels.length){const s=e.xAxisLabels.filter((F,b)=>b>=L.start&&b<=L.end);for(let F=0;F["plot","line","area"].includes(i.type));function z(){T.innerHTML="",k.forEach(i=>{i.values.length&&i.values.filter((m,s)=>s>=L.start&&s<=L.end).forEach((m,s)=>{m!==null&&(te({options:{r:i.plotRadius,cx:y.left+o*s+o/2,cy:E(m),fill:i.color,stroke:i.stroke,"stroke-width":i["stroke-width"],"stroke-dasharray":i["stroke-dasharray"],"stroke-dashoffset":i["stroke-dashoffset"],"stroke-linecap":i["stroke-linecap"],"stroke-linejoin":i["stroke-linejoin"],"shape-rendering":a["shape-rendering"]},parent:T}),i.showDataLabels&&D({options:{x:y.left+o*s+o/2,y:E(m)-i.dataLabelsFontSize/2+i.dataLabelOffsetY,"text-anchor":"middle","font-size":i.dataLabelsFontSize,content:G(m,i.rounding),fill:i.dataLabelsColor},parent:T}))})})}const _=$({el:C.G,options:{className:"savyg-line"},parent:c}),R=u.filter(i=>i.type==="line");function O(){_.innerHTML="",R.forEach(i=>{if(i.values.length){const m=i.values.filter((s,F)=>F>=L.start&&F<=L.end).map((s,F)=>({x:y.left+o*F+o/2,y:s===null?null:E(s)}));K({options:{d:("M"+m.map(s=>s.y===null?"M ":`${s.x},${s.y} `).join(" ")).replace("MM","M").trimEnd().replace(/M$/,""),fill:"none",stroke:i.color,"stroke-width":i["stroke-width"],"stroke-dasharray":i["stroke-dasharray"],"stroke-dashoffset":i["stroke-dashoffset"],"stroke-linecap":i["stroke-linecap"],"stroke-linejoin":i["stroke-linejoin"],"shape-rendering":a["shape-rendering"]},parent:_})}})}const Z=$({el:C.G,options:{className:"savyg-area"},parent:c}),ce=u.filter(i=>i.type==="area");function ve(){Z.innerHTML="",ce.forEach(i=>{if(i.values.length){const m=i.values.filter((b,P)=>P>=L.start&&P<=L.end).map((b,P)=>({x:y.left+o*P+o/2,y:b===null?null:E(b)})),s=i.gradientFrom&&i.gradientTo&&i.gradientDirection,F=i.uid;if(s){const b=[{offset:"0%","stop-color":i.gradientFrom,"stop-opacity":1},{offset:"100%","stop-color":i.gradientTo,"stop-opacity":1}];ye({stops:b,id:F,parent:Z,direction:i.gradientDirection})}K({options:{d:`M ${m[0].x},${y.bottom} ${m.map(b=>b.y===null?" ":`${b.x},${b.y} `).join(" ")} ${m[m.length-1].x},${y.bottom}Z`,fill:s?`url(#${F})`:i.fill,stroke:i.color,"stroke-width":i["stroke-width"],"stroke-dasharray":i["stroke-dasharray"],"stroke-dashoffset":i["stroke-dashoffset"],"stroke-linecap":i["stroke-linecap"],"stroke-linejoin":i["stroke-linejoin"],"shape-rendering":a["shape-rendering"]},parent:Z})}})}const ue=$({el:C.G,options:{className:"savyg-bar"},parent:c});function He(){const i=u.filter(s=>s.type==="bar"),m=(f-a.paddingLeft-a.paddingRight)/i.length/A;ue.innerHTML="",i.forEach((s,F)=>{const b=s.gradientFrom&&s.gradientTo&&s.gradientDirection,P=s.uid,re=J();if(b){const X=[{offset:"0%","stop-color":s.gradientFrom,"stop-opacity":1},{offset:"100%","stop-color":s.gradientTo,"stop-opacity":1}],W=[{offset:"0%","stop-color":s.gradientTo,"stop-opacity":1},{offset:"100%","stop-color":s.gradientFrom,"stop-opacity":1}];ye({stops:X,id:P,parent:ue,direction:s.gradientDirection}),ye({stops:W,id:re,parent:ue,direction:s.gradientDirection})}s.values.filter((X,W)=>W>=L.start&&W<=L.end).forEach((X,W)=>{me({options:{x:y.left+m*F+m*W*i.length+a.barSpacing,y:(X??0)<0?Q:E(X??0),height:(X??0)>=0?Q-E(X??0):E(X??0)-Q,width:m-a.barSpacing*2,fill:b?(X??0)>0?`url(#${P})`:`url(#${re})`:s.color,rx:s.rx??void 0,ry:s.ry??void 0,"shape-rendering":a["shape-rendering"]},parent:ue}),X!==null&&D({options:{x:y.left+m*F+m*W*i.length+a.barSpacing+(m/2-a.barSpacing),y:E(X??0)+((X??0)<0?s.dataLabelsFontSize+s.dataLabelOffsetY:-s.dataLabelsFontSize/2-s.dataLabelOffsetY),"text-anchor":"middle","font-size":s.dataLabelsFontSize,content:G(X??0,s.rounding),fill:s.dataLabelsColor},parent:ue})})})}if(a.showLegend){let i=function(b){if(n!=null&&n.onClickLegend)return n==null?void 0:n.onClickLegend({item:r[b]})},m=function(b){if(n!=null&&n.onHoverLegend)return n==null?void 0:n.onHoverLegend({item:r[b]})};const s=$({el:C.FOREIGN_OBJECT,options:{x:y.left,y:y.bottom+a.xAxisLabelsFontSize*1.2+a.xAxisLabelsOffsetY,height:a.paddingBottom-a.xAxisLabelsFontSize*1.2+a.xAxisLabelsOffsetY,width:f-a.paddingLeft-a.paddingRight}});s.style.background="transparent";const F=document.createElement("div");F.classList.add("savyg-legend"),F.setAttribute("style",`display:flex;align-items:center;justify-content:center;flex-direction:row;column-gap:12px;width:100%;height:100%;font-family:inherit;font-size:${a.legendFontSize}px;overflow:visible`),u.forEach((b,P)=>{const re=document.createElement("div");re.setAttribute("style","display:flex;flex-direction:row;gap:4px;font-size:inherit;width:100%;align-items:center;justify-content:center;align-items:center");const X=ne({options:{viewBox:"0 0 20 20",height:"12",width:"12"}});F.style.background="transparent",te({options:{cx:10,cy:10,r:9,fill:b.gradientFrom&&b.gradientTo&&b.gradientDirection?`url(#${b.uid})`:b.color,"shape-rendering":a["shape-rendering"]},parent:X});const W=document.createElement("span");W.style.maxWidth="calc(100% - 24px)",W.style.whiteSpace="nowrap",W.style.color=a.legendColor,W.innerHTML=b.name,[X,W].forEach(qe=>{re.appendChild(qe)}),F.appendChild(re),n!=null&&n.onClickLegend&&re.addEventListener("click",()=>i(P)),n!=null&&n.onHoverLegend&&re.addEventListener("mouseenter",()=>m(P))}),s.appendChild(F),c.appendChild(s)}const le=J(),ae={x:0,y:0};function Ie(i){const m=document.getElementById(le),s=document.getElementById(`${l}_${i}`),F=i+L.start;s.setAttribute("fill",a.selectorColor);let b="";e!=null&&e.xAxisLabels&&(e!=null&&e.xAxisLabels.length)&&(b+=`
${e.xAxisLabels[F]}
`),r.forEach(P=>{b+=`
${P.name} : ${[void 0,null].includes(P.values[F])?"-":G(P.values[F]??0,P.rounding)}
`}),m.innerHTML=b}function Se(i){document.getElementById(le).setAttribute("style","display:none");const s=document.getElementById(`${l}_${i}`);s==null||s.setAttribute("fill","transparent")}function Ve(i,m){if(!p){ae.x=i.clientX,ae.y=i.clientY;const F=document.getElementById(le);F.setAttribute("style",`min-width:0;padding:12px;display:flex;position:fixed;top:${ae.y+24}px;left:${ae.x}px;flex-direction:column;gap:3px;align-items:start;background:${a.tooltipBackgroundColor};color:${a.tooltipColor};font-family:inherit;box-shadow:0 6px 12px -6px rgba(0,0,0,0.3);width:200px;`);const b=F.getBoundingClientRect(),P=c.getBoundingClientRect();i.clientX+b.width/2>P.right?F.style.left=String(ae.x-b.width)+"px":i.clientX-b.width/2P.bottom&&(F.style.top=String(ae.y-b.height-48)+"px")}const s=document.querySelectorAll(`[data-savyg-zoom="${l}"]`);p&&(x.includes(m)||x.push(m),Array.from(s).forEach((F,b)=>{(b===m||x.includes(b))&&F.setAttribute("fill",a.zoomColor)}))}const we=document.createElement("div");we.setAttribute("id",le),we.classList.add("savyg-tooltip"),we.style.display="none",d&&d.appendChild(we);const _e=$({el:C.G,options:{className:"savyg-tooltip-trap"},parent:c});function We(i){if(n!=null&&n.onHoverPeriod)return n==null?void 0:n.onHoverPeriod({item:r.map(m=>({...m,value:m.values[i]??null}))})}function je(){if(a.interactive){_e.innerHTML="";for(let i=0;iWe(i)),m.addEventListener("mouseenter",()=>!p&&Ie(i)),m.addEventListener("mouseleave",()=>Se(i)),m.addEventListener("mousemove",s=>Ve(s,i)),m.addEventListener("mousedown",()=>Ue(i)),m.addEventListener("mouseup",()=>Ze(i))}}}function Ue(i){if(Se(i),p=!0,L.start=i,n!=null&&n.onClickPeriod)return n==null?void 0:n.onClickPeriod({item:r.map(m=>({...m,value:m.values[i]??null}))})}function Ze(i){if(Se(i),L.end=i,p=!1,x=[],L.endH(o.value)).reduce((o,w)=>o+w,0),a=t.map((o,w)=>{const g=H(o.value);return{...o,value:g,color:o.color??Le[w],"stroke-width":o["stroke-width"]??20,"stroke-linecap":o["stroke-linecap"]??"butt",uid:J(),proportion:g/u}}).sort((o,w)=>w.proportion-o.proportion),l={backgroundColor:(e==null?void 0:e.backgroundColor)??"#FFFFFF",dataLabelsAsDivs:(e==null?void 0:e.dataLabelsAsDivs)??!1,dataLabelsColor:(e==null?void 0:e.dataLabelsColor)??"#000000",dataLabelsFontSize:(e==null?void 0:e.dataLabelsFontSize)??12,dataLabelsRoundingPercentage:(e==null?void 0:e.dataLabelsRoundingPercentage)??0,dataLabelsRoundingValue:(e==null?void 0:e.dataLabelsRoundingValue)??0,dataLabelsOffset:(e==null?void 0:e.dataLabelsOffset)??40,dataLabelsLineOffset:(e==null?void 0:e.dataLabelsLineOffset)??20,donutBorderWidth:(e==null?void 0:e.donutBorderWidth)??1,donutThickness:(e==null?void 0:e.donutThickness)??48,donutRadiusRatio:(e==null?void 0:e.donutRadiusRatio)??1,fontFamily:(e==null?void 0:e.fontFamily)??"inherit",hideLabelUnderPercentage:(e==null?void 0:e.hideLabelUnderPercentage)??3,interactive:(e==null?void 0:e.interactive)??!0,legendColor:(e==null?void 0:e.legendColor)??"#000000",legendFontSize:(e==null?void 0:e.legendFontSize)??10,legendOffsetY:(e==null?void 0:e.legendOffsetY)??40,paddingBottom:(e==null?void 0:e.paddingBottom)??36,paddingLeft:(e==null?void 0:e.paddingLeft)??0,paddingRight:(e==null?void 0:e.paddingRight)??0,paddingTop:(e==null?void 0:e.paddingTop)??96,"shape-rendering":(e==null?void 0:e["shape-rendering"])??"auto",showDataLabels:(e==null?void 0:e.showDataLabels)??!0,showLegend:(e==null?void 0:e.showLegend)??!0,showTotal:(e==null?void 0:e.showTotal)??!0,title:(e==null?void 0:e.title)??"",titleColor:(e==null?void 0:e.titleColor)??"#000000",titleFontSize:(e==null?void 0:e.titleFontSize)??18,titlePosition:(e==null?void 0:e.titlePosition)??"middle",tooltipBackgroundColor:(e==null?void 0:e.tooltipBackgroundColor)??"rgb(255,255,255,0.9)",tooltipColor:(e==null?void 0:e.tooltipColor)??"#000000",totalLabel:(e==null?void 0:e.totalLabel)??"Total",totalLabelColor:(e==null?void 0:e.totalLabelColor)??"#000000",totalLabelFontSize:(e==null?void 0:e.totalLabelFontSize)??20,totalValueFontSize:(e==null?void 0:e.totalValueFontSize)??20,totalValueRounding:(e==null?void 0:e.totalValueRounding)??0,viewBox:(e==null?void 0:e.viewBox)??"0 0 450 450"},c=ne({options:{viewBox:l.viewBox,className:(e==null?void 0:e.className)??"",id:(e==null?void 0:e.id)??r}});c.dataset.savyg="donut",c.style.fontFamily=l.fontFamily,c.style.backgroundColor=l.backgroundColor,c.style.overflow="visible";const{width:f,height:h}=fe(l.viewBox),y={left:l.paddingLeft,top:l.paddingTop,right:f-l.paddingRight,bottom:h-l.paddingBottom},p={top:l.paddingTop,right:y.right,left:y.left,bottom:y.bottom,height:h,width:f,fullHeight:h,fullWidth:f,centerX:f/2,centerY:h/2};let x=Te({series:a,cx:f/2,cy:h/2,rx:f/(5/l.donutRadiusRatio),ry:f/(5/l.donutRadiusRatio),size:l.donutThickness});const A=J(),L={x:0,y:0},Y=[{el:`${r}_##`,s:"savyg-arc-selected",u:"savyg-arc-unselected"},{el:`${r}_marker_name_##`,s:"savyg-marker-name-selected",u:"savyg-marker-name-unselected"},{el:`${r}_marker_value_##`,s:"savyg-marker-value-selected",u:"savyg-marker-value-unselected"},{el:`${r}_marker_line_##`,s:"savyg-marker-line-selected",u:"savyg-marker-line-unselected"},{el:`${r}_marker_circle_##`,s:"savyg-marker-circle-selected",u:"savyg-marker-circle-unselected"}];function U(o){const w=document.getElementById(A);for(let S=0;S{const k=document.getElementById(T.el.replace("##",S+""));k&&(S!==o?k.classList.add(T.u):k.classList.add(T.s))});let g="";g+=`
${a[o].name??"-"}
`,g+=`
${G(a[o].value/u*100,l.dataLabelsRoundingPercentage,"%")} (${G(a[o].value,l.dataLabelsRoundingValue)})
`,w.innerHTML=g}function V(){const o=document.getElementById(A);for(let w=0;w{const S=document.getElementById(g.el.replace("##",w+""));S&&(S.classList.remove(g.s),S.classList.remove(g.u))});o.setAttribute("style","display:none")}function N(o){L.x=o.clientX,L.y=o.clientY;const w=document.getElementById(A);w.setAttribute("style",`min-width:0;padding:12px;display:flex;position:fixed;top:${L.y+24}px;left:${L.x}px;flex-direction:column;gap:3px;align-items:start;background:${l.tooltipBackgroundColor};color:${l.tooltipColor};font-family:inherit;box-shadow:0 6px 12px -6px rgba(0,0,0,0.3);width:200px;`);const g=w.getBoundingClientRect(),S=c.getBoundingClientRect();o.clientX+g.width/2>S.right?w.style.left=String(L.x-g.width)+"px":o.clientX-g.width/2S.bottom&&(w.style.top=String(L.y-g.height-48)+"px")}const v=document.createElement("div");v.setAttribute("id",A),v.classList.add("savyg-tooltip"),v.style.display="none",d&&d.appendChild(v);const B=$({el:C.G,options:{className:"savyg-donut-arcs"},parent:c});if(x=x.map((o,w)=>({...o,borderPath:K({options:{d:o.path}}),path:K({options:{d:o.arcSlice,stroke:l.backgroundColor,"stroke-width":o.value<1?.1:l.donutBorderWidth,fill:o.color,id:`${r}_${w}`,"shape-rendering":l["shape-rendering"]}})})),l.showDataLabels){const o=$({el:C.G,options:{className:"savyg-marker"},parent:c});let w=a.map(g=>g.proportion*100).filter(g=>g{const T=de(g.borderPath),k=oe({initX:T.x,initY:T.y,offset:l.dataLabelsLineOffset,centerX:p.centerX,centerY:p.centerY}),z=oe({initX:T.x,initY:T.y,offset:l.dataLabelsLineOffset,centerX:p.centerX,centerY:p.centerY}),_=oe({initX:T.x,initY:T.y,offset:0,centerX:p.centerX,centerY:p.centerY});if(a[S].proportion*100>=l.hideLabelUnderPercentage){const R=oe({initX:T.x,initY:T.y,offset:l.dataLabelsOffset,centerX:p.centerX,centerY:p.centerY});if(l.dataLabelsAsDivs){const O={width:64,height:32},Z=document.createElement("DIV"),ce=xe({x:R.x,centerX:p.centerX,middleRange:30,isDiv:!0}),ve=$({el:C.FOREIGN_OBJECT,options:{className:"savyg-donut-datalabel",x:R.x-(ce==="right"?O.width:ce==="center"?O.width/2:0),y:R.y-O.height/2,width:O.width,height:O.height},parent:o});ve.setAttribute("style","overflow: visible"),Z.classList.add("savyg-donut-label-item"),Z.setAttribute("id",`${r}_marker_label_${S}`),Z.setAttribute("width","100%"),Z.setAttribute("height","100%"),Z.style.fontSize=`${l.dataLabelsFontSize}px`,Z.style.textAlign=ce,Z.innerHTML=`${g.name} : ${G(g.proportion*100,l.dataLabelsRoundingPercentage,"%")} (${G(g.value,l.dataLabelsRoundingValue)})`,ve.appendChild(Z)}else D({options:{x:R.x,y:R.y,fill:l.dataLabelsColor,"font-size":l.dataLabelsFontSize,"text-anchor":xe({x:R.x,centerX:p.centerX,middleRange:30}),content:g.name,id:`${r}_marker_name_${S}`},parent:o}),D({options:{x:R.x,y:R.y+l.dataLabelsFontSize,fill:l.dataLabelsColor,"font-size":l.dataLabelsFontSize,"text-anchor":xe({x:R.x,centerX:p.centerX,middleRange:30}),content:`${G(g.proportion*100,l.dataLabelsRoundingPercentage,"%")} (${G(g.value,l.dataLabelsRoundingValue)})`,id:`${r}_marker_value_${S}`},parent:o});j({options:{x1:_.x,y1:_.y,x2:k.x,y2:k.y,stroke:g.color,"stroke-width":1,id:`${r}_marker_line_${S}`,"shape-rendering":l["shape-rendering"]},parent:o}),te({options:{cx:k.x,cy:k.y,fill:g.color,r:3,stroke:"none",id:`${r}_marker_circle_${S}`,"shape-rendering":l["shape-rendering"]},parent:o})}else{const R=(p.centerX-z.x)/2,O=z.y*1.3-w*l.dataLabelsFontSize-R;K({options:{d:`M${_.x},${_.y} ${z.x},${O}`,stroke:g.color,"stroke-width":.6,id:`${r}_marker_line_${S}`,"stroke-linecap":"round","shape-rendering":l["shape-rendering"],fill:"none"},parent:o}),te({options:{cx:z.x,cy:O,fill:g.color,r:1.8,stroke:"none",id:`${r}_marker_circle_${S}`,"shape-rendering":l["shape-rendering"]},parent:o}),D({options:{x:z.x+6,y:O+l.dataLabelsFontSize*.6/4,fill:l.dataLabelsColor,"font-size":l.dataLabelsFontSize*.6,"text-anchor":"start",content:`${g.name} : ${G(g.proportion*100,l.dataLabelsRoundingPercentage,"%")} (${G(g.value,l.dataLabelsRoundingValue)})`,id:`${r}_marker_name_${S}`},parent:o}),w-=1}})}function E(o){if(n!=null&&n.onClickArc)return n==null?void 0:n.onClickArc({arc:{"stroke-width":x[o]["stroke-width"],arcMidpoint:de(x[o].path),color:x[o].color,cx:x[o].cx,cy:x[o].cy,name:x[o].name,path:x[o].path,proportion:x[o].proportion,uid:x[o].uid,value:x[o].value}})}function I(o){if(n!=null&&n.onHoverArc)return n==null?void 0:n.onHoverArc({arc:{"stroke-width":x[o]["stroke-width"],arcMidpoint:de(x[o].path),color:x[o].color,cx:x[o].cx,cy:x[o].cy,name:x[o].name,path:x[o].path,proportion:x[o].proportion,uid:x[o].uid,value:x[o].value}})}if(x.forEach((o,w)=>{const g=o.path;l.interactive&&(g.addEventListener("mouseenter",()=>U(w)),g.addEventListener("mouseleave",()=>V()),g.addEventListener("mousemove",S=>N(S)),n!=null&&n.onClickArc&&g.addEventListener("click",()=>E(w)),n!=null&&n.onHoverArc&&g.addEventListener("mouseenter",()=>I(w))),B.appendChild(g)}),l.showTotal&&(D({options:{x:f/2,y:h/2-l.totalLabelFontSize/3,"font-size":l.totalLabelFontSize,content:l.totalLabel,"text-anchor":"middle",fill:l.totalLabelColor},parent:c}),D({options:{x:f/2,y:h/2+l.totalValueFontSize,"font-size":l.totalValueFontSize,content:G(u,l.totalValueRounding),"text-anchor":"middle",fill:l.totalLabelColor},parent:c})),l.title&&D({options:{x:l.titlePosition==="middle"?f/2:l.titlePosition==="start"?y.left:y.right,y:l.paddingTop/2,"text-anchor":l.titlePosition,content:l.title,"font-weight":"bold",fill:l.titleColor,className:"savyg-title"},parent:c}),l.showLegend){let o=function(T){if(n!=null&&n.onClickLegend)return n==null?void 0:n.onClickLegend({arc:x[T],item:a[T]})},w=function(T){if(n!=null&&n.onHoverLegend)return n==null?void 0:n.onHoverLegend({arc:x[T],item:a[T]})};const g=$({el:C.FOREIGN_OBJECT,options:{x:y.left,y:y.bottom-l.legendOffsetY,height:l.paddingBottom+l.legendOffsetY,width:f}});g.style.background="transparent";const S=document.createElement("div");S.classList.add("savyg-legend"),S.setAttribute("style",`display:flex;align-items:center;justify-content:center;flex-direction:row;column-gap:12px;width:100%;height:100%;font-family:inherit;font-size:${l.legendFontSize}px;overflow:visible;flex-wrap:wrap`),a.forEach((T,k)=>{const z=document.createElement("div");z.setAttribute("style","display:flex;flex-direction:row;gap:4px;font-size:inherit;width:fit-content;max-width:100%;align-items:center;justify-content:center;align-items:center;");const _=ne({options:{viewBox:"0 0 20 20",height:"12",width:"12"}});S.style.background="transparent",te({options:{cx:10,cy:10,r:9,fill:T.color,"shape-rendering":l["shape-rendering"]},parent:_});const R=document.createElement("span");R.style.maxWidth="calc(100% - 24px)",R.style.whiteSpace="nowrap",R.style.color=l.legendColor,R.innerHTML=T.name,[_,R].forEach(O=>{z.appendChild(O)}),S.appendChild(z),n!=null&&n.onClickLegend&&z.addEventListener("click",()=>o(k)),n!=null&&n.onHoverLegend&&z.addEventListener("mouseenter",()=>w(k))}),g.appendChild(S),c.appendChild(g)}d&&d.appendChild(c);function q(o){if(c&&o){const w=document.getElementById(A);return w&&w.remove(),d?d.removeChild(c):o.removeChild(c),Ae({dataset:t,options:e,parent:o,callbacks:n})}}function Q(o){if(c&&d){const w=document.getElementById(A);return w&&w.remove(),d.removeChild(c),Ae({dataset:o,options:e,parent:d,callbacks:n})}else return}return{chart:c,refresh:q,updateData:Q,arcs:x.map((o,w)=>({...o,pathElement:o.path,arcMidPoint:de(o.path),name:a[w].name,color:a[w].color,uid:a[w].uid,value:a[w].value,percentage:a[w].proportion})),dimensions:{centerX:p.centerX,centerY:p.centerY}}}function Fe({dataset:t,options:e,parent:d}){const n=J(),r={arcThickness:(e==null?void 0:e.arcThickness)??58,backgroundColor:(e==null?void 0:e.backgroundColor)??"#FFFFFF",dataLabelsColor:(e==null?void 0:e.dataLabelsColor)??"#000000",dataLabelsFontSize:(e==null?void 0:e.dataLabelsFontSize)??12,dataLabelsOffset:(e==null?void 0:e.dataLabelsOffset)??1.4,fontFamily:(e==null?void 0:e.fontFamily)??"inherit",paddingBottom:(e==null?void 0:e.paddingBottom)??0,paddingLeft:(e==null?void 0:e.paddingLeft)??0,paddingRight:(e==null?void 0:e.paddingRight)??0,paddingTop:(e==null?void 0:e.paddingTop)??0,pointerBaseColor:(e==null?void 0:e.pointerBaseColor)??"#1A1A1A",pointerBaseRadius:(e==null?void 0:e.pointerBaseRadius)??5,pointerBaseStroke:(e==null?void 0:e.pointerBaseStroke)??"#FFFFFF",pointerBaseStrokeWidth:(e==null?void 0:e.pointerBaseStrokeWidth)??1,pointerColor:(e==null?void 0:e.pointerColor)??"#2A2A2A",pointerSize:(e==null?void 0:e.pointerSize)??1,pointerWidth:(e==null?void 0:e.pointerWidth)??5,"shape-rendering":(e==null?void 0:e["shape-rendering"])??"auto",showDataLabels:(e==null?void 0:e.showDataLabels)??!0,showValue:(e==null?void 0:e.showValue)??!0,title:(e==null?void 0:e.title)??"",titleColor:(e==null?void 0:e.titleColor)??"#000000",titleFontSize:(e==null?void 0:e.titleFontSize)??18,titleFontWeight:(e==null?void 0:e.titleFontWeight)??"bold",titlePosition:(e==null?void 0:e.titlePosition)??"middle",valueColor:(e==null?void 0:e.valueColor)??"#000000",valueFontSize:(e==null?void 0:e.valueFontSize)??20,valueFontWeight:(e==null?void 0:e.valueFontWeight)??"normal",valueRounding:(e==null?void 0:e.valueRounding)??0,viewBox:(e==null?void 0:e.viewBox)??"0 0 450 300"},u=ne({options:{viewBox:r.viewBox,className:(e==null?void 0:e.className)??"",id:(e==null?void 0:e.id)??`gauge_${n}`}});u.dataset.savyg="gauge",u.style.fontFamily=r.fontFamily,u.style.backgroundColor=r.backgroundColor;const{width:a,height:l}=fe(r.viewBox),c={left:r.paddingLeft,top:r.paddingTop,right:a-r.paddingRight,bottom:l-r.paddingBottom},f={top:r.paddingTop,right:c.right,left:c.left,bottom:c.bottom,height:l,width:a,fullHeight:l,fullWidth:a,centerX:a/2,centerY:l/2},h=function(){const B=[];return t.segments.forEach(E=>{B.push(H(E.from)),B.push(H(E.to))}),{max:Math.max(...B),min:Math.min(...B)}}(),y=function(){const B=f.centerX,E=f.centerY+l/4,I=Math.PI*((H(t.value)-h.min)/(h.max-h.min))+Math.PI;return{x1:B,y1:E,x2:B+f.width/(f.width/72.58*r.pointerSize)*Math.cos(I),y2:E+f.width/(f.width/72.58*r.pointerSize)*Math.sin(I)}}(),p={value:t.value,segments:[...t.segments.map((v,B)=>({...v,id:`${n}_segment_${B}`,color:v.color??Le[B],value:(H(v.to)-H(v.from))/h.max*100})),{color:"transparent",value:0,from:H(t.segments[t.segments.length-1].to),to:H(t.segments[t.segments.length-1].to)}]},x=$({el:C.G,options:{className:"savyg-gauge-arc"},parent:u});let A=Te({series:p.segments,cx:f.centerX,cy:f.centerY+l/4,rx:a/4,ry:a/4,piProportion:1,piMult:1,arcAmpl:r.dataLabelsOffset,degrees:180,rotation:Math.PI});A=A.map((v,B)=>({...v,path:K({options:{d:v.path,stroke:v.color,"stroke-width":r.arcThickness,fill:"none",className:`savyg-gauge-arc-path savyg-gauge-arc-path-${B}`,"shape-rendering":r["shape-rendering"]}})})),A.forEach(v=>{const B=v.path;x.appendChild(B)});const L=$({el:C.G,options:{className:"savyg-gauge-pointer"},parent:u});j({options:{...y,"stroke-width":r.pointerWidth,stroke:r.pointerColor,"stroke-linecap":"round",className:"savyg-gauge-pointer-arrow","shape-rendering":r["shape-rendering"]},parent:L}),te({options:{cx:f.centerX,cy:f.centerY+l/4,r:r.pointerBaseRadius,fill:r.pointerBaseColor,stroke:r.pointerBaseStroke,"stroke-width":r.pointerBaseStrokeWidth,className:"savyg-gauge-pointer-base","shape-rendering":r["shape-rendering"]},parent:L});const Y=$({el:C.G,options:{className:"savyg-gauge-data-labels"},parent:u});function U(v){return va/2+12?"start":"middle"}r.showDataLabels&&A.forEach(v=>{D({options:{x:v.center.startX,y:v.center.startY,"font-size":r.dataLabelsFontSize,fill:r.dataLabelsColor,content:String(v.from),"text-anchor":U(v.center.startX),className:"savyg-gauge-data-label"},parent:Y})}),r.title&&D({options:{x:r.titlePosition==="middle"?a/2:r.titlePosition==="start"?c.left:c.right,y:r.titleFontSize*1.5,content:r.title,"font-size":r.titleFontSize,fill:r.titleColor,className:"savyg-title","text-anchor":r.titlePosition,"font-weight":r.titleFontWeight},parent:u}),r.showValue&&D({options:{x:a/2,y:f.centerY+l/4+r.valueFontSize*2,content:G(t.value,r.valueRounding),fill:r.valueColor,"font-weight":r.valueFontWeight,"font-size":r.valueFontSize,"text-anchor":"middle",className:"savyg-gauge-value"},parent:u}),d&&d.appendChild(u);function V(v){if(u&&v)return d?d.removeChild(u):v.removeChild(u),Fe({dataset:t,options:e,parent:v})}function N(v){if(u&&d)return d.removeChild(u),Fe({dataset:v,options:e,parent:d})}return{chart:u,refresh:V,updateData:N,arcs:A.map(v=>({pathElement:v.path,color:v.color})),dimensions:{centerX:f.centerX,centerY:f.centerY+l/4}}}function pe({dataset:t,options:e,parent:d}){const n={...t,name:t.name??"",values:t.values.map(k=>H(k)),"stroke-dasharray":t["stroke-dasharray"]??null,"stroke-dashoffset":t["stroke-dashoffset"]??null,"stroke-linecap":t["stroke-linecap"]??"round","stroke-linejoin":t["stroke-linejoin"]??"round","stroke-width":t["stroke-width"]??1.5,color:t.stroke??Le[0],uid:J()},r={areaOpacity:(e==null?void 0:e.areaOpacity)??.3,axisColor:(e==null?void 0:e.axisColor)??"#CCCCCC",backgroundColor:(e==null?void 0:e.backgroundColor)??"#FFFFFF",fontFamily:(e==null?void 0:e.fontFamily)??"inherit",indicatorColor:(e==null?void 0:e.indicatorColor)??"","shape-rendering":(e==null?void 0:e["shape-rendering"])??"auto",paddingLeft:(e==null?void 0:e.paddingLeft)??3,paddingRight:(e==null?void 0:e.paddingRight)??3,paddingBottom:(e==null?void 0:e.paddingBottom)??3,rounding:(e==null?void 0:e.rounding)??0,showArea:(e==null?void 0:e.showArea)??!0,showGrid:(e==null?void 0:e.showGrid)??!1,showTitle:(e==null?void 0:e.showTitle)??!0,showValueOnHover:(e==null?void 0:e.showValueOnHover)??!0,titleFontSize:(e==null?void 0:e.titleFontSize)??8,titleFontWeight:(e==null?void 0:e.titleFontWeight)??"normal",viewBox:(e==null?void 0:e.viewBox)??"0 0 192 64"},u=J(),a=ne({options:{viewBox:r.viewBox,className:(e==null?void 0:e.className)??"",id:(e==null?void 0:e.id)??`spark_${u}`}});a.dataset.savyg="sparkLine",a.style.fontFamily=r.fontFamily,a.style.background=r.backgroundColor;const{width:l,height:c}=fe(r.viewBox);let{maxSeriesLength:f}=he([t]);const h={left:r.paddingLeft,top:r.showTitle||r.showValueOnHover?r.titleFontSize+3:3,right:l-r.paddingRight,bottom:c-r.paddingBottom,height:c-(r.showTitle||r.showValueOnHover?r.titleFontSize+3:3)-r.paddingBottom,width:l-r.paddingLeft-r.paddingRight},{max:y,min:p}=se([t]);function x(){return{min:ie(p,y,10).min,max:ie(p,y,10).max,ticks:ie(p,y,10).ticks}}const A=x();function L(k){return h.bottom-h.height*ge(k+Y,U)}const Y=Math.abs(A.min),U=Math.abs(A.max+Y),V=h.bottom-h.height*ge(Y,U),N=h.width/f,v=$({el:C.G,options:{className:"savyg-grid"},parent:a});function B(){if(r.showGrid){v.innerHTML="";const k=j({options:{x1:h.left,x2:h.right,y1:V,y2:V,stroke:r.axisColor,"stroke-linecap":"round","shape-rendering":r["shape-rendering"]},parent:v}),z=j({options:{x1:h.left,y1:h.top,x2:h.left,y2:h.bottom,stroke:r.axisColor,"stroke-linecap":"round","shape-rendering":r["shape-rendering"]},parent:v});[k,z].forEach(_=>_.dataset.savyg="axis")}}const E=n.values.map((k,z)=>({x:h.left+N*z+N/2,y:k===null?null:L(k)}));function I(){const k=$({el:C.G,options:{className:"savyg-line"},parent:a});if(k.innerHTML="",K({options:{d:"M"+ze(E),fill:"none",stroke:n.color,"stroke-width":n["stroke-width"],"stroke-dasharray":n["stroke-dasharray"],"stroke-dashoffset":n["stroke-dashoffset"],"stroke-linecap":n["stroke-linecap"],"stroke-linejoin":n["stroke-linejoin"],"shape-rendering":r["shape-rendering"]},parent:k}),r.showArea){const z=K({options:{d:`M${E[0].x},${h.bottom} `+ze(E)+` L ${E[E.length-1].x},${h.bottom} z`,fill:n.color,stroke:"none","stroke-linecap":n["stroke-linecap"],"stroke-linejoin":n["stroke-linejoin"],"shape-rendering":r["shape-rendering"]},parent:k});z.style.opacity=String(r.areaOpacity)}}function q({index:k,trap:z}){z.style.opacity="1";const _=document.getElementById(`title_${u}`);_&&r.showValueOnHover&&(_.innerHTML=`${n.name&&r.showTitle?n.name+" - ":""}${n.periods?n.periods[k]+" : ":""} ${Number(n.values[k].toFixed(r.rounding)).toLocaleString()}`)}function Q({trap:k}){k.style.opacity="0";const z=document.getElementById(`title_${u}`);z&&r.showValueOnHover&&(z.innerHTML=n.name&&r.showTitle?n.name:"")}function o(){const k=$({el:C.G,options:{className:"savyg-mouse-traps"},parent:a});k.innerHTML="",n.values.forEach((z,_)=>{const R=me({options:{x:h.left+_*N,y:h.top,height:h.height,width:N,fill:"transparent",id:`trap_${u}_${_}`},parent:k}),O=$({el:C.G,options:{className:"savyg-trap-indicator"},parent:k});j({options:{x1:h.left+_*N+N/2,x2:h.left+_*N+N/2,y1:h.top,y2:h.bottom,"stroke-linecap":"round","stroke-width":1,stroke:r.indicatorColor||n.color},parent:O}),te({options:{cx:h.left+_*N+N/2,cy:E[_].y,fill:r.indicatorColor||n.color,r:3,stroke:r.backgroundColor,"stroke-width":1},parent:O}),O.style.opacity="0",O.style.pointerEvents="none",R.addEventListener("mouseenter",()=>q({index:_,trap:O})),R.addEventListener("mouseout",()=>Q({trap:O}))})}function w(){D({options:{x:h.left+N/2,y:r.titleFontSize,content:r.showTitle?n.name:"",fill:"black","font-size":r.titleFontSize,id:`title_${u}`,"text-anchor":"start"},parent:a})}function g(){B(),n.values.length&&I(),o(),(r.showTitle||r.showValueOnHover)&&w()}g(),d&&d.appendChild(a);function S(k){if(a&&k)return d?d.removeChild(a):k.removeChild(a),pe({dataset:t,options:e,parent:k})}function T(k){if(a&&d)return d.removeChild(a),pe({dataset:k,options:e,parent:d})}return{chart:a,refresh:S,updateData:T}}M.arrow=De,M.calcPolygonPoints=Pe,M.chartDonut=Ae,M.chartGauge=Fe,M.chartSparkline=pe,M.chartXy=ke,M.circle=te,M.clipPath=Oe,M.element=$,M.findArcMidpoint=de,M.freePolygon=Be,M.line=j,M.linearGradient=ye,M.marker=Ce,M.offsetFromCenterPoint=oe,M.path=K,M.radialGradient=Ge,M.rect=me,M.regularPolygon=Xe,M.setTextAnchorFromCenterPoint=xe,M.svg=ne,M.text=D,M.use=Ye,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});