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