import e from"../../@babel/runtime/helpers/esm/inheritsLoose.js";import n from"react";import t from"../../prop-types/index.js";import{ENTERED as r,ENTERING as o,EXITING as i}from"./Transition.js";import a from"./TransitionGroupContext.js";var u,c;var s={out:"out-in",in:"in-out"},l=function(e,n,t){return function(){var r;e.props[n]&&(r=e.props)[n].apply(r,arguments),t()}},p=((u={})[s.out]=function(e){var t=e.current,r=e.changeState;return n.cloneElement(t,{in:!1,onExited:l(t,"onExited",(function(){r(o,null)}))})},u[s.in]=function(e){var t=e.current,r=e.changeState,i=e.children;return[t,n.cloneElement(i,{in:!0,onEntered:l(i,"onEntered",(function(){r(o)}))})]},u),d=((c={})[s.out]=function(e){var t=e.children,o=e.changeState;return n.cloneElement(t,{in:!0,onEntered:l(t,"onEntered",(function(){o(r,n.cloneElement(t,{in:!0}))}))})},c[s.in]=function(e){var t=e.current,o=e.children,i=e.changeState;return[n.cloneElement(t,{in:!1,onExited:l(t,"onExited",(function(){i(r,n.cloneElement(o,{in:!0}))}))}),n.cloneElement(o,{in:!0})]},c),m=function(t){function u(){for(var e,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return(e=t.call.apply(t,[this].concat(o))||this).state={status:r,current:null},e.appeared=!1,e.changeState=function(n,t){void 0===t&&(t=e.state.current),e.setState({status:n,current:t})},e}e(u,t);var c=u.prototype;return c.componentDidMount=function(){this.appeared=!0},u.getDerivedStateFromProps=function(e,t){return null==e.children?{current:null}:t.status===o&&e.mode===s.in?{status:o}:!t.current||(r=t.current,a=e.children,r===a||n.isValidElement(r)&&n.isValidElement(a)&&null!=r.key&&r.key===a.key)?{current:n.cloneElement(e.children,{in:!0})}:{status:i};var r,a},c.render=function(){var e,t=this.props,u=t.children,c=t.mode,s=this.state,l=s.status,m=s.current,h={children:u,current:m,changeState:this.changeState,status:l};switch(l){case o:e=d[c](h);break;case i:e=p[c](h);break;case r:e=m}return n.createElement(a.Provider,{value:{isMounting:!this.appeared}},e)},u}(n.Component);m.propTypes="production"!==process.env.NODE_ENV?{mode:t.oneOf([s.in,s.out]),children:t.oneOfType([t.element.isRequired])}:{},m.defaultProps={mode:s.out};var h=m;export{h as default,s as modes};
//# sourceMappingURL=SwitchTransition.js.map
