import{r as e}from"./rolldown-runtime-BM3Ffeng.js";import{A as t,E as n,I as r,J as i,P as a,Pt as o,Tt as s,Z as c,et as l,pt as u}from"./vue-vendor-DMUmTARL.js";import{yt as d}from"./index-kSn5YXd0.js";import{t as f}from"./useDarks-zOpm_Fmh.js";import{a as p,c as m,l as h,o as g,r as _,t as v,u as y}from"./echarts-vendor-ChBC2lro.js";import{r as b}from"./useMonitorCharts-BZjff5TF.js";var x={class:`h-80 w-full sm:h-[420px]`},S=r({__name:`MonitorChartViewer`,props:{type:{},history:{},demoStyle:{type:Boolean}},setup(e,{expose:r}){y([h,m,g,p,_]);let S=e,{isDark:C}=f(),w=d(),T=n(()=>w.globalConfig.monitorEwmaEnabled??!0),E=s(null),D=b(S.type,S.history||[],C.value,S.demoStyle,T.value),O=()=>{E.value?.setOption(b(S.type,S.history||[],C.value,S.demoStyle,T.value),!0)};u(()=>[S.type,S.history,S.demoStyle,T.value],()=>O(),{deep:!0}),u(C,()=>O());let k=()=>new Date().toISOString().slice(0,19).replace(/[:T]/g,`-`),A=()=>{if(typeof window<`u`){let e=getComputedStyle(document.documentElement).getPropertyValue(`--el-bg-color`).trim();if(e)return e}return C.value?`#18181b`:`#ffffff`};return r({exportChart:(e=`monitor`)=>{let t=E.value;if(!t)return;let n;try{n=t.getDataURL({type:`png`,pixelRatio:2,backgroundColor:A()})}catch{return}if(!n)return;let r=document.createElement(`a`);r.href=n,r.download=`${e}-${k()}.png`,r.click()}}),c(()=>O()),i(()=>{E.value?.dispose()}),(e,n)=>(l(),t(`div`,x,[a(o(v),{ref_key:`chartRef`,ref:E,class:`h-full w-full`,option:o(D),autoresize:``,"manual-update":``},null,8,[`option`])]))}}),C=e({default:()=>w}),w=S;export{C as n,w as t};