import{r as e,ak as E,aV as p,ao as l,gz as c,j as u,cd as P}from"./index-62412d73.js";function g(o){return typeof o=="function"?o():o}const x=e.forwardRef(function(i,a){const{children:t,container:s,disablePortal:r=!1}=i,[n,f]=e.useState(null),m=E(e.isValidElement(t)?p(t):null,a);if(l(()=>{r||f(g(s)||document.body)},[s,r]),l(()=>{if(n&&!r)return c(a,n),()=>{c(a,null)}},[a,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};
