import e from"react";import t from"../../../@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js";import r from"../../../@babel/runtime/helpers/esm/extends.js";import n from"../../../@babel/runtime/helpers/esm/assertThisInitialized.js";import o from"../../../@babel/runtime/helpers/esm/inheritsLoose.js";import"../../../react-is/index.js";import a from"../../../hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js";import{r as s}from"../../../../_virtual/index3.js_commonjs-module";var i=e.createContext(),c={};var u=function(e){return e};function l(l){var h=l.defaultResolveComponent,d=void 0===h?u:h,f=l.render,p=l.onLoad;function m(u,l){void 0===l&&(l={});var h=function(e){return"function"==typeof e?{requireAsync:e,resolve:function(){},chunkName:function(){}}:e}(u),m={};function y(e){return l.cacheKey?l.cacheKey(e):h.resolve?h.resolve(e):"static"}function v(e,t,r){var n=l.resolveComponent?l.resolveComponent(e,t):d(e);if(l.resolveComponent&&!s.exports.isValidElementType(n))throw new Error("resolveComponent returned something that is not a React component!");return a(r,n,{preload:!0}),n}var b,g,E=function(e){function a(t){var r;return(r=e.call(this,t)||this).state={result:null,error:null,loading:!0,cacheKey:y(t)},function(e,t){if(!e){var r=new Error("loadable: "+t);throw r.framesToPop=1,r.name="Invariant Violation",r}}(!t.__chunkExtractor||h.requireSync,"SSR requires `@loadable/babel-plugin`, please install it"),t.__chunkExtractor?(!1===l.ssr||(h.requireAsync(t).catch((function(){return null})),r.loadSync(),t.__chunkExtractor.addChunk(h.chunkName(t))),n(r)):(!1!==l.ssr&&(h.isReady&&h.isReady(t)||h.chunkName&&c[h.chunkName(t)])&&r.loadSync(),r)}o(a,e),a.getDerivedStateFromProps=function(e,t){var n=y(e);return r({},t,{cacheKey:n,loading:t.loading||t.cacheKey!==n})};var s=a.prototype;return s.componentDidMount=function(){this.mounted=!0;var e=this.getCache();e&&"REJECTED"===e.status&&this.setCache(),this.state.loading&&this.loadAsync()},s.componentDidUpdate=function(e,t){t.cacheKey!==this.state.cacheKey&&this.loadAsync()},s.componentWillUnmount=function(){this.mounted=!1},s.safeSetState=function(e,t){this.mounted&&this.setState(e,t)},s.getCacheKey=function(){return y(this.props)},s.getCache=function(){return m[this.getCacheKey()]},s.setCache=function(e){void 0===e&&(e=void 0),m[this.getCacheKey()]=e},s.triggerOnLoad=function(){var e=this;p&&setTimeout((function(){p(e.state.result,e.props)}))},s.loadSync=function(){if(this.state.loading)try{var e=v(h.requireSync(this.props),this.props,k);this.state.result=e,this.state.loading=!1}catch(e){console.error("loadable-components: failed to synchronously load component, which expected to be available",{fileName:h.resolve(this.props),chunkName:h.chunkName(this.props),error:e?e.message:e}),this.state.error=e}},s.loadAsync=function(){var e=this,t=this.resolveAsync();return t.then((function(t){var r=v(t,e.props,{Loadable:k});e.safeSetState({result:r,loading:!1},(function(){return e.triggerOnLoad()}))})).catch((function(t){return e.safeSetState({error:t,loading:!1})})),t},s.resolveAsync=function(){var e=this,r=this.props;r.__chunkExtractor,r.forwardedRef;var n=t(r,["__chunkExtractor","forwardedRef"]),o=this.getCache();return o||((o=h.requireAsync(n)).status="PENDING",this.setCache(o),o.then((function(){o.status="RESOLVED"}),(function(t){console.error("loadable-components: failed to asynchronously load component",{fileName:h.resolve(e.props),chunkName:h.chunkName(e.props),error:t?t.message:t}),o.status="REJECTED"}))),o},s.render=function(){var e=this.props,n=e.forwardedRef,o=e.fallback;e.__chunkExtractor;var a=t(e,["forwardedRef","fallback","__chunkExtractor"]),s=this.state,i=s.error,c=s.loading,u=s.result;if(l.suspense&&"PENDING"===(this.getCache()||this.loadAsync()).status)throw this.loadAsync();if(i)throw i;var h=o||l.fallback||null;return c?h:f({fallback:h,result:u,options:l,props:r({},a,{ref:n})})},a}(e.Component),C=(g=function(t){return e.createElement(i.Consumer,null,(function(r){return e.createElement(b,Object.assign({__chunkExtractor:r},t))}))},(b=E).displayName&&(g.displayName=b.displayName+"WithChunkExtractor"),g),k=e.forwardRef((function(t,r){return e.createElement(C,Object.assign({forwardedRef:r},t))}));return k.displayName="Loadable",k.preload=function(e){h.requireAsync(e)},k.load=function(e){return h.requireAsync(e)},k}return{loadable:m,lazy:function(e,t){return m(e,r({},t,{suspense:!0}))}}}var h=l({defaultResolveComponent:function(e){return e.__esModule?e.default:e.default||e},render:function(t){var r=t.result,n=t.props;return e.createElement(r,n)}}),d=h.loadable,f=h.lazy,p=l({onLoad:function(e,t){e&&t.forwardedRef&&("function"==typeof t.forwardedRef?t.forwardedRef(e):t.forwardedRef.current=e)},render:function(e){var t=e.result,r=e.props;return r.children?r.children(t):null}}),m=p.loadable,y=p.lazy,v=d;v.lib=m;var b=f;b.lib=y;export default v;export{b as lazy};
//# sourceMappingURL=loadable.esm.js.map
