import{a as i}from"./chunk-C5X6SCSP.js";import{El as s,Kg as f,Lg as N,qm as k,ul as b}from"./chunk-J3OKDS6D.js";import{i as T}from"./chunk-Z427YWOQ.js";T();var v=class{constructor(a,o){this.ctx=a;let t=$("#"+o,a.$container)[0],u=a.settings,m=this.createGaugeOptions(t,u);this.gauge=this.createGauge(m).draw()}update(){if(this.ctx.data.length>0){let a=this.ctx.data[0];if(a.data.length>0){let o=a.data[a.data.length-1],t=parseFloat(o[1]);this.formatValue&&(t=parseFloat(this.formatValue.format(t))),t!==this.gauge.value&&(this.gauge.options.animation?delete this.gauge._value:this.gauge._value=t,this.gauge.value=t)}}}mobileModeChanged(){let a=this.ctx.settings.animation!==!1&&!this.ctx.isMobile;this.gauge.update({animation:a})}resize(){this.ctx.width>0&&this.ctx.height>0&&this.gauge.update({width:this.ctx.width,height:this.ctx.height})}destroy(){this.gauge.destroy(),this.gauge=null}},B=class extends v{constructor(a,o){super(a,o)}createGaugeOptions(a,o){let t=R(this.ctx,o),u=C(this.ctx,o);this.formatValue=k.fromSettings(this.ctx.$injector,{units:t,decimals:u,ignoreUnitSymbol:!0});let m=this.ctx.$injector.get(s).getTargetUnitSymbol(t),n=Number(this.formatValue.format(o.minValue||0)),c=Number(this.formatValue.format(o.maxValue||100)),x=this.ctx.data[0].dataKey,h=o.defaultColor||x.color,D=o.majorTicksCount||10,p=c-n,d=p/D,z=o.valueInt||3;d=parseFloat(parseFloat(d+"").toFixed(u))||1;let w=[],F=[],r=n,V=!1;for(o?.highlights?.length>0&&(V=!0,o.highlights.forEach(l=>{F.push({from:Number(this.formatValue.format(l.from)),to:Number(this.formatValue.format(l.to)),color:l.color})}));r<=c;){w.push(r);let l=r+d;if(l=parseFloat(parseFloat(l+"").toFixed(u)),r<c&&!V){let S=b(h),W=(r-n)/p;S.setAlpha(W);let j={from:r,to:l,color:S.toRgbString()};F.push(j)}r=l}let U=b(h).darken(20).toRgbString(),y={renderTo:a,minValue:n,maxValue:c,majorTicks:w,minorTicks:o.minorTicks||2,units:m,title:o.showUnitTitle!==!1?o.unitTitle&&o.unitTitle.length>0?o.unitTitle:x.label:"",borders:o.showBorder!==!1,borderShadowWidth:o.showBorder!==!1?3:0,valueInt:z,valueDec:u,majorTicksInt:1,majorTicksDec:0,valueBox:o.valueBox!==!1,valueBoxStroke:5,valueBoxWidth:0,valueText:"",valueTextShadow:!0,valueBoxBorderRadius:2.5,highlights:F,highlightsWidth:f(o.highlightsWidth)&&o.highlightsWidth!==null?o.highlightsWidth:15,fontNumbers:i(o.numbersFont),fontTitle:i(o.titleFont),fontUnits:i(o.unitsFont),fontValue:i(o.valueFont),fontNumbersSize:o.numbersFont&&o.numbersFont.size?o.numbersFont.size:18,fontTitleSize:o.titleFont&&o.titleFont.size?o.titleFont.size:24,fontUnitsSize:o.unitsFont&&o.unitsFont.size?o.unitsFont.size:22,fontValueSize:o.valueFont&&o.valueFont.size?o.valueFont.size:40,fontNumbersStyle:o.numbersFont&&o.numbersFont.style?o.numbersFont.style:"normal",fontTitleStyle:o.titleFont&&o.titleFont.style?o.titleFont.style:"normal",fontUnitsStyle:o.unitsFont&&o.unitsFont.style?o.unitsFont.style:"normal",fontValueStyle:o.valueFont&&o.valueFont.style?o.valueFont.style:"normal",fontNumbersWeight:o.numbersFont&&o.numbersFont.weight?o.numbersFont.weight:"500",fontTitleWeight:o.titleFont&&o.titleFont.weight?o.titleFont.weight:"500",fontUnitsWeight:o.unitsFont&&o.unitsFont.weight?o.unitsFont.weight:"500",fontValueWeight:o.valueFont&&o.valueFont.weight?o.valueFont.weight:"500",colorNumbers:o.numbersFont&&o.numbersFont.color?o.numbersFont.color:U,colorTitle:o.titleFont&&o.titleFont.color?o.titleFont.color:"#888",colorUnits:o.unitsFont&&o.unitsFont.color?o.unitsFont.color:"#888",colorValueText:o.valueFont&&o.valueFont.color?o.valueFont.color:"#444",colorValueTextShadow:o.valueFont&&o.valueFont.shadowColor?o.valueFont.shadowColor:"rgba(0,0,0,0.3)",colorPlate:o.colorPlate||"#fff",colorMajorTicks:o.colorMajorTicks||"#444",colorMinorTicks:o.colorMinorTicks||"#666",colorNeedle:o.colorNeedle||h,colorNeedleEnd:o.colorNeedleEnd||h,colorValueBoxRect:o.colorValueBoxRect||"#888",colorValueBoxRectEnd:o.colorValueBoxRectEnd||"#666",colorValueBoxBackground:o.colorValueBoxBackground||"#babab2",colorValueBoxShadow:o.colorValueBoxShadow||"rgba(0,0,0,1)",colorNeedleShadowUp:o.colorNeedleShadowUp||"rgba(2,255,255,0.2)",colorNeedleShadowDown:o.colorNeedleShadowDown||"rgba(188,143,143,0.45)",animation:o.animation!==!1&&!this.ctx.isMobile,animationDuration:f(o.animationDuration)&&o.animationDuration!==null?o.animationDuration:500,animationRule:o.animationRule||"cycle",animatedValue:!0};return this.prepareGaugeOptions(o,y),y}};function C(e,a){let o;return e.data&&e.data[0]&&(o=e.data[0].dataKey),o&&N(o.decimals)?o.decimals:e.decimals??0}function R(e,a){let o;return e.data&&e.data[0]&&(o=e.data[0].dataKey),o?.units?o.units:a.units??e.units}export{v as a,B as b};
