import t from"../../@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js";import n from"../../@babel/runtime/helpers/esm/inheritsLoose.js";import e from"../../prop-types/index.js";import i from"react";import o from"../../react-dom/index.js";import r from"./config.js";import{timeoutsShape as s}from"./utils/PropTypes.js";import a from"./TransitionGroupContext.js";import{forceReflow as u}from"./utils/reflow.js";var p="unmounted",l="exited",c="entering",d="entered",f="exiting",E=function(e){function s(t,n){var i;i=e.call(this,t,n)||this;var o,r=n&&!n.isMounting?t.enter:t.appear;return i.appearStatus=null,t.in?r?(o=l,i.appearStatus=c):o=d:o=t.unmountOnExit||t.mountOnEnter?p:l,i.state={status:o},i.nextCallback=null,i}n(s,e),s.getDerivedStateFromProps=function(t,n){return t.in&&n.status===p?{status:l}:null};var E=s.prototype;return E.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},E.componentDidUpdate=function(t){var n=null;if(t!==this.props){var e=this.state.status;this.props.in?e!==c&&e!==d&&(n=c):e!==c&&e!==d||(n=f)}this.updateStatus(!1,n)},E.componentWillUnmount=function(){this.cancelNextCallback()},E.getTimeouts=function(){var t,n,e,i=this.props.timeout;return t=n=e=i,null!=i&&"number"!=typeof i&&(t=i.exit,n=i.enter,e=void 0!==i.appear?i.appear:n),{exit:t,enter:n,appear:e}},E.updateStatus=function(t,n){if(void 0===t&&(t=!1),null!==n)if(this.cancelNextCallback(),n===c){if(this.props.unmountOnExit||this.props.mountOnEnter){var e=this.props.nodeRef?this.props.nodeRef.current:o.findDOMNode(this);e&&u(e)}this.performEnter(t)}else this.performExit();else this.props.unmountOnExit&&this.state.status===l&&this.setState({status:p})},E.performEnter=function(t){var n=this,e=this.props.enter,i=this.context?this.context.isMounting:t,s=this.props.nodeRef?[i]:[o.findDOMNode(this),i],a=s[0],u=s[1],p=this.getTimeouts(),l=i?p.appear:p.enter;!t&&!e||r.disabled?this.safeSetState({status:d},(function(){n.props.onEntered(a)})):(this.props.onEnter(a,u),this.safeSetState({status:c},(function(){n.props.onEntering(a,u),n.onTransitionEnd(l,(function(){n.safeSetState({status:d},(function(){n.props.onEntered(a,u)}))}))})))},E.performExit=function(){var t=this,n=this.props.exit,e=this.getTimeouts(),i=this.props.nodeRef?void 0:o.findDOMNode(this);n&&!r.disabled?(this.props.onExit(i),this.safeSetState({status:f},(function(){t.props.onExiting(i),t.onTransitionEnd(e.exit,(function(){t.safeSetState({status:l},(function(){t.props.onExited(i)}))}))}))):this.safeSetState({status:l},(function(){t.props.onExited(i)}))},E.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},E.safeSetState=function(t,n){n=this.setNextCallback(n),this.setState(t,n)},E.setNextCallback=function(t){var n=this,e=!0;return this.nextCallback=function(i){e&&(e=!1,n.nextCallback=null,t(i))},this.nextCallback.cancel=function(){e=!1},this.nextCallback},E.onTransitionEnd=function(t,n){this.setNextCallback(n);var e=this.props.nodeRef?this.props.nodeRef.current:o.findDOMNode(this),i=null==t&&!this.props.addEndListener;if(e&&!i){if(this.props.addEndListener){var r=this.props.nodeRef?[this.nextCallback]:[e,this.nextCallback],s=r[0],a=r[1];this.props.addEndListener(s,a)}null!=t&&setTimeout(this.nextCallback,t)}else setTimeout(this.nextCallback,0)},E.render=function(){var n=this.state.status;if(n===p)return null;var e=this.props,o=e.children;e.in,e.mountOnEnter,e.unmountOnExit,e.appear,e.enter,e.exit,e.timeout,e.addEndListener,e.onEnter,e.onEntering,e.onEntered,e.onExit,e.onExiting,e.onExited,e.nodeRef;var r=t(e,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return i.createElement(a.Provider,{value:null},"function"==typeof o?o(n,r):i.cloneElement(i.Children.only(o),r))},s}(i.Component);function h(){}E.contextType=a,E.propTypes="production"!==process.env.NODE_ENV?{nodeRef:e.shape({current:"undefined"==typeof Element?e.any:function(t,n,i,o,r,s){var a=t[n];return e.instanceOf(a&&"ownerDocument"in a?a.ownerDocument.defaultView.Element:Element)(t,n,i,o,r,s)}}),children:e.oneOfType([e.func.isRequired,e.element.isRequired]).isRequired,in:e.bool,mountOnEnter:e.bool,unmountOnExit:e.bool,appear:e.bool,enter:e.bool,exit:e.bool,timeout:function(t){var n=s;t.addEndListener||(n=n.isRequired);for(var e=arguments.length,i=new Array(e>1?e-1:0),o=1;o<e;o++)i[o-1]=arguments[o];return n.apply(void 0,[t].concat(i))},addEndListener:e.func,onEnter:e.func,onEntering:e.func,onEntered:e.func,onExit:e.func,onExiting:e.func,onExited:e.func}:{},E.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:h,onEntering:h,onEntered:h,onExit:h,onExiting:h,onExited:h},E.UNMOUNTED=p,E.EXITED=l,E.ENTERING=c,E.ENTERED=d,E.EXITING=f;var m=E;export{d as ENTERED,c as ENTERING,l as EXITED,f as EXITING,p as UNMOUNTED,m as default};
//# sourceMappingURL=Transition.js.map
