import{o as e}from"./rolldown-runtime.DAXXjFlN.js";import{r as t}from"./emotion-is-prop-valid.esm.CygBv61C.js";import{N as n,T as r,lt as i}from"./Tooltip.DJg7muty.js";var a=e(t(),1);function o(e,t,n,i){let o=r(n),s=n==null;(0,a.useEffect)(()=>{if(s||!e.current)return;let n=e.current;return n.addEventListener(t,o,i),()=>{n.removeEventListener(t,o,i)}},[e,t,i,s])}function s(e,t){if(!e)return!1;let n=window.getComputedStyle(e),r=document.scrollingElement||document.documentElement,i=/(auto|scroll)/.test(n.overflow+n.overflowX+n.overflowY);return e===r&&n.overflow!==`hidden`&&(i=!0),i&&t&&(i=e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth),i}function c(e,t){let n=[],r=document.scrollingElement||document.documentElement;for(;e&&(s(e,t)&&n.push(e),e!==r);)e=e.parentElement;return n}function l(e,t,r={}){let{block:i=`nearest`,inline:a=`nearest`}=r;if(e===t)return;let o=e.scrollTop,s=e.scrollLeft,c=t.getBoundingClientRect(),l=e.getBoundingClientRect(),u=window.getComputedStyle(t),d=window.getComputedStyle(e),f=document.scrollingElement||document.documentElement,p=e===f,m=e===f?0:l.top,h=e===f?e.clientHeight:l.bottom,g=e===f?0:l.left,_=e===f?e.clientWidth:l.right,v=parseFloat(u.scrollMarginTop)||0,y=parseFloat(u.scrollMarginBottom)||0,b=parseFloat(u.scrollMarginLeft)||0,x=parseFloat(u.scrollMarginRight)||0,S=parseFloat(d.scrollPaddingTop)||0,C=parseFloat(d.scrollPaddingBottom)||0,w=parseFloat(d.scrollPaddingLeft)||0,T=parseFloat(d.scrollPaddingRight)||0,E=parseFloat(d.borderTopWidth)||0,D=parseFloat(d.borderBottomWidth)||0,O=parseFloat(d.borderLeftWidth)||0,k=parseFloat(d.borderRightWidth)||0,A=c.top-v,j=c.bottom+y,M=c.left-b,N=c.right+x,P=e===f?0:O+k,F=e===f?0:E+D,I=e===f?0:e.offsetWidth-e.clientWidth-P,L=e===f?0:e.offsetHeight-e.clientHeight-F,R=m+(p?0:E)+S,z=h-(p?0:D)-C-L,B=g+(p?0:O)+w,V=_-(p?0:k)-T;d.direction===`rtl`&&!n()?B+=I:V-=I;let H=A<R||j>z,U=M<B||N>V;if(H&&i===`start`)o+=A-R;else if(H&&i===`center`)o+=(A+j)/2-(R+z)/2;else if(H&&i===`end`)o+=j-z;else if(H&&i===`nearest`){let e=A-R,t=j-z;o+=Math.abs(e)<=Math.abs(t)?e:t}if(U&&a===`start`)s+=M-B;else if(U&&a===`center`)s+=(M+N)/2-(B+V)/2;else if(U&&a===`end`)s+=N-V;else if(U&&a===`nearest`){let e=M-B,t=N-V;s+=Math.abs(e)<=Math.abs(t)?e:t}e.scrollTo({left:s,top:o})}function u(e,t={}){let{containingElement:n}=t;if(e&&e.isConnected){let t=document.scrollingElement||document.documentElement;if(window.getComputedStyle(t).overflow!==`hidden`){let{left:t,top:r}=e.getBoundingClientRect();e?.scrollIntoView?.({block:`nearest`});let{left:i,top:a}=e.getBoundingClientRect();(Math.abs(t-i)>1||Math.abs(r-a)>1)&&(n?.scrollIntoView?.({block:`center`,inline:`center`}),e.scrollIntoView?.({block:`nearest`}))}else{let{left:t,top:r}=e.getBoundingClientRect(),i=c(e,!0);for(let t of i)l(t,e);let{left:a,top:o}=e.getBoundingClientRect();if(Math.abs(t-a)>1||Math.abs(r-o)>1){i=n?c(n,!0):[];for(let e of i)l(e,n,{block:`center`,inline:`center`});for(let t of c(e,!0))l(t,e)}}}}var d=0,f=new Map;function p(e){let[t,n]=(0,a.useState)();return i(()=>{if(!e)return;let t=f.get(e);if(t)n(t.element.id);else{let r=`react-aria-description-${d++}`;n(r);let i=document.createElement(`div`);i.id=r,i.style.display=`none`,i.textContent=e,document.body.appendChild(i),t={refCount:0,element:i},f.set(e,t)}return t.refCount++,()=>{t&&--t.refCount===0&&(t.element.remove(),f.delete(e))}},[e]),{"aria-describedby":e?t:void 0}}export{o as a,s as i,l as n,u as r,p as t};