/**
 * Minified by jsDelivr using Terser v5.37.0.
 * Original file: /npm/rrr-lazy@4.1.0/dist/rrr-lazy.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var isDeepEqual=_interopDefault(require("react-fast-compare")),createContext=_interopDefault(require("create-react-context")),React=_interopDefault(require("react")),PropTypes=_interopDefault(require("prop-types")),hoistNonReactStatics=_interopDefault(require("hoist-non-react-statics"));function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _extends(){return _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(this,arguments)}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){_defineProperty(e,t,r[t])}))}return e}function _inheritsLoose(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,o={},s=Object.keys(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var _Lazy$propTypes,_Lazy$defaultProps,_createContext=createContext(),LazyProvider=_createContext.Provider,LazyConsumer=_createContext.Consumer,IntersectionListener=function(){function e(e){var t=this;this.callbacks=new WeakMap,this.observer=new IntersectionObserver((function(e){e.forEach((function(e){var r=t.callbacks.get(e.target);e.target&&r?r(e,t.observer):t.observer.unobserve(e.target)}))}),e)}return e.prototype.listen=function(e,t){var r=this;return this.callbacks.set(e,t),this.observer.observe(e),function(){r.callbacks.delete(e),r.observer.unobserve(e)}},e}(),observerPool=new WeakMap;function createIntersectionListener(e){var t=e.root,r=void 0===t?"undefined"==typeof window?Object:window:t,n=e.rootMargin,o=void 0===n?"":n,s=e.threshold,a=void 0===s?"":s;observerPool.get(r)||observerPool.set(r,{});var i=observerPool.get(r),p=o+"_"+a,u=i[p];return u||(u=new IntersectionListener(e),i[p]=u),u}var Status={Unload:"unload",Loading:"loading",Loaded:"loaded"},VERSION_PROP="@@rrr-lazy/Version",Lazy=function(e){function t(t){var r;(r=e.call(this,t)||this).startListen=r.startListen.bind(_assertThisInitialized(_assertThisInitialized(r))),r.stopListen=r.stopListen.bind(_assertThisInitialized(_assertThisInitialized(r))),r.enterViewport=r.enterViewport.bind(_assertThisInitialized(_assertThisInitialized(r)));var n=t[VERSION_PROP];return r.state={version:n,status:Status.Unload},r}_inheritsLoose(t,e),t.getDerivedStateFromProps=function(e,t){var r=e[VERSION_PROP];return r!==t.version?{version:r,status:Status.Unload}:{}};var r=t.prototype;return r.componentDidMount=function(){this.startListen()},r.shouldComponentUpdate=function(e,t){return!isDeepEqual(this.props,e)||!isDeepEqual(this.state,t)},r.componentDidUpdate=function(e,t){var r=this.state.status,n=this.props.onUnload;r!==t.status&&r===Status.Unload&&(n&&n(),this.startListen())},r.componentWillUnmount=function(){this.stopListen(),this.node&&(this.node=null)},r.startListen=function(){var e=this;this.stopListen();var t=this.props,r=t.root,n=t.rootMargin,o={};r&&(o.root="string"==typeof r?document.querySelector(r):r),n&&(o.rootMargin=n);var s=createIntersectionListener(o);this.node&&!this.unlisten&&(this.unlisten=s.listen(this.node,(function(t){(t.isIntersecting||t.intersectionRatio>0)&&(e.stopListen(),e.enterViewport())})))},r.stopListen=function(){this.unlisten&&(this.unlisten(),this.unlisten=null)},r.enterViewport=function(){var e=this,t=this.state.status,r=this.props,n=r.onLoading,o=r.onLoaded,s=r.onError;return this.node&&t===Status.Unload?Promise.resolve().then((function(){if(!e.node)throw new Error("ABORT");return e.setState({status:Status.Loading}),n?n():null})).then((function(){if(!e.node)throw new Error("ABORT");return e.setState({status:Status.Loaded}),o?o():null})).catch((function(e){if("ABORT"!==e.message){if(s)return s(e);throw e}return null})):null},r.render=function(){var e=this,t=this.props,r=(t.root,t.rootMargin,t.render),n=t.loaderComponent,o=t.loaderProps,s=void 0===o?{}:o,a=(t.onLoaded,t.onLoading,t.onUnload,t.onError,_objectWithoutPropertiesLoose(t,["root","rootMargin","render","loaderComponent","loaderProps","onLoaded","onLoading","onUnload","onError"])),i=this.state.status;return i!==Status.Loaded?React.createElement(n,_objectSpread({},s,{ref:function(t){e.node=t}}),r(i,a)):r(i,a)},t}(React.Component);function LazyWrapper(e){return React.createElement(LazyConsumer,null,(function(t){var r,n=_objectSpread({},e,((r={})[VERSION_PROP]=t,r));return React.createElement(Lazy,n)}))}function interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function noop(){}function Empty(){return null}Lazy.propTypes=((_Lazy$propTypes={})[VERSION_PROP]=PropTypes.any,_Lazy$propTypes.render=PropTypes.func.isRequired,_Lazy$propTypes.root=PropTypes.oneOfType([PropTypes.string].concat("undefined"==typeof HTMLElement?[]:PropTypes.instanceOf(HTMLElement))),_Lazy$propTypes.rootMargin=PropTypes.string,_Lazy$propTypes.loaderComponent=PropTypes.string,_Lazy$propTypes.loaderProps=PropTypes.object,_Lazy$propTypes.onError=PropTypes.func,_Lazy$propTypes.onLoaded=PropTypes.func,_Lazy$propTypes.onLoading=PropTypes.func,_Lazy$propTypes.onUnload=PropTypes.func,_Lazy$propTypes),Lazy.defaultProps=((_Lazy$defaultProps={})[VERSION_PROP]=null,_Lazy$defaultProps.root=null,_Lazy$defaultProps.rootMargin=null,_Lazy$defaultProps.loaderComponent="div",_Lazy$defaultProps.loaderProps=null,_Lazy$defaultProps.onError=null,_Lazy$defaultProps.onLoaded=null,_Lazy$defaultProps.onLoading=null,_Lazy$defaultProps.onUnload=null,_Lazy$defaultProps);var LazyDecorated=function(e){function t(t){var r;return(r=e.call(this,t)||this).handleLoading=r.handleLoading.bind(_assertThisInitialized(_assertThisInitialized(r))),r.renderComponent=r.renderComponent.bind(_assertThisInitialized(_assertThisInitialized(r))),r.state={Component:null},r}_inheritsLoose(t,e);var r=t.prototype;return r.handleLoading=function(){var e=this,t=this.props,r=t.getComponent,n=t.lazyProps.onLoading,o=void 0===n?noop:n;return Promise.resolve().then((function(){return r()})).then((function(t){var r=interopRequireDefault(t).default||Empty;return e.setState({Component:r}),o()}))},r.renderComponent=function(e,t){var r=this.state.Component,n=this.props.lazyProps.render;return"function"==typeof n?n(e,t,r):r&&"loaded"===e?React.createElement(r,t):null},r.render=function(){var e=this.props,t=e.lazyProps,r=e.ownProps;return React.createElement(LazyWrapper,_extends({},r,t,{render:this.renderComponent,onLoading:this.handleLoading}))},t}(React.PureComponent);LazyDecorated.propTypes={getComponent:PropTypes.func.isRequired,lazyProps:PropTypes.object.isRequired,ownProps:PropTypes.object.isRequired};var lazy=function(e){return function(t){var r=e.getComponent,n=_objectWithoutPropertiesLoose(e,["getComponent"]),o=function(e){return React.createElement(LazyDecorated,{getComponent:"function"===r?r:function(){return t},lazyProps:n,ownProps:e})};return o.WrappedComponent=t,hoistNonReactStatics(o,t),o}};exports.Lazy=LazyWrapper,exports.lazy=lazy,exports.LazyProvider=LazyProvider;
//# sourceMappingURL=/sm/7e467325a55481dbf1d346de682040984cded67bd10b8cbde275b0f8e255479e.map