import e from"../../_util/classNames.mjs";import t from"../../vc-util/Dom/addEventListener.mjs";import n from"../../_util/vue-types/index.mjs";import{computed as r,createVNode as i,defineComponent as a,onBeforeUnmount as o,onMounted as s,shallowRef as c}from"vue";var l=a({compatConfig:{MODE:3},name:`Handle`,inheritAttrs:!1,props:{prefixCls:String,vertical:{type:Boolean,default:void 0},offset:Number,disabled:{type:Boolean,default:void 0},min:Number,max:Number,value:Number,tabindex:n.oneOfType([n.number,n.string]),reverse:{type:Boolean,default:void 0},ariaLabel:String,ariaLabelledBy:String,ariaValueTextFormatter:Function,onMouseenter:{type:Function},onMouseleave:{type:Function},onMousedown:{type:Function}},setup(n,{attrs:a,emit:l,expose:u}){let d=c(!1),f=c(),p=()=>{document.activeElement===f.value&&(d.value=!0)},m=e=>{d.value=!1,l(`blur`,e)},h=()=>{d.value=!1},g=()=>{f.value?.focus()},_=()=>{f.value?.blur()},v=()=>{d.value=!0,g()},y=e=>{e.preventDefault(),g(),l(`mousedown`,e)};u({focus:g,blur:_,clickFocus:v,ref:f});let b=null;s(()=>{b=t(document,`mouseup`,p)}),o(()=>{b?.remove()});let x=r(()=>{let{vertical:e,offset:t,reverse:r}=n;return e?{[r?`top`:`bottom`]:`${t}%`,[r?`bottom`:`top`]:`auto`,transform:r?null:`translateY(+50%)`}:{[r?`right`:`left`]:`${t}%`,[r?`left`:`right`]:`auto`,transform:`translateX(${r?`+`:`-`}50%)`}});return()=>{let{prefixCls:t,disabled:r,min:o,max:s,value:c,tabindex:l,ariaLabel:u,ariaLabelledBy:p,ariaValueTextFormatter:g,onMouseenter:_,onMouseleave:v}=n,b=e(a.class,{[`${t}-handle-click-focused`]:d.value}),S={"aria-valuemin":o,"aria-valuemax":s,"aria-valuenow":c,"aria-disabled":!!r},C=[a.style,x.value],w=l||0;(r||l===null)&&(w=null);let T;return g&&(T=g(c)),i(`div`,{...a,role:`slider`,tabindex:w,...S,class:b,onBlur:m,onKeydown:h,onMousedown:y,onMouseenter:_,onMouseleave:v,ref:f,style:C,"aria-label":u,"aria-labelledby":p,"aria-valuetext":T},null)}}});export{l as default};