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