import{r as t}from"./index-NdkWRN8K.js";import{r as E}from"./index-B5xazMy1.js";import{j as i}from"./jsx-runtime-CnH95YSl.js";import{u as d,s as l}from"./useIsFocusVisible-DH0qxT5e.js";import{g as x}from"./getReactElementRef-DsIevm5t.js";import{a as m}from"./OdysseyThemeProvider-Bh0Bu-2o.js";function P(n){return typeof n=="function"?n():n}const y=t.forwardRef(function(u,s){const{children:e,container:a,disablePortal:o=!1}=u,[r,f]=t.useState(null),c=d(t.isValidElement(e)?x(e):null,s);if(m(()=>{o||f(P(a)||document.body)},[a,o]),m(()=>{if(r&&!o)return l(s,r),()=>{l(s,null)}},[s,r,o]),o){if(t.isValidElement(e)){const p={ref:c};return t.cloneElement(e,p)}return i.jsx(t.Fragment,{children:e})}return i.jsx(t.Fragment,{children:r&&E.createPortal(e,r)})});export{y as P};
