import{Ot as e}from"./vue-vendor-DMUmTARL.js";import{B as t}from"./index-BcZTP2Ia.js";var n={cpu:`#3b82f6`,memory:`#22c55e`,upload:`#8b5cf6`,download:`#f97316`},r=(e,t)=>typeof window>`u`?t:getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t,i=e=>{let t=[59,130,246];if(!e)return t;let n=e.trim();if(n.startsWith(`#`)){let e=n.slice(1);if(e.length===3&&(e=e.split(``).map(e=>e+e).join(``)),e.length>=6){let t=parseInt(e.slice(0,2),16),n=parseInt(e.slice(2,4),16),r=parseInt(e.slice(4,6),16);if([t,n,r].every(e=>Number.isFinite(e)))return[t,n,r]}return t}let r=n.match(/rgba?\(([^)]+)\)/i);if(r){let e=r[1].split(`,`).map(e=>parseInt(e.trim(),10));if(e.length>=3&&e.slice(0,3).every(e=>Number.isFinite(e)))return[e[0],e[1],e[2]]}return t},a=()=>({primary:r(`--zf-chart-primary`,`#3b82f6`),success:r(`--zf-chart-success`,`#22c55e`),warning:r(`--zf-chart-warning`,`#f97316`)}),o=e=>{let[t,n,r]=i(e);return{type:`linear`,x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:`rgba(${t}, ${n}, ${r}, 0.3)`},{offset:1,color:`rgba(${t}, ${n}, ${r}, 0)`}]}},s=(e,t=.3)=>{if(e.length===0)return e;let n=Array(e.length);n[0]=e[0];for(let r=1;r<e.length;r++)n[r]=t*e[r]+(1-t)*n[r-1];return n},c=(e,t,n)=>{let r=n?s(t):t;return e.map((e,n)=>({value:[e.time,r[n]],raw:t[n]}))},l=e=>{let t=new Date(e);return`${t.getHours().toString().padStart(2,`0`)}:${t.getMinutes().toString().padStart(2,`0`)}:${t.getSeconds().toString().padStart(2,`0`)}`};function u(e,i,s,u=!1,d=!1){let f=i||[],{primary:p,success:m,warning:h}=a(),g=u?`#f59e0b`:h,_=r(`--el-text-color-secondary`,`#909399`),v=r(`--el-border-color-light`,`#ebeef5`),y={left:`3%`,right:`4%`,top:`10%`,bottom:`15%`,containLabel:!0},b={type:`time`,axisLabel:{formatter:e=>l(e),hideOverlap:!0},axisLine:{lineStyle:{color:_}}},x={type:`value`,min:0,max:100,axisLine:{show:!1},axisLabel:{color:_,formatter:`{value}%`},splitLine:{lineStyle:{type:`dashed`,color:v}}};if(e===`cpu`||e===`memory`){let n=e===`cpu`,r=n?p:m,i=u?`进程`:`ZFile`,a={},s={};return n||f.forEach(e=>{a[e.time]=e.processMemory||0,s[e.time]=e.systemMemory||0}),{grid:u?{...y,top:`14%`}:y,tooltip:{trigger:`axis`,formatter:e=>{let r=`${l(e[0].value[0])}`;return e.forEach(e=>{let o=(e.data?.raw??e.value[1])?.toFixed(1)||0;if(n)r+=`<br/>${e.seriesName}: <span class="font-bold">${o}%</span>`;else{let n=(e.seriesName===i?a:s)[e.value[0]]||0;r+=`<br/>${e.seriesName}: <span class="font-bold">${o}%</span> (${t(n)})`}}),r}},legend:u?{data:[`系统`,i],top:0,itemHeight:8,itemWidth:14,textStyle:{color:_}}:{data:[`系统`,i],bottom:0,icon:`circle`},xAxis:b,yAxis:x,series:[{name:`系统`,type:`line`,smooth:!0,showSymbol:!1,sampling:`lttb`,areaStyle:{color:o(r)},itemStyle:{color:r},data:c(f,f.map(e=>n?e.cpuUsage:e.memoryUsage),d)},{name:i,type:`line`,smooth:!0,showSymbol:!1,sampling:`lttb`,...u?{lineStyle:{color:g,type:`dashed`}}:{areaStyle:{color:o(g)}},itemStyle:{color:g},data:c(f,f.map(e=>n?e.processCpuUsage:e.processMemoryUsage),d)}]}}let S=e===`upload`,C=u?n[e]:S?p:m;return{grid:u?{...y,top:`14%`,bottom:`10%`}:{...y,bottom:`10%`},tooltip:{trigger:`axis`,formatter:e=>{let n=`${l(e[0].value[0])}`;return e.forEach(e=>{n+=`<br/>${e.seriesName}: <span class="font-bold">${t(e.data?.raw??e.value[1])}/s</span>`}),n}},legend:u?{data:[S?`上传`:`下载`],top:0,itemHeight:8,itemWidth:14,textStyle:{color:_}}:{data:[S?`上传`:`下载`],bottom:0,icon:`circle`},xAxis:b,yAxis:{type:`value`,axisLine:{show:!1},axisLabel:{color:_,formatter:e=>t(e)},splitLine:{lineStyle:{type:`dashed`,color:v}}},series:[{name:S?`上传`:`下载`,type:`line`,smooth:!0,showSymbol:!1,sampling:`lttb`,itemStyle:{color:C},data:c(f,f.map(e=>S?e.networkUploadSpeed:e.networkDownloadSpeed),d)}]}}function d(){let t=e([]);return{history:t,applyTrend:e=>{t.value=e||[]}}}export{d as i,s as n,u as r,n as t};