var e=Object.defineProperty,a=Object.defineProperties,l=Object.getOwnPropertyDescriptors,t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,s=Math.pow,i=(a,l,t)=>l in a?e(a,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[l]=t,n=(e,a)=>{for(var l in a||(a={}))r.call(a,l)&&i(e,l,a[l]);if(t)for(var l of t(a))o.call(a,l)&&i(e,l,a[l]);return e};import{a8 as u,a0 as c,d as v,a9 as f,a1 as m,aa as d,r as p,c as b,g as y,br as h,ay as g,G as w,o as S,w as z,M as x,j as E,O as _,k as L,i as H,h as O,aj as k,a3 as T,bs as j,a as C,b as B,H as R,be as N,bt as W,at as M,bu as P,y as A,ae as $,e as q,bv as I,f as K,n as X,bw as Y,m as D,l as G,aE as F,ao as J,ap as Q,az as U}from"./index-BeZn6wgH.js";const V={vertical:{offset:"offsetHeight",scroll:"scrollTop",scrollSize:"scrollHeight",size:"height",key:"vertical",axis:"Y",client:"clientY",direction:"top"},horizontal:{offset:"offsetWidth",scroll:"scrollLeft",scrollSize:"scrollWidth",size:"width",key:"horizontal",axis:"X",client:"clientX",direction:"left"}},Z=Symbol("scrollbarContextKey"),ee=u({vertical:Boolean,size:String,move:Number,ratio:{type:Number,required:!0},always:Boolean});var ae=c(v({__name:"thumb",props:ee,setup(e){const a=e,l=f(Z),t=m("scrollbar");l||d("Thumb","can not inject scrollbar context");const r=p(),o=p(),i=p({}),n=p(!1);let u=!1,c=!1,v=0,C=0,B=j?document.onselectstart:null;const R=b(()=>V[a.vertical?"vertical":"horizontal"]),N=b(()=>(({move:e,size:a,bar:l})=>({[l.size]:a,transform:`translate${l.axis}(${e}%)`}))({size:a.size,move:a.move,bar:R.value})),W=b(()=>s(r.value[R.value.offset],2)/l.wrapElement[R.value.scrollSize]/a.ratio/o.value[R.value.offset]),M=e=>{var a;if(e.stopPropagation(),e.ctrlKey||[1,2].includes(e.button))return;null==(a=window.getSelection())||a.removeAllRanges(),A(e);const l=e.currentTarget;l&&(i.value[R.value.axis]=l[R.value.offset]-(e[R.value.client]-l.getBoundingClientRect()[R.value.direction]))},P=e=>{if(!o.value||!r.value||!l.wrapElement)return;const a=100*(Math.abs(e.target.getBoundingClientRect()[R.value.direction]-e[R.value.client])-o.value[R.value.offset]/2)*W.value/r.value[R.value.offset];l.wrapElement[R.value.scroll]=a*l.wrapElement[R.value.scrollSize]/100},A=e=>{e.stopImmediatePropagation(),u=!0,v=l.wrapElement.scrollHeight,C=l.wrapElement.scrollWidth,document.addEventListener("mousemove",$),document.addEventListener("mouseup",q),B=document.onselectstart,document.onselectstart=()=>!1},$=e=>{if(!r.value||!o.value)return;if(!1===u)return;const a=i.value[R.value.axis];if(!a)return;const t=100*(-1*(r.value.getBoundingClientRect()[R.value.direction]-e[R.value.client])-(o.value[R.value.offset]-a))*W.value/r.value[R.value.offset];"scrollLeft"===R.value.scroll?l.wrapElement[R.value.scroll]=t*C/100:l.wrapElement[R.value.scroll]=t*v/100},q=()=>{u=!1,i.value[R.value.axis]=0,document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",q),I(),c&&(n.value=!1)};y(()=>{I(),document.removeEventListener("mouseup",q)});const I=()=>{document.onselectstart!==B&&(document.onselectstart=B)};return h(g(l,"scrollbarElement"),"mousemove",()=>{c=!1,n.value=!!a.size}),h(g(l,"scrollbarElement"),"mouseleave",()=>{c=!0,n.value=u}),(e,a)=>(S(),w(T,{name:H(t).b("fade"),persisted:""},{default:z(()=>[x(E("div",{ref_key:"instance",ref:r,class:L([H(t).e("bar"),H(t).is(H(R).key)]),onMousedown:P,onClick:_(()=>{},["stop"])},[E("div",{ref_key:"thumb",ref:o,class:L(H(t).e("thumb")),style:O(H(N)),onMousedown:M},null,38)],42,["onClick"]),[[k,e.always||n.value]])]),_:1},8,["name"]))}}),[["__file","thumb.vue"]]);var le=c(v({__name:"bar",props:u({always:{type:Boolean,default:!0},minSize:{type:Number,required:!0}}),setup(e,{expose:a}){const l=e,t=f(Z),r=p(0),o=p(0),i=p(""),n=p(""),u=p(1),c=p(1);return a({handleScroll:e=>{if(e){const a=e.offsetHeight-4,l=e.offsetWidth-4;o.value=100*e.scrollTop/a*u.value,r.value=100*e.scrollLeft/l*c.value}},update:()=>{const e=null==t?void 0:t.wrapElement;if(!e)return;const a=e.offsetHeight-4,r=e.offsetWidth-4,o=s(a,2)/e.scrollHeight,v=s(r,2)/e.scrollWidth,f=Math.max(o,l.minSize),m=Math.max(v,l.minSize);u.value=o/(a-o)/(f/(a-f)),c.value=v/(r-v)/(m/(r-m)),n.value=f+4(S(),C(R,null,[B(ae,{move:r.value,ratio:c.value,size:i.value,always:e.always},null,8,["move","ratio","size","always"]),B(ae,{move:o.value,ratio:u.value,size:n.value,vertical:"",always:e.always},null,8,["move","ratio","size","always"])],64))}}),[["__file","bar.vue"]]);const te=u(n({distance:{type:Number,default:0},height:{type:[String,Number],default:""},maxHeight:{type:[String,Number],default:""},native:Boolean,wrapStyle:{type:M([String,Object,Array]),default:""},wrapClass:{type:[String,Array],default:""},viewClass:{type:[String,Array],default:""},viewStyle:{type:[String,Array,Object],default:""},noresize:Boolean,tag:{type:String,default:"div"},always:Boolean,minSize:{type:Number,default:20},tabindex:{type:[String,Number],default:void 0},id:String,role:String},W(["ariaLabel","ariaOrientation"]))),re={"end-reached":e=>["left","right","top","bottom"].includes(e),scroll:({scrollTop:e,scrollLeft:a})=>[e,a].every(N)},oe=v({name:"ElScrollbar"});var se;const ie=U(c(v((se=n({},oe),a(se,l({props:te,emits:re,setup(e,{expose:a,emit:l}){const t=e,r=m("scrollbar");let o,s,i,n=0,u=0,c="";const v={bottom:!1,top:!1,right:!1,left:!1},f=p(),d=p(),y=p(),g=p(),x=b(()=>{const e={};return t.height&&(e.height=P(t.height)),t.maxHeight&&(e.maxHeight=P(t.maxHeight)),[t.wrapStyle,e]}),_=b(()=>[t.wrapClass,r.e("wrap"),{[r.em("wrap","hidden-default")]:!t.native}]),k=b(()=>[r.e("view"),t.viewClass]),T={top:"bottom",bottom:"top",left:"right",right:"left"},j=()=>{var e;if(d.value){null==(e=g.value)||e.handleScroll(d.value);const a=n,r=u;n=d.value.scrollTop,u=d.value.scrollLeft;const o={bottom:n+d.value.clientHeight>=d.value.scrollHeight-t.distance,top:n<=t.distance&&0!==a,right:u+d.value.clientWidth>=d.value.scrollWidth-t.distance&&r!==u,left:u<=t.distance&&0!==r};if(l("scroll",{scrollTop:n,scrollLeft:u}),a!==n&&(c=n>a?"bottom":"top"),r!==u&&(c=u>r?"right":"left"),t.distance>0){if((e=>{var a;return null!=(a=v[e])&&a})(c))return;(e=>{const a=T[c];if(!a)return;const l=e[c],t=e[a];l&&!v[c]&&(v[c]=!0),!t&&v[a]&&(v[a]=!1)})(o)}o[c]&&l("end-reached",c)}},B=()=>{var e;null==(e=g.value)||e.update(),v[c]=!1};return A(()=>t.noresize,e=>{e?(null==o||o(),null==s||s(),null==i||i()):(({stop:o}=Q(y,B)),({stop:s}=Q(d,B)),i=h("resize",B))},{immediate:!0}),A(()=>[t.maxHeight,t.height],()=>{t.native||X(()=>{var e;B(),d.value&&(null==(e=g.value)||e.handleScroll(d.value))})}),$(Z,q({scrollbarElement:f,wrapElement:d})),I(()=>{d.value&&(d.value.scrollTop=n,d.value.scrollLeft=u)}),K(()=>{t.native||X(()=>{B()})}),Y(()=>B()),a({wrapRef:d,update:B,scrollTo:function(e,a){J(e)?d.value.scrollTo(e):N(e)&&N(a)&&d.value.scrollTo(e,a)},setScrollTop:e=>{N(e)&&(d.value.scrollTop=e)},setScrollLeft:e=>{N(e)&&(d.value.scrollLeft=e)},handleScroll:j}),(e,a)=>(S(),C("div",{ref_key:"scrollbarRef",ref:f,class:L(H(r).b())},[E("div",{ref_key:"wrapRef",ref:d,class:L(H(_)),style:O(H(x)),tabindex:e.tabindex,onScroll:j},[(S(),w(F(e.tag),{id:e.id,ref_key:"resizeRef",ref:y,class:L(H(k)),style:O(e.viewStyle),role:e.role,"aria-label":e.ariaLabel,"aria-orientation":e.ariaOrientation},{default:z(()=>[G(e.$slots,"default")]),_:3},8,["id","class","style","role","aria-label","aria-orientation"]))],46,["tabindex"]),e.native?D("v-if",!0):(S(),w(le,{key:0,ref_key:"barRef",ref:g,always:e.always,"min-size":e.minSize},null,8,["always","min-size"]))],2))}})))),[["__file","scrollbar.vue"]]));export{ie as E,re as s};