import{d as V,aw as O,g as k,c1 as $,B as M,bY as j,e as f,o as h,b as _,l as S,a as x,n as w,_ as E,t as z,m as C,c as I,E as H,G as B,ag as L,c2 as W,c3 as F,c4 as A,c5 as T,x as P,J as R,c6 as U,c7 as G}from"./Dk4AzF7j.js";import{_ as J}from"./BnFHREeV.js";const Y={class:"relative"},q={key:0,class:"absolute o_top-0 0_start-0 o_p-2 text-xs text-right o_z-10"},K={key:1},Q={class:"o_overflow-hidden size-5 flex items-center justify-center"},X={key:0,class:"p-px border-t border-neutral-200"},Z=V({__name:"ChartCard",props:{chartData:{default:()=>({chartType:"",series:[]})},chartOptions:{default:()=>({})},inset:{type:Boolean,default:!1},pending:{type:Boolean,default:!1},chartHeight:{default:"300px"}},setup(s){const i=s,l={chart:{style:{direction:"rtl"}},xAxis:{reversed:!0},yAxis:{opposite:!0},legend:{style:{direction:"rtl"}},labels:{style:{direction:"rtl"},useHtml:!0,align:"left"}},{isRTLLanguage:b}=O(),g=k(()=>i.chartData?i.chartData.series.every(o=>o.data.length===0):!1),p=k(()=>{if(g.value)return{};if(!i.chartData)return{};if(!b.value)return $(i.chartOptions,i.chartData);const o=$(l,i.chartOptions);return $(o,i.chartData)}),r=M(),e=k(()=>r.value==="dark");return(o,u)=>{const m=E,c=j("highcharts"),n=J;return h(),f("div",{class:H([o.inset?"":"bg-uiBg"])},[_("div",Y,[o.pending?(h(),f("div",q,[x(m,{name:"svg-spinners:90-ring-with-bg",class:"size-3"}),w(" "+z(o.$t("refreshingData")),1)])):S("",!0),C(g)?(h(),f("div",{key:2,class:"flex items-baseline text-sm text-gray-500 o_p-6",style:B({height:o.chartHeight})},[x(n,{color:"info",title:o.$t("chartInfo.noDataAvailable"),description:o.$t("chartInfo.noDataAvailableDescription"),variant:"subtle",icon:"material-symbols:insert-chart-rounded"},null,8,["title","description"])],4)):(h(),f("div",K,[o.chartData?(h(),I(c,{key:0,options:C(p),class:H([C(e)?"invert-90":""])},null,8,["options","class"])):(h(),f("div",{key:1,class:"flex o_gap-2 items-center justify-center text-sm text-gray-500",style:B({height:o.chartHeight})},[_("div",Q,[x(m,{name:"svg-spinners:90-ring-with-bg",class:"size-4"})]),w(" "+z(o.$t("loadingData")),1)],4))]))]),o.$slots.default?(h(),f("div",X,[L(o.$slots,"default")])):S("",!0)],2)}}}),re=Object.assign(Z,{__name:"ChartCard"}),se=()=>{const s={"mini-load-average":"percentToHundred","mini-top-processes-cpu":"percent","overall-cpu-usage":"percent","overall-memory-usage":"percentAndBytes","overall-disk-usage":"byteCalculation","overall-load-average":"none","overall-network":"bps","overall-top-processes-cpu":"percent","network-packets-total":"none","network-bytes-total":"bps","network-packets-eth0":"none","network-bytes-eth0":"bps","network-ping-response-times":"time","cpu-detailed-usage":"percent","cpu-detailed-usage-cpu0":"percent","cpu-top-processes":"percent","memory-usage":"byteCalculation","memory-active-inactive":"byteCalculation","disk-overall-usage":"byteCalculation","disk-io-transactions":"none","disk-io-data":"bps",uptime:"percent",browserTimings:"time",serverTimings:"time",pageSize:"byteCalculation",cookieCount:"cookieValue",percent:"percentToHundred"},i=(r,e,o,u,m="")=>`<div>
    <span style="color:${u}">● </span>${o}: <strong>${e} ${m}</strong></div>
    `,l=(r,e,o="")=>`<div><span style="color:${e}">● </span><strong>${r} ${o}</strong></div>
    `,b=(r,e,o,u=!1,m="")=>{if(!s[r])return l(o.y,e.color,m);const c=e.series.name,n=e.color;if(s[r]==="none")return u?l(e.y,n):i(e.x,e.y,c,n);if(s[r]==="roundValue")return u?l(Math.round(Number(e.y)).toString(),n):i(e.x,Math.round(Number(e.y)).toString(),c,n);if(s[r]==="cookieValue")return u?l(Math.round(Number(e.y)).toString(),n,"cookies"):i(e.x,Math.round(Number(e.y)).toString(),c,n,"cookies");if(s[r]==="bps"){const t=F(e.y);return u?l(t,n):i(e.x,t,c,n)}if(s[r]==="time"){const t=A(e.y);return u?l(t,n):i(e.x,t,c,n)}if(["byteCalculation","percentAndBytes"].includes(s[r])){const t=T(e.y,"bytes");return u?l(t,n):i(e.x,t,c,n)}if(s[r]==="bitCalculation"){const t=T(e.y,"bits");return u?l(t,n):i(e.x,t,c,n)}if(s[r]==="percent")return u?l(`${parseFloat(e.y).toFixed(2)}%`,n):i(e.x,`${parseFloat(e.y).toFixed(2)}%`,c,n);if(s[r]==="percentToHundred")return u?l(`${(e.y*100).toFixed(2)}%`,n):i(e.x,`${(e.y*100).toFixed(2)}%`,c,n)},g=(r,e)=>{if(!s[r])return e.value;if(s[r]==="none")return`${e.value} `;if(s[r]==="roundValue"||s[r]==="cookieValue")return Math.round(e.value);if(s[r]==="bps")return F(e.value);if(s[r]==="time")return A(e.value);if(s[r]==="byteCalculation")return T(e.value,"bytes");if(s[r]==="bitCalculation")return T(e.value,"bits");if(["percent","percentAndBytes"].includes(s[r]))return`${e.value}%`;if(s[r]==="percentToHundred")return`${e.value*100}%`};return{remapToRelevantOptions:(r,e={},o=!0,u)=>{const m={xAxis:{showFirstLabel:!0,labels:{step:0}},yAxis:{labels:{useHTML:!1,align:"right",enabled:!0,formatter:c=>g(r,c)}},tooltip:{useHTML:!0,shared:!0,xDateFormat:"%d.%m.%y %H:%M",formatter:function(){const{points:c,x:n}=this;let t=`<span style="font-size: 0.7rem;">${W(+n)}</span>`;return c?.forEach(a=>{t+=`${b(r,a,this,o,u)}`}),t},style:{zIndex:1},outside:!0}};return Object.keys(e).length>0?$(m,e):m}}},D={hour:{time:"1d",from:"-1month"},day:{time:"1d",from:"-1month"},week:{time:"7d",from:"-1year"}},oe=()=>{const s=P(),i=k(()=>s.currentProject?.system||null),l=k(()=>{if(i.value===null)throw new Error("No system found");const t=i.value.main_interval;return D[t]}),b=t=>{const a={browserTimings:{group:"performance",unit:"ms",chartType:"line"},serverTimings:{group:"performance",unit:"ms",chartType:"line"},cookieCount:{group:"cookies",unit:"cookies",chartType:"line"},cookiesCount:{group:"cookies",unit:"cookies",chartType:"line"},pageSize:{group:"size",unit:"kb",chartType:"line"},uptime:{group:"uptime",unit:"%",chartType:"bar"}};return a[t]||a.uptime},g=[{type:"time",group:"performance",key:["browserTimings","serverTimings"],unit:"ms",chartType:"line"},{type:"size",group:"size",key:["pageSize"],unit:"kb",chartType:"line"},{type:"uptime",group:"uptime",key:["uptime"],unit:"%",chartType:"bar"},{type:"cookies",group:"cookies",key:["cookieCount"],unit:"cookies",chartType:"line"}],{t:p,locale:r,n:e}=R();return{currentSystem:i,mainInterval:l,metricConfig:b,metricConfigs:g,underValues:(t,a,d,y)=>{const v=d===0?["ms","kb"].includes(y)?!1:d!==t:y!=="uptime"?t<=d:t*100>=d,N=a===0?!0:t<=a;return{uThreshold:v,uAverage:N}},metricStatus:(t,a,d)=>{const y={ms:["fast","slow"],kb:["small","big"],"%":["good","bad"],cookies:["good","bad"],custom:["good","bad"]},v=d??"ms";return p(t&&a?String(y[v][0]):t?"onAverage":String(y[v][1]))},componentStatus:(t,a)=>{const d={0:{border:"bg-uiSuccess",background:"bg-uiSuccess-50",score:0},1:{border:"bg-uiWarning",background:"bg-uiWarning-50",score:1},2:{border:"bg-uiError",background:"bg-uiError-50",score:2}};return t&&a?d[0]:t||a?d[1]:d[2]},metricConverter:(t,a)=>{const d=["ms","kb","%"].includes(a)?a:"default";return{ms:G(t,r.value),kb:U(t,r.value),"%":`${e(t*100,"currency")}%`,default:Math.floor(t)}[d]},setThreshold:(t,a)=>({uptime:`${t}% ${p("threshold")}`,browserTimings:`${t/1e3}s ${p("threshold")}`,serverTimings:`${t/1e3}s ${p("threshold")}`,pageSize:`${t/1e3}MB ${p("threshold")}`,cookieCount:`${t} ${p("cookies")} ${p("threshold")}`})[a]}};export{re as _,se as a,oe as u};
