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