import{r as e,ad as E,aO as h,ah as l,gA as c,j as u,c5 as p}from"./index-91e9700c.js";function P(a){return typeof a=="function"?a():a}const x=e.forwardRef(function(i,o){const{children:t,container:s,disablePortal:r=!1}=i,[n,f]=e.useState(null),m=E(e.isValidElement(t)?h(t):null,o);if(l(()=>{r||f(P(s)||document.body)},[s,r]),l(()=>{if(n&&!r)return c(o,n),()=>{c(o,null)}},[o,n,r]),r){if(e.isValidElement(t)){const d={ref:m};return e.cloneElement(t,d)}return u(e.Fragment,{children:t})}return u(e.Fragment,{children:n&&p.createPortal(t,n)})});export{x as P};
