import{r}from"./react-DnjLh4X0.js";const e=r.createContext(null),t={didCatch:!1,error:null};class o extends r.Component{constructor(r){super(r),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=t}static getDerivedStateFromError(r){return{didCatch:!0,error:r}}resetErrorBoundary(){const{error:r}=this.state;if(null!==r){for(var e,o,s=arguments.length,n=new Array(s),a=0;a<s;a++)n[a]=arguments[a];null===(e=(o=this.props).onReset)||void 0===e||e.call(o,{args:n,reason:"imperative-api"}),this.setState(t)}}componentDidCatch(r,e){var t,o;null===(t=(o=this.props).onError)||void 0===t||t.call(o,r,e)}componentDidUpdate(r,e){const{didCatch:o}=this.state,{resetKeys:s}=this.props;var n,a;o&&null!==e.error&&function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return r.length!==e.length||r.some((r,t)=>!Object.is(r,e[t]))}(r.resetKeys,s)&&(null===(n=(a=this.props).onReset)||void 0===n||n.call(a,{next:s,prev:r.resetKeys,reason:"keys"}),this.setState(t))}render(){const{children:t,fallbackRender:o,FallbackComponent:s,fallback:n}=this.props,{didCatch:a,error:i}=this.state;let l=t;if(a){const e={error:i,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof o)l=o(e);else if(s)l=r.createElement(s,e);else{if(void 0===n)throw i;l=n}}return r.createElement(e.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},l)}}export{o as E};
