(()=>{function e(t){e.$inject=["$scope","$element"];var a=[250,500,1e3];function n(e){if(e.paging&&(e.paging.next||e.paging.blind))return t("More data may be available.")}return{restrict:"EA",replace:!0,templateUrl:":::PLUGIN_PATH:::/ui/views/loadmore.html",link:function(o,e,t){Object.hasOwn(t,"cheapnextcheck")&&(o.cheapNextCheck=!0),o.hidePageSize=!0,o.getLoadMoreTooltip=_.partial(n,o),t=!_.isUndefined(t.changePageSize),!o.hidePageSize&&t&&(o._pageSizes=_.cloneDeep(a),o.$on("paging.statistics.pageSize",function(e){var e=parseInt(e,10),t=_.cloneDeep(a);e&&(o._pageSizes=_.without(t,e))}))},controller:e};function e(o,t){var a;function n(){var e=jQuery(t),e=_.head(e);a||(e=e.querySelector(".classForObserver"),(a=new IntersectionObserver(i,{root:null,rootMargin:"0px 0px 0px 0px",threshold:1})).observe(e))}function i(e){o.paging&&o.paging.next&&e.forEach(function(e){e.isIntersecting&&o.loadNext()})}o.$watch("paging",function(e){var t;e&&e.next?(t=e.next)===_.noop?o.shouldShowLoadMore=!0:e.noPreFetch?(o.shouldShowLoadMore=!0,n()):o.cheapNextCheck&&e.statistics&&e.statistics.currentPage&&e.statistics.totalPages?(o.shouldShowLoadMore=e.statistics.currentPage<e.statistics.totalPages,o.shouldShowLoadMore&&n()):t().then(function(e){o.shouldShowLoadMore=!_.isEmpty(e),o.shouldShowLoadMore&&n()}):o.shouldShowLoadMore=!1})}}e.$inject=["gettext"],angular.module("c8y.ui").directive("c8yLoadMore",e)})();