| Server IP : 167.99.254.82 / Your IP : 216.73.216.188 Web Server : Apache System : Linux host.techisquad.com 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 User : pawluxera ( 1011) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/webmin/authentic-theme/extensions/stats/ |
Upload File : |
/*!
* Authentic Theme (https://github.com/authentic-theme/authentic-theme)
* Copyright Ilia Rostovtsev <ilia@virtualmin.com>
* Licensed under MIT (https://github.com/authentic-theme/authentic-theme/blob/master/LICENSE)
*/
"use strict";const stats={sys:{error:0,tried:0,activating:0,requery:null,socket:null,socketSession:null,chartZoomRange:null,_:{prefix:v___location_prefix,error:connection_error,language:theme_language,convert:{size:Convert.nice_size},chart:uPlot,dayjs,locale:{time:config_portable_theme_locale_format_time,offset:()=>get_utc_offset()},can_conn_ws,blocked:theme_updating,getHistoryData:function(){return vars.stats.history}},selector:{chart:{container:{parent:"live_stats",data:"data-chart"},loader:"data-charts-loader"},collapse:"collapse",dashboard:"system-status",slider:"info-container",piechart:"piechart",defaultClassLabel:"bg-semi-transparent",defaultSliderClassLabel:"bg-semi-transparent-dark"},isAllowed:function(){return theme.visibility.get()&&(plugins.dashboard.visible()||plugins.slider.visible())},getSocketDefs:function(){return{session:this.socketSession||session.server.data("session-hash"),paused:this.canRender()?0:1,interval:this.getInterval(),disable:this.isEnabled()?0:1,shutdown:settings_sysinfo_real_time_shutdown_on_last?1:0}},graphsCanPreRender:function(){return document.querySelector(`[${this.selector.chart.loader}]`)?1:0},getInterval:function(){return settings_sysinfo_real_time_run_rate/1e3},getStoredDuration:function(){return settings_sysinfo_real_time_stored_duration},getRenderType:function(t){t=t.graphs;let e=!1;for(const a in t)if(t.hasOwnProperty(a)&&Array.isArray(t[a])&&t[a].length>1){e=!0;break}return e?3:null},canRender:function(){return theme.visibility.get()},isEnabled:function(){const t=settings_sysinfo_real_time_status?1:0,e=this._.can_conn_ws();return t&&e},restart:function(){this.shutdown(),setTimeout(()=>{this.enable()},1e3*this.getInterval()*4)},toggle:function(){setTimeout(()=>{this.isAllowed()?this.enable():this.disable()},200)},_toggleLimiter:(()=>{let t=null,e=null;return(a,n,r,o)=>{e=()=>a.apply(n,r),clearTimeout(t),t=setTimeout(()=>{e(),e=t=null},o)}})(),_disableFn:function(){if(this.socket&&1===this.socket.readyState&&!0!==this.socket.paused&&!this.isAllowed()){const t=this.getSocketDefs();t.paused=1,this.socket.paused=!0,this.socket.send(JSON.stringify(t))}},_enableFn:function(){this.isEnabled()&&this.isAllowed()&&(this.graphsCanPreRender()&&this.preRender(),this.socket&&!1!==this.socket.paused?(1===this.socket.readyState&&this.socket.send(JSON.stringify(this.getSocketDefs())),this.socket.paused=!1):this.activate())},enable:function(){this._toggleLimiter(this._enableFn,this,arguments,40)},disable:function(){this._toggleLimiter(this._disableFn,this,arguments,4e3)},shutdown:function(){if(this.socket&&1===this.socket.readyState){const t=this.getSocketDefs();t.disable=1,this.socket.send(JSON.stringify(t))}},activate:function(){this.activating++||this._.blocked()||this.socket||this.tried++>4||$.ajax({context:this,url:`${this._.prefix}/stats.cgi`,error:function(){this.activating=0,this.error++>3||!this.requery&&(this.requery=setTimeout(()=>{this.requery=null,this.activate()},1e3*this.getInterval()*4))},success:function(t){t.success?(this.socketSession=t.session||null,this.socket=new WebSocket(t.socket),this.socket.onopen=()=>{this.tried=0,this.activating=0,this.socket.send(JSON.stringify(this.getSocketDefs()))},this.socket.onmessage=t=>{const e=JSON.parse(t.data),a=this.getRenderType(e);this.render(e,a)},this.socket.onclose=()=>{setTimeout(()=>{this.socket=null,this.activating=0,this.enable()},1e3*this.getInterval()*4)}):this.activating=0,this.error=0},dataType:"json"})},preRender:function(){this.render(this._.getHistoryData(),2)},getChartStyle:function(){const t=getComputedStyle(document.documentElement),e=e=>t.getPropertyValue(e).trim();return{blue:e("--stats-chart-color-blue"),green:e("--stats-chart-color-green"),greenFill:e("--stats-chart-color-green-fill"),grid:e("--stats-chart-grid-color"),axisLabel:e("--stats-chart-axis-label-color"),axisLabelHover:e("--stats-chart-axis-label-hover-color"),label:e("--stats-chart-label-color"),red:e("--stats-chart-color-red"),redFill:e("--stats-chart-color-red-fill")}},getChartDuration:function(){let t=parseInt(this.getStoredDuration(),10);return(t<300||t>86400)&&(t=1200),t},getChartSize:function(t,e){const a=t.getBoundingClientRect(),n=t.parentNode?t.parentNode.getBoundingClientRect():{width:0},r=a.width||n.width||document.documentElement.clientWidth;return{width:Math.max(Math.floor(r-6),220),height:parseInt(e,10)||110}},getChartData:function(t,e){const a=[],n=t&&t[0],r=n&&(n.data||n),o=r&&Array.isArray(r.y),s=o?r.y.length:1,i="cpu"===e||"virt"===e,h=[[]];for(let t=0;t<(i?2:s);t++)h.push([]);return(t||[]).forEach(t=>{const e=t&&(t.data||t),n=e&&parseFloat(e.x);Number.isFinite(n)&&a.push({x:n,y:e.y})}),a.sort((t,e)=>t.x-e.x),i?this.getThresholdChartData(a,80):(a.forEach(t=>{if(h[0].push(t.x),o)for(let e=0;e<s;e++)h[e+1].push(parseFloat(t.y[e])||0);else h[1].push(parseFloat(t.y)||0)}),h)},getThresholdChartData:function(t,e){const a=[[],[],[]],n=(t,e,n)=>{a[0].push(t),a[1].push(e),a[2].push(n)};return t.forEach((a,r)=>{const o=parseFloat(a.y)||0;if(r>0){const s=t[r-1],i=parseFloat(s.y)||0;if((i<=e&&o>e||i>e&&o<=e)&&o!==i){const t=(e-i)/(o-i),r=s.x+(a.x-s.x)*t;n(r,e,e)}}o>e?n(a.x,null,o):n(a.x,o,null)}),a},trimChartData:function(t,e){const a=t[0];let n=0,r=a.length-1,o=0;for(;n<=r;){const t=Math.floor((n+r)/2);a[t]<e?(n=t+1,o=n):r=t-1}o>0&&t.forEach(t=>t.splice(0,o))},getChartWindow:function(t){const e=t[0],a=this.getChartDuration(),n=e[e.length-1]||Math.floor(Date.now()/1e3),r=e[0]||n;let o=Math.max(n-a,r);return n<=o&&(o=n-Math.max(this.getInterval(),1)),{low:o,high:n}},getChartDataBounds:function(t){const e=t&&t[0],a=e&&e[0],n=e&&e[e.length-1];return Number.isFinite(a)&&Number.isFinite(n)?{low:a,high:n}:null},getChartZoomMinSpan:function(t){return Math.min(t.high-t.low,Math.max(4*this.getInterval(),10))},clampChartZoomRange:function(t,e,a){const n=a.high-a.low;if(!Number.isFinite(n)||n<=0)return{low:a.low,high:a.high};let r=e-t;return(!Number.isFinite(r)||r<=0)&&(r=n),r=Math.min(n,Math.max(this.getChartZoomMinSpan(a),r)),Number.isFinite(t)||(t=a.high-r),Number.isFinite(e)||(e=t+r),t<a.low&&(e=(t=a.low)+r),e>a.high&&(t=(e=a.high)-r),{low:t,high:e}},getChartVisibleRange:function(t){const e=this.chartZoomRange,a=e?this.getChartDataBounds(t):null;return e&&a&&a.high>a.low?this.clampChartZoomRange(e.low,e.high,a):this.getChartWindow(t)},syncChartZoomRange:function(){Object.keys(this).forEach(t=>{if(0!==t.indexOf("chart_"))return;const e=this[t];e&&"function"==typeof e.setScale&&this.applyChartZoomRange(e)})},setChartZoomRange:function(t){this.chartZoomRange=t?{low:t.low,high:t.high}:null,this.syncChartZoomRange()},applyChartZoomRange:function(t){const e=this.getChartVisibleRange(t.data);t.setScale("x",{min:e.low,max:e.high})},getCurrentChartScaleRange:function(t){const e=t.scales&&t.scales.x,a=this.getChartVisibleRange(t.data);return{low:e&&Number.isFinite(e.min)?e.min:a.low,high:e&&Number.isFinite(e.max)?e.max:a.high}},getChartWheelDelta:function(t,e){return 1===t.deltaMode?16*e:2===t.deltaMode?e*(window.innerHeight||document.documentElement.clientHeight||800):e},getChartPlotWidth:function(t,e){const a=(e.over?e.over.getBoundingClientRect():t.getBoundingClientRect()).width||e.width||t.clientWidth||1;return Math.max(a,1)},panChartZoomRange:function(t,e,a,n){const r=this.getChartDataBounds(e.data);if(!this.chartZoomRange||!r||r.high<=r.low)return!1;const o=n||this.getCurrentChartScaleRange(e),s=o.high-o.low,i=r.high-r.low;if(!Number.isFinite(s)||s<=0||!Number.isFinite(i)||s>=.999*i)return!1;const h=s*(a/this.getChartPlotWidth(t,e)),l=this.clampChartZoomRange(o.low+h,o.high+h,r);return this.setChartZoomRange(l),!0},getNetworkChartStep:function(t){const e=Math.pow(10,Math.floor(Math.log10(t))),a=t/e;return(a<=1?1:a<=2?2:a<=2.5?2.5:a<=5?5:a<=7.5?7.5:10)*e},getNetworkChartScale:function(t){const e=1.25*Math.max(t||1,1),a=this.getNetworkChartStep(e/3);return{high:a*Math.ceil(e/a),step:a}},getNetworkChartSplits:function(t){const e=this.getNetworkChartStep(t/3),a=[];for(let n=0;n<=t+e/2;n+=e)a.push(n);return a},formatChartValue:function(t,e,a,n){return e=Math.round(e),a?e?e+"%":e:n?"net"===t?e?this._.convert.size(e,{fixed:0,bits:1,round:1}):e:e?this._.convert.size(1024*e,{fixed:0,round:1}):e:e},getChartHoverValueRows:function(t,e,a,n,r){const o=[],s=e.data[0]&&e.data[0][a],i=Number.isFinite(s)?this._.dayjs(1e3*s).utcOffset(this._.locale.offset()).format(this._.locale.time):"";if(i&&o.push([i]),"disk"===t||"net"===t){const s=[this._.language(`dashboard_chart_${t}_read`),this._.language(`dashboard_chart_${t}_write`)];for(let i=1;i<e.data.length;i++){const h=e.data[i][a];null!=h&&o.push([s[i-1]||"",this.formatChartValue(t,h,n,r)])}}else for(let s=1;s<e.data.length;s++){const i=e.data[s][a];if(null!=i){o.push([this.formatChartValue(t,i,n,r)]);break}}return o},getChartHoverValuesAtIndex:function(t,e){const a=[];for(let n=1;n<t.data.length;n++){const r=t.data[n][e];null!=r&&Number.isFinite(r)&&a.push(r)}return a},getChartHoverValueIndex:function(t,e){const a=t.data[0];if(null==e||!a||!t.cursor)return e;const n=t.cursor.left,r=t.cursor.top,o=e=>{const o=a[e],s=this.getChartHoverValuesAtIndex(t,e);if(!Number.isFinite(o)||!s.length)return null;const i=t.valToPos(o,"x"),h=Math.abs(i-n);if(!Number.isFinite(h)||h>8)return null;let l=1/0;return s.forEach(e=>{const a=t.valToPos(e,"y"),n=Math.abs(a-r);Number.isFinite(n)&&n<l&&(l=n)}),Number.isFinite(l)?{index:e,score:l+.35*h}:null};let s=o(e)||{index:e,score:1/0};for(let r=-1;r<=1;r+=2)for(let i=e+r,h=0;i>=0&&i<a.length&&h<32;i+=r,h++){const e=a[i],r=Number.isFinite(e)?t.valToPos(e,"x"):NaN,h=Math.abs(r-n);if(!Number.isFinite(h)||h>8)break;const l=o(i);l&&l.score<s.score&&(s=l)}return s.index},getChartHoverValueElement:function(t,e){if(!e.hoverValueElement){const a=document.createElement("span");a.className="uplot-hover-value tooltip",a.style.cssText=["background:var(--authentic-tooltip-bg)","border:1px solid var(--border-color-input,var(--border-color,rgba(255,255,255,0.14)))","border-radius:6px","box-shadow:0 4px 10px rgba(0,0,0,0.22)","color:var(--authentic-tooltip-fg)","display:none","font-size:11px","font-weight:500","letter-spacing:0","line-height:1.12","padding:5px 7px 4px","pointer-events:none","position:absolute","text-align:center","white-space:nowrap","width:max-content","z-index:2"].join(";");const n=document.createElement("span"),r=document.createElement("span");n.style.display="block",r.style.cssText=["border-left:5px solid transparent","border-right:5px solid transparent","height:0","position:absolute","width:0"].join(";"),a.appendChild(n),a.appendChild(r),t.appendChild(a),e.hoverValueElement=a,e.hoverValueContent=n,e.hoverValueArrow=r}return e.hoverValueElement},hideChartHoverValue:function(t){t.hoverValueElement&&(t.hoverValueElement.style.display="none",t.hoverValueIndex=null)},renderChartHoverValue:function(t,e){const a=e.length&&1===e[0].length?e[0][0]:"",n=(a?e.slice(1):e).map(t=>t.length>1?`${t[0]}: ${t[1]}`:t[0]).join(" · "),r=t.hoverValueContent;if(r.textContent="",n){const t=document.createElement("span");t.style.display="block",t.textContent=n,r.appendChild(t)}if(a&&n){const t=document.createElement("span");t.style.cssText=["background-color:var(--authentic-tooltip-fg)","display:block","height:1px","margin:4px 0 3px","opacity:.50"].join(";"),r.appendChild(t)}if(a){const t=document.createElement("span");t.style.cssText=["color:var(--authentic-tooltip-fg)","display:block","font-size:10px","font-weight:400"].join(";"),t.textContent=a,r.appendChild(t)}},updateChartHoverValue:function(t,e,a,n,r){const o=a.cursor&&a.cursor.idx,s=this.getChartHoverValueIndex(a,o),i=a.hoverValueElement||(null==o?null:this.getChartHoverValueElement(e,a));if(!i)return;if(null==o||!a.over||a.zoomPanStart)return void this.hideChartHoverValue(a);if(a.hoverValueIndex!==s){const e=this.getChartHoverValueRows(t,a,s,n,r);if(!e.length)return void this.hideChartHoverValue(a);this.renderChartHoverValue(a,e),a.hoverValueIndex=s}const h=e.getBoundingClientRect(),l=a.over.getBoundingClientRect(),c=h.width||e.clientWidth,u=a.cursor.left||0,d=a.cursor.top||0,g=l.left-h.left+u,p=l.top-h.top+d;i.style.display="block";let f=g-i.offsetWidth/2,m=p-i.offsetHeight-8,v=!0;if(m<4&&(m=p+8,v=!1),f=Math.min(Math.max(f,4),Math.max(4,c-i.offsetWidth-4)),i.style.left=`${Math.round(f)}px`,i.style.top=`${Math.round(m)}px`,a.hoverValueArrow){const t=Math.min(Math.max(g-f,8),i.offsetWidth-8);a.hoverValueArrow.style.left=`${Math.round(t-5)}px`,a.hoverValueArrow.style.top=v?"auto":"-5px",a.hoverValueArrow.style.bottom=v?"-5px":"auto",a.hoverValueArrow.style.borderTop=v?"5px solid var(--authentic-tooltip-bg)":"0",a.hoverValueArrow.style.borderBottom=v?"0":"5px solid var(--authentic-tooltip-bg)"}},getChartOptions:function(t,e,a,n,r){const o=this.getChartSize(r,n.height),s=n.fill(),i=n.bandwidth(),h=t=>()=>this.getChartStyle()[t],l={stroke:h("grid"),width:1,dash:[3,4]},c={points:{show:!1},width:s?.7:.8},u=[{}],d=this._.chart;return"cpu"===t||"virt"===t?(u.push(d.assign({},c,{stroke:h("green"),fill:h("greenFill"),spanGaps:!1})),u.push(d.assign({},c,{stroke:h("red"),fill:h("redFill"),spanGaps:!1}))):"disk"===t||"net"===t?(u.push(d.assign({},c,{stroke:h("blue")})),u.push(d.assign({},c,{stroke:h("red")}))):u.push(d.assign({},c,{stroke:h("proc"===t?"blue":"green"),fill:s?h("greenFill"):null})),{width:o.width,height:o.height,cursor:{show:!0,x:!1,y:!1,points:{show:!1},drag:{setScale:!1,x:!1,y:!1}},legend:{show:!1},scales:{x:{time:!0,range:t=>{const e=this.getChartVisibleRange(t.data||a);return[e.low,e.high]}},y:{range:s?()=>[0,100]:(e,a,n)=>{if("net"===t)return[0,this.getNetworkChartScale(n).high];const r=Math.max(n||1,1),o=d.rangeNum(0,r,.1,!0);return o[0]=0,o}}},axes:[{stroke:h("label"),grid:l,ticks:{show:!1},border:{show:!1},font:"11px RobotoLocal",align:1,size:24,space:120,values:(t,e)=>{const a=t.scales.x,n=a&&Number.isFinite(a.max)?t.valToPos(a.max,"x"):0,r=new Set;return e.map(e=>{let a;return n&&n-t.valToPos(e,"x")<50?"":(a=this._.dayjs(1e3*e).utcOffset(this._.locale.offset()).format(this._.locale.time),r.has(a)?"":(r.add(a),a))})}},{stroke:h("label"),grid:l,ticks:{show:!1},border:{show:!1},label:"",font:"11px RobotoLocal",labelFont:"12px RobotoLocal",labelGap:12,labelSize:24,size:60,splits:s?()=>[0,50,100]:"net"===t?(t,e,a,n)=>this.getNetworkChartSplits(n):null,values:(e,a)=>a.map(e=>this.formatChartValue(t,e,s,i))}],hooks:{drawAxes:[t=>{const a=t.axes[1],n=t.ctx,o=t.ctx.canvas.width/t.width,s=this.getChartStyle(),i=r.matches(":hover")?s.axisLabelHover:s.axisLabel;n.save(),n.font=a.labelFont[0],n.fillStyle=i,n.textAlign="center",n.textBaseline="bottom",n.translate(Math.round((a._lpos-a.labelGap+5)*o),Math.round(t.bbox.top+t.bbox.height/2)),n.rotate(-Math.PI/2),n.fillText(e,0,0),n.restore()}],setCursor:[e=>{this.updateChartHoverValue(t,r,e,s,i)}]},series:u}},bindChartResize:function(t,e,a,n){const r=()=>{const t=this.getChartSize(e,n);a.width===t.width&&a.height===t.height||a.setSize(t)};window.ResizeObserver?(a.resizeObserver=new ResizeObserver(r),a.resizeObserver.observe(e.parentNode||e)):(a.resizeEvent=`resize.stats-chart-${t}`,$(window).on(a.resizeEvent,r))},destroyChart:function(t){const e=this[`chart_${t}`];e&&(e.resizeObserver&&e.resizeObserver.disconnect(),e.resizeEvent&&$(window).off(e.resizeEvent),e.hoverEvent&&e.statsTarget&&$(e.statsTarget).off(e.hoverEvent),e.zoomEventTarget&&(e.zoomEventTarget.removeEventListener("wheel",e.zoomWheelHandler),e.zoomEventTarget.removeEventListener("dblclick",e.zoomResetHandler),e.zoomEventTarget.removeEventListener("pointerdown",e.zoomPanStartHandler),e.zoomEventTarget.removeEventListener("pointermove",e.zoomPanMoveHandler),e.zoomEventTarget.removeEventListener("pointerup",e.zoomPanEndHandler),e.zoomEventTarget.removeEventListener("pointercancel",e.zoomPanEndHandler)),e.hoverValueElement&&(e.hoverValueElement.remove(),e.hoverValueElement=null,e.hoverValueContent=null,e.hoverValueArrow=null),e.destroy(),this[`chart_${t}`]=null)},bindChartHover:function(t,e,a){a.hoverEvent=`mouseenter.stats-chart-${t} mouseleave.stats-chart-${t}`,$(e).off(a.hoverEvent).on(a.hoverEvent,()=>{a.redraw(!1,!1)})},bindChartZoom:function(t,e){e.zoomEventTarget=t,e.zoomWheelHandler=a=>{const n=this.getChartWheelDelta(a,a.deltaX),r=this.getChartWheelDelta(a,a.deltaY),o=Math.abs(n)>Math.abs(r)?n:r;if(!a.shiftKey){const o=Math.abs(n)>Math.abs(r)?n:0;return void(o&&this.panChartZoomRange(t,e,o)&&(a.preventDefault(),a.stopPropagation()))}const s=this.getChartDataBounds(e.data);if(!s||s.high<=s.low)return;const i=this.getCurrentChartScaleRange(e),h=i.high-i.low;if(!o||!Number.isFinite(h)||h<=0)return;a.preventDefault(),a.stopPropagation();const l=e.over?e.over.getBoundingClientRect():t.getBoundingClientRect(),c=l.width?(a.clientX-l.left)/l.width:.5,u=Math.min(Math.max(c,0),1),d=i.low+h*u,g=Math.max(-1,Math.min(1,o/100)),p=h*Math.pow(1.14,g),f=d-p*((d-i.low)/h),m=f+p,v=this.clampChartZoomRange(f,m,s),b=s.high-s.low;v.high-v.low>=.999*b?this.setChartZoomRange(null):this.setChartZoomRange(v)},e.zoomPanStartHandler=a=>{if(!this.chartZoomRange||0!==a.button)return;const n=this.getCurrentChartScaleRange(e);e.zoomPanStart={x:a.clientX,range:{low:n.low,high:n.high},pointerId:a.pointerId},t.setPointerCapture&&t.setPointerCapture(a.pointerId),this.hideChartHoverValue(e),a.preventDefault()},e.zoomPanMoveHandler=a=>{const n=e.zoomPanStart;if(!n||n.pointerId!==a.pointerId)return;const r=n.x-a.clientX;Math.abs(r)<1||this.panChartZoomRange(t,e,r,n.range)&&(a.preventDefault(),a.stopPropagation())},e.zoomPanEndHandler=a=>{e.zoomPanStart&&e.zoomPanStart.pointerId===a.pointerId&&(!t.releasePointerCapture||t.hasPointerCapture&&!t.hasPointerCapture(a.pointerId)||t.releasePointerCapture(a.pointerId),e.zoomPanStart=null)},e.zoomResetHandler=()=>{this.chartZoomRange&&this.setChartZoomRange(null)},t.addEventListener("wheel",e.zoomWheelHandler,{passive:!1}),t.addEventListener("pointerdown",e.zoomPanStartHandler),t.addEventListener("pointermove",e.zoomPanMoveHandler),t.addEventListener("pointerup",e.zoomPanEndHandler),t.addEventListener("pointercancel",e.zoomPanEndHandler),t.addEventListener("dblclick",e.zoomResetHandler)},repaintCharts:function(){Object.keys(this).forEach(t=>{if(0!==t.indexOf("chart_"))return;const e=this[t];e&&"function"==typeof e.redraw&&e.redraw(!1,!1)})},addChartTrafficLabels:function(t,e){if("disk"!==e&&"net"!==e)return;const a=this._.language(`dashboard_chart_${e}_read`),n=this._.language(`dashboard_chart_${e}_write`);a&&n&&($(t).find(".uplot-traffic-labels").remove(),$('<span class="uplot-traffic-labels" translate="no"></span>').append($('<span class="uplot-traffic-read"></span>').text(`▪ ${a}`)).append($('<span class="uplot-traffic-write"></span>').text(`▪ ${n}`)).appendTo(t))},drawChart:function(t,e,a,n,r){const o=this.getChartData(a,t);if(!o[0].length)return;const s=this.getChartWindow(o);this.trimChartData(o,s.low),e.classList.add("uplot-chart-ready"),this.destroyChart(t);const i=new this._.chart(this.getChartOptions(t,n,o,r,e),o,e);this[`chart_${t}`]=i,i.statsTarget=e,this.bindChartResize(t,e,i,r.height),this.bindChartHover(t,e,i),this.bindChartZoom(e,i),this.addChartTrafficLabels(e,t)},updateChart:function(t,e){const a=this[`chart_${t}`],n=this.getChartData(e,t);if(!a||!n[0].length)return!1;if(n.length!==a.data.length)return!1;n[0].forEach((t,e)=>{a.data[0].push(t);for(let t=1;t<n.length;t++)a.data[t].push(n[t][e])});const r=this.getChartWindow(a.data);return this.trimChartData(a.data,r.low),a.setData(a.data,!0),this.applyChartZoomRange(a),!0},render:function(t,e){t&&Object.entries(t).map(([t,a])=>{let n=parseInt(a),r="object"==typeof a&&a[a.length-1],o=r||n,s=$(`#${this.selector.dashboard} .${this.selector.piechart}[data-charts*="${t}"]`),i=$(`.${this.selector.slider} .${t}_percent`),h=$(`#${this.selector.dashboard} span[data-id="sysinfo_${t}"], \n .${this.selector.slider} span[data-data="${t}"]`),l="graphs"===t?e?3===e?3:2:this.graphsCanPreRender()?2:1:0;if(Number.isInteger(n)){if(s.length){let t=s.data("easyPieChart");t&&t.update(n)}if(i.length){i.find(".bar").attr("style","width:"+n+"%");let e=i.find(".description"),a=e.text().split(":")[0]+": "+n+"% ("+r+")";"cpu"!==t&&(a=plugins.slider.update.stats.graphs.flatten(a),"virt"!==t&&(a=plugins.slider.update.stats.graphs.plunk(a))),e.attr("title",r).text(a)}h.length&&(h.find("a").length?h.find("a").text(o):h.text(o))}if("sensors"===t&&r&&Object.entries(r).forEach(([t,e])=>{let a=this,n=$(`#${this.selector.dashboard} span[data-stats="${t}"]`),r=$(`.${this.selector.slider} span[data-stats="${t}"]`);if(n&&n.length){let o=n.length,s=r.length;e.sort((e,a)=>"fans"===t?e.fan-a.fan:e.core-a.core);const i=function(e,n,r,o){if(!n)return;r?e.html(function(e,a){const r=a.includes("°F"),o="fans"===t?n.rpm:r?Math.round(9*n.temp/5+32):n.temp;return a.replace(/\d+/,o)}):e.html(function(e,a){const r=a.includes("°F"),o="fans"===t?n.rpm:r?Math.round(9*n.temp/5+32):n.temp;return a.replace(/: \d+/,`: ${o}`)});const s=e.text().replace(/.*?\d+:\s*/,"");let i=HTML.label.textMaxLevels(t,s)||(o?a.selector.defaultSliderClassLabel:a.selector.defaultClassLabel);o&&i===a.selector.defaultClassLabel&&(i=a.selector.defaultSliderClassLabel),e.removeClass((t,e)=>(e.match(/\bbg-\S+/g)||[]).join(" ")).addClass(i)};1===o?i(n,e[0],!0):n.each((t,a)=>{e[t]&&i($(a),e[t],!1)}),1===s?i(r,e[0],!0,!0):r.each((t,a)=>{e[t]&&i($(a),e[t],!1,!0)})}}),l){let t=`${this.selector.chart.container.parent}-${this.selector.collapse}`,e=$(`#${t}`).find(`[${this.selector.chart.loader}]`);Object.entries(a).map(([a,n])=>{let r={chart:{type:()=>"proc"===a||"disk"===a||"net"===a,bandwidth:()=>"disk"===a||"net"===a,fill:function(){return!this.type()},high:function(){return this.type()?void 0:100},threshold:function(){return this.type()?-1:80},height:"110px"}},o=this._.language(`${this.selector.chart.container.parent}_${a}`),s=$(`#${t}`).find(`[${this.selector.chart.container.data}=${a}]`),i=this[`chart_${a}`],h=i&&i.statsTarget,c=!i||2===l||3===l||!h||h!==s[0]||!h.isConnected;s.length&&(c?c&&(this.drawChart(a,s[0],n,o,r.chart),e.remove()):1!==l||this.updateChart(a,n)||(this.drawChart(a,s[0],n,o,r.chart),e.remove()))})}})}}};