import{d as D,o as h,c as x,b as w,a as $,F as N,g as W,i as b}from"./index-CXwCk-SR.js";import{_ as j}from"./_plugin-vue_export-helper-DlAUqK2U.js";const I=["width","height","viewBox","preserveAspectRatio"],R=["d","fill"],A=["d","stroke","stroke-width"],V=["cx","cy","r","fill"],Z=["x1","x2","y2"],z=["cx","cy","fill"],E=D({__name:"Sparkline",props:{values:{},width:{default:56},height:{default:14},color:{default:"var(--sw-accent)"},stroke:{default:1.25},fluid:{type:Boolean,default:!1},crosshairBucket:{default:null}},emits:["bucket-hover","bucket-leave"],setup(t,{emit:B}){const n=t,F=B;function M(o){const l=o.currentTarget;if(!l)return;const s=l.getBoundingClientRect();if(s.width===0)return;const v=o.clientX-s.left,m=Math.max(0,Math.min(1,v/s.width)),d=n.values.length;if(d<2)return;const k=Math.round(m*(d-1));F("bucket-hover",k)}function L(){F("bucket-leave")}const r=b(()=>{const o=n.values.length;if(o<2)return{d:"",fillD:"",dotX:null,dotY:null,internalW:n.width,points:[],empty:!0};let l=1/0,s=-1/0,v=0;for(const e of n.values)e===null||!Number.isFinite(e)||(v++,e<l&&(l=e),e>s&&(s=e));if(v<2)return{d:"",fillD:"",dotX:null,dotY:null,internalW:n.width,points:[],empty:!0};const m=s-l||1,d=n.stroke,k=n.fluid?Math.max(n.width,o*12):n.width,u=n.height,P=(k-1)/(o-1),p=n.values.map((e,Y)=>{if(e===null||!Number.isFinite(e))return null;const S=(e-l)/m,X=.5+Y*P,C=u-d-S*(u-d*2);return{x:X,y:C}}),y=[],f=[];let g=!0,i=null,a=null;for(const e of p){if(!e){a&&i&&f.push(`L ${i.x.toFixed(2)} ${(u-.5).toFixed(2)} L ${a.x.toFixed(2)} ${(u-.5).toFixed(2)} Z`),g=!0,a=null;continue}g?(y.push(`M ${e.x.toFixed(2)} ${e.y.toFixed(2)}`),f.push(`M ${e.x.toFixed(2)} ${(u-.5).toFixed(2)} L ${e.x.toFixed(2)} ${e.y.toFixed(2)}`),a=e,g=!1):(y.push(`L ${e.x.toFixed(2)} ${e.y.toFixed(2)}`),f.push(`L ${e.x.toFixed(2)} ${e.y.toFixed(2)}`)),i=e}return a&&i&&f.push(`L ${i.x.toFixed(2)} ${(u-.5).toFixed(2)} L ${a.x.toFixed(2)} ${(u-.5).toFixed(2)} Z`),{d:y.join(" "),fillD:f.join(" "),dotX:(i==null?void 0:i.x)??null,dotY:(i==null?void 0:i.y)??null,internalW:k,points:p,empty:!1}}),c=b(()=>{const o=n.crosshairBucket;if(o==null)return null;const l=r.value.points[o];return l||null});return(o,l)=>r.value.empty?(h(),x("span",{key:1,class:"sparkline-empty",style:W({width:t.fluid?"100%":`${t.width}px`,height:`${t.height}px`})},"—",4)):(h(),x("svg",{key:0,class:"sparkline",width:t.fluid?"100%":t.width,height:t.height,viewBox:`0 0 ${r.value.internalW} ${t.height}`,preserveAspectRatio:t.fluid?"none":"xMidYMid meet",role:"img","aria-label":"trend",onPointermove:M,onPointerleave:L},[t.fluid?w("",!0):(h(),x("path",{key:0,d:r.value.fillD,fill:t.color,"fill-opacity":"0.12",stroke:"none"},null,8,R)),$("path",{d:r.value.d,fill:"none",stroke:t.color,"stroke-width":t.stroke,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":"non-scaling-stroke"},null,8,A),!t.fluid&&r.value.dotX!==null&&r.value.dotY!==null?(h(),x("circle",{key:1,cx:r.value.dotX,cy:r.value.dotY,r:t.stroke+.5,fill:t.color},null,8,V)):w("",!0),c.value?(h(),x(N,{key:2},[$("line",{x1:c.value.x,x2:c.value.x,y1:0,y2:t.height,stroke:"var(--sw-fg-3)","stroke-width":"1","stroke-dasharray":"2 3","vector-effect":"non-scaling-stroke","pointer-events":"none"},null,8,Z),$("circle",{cx:c.value.x,cy:c.value.y,r:"2.6",fill:t.color,stroke:"var(--sw-bg-0)","stroke-width":"1","vector-effect":"non-scaling-stroke","pointer-events":"none"},null,8,z)],64)):w("",!0)],40,I))}}),G=j(E,[["__scopeId","data-v-7f652495"]]);export{G as S};
