import{r as e}from"./rolldown-runtime-BM3Ffeng.js";import{A as t,D as n,E as r,I as i,et as a,k as o}from"./vue-vendor-DMUmTARL.js";import{n as s}from"./useMonitorCharts-F3aYeMmH.js";var c={class:`relative h-full w-full`},l=[`viewBox`],u={key:0},d=[`stop-color`],f=[`stop-color`],p=[`d`,`fill`],m=[`d`,`stroke`,`stroke-width`],h=100,g=32,_=i({__name:`MonitorSparkline`,props:{points:{},colorVar:{},color:{default:void 0},area:{type:Boolean,default:!1},timestamps:{default:()=>[]},valueFormatter:{type:Function,default:e=>String(e)},yRange:{default:void 0},smoothEwma:{type:Boolean,default:!0}},setup(e){let i=e,_=r(()=>i.color||`var(${i.colorVar})`),v=`spark-grad-${Math.random().toString(36).slice(2,9)}`,y=r(()=>{let e=i.points||[];if(e.length===0)return[];let t=i.smoothEwma?s(e):e,n,r;if(i.yRange!=null)n=i.yRange[0],r=i.yRange[1];else{let e=Math.max(...t),i=Math.min(...t),a=e-i,o=a===0?Math.max(Math.abs(e)||1,1)*.05:a*.05;n=i-o,r=e+o}let a=r-n||1,o=t.length>1?h/(t.length-1):0,c=e=>g-(e-n)/a*g;if(t.length===1){let e=c(t[0]);return[{x:0,y:e},{x:h,y:e}]}return t.map((e,t)=>({x:t*o,y:c(e)}))});function b(e,t,n){return e<t?t:e>n?n:e}let x=r(()=>{let e=y.value,t=e.length;if(t===0)return``;if(t===1){let t=e[0];return`M ${t.x.toFixed(2)} ${t.y.toFixed(2)}`}if(t===2)return`M ${e[0].x.toFixed(2)} ${e[0].y.toFixed(2)} L ${e[1].x.toFixed(2)} ${e[1].y.toFixed(2)}`;let n=n=>e[b(n,0,t-1)],r=`M ${e[0].x.toFixed(2)} ${e[0].y.toFixed(2)}`;for(let e=0;e<t-1;e++){let t=n(e-1),i=n(e),a=n(e+1),o=n(e+2),s=i.x+(a.x-t.x)/6,c=b(i.y+(a.y-t.y)/6,0,g),l=a.x-(o.x-i.x)/6,u=b(a.y-(o.y-i.y)/6,0,g);r+=` C ${s.toFixed(2)} ${c.toFixed(2)} ${l.toFixed(2)} ${u.toFixed(2)} ${a.x.toFixed(2)} ${a.y.toFixed(2)}`}return r}),S=r(()=>{let e=x.value,t=y.value;if(!e||t.length===0)return``;let n=t[t.length-1],r=t[0];return`${e} L ${n.x.toFixed(2)} ${g} L ${r.x.toFixed(2)} ${g} Z`});return(r,i)=>(a(),t(`div`,c,[(a(),t(`svg`,{class:`block h-full w-full overflow-visible`,viewBox:`0 0 ${h} ${g}`,preserveAspectRatio:`none`,"aria-hidden":`true`,focusable:`false`},[e.area?(a(),t(`defs`,u,[n(`linearGradient`,{id:v,x1:`0`,y1:`0`,x2:`0`,y2:`1`},[n(`stop`,{offset:`0%`,"stop-color":_.value,"stop-opacity":`0.22`},null,8,d),n(`stop`,{offset:`100%`,"stop-color":_.value,"stop-opacity":`0`},null,8,f)])])):o(``,!0),e.area&&S.value?(a(),t(`path`,{key:1,d:S.value,fill:`url(#${v})`,stroke:`none`},null,8,p)):o(``,!0),x.value?(a(),t(`path`,{key:2,d:x.value,fill:`none`,stroke:_.value,"stroke-width":e.area?2:1.5,"stroke-linecap":`round`,"stroke-linejoin":`round`,"vector-effect":`non-scaling-stroke`},null,8,m)):o(``,!0)],8,l))]))}}),v=e({default:()=>y}),y=_;export{v as n,y as t};