Liferay.Loader.define("commerce-frontend-js@4.0.75/components/infinite_scroller/InfiniteScroller",["module","exports","require","@frontend-taglib-clay$clayui/loading-indicator","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react"],(function(e,r,t){window;{Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=_interopRequireDefault(t("@frontend-taglib-clay$clayui/loading-indicator")),a=(_interopRequireDefault(t("liferay!frontend-js-react-web$prop-types")),function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=_getRequireWildcardCache();if(r&&r.has(e))return r.get(e);var t={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var i=n?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(t,a,i):t[a]=e[a]}t.default=e,r&&r.set(e,t);return t}(t("liferay!frontend-js-react-web$react")));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var i=function InfiniteScroller({children:e,customLoader:r,maxHeight:t,onBottomTouched:i,scrollCompleted:l}){const[o,c]=(0,a.useState)(!1),u=(0,a.useRef)(null),[f,d]=(0,a.useState)(!1),s=(0,a.useRef)(null),p=(0,a.useCallback)((e=>{s.current=e,c(!0)}),[]),y=(0,a.useCallback)((e=>{u.current=e,d(!0)}),[]),b=(0,a.useCallback)((()=>{if(!s.current||!u.current||!IntersectionObserver)return;const e={root:s.current,rootMargin:"0px",threshold:1};new IntersectionObserver((e=>{1===e[0].intersectionRatio&&i()}),e).observe(u.current)}),[i]);return(0,a.useEffect)((()=>{o&&f&&!l&&b()}),[o,f,l,b]),a.default.createElement("div",{className:"inline-scroller",ref:p,style:t?{maxHeight:t}:null},e,!l&&(r?a.default.createElement(r,{ref:y}):a.default.createElement(n.default,{ref:y,small:!0})))};r.default=i}}));
//# sourceMappingURL=InfiniteScroller.js.map