import{b as k,_ as O,T as D,a as y,s as S}from"./ButtonBase-1.0.74-W6tAH7AI.js";import{r as E,R as v}from"./redux-1.0.74-D8bIc6ki.js";import{R as T,b as P}from"./utils-1.0.74-7xWhx9mc.js";import{u as g}from"./useEnhancedEffect-1.0.74-B56M26dS.js";function F(o){return o&&o.ownerDocument||document}function M(o){var a;return parseInt(E.version,10)>=19?((a=o==null?void 0:o.props)==null?void 0:a.ref)||null:(o==null?void 0:o.ref)||null}const C={disabled:!1};var I=function(a){return a.scrollTop},m="unmounted",p="exited",c="entering",h="entered",b="exiting",f=function(o){k(a,o);function a(i,e){var t;t=o.call(this,i,e)||this;var n=e,r=n&&!n.isMounting?i.enter:i.appear,u;return t.appearStatus=null,i.in?r?(u=p,t.appearStatus=c):u=h:i.unmountOnExit||i.mountOnEnter?u=m:u=p,t.state={status:u},t.nextCallback=null,t}a.getDerivedStateFromProps=function(e,t){var n=e.in;return n&&t.status===m?{status:p}:null};var s=a.prototype;return s.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},s.componentDidUpdate=function(e){var t=null;if(e!==this.props){var n=this.state.status;this.props.in?n!==c&&n!==h&&(t=c):(n===c||n===h)&&(t=b)}this.updateStatus(!1,t)},s.componentWillUnmount=function(){this.cancelNextCallback()},s.getTimeouts=function(){var e=this.props.timeout,t,n,r;return t=n=r=e,e!=null&&typeof e!="number"&&(t=e.exit,n=e.enter,r=e.appear!==void 0?e.appear:n),{exit:t,enter:n,appear:r}},s.updateStatus=function(e,t){if(e===void 0&&(e=!1),t!==null)if(this.cancelNextCallback(),t===c){if(this.props.unmountOnExit||this.props.mountOnEnter){var n=this.props.nodeRef?this.props.nodeRef.current:T.findDOMNode(this);n&&I(n)}this.performEnter(e)}else this.performExit();else this.props.unmountOnExit&&this.state.status===p&&this.setState({status:m})},s.performEnter=function(e){var t=this,n=this.props.enter,r=this.context?this.context.isMounting:e,u=this.props.nodeRef?[r]:[T.findDOMNode(this),r],l=u[0],x=u[1],N=this.getTimeouts(),R=r?N.appear:N.enter;if(!e&&!n||C.disabled){this.safeSetState({status:h},function(){t.props.onEntered(l)});return}this.props.onEnter(l,x),this.safeSetState({status:c},function(){t.props.onEntering(l,x),t.onTransitionEnd(R,function(){t.safeSetState({status:h},function(){t.props.onEntered(l,x)})})})},s.performExit=function(){var e=this,t=this.props.exit,n=this.getTimeouts(),r=this.props.nodeRef?void 0:T.findDOMNode(this);if(!t||C.disabled){this.safeSetState({status:p},function(){e.props.onExited(r)});return}this.props.onExit(r),this.safeSetState({status:b},function(){e.props.onExiting(r),e.onTransitionEnd(n.exit,function(){e.safeSetState({status:p},function(){e.props.onExited(r)})})})},s.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},s.safeSetState=function(e,t){t=this.setNextCallback(t),this.setState(e,t)},s.setNextCallback=function(e){var t=this,n=!0;return this.nextCallback=function(r){n&&(n=!1,t.nextCallback=null,e(r))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},s.onTransitionEnd=function(e,t){this.setNextCallback(t);var n=this.props.nodeRef?this.props.nodeRef.current:T.findDOMNode(this),r=e==null&&!this.props.addEndListener;if(!n||r){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var u=this.props.nodeRef?[this.nextCallback]:[n,this.nextCallback],l=u[0],x=u[1];this.props.addEndListener(l,x)}e!=null&&setTimeout(this.nextCallback,e)},s.render=function(){var e=this.state.status;if(e===m)return null;var t=this.props,n=t.children;t.in,t.mountOnEnter,t.unmountOnExit,t.appear,t.enter,t.exit,t.timeout,t.addEndListener,t.onEnter,t.onEntering,t.onEntered,t.onExit,t.onExiting,t.onExited,t.nodeRef;var r=O(t,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return v.createElement(D.Provider,{value:null},typeof n=="function"?n(e,r):v.cloneElement(v.Children.only(n),r))},a}(v.Component);f.contextType=D;f.propTypes={};function d(){}f.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:d,onEntering:d,onEntered:d,onExit:d,onExiting:d,onExited:d};f.UNMOUNTED=m;f.EXITED=p;f.ENTERING=c;f.ENTERED=h;f.EXITING=b;const X=o=>o.scrollTop;function W(o,a){const{timeout:s,easing:i,style:e={}}=o;return{duration:e.transitionDuration??(typeof s=="number"?s:s[a.mode]||0),easing:e.transitionTimingFunction??(typeof i=="object"?i[a.mode]:i),delay:e.transitionDelay}}function _(o){return typeof o=="function"?o():o}const j=E.forwardRef(function(a,s){const{children:i,container:e,disablePortal:t=!1}=a,[n,r]=E.useState(null),u=y(E.isValidElement(i)?M(i):null,s);if(g(()=>{t||r(_(e)||document.body)},[e,t]),g(()=>{if(n&&!t)return S(s,n),()=>{S(s,null)}},[s,n,t]),t){if(E.isValidElement(i)){const l={ref:u};return E.cloneElement(i,l)}return i}return n&&P.createPortal(i,n)});export{j as P,f as T,W as a,I as f,M as g,F as o,X as r};
