import e from"../_util/supportsPassive.mjs";import t from"../vc-util/Dom/addEventListener.mjs";function n(e){return e===window?{top:0,bottom:window.innerHeight}:e.getBoundingClientRect()}function r(e,t,n){if(n!==void 0&&t.top>e.top-n)return`${n+t.top}px`}function i(e,t,n){if(n!==void 0&&t.bottom<e.bottom+n)return`${n+(window.innerHeight-t.bottom)}px`}var a=[`resize`,`scroll`,`touchstart`,`touchmove`,`touchend`,`pageshow`,`load`],o=[];function s(n,r){if(!n)return;let i=o.find(e=>e.target===n);i?i.affixList.push(r):(i={target:n,affixList:[r],eventHandlers:{}},o.push(i),a.forEach(r=>{i.eventHandlers[r]=t(n,r,()=>{i.affixList.forEach(e=>{let{lazyUpdatePosition:t}=e.exposed;t()},(r===`touchstart`||r===`touchmove`)&&e?{passive:!0}:!1)})}))}function c(e){let t=o.find(t=>{let n=t.affixList.includes(e);return n&&(t.affixList=t.affixList.filter(t=>t!==e)),n});t&&t.affixList.length===0&&(o=o.filter(e=>e!==t),a.forEach(e=>{let n=t.eventHandlers[e];n&&n.remove&&n.remove()}))}export{s as addObserveTarget,i as getFixedBottom,r as getFixedTop,n as getTargetRect,c as removeObserveTarget};