const e=require("../_util/throttleByAnimationFrame.js"),t=require("../_util/props-util/initDefaultProps.js"),n=require("../config-provider/hooks/useConfigInject.js"),r=require("../_util/getScroll.js"),i=require("../_util/scrollTo.js"),a=require("../_util/transition.js"),o=require("./interface.js"),s=require("./context.js"),c=require("./style/index.js"),l=require("./FloatButton.js");let u=require("vue"),d=require("@antsoo-lib/icons");var f=(0,u.defineComponent)({compatConfig:{MODE:3},name:`ABackTop`,inheritAttrs:!1,props:t.default(o.backTopProps(),{visibilityHeight:400,target:()=>window,duration:450,type:`default`,shape:`circle`}),setup(t,{slots:o,attrs:f,emit:p}){let{prefixCls:m,direction:h}=n.default(l.floatButtonPrefixCls,t),[g]=c.default(m),_=(0,u.ref)(),v=(0,u.reactive)({visible:t.visibilityHeight===0,scrollEvent:null}),y=()=>_.value&&_.value.ownerDocument?_.value.ownerDocument:window,b=e=>{let{target:n=y,duration:r}=t;i.default(0,{getContainer:n,duration:r}),p(`click`,e)},x=e.default(e=>{let{visibilityHeight:n}=t,i=r.default(e.target,!0);v.visible=i>=n}),S=()=>{let{target:e}=t,n=(e||y)();x({target:n}),n?.addEventListener(`scroll`,x)},C=()=>{let{target:e}=t,n=(e||y)();x.cancel(),n?.removeEventListener(`scroll`,x)};(0,u.watch)(()=>t.target,()=>{C(),(0,u.nextTick)(()=>{S()})}),(0,u.onMounted)(()=>{(0,u.nextTick)(()=>{S()})}),(0,u.onActivated)(()=>{(0,u.nextTick)(()=>{S()})}),(0,u.onDeactivated)(()=>{C()}),(0,u.onBeforeUnmount)(()=>{C()});let w=s.useInjectFloatButtonGroupContext();return()=>{let{description:e,type:n,shape:r,tooltip:i,badge:s}=t,c={...f,shape:w?.shape.value||r,onClick:b,class:{[`${m.value}`]:!0,[`${f.class}`]:f.class,[`${m.value}-rtl`]:h.value===`rtl`},description:e,type:n,tooltip:i,badge:s},p=a.getTransitionProps(`fade`);return g((0,u.createVNode)(u.Transition,p,{default:()=>[(0,u.withDirectives)((0,u.createVNode)(l.default,{...c,ref:_},{icon:()=>o.icon?.()||(0,u.createVNode)(d.VerticalAlignTopOutlined,null,null)}),[[u.vShow,v.visible]])]}))}}});exports.default=f;