"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),o=require("../../_util/type.js"),v=require("../../vc-util/Dom/class.js"),m=t=>t?{left:t.offsetLeft,right:t.parentElement.clientWidth-t.clientWidth-t.offsetLeft,width:t.clientWidth}:null,i=t=>t!==void 0?`${t}px`:void 0,C=n.defineComponent({props:{value:o.anyType(),getValueIndex:o.anyType(),prefixCls:o.anyType(),motionName:o.anyType(),onMotionStart:o.anyType(),onMotionEnd:o.anyType(),direction:o.anyType(),containerRef:o.anyType()},emits:["motionStart","motionEnd"],setup(t,{emit:u}){const h=n.ref(),d=e=>{const s=t.getValueIndex(e),r=t.containerRef.value?.querySelectorAll(`.${t.prefixCls}-item`)[s];return r?.offsetParent&&r},a=n.ref(null),l=n.ref(null);n.watch(()=>t.value,(e,s)=>{const r=d(s),f=d(e),x=m(r),A=m(f);a.value=x,l.value=A,u(r&&f?"motionStart":"motionEnd")},{flush:"post"});const y=n.computed(()=>t.direction==="rtl"?i(-a.value?.right):i(a.value?.left)),p=n.computed(()=>t.direction==="rtl"?i(-l.value?.right):i(l.value?.left));let c;const b=e=>{clearTimeout(c),n.nextTick(()=>{e&&(e.style.transform="translateX(var(--thumb-start-left))",e.style.width="var(--thumb-start-width)")})},T=e=>{c=setTimeout(()=>{e&&(v.addClass(e,`${t.motionName}-appear-active`),e.style.transform="translateX(var(--thumb-active-left))",e.style.width="var(--thumb-active-width)")})},S=e=>{a.value=null,l.value=null,e&&(e.style.transform=null,e.style.width=null,v.removeClass(e,`${t.motionName}-appear-active`)),u("motionEnd")},w=n.computed(()=>({"--thumb-start-left":y.value,"--thumb-start-width":i(a.value?.width),"--thumb-active-left":p.value,"--thumb-active-width":i(l.value?.width)}));return n.onBeforeUnmount(()=>{clearTimeout(c)}),()=>{const e={ref:h,style:w.value,class:[`${t.prefixCls}-thumb`]};return n.createVNode(n.Transition,{appear:!0,onBeforeEnter:b,onEnter:T,onAfterEnter:S},{default:()=>[!a.value||!l.value?null:n.createVNode("div",e,null)]})}}});exports.default=C;
