import{ak as le,e as c,da as ne,db as m,aC as y,aB as z,bh as oe,d as se,aD as j,r as k,f as ie,dc as ue,a as E,M as ce,ay as de,bO as H,b8 as ve,cD as me,cF as pe}from"./index-03f5d926.js";var P=Number.isNaN||function(e){return typeof e=="number"&&e!=e};function fe(e,a){if(e.length!==a.length)return!1;for(var l=0;l{const e=le().proxy.$props;return c(()=>{const a=(l,n,r)=>({});return e.perfMode?ne(a):function(l,n){n===void 0&&(n=fe);var r=null;function p(){for(var u=[],d=0;doe([])},direction:Me,height:{type:[String,Number],required:!0},innerElement:{type:[String,Object],default:"div"},style:{type:y([Object,String,Array])},useIsScrolling:{type:Boolean,default:!1},width:{type:[Number,String],required:!1},perfMode:{type:Boolean,default:!0},scrollbarAlwaysOn:{type:Boolean,default:!1}}),Ce=z({cache:T,estimatedItemSize:D,layout:J,initScrollOffset:O,total:M,itemSize:R,...Q}),F={type:Number,default:6},U={type:Number,default:0},X={type:Number,default:2},Le=z({columnCache:T,columnWidth:R,estimatedColumnWidth:D,estimatedRowHeight:D,initScrollLeft:O,initScrollTop:O,itemKey:{type:y(Function),default:({columnIndex:e,rowIndex:a})=>`${a}:${e}`},rowCache:T,rowHeight:R,totalColumn:M,totalRow:M,hScrollbarSize:F,vScrollbarSize:F,scrollbarStartGap:U,scrollbarEndGap:X,role:String,...Q}),Z=z({alwaysOn:Boolean,class:String,layout:J,total:M,ratio:{type:Number,required:!0},clientSize:{type:Number,required:!0},scrollFrom:{type:Number,required:!0},scrollbarSize:F,startGap:U,endGap:X,visible:Boolean}),Be=(e,a)=>ee==="ltr"||e===I||e===b,Re=e=>e===I;let S=null;function De(e=!1){if(S===null||e){const a=document.createElement("div"),l=a.style;l.width="50px",l.height="50px",l.overflow="scroll",l.direction="rtl";const n=document.createElement("div"),r=n.style;return r.width="100px",r.height="100px",a.appendChild(n),document.body.appendChild(a),a.scrollLeft>0?S=_:(a.scrollLeft=1,S=a.scrollLeft===0?W:Y),document.body.removeChild(a),S}return S}const Te=se({name:"ElVirtualScrollBar",props:Z,emits:["scroll","start-move","stop-move"],setup(e,{emit:a}){const l=c(()=>e.startGap+e.endGap),n=j("virtual-scrollbar"),r=j("scrollbar"),p=k(),u=k();let d=null,f=null;const i=ie({isDragging:!1,traveled:0}),o=c(()=>ue[e.layout]),$=c(()=>e.clientSize-E(l)),ee=c(()=>({position:"absolute",width:`${b===e.layout?$.value:e.scrollbarSize}px`,height:`${b===e.layout?e.scrollbarSize:$.value}px`,[Ee[e.layout]]:"2px",right:"2px",bottom:"2px",borderRadius:"4px"})),C=c(()=>{const t=e.ratio,s=e.clientSize;if(t>=100)return Number.POSITIVE_INFINITY;if(t>=50)return t*s/100;const g=s/3;return Math.floor(Math.min(Math.max(t*s,20),g))}),te=c(()=>{if(!Number.isFinite(C.value))return{display:"none"};const t=`${C.value}px`;return function({move:g,size:N,bar:A},re){const v={},L=`translate${A.axis}(${g}px)`;return v[A.size]=N,v.transform=L,v.msTransform=L,v.webkitTransform=L,re==="horizontal"?v.height="100%":v.width="100%",v}({bar:o.value,size:t,move:i.traveled},e.layout)}),h=c(()=>Math.floor(e.clientSize-C.value-E(l))),q=()=>{window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",w),document.onselectstart=f,f=null;const t=E(u);t&&(t.removeEventListener("touchmove",x),t.removeEventListener("touchend",w))},G=t=>{t.stopImmediatePropagation(),t.ctrlKey||[1,2].includes(t.button)||(i.isDragging=!0,i[o.value.axis]=t.currentTarget[o.value.offset]-(t[o.value.client]-t.currentTarget.getBoundingClientRect()[o.value.direction]),a("start-move"),(()=>{window.addEventListener("mousemove",x),window.addEventListener("mouseup",w);const s=E(u);s&&(f=document.onselectstart,document.onselectstart=()=>!1,s.addEventListener("touchmove",x),s.addEventListener("touchend",w))})())},w=()=>{i.isDragging=!1,i[o.value.axis]=0,a("stop-move"),q()},x=t=>{const{isDragging:s}=i;if(!s||!u.value||!p.value)return;const g=i[o.value.axis];if(!g)return;me(d);const N=-1*(p.value.getBoundingClientRect()[o.value.direction]-t[o.value.client])-(u.value[o.value.offset]-g);d=pe(()=>{i.traveled=Math.max(e.startGap,Math.min(N,h.value)),a("scroll",N,h.value)})},ae=t=>{const s=Math.abs(t.target.getBoundingClientRect()[o.value.direction]-t[o.value.client])-u.value[o.value.offset]/2;i.traveled=Math.max(0,Math.min(s,h.value)),a("scroll",s,h.value)};return ce(()=>e.scrollFrom,t=>{i.isDragging||(i.traveled=Math.ceil(t*h.value))}),de(()=>{q()}),()=>H("div",{role:"presentation",ref:p,class:[n.b(),e.class,(e.alwaysOn||i.isDragging)&&"always-on"],style:ee.value,onMousedown:ve(ae,["stop","prevent"]),onTouchstartPrevent:G},H("div",{ref:u,class:r.e("thumb"),style:te.value,onMousedown:G},[]))}});export{Se as A,K as B,Ne as C,he as D,ze as E,V as F,b as H,ye as I,I as R,be as S,B as V,Y as a,W as b,Te as c,Be as d,_ as e,xe as f,De as g,we as h,Ie as i,Le as j,Re as k,Z as l,ge as u,Ce as v};