const $=t=>typeof t=="object"&&t!=null&&t.nodeType===1,tt=(t,o)=>(!o||t!=="hidden")&&t!=="visible"&&t!=="clip",S=(t,o)=>{if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){const s=getComputedStyle(t,null);return tt(s.overflowY,o)||tt(s.overflowX,o)||(h=>{const c=(l=>{if(!l.ownerDocument||!l.ownerDocument.defaultView)return null;try{return l.ownerDocument.defaultView.frameElement}catch{return null}})(h);return!!c&&(c.clientHeight<h.scrollHeight||c.clientWidth<h.scrollWidth)})(t)}return!1},X=(t,o,s,h,c,l,f,n)=>l<t&&f>o||l>t&&f<o?0:l<=t&&n<=s||f>=o&&n>=s?l-t-h:f>o&&n<s||l<t&&n>s?f-o+c:0,nt=t=>{const o=t.parentElement;return o??(t.getRootNode().host||null)},lt=(t,o)=>{var s,h,c,l;if(typeof document>"u")return[];const{scrollMode:f,block:n,inline:a,boundary:Y,skipOverflowHiddenElements:et}=o,ot=typeof Y=="function"?Y:p=>p!==Y;if(!$(t))throw new TypeError("Invalid target");const j=document.scrollingElement||document.documentElement,M=[];let r=t;for(;$(r)&&ot(r);){if(r=nt(r),r===j){M.push(r);break}r!=null&&r===document.body&&S(r)&&!S(document.documentElement)||r!=null&&S(r,et)&&M.push(r)}const m=(h=(s=window.visualViewport)==null?void 0:s.width)!=null?h:innerWidth,w=(l=(c=window.visualViewport)==null?void 0:c.height)!=null?l:innerHeight,{scrollX:W,scrollY:b}=window,{height:H,width:y,top:v,right:N,bottom:O,left:E}=t.getBoundingClientRect(),{top:K,right:P,bottom:Q,left:U}=(p=>{const e=window.getComputedStyle(p);return{top:parseFloat(e.scrollMarginTop)||0,right:parseFloat(e.scrollMarginRight)||0,bottom:parseFloat(e.scrollMarginBottom)||0,left:parseFloat(e.scrollMarginLeft)||0}})(t);let i=n==="start"||n==="nearest"?v-K:n==="end"?O+Q:v+H/2-K+Q,d=a==="center"?E+y/2-U+P:a==="end"?N+P:E-U;const q=[];for(let p=0;p<M.length;p++){const e=M[p],{height:T,width:x,top:B,right:z,bottom:A,left:C}=e.getBoundingClientRect();if(f==="if-needed"&&v>=0&&E>=0&&O<=w&&N<=m&&(e===j&&!S(e)||v>=B&&O<=A&&E>=C&&N<=z))return q;const F=getComputedStyle(e),I=parseInt(F.borderLeftWidth,10),R=parseInt(F.borderTopWidth,10),V=parseInt(F.borderRightWidth,10),k=parseInt(F.borderBottomWidth,10);let u=0,g=0;const D="offsetWidth"in e?e.offsetWidth-e.clientWidth-I-V:0,L="offsetHeight"in e?e.offsetHeight-e.clientHeight-R-k:0,G="offsetWidth"in e?e.offsetWidth===0?0:x/e.offsetWidth:0,J="offsetHeight"in e?e.offsetHeight===0?0:T/e.offsetHeight:0;if(j===e)u=n==="start"?i:n==="end"?i-w:n==="nearest"?X(b,b+w,w,R,k,b+i,b+i+H,H):i-w/2,g=a==="start"?d:a==="center"?d-m/2:a==="end"?d-m:X(W,W+m,m,I,V,W+d,W+d+y,y),u=Math.max(0,u+b),g=Math.max(0,g+W);else{u=n==="start"?i-B-R:n==="end"?i-A+k+L:n==="nearest"?X(B,A,T,R,k+L,i,i+H,H):i-(B+T/2)+L/2,g=a==="start"?d-C-I:a==="center"?d-(C+x/2)+D/2:a==="end"?d-z+V+D:X(C,z,x,I,V+D,d,d+y,y);const{scrollLeft:Z,scrollTop:_}=e;u=J===0?0:Math.max(0,Math.min(_+u/J,e.scrollHeight-T/J+L)),g=G===0?0:Math.max(0,Math.min(Z+g/G,e.scrollWidth-x/G+D)),i+=_-u,d+=Z-g}q.push({el:e,top:u,left:g})}return q};export{lt as r};
