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