Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

virtual-scroller

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

virtual-scroller - npm Package Compare versions

Comparing version 1.7.1 to 1.7.2

2

bundle/virtual-scroller-dom.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).VirtualScroller=t()}(this,function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var t,n=(function(t){(function(){var e,n,i,r,o,s;"undefined"!=typeof performance&&null!==performance&&performance.now?t.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(t.exports=function(){return(e()-o)/1e6},n=process.hrtime,r=(e=function(){var e;return 1e9*(e=n())[0]+e[1]})(),s=1e9*process.uptime(),o=r-s):Date.now?(t.exports=function(){return Date.now()-i},i=Date.now()):(t.exports=function(){return(new Date).getTime()-i},i=(new Date).getTime())}).call(e)}(t={exports:{}},t.exports),t.exports),i="undefined"==typeof window?e:window,r=["moz","webkit"],o="AnimationFrame",s=i["request"+o],a=i["cancel"+o]||i["cancelRequest"+o],l=0;!s&&l<r.length;l++)s=i[r[l]+"Request"+o],a=i[r[l]+"Cancel"+o]||i[r[l]+"CancelRequest"+o];if(!s||!a){var u=0,h=0,d=[];s=function(e){if(0===d.length){var t=n(),i=Math.max(0,1e3/60-(t-u));u=i+t,setTimeout(function(){var e=d.slice(0);d.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(u)}catch(e){setTimeout(function(){throw e},0)}},Math.round(i))}return d.push({handle:++h,callback:e,cancelled:!1}),h},a=function(e){for(var t=0;t<d.length;t++)d[t].handle===e&&(d[t].cancelled=!0)}}var c=function(e){return s.call(i,e)};c.cancel=function(){a.apply(i,arguments)},c.polyfill=function(e){e||(e=i),e.requestAnimationFrame=s,e.cancelAnimationFrame=a};var m=c.cancel;function f(e,t){var n=Date.now(),i=c(function r(){Date.now()-n>=t?e():i=c(r)});return{clear:function(){return m(i)}}}function g(e){e&&e.clear()}function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(e,t){return!t||"object"!==I(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function b(e,t,n){return t&&w(e.prototype,t),n&&w(e,n),e}var C=function(){function e(t){y(this,e),this.element=t}return b(e,[{key:"getScrollY",value:function(){return this.element.scrollTop}},{key:"scrollTo",value:function(e,t){this.element.scrollTo(e,t)}},{key:"getWidth",value:function(){return this.element.offsetWidth}},{key:"getHeight",value:function(){return this.element.offsetHeight}},{key:"getContentHeight",value:function(){return this.element.scrollHeight}},{key:"getTopOffset",value:function(e){var t=this.element.getBoundingClientRect().top,n=this.element.clientTop;return e.getBoundingClientRect().top-t+this.getScrollY()-n}},{key:"addScrollListener",value:function(e){var t=this;return this.element.addEventListener("scroll",e),function(){return t.element.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e){var t,n=this;if("undefined"!=typeof ResizeObserver){var i=new ResizeObserver(function(t){var n=t,i=Array.isArray(n),r=0;for(n=i?n:n[Symbol.iterator]();;){if(i){if(r>=n.length)break;n[r++]}else{if((r=n.next()).done)break;r.value}return e()}});i.observe(this.element),t=function(){return i.unobserve(n.element)}}var r=(new x).onResize(e);return function(){t&&t(),r()}}}]),e}(),x=function(e){function t(){return y(this,t),v(this,p(t).call(this,window))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&S(e,t)}(t,C),b(t,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getContentHeight",value:function(){return document.documentElement.scrollHeight}},{key:"getTopOffset",value:function(e){var t=document.clientTop||document.body.clientTop||0;return e.getBoundingClientRect().top+this.getScrollY()-t}},{key:"onResize",value:function(e){return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}}]),t}();function H(e){return e.toFixed(2)+"px"}var O="It looks like you're using Internet Explorer which doesn't support CSS variables required for a <tbody/> container. VirtualScroller has been switched into \"bypass\" mode (render all items). See: https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1";function k(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function R(){if(A()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,k(["[virtual-scroller]"].concat(n)))}}function M(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i;"undefined"!=typeof window?(R.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw new Error(["[virtual-scroller]"].concat(t).join(" "))},0)):(i=console).error.apply(i,k(["[virtual-scroller]"].concat(t)))}function A(){return"undefined"!=typeof window&&window.VirtualScrollerDebug}function T(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var L=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getContainerElement=t,this.getState=n,this.initialize()}var t,n,i;return t=e,(n=[{key:"initialize",value:function(){this.reset(),this.getState()&&this.initializeFromState(this.getState())}},{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"initializeFromState",value:function(e){for(var t=e.itemHeights,n=0;n<t.length;){if(void 0===t[n]){if(void 0!==this.firstMeasuredItemIndex){this.lastMeasuredItemIndex=n-1;break}}else void 0===this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex=n),this.measuredItemsHeight+=t[n];n++}}},{key:"_measureItemHeight",value:function(e,t){var n=this.getContainerElement();if(n){var i=e-t;if(i>=0&&i<n.childNodes.length)return n.childNodes[i].getBoundingClientRect().height}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(e,t){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(R("Non-measured items gap detected. Reset first and last measured item indexes."),this.reset());for(var n=[],i=this.firstMeasuredItemIndex,r=this.lastMeasuredItemIndex,o=!1,s=e;s<=t;){if(void 0===this._get(s)){n.push(s),R("Item",s,"hasn't been previously measured");var a=this._measureItemHeight(s,e);R("Height",a),this._set(s,a),(void 0===i||s<i)&&(this.measuredItemsHeight+=a,o||(this.firstMeasuredItemIndex=s,o=!0)),(void 0===r||s>r)&&(void 0!==r&&(this.measuredItemsHeight+=a),this.lastMeasuredItemIndex=s)}else{var l=this._get(s),u=this._measureItemHeight(s,e);l!==u&&R("Item",s,"height has changed from",l,"to",u,"while it was shown, and \".onItemHeightChange(i)\" hasn't been called yet. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}s++}return n}},{key:"remeasureItemHeight",value:function(e,t){var n=this._get(e),i=this._measureItemHeight(e,t);return this._set(e,i),this.measuredItemsHeight+=i-n,i}},{key:"getAverage",value:function(){return void 0===this.lastMeasuredItemIndex?0:this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"_get",value:function(e){return this.getState().itemHeights[e]}},{key:"_set",value:function(e,t){this.getState().itemHeights[e]=t}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}])&&T(t.prototype,n),i&&T(t,i),e}();function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var P=Object.prototype.hasOwnProperty;function U(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function B(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){N(e,t,n[t])})}return e}function _(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var V=250,z=100,j=function(){function e(t,n){var i,r,o,s=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),N(this,"updateLayout",function(){return s.onUpdateShownItemIndexes({reason:D.MANUAL})}),N(this,"onScroll",function(){return s.onUpdateShownItemIndexes({reason:D.SCROLL})}),N(this,"restoreScrollPosition",function(){var e=s.getState().scrollY;void 0!==e&&s.scrollTo(0,e)}),N(this,"updateScrollPosition",function(){return s.getState().scrollY=s.getScrollY()}),N(this,"layout",function(){return s.updateLayout()}),N(this,"onResize",(i=function(e){if(s.isRendered){var t=s.shouldUpdateLayoutOnScrollableContainerResize(e);if("UPDATE_LAYOUT"===t){R("~ Scrollable container size changed, re-measure item heights. ~"),s.resized=!0;var n=s.getInitialLayoutState();R("Reset state to",n),s.setState(n)}else"UPDATE_SHOWN_ITEM_INDEXES"===t&&s.onUpdateShownItemIndexes({reason:"resize"})}},r=V,function(){for(var e=this,t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];clearTimeout(o),o=setTimeout(function(){return i.apply(e,n)},r)})),N(this,"willUpdateState",function(e,t){if(t&&s.preserveScrollPositionOnPrependItems){s.preserveScrollPositionOnPrependItems=void 0;var n=t.items,i=e.items,r=s.getItemsDiff(n,i);r&&s.captureScroll(n,i,r.prependedItemsCount)}}),N(this,"didUpdateState",function(e){var t=s.getState();if(s.onStateChange&&(function(e,t){if(U(e,t))return!0;if("object"!==E(e)||null===e||"object"!==E(t)||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!P.call(t,n[r])||!U(e[n[r]],t[n[r]]))return!1;return!0}(t,e)||s.onStateChange(t,e)),e&&s.isRendered){R("~ Rendered ~"),t.firstShownItemIndex===e.firstShownItemIndex&&t.lastShownItemIndex===e.lastShownItemIndex&&t.items===e.items||s.onRendered();var n=e.items,i=t.items;if(i!==n){var r=s.getItemsDiff(n,i);if(r){var o=r.prependedItemsCount;r.appendedItemsCount;o>0&&(s.itemHeights.onPrepend(o),void 0!==s.firstSeenItemIndex&&(s.firstSeenItemIndex+=o,s.lastSeenItemIndex+=o))}else s.itemHeights.initialize(),s.firstSeenItemIndex=void 0,s.lastSeenItemIndex=void 0;return s.updateSeenItemIndexes(),s.multiRenderLayout&&s.stopMultiRenderLayout(),s.onUpdateShownItemIndexes({reason:D.ITEMS_CHANGED})}return s.resized?(s.resized=void 0,R("~ Rendered (resize) ~"),s.multiRenderLayout&&s.stopMultiRenderLayout(),s.onUpdateShownItemIndexes({reason:"resize"})):s.multiRenderLayout?s.onMultiRenderLayoutRendered():void 0}}),N(this,"updateShownItemIndexes",function(){R("~ Layout results "+(s.bypass?"(bypass) ":"")+"~");var e=s.getShownItemIndexes(),t=e.firstShownItemIndex,n=e.lastShownItemIndex,i=e.redoLayoutAfterRender,r=s.getState().itemHeights,o=s.getBeforeItemsHeight(t,n,r),a=s.getAfterItemsHeight(t,n,r);s._getColumnsCount&&R("Columns count",s.getColumnsCount()),R("First shown item index",t),R("Last shown item index",n),R("Before items height",o),R("After items height (actual or estimated)",a),R("Average item height (calculated on previous render)",s.itemHeights.getAverage()),A()&&(R("Item heights",s.getState().itemHeights.slice()),R("Item states",s.getState().itemStates.slice())),i&&(R("Schedule a re-layout after the upcoming rerender"),s.redoLayoutAfterRender=!0),s.validateWillBeHiddenItemHeightsAndState(t,n),void 0!==s.firstSeenItemIndex&&(t>s.lastSeenItemIndex+1||n<s.firstSeenItemIndex-1)&&(s.firstSeenItemIndex=void 0,s.lastSeenItemIndex=void 0),s.onBeforeShowItems(s.getState().items,t,n,s.firstSeenItemIndex,s.lastSeenItemIndex),s.setState({firstShownItemIndex:t,lastShownItemIndex:n,beforeItemsHeight:o,afterItemsHeight:a})}),N(this,"updateShownItemIndexesRecursive",function(){s.multiRenderLayout=!0,s.updateShownItemIndexes()}),N(this,"restoreScroll",function(){var e=s.restoreScrollAfterPrepend,t=e.index,n=e.visibleAreaTop;s.restoreScrollAfterPrepend=void 0;var i=s.getItemElement(t).getBoundingClientRect().top-n;0!==i&&(R("Restore scroll position: scroll by",i),s.scrollTo(0,s.getScrollY()+i))}),N(this,"onUpdateShownItemIndexes",function(e){var t=e.reason;if(0!==s.getItemsCount()&&(!s.multiRenderLayout||t!==D.SCROLL)){if(g(s.onUserStopsScrollingTimeout),t===D.SCROLL){var n=void 0!==s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getScrollY()<s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getState().firstShownItemIndex>0||void 0!==s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getScrollY()+s.scrollableContainer.getHeight()>s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getState().lastShownItemIndex<s.getItemsCount()-1;if(R(n?"The user has scrolled far enough: force re-render":"The user hasn't scrolled too much: delay re-render"),!n)return s.onUserStopsScrollingTimeout=f(s.onUserStoppedScrolling,z)}R("~ Update layout (on ".concat(t,") ~")),s.updateShownItemIndexesRecursive()}}),N(this,"onUserStoppedScrolling",function(){s.isRendered&&s.updateLayout("stopped scrolling")});var l=a.getState,u=a.setState,h=a.onStateChange,d=a.customState,c=a.preserveScrollPositionAtBottomOnMount,m=a.shouldUpdateLayoutOnWindowResize,I=a.measureItemsBatchSize,v=a.getScrollableContainer,p=a.getColumnsCount,S=a.getItemId,y=a.tbody,w=a.bypass,b=a.estimatedItemHeight,H=a.onItemInitialRender,k=a.onItemFirstRender,T=a.scrollableContainer,_=a.preserveScrollPositionOfTheBottomOfTheListOnMount,j=a.state;R("~ Initialize ~"),j&&(n=j.items),!T&&v&&(T=v()),T?this.scrollableContainer=new C(T):"undefined"!=typeof window&&(this.scrollableContainer=new x),y&&(R("~ <tbody/> detected ~"),this.tbody=!0,"undefined"!=typeof window&&window.document.documentMode&&(R("~ <tbody/> not supported ~"),M(O),w=!0)),w&&R('~ "bypass" mode ~'),this.bypass=w,this.isItemEqual=S?function(e,t){return S(e)===S(t)}:function(e,t){return e===t},this.initialItems=n,this.estimatedItemHeight=b,this.onStateChange=h,this._shouldUpdateLayoutOnWindowResize=m,this.measureItemsBatchSize=void 0===I?50:I,this._getColumnsCount=p,H?this.onItemFirstRender=H:k&&(this.onItemFirstRender=function(e){console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=s.getState().items.indexOf(e);t>=0&&k(t)}),u?(this.getState=l,this.setState=function(e){return u(e,{willUpdateState:s.willUpdateState,didUpdateState:s.didUpdateState})}):(this.getState=function(){return s.state},this.setState=function(e){var t=s.getState(),n=B({},t,e);s.willUpdateState(n,t),s.state=n,s.didUpdateState(t)}),j&&R("Initial state (passed)",j),this.getContainerElement=t,t()&&function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}(t()),this.itemHeights=new L(this.getContainerElement,this.getState),this.scrollableContainer&&(c&&(console.warn("[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),_=c),_&&(this.preserveScrollPositionOfTheBottomOfTheListOnMount={scrollableContainerContentHeight:this.scrollableContainer.getContentHeight()})),this.setState(j||this.getInitialState(d)),R("Items count",n.length),b&&R("Estimated item height",b)}var t,n,i;return t=e,(n=[{key:"getInitialState",value:function(e){var t=this.initialItems.length,n=B({},e,this.getInitialLayoutState(),{items:this.initialItems,itemStates:new Array(t)});return R("Initial state (autogenerated)",n),R("First shown item index",n.firstShownItemIndex),R("Last shown item index",n.lastShownItemIndex),n}},{key:"getInitialLayoutState",value:function(){var e,t,n=this.initialItems,i=n.length,r=this._getColumnsCount?this._getColumnsCount(this.scrollableContainer):void 0;return i>0&&(e=0,t=this.getLastShownItemIndex(e,i,r||1)),this.preserveScrollPositionOfTheBottomOfTheListOnMount&&(e=0,t=i-1),this.onBeforeShowItems(n,e,t,this.firstSeenItemIndex,this.lastSeenItemIndex),{itemHeights:new Array(i),columnsCount:r,verticalSpacing:void 0,beforeItemsHeight:0,afterItemsHeight:0,firstShownItemIndex:e,lastShownItemIndex:t,scrollY:void 0}}},{key:"getEstimatedItemHeight",value:function(){return this.itemHeights&&this.itemHeights.getAverage()||this.estimatedItemHeight||0}},{key:"getVerticalSpacing",value:function(){return this.getState()&&this.getState().verticalSpacing||0}},{key:"getColumnsCount",value:function(){return this.getState()&&this.getState().columnsCount||1}},{key:"getEstimatedItemsCount",value:function(e){return this.getEstimatedRowsCount(e)*this.getColumnsCount()}},{key:"getEstimatedRowsCount",value:function(e){return this.getEstimatedItemHeight()?Math.ceil((e+this.getVerticalSpacing())/(this.getEstimatedItemHeight()+this.getVerticalSpacing())):1}},{key:"getEstimatedItemsCountOnScreen",value:function(e){return this.getEstimatedRowsCountOnScreen()*e}},{key:"getEstimatedRowsCountOnScreen",value:function(){return this.scrollableContainer?this.getEstimatedRowsCount(2*this.getMargin()+this.scrollableContainer.getHeight()):1}},{key:"getLastShownItemIndex",value:function(e,t,n){return this.bypass?t-1:Math.min(e+(this.getEstimatedItemsCountOnScreen(n)-1),t-1)}},{key:"getItemsCount",value:function(){return this.getState().items.length}},{key:"getMargin",value:function(){return 1*this.scrollableContainer.getHeight()}},{key:"onBeforeShowItems",value:function(e,t,n,i,r){var o=this.onItemFirstRender;if(o)if(void 0===i)for(var s=t;s<=n;)o(e[s]),s++;else{if(t<i)for(var a=t,l=Math.min(n,i-1),u=a;u<=l;)o(e[u]),u++;if(n>r)for(var h=n,d=Math.max(t,r+1);d<=h;)o(e[d]),d++}}},{key:"updateSeenItemIndexes",value:function(){var e=this.firstSeenItemIndex,t=this.lastSeenItemIndex,n=this.getState(),i=n.firstShownItemIndex,r=n.lastShownItemIndex;void 0===e?(e=i,t=r):(i<e&&(e=i),r>t&&(t=r)),this.firstSeenItemIndex=e,this.lastSeenItemIndex=t}},{key:"onMount",value:function(){console.warn("[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){console.warn("[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"listen",value:function(){if(!1===this.isRendered)throw new Error("[virtual-scroller] Can't restart a `VirtualScroller` after it has been stopped");R("~ Rendered (initial) ~"),this.isRendered=!0,this.onRendered(),this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.restoreScrollPosition(),this.updateScrollPosition(),this.removeScrollPositionListener=this.scrollableContainer.addScrollListener(this.updateScrollPosition),this.bypass||(this.removeScrollListener=this.scrollableContainer.addScrollListener(this.onScroll),this.scrollableContainerUnlistenResize=this.scrollableContainer.onResize(this.onResize)),this.tbody&&function(e){e.classList.add("VirtualScroller");var t=document.getElementById("VirtualScrollerStyle");t||((t=document.createElement("style")).id="VirtualScrollerStyle",t.innerText="\n\t\t\ttbody.VirtualScroller:before {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t\t}\n\t\t\ttbody.VirtualScroller:after {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t\t}\n\t\t".replace(/[\n\t]/g,""),document.head.appendChild(t))}(this.getContainerElement()),this.preserveScrollPositionOfTheBottomOfTheListOnMount?this.scrollTo(0,this.getScrollY()+(this.scrollableContainer.getContentHeight()-this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight)):this.onUpdateShownItemIndexes({reason:D.MOUNT})}},{key:"onRendered",value:function(){if(void 0===this.getState().verticalSpacing){R("~ Measure item vertical spacing ~");var e=this.measureVerticalSpacing();void 0===e?R("Not enough items rendered"):(R("Item vertical spacing",e),this.setState({verticalSpacing:e}))}this.measureNonPreviouslyMeasuredItemHeights(),this.tbody&&this.updateTbodyPadding()}},{key:"scrollTo",value:function(e,t){this.scrollableContainer.scrollTo(e,t)}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}},{key:"getHeight",value:function(){return this.getContainerElement().getBoundingClientRect().height}},{key:"getTopOffset",value:function(){return this.scrollableContainer.getTopOffset(this.getContainerElement())}},{key:"shouldUpdateLayoutOnScrollableContainerResize",value:function(e){if(e&&e.target===window){if(document.fullscreenElement&&this.getContainerElement().contains(document.fullscreenElement))return!1;if(this._shouldUpdateLayoutOnWindowResize&&!1===this._shouldUpdateLayoutOnWindowResize(e))return!1}var t=this.scrollableContainerWidth,n=this.scrollableContainerHeight;return this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.scrollableContainerWidth===t?this.scrollableContainerHeight!==n&&"UPDATE_SHOWN_ITEM_INDEXES":"UPDATE_LAYOUT"}},{key:"onUnmount",value:function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"stop",value:function(){this.isRendered=!1,this.removeScrollPositionListener(),this.bypass||(this.removeScrollListener(),this.scrollableContainerUnlistenResize(),g(this.onUserStopsScrollingTimeout),g(this.watchContainerElementCoordinatesTimer))}},{key:"updateTbodyPadding",value:function(){var e=this.getState(),t=e.beforeItemsHeight,n=e.afterItemsHeight;!function(e,t,n){e.style.setProperty("--VirtualScroller-paddingTop",H(t)),e.style.setProperty("--VirtualScroller-paddingBottom",H(n))}(this.getContainerElement(),t,n)}},{key:"measureVerticalSpacing",value:function(){var e=this.getContainerElement();if(e&&e.childNodes.length>1)for(var t=e.childNodes[0].getBoundingClientRect(),n=t.top,i=t.height,r=1;r<e.childNodes.length;){var o=e.childNodes[r].getBoundingClientRect(),s=o.top,a=o.height;if(s!==n)return s-(n+i);i=Math.max(i,a),r++}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(){var e=this.getState(),t=e.firstShownItemIndex,n=e.lastShownItemIndex;if(void 0!==t){R("~ Measure non-previously-measured items' heights ~");var i=this.itemHeights.measureNonPreviouslyMeasuredItemHeights(t,n);A()&&0===i.length&&R("All shown items have been previously measured")}}},{key:"remeasureItemHeight",value:function(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}},{key:"onItemStateChange",value:function(e,t){A()&&(R("~ Item state changed ~"),R("Item",e),R("Previous state\n"+JSON.stringify(this.getState().itemStates[e],null,2)),R("New state\n"+JSON.stringify(t,null,2))),this.getState().itemStates[e]=t}},{key:"onItemHeightChange",value:function(e){R("~ Re-measure item height ~"),R("Item",e);var t=this.getState().itemHeights[e];if(void 0===t)return M('"onItemHeightChange()" has been called for item '.concat(e,", but that item hasn't been rendered before."));var n=this.remeasureItemHeight(e);if(void 0===n)return R("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.");R("Previous height",t),R("New height",n),t!==n&&(R("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:D.ITEM_HEIGHT_CHANGED}))}},{key:"getItemCoordinates",value:function(e){for(var t=this.getState().itemHeights,n=this.getColumnsCount(),i=this.getTopOffset(),r=Math.floor(e/n),o=0;o<r;){for(var s=0,a=0;a<n;)s=Math.max(s,t[o*n+a]),a++;i+=s,i+=this.getVerticalSpacing(),o++}return{top:i,bottom:i+t[e],height:t[e]}}},{key:"_getVisibleItemIndexes",value:function(e,t,n){for(var i,r,o=0,s=this.getItemsCount(),a=this.getColumnsCount(),l=Math.ceil(s/a),u=0;u<l;){for(var h=s>(u+1)*a?this.getVerticalSpacing():0,d=0,c=0,m=void 0;c<a&&(m=u*a+c)<s;){var f=this.getState().itemHeights[m];if(void 0===f){R("Item index ".concat(m,' lies within the visible area or its "margins", but its height hasn\'t been measured yet. Mark the item as "shown", render the list, measure the item\'s height and redo the layout.')),void 0===i&&(i=u*a);var g=t-(n+o);return{firstNonMeasuredItemIndex:m,firstShownItemIndex:i,lastShownItemIndex:r=Math.min((u+this.getEstimatedRowsCount(g))*a-1,s-1)}}if(d=Math.max(d,f),void 0===i&&n+o+d>e&&(R("First shown row index",u),i=u*a),n+o+d+h>t)return R("Last shown row index",u),void 0!==i&&(r=Math.min((u+1)*a-1,s-1)),{firstShownItemIndex:i,lastShownItemIndex:r};c++}o+=d,o+=h,u++}return void 0!==i&&void 0===r&&R("Last item index (is fully visible)",r=s-1),{firstShownItemIndex:i,lastShownItemIndex:r}}},{key:"getVisibleItemIndexes",value:function(e,t,n){var i=this._getVisibleItemIndexes(e,t,n),r=i.firstNonMeasuredItemIndex,o=i.firstShownItemIndex,s=i.lastShownItemIndex,a=void 0!==r;if(this.restoreScrollAfterPrepend&&(s<this.restoreScrollAfterPrepend.index&&(s=this.restoreScrollAfterPrepend.index),a=!1),a&&this.measureItemsBatchSize){var l=this.getColumnsCount(),u=r+this.measureItemsBatchSize-1;s=Math.min(s,Math.ceil(u/l)*l-1)}return{firstShownItemIndex:o,lastShownItemIndex:s,redoLayoutAfterRender:a}}},{key:"getOffscreenListShownItemIndexes",value:function(){return{firstShownItemIndex:0,lastShownItemIndex:0,redoLayoutAfterRender:void 0===this.getState().itemHeights[0]}}},{key:"getItemIndexes",value:function(e,t,n,i){if(n+i>e&&n<t){var r=this.getVisibleItemIndexes(e,t,n);if(void 0!==r.firstShownItemIndex)return r;R("The entire list is off-screen. No items are visible.")}else R("The entire list is off-screen. No items are visible.")}},{key:"getBeforeItemsHeight",value:function(e,t,n){for(var i=this.getColumnsCount(),r=Math.floor(e/i),o=0,s=0;s<r;){for(var a=0,l=0;l<i;)a=Math.max(a,n[s*i+l]||this.itemHeights.getAverage()),l++;o+=a,o+=this.getVerticalSpacing(),s++}return o}},{key:"getAfterItemsHeight",value:function(e,t,n){for(var i=this.getItemsCount(),r=this.getColumnsCount(),o=Math.ceil(i/r),s=0,a=Math.floor(t/r)+1;a<o;){for(var l=0,u=0,h=void 0;u<r&&(h=a*r+u)<i;)l=Math.max(l,n[h]||this.itemHeights.getAverage()),u++;s+=this.getVerticalSpacing(),s+=l,a++}return s}},{key:"validateWillBeHiddenItemHeightsAndState",value:function(e,t){for(var n=this.getState().firstShownItemIndex;n<=this.getState().lastShownItemIndex;){if(n>=e&&n<=t);else{var i=this.getState().itemHeights[n],r=this.remeasureItemHeight(n);r!==i&&R("Item",n,"will be unmounted at next render. Its height has changed from",i,"to",r,"while it was shown. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}n++}}},{key:"watchContainerElementCoordinates",value:function(){var e=this,t=Date.now();!function n(){e.isRendered&&(void 0!==e.topOffset&&e.getTopOffset()!==e.topOffset&&e.onUpdateShownItemIndexes({reason:"top offset change"}),Date.now()-t<3e3&&(e.watchContainerElementCoordinatesTimer=f(n,500)))}()}},{key:"getShownItemIndexes",value:function(){if(this.bypass)return{firstShownItemIndex:0,lastShownItemIndex:this.getItemsCount()-1};var e=this.getTopOffset();void 0===this.topOffset&&this.watchContainerElementCoordinates(),this.topOffset=e;var t=this.getVisibleAreaBounds(),n=t.top,i=t.bottom;return this.latestLayoutVisibleAreaTopAfterIncludingMargin=n-this.getMargin(),this.latestLayoutVisibleAreaBottomAfterIncludingMargin=i+this.getMargin(),this.getItemIndexes(n-this.getMargin(),i+this.getMargin(),e,this.getHeight())||this.getOffscreenListShownItemIndexes()}},{key:"onMultiRenderLayoutRendered",value:function(){var e=this;if(this.redoLayoutAfterRender)return this.redoLayoutAfterRender=void 0,f(function(){e.isRendered&&e.updateShownItemIndexesRecursive()},0);this.stopMultiRenderLayout()}},{key:"stopMultiRenderLayout",value:function(){this.multiRenderLayout=void 0,this.redoLayoutAfterRender||this.restoreScrollAfterPrepend&&this.restoreScroll()}},{key:"captureScroll",value:function(e,t,n){0!==e.length&&0!==n&&(this.getState().firstShownItemIndex>0||this.restoreScrollAfterPrepend&&this.restoreScrollAfterPrepend.previousItems===e&&this.restoreScrollAfterPrepend.nextItems===t||(this.restoreScrollAfterPrepend={previousItems:e,nextItems:t,index:n,visibleAreaTop:this.getItemElement(0).getBoundingClientRect().top}))}},{key:"updateItems",value:function(e,t){return this.setItems(e,t)}},{key:"setItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getState().items,i=this.getState(),r=i.firstShownItemIndex,o=i.lastShownItemIndex,s=i.beforeItemsHeight,a=i.afterItemsHeight,l=i.itemStates,u=i.itemHeights,h=this.firstSeenItemIndex,d=this.lastSeenItemIndex;R("~ Update items ~");var c=this.getItemsDiff(n,e);if(c){var m=c.prependedItemsCount,f=c.appendedItemsCount;m>0&&(R("Prepend",m,"items"),u=new Array(m).concat(u),l&&(l=new Array(m).concat(l))),f>0&&(R("Append",f,"items"),u=u.concat(new Array(f)),l&&(l=l.concat(new Array(f)))),r+=m,o+=m,void 0!==h&&(h+=m,d+=m);this.getVerticalSpacing();var g=this.getColumnsCount();if(m%g==0){var I=m/g,v=Math.ceil(f/g);s+=I*(this.itemHeights.getAverage()+this.getVerticalSpacing()),a+=v*(this.getVerticalSpacing()+this.itemHeights.getAverage())}else s=this.getBeforeItemsHeight(r,o,u),a=this.getAfterItemsHeight(r,o,u)}else R("Items have changed, and it's not a simple append and/or prepend: rerender the entire list from scratch."),R("Previous items",n),R("New items",e),h=void 0,d=void 0,u=new Array(e.length),l=new Array(e.length),0===e.length?(r=void 0,o=void 0):(r=0,o=this.getLastShownItemIndex(r,e.length,this.getColumnsCount())),s=0,a=0;R("First shown item index",r),R("Last shown item index",o),R("Before items height",s),R("After items height (actual or estimated)",a),this.onBeforeShowItems(e,r,o,h,d),this.preserveScrollPositionOnPrependItems=t.preserveScrollPositionOnPrependItems||t.preserveScrollPosition,this.setState({items:e,itemStates:l,itemHeights:u,firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:s,afterItemsHeight:a})}},{key:"getItemsDiff",value:function(e,t){return function(e,t,n){var i=-1,r=-1;e.length>0&&(i=function(e,t,n){var i=0;for(;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n))>=0&&function(e,t,n,i){var r=0;for(;r<e.length;){if(t.length<=n+r||!i(t[n+r],e[r]))return!1;r++}return!0}(e,t,i,n)&&(r=i+e.length-1);if(i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(e,t,this.isItemEqual)}},{key:"getItemElement",value:function(e){return this.getContainerElement().childNodes[e]}}])&&_(t.prototype,n),i&&_(t,i),e}();var D={SCROLL:"scroll",MANUAL:"manual",ITEM_HEIGHT_CHANGED:"item height changed",ITEMS_CHANGED:"items changed",MOUNT:"mount"};function Y(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function W(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function F(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return function(){function e(t,n,i){var r=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),F(this,"onStateChange",function(e,t){var n=e.items,i=e.firstShownItemIndex,o=e.lastShownItemIndex,s=e.beforeItemsHeight,a=e.afterItemsHeight;R("~ On state change ~"),R("Previous state",t),R("New state",e),r.tbody||(r.container.style.paddingTop=H(s),r.container.style.paddingBottom=H(a));var l=t&&n===t.items&&n.length>0;if(l){R("Incremental rerender");for(var u=t.lastShownItemIndex;u>=t.firstShownItemIndex;)u>=i&&u<=o||(R("Remove item index",u),r.unmountItem(r.container.childNodes[u-t.firstShownItemIndex])),u--}else for(R("Rerender from scratch");r.container.firstChild;)r.unmountItem(r.container.firstChild);for(var h=l,d=h&&r.container.firstChild,c=i;c<=o;){if(l&&c>=t.firstShownItemIndex&&c<=t.lastShownItemIndex)h&&(h=!1);else{var m=r.renderItem(n[c]);h?(R("Prepend item index",c),r.container.insertBefore(m,d)):(R("Append item index",c),r.container.appendChild(m))}c++}}),F(this,"onUnmount",function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),F(this,"destroy",function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),F(this,"stop",function(){r.virtualScroller.stop()}),this.container=t,this.renderItem=i;var s=o.onMount,a=o.onItemUnmount,l=Y(o,["onMount","onItemUnmount"]);this.onItemUnmount=a,this.tbody="TBODY"===this.container.tagName,this.virtualScroller=new j(function(){return r.container},n,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){F(e,t,n[t])})}return e}({},l,{tbody:this.tbody,onStateChange:this.onStateChange})),s&&s(),this.virtualScroller.listen()}var t,n,i;return t=e,(n=[{key:"unmountItem",value:function(e){this.container.removeChild(e),this.onItemUnmount&&this.onItemUnmount(e)}},{key:"onItemHeightChange",value:function(e){this.virtualScroller.onItemHeightChange(e)}},{key:"updateItems",value:function(e,t){this.setItems(e,t)}},{key:"setItems",value:function(e,t){this.virtualScroller.setItems(e,t)}},{key:"getItemCoordinates",value:function(e){return this.virtualScroller.getItemCoordinates(e)}}])&&W(t.prototype,n),i&&W(t,i),e}()});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).VirtualScroller=t()}(this,function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var t,n=(function(t){(function(){var e,n,i,r,o,s;"undefined"!=typeof performance&&null!==performance&&performance.now?t.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(t.exports=function(){return(e()-o)/1e6},n=process.hrtime,r=(e=function(){var e;return 1e9*(e=n())[0]+e[1]})(),s=1e9*process.uptime(),o=r-s):Date.now?(t.exports=function(){return Date.now()-i},i=Date.now()):(t.exports=function(){return(new Date).getTime()-i},i=(new Date).getTime())}).call(e)}(t={exports:{}},t.exports),t.exports),i="undefined"==typeof window?e:window,r=["moz","webkit"],o="AnimationFrame",s=i["request"+o],a=i["cancel"+o]||i["cancelRequest"+o],l=0;!s&&l<r.length;l++)s=i[r[l]+"Request"+o],a=i[r[l]+"Cancel"+o]||i[r[l]+"CancelRequest"+o];if(!s||!a){var u=0,h=0,c=[];s=function(e){if(0===c.length){var t=n(),i=Math.max(0,1e3/60-(t-u));u=i+t,setTimeout(function(){var e=c.slice(0);c.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(u)}catch(e){setTimeout(function(){throw e},0)}},Math.round(i))}return c.push({handle:++h,callback:e,cancelled:!1}),h},a=function(e){for(var t=0;t<c.length;t++)c[t].handle===e&&(c[t].cancelled=!0)}}var d=function(e){return s.call(i,e)};d.cancel=function(){a.apply(i,arguments)},d.polyfill=function(e){e||(e=i),e.requestAnimationFrame=s,e.cancelAnimationFrame=a};var m=d.cancel;function f(e,t){var n=Date.now(),i=d(function r(){Date.now()-n>=t?e():i=d(r)});return{clear:function(){return m(i)}}}function g(e){e&&e.clear()}function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(e,t){return!t||"object"!==I(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function b(e,t,n){return t&&w(e.prototype,t),n&&w(e,n),e}var C=function(){function e(t){y(this,e),this.element=t}return b(e,[{key:"getScrollY",value:function(){return this.element.scrollTop}},{key:"scrollTo",value:function(e,t){this.element.scrollTo(e,t)}},{key:"getWidth",value:function(){return this.element.offsetWidth}},{key:"getHeight",value:function(){return this.element.offsetHeight}},{key:"getContentHeight",value:function(){return this.element.scrollHeight}},{key:"getTopOffset",value:function(e){var t=this.element.getBoundingClientRect().top,n=this.element.clientTop;return e.getBoundingClientRect().top-t+this.getScrollY()-n}},{key:"addScrollListener",value:function(e){var t=this;return this.element.addEventListener("scroll",e),function(){return t.element.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e){var t,n=this;if("undefined"!=typeof ResizeObserver){var i=new ResizeObserver(function(t){var n=t,i=Array.isArray(n),r=0;for(n=i?n:n[Symbol.iterator]();;){if(i){if(r>=n.length)break;n[r++]}else{if((r=n.next()).done)break;r.value}return e()}});i.observe(this.element),t=function(){return i.unobserve(n.element)}}var r=(new x).onResize(e);return function(){t&&t(),r()}}}]),e}(),x=function(e){function t(){return y(this,t),v(this,p(t).call(this,window))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&S(e,t)}(t,C),b(t,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getContentHeight",value:function(){return document.documentElement.scrollHeight}},{key:"getTopOffset",value:function(e){var t=document.clientTop||document.body.clientTop||0;return e.getBoundingClientRect().top+this.getScrollY()-t}},{key:"onResize",value:function(e){return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}}]),t}();function H(e){return e.toFixed(2)+"px"}var O="It looks like you're using Internet Explorer which doesn't support CSS variables required for a <tbody/> container. VirtualScroller has been switched into \"bypass\" mode (render all items). See: https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1";function T(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function R(){if(E()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,T(["[virtual-scroller]"].concat(n)))}}function k(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i;"undefined"!=typeof window?(R.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw new Error(["[virtual-scroller]"].concat(t).join(" "))},0)):(i=console).error.apply(i,T(["[virtual-scroller]"].concat(t)))}function E(){return"undefined"!=typeof window&&window.VirtualScrollerDebug}function A(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var M=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getContainerElement=t,this.getState=n,this.initialize()}var t,n,i;return t=e,(n=[{key:"initialize",value:function(){this.reset(),this.getState()&&this.initializeFromState(this.getState())}},{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"initializeFromState",value:function(e){for(var t=e.itemHeights,n=0;n<t.length;){if(void 0===t[n]){if(void 0!==this.firstMeasuredItemIndex){this.lastMeasuredItemIndex=n-1;break}}else void 0===this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex=n),this.measuredItemsHeight+=t[n];n++}}},{key:"_measureItemHeight",value:function(e,t){var n=this.getContainerElement();if(n){var i=e-t;if(i>=0&&i<n.childNodes.length)return n.childNodes[i].getBoundingClientRect().height}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(e,t){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(R("Non-measured items gap detected. Reset first and last measured item indexes."),this.reset());for(var n=[],i=this.firstMeasuredItemIndex,r=this.lastMeasuredItemIndex,o=!1,s=e;s<=t;){if(void 0===this._get(s)){n.push(s),R("Item",s,"hasn't been previously measured");var a=this._measureItemHeight(s,e);R("Height",a),this._set(s,a),(void 0===i||s<i)&&(this.measuredItemsHeight+=a,o||(this.firstMeasuredItemIndex=s,o=!0)),(void 0===r||s>r)&&(void 0!==r&&(this.measuredItemsHeight+=a),this.lastMeasuredItemIndex=s)}else{var l=this._get(s),u=this._measureItemHeight(s,e);l!==u&&R("Item",s,"height has changed from",l,"to",u,"while it was shown, and \".onItemHeightChange(i)\" hasn't been called yet. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}s++}return n}},{key:"remeasureItemHeight",value:function(e,t){var n=this._get(e),i=this._measureItemHeight(e,t);return this._set(e,i),this.measuredItemsHeight+=i-n,i}},{key:"getAverage",value:function(){return void 0===this.lastMeasuredItemIndex?0:this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"_get",value:function(e){return this.getState().itemHeights[e]}},{key:"_set",value:function(e,t){this.getState().itemHeights[e]=t}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}])&&A(t.prototype,n),i&&A(t,i),e}();function L(e){return(L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var P=Object.prototype.hasOwnProperty;function _(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){B(e,t,n[t])})}return e}function V(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function B(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var N=250,j=100,D=function(){function e(t,n){var i,r,o,s=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),B(this,"updateLayout",function(){return s.onUpdateShownItemIndexes({reason:z.MANUAL})}),B(this,"onScroll",function(){return s.onUpdateShownItemIndexes({reason:z.SCROLL})}),B(this,"restoreScrollPositionFromState",function(){var e=s.getState().scrollY;void 0!==e&&s.scrollTo(0,e)}),B(this,"updateScrollPosition",function(){return s.getState().scrollY=s.getScrollY()}),B(this,"layout",function(){return s.updateLayout()}),B(this,"onResize",(i=function(e){if(s.isRendered){var t=s.shouldUpdateLayoutOnScrollableContainerResize(e);if("UPDATE_LAYOUT"===t){R("~ Scrollable container size changed, re-measure item heights. ~"),s.redoLayoutReason=z.RESIZE;var n=s.getInitialLayoutState();R("Reset state to",n),s.setState(n)}else"UPDATE_SHOWN_ITEM_INDEXES"===t&&s.onUpdateShownItemIndexes({reason:z.RESIZE})}},r=N,function(){for(var e=this,t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];clearTimeout(o),o=setTimeout(function(){return i.apply(e,n)},r)})),B(this,"willUpdateState",function(e,t){}),B(this,"didUpdateState",function(e){var t=s.getState();if(s.onStateChange&&(function(e,t){if(_(e,t))return!0;if("object"!==L(e)||null===e||"object"!==L(t)||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!P.call(t,n[r])||!_(e[n[r]],t[n[r]]))return!1;return!0}(t,e)||s.onStateChange(t,e)),e&&s.isRendered){R("~ Rendered ~");var n=s.redoLayoutReason;s.redoLayoutReason=void 0;var i=e.items,r=t.items;if(r!==i){var o=!0,a=s.getItemsDiff(i,r);if(a){var l=a.prependedItemsCount;a.appendedItemsCount;l>0&&(s.itemHeights.onPrepend(l),s.restoreScrollAfterRenderValues&&(o=!1,s.restoreScrollAfterRender()))}else s.itemHeights.initialize();o&&(n=z.ITEMS_CHANGED)}return t.firstShownItemIndex===e.firstShownItemIndex&&t.lastShownItemIndex===e.lastShownItemIndex&&t.items===e.items||s.onRendered(),n?s.redoLayoutRightAfterRender({reason:n}):void 0}}),B(this,"updateShownItemIndexes",function(){R("~ Layout results "+(s.bypass?"(bypass) ":"")+"~");var e=s.getShownItemIndexes(),t=e.firstShownItemIndex,n=e.lastShownItemIndex,i=e.redoLayoutAfterMeasuringItemHeights,r=s.getState().itemHeights,o=s.getBeforeItemsHeight(t,n,r),a=s.getAfterItemsHeight(t,n,r);s._getColumnsCount&&R("Columns count",s.getColumnsCount()),R("First shown item index",t),R("Last shown item index",n),R("Before items height",o),R("After items height (actual or estimated)",a),R("Average item height (calculated on previous render)",s.itemHeights.getAverage()),E()&&(R("Item heights",s.getState().itemHeights.slice()),R("Item states",s.getState().itemStates.slice())),i&&(s.redoLayoutReason=z.ITEM_HEIGHT_NOT_MEASURED),s.validateWillBeHiddenItemHeightsAndState(t,n),s.onBeforeShowItems(s.getState().items,s.getState().itemHeights,t,n),s.setState({firstShownItemIndex:t,lastShownItemIndex:n,beforeItemsHeight:o,afterItemsHeight:a})}),B(this,"updateShownItemIndexesRecursive",function(){s.layoutInProgress=!0,s.updateShownItemIndexes()}),B(this,"onUpdateShownItemIndexes",function(e){var t=e.reason;if(0!==s.getItemsCount()){if(s.onUserStopsScrollingTimer&&(g(s.onUserStopsScrollingTimer),s.onUserStopsScrollingTimer=void 0),t===z.SCROLL){var n=void 0!==s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getScrollY()<s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getState().firstShownItemIndex>0||void 0!==s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getScrollY()+s.scrollableContainer.getHeight()>s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getState().lastShownItemIndex<s.getItemsCount()-1;if(R(n?"The user has scrolled far enough: force re-render":"The user hasn't scrolled too much: delay re-render"),!n){if(s.layoutTimer)return;return void(s.onUserStopsScrollingTimer=f(function(){s.isRendered&&s.onUpdateShownItemIndexes({reason:z.STOPPED_SCROLLING})},j))}}s.layoutTimer&&(g(s.layoutTimer),s.layoutTimer=void 0),R("~ Calculate Layout (on ".concat(t,") ~")),s.updateShownItemIndexesRecursive()}});var l=a.getState,u=a.setState,h=a.onStateChange,c=a.customState,d=a.preserveScrollPositionAtBottomOnMount,m=a.shouldUpdateLayoutOnWindowResize,I=a.measureItemsBatchSize,v=a.getScrollableContainer,p=a.getColumnsCount,S=a.getItemId,y=a.tbody,w=a._useTimeoutInRenderLoop,b=a.bypass,H=a.estimatedItemHeight,T=a.onItemInitialRender,A=a.onItemFirstRender,V=a.scrollableContainer,D=a.preserveScrollPositionOfTheBottomOfTheListOnMount,Y=a.state;R("~ Initialize ~"),Y&&(n=Y.items),!V&&v&&(V=v()),V?this.scrollableContainer=new C(V):"undefined"!=typeof window&&(this.scrollableContainer=new x),y&&(R("~ <tbody/> detected ~"),this.tbody=!0,"undefined"!=typeof window&&window.document.documentMode&&(R("~ <tbody/> not supported ~"),k(O),b=!0)),b&&R('~ "bypass" mode ~'),this.bypass=b,this._useTimeoutInRenderLoop=w,this.isItemEqual=S?function(e,t){return S(e)===S(t)}:function(e,t){return e===t},this.initialItems=n,this.estimatedItemHeight=H,this.onStateChange=h,this._shouldUpdateLayoutOnWindowResize=m,this.measureItemsBatchSize=void 0===I?50:I,this._getColumnsCount=p,T?this.onItemInitialRender=T:A&&(this.onItemInitialRender=function(e){console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=s.getState().items.indexOf(e);t>=0&&A(t)}),R("Items count",n.length),H&&R("Estimated item height",H),u?(this.getState=l,this.setState=function(e){R("Set state",e),u(e,{willUpdateState:s.willUpdateState,didUpdateState:s.didUpdateState})}):(this.getState=function(){return s.state},this.setState=function(e){R("Set state",e);var t=s.getState(),n=U({},t,e);s.willUpdateState(n,t),s.state=n,s.didUpdateState(t)}),Y&&R("Initial state (passed)",Y),this.getContainerElement=t,t()&&function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}(t()),this.itemHeights=new M(this.getContainerElement,this.getState),this.scrollableContainer&&(d&&(console.warn("[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),D=d),D&&(this.preserveScrollPositionOfTheBottomOfTheListOnMount={scrollableContainerContentHeight:this.scrollableContainer.getContentHeight()})),this.setState(Y||this.getInitialState(c))}var t,n,i;return t=e,(n=[{key:"getInitialState",value:function(e){var t=this.initialItems.length,n=U({},e,this.getInitialLayoutState(),{items:this.initialItems,itemStates:new Array(t)});return R("Initial state (autogenerated)",n),R("First shown item index",n.firstShownItemIndex),R("Last shown item index",n.lastShownItemIndex),n}},{key:"getInitialLayoutState",value:function(){var e,t,n=this.initialItems,i=n.length,r=this._getColumnsCount?this._getColumnsCount(this.scrollableContainer):void 0;i>0&&(e=0,t=this.getLastShownItemIndex(e,i,r||1)),this.preserveScrollPositionOfTheBottomOfTheListOnMount&&(e=0,t=i-1);var o=new Array(i);return this.onBeforeShowItems(n,o,e,t),{itemHeights:o,columnsCount:r,verticalSpacing:void 0,beforeItemsHeight:0,afterItemsHeight:0,firstShownItemIndex:e,lastShownItemIndex:t,scrollY:void 0}}},{key:"getEstimatedItemHeight",value:function(){return this.itemHeights&&this.itemHeights.getAverage()||this.estimatedItemHeight||0}},{key:"getVerticalSpacing",value:function(){return this.getState()&&this.getState().verticalSpacing||0}},{key:"getColumnsCount",value:function(){return this.getState()&&this.getState().columnsCount||1}},{key:"getEstimatedItemsCount",value:function(e){return this.getEstimatedRowsCount(e)*this.getColumnsCount()}},{key:"getEstimatedRowsCount",value:function(e){return this.getEstimatedItemHeight()?Math.ceil((e+this.getVerticalSpacing())/(this.getEstimatedItemHeight()+this.getVerticalSpacing())):1}},{key:"getEstimatedItemsCountOnScreen",value:function(e){return this.getEstimatedRowsCountOnScreen()*e}},{key:"getEstimatedRowsCountOnScreen",value:function(){return this.scrollableContainer?this.getEstimatedRowsCount(2*this.getMargin()+this.scrollableContainer.getHeight()):1}},{key:"getLastShownItemIndex",value:function(e,t,n){return this.bypass?t-1:Math.min(e+(this.getEstimatedItemsCountOnScreen(n)-1),t-1)}},{key:"getItemsCount",value:function(){return this.getState().items.length}},{key:"getMargin",value:function(){return 1*this.scrollableContainer.getHeight()}},{key:"onBeforeShowItems",value:function(e,t,n,i){if(this.onItemInitialRender)for(var r=n;r<=i;)void 0===t[r]&&this.onItemInitialRender(e[r]),r++}},{key:"onMount",value:function(){console.warn("[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){console.warn("[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"listen",value:function(){if(!1===this.isRendered)throw new Error("[virtual-scroller] Can't restart a `VirtualScroller` after it has been stopped");R("~ Rendered (initial) ~"),this.isRendered=!0,this.onRendered(),this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.restoreScrollPositionFromState(),this.updateScrollPosition(),this.removeScrollPositionListener=this.scrollableContainer.addScrollListener(this.updateScrollPosition),this.bypass||(this.removeScrollListener=this.scrollableContainer.addScrollListener(this.onScroll),this.scrollableContainerUnlistenResize=this.scrollableContainer.onResize(this.onResize)),this.tbody&&function(e){e.classList.add("VirtualScroller");var t=document.getElementById("VirtualScrollerStyle");t||((t=document.createElement("style")).id="VirtualScrollerStyle",t.innerText="\n\t\t\ttbody.VirtualScroller:before {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t\t}\n\t\t\ttbody.VirtualScroller:after {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t\t}\n\t\t".replace(/[\n\t]/g,""),document.head.appendChild(t))}(this.getContainerElement()),this.preserveScrollPositionOfTheBottomOfTheListOnMount?this.scrollTo(0,this.getScrollY()+(this.scrollableContainer.getContentHeight()-this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight)):this.onUpdateShownItemIndexes({reason:z.MOUNT})}},{key:"onRendered",value:function(){this.measureVerticalSpacing(),this.measureNonPreviouslyMeasuredItemHeights(),this.tbody&&this.updateTbodyPadding()}},{key:"scrollTo",value:function(e,t){this.scrollableContainer.scrollTo(e,t)}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}},{key:"getHeight",value:function(){return this.getContainerElement().getBoundingClientRect().height}},{key:"getTopOffset",value:function(){return this.scrollableContainer.getTopOffset(this.getContainerElement())}},{key:"shouldUpdateLayoutOnScrollableContainerResize",value:function(e){if(e&&e.target===window){if(document.fullscreenElement&&this.getContainerElement().contains(document.fullscreenElement))return!1;if(this._shouldUpdateLayoutOnWindowResize&&!1===this._shouldUpdateLayoutOnWindowResize(e))return!1}var t=this.scrollableContainerWidth,n=this.scrollableContainerHeight;return this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.scrollableContainerWidth===t?this.scrollableContainerHeight!==n&&"UPDATE_SHOWN_ITEM_INDEXES":"UPDATE_LAYOUT"}},{key:"onUnmount",value:function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"stop",value:function(){this.isRendered=!1,this.removeScrollPositionListener(),this.bypass||(this.removeScrollListener(),this.scrollableContainerUnlistenResize(),g(this.onUserStopsScrollingTimer),g(this.watchContainerElementCoordinatesTimer),g(this.layoutTimer))}},{key:"redoLayoutRightAfterRender",value:function(e){var t=this,n=e.reason;this._useTimeoutInRenderLoop?(this.layoutTimer&&g(this.layoutTimer),this.layoutTimer=f(function(){t.layoutTimer=void 0,t.onUpdateShownItemIndexes({reason:n})},0)):this.onUpdateShownItemIndexes({reason:n})}},{key:"updateTbodyPadding",value:function(){var e=this.getState(),t=e.beforeItemsHeight,n=e.afterItemsHeight;!function(e,t,n){e.style.setProperty("--VirtualScroller-paddingTop",H(t)),e.style.setProperty("--VirtualScroller-paddingBottom",H(n))}(this.getContainerElement(),t,n)}},{key:"measureVerticalSpacing",value:function(){if(void 0===this.getState().verticalSpacing){R("~ Measure item vertical spacing ~");var e=this.measureVerticalSpacingValue();void 0===e?R("Not enough items rendered to measure vertical spacing"):(R("Item vertical spacing",e),this.setState({verticalSpacing:e}))}}},{key:"measureVerticalSpacingValue",value:function(){var e=this.getContainerElement();if(e&&e.childNodes.length>1)for(var t=e.childNodes[0].getBoundingClientRect(),n=t.top,i=t.height,r=1;r<e.childNodes.length;){var o=e.childNodes[r].getBoundingClientRect(),s=o.top,a=o.height;if(s!==n)return s-(n+i);i=Math.max(i,a),r++}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(){var e=this.getState(),t=e.firstShownItemIndex,n=e.lastShownItemIndex;if(void 0!==t)this.itemHeights.measureNonPreviouslyMeasuredItemHeights(t,n)}},{key:"remeasureItemHeight",value:function(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}},{key:"onItemStateChange",value:function(e,t){E()&&(R("~ Item state changed ~"),R("Item",e),R("Previous state\n"+JSON.stringify(this.getState().itemStates[e],null,2)),R("New state\n"+JSON.stringify(t,null,2))),this.getState().itemStates[e]=t}},{key:"onItemHeightChange",value:function(e){R("~ Re-measure item height ~"),R("Item",e);var t=this.getState().itemHeights[e];if(void 0===t)return k('"onItemHeightChange()" has been called for item '.concat(e,", but that item hasn't been rendered before."));var n=this.remeasureItemHeight(e);if(void 0===n)return R("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.");R("Previous height",t),R("New height",n),t!==n&&(R("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:z.ITEM_HEIGHT_CHANGED}))}},{key:"getItemCoordinates",value:function(e){for(var t=this.getState().itemHeights,n=this.getColumnsCount(),i=this.getTopOffset(),r=Math.floor(e/n),o=0;o<r;){for(var s=0,a=0;a<n;)s=Math.max(s,t[o*n+a]),a++;i+=s,i+=this.getVerticalSpacing(),o++}return{top:i,bottom:i+t[e],height:t[e]}}},{key:"_getVisibleItemIndexes",value:function(e,t,n){for(var i,r,o=0,s=this.getItemsCount(),a=this.getColumnsCount(),l=Math.ceil(s/a),u=0;u<l;){for(var h=s>(u+1)*a?this.getVerticalSpacing():0,c=0,d=0,m=void 0;d<a&&(m=u*a+d)<s;){var f=this.getState().itemHeights[m];if(void 0===f){R("Item index ".concat(m,' lies within the visible area or its "margins", but its height hasn\'t been measured yet. Mark the item as "shown", render the list, measure the item\'s height and redo the layout.')),void 0===i&&(i=u*a);var g=t-(n+o);return{firstNonMeasuredItemIndex:m,firstShownItemIndex:i,lastShownItemIndex:r=Math.min((u+this.getEstimatedRowsCount(g))*a-1,s-1)}}if(c=Math.max(c,f),void 0===i&&n+o+c>e&&(R("First shown row index",u),i=u*a),n+o+c+h>t)return R("Last shown row index",u),void 0!==i&&(r=Math.min((u+1)*a-1,s-1)),{firstShownItemIndex:i,lastShownItemIndex:r};d++}o+=c,o+=h,u++}return void 0!==i&&void 0===r&&R("Last item index (is fully visible)",r=s-1),{firstShownItemIndex:i,lastShownItemIndex:r}}},{key:"getVisibleItemIndexes",value:function(e,t,n){var i=this._getVisibleItemIndexes(e,t,n),r=i.firstNonMeasuredItemIndex,o=i.firstShownItemIndex,s=i.lastShownItemIndex,a=void 0!==r;if(this.restoreScrollAfterRenderValues&&(s<this.restoreScrollAfterRenderValues.index&&(s=this.restoreScrollAfterRenderValues.index),a=!1),a&&this.measureItemsBatchSize){var l=this.getColumnsCount(),u=r+this.measureItemsBatchSize-1;s=Math.min(s,Math.ceil(u/l)*l-1)}return{firstShownItemIndex:o,lastShownItemIndex:s,redoLayoutAfterMeasuringItemHeights:a}}},{key:"getOffscreenListShownItemIndexes",value:function(){return{firstShownItemIndex:0,lastShownItemIndex:0,redoLayoutAfterMeasuringItemHeights:void 0===this.getState().itemHeights[0]}}},{key:"getItemIndexes",value:function(e,t,n,i){if(n+i>e&&n<t){var r=this.getVisibleItemIndexes(e,t,n);if(void 0!==r.firstShownItemIndex)return r;R("The entire list is off-screen. No items are visible.")}else R("The entire list is off-screen. No items are visible.")}},{key:"getBeforeItemsHeight",value:function(e,t,n){for(var i=this.getColumnsCount(),r=Math.floor(e/i),o=0,s=0;s<r;){for(var a=0,l=0;l<i;)a=Math.max(a,n[s*i+l]||this.itemHeights.getAverage()),l++;o+=a,o+=this.getVerticalSpacing(),s++}return o}},{key:"getAfterItemsHeight",value:function(e,t,n){for(var i=this.getItemsCount(),r=this.getColumnsCount(),o=Math.ceil(i/r),s=0,a=Math.floor(t/r)+1;a<o;){for(var l=0,u=0,h=void 0;u<r&&(h=a*r+u)<i;)l=Math.max(l,n[h]||this.itemHeights.getAverage()),u++;s+=this.getVerticalSpacing(),s+=l,a++}return s}},{key:"validateWillBeHiddenItemHeightsAndState",value:function(e,t){for(var n=this.getState().firstShownItemIndex;n<=this.getState().lastShownItemIndex;){if(n>=e&&n<=t);else{var i=this.getState().itemHeights[n],r=this.remeasureItemHeight(n);r!==i&&R("Item",n,"will be unmounted at next render. Its height has changed from",i,"to",r,"while it was shown. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}n++}}},{key:"watchContainerElementCoordinates",value:function(){var e=this,t=Date.now();!function n(){e.isRendered&&(void 0!==e.topOffset&&e.getTopOffset()!==e.topOffset&&e.onUpdateShownItemIndexes({reason:z.TOP_OFFSET_CHANGED}),Date.now()-t<3e3&&(e.watchContainerElementCoordinatesTimer=f(n,500)))}()}},{key:"getShownItemIndexes",value:function(){if(this.bypass)return{firstShownItemIndex:0,lastShownItemIndex:this.getItemsCount()-1};var e=this.getTopOffset();void 0===this.topOffset&&this.watchContainerElementCoordinates(),this.topOffset=e;var t=this.getVisibleAreaBounds(),n=t.top,i=t.bottom;return this.latestLayoutVisibleAreaTopAfterIncludingMargin=n-this.getMargin(),this.latestLayoutVisibleAreaBottomAfterIncludingMargin=i+this.getMargin(),this.getItemIndexes(n-this.getMargin(),i+this.getMargin(),e,this.getHeight())||this.getOffscreenListShownItemIndexes()}},{key:"captureScroll",value:function(e,t,n){if(0!==e.length&&0!==n){var i=this.getState().firstShownItemIndex,r=this.getItemElement(0).getBoundingClientRect().top;if(i>0){var o=this.getState(),s=(o.verticalSpacing,o.itemHeights);r=this.getItemElement(0).getBoundingClientRect().top;for(var a=i-1;a>=0;)r+=s[a]+this.getVerticalSpacing(),a--}this.restoreScrollAfterRenderValues&&this.restoreScrollAfterRenderValues.previousItems===e&&this.restoreScrollAfterRenderValues.nextItems===t||(this.restoreScrollAfterRenderValues={previousItems:e,nextItems:t,index:n,visibleAreaTop:r})}}},{key:"restoreScrollAfterRender",value:function(){R("~ Restore Scroll Position ~");var e=this.restoreScrollAfterRenderValues,t=e.index,n=e.visibleAreaTop;this.restoreScrollAfterRenderValues=void 0;var i=this.getItemElement(t).getBoundingClientRect().top-n;0===i?R("Scroll position hasn't changed"):(R("Scroll down by",i),this.scrollTo(0,this.getScrollY()+i))}},{key:"updateItems",value:function(e,t){return this.setItems(e,t)}},{key:"setItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getState().items,i=this.getState(),r=i.firstShownItemIndex,o=i.lastShownItemIndex,s=i.beforeItemsHeight,a=i.afterItemsHeight,l=i.itemStates,u=i.itemHeights;R("~ Update items ~");var h=this.getItemsDiff(n,e);if(h){var c=h.prependedItemsCount,d=h.appendedItemsCount;c>0&&(R("Prepend",c,"items"),u=new Array(c).concat(u),l&&(l=new Array(c).concat(l))),d>0&&(R("Append",d,"items"),u=u.concat(new Array(d)),l&&(l=l.concat(new Array(d)))),r+=c,o+=c;this.getVerticalSpacing();var m=this.getColumnsCount();if(c%m==0){var f=c/m,g=Math.ceil(d/m);s+=f*(this.itemHeights.getAverage()+this.getVerticalSpacing()),a+=g*(this.getVerticalSpacing()+this.itemHeights.getAverage())}else s=this.getBeforeItemsHeight(r,o,u),a=this.getAfterItemsHeight(r,o,u);c>0&&(t.preserveScrollPositionOnPrependItems||t.preserveScrollPosition)&&(r=0,s=0,this.captureScroll(n,e,c))}else R("Items have changed, and it's not a simple append and/or prepend: rerender the entire list from scratch."),R("Previous items",n),R("New items",e),u=new Array(e.length),l=new Array(e.length),0===e.length?(r=void 0,o=void 0):(r=0,o=this.getLastShownItemIndex(r,e.length,this.getColumnsCount())),s=0,a=0;R("~ Update state ~"),R("First shown item index",r),R("Last shown item index",o),R("Before items height",s),R("After items height (actual or estimated)",a),this.onBeforeShowItems(e,u,r,o),this.setState({items:e,itemStates:l,itemHeights:u,firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:s,afterItemsHeight:a})}},{key:"getItemsDiff",value:function(e,t){return function(e,t,n){var i=-1,r=-1;e.length>0&&(i=function(e,t,n){var i=0;for(;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n))>=0&&function(e,t,n,i){var r=0;for(;r<e.length;){if(t.length<=n+r||!i(t[n+r],e[r]))return!1;r++}return!0}(e,t,i,n)&&(r=i+e.length-1);if(i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(e,t,this.isItemEqual)}},{key:"getItemElement",value:function(e){return this.getContainerElement().childNodes[e]}}])&&V(t.prototype,n),i&&V(t,i),e}();var z={SCROLL:"scroll",STOPPED_SCROLLING:"stopped scrolling",MANUAL:"manual",MOUNT:"mount",ITEM_HEIGHT_NOT_MEASURED:"some item height wasn't measured",RESIZE:"resize",ITEM_HEIGHT_CHANGED:"item height changed",ITEMS_CHANGED:"items changed",TOP_OFFSET_CHANGED:"top offset changed"};function Y(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function F(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function W(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return function(){function e(t,n,i){var r=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),W(this,"onStateChange",function(e,t){var n=e.items,i=e.firstShownItemIndex,o=e.lastShownItemIndex,s=e.beforeItemsHeight,a=e.afterItemsHeight;R("~ On state change ~"),R("Previous state",t),R("New state",e),r.tbody||(r.container.style.paddingTop=H(s),r.container.style.paddingBottom=H(a));var l=t&&n===t.items&&n.length>0;if(l){R("Incremental rerender");for(var u=t.lastShownItemIndex;u>=t.firstShownItemIndex;)u>=i&&u<=o||(R("Remove item index",u),r.unmountItem(r.container.childNodes[u-t.firstShownItemIndex])),u--}else for(R("Rerender from scratch");r.container.firstChild;)r.unmountItem(r.container.firstChild);for(var h=l,c=h&&r.container.firstChild,d=i;d<=o;){if(l&&d>=t.firstShownItemIndex&&d<=t.lastShownItemIndex)h&&(h=!1);else{var m=r.renderItem(n[d]);h?(R("Prepend item index",d),r.container.insertBefore(m,c)):(R("Append item index",d),r.container.appendChild(m))}d++}}),W(this,"onUnmount",function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),W(this,"destroy",function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),W(this,"stop",function(){r.virtualScroller.stop()}),this.container=t,this.renderItem=i;var s=o.onMount,a=o.onItemUnmount,l=Y(o,["onMount","onItemUnmount"]);this.onItemUnmount=a,this.tbody="TBODY"===this.container.tagName,this.virtualScroller=new D(function(){return r.container},n,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){W(e,t,n[t])})}return e}({},l,{tbody:this.tbody,onStateChange:this.onStateChange})),s&&s(),this.virtualScroller.listen()}var t,n,i;return t=e,(n=[{key:"unmountItem",value:function(e){this.container.removeChild(e),this.onItemUnmount&&this.onItemUnmount(e)}},{key:"onItemHeightChange",value:function(e){this.virtualScroller.onItemHeightChange(e)}},{key:"updateItems",value:function(e,t){this.setItems(e,t)}},{key:"setItems",value:function(e,t){this.virtualScroller.setItems(e,t)}},{key:"getItemCoordinates",value:function(e){return this.virtualScroller.getItemCoordinates(e)}}])&&F(t.prototype,n),i&&F(t,i),e}()});
//# sourceMappingURL=virtual-scroller-dom.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):(e=e||self).VirtualScroller=t(e.React,e.PropTypes)}(this,function(e,t){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,t=t&&t.hasOwnProperty("default")?t.default:t;var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var i,r=(function(e){(function(){var t,n,i,r,o,s;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(e.exports=function(){return(t()-o)/1e6},n=process.hrtime,r=(t=function(){var e;return 1e9*(e=n())[0]+e[1]})(),s=1e9*process.uptime(),o=r-s):Date.now?(e.exports=function(){return Date.now()-i},i=Date.now()):(e.exports=function(){return(new Date).getTime()-i},i=(new Date).getTime())}).call(n)}(i={exports:{}},i.exports),i.exports),o="undefined"==typeof window?n:window,s=["moz","webkit"],a="AnimationFrame",l=o["request"+a],u=o["cancel"+a]||o["cancelRequest"+a],h=0;!l&&h<s.length;h++)l=o[s[h]+"Request"+a],u=o[s[h]+"Cancel"+a]||o[s[h]+"CancelRequest"+a];if(!l||!u){var d=0,c=0,m=[];l=function(e){if(0===m.length){var t=r(),n=Math.max(0,1e3/60-(t-d));d=n+t,setTimeout(function(){var e=m.slice(0);m.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(d)}catch(e){setTimeout(function(){throw e},0)}},Math.round(n))}return m.push({handle:++c,callback:e,cancelled:!1}),c},u=function(e){for(var t=0;t<m.length;t++)m[t].handle===e&&(m[t].cancelled=!0)}}var f=function(e){return l.call(o,e)};f.cancel=function(){u.apply(o,arguments)},f.polyfill=function(e){e||(e=o),e.requestAnimationFrame=l,e.cancelAnimationFrame=u};var g=f.cancel;function p(e,t){var n=Date.now(),i=f(function r(){Date.now()-n>=t?e():i=f(r)});return{clear:function(){return g(i)}}}function I(e){e&&e.clear()}function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function S(e,t){return!t||"object"!==v(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function C(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function x(e,t,n){return t&&C(e.prototype,t),n&&C(e,n),e}var O=function(){function e(t){w(this,e),this.element=t}return x(e,[{key:"getScrollY",value:function(){return this.element.scrollTop}},{key:"scrollTo",value:function(e,t){this.element.scrollTo(e,t)}},{key:"getWidth",value:function(){return this.element.offsetWidth}},{key:"getHeight",value:function(){return this.element.offsetHeight}},{key:"getContentHeight",value:function(){return this.element.scrollHeight}},{key:"getTopOffset",value:function(e){var t=this.element.getBoundingClientRect().top,n=this.element.clientTop;return e.getBoundingClientRect().top-t+this.getScrollY()-n}},{key:"addScrollListener",value:function(e){var t=this;return this.element.addEventListener("scroll",e),function(){return t.element.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e){var t,n=this;if("undefined"!=typeof ResizeObserver){var i=new ResizeObserver(function(t){var n=t,i=Array.isArray(n),r=0;for(n=i?n:n[Symbol.iterator]();;){if(i){if(r>=n.length)break;n[r++]}else{if((r=n.next()).done)break;r.value}return e()}});i.observe(this.element),t=function(){return i.unobserve(n.element)}}var r=(new R).onResize(e);return function(){t&&t(),r()}}}]),e}(),R=function(e){function t(){return w(this,t),S(this,y(t).call(this,window))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}(t,O),x(t,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getContentHeight",value:function(){return document.documentElement.scrollHeight}},{key:"getTopOffset",value:function(e){var t=document.clientTop||document.body.clientTop||0;return e.getBoundingClientRect().top+this.getScrollY()-t}},{key:"onResize",value:function(e){return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}}]),t}();function H(e){return e.toFixed(2)+"px"}var P="It looks like you're using Internet Explorer which doesn't support CSS variables required for a <tbody/> container. VirtualScroller has been switched into \"bypass\" mode (render all items). See: https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1";function k(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function M(){if(A()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,k(["[virtual-scroller]"].concat(n)))}}function T(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i;"undefined"!=typeof window?(M.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw new Error(["[virtual-scroller]"].concat(t).join(" "))},0)):(i=console).error.apply(i,k(["[virtual-scroller]"].concat(t)))}function A(){return"undefined"!=typeof window&&window.VirtualScrollerDebug}function L(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var E=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getContainerElement=t,this.getState=n,this.initialize()}var t,n,i;return t=e,(n=[{key:"initialize",value:function(){this.reset(),this.getState()&&this.initializeFromState(this.getState())}},{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"initializeFromState",value:function(e){for(var t=e.itemHeights,n=0;n<t.length;){if(void 0===t[n]){if(void 0!==this.firstMeasuredItemIndex){this.lastMeasuredItemIndex=n-1;break}}else void 0===this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex=n),this.measuredItemsHeight+=t[n];n++}}},{key:"_measureItemHeight",value:function(e,t){var n=this.getContainerElement();if(n){var i=e-t;if(i>=0&&i<n.childNodes.length)return n.childNodes[i].getBoundingClientRect().height}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(e,t){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(M("Non-measured items gap detected. Reset first and last measured item indexes."),this.reset());for(var n=[],i=this.firstMeasuredItemIndex,r=this.lastMeasuredItemIndex,o=!1,s=e;s<=t;){if(void 0===this._get(s)){n.push(s),M("Item",s,"hasn't been previously measured");var a=this._measureItemHeight(s,e);M("Height",a),this._set(s,a),(void 0===i||s<i)&&(this.measuredItemsHeight+=a,o||(this.firstMeasuredItemIndex=s,o=!0)),(void 0===r||s>r)&&(void 0!==r&&(this.measuredItemsHeight+=a),this.lastMeasuredItemIndex=s)}else{var l=this._get(s),u=this._measureItemHeight(s,e);l!==u&&M("Item",s,"height has changed from",l,"to",u,"while it was shown, and \".onItemHeightChange(i)\" hasn't been called yet. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}s++}return n}},{key:"remeasureItemHeight",value:function(e,t){var n=this._get(e),i=this._measureItemHeight(e,t);return this._set(e,i),this.measuredItemsHeight+=i-n,i}},{key:"getAverage",value:function(){return void 0===this.lastMeasuredItemIndex?0:this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"_get",value:function(e){return this.getState().itemHeights[e]}},{key:"_set",value:function(e,t){this.getState().itemHeights[e]=t}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}])&&L(t.prototype,n),i&&L(t,i),e}();function U(e){return(U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var B=Object.prototype.hasOwnProperty;function _(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function z(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){V(e,t,n[t])})}return e}function j(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function V(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var N=250,W=100,D=function(){function e(t,n){var i,r,o,s=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),V(this,"updateLayout",function(){return s.onUpdateShownItemIndexes({reason:F.MANUAL})}),V(this,"onScroll",function(){return s.onUpdateShownItemIndexes({reason:F.SCROLL})}),V(this,"restoreScrollPosition",function(){var e=s.getState().scrollY;void 0!==e&&s.scrollTo(0,e)}),V(this,"updateScrollPosition",function(){return s.getState().scrollY=s.getScrollY()}),V(this,"layout",function(){return s.updateLayout()}),V(this,"onResize",(i=function(e){if(s.isRendered){var t=s.shouldUpdateLayoutOnScrollableContainerResize(e);if("UPDATE_LAYOUT"===t){M("~ Scrollable container size changed, re-measure item heights. ~"),s.resized=!0;var n=s.getInitialLayoutState();M("Reset state to",n),s.setState(n)}else"UPDATE_SHOWN_ITEM_INDEXES"===t&&s.onUpdateShownItemIndexes({reason:"resize"})}},r=N,function(){for(var e=this,t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];clearTimeout(o),o=setTimeout(function(){return i.apply(e,n)},r)})),V(this,"willUpdateState",function(e,t){if(t&&s.preserveScrollPositionOnPrependItems){s.preserveScrollPositionOnPrependItems=void 0;var n=t.items,i=e.items,r=s.getItemsDiff(n,i);r&&s.captureScroll(n,i,r.prependedItemsCount)}}),V(this,"didUpdateState",function(e){var t=s.getState();if(s.onStateChange&&(function(e,t){if(_(e,t))return!0;if("object"!==U(e)||null===e||"object"!==U(t)||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!B.call(t,n[r])||!_(e[n[r]],t[n[r]]))return!1;return!0}(t,e)||s.onStateChange(t,e)),e&&s.isRendered){M("~ Rendered ~"),t.firstShownItemIndex===e.firstShownItemIndex&&t.lastShownItemIndex===e.lastShownItemIndex&&t.items===e.items||s.onRendered();var n=e.items,i=t.items;if(i!==n){var r=s.getItemsDiff(n,i);if(r){var o=r.prependedItemsCount;r.appendedItemsCount;o>0&&(s.itemHeights.onPrepend(o),void 0!==s.firstSeenItemIndex&&(s.firstSeenItemIndex+=o,s.lastSeenItemIndex+=o))}else s.itemHeights.initialize(),s.firstSeenItemIndex=void 0,s.lastSeenItemIndex=void 0;return s.updateSeenItemIndexes(),s.multiRenderLayout&&s.stopMultiRenderLayout(),s.onUpdateShownItemIndexes({reason:F.ITEMS_CHANGED})}return s.resized?(s.resized=void 0,M("~ Rendered (resize) ~"),s.multiRenderLayout&&s.stopMultiRenderLayout(),s.onUpdateShownItemIndexes({reason:"resize"})):s.multiRenderLayout?s.onMultiRenderLayoutRendered():void 0}}),V(this,"updateShownItemIndexes",function(){M("~ Layout results "+(s.bypass?"(bypass) ":"")+"~");var e=s.getShownItemIndexes(),t=e.firstShownItemIndex,n=e.lastShownItemIndex,i=e.redoLayoutAfterRender,r=s.getState().itemHeights,o=s.getBeforeItemsHeight(t,n,r),a=s.getAfterItemsHeight(t,n,r);s._getColumnsCount&&M("Columns count",s.getColumnsCount()),M("First shown item index",t),M("Last shown item index",n),M("Before items height",o),M("After items height (actual or estimated)",a),M("Average item height (calculated on previous render)",s.itemHeights.getAverage()),A()&&(M("Item heights",s.getState().itemHeights.slice()),M("Item states",s.getState().itemStates.slice())),i&&(M("Schedule a re-layout after the upcoming rerender"),s.redoLayoutAfterRender=!0),s.validateWillBeHiddenItemHeightsAndState(t,n),void 0!==s.firstSeenItemIndex&&(t>s.lastSeenItemIndex+1||n<s.firstSeenItemIndex-1)&&(s.firstSeenItemIndex=void 0,s.lastSeenItemIndex=void 0),s.onBeforeShowItems(s.getState().items,t,n,s.firstSeenItemIndex,s.lastSeenItemIndex),s.setState({firstShownItemIndex:t,lastShownItemIndex:n,beforeItemsHeight:o,afterItemsHeight:a})}),V(this,"updateShownItemIndexesRecursive",function(){s.multiRenderLayout=!0,s.updateShownItemIndexes()}),V(this,"restoreScroll",function(){var e=s.restoreScrollAfterPrepend,t=e.index,n=e.visibleAreaTop;s.restoreScrollAfterPrepend=void 0;var i=s.getItemElement(t).getBoundingClientRect().top-n;0!==i&&(M("Restore scroll position: scroll by",i),s.scrollTo(0,s.getScrollY()+i))}),V(this,"onUpdateShownItemIndexes",function(e){var t=e.reason;if(0!==s.getItemsCount()&&(!s.multiRenderLayout||t!==F.SCROLL)){if(I(s.onUserStopsScrollingTimeout),t===F.SCROLL){var n=void 0!==s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getScrollY()<s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getState().firstShownItemIndex>0||void 0!==s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getScrollY()+s.scrollableContainer.getHeight()>s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getState().lastShownItemIndex<s.getItemsCount()-1;if(M(n?"The user has scrolled far enough: force re-render":"The user hasn't scrolled too much: delay re-render"),!n)return s.onUserStopsScrollingTimeout=p(s.onUserStoppedScrolling,W)}M("~ Update layout (on ".concat(t,") ~")),s.updateShownItemIndexesRecursive()}}),V(this,"onUserStoppedScrolling",function(){s.isRendered&&s.updateLayout("stopped scrolling")});var l=a.getState,u=a.setState,h=a.onStateChange,d=a.customState,c=a.preserveScrollPositionAtBottomOnMount,m=a.shouldUpdateLayoutOnWindowResize,f=a.measureItemsBatchSize,g=a.getScrollableContainer,v=a.getColumnsCount,S=a.getItemId,y=a.tbody,b=a.bypass,w=a.estimatedItemHeight,C=a.onItemInitialRender,x=a.onItemFirstRender,H=a.scrollableContainer,k=a.preserveScrollPositionOfTheBottomOfTheListOnMount,L=a.state;M("~ Initialize ~"),L&&(n=L.items),!H&&g&&(H=g()),H?this.scrollableContainer=new O(H):"undefined"!=typeof window&&(this.scrollableContainer=new R),y&&(M("~ <tbody/> detected ~"),this.tbody=!0,"undefined"!=typeof window&&window.document.documentMode&&(M("~ <tbody/> not supported ~"),T(P),b=!0)),b&&M('~ "bypass" mode ~'),this.bypass=b,this.isItemEqual=S?function(e,t){return S(e)===S(t)}:function(e,t){return e===t},this.initialItems=n,this.estimatedItemHeight=w,this.onStateChange=h,this._shouldUpdateLayoutOnWindowResize=m,this.measureItemsBatchSize=void 0===f?50:f,this._getColumnsCount=v,C?this.onItemFirstRender=C:x&&(this.onItemFirstRender=function(e){console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=s.getState().items.indexOf(e);t>=0&&x(t)}),u?(this.getState=l,this.setState=function(e){return u(e,{willUpdateState:s.willUpdateState,didUpdateState:s.didUpdateState})}):(this.getState=function(){return s.state},this.setState=function(e){var t=s.getState(),n=z({},t,e);s.willUpdateState(n,t),s.state=n,s.didUpdateState(t)}),L&&M("Initial state (passed)",L),this.getContainerElement=t,t()&&function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}(t()),this.itemHeights=new E(this.getContainerElement,this.getState),this.scrollableContainer&&(c&&(console.warn("[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),k=c),k&&(this.preserveScrollPositionOfTheBottomOfTheListOnMount={scrollableContainerContentHeight:this.scrollableContainer.getContentHeight()})),this.setState(L||this.getInitialState(d)),M("Items count",n.length),w&&M("Estimated item height",w)}var t,n,i;return t=e,(n=[{key:"getInitialState",value:function(e){var t=this.initialItems.length,n=z({},e,this.getInitialLayoutState(),{items:this.initialItems,itemStates:new Array(t)});return M("Initial state (autogenerated)",n),M("First shown item index",n.firstShownItemIndex),M("Last shown item index",n.lastShownItemIndex),n}},{key:"getInitialLayoutState",value:function(){var e,t,n=this.initialItems,i=n.length,r=this._getColumnsCount?this._getColumnsCount(this.scrollableContainer):void 0;return i>0&&(e=0,t=this.getLastShownItemIndex(e,i,r||1)),this.preserveScrollPositionOfTheBottomOfTheListOnMount&&(e=0,t=i-1),this.onBeforeShowItems(n,e,t,this.firstSeenItemIndex,this.lastSeenItemIndex),{itemHeights:new Array(i),columnsCount:r,verticalSpacing:void 0,beforeItemsHeight:0,afterItemsHeight:0,firstShownItemIndex:e,lastShownItemIndex:t,scrollY:void 0}}},{key:"getEstimatedItemHeight",value:function(){return this.itemHeights&&this.itemHeights.getAverage()||this.estimatedItemHeight||0}},{key:"getVerticalSpacing",value:function(){return this.getState()&&this.getState().verticalSpacing||0}},{key:"getColumnsCount",value:function(){return this.getState()&&this.getState().columnsCount||1}},{key:"getEstimatedItemsCount",value:function(e){return this.getEstimatedRowsCount(e)*this.getColumnsCount()}},{key:"getEstimatedRowsCount",value:function(e){return this.getEstimatedItemHeight()?Math.ceil((e+this.getVerticalSpacing())/(this.getEstimatedItemHeight()+this.getVerticalSpacing())):1}},{key:"getEstimatedItemsCountOnScreen",value:function(e){return this.getEstimatedRowsCountOnScreen()*e}},{key:"getEstimatedRowsCountOnScreen",value:function(){return this.scrollableContainer?this.getEstimatedRowsCount(2*this.getMargin()+this.scrollableContainer.getHeight()):1}},{key:"getLastShownItemIndex",value:function(e,t,n){return this.bypass?t-1:Math.min(e+(this.getEstimatedItemsCountOnScreen(n)-1),t-1)}},{key:"getItemsCount",value:function(){return this.getState().items.length}},{key:"getMargin",value:function(){return 1*this.scrollableContainer.getHeight()}},{key:"onBeforeShowItems",value:function(e,t,n,i,r){var o=this.onItemFirstRender;if(o)if(void 0===i)for(var s=t;s<=n;)o(e[s]),s++;else{if(t<i)for(var a=t,l=Math.min(n,i-1),u=a;u<=l;)o(e[u]),u++;if(n>r)for(var h=n,d=Math.max(t,r+1);d<=h;)o(e[d]),d++}}},{key:"updateSeenItemIndexes",value:function(){var e=this.firstSeenItemIndex,t=this.lastSeenItemIndex,n=this.getState(),i=n.firstShownItemIndex,r=n.lastShownItemIndex;void 0===e?(e=i,t=r):(i<e&&(e=i),r>t&&(t=r)),this.firstSeenItemIndex=e,this.lastSeenItemIndex=t}},{key:"onMount",value:function(){console.warn("[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){console.warn("[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"listen",value:function(){if(!1===this.isRendered)throw new Error("[virtual-scroller] Can't restart a `VirtualScroller` after it has been stopped");M("~ Rendered (initial) ~"),this.isRendered=!0,this.onRendered(),this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.restoreScrollPosition(),this.updateScrollPosition(),this.removeScrollPositionListener=this.scrollableContainer.addScrollListener(this.updateScrollPosition),this.bypass||(this.removeScrollListener=this.scrollableContainer.addScrollListener(this.onScroll),this.scrollableContainerUnlistenResize=this.scrollableContainer.onResize(this.onResize)),this.tbody&&function(e){e.classList.add("VirtualScroller");var t=document.getElementById("VirtualScrollerStyle");t||((t=document.createElement("style")).id="VirtualScrollerStyle",t.innerText="\n\t\t\ttbody.VirtualScroller:before {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t\t}\n\t\t\ttbody.VirtualScroller:after {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t\t}\n\t\t".replace(/[\n\t]/g,""),document.head.appendChild(t))}(this.getContainerElement()),this.preserveScrollPositionOfTheBottomOfTheListOnMount?this.scrollTo(0,this.getScrollY()+(this.scrollableContainer.getContentHeight()-this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight)):this.onUpdateShownItemIndexes({reason:F.MOUNT})}},{key:"onRendered",value:function(){if(void 0===this.getState().verticalSpacing){M("~ Measure item vertical spacing ~");var e=this.measureVerticalSpacing();void 0===e?M("Not enough items rendered"):(M("Item vertical spacing",e),this.setState({verticalSpacing:e}))}this.measureNonPreviouslyMeasuredItemHeights(),this.tbody&&this.updateTbodyPadding()}},{key:"scrollTo",value:function(e,t){this.scrollableContainer.scrollTo(e,t)}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}},{key:"getHeight",value:function(){return this.getContainerElement().getBoundingClientRect().height}},{key:"getTopOffset",value:function(){return this.scrollableContainer.getTopOffset(this.getContainerElement())}},{key:"shouldUpdateLayoutOnScrollableContainerResize",value:function(e){if(e&&e.target===window){if(document.fullscreenElement&&this.getContainerElement().contains(document.fullscreenElement))return!1;if(this._shouldUpdateLayoutOnWindowResize&&!1===this._shouldUpdateLayoutOnWindowResize(e))return!1}var t=this.scrollableContainerWidth,n=this.scrollableContainerHeight;return this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.scrollableContainerWidth===t?this.scrollableContainerHeight!==n&&"UPDATE_SHOWN_ITEM_INDEXES":"UPDATE_LAYOUT"}},{key:"onUnmount",value:function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"stop",value:function(){this.isRendered=!1,this.removeScrollPositionListener(),this.bypass||(this.removeScrollListener(),this.scrollableContainerUnlistenResize(),I(this.onUserStopsScrollingTimeout),I(this.watchContainerElementCoordinatesTimer))}},{key:"updateTbodyPadding",value:function(){var e=this.getState(),t=e.beforeItemsHeight,n=e.afterItemsHeight;!function(e,t,n){e.style.setProperty("--VirtualScroller-paddingTop",H(t)),e.style.setProperty("--VirtualScroller-paddingBottom",H(n))}(this.getContainerElement(),t,n)}},{key:"measureVerticalSpacing",value:function(){var e=this.getContainerElement();if(e&&e.childNodes.length>1)for(var t=e.childNodes[0].getBoundingClientRect(),n=t.top,i=t.height,r=1;r<e.childNodes.length;){var o=e.childNodes[r].getBoundingClientRect(),s=o.top,a=o.height;if(s!==n)return s-(n+i);i=Math.max(i,a),r++}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(){var e=this.getState(),t=e.firstShownItemIndex,n=e.lastShownItemIndex;if(void 0!==t){M("~ Measure non-previously-measured items' heights ~");var i=this.itemHeights.measureNonPreviouslyMeasuredItemHeights(t,n);A()&&0===i.length&&M("All shown items have been previously measured")}}},{key:"remeasureItemHeight",value:function(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}},{key:"onItemStateChange",value:function(e,t){A()&&(M("~ Item state changed ~"),M("Item",e),M("Previous state\n"+JSON.stringify(this.getState().itemStates[e],null,2)),M("New state\n"+JSON.stringify(t,null,2))),this.getState().itemStates[e]=t}},{key:"onItemHeightChange",value:function(e){M("~ Re-measure item height ~"),M("Item",e);var t=this.getState().itemHeights[e];if(void 0===t)return T('"onItemHeightChange()" has been called for item '.concat(e,", but that item hasn't been rendered before."));var n=this.remeasureItemHeight(e);if(void 0===n)return M("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.");M("Previous height",t),M("New height",n),t!==n&&(M("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:F.ITEM_HEIGHT_CHANGED}))}},{key:"getItemCoordinates",value:function(e){for(var t=this.getState().itemHeights,n=this.getColumnsCount(),i=this.getTopOffset(),r=Math.floor(e/n),o=0;o<r;){for(var s=0,a=0;a<n;)s=Math.max(s,t[o*n+a]),a++;i+=s,i+=this.getVerticalSpacing(),o++}return{top:i,bottom:i+t[e],height:t[e]}}},{key:"_getVisibleItemIndexes",value:function(e,t,n){for(var i,r,o=0,s=this.getItemsCount(),a=this.getColumnsCount(),l=Math.ceil(s/a),u=0;u<l;){for(var h=s>(u+1)*a?this.getVerticalSpacing():0,d=0,c=0,m=void 0;c<a&&(m=u*a+c)<s;){var f=this.getState().itemHeights[m];if(void 0===f){M("Item index ".concat(m,' lies within the visible area or its "margins", but its height hasn\'t been measured yet. Mark the item as "shown", render the list, measure the item\'s height and redo the layout.')),void 0===i&&(i=u*a);var g=t-(n+o);return{firstNonMeasuredItemIndex:m,firstShownItemIndex:i,lastShownItemIndex:r=Math.min((u+this.getEstimatedRowsCount(g))*a-1,s-1)}}if(d=Math.max(d,f),void 0===i&&n+o+d>e&&(M("First shown row index",u),i=u*a),n+o+d+h>t)return M("Last shown row index",u),void 0!==i&&(r=Math.min((u+1)*a-1,s-1)),{firstShownItemIndex:i,lastShownItemIndex:r};c++}o+=d,o+=h,u++}return void 0!==i&&void 0===r&&M("Last item index (is fully visible)",r=s-1),{firstShownItemIndex:i,lastShownItemIndex:r}}},{key:"getVisibleItemIndexes",value:function(e,t,n){var i=this._getVisibleItemIndexes(e,t,n),r=i.firstNonMeasuredItemIndex,o=i.firstShownItemIndex,s=i.lastShownItemIndex,a=void 0!==r;if(this.restoreScrollAfterPrepend&&(s<this.restoreScrollAfterPrepend.index&&(s=this.restoreScrollAfterPrepend.index),a=!1),a&&this.measureItemsBatchSize){var l=this.getColumnsCount(),u=r+this.measureItemsBatchSize-1;s=Math.min(s,Math.ceil(u/l)*l-1)}return{firstShownItemIndex:o,lastShownItemIndex:s,redoLayoutAfterRender:a}}},{key:"getOffscreenListShownItemIndexes",value:function(){return{firstShownItemIndex:0,lastShownItemIndex:0,redoLayoutAfterRender:void 0===this.getState().itemHeights[0]}}},{key:"getItemIndexes",value:function(e,t,n,i){if(n+i>e&&n<t){var r=this.getVisibleItemIndexes(e,t,n);if(void 0!==r.firstShownItemIndex)return r;M("The entire list is off-screen. No items are visible.")}else M("The entire list is off-screen. No items are visible.")}},{key:"getBeforeItemsHeight",value:function(e,t,n){for(var i=this.getColumnsCount(),r=Math.floor(e/i),o=0,s=0;s<r;){for(var a=0,l=0;l<i;)a=Math.max(a,n[s*i+l]||this.itemHeights.getAverage()),l++;o+=a,o+=this.getVerticalSpacing(),s++}return o}},{key:"getAfterItemsHeight",value:function(e,t,n){for(var i=this.getItemsCount(),r=this.getColumnsCount(),o=Math.ceil(i/r),s=0,a=Math.floor(t/r)+1;a<o;){for(var l=0,u=0,h=void 0;u<r&&(h=a*r+u)<i;)l=Math.max(l,n[h]||this.itemHeights.getAverage()),u++;s+=this.getVerticalSpacing(),s+=l,a++}return s}},{key:"validateWillBeHiddenItemHeightsAndState",value:function(e,t){for(var n=this.getState().firstShownItemIndex;n<=this.getState().lastShownItemIndex;){if(n>=e&&n<=t);else{var i=this.getState().itemHeights[n],r=this.remeasureItemHeight(n);r!==i&&M("Item",n,"will be unmounted at next render. Its height has changed from",i,"to",r,"while it was shown. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}n++}}},{key:"watchContainerElementCoordinates",value:function(){var e=this,t=Date.now();!function n(){e.isRendered&&(void 0!==e.topOffset&&e.getTopOffset()!==e.topOffset&&e.onUpdateShownItemIndexes({reason:"top offset change"}),Date.now()-t<3e3&&(e.watchContainerElementCoordinatesTimer=p(n,500)))}()}},{key:"getShownItemIndexes",value:function(){if(this.bypass)return{firstShownItemIndex:0,lastShownItemIndex:this.getItemsCount()-1};var e=this.getTopOffset();void 0===this.topOffset&&this.watchContainerElementCoordinates(),this.topOffset=e;var t=this.getVisibleAreaBounds(),n=t.top,i=t.bottom;return this.latestLayoutVisibleAreaTopAfterIncludingMargin=n-this.getMargin(),this.latestLayoutVisibleAreaBottomAfterIncludingMargin=i+this.getMargin(),this.getItemIndexes(n-this.getMargin(),i+this.getMargin(),e,this.getHeight())||this.getOffscreenListShownItemIndexes()}},{key:"onMultiRenderLayoutRendered",value:function(){var e=this;if(this.redoLayoutAfterRender)return this.redoLayoutAfterRender=void 0,p(function(){e.isRendered&&e.updateShownItemIndexesRecursive()},0);this.stopMultiRenderLayout()}},{key:"stopMultiRenderLayout",value:function(){this.multiRenderLayout=void 0,this.redoLayoutAfterRender||this.restoreScrollAfterPrepend&&this.restoreScroll()}},{key:"captureScroll",value:function(e,t,n){0!==e.length&&0!==n&&(this.getState().firstShownItemIndex>0||this.restoreScrollAfterPrepend&&this.restoreScrollAfterPrepend.previousItems===e&&this.restoreScrollAfterPrepend.nextItems===t||(this.restoreScrollAfterPrepend={previousItems:e,nextItems:t,index:n,visibleAreaTop:this.getItemElement(0).getBoundingClientRect().top}))}},{key:"updateItems",value:function(e,t){return this.setItems(e,t)}},{key:"setItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getState().items,i=this.getState(),r=i.firstShownItemIndex,o=i.lastShownItemIndex,s=i.beforeItemsHeight,a=i.afterItemsHeight,l=i.itemStates,u=i.itemHeights,h=this.firstSeenItemIndex,d=this.lastSeenItemIndex;M("~ Update items ~");var c=this.getItemsDiff(n,e);if(c){var m=c.prependedItemsCount,f=c.appendedItemsCount;m>0&&(M("Prepend",m,"items"),u=new Array(m).concat(u),l&&(l=new Array(m).concat(l))),f>0&&(M("Append",f,"items"),u=u.concat(new Array(f)),l&&(l=l.concat(new Array(f)))),r+=m,o+=m,void 0!==h&&(h+=m,d+=m);this.getVerticalSpacing();var g=this.getColumnsCount();if(m%g==0){var p=m/g,I=Math.ceil(f/g);s+=p*(this.itemHeights.getAverage()+this.getVerticalSpacing()),a+=I*(this.getVerticalSpacing()+this.itemHeights.getAverage())}else s=this.getBeforeItemsHeight(r,o,u),a=this.getAfterItemsHeight(r,o,u)}else M("Items have changed, and it's not a simple append and/or prepend: rerender the entire list from scratch."),M("Previous items",n),M("New items",e),h=void 0,d=void 0,u=new Array(e.length),l=new Array(e.length),0===e.length?(r=void 0,o=void 0):(r=0,o=this.getLastShownItemIndex(r,e.length,this.getColumnsCount())),s=0,a=0;M("First shown item index",r),M("Last shown item index",o),M("Before items height",s),M("After items height (actual or estimated)",a),this.onBeforeShowItems(e,r,o,h,d),this.preserveScrollPositionOnPrependItems=t.preserveScrollPositionOnPrependItems||t.preserveScrollPosition,this.setState({items:e,itemStates:l,itemHeights:u,firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:s,afterItemsHeight:a})}},{key:"getItemsDiff",value:function(e,t){return function(e,t,n){var i=-1,r=-1;e.length>0&&(i=function(e,t,n){var i=0;for(;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n))>=0&&function(e,t,n,i){var r=0;for(;r<e.length;){if(t.length<=n+r||!i(t[n+r],e[r]))return!1;r++}return!0}(e,t,i,n)&&(r=i+e.length-1);if(i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(e,t,this.isItemEqual)}},{key:"getItemElement",value:function(e){return this.getContainerElement().childNodes[e]}}])&&j(t.prototype,n),i&&j(t,i),e}();var F={SCROLL:"scroll",MANUAL:"manual",ITEM_HEIGHT_CHANGED:"item height changed",ITEMS_CHANGED:"items changed",MOUNT:"mount"};function q(){return(q=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}function Y(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function K(e){return(K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function G(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function J(e){return(J=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function X(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Q(e,t){return(Q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Z(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var $=t.elementType||t.oneOfType([t.string,t.func,t.object]),ee=function(t){function n(t){var i,r,o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),r=this,o=J(n).call(this,t),i=!o||"object"!==K(o)&&"function"!=typeof o?X(r):o,Z(X(i),"container",e.createRef()),Z(X(i),"onItemStateChange",new Array(i.props.items.length)),Z(X(i),"onItemHeightChange",new Array(i.props.items.length)),Z(X(i),"itemRefs",new Array(i.props.items.length)),Z(X(i),"itemKeyPrefixes",[]),Z(X(i),"updateLayout",function(){return i.virtualScroller.updateLayout()}),Z(X(i),"layout",function(){return i.updateLayout()}),Z(X(i),"onItemInitialRender",function(){var e=i.props.onItemInitialRender;e&&e.apply(void 0,arguments)}),Z(X(i),"onItemFirstRender",function(){var e=i.props.onItemFirstRender;e&&e.apply(void 0,arguments)}),Z(X(i),"shouldUpdateLayoutOnWindowResize",function(){var e=i.props.shouldUpdateLayoutOnWindowResize;if(e)return e.apply(void 0,arguments)}),i.previousItemsProperty=t.items,i.generateItemKeyPrefix(),i.createVirtualScroller(),i}var i,r,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Q(e,t)}(n,e.Component),i=n,(r=[{key:"createVirtualScroller",value:function(){var e=this,t=this.props,n=t.as,i=t.items,r=t.initialState,o=t.initialCustomState,s=t.onStateChange,a=t.estimatedItemHeight,l=t.preserveScrollPositionOfTheBottomOfTheListOnMount,u=t.preserveScrollPositionAtBottomOnMount,h=t.measureItemsBatchSize,d=t.scrollableContainer,c=t.getScrollableContainer,m=t.getColumnsCount,f=t.getItemId,g=t.bypass;this.virtualScroller=new D(function(){return e.container.current},i,{estimatedItemHeight:a,bypass:g,onItemInitialRender:this.onItemInitialRender,onItemFirstRender:this.onItemFirstRender,preserveScrollPositionOfTheBottomOfTheListOnMount:l,preserveScrollPositionAtBottomOnMount:u,shouldUpdateLayoutOnWindowResize:this.shouldUpdateLayoutOnWindowResize,measureItemsBatchSize:h,scrollableContainer:d,getScrollableContainer:c,getColumnsCount:m,getItemId:f,tbody:"tbody"===n,state:r,customState:o,onStateChange:s,getState:function(){return e.state},setState:function(t,n){var i=n.willUpdateState,r=n.didUpdateState;e.willUpdateState=i,e.didUpdateState=r,e.state?e.setState(t):(i(t),e.state=t,r())}})}},{key:"shouldUseRefs",value:function(){var e,t=this.props.itemComponent;return(e=t).prototype&&e.prototype.isReactComponent}},{key:"getItemKey",value:function(e,t){var n=this.props.getItemId;return n?n(e):"".concat(this.itemKeyPrefix,":").concat(t)}},{key:"getItemCoordinates",value:function(e){return this.virtualScroller.getItemCoordinates(e)}},{key:"updateItem",value:function(e){return this.renderItem(e)}},{key:"renderItem",value:function(e){var t=this;if(void 0===(e=this.getItemIndex(e)))return T("Item ".concat(JSON.stringify(e),' not found when calling ".renderItem()"'));if(!this.shouldUseRefs())return T("`.renderItem(i)` has been called but the `component` doesn't allow `ref`s. Only `component`s that're `React.Component`s support this feature.");if(this.itemRefs[e]&&this.itemRefs[e].current){var n=this.props.items,i=n[e];this.itemRefs[e].current.forceUpdate(function(){if(t._isMounted){var e=n.indexOf(i);e>=0&&t.virtualScroller.onItemHeightChange(e)}})}}},{key:"getItemIndex",value:function(e){if("number"==typeof e)return e;if("object"===K(e)&&null!==e){var t=this.props,n=t.items,i=t.getItemId,r=e;for(e=0;e<n.length;){if(i){if(i(r)===i(n[e]))return e}else if(r===n[e])return e;e++}}}},{key:"getItemRef",value:function(t){return this.itemRefs[t]||(this.itemRefs[t]=e.createRef()),this.itemRefs[t]}},{key:"getOnItemStateChange",value:function(e){var t=this;return this.onItemStateChange[e]||(this.onItemStateChange[e]=function(n){return t.virtualScroller.onItemStateChange(e,n)}),this.onItemStateChange[e]}},{key:"getOnItemHeightChange",value:function(e){var t=this;return this.onItemHeightChange[e]||(this.onItemHeightChange[e]=function(){return t.virtualScroller.onItemHeightChange(e)}),this.onItemHeightChange[e]}},{key:"generateItemKeyPrefix",value:function(){var e=String(Math.random()).slice(2);if(this.itemKeyPrefixes.indexOf(e)>=0)return this.generateItemKeyPrefix();this.itemKeyPrefixes.push(e),this.itemKeyPrefix=e}},{key:"componentDidMount",value:function(){var e=this.props.onMount;e&&e(),this._isMounted=!0,this.virtualScroller.listen()}},{key:"getSnapshotBeforeUpdate",value:function(e,t){return this.state!==t&&this.willUpdateState(this.state,t),null}},{key:"componentDidUpdate",value:function(e,t){this.state!==t&&this.didUpdateState(t);var n=this.props,i=n.items,r=n.preserveScrollPosition,o=n.preserveScrollPositionOnPrependItems;i!==e.items&&this.virtualScroller.setItems(i,{preserveScrollPositionOnPrependItems:o||r})}},{key:"componentWillUnmount",value:function(){this._isMounted=!1,this.virtualScroller.stop()}},{key:"render",value:function(){var t=this,n=this.props,i=n.as,r=n.itemComponent,o=n.itemComponentProps,s=(n.items,n.estimatedItemHeight,n.bypass,n.preserveScrollPositionOnPrependItems),a=n.preserveScrollPosition,l=(n.preserveScrollPositionOfTheBottomOfTheListOnMount,n.preserveScrollPositionAtBottomOnMount,n.shouldUpdateLayoutOnWindowResize,n.measureItemsBatchSize,n.scrollableContainer,n.getScrollableContainer,n.getColumnsCount,n.initialState,n.initialCustomState,n.onStateChange,n.onItemInitialRender,n.onItemFirstRender,n.getItemId),u=(n.onMount,n.className),h=Y(n,["as","itemComponent","itemComponentProps","items","estimatedItemHeight","bypass","preserveScrollPositionOnPrependItems","preserveScrollPosition","preserveScrollPositionOfTheBottomOfTheListOnMount","preserveScrollPositionAtBottomOnMount","shouldUpdateLayoutOnWindowResize","measureItemsBatchSize","scrollableContainer","getScrollableContainer","getColumnsCount","initialState","initialCustomState","onStateChange","onItemInitialRender","onItemFirstRender","getItemId","onMount","className"]),d=this.virtualScroller.getState(),c=d.items,m=d.itemStates,f=d.firstShownItemIndex,g=d.lastShownItemIndex,p=d.beforeItemsHeight,I=d.afterItemsHeight,v=this.props.items,S=c;if(this.itemsPropertyWasChanged||(this.itemsPropertyWasChanged=this.props.items!==this.previousItemsProperty),this.previousItemsProperty=this.props.items,this.itemsPropertyWasChanged&&v!==S){var y=this.virtualScroller.getItemsDiff(S,v);y&&0===y.prependedItemsCount&&y.appendedItemsCount>0||(y&&(s||a)&&this.virtualScroller.captureScroll(S,v,y.prependedItemsCount),l||this.generateItemKeyPrefix(),this.itemRefs=new Array(v.length))}var b=this.virtualScroller.tbody;return e.createElement(i,q({},h,{ref:this.container,className:b?u?u+" VirtualScroller":"VirtualScroller":u,style:{paddingTop:b?void 0:H(p),paddingBottom:b?void 0:H(I)}}),c.map(function(n,i){return i>=f&&i<=g?e.createElement(r,q({},o,{ref:t.shouldUseRefs()?t.getItemRef(i):void 0,key:t.getItemKey(n,i),state:m&&m[i],onStateChange:t.getOnItemStateChange(i),onHeightChange:t.getOnItemHeightChange(i)}),n):null}))}}])&&G(i.prototype,r),o&&G(i,o),n}();return Z(ee,"propTypes",{as:$,items:t.arrayOf(t.object).isRequired,itemComponent:$.isRequired,itemComponentProps:t.object,estimatedItemHeight:t.number,bypass:t.bool,preserveScrollPositionOnPrependItems:t.bool,preserveScrollPosition:t.bool,preserveScrollPositionOfTheBottomOfTheListOnMount:t.bool,preserveScrollPositionAtBottomOnMount:t.bool,shouldUpdateLayoutOnWindowResize:t.func,measureItemsBatchSize:t.number,scrollableContainer:t.any,getScrollableContainer:t.func,getColumnsCount:t.func,getItemId:t.func,className:t.string,onMount:t.func,onItemInitialRender:t.func,onItemFirstRender:t.func,onStateChange:t.func,initialCustomState:t.object,initialState:t.shape({items:t.arrayOf(t.object).isRequired,itemStates:t.arrayOf(t.any),firstShownItemIndex:t.number.isRequired,lastShownItemIndex:t.number.isRequired,beforeItemsHeight:t.number.isRequired,afterItemsHeight:t.number.isRequired,itemHeights:t.arrayOf(t.number).isRequired,columnsCount:t.number,verticalSpacing:t.number})}),Z(ee,"defaultProps",{as:"div"}),ee});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):(e=e||self).VirtualScroller=t(e.React,e.PropTypes)}(this,function(e,t){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,t=t&&t.hasOwnProperty("default")?t.default:t;var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var i,r=(function(e){(function(){var t,n,i,r,o,s;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(e.exports=function(){return(t()-o)/1e6},n=process.hrtime,r=(t=function(){var e;return 1e9*(e=n())[0]+e[1]})(),s=1e9*process.uptime(),o=r-s):Date.now?(e.exports=function(){return Date.now()-i},i=Date.now()):(e.exports=function(){return(new Date).getTime()-i},i=(new Date).getTime())}).call(n)}(i={exports:{}},i.exports),i.exports),o="undefined"==typeof window?n:window,s=["moz","webkit"],a="AnimationFrame",l=o["request"+a],u=o["cancel"+a]||o["cancelRequest"+a],h=0;!l&&h<s.length;h++)l=o[s[h]+"Request"+a],u=o[s[h]+"Cancel"+a]||o[s[h]+"CancelRequest"+a];if(!l||!u){var c=0,m=0,d=[];l=function(e){if(0===d.length){var t=r(),n=Math.max(0,1e3/60-(t-c));c=n+t,setTimeout(function(){var e=d.slice(0);d.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(c)}catch(e){setTimeout(function(){throw e},0)}},Math.round(n))}return d.push({handle:++m,callback:e,cancelled:!1}),m},u=function(e){for(var t=0;t<d.length;t++)d[t].handle===e&&(d[t].cancelled=!0)}}var f=function(e){return l.call(o,e)};f.cancel=function(){u.apply(o,arguments)},f.polyfill=function(e){e||(e=o),e.requestAnimationFrame=l,e.cancelAnimationFrame=u};var g=f.cancel;function p(e,t){var n=Date.now(),i=f(function r(){Date.now()-n>=t?e():i=f(r)});return{clear:function(){return g(i)}}}function I(e){e&&e.clear()}function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function S(e,t){return!t||"object"!==v(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function C(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function O(e,t,n){return t&&C(e.prototype,t),n&&C(e,n),e}var x=function(){function e(t){w(this,e),this.element=t}return O(e,[{key:"getScrollY",value:function(){return this.element.scrollTop}},{key:"scrollTo",value:function(e,t){this.element.scrollTo(e,t)}},{key:"getWidth",value:function(){return this.element.offsetWidth}},{key:"getHeight",value:function(){return this.element.offsetHeight}},{key:"getContentHeight",value:function(){return this.element.scrollHeight}},{key:"getTopOffset",value:function(e){var t=this.element.getBoundingClientRect().top,n=this.element.clientTop;return e.getBoundingClientRect().top-t+this.getScrollY()-n}},{key:"addScrollListener",value:function(e){var t=this;return this.element.addEventListener("scroll",e),function(){return t.element.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e){var t,n=this;if("undefined"!=typeof ResizeObserver){var i=new ResizeObserver(function(t){var n=t,i=Array.isArray(n),r=0;for(n=i?n:n[Symbol.iterator]();;){if(i){if(r>=n.length)break;n[r++]}else{if((r=n.next()).done)break;r.value}return e()}});i.observe(this.element),t=function(){return i.unobserve(n.element)}}var r=(new R).onResize(e);return function(){t&&t(),r()}}}]),e}(),R=function(e){function t(){return w(this,t),S(this,y(t).call(this,window))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}(t,x),O(t,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getContentHeight",value:function(){return document.documentElement.scrollHeight}},{key:"getTopOffset",value:function(e){var t=document.clientTop||document.body.clientTop||0;return e.getBoundingClientRect().top+this.getScrollY()-t}},{key:"onResize",value:function(e){return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}}]),t}();function H(e){return e.toFixed(2)+"px"}var T="It looks like you're using Internet Explorer which doesn't support CSS variables required for a <tbody/> container. VirtualScroller has been switched into \"bypass\" mode (render all items). See: https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1";function P(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function k(){if(E()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,P(["[virtual-scroller]"].concat(n)))}}function M(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i;"undefined"!=typeof window?(k.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw new Error(["[virtual-scroller]"].concat(t).join(" "))},0)):(i=console).error.apply(i,P(["[virtual-scroller]"].concat(t)))}function E(){return"undefined"!=typeof window&&window.VirtualScrollerDebug}function A(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var L=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getContainerElement=t,this.getState=n,this.initialize()}var t,n,i;return t=e,(n=[{key:"initialize",value:function(){this.reset(),this.getState()&&this.initializeFromState(this.getState())}},{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"initializeFromState",value:function(e){for(var t=e.itemHeights,n=0;n<t.length;){if(void 0===t[n]){if(void 0!==this.firstMeasuredItemIndex){this.lastMeasuredItemIndex=n-1;break}}else void 0===this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex=n),this.measuredItemsHeight+=t[n];n++}}},{key:"_measureItemHeight",value:function(e,t){var n=this.getContainerElement();if(n){var i=e-t;if(i>=0&&i<n.childNodes.length)return n.childNodes[i].getBoundingClientRect().height}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(e,t){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(k("Non-measured items gap detected. Reset first and last measured item indexes."),this.reset());for(var n=[],i=this.firstMeasuredItemIndex,r=this.lastMeasuredItemIndex,o=!1,s=e;s<=t;){if(void 0===this._get(s)){n.push(s),k("Item",s,"hasn't been previously measured");var a=this._measureItemHeight(s,e);k("Height",a),this._set(s,a),(void 0===i||s<i)&&(this.measuredItemsHeight+=a,o||(this.firstMeasuredItemIndex=s,o=!0)),(void 0===r||s>r)&&(void 0!==r&&(this.measuredItemsHeight+=a),this.lastMeasuredItemIndex=s)}else{var l=this._get(s),u=this._measureItemHeight(s,e);l!==u&&k("Item",s,"height has changed from",l,"to",u,"while it was shown, and \".onItemHeightChange(i)\" hasn't been called yet. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}s++}return n}},{key:"remeasureItemHeight",value:function(e,t){var n=this._get(e),i=this._measureItemHeight(e,t);return this._set(e,i),this.measuredItemsHeight+=i-n,i}},{key:"getAverage",value:function(){return void 0===this.lastMeasuredItemIndex?0:this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"_get",value:function(e){return this.getState().itemHeights[e]}},{key:"_set",value:function(e,t){this.getState().itemHeights[e]=t}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}])&&A(t.prototype,n),i&&A(t,i),e}();function _(e){return(_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var U=Object.prototype.hasOwnProperty;function B(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function V(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){j(e,t,n[t])})}return e}function N(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function j(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var z=250,D=100,W=function(){function e(t,n){var i,r,o,s=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),j(this,"updateLayout",function(){return s.onUpdateShownItemIndexes({reason:F.MANUAL})}),j(this,"onScroll",function(){return s.onUpdateShownItemIndexes({reason:F.SCROLL})}),j(this,"restoreScrollPositionFromState",function(){var e=s.getState().scrollY;void 0!==e&&s.scrollTo(0,e)}),j(this,"updateScrollPosition",function(){return s.getState().scrollY=s.getScrollY()}),j(this,"layout",function(){return s.updateLayout()}),j(this,"onResize",(i=function(e){if(s.isRendered){var t=s.shouldUpdateLayoutOnScrollableContainerResize(e);if("UPDATE_LAYOUT"===t){k("~ Scrollable container size changed, re-measure item heights. ~"),s.redoLayoutReason=F.RESIZE;var n=s.getInitialLayoutState();k("Reset state to",n),s.setState(n)}else"UPDATE_SHOWN_ITEM_INDEXES"===t&&s.onUpdateShownItemIndexes({reason:F.RESIZE})}},r=z,function(){for(var e=this,t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];clearTimeout(o),o=setTimeout(function(){return i.apply(e,n)},r)})),j(this,"willUpdateState",function(e,t){}),j(this,"didUpdateState",function(e){var t=s.getState();if(s.onStateChange&&(function(e,t){if(B(e,t))return!0;if("object"!==_(e)||null===e||"object"!==_(t)||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!U.call(t,n[r])||!B(e[n[r]],t[n[r]]))return!1;return!0}(t,e)||s.onStateChange(t,e)),e&&s.isRendered){k("~ Rendered ~");var n=s.redoLayoutReason;s.redoLayoutReason=void 0;var i=e.items,r=t.items;if(r!==i){var o=!0,a=s.getItemsDiff(i,r);if(a){var l=a.prependedItemsCount;a.appendedItemsCount;l>0&&(s.itemHeights.onPrepend(l),s.restoreScrollAfterRenderValues&&(o=!1,s.restoreScrollAfterRender()))}else s.itemHeights.initialize();o&&(n=F.ITEMS_CHANGED)}return t.firstShownItemIndex===e.firstShownItemIndex&&t.lastShownItemIndex===e.lastShownItemIndex&&t.items===e.items||s.onRendered(),n?s.redoLayoutRightAfterRender({reason:n}):void 0}}),j(this,"updateShownItemIndexes",function(){k("~ Layout results "+(s.bypass?"(bypass) ":"")+"~");var e=s.getShownItemIndexes(),t=e.firstShownItemIndex,n=e.lastShownItemIndex,i=e.redoLayoutAfterMeasuringItemHeights,r=s.getState().itemHeights,o=s.getBeforeItemsHeight(t,n,r),a=s.getAfterItemsHeight(t,n,r);s._getColumnsCount&&k("Columns count",s.getColumnsCount()),k("First shown item index",t),k("Last shown item index",n),k("Before items height",o),k("After items height (actual or estimated)",a),k("Average item height (calculated on previous render)",s.itemHeights.getAverage()),E()&&(k("Item heights",s.getState().itemHeights.slice()),k("Item states",s.getState().itemStates.slice())),i&&(s.redoLayoutReason=F.ITEM_HEIGHT_NOT_MEASURED),s.validateWillBeHiddenItemHeightsAndState(t,n),s.onBeforeShowItems(s.getState().items,s.getState().itemHeights,t,n),s.setState({firstShownItemIndex:t,lastShownItemIndex:n,beforeItemsHeight:o,afterItemsHeight:a})}),j(this,"updateShownItemIndexesRecursive",function(){s.layoutInProgress=!0,s.updateShownItemIndexes()}),j(this,"onUpdateShownItemIndexes",function(e){var t=e.reason;if(0!==s.getItemsCount()){if(s.onUserStopsScrollingTimer&&(I(s.onUserStopsScrollingTimer),s.onUserStopsScrollingTimer=void 0),t===F.SCROLL){var n=void 0!==s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getScrollY()<s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getState().firstShownItemIndex>0||void 0!==s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getScrollY()+s.scrollableContainer.getHeight()>s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getState().lastShownItemIndex<s.getItemsCount()-1;if(k(n?"The user has scrolled far enough: force re-render":"The user hasn't scrolled too much: delay re-render"),!n){if(s.layoutTimer)return;return void(s.onUserStopsScrollingTimer=p(function(){s.isRendered&&s.onUpdateShownItemIndexes({reason:F.STOPPED_SCROLLING})},D))}}s.layoutTimer&&(I(s.layoutTimer),s.layoutTimer=void 0),k("~ Calculate Layout (on ".concat(t,") ~")),s.updateShownItemIndexesRecursive()}});var l=a.getState,u=a.setState,h=a.onStateChange,c=a.customState,m=a.preserveScrollPositionAtBottomOnMount,d=a.shouldUpdateLayoutOnWindowResize,f=a.measureItemsBatchSize,g=a.getScrollableContainer,v=a.getColumnsCount,S=a.getItemId,y=a.tbody,b=a._useTimeoutInRenderLoop,w=a.bypass,C=a.estimatedItemHeight,O=a.onItemInitialRender,H=a.onItemFirstRender,P=a.scrollableContainer,A=a.preserveScrollPositionOfTheBottomOfTheListOnMount,N=a.state;k("~ Initialize ~"),N&&(n=N.items),!P&&g&&(P=g()),P?this.scrollableContainer=new x(P):"undefined"!=typeof window&&(this.scrollableContainer=new R),y&&(k("~ <tbody/> detected ~"),this.tbody=!0,"undefined"!=typeof window&&window.document.documentMode&&(k("~ <tbody/> not supported ~"),M(T),w=!0)),w&&k('~ "bypass" mode ~'),this.bypass=w,this._useTimeoutInRenderLoop=b,this.isItemEqual=S?function(e,t){return S(e)===S(t)}:function(e,t){return e===t},this.initialItems=n,this.estimatedItemHeight=C,this.onStateChange=h,this._shouldUpdateLayoutOnWindowResize=d,this.measureItemsBatchSize=void 0===f?50:f,this._getColumnsCount=v,O?this.onItemInitialRender=O:H&&(this.onItemInitialRender=function(e){console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=s.getState().items.indexOf(e);t>=0&&H(t)}),k("Items count",n.length),C&&k("Estimated item height",C),u?(this.getState=l,this.setState=function(e){k("Set state",e),u(e,{willUpdateState:s.willUpdateState,didUpdateState:s.didUpdateState})}):(this.getState=function(){return s.state},this.setState=function(e){k("Set state",e);var t=s.getState(),n=V({},t,e);s.willUpdateState(n,t),s.state=n,s.didUpdateState(t)}),N&&k("Initial state (passed)",N),this.getContainerElement=t,t()&&function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}(t()),this.itemHeights=new L(this.getContainerElement,this.getState),this.scrollableContainer&&(m&&(console.warn("[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),A=m),A&&(this.preserveScrollPositionOfTheBottomOfTheListOnMount={scrollableContainerContentHeight:this.scrollableContainer.getContentHeight()})),this.setState(N||this.getInitialState(c))}var t,n,i;return t=e,(n=[{key:"getInitialState",value:function(e){var t=this.initialItems.length,n=V({},e,this.getInitialLayoutState(),{items:this.initialItems,itemStates:new Array(t)});return k("Initial state (autogenerated)",n),k("First shown item index",n.firstShownItemIndex),k("Last shown item index",n.lastShownItemIndex),n}},{key:"getInitialLayoutState",value:function(){var e,t,n=this.initialItems,i=n.length,r=this._getColumnsCount?this._getColumnsCount(this.scrollableContainer):void 0;i>0&&(e=0,t=this.getLastShownItemIndex(e,i,r||1)),this.preserveScrollPositionOfTheBottomOfTheListOnMount&&(e=0,t=i-1);var o=new Array(i);return this.onBeforeShowItems(n,o,e,t),{itemHeights:o,columnsCount:r,verticalSpacing:void 0,beforeItemsHeight:0,afterItemsHeight:0,firstShownItemIndex:e,lastShownItemIndex:t,scrollY:void 0}}},{key:"getEstimatedItemHeight",value:function(){return this.itemHeights&&this.itemHeights.getAverage()||this.estimatedItemHeight||0}},{key:"getVerticalSpacing",value:function(){return this.getState()&&this.getState().verticalSpacing||0}},{key:"getColumnsCount",value:function(){return this.getState()&&this.getState().columnsCount||1}},{key:"getEstimatedItemsCount",value:function(e){return this.getEstimatedRowsCount(e)*this.getColumnsCount()}},{key:"getEstimatedRowsCount",value:function(e){return this.getEstimatedItemHeight()?Math.ceil((e+this.getVerticalSpacing())/(this.getEstimatedItemHeight()+this.getVerticalSpacing())):1}},{key:"getEstimatedItemsCountOnScreen",value:function(e){return this.getEstimatedRowsCountOnScreen()*e}},{key:"getEstimatedRowsCountOnScreen",value:function(){return this.scrollableContainer?this.getEstimatedRowsCount(2*this.getMargin()+this.scrollableContainer.getHeight()):1}},{key:"getLastShownItemIndex",value:function(e,t,n){return this.bypass?t-1:Math.min(e+(this.getEstimatedItemsCountOnScreen(n)-1),t-1)}},{key:"getItemsCount",value:function(){return this.getState().items.length}},{key:"getMargin",value:function(){return 1*this.scrollableContainer.getHeight()}},{key:"onBeforeShowItems",value:function(e,t,n,i){if(this.onItemInitialRender)for(var r=n;r<=i;)void 0===t[r]&&this.onItemInitialRender(e[r]),r++}},{key:"onMount",value:function(){console.warn("[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){console.warn("[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"listen",value:function(){if(!1===this.isRendered)throw new Error("[virtual-scroller] Can't restart a `VirtualScroller` after it has been stopped");k("~ Rendered (initial) ~"),this.isRendered=!0,this.onRendered(),this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.restoreScrollPositionFromState(),this.updateScrollPosition(),this.removeScrollPositionListener=this.scrollableContainer.addScrollListener(this.updateScrollPosition),this.bypass||(this.removeScrollListener=this.scrollableContainer.addScrollListener(this.onScroll),this.scrollableContainerUnlistenResize=this.scrollableContainer.onResize(this.onResize)),this.tbody&&function(e){e.classList.add("VirtualScroller");var t=document.getElementById("VirtualScrollerStyle");t||((t=document.createElement("style")).id="VirtualScrollerStyle",t.innerText="\n\t\t\ttbody.VirtualScroller:before {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t\t}\n\t\t\ttbody.VirtualScroller:after {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t\t}\n\t\t".replace(/[\n\t]/g,""),document.head.appendChild(t))}(this.getContainerElement()),this.preserveScrollPositionOfTheBottomOfTheListOnMount?this.scrollTo(0,this.getScrollY()+(this.scrollableContainer.getContentHeight()-this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight)):this.onUpdateShownItemIndexes({reason:F.MOUNT})}},{key:"onRendered",value:function(){this.measureVerticalSpacing(),this.measureNonPreviouslyMeasuredItemHeights(),this.tbody&&this.updateTbodyPadding()}},{key:"scrollTo",value:function(e,t){this.scrollableContainer.scrollTo(e,t)}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}},{key:"getHeight",value:function(){return this.getContainerElement().getBoundingClientRect().height}},{key:"getTopOffset",value:function(){return this.scrollableContainer.getTopOffset(this.getContainerElement())}},{key:"shouldUpdateLayoutOnScrollableContainerResize",value:function(e){if(e&&e.target===window){if(document.fullscreenElement&&this.getContainerElement().contains(document.fullscreenElement))return!1;if(this._shouldUpdateLayoutOnWindowResize&&!1===this._shouldUpdateLayoutOnWindowResize(e))return!1}var t=this.scrollableContainerWidth,n=this.scrollableContainerHeight;return this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.scrollableContainerWidth===t?this.scrollableContainerHeight!==n&&"UPDATE_SHOWN_ITEM_INDEXES":"UPDATE_LAYOUT"}},{key:"onUnmount",value:function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"stop",value:function(){this.isRendered=!1,this.removeScrollPositionListener(),this.bypass||(this.removeScrollListener(),this.scrollableContainerUnlistenResize(),I(this.onUserStopsScrollingTimer),I(this.watchContainerElementCoordinatesTimer),I(this.layoutTimer))}},{key:"redoLayoutRightAfterRender",value:function(e){var t=this,n=e.reason;this._useTimeoutInRenderLoop?(this.layoutTimer&&I(this.layoutTimer),this.layoutTimer=p(function(){t.layoutTimer=void 0,t.onUpdateShownItemIndexes({reason:n})},0)):this.onUpdateShownItemIndexes({reason:n})}},{key:"updateTbodyPadding",value:function(){var e=this.getState(),t=e.beforeItemsHeight,n=e.afterItemsHeight;!function(e,t,n){e.style.setProperty("--VirtualScroller-paddingTop",H(t)),e.style.setProperty("--VirtualScroller-paddingBottom",H(n))}(this.getContainerElement(),t,n)}},{key:"measureVerticalSpacing",value:function(){if(void 0===this.getState().verticalSpacing){k("~ Measure item vertical spacing ~");var e=this.measureVerticalSpacingValue();void 0===e?k("Not enough items rendered to measure vertical spacing"):(k("Item vertical spacing",e),this.setState({verticalSpacing:e}))}}},{key:"measureVerticalSpacingValue",value:function(){var e=this.getContainerElement();if(e&&e.childNodes.length>1)for(var t=e.childNodes[0].getBoundingClientRect(),n=t.top,i=t.height,r=1;r<e.childNodes.length;){var o=e.childNodes[r].getBoundingClientRect(),s=o.top,a=o.height;if(s!==n)return s-(n+i);i=Math.max(i,a),r++}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(){var e=this.getState(),t=e.firstShownItemIndex,n=e.lastShownItemIndex;if(void 0!==t)this.itemHeights.measureNonPreviouslyMeasuredItemHeights(t,n)}},{key:"remeasureItemHeight",value:function(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}},{key:"onItemStateChange",value:function(e,t){E()&&(k("~ Item state changed ~"),k("Item",e),k("Previous state\n"+JSON.stringify(this.getState().itemStates[e],null,2)),k("New state\n"+JSON.stringify(t,null,2))),this.getState().itemStates[e]=t}},{key:"onItemHeightChange",value:function(e){k("~ Re-measure item height ~"),k("Item",e);var t=this.getState().itemHeights[e];if(void 0===t)return M('"onItemHeightChange()" has been called for item '.concat(e,", but that item hasn't been rendered before."));var n=this.remeasureItemHeight(e);if(void 0===n)return k("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.");k("Previous height",t),k("New height",n),t!==n&&(k("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:F.ITEM_HEIGHT_CHANGED}))}},{key:"getItemCoordinates",value:function(e){for(var t=this.getState().itemHeights,n=this.getColumnsCount(),i=this.getTopOffset(),r=Math.floor(e/n),o=0;o<r;){for(var s=0,a=0;a<n;)s=Math.max(s,t[o*n+a]),a++;i+=s,i+=this.getVerticalSpacing(),o++}return{top:i,bottom:i+t[e],height:t[e]}}},{key:"_getVisibleItemIndexes",value:function(e,t,n){for(var i,r,o=0,s=this.getItemsCount(),a=this.getColumnsCount(),l=Math.ceil(s/a),u=0;u<l;){for(var h=s>(u+1)*a?this.getVerticalSpacing():0,c=0,m=0,d=void 0;m<a&&(d=u*a+m)<s;){var f=this.getState().itemHeights[d];if(void 0===f){k("Item index ".concat(d,' lies within the visible area or its "margins", but its height hasn\'t been measured yet. Mark the item as "shown", render the list, measure the item\'s height and redo the layout.')),void 0===i&&(i=u*a);var g=t-(n+o);return{firstNonMeasuredItemIndex:d,firstShownItemIndex:i,lastShownItemIndex:r=Math.min((u+this.getEstimatedRowsCount(g))*a-1,s-1)}}if(c=Math.max(c,f),void 0===i&&n+o+c>e&&(k("First shown row index",u),i=u*a),n+o+c+h>t)return k("Last shown row index",u),void 0!==i&&(r=Math.min((u+1)*a-1,s-1)),{firstShownItemIndex:i,lastShownItemIndex:r};m++}o+=c,o+=h,u++}return void 0!==i&&void 0===r&&k("Last item index (is fully visible)",r=s-1),{firstShownItemIndex:i,lastShownItemIndex:r}}},{key:"getVisibleItemIndexes",value:function(e,t,n){var i=this._getVisibleItemIndexes(e,t,n),r=i.firstNonMeasuredItemIndex,o=i.firstShownItemIndex,s=i.lastShownItemIndex,a=void 0!==r;if(this.restoreScrollAfterRenderValues&&(s<this.restoreScrollAfterRenderValues.index&&(s=this.restoreScrollAfterRenderValues.index),a=!1),a&&this.measureItemsBatchSize){var l=this.getColumnsCount(),u=r+this.measureItemsBatchSize-1;s=Math.min(s,Math.ceil(u/l)*l-1)}return{firstShownItemIndex:o,lastShownItemIndex:s,redoLayoutAfterMeasuringItemHeights:a}}},{key:"getOffscreenListShownItemIndexes",value:function(){return{firstShownItemIndex:0,lastShownItemIndex:0,redoLayoutAfterMeasuringItemHeights:void 0===this.getState().itemHeights[0]}}},{key:"getItemIndexes",value:function(e,t,n,i){if(n+i>e&&n<t){var r=this.getVisibleItemIndexes(e,t,n);if(void 0!==r.firstShownItemIndex)return r;k("The entire list is off-screen. No items are visible.")}else k("The entire list is off-screen. No items are visible.")}},{key:"getBeforeItemsHeight",value:function(e,t,n){for(var i=this.getColumnsCount(),r=Math.floor(e/i),o=0,s=0;s<r;){for(var a=0,l=0;l<i;)a=Math.max(a,n[s*i+l]||this.itemHeights.getAverage()),l++;o+=a,o+=this.getVerticalSpacing(),s++}return o}},{key:"getAfterItemsHeight",value:function(e,t,n){for(var i=this.getItemsCount(),r=this.getColumnsCount(),o=Math.ceil(i/r),s=0,a=Math.floor(t/r)+1;a<o;){for(var l=0,u=0,h=void 0;u<r&&(h=a*r+u)<i;)l=Math.max(l,n[h]||this.itemHeights.getAverage()),u++;s+=this.getVerticalSpacing(),s+=l,a++}return s}},{key:"validateWillBeHiddenItemHeightsAndState",value:function(e,t){for(var n=this.getState().firstShownItemIndex;n<=this.getState().lastShownItemIndex;){if(n>=e&&n<=t);else{var i=this.getState().itemHeights[n],r=this.remeasureItemHeight(n);r!==i&&k("Item",n,"will be unmounted at next render. Its height has changed from",i,"to",r,"while it was shown. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}n++}}},{key:"watchContainerElementCoordinates",value:function(){var e=this,t=Date.now();!function n(){e.isRendered&&(void 0!==e.topOffset&&e.getTopOffset()!==e.topOffset&&e.onUpdateShownItemIndexes({reason:F.TOP_OFFSET_CHANGED}),Date.now()-t<3e3&&(e.watchContainerElementCoordinatesTimer=p(n,500)))}()}},{key:"getShownItemIndexes",value:function(){if(this.bypass)return{firstShownItemIndex:0,lastShownItemIndex:this.getItemsCount()-1};var e=this.getTopOffset();void 0===this.topOffset&&this.watchContainerElementCoordinates(),this.topOffset=e;var t=this.getVisibleAreaBounds(),n=t.top,i=t.bottom;return this.latestLayoutVisibleAreaTopAfterIncludingMargin=n-this.getMargin(),this.latestLayoutVisibleAreaBottomAfterIncludingMargin=i+this.getMargin(),this.getItemIndexes(n-this.getMargin(),i+this.getMargin(),e,this.getHeight())||this.getOffscreenListShownItemIndexes()}},{key:"captureScroll",value:function(e,t,n){if(0!==e.length&&0!==n){var i=this.getState().firstShownItemIndex,r=this.getItemElement(0).getBoundingClientRect().top;if(i>0){var o=this.getState(),s=(o.verticalSpacing,o.itemHeights);r=this.getItemElement(0).getBoundingClientRect().top;for(var a=i-1;a>=0;)r+=s[a]+this.getVerticalSpacing(),a--}this.restoreScrollAfterRenderValues&&this.restoreScrollAfterRenderValues.previousItems===e&&this.restoreScrollAfterRenderValues.nextItems===t||(this.restoreScrollAfterRenderValues={previousItems:e,nextItems:t,index:n,visibleAreaTop:r})}}},{key:"restoreScrollAfterRender",value:function(){k("~ Restore Scroll Position ~");var e=this.restoreScrollAfterRenderValues,t=e.index,n=e.visibleAreaTop;this.restoreScrollAfterRenderValues=void 0;var i=this.getItemElement(t).getBoundingClientRect().top-n;0===i?k("Scroll position hasn't changed"):(k("Scroll down by",i),this.scrollTo(0,this.getScrollY()+i))}},{key:"updateItems",value:function(e,t){return this.setItems(e,t)}},{key:"setItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getState().items,i=this.getState(),r=i.firstShownItemIndex,o=i.lastShownItemIndex,s=i.beforeItemsHeight,a=i.afterItemsHeight,l=i.itemStates,u=i.itemHeights;k("~ Update items ~");var h=this.getItemsDiff(n,e);if(h){var c=h.prependedItemsCount,m=h.appendedItemsCount;c>0&&(k("Prepend",c,"items"),u=new Array(c).concat(u),l&&(l=new Array(c).concat(l))),m>0&&(k("Append",m,"items"),u=u.concat(new Array(m)),l&&(l=l.concat(new Array(m)))),r+=c,o+=c;this.getVerticalSpacing();var d=this.getColumnsCount();if(c%d==0){var f=c/d,g=Math.ceil(m/d);s+=f*(this.itemHeights.getAverage()+this.getVerticalSpacing()),a+=g*(this.getVerticalSpacing()+this.itemHeights.getAverage())}else s=this.getBeforeItemsHeight(r,o,u),a=this.getAfterItemsHeight(r,o,u);c>0&&(t.preserveScrollPositionOnPrependItems||t.preserveScrollPosition)&&(r=0,s=0,this.captureScroll(n,e,c))}else k("Items have changed, and it's not a simple append and/or prepend: rerender the entire list from scratch."),k("Previous items",n),k("New items",e),u=new Array(e.length),l=new Array(e.length),0===e.length?(r=void 0,o=void 0):(r=0,o=this.getLastShownItemIndex(r,e.length,this.getColumnsCount())),s=0,a=0;k("~ Update state ~"),k("First shown item index",r),k("Last shown item index",o),k("Before items height",s),k("After items height (actual or estimated)",a),this.onBeforeShowItems(e,u,r,o),this.setState({items:e,itemStates:l,itemHeights:u,firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:s,afterItemsHeight:a})}},{key:"getItemsDiff",value:function(e,t){return function(e,t,n){var i=-1,r=-1;e.length>0&&(i=function(e,t,n){var i=0;for(;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n))>=0&&function(e,t,n,i){var r=0;for(;r<e.length;){if(t.length<=n+r||!i(t[n+r],e[r]))return!1;r++}return!0}(e,t,i,n)&&(r=i+e.length-1);if(i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(e,t,this.isItemEqual)}},{key:"getItemElement",value:function(e){return this.getContainerElement().childNodes[e]}}])&&N(t.prototype,n),i&&N(t,i),e}();var F={SCROLL:"scroll",STOPPED_SCROLLING:"stopped scrolling",MANUAL:"manual",MOUNT:"mount",ITEM_HEIGHT_NOT_MEASURED:"some item height wasn't measured",RESIZE:"resize",ITEM_HEIGHT_CHANGED:"item height changed",ITEMS_CHANGED:"items changed",TOP_OFFSET_CHANGED:"top offset changed"};function q(){return(q=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}function Y(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function G(e){return(G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function K(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function J(e){return(J=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Z(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function X(e,t){return(X=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Q(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var $=t.elementType||t.oneOfType([t.string,t.func,t.object]),ee=function(t){function n(t){var i,r,o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),r=this,o=J(n).call(this,t),i=!o||"object"!==G(o)&&"function"!=typeof o?Z(r):o,Q(Z(i),"container",e.createRef()),Q(Z(i),"onItemStateChange",new Array(i.props.items.length)),Q(Z(i),"onItemHeightChange",new Array(i.props.items.length)),Q(Z(i),"itemRefs",new Array(i.props.items.length)),Q(Z(i),"itemKeyPrefixes",[]),Q(Z(i),"updateLayout",function(){return i.virtualScroller.updateLayout()}),Q(Z(i),"layout",function(){return i.updateLayout()}),Q(Z(i),"onItemInitialRender",function(){var e=i.props.onItemInitialRender;e&&e.apply(void 0,arguments)}),Q(Z(i),"onItemFirstRender",function(){var e=i.props.onItemFirstRender;e&&e.apply(void 0,arguments)}),Q(Z(i),"shouldUpdateLayoutOnWindowResize",function(){var e=i.props.shouldUpdateLayoutOnWindowResize;if(e)return e.apply(void 0,arguments)}),i.previousItemsProperty=t.items,i.generateItemKeyPrefix(),i.createVirtualScroller(),i}var i,r,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&X(e,t)}(n,e.Component),i=n,(r=[{key:"createVirtualScroller",value:function(){var e=this,t=this.props,n=t.as,i=t.items,r=t.initialState,o=t.initialCustomState,s=t.onStateChange,a=t.estimatedItemHeight,l=t.preserveScrollPositionOfTheBottomOfTheListOnMount,u=t.preserveScrollPositionAtBottomOnMount,h=t.measureItemsBatchSize,c=t.scrollableContainer,m=t.getScrollableContainer,d=t.getColumnsCount,f=t.getItemId,g=t.bypass;this.virtualScroller=new W(function(){return e.container.current},i,{_useTimeoutInRenderLoop:!0,estimatedItemHeight:a,bypass:g,onItemInitialRender:this.onItemInitialRender,onItemFirstRender:this.onItemFirstRender,preserveScrollPositionOfTheBottomOfTheListOnMount:l,preserveScrollPositionAtBottomOnMount:u,shouldUpdateLayoutOnWindowResize:this.shouldUpdateLayoutOnWindowResize,measureItemsBatchSize:h,scrollableContainer:c,getScrollableContainer:m,getColumnsCount:d,getItemId:f,tbody:"tbody"===n,state:r,customState:o,onStateChange:s,getState:function(){return e.state},setState:function(t,n){var i=n.willUpdateState,r=n.didUpdateState;e.willUpdateState=i,e.didUpdateState=r,e.state?e.setState(t):(i(t),e.state=t,r())}})}},{key:"shouldUseRefs",value:function(){var e,t=this.props.itemComponent;return(e=t).prototype&&e.prototype.isReactComponent}},{key:"getItemKey",value:function(e,t){var n=this.props.getItemId;return n?n(e):"".concat(this.itemKeyPrefix,":").concat(t)}},{key:"getItemCoordinates",value:function(e){return this.virtualScroller.getItemCoordinates(e)}},{key:"updateItem",value:function(e){return this.renderItem(e)}},{key:"renderItem",value:function(e){var t=this;if(void 0===(e=this.getItemIndex(e)))return M("Item ".concat(JSON.stringify(e),' not found when calling ".renderItem()"'));if(!this.shouldUseRefs())return M("`.renderItem(i)` has been called but the `component` doesn't allow `ref`s. Only `component`s that're `React.Component`s support this feature.");if(this.itemRefs[e]&&this.itemRefs[e].current){var n=this.props.items,i=n[e];this.itemRefs[e].current.forceUpdate(function(){if(t._isMounted){var e=n.indexOf(i);e>=0&&t.virtualScroller.onItemHeightChange(e)}})}}},{key:"getItemIndex",value:function(e){if("number"==typeof e)return e;if("object"===G(e)&&null!==e){var t=this.props,n=t.items,i=t.getItemId,r=e;for(e=0;e<n.length;){if(i){if(i(r)===i(n[e]))return e}else if(r===n[e])return e;e++}}}},{key:"getItemRef",value:function(t){return this.itemRefs[t]||(this.itemRefs[t]=e.createRef()),this.itemRefs[t]}},{key:"getOnItemStateChange",value:function(e){var t=this;return this.onItemStateChange[e]||(this.onItemStateChange[e]=function(n){return t.virtualScroller.onItemStateChange(e,n)}),this.onItemStateChange[e]}},{key:"getOnItemHeightChange",value:function(e){var t=this;return this.onItemHeightChange[e]||(this.onItemHeightChange[e]=function(){return t.virtualScroller.onItemHeightChange(e)}),this.onItemHeightChange[e]}},{key:"generateItemKeyPrefix",value:function(){var e=String(Math.random()).slice(2);if(this.itemKeyPrefixes.indexOf(e)>=0)return this.generateItemKeyPrefix();this.itemKeyPrefixes.push(e),this.itemKeyPrefix=e}},{key:"componentDidMount",value:function(){var e=this.props.onMount;e&&e(),this._isMounted=!0,this.virtualScroller.listen()}},{key:"getSnapshotBeforeUpdate",value:function(e,t){return this.state!==t&&this.willUpdateState(this.state,t),null}},{key:"componentDidUpdate",value:function(e,t){this.state!==t&&this.didUpdateState(t);var n=this.props,i=n.items,r=n.preserveScrollPosition,o=n.preserveScrollPositionOnPrependItems;i!==e.items&&this.virtualScroller.setItems(i,{preserveScrollPositionOnPrependItems:o||r})}},{key:"componentWillUnmount",value:function(){this._isMounted=!1,this.virtualScroller.stop()}},{key:"render",value:function(){var t=this,n=this.props,i=n.as,r=n.itemComponent,o=n.itemComponentProps,s=(n.items,n.estimatedItemHeight,n.bypass,n.preserveScrollPositionOnPrependItems),a=n.preserveScrollPosition,l=(n.preserveScrollPositionOfTheBottomOfTheListOnMount,n.preserveScrollPositionAtBottomOnMount,n.shouldUpdateLayoutOnWindowResize,n.measureItemsBatchSize,n.scrollableContainer,n.getScrollableContainer,n.getColumnsCount,n.initialState,n.initialCustomState,n.onStateChange,n.onItemInitialRender,n.onItemFirstRender,n.getItemId),u=(n.onMount,n.className),h=Y(n,["as","itemComponent","itemComponentProps","items","estimatedItemHeight","bypass","preserveScrollPositionOnPrependItems","preserveScrollPosition","preserveScrollPositionOfTheBottomOfTheListOnMount","preserveScrollPositionAtBottomOnMount","shouldUpdateLayoutOnWindowResize","measureItemsBatchSize","scrollableContainer","getScrollableContainer","getColumnsCount","initialState","initialCustomState","onStateChange","onItemInitialRender","onItemFirstRender","getItemId","onMount","className"]),c=this.virtualScroller.getState(),m=c.items,d=c.itemStates,f=c.firstShownItemIndex,g=c.lastShownItemIndex,p=c.beforeItemsHeight,I=c.afterItemsHeight,v=this.props.items,S=m;if(this.itemsPropertyWasChanged||(this.itemsPropertyWasChanged=this.props.items!==this.previousItemsProperty),this.previousItemsProperty=this.props.items,this.itemsPropertyWasChanged&&v!==S){var y=this.virtualScroller.getItemsDiff(S,v);y&&0===y.prependedItemsCount&&y.appendedItemsCount>0||(y&&(s||a)&&this.virtualScroller.captureScroll(S,v,y.prependedItemsCount),l||this.generateItemKeyPrefix(),this.itemRefs=new Array(v.length))}var b=this.virtualScroller.tbody;return e.createElement(i,q({},h,{ref:this.container,className:b?u?u+" VirtualScroller":"VirtualScroller":u,style:{paddingTop:b?void 0:H(p),paddingBottom:b?void 0:H(I)}}),m.map(function(n,i){return i>=f&&i<=g?e.createElement(r,q({},o,{ref:t.shouldUseRefs()?t.getItemRef(i):void 0,key:t.getItemKey(n,i),state:d&&d[i],onStateChange:t.getOnItemStateChange(i),onHeightChange:t.getOnItemHeightChange(i)}),n):null}))}}])&&K(i.prototype,r),o&&K(i,o),n}();return Q(ee,"propTypes",{as:$,items:t.arrayOf(t.object).isRequired,itemComponent:$.isRequired,itemComponentProps:t.object,estimatedItemHeight:t.number,bypass:t.bool,preserveScrollPositionOnPrependItems:t.bool,preserveScrollPosition:t.bool,preserveScrollPositionOfTheBottomOfTheListOnMount:t.bool,preserveScrollPositionAtBottomOnMount:t.bool,shouldUpdateLayoutOnWindowResize:t.func,measureItemsBatchSize:t.number,scrollableContainer:t.any,getScrollableContainer:t.func,getColumnsCount:t.func,getItemId:t.func,className:t.string,onMount:t.func,onItemInitialRender:t.func,onItemFirstRender:t.func,onStateChange:t.func,initialCustomState:t.object,initialState:t.shape({items:t.arrayOf(t.object).isRequired,itemStates:t.arrayOf(t.any),firstShownItemIndex:t.number.isRequired,lastShownItemIndex:t.number.isRequired,beforeItemsHeight:t.number.isRequired,afterItemsHeight:t.number.isRequired,itemHeights:t.arrayOf(t.number).isRequired,columnsCount:t.number,verticalSpacing:t.number})}),Q(ee,"defaultProps",{as:"div"}),ee});
//# sourceMappingURL=virtual-scroller-react.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).VirtualScroller=t()}(this,function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var t,n=(function(t){(function(){var e,n,i,r,o,s;"undefined"!=typeof performance&&null!==performance&&performance.now?t.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(t.exports=function(){return(e()-o)/1e6},n=process.hrtime,r=(e=function(){var e;return 1e9*(e=n())[0]+e[1]})(),s=1e9*process.uptime(),o=r-s):Date.now?(t.exports=function(){return Date.now()-i},i=Date.now()):(t.exports=function(){return(new Date).getTime()-i},i=(new Date).getTime())}).call(e)}(t={exports:{}},t.exports),t.exports),i="undefined"==typeof window?e:window,r=["moz","webkit"],o="AnimationFrame",s=i["request"+o],a=i["cancel"+o]||i["cancelRequest"+o],l=0;!s&&l<r.length;l++)s=i[r[l]+"Request"+o],a=i[r[l]+"Cancel"+o]||i[r[l]+"CancelRequest"+o];if(!s||!a){var u=0,h=0,d=[];s=function(e){if(0===d.length){var t=n(),i=Math.max(0,1e3/60-(t-u));u=i+t,setTimeout(function(){var e=d.slice(0);d.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(u)}catch(e){setTimeout(function(){throw e},0)}},Math.round(i))}return d.push({handle:++h,callback:e,cancelled:!1}),h},a=function(e){for(var t=0;t<d.length;t++)d[t].handle===e&&(d[t].cancelled=!0)}}var c=function(e){return s.call(i,e)};c.cancel=function(){a.apply(i,arguments)},c.polyfill=function(e){e||(e=i),e.requestAnimationFrame=s,e.cancelAnimationFrame=a};var m=c.cancel;function f(e,t){var n=Date.now(),i=c(function r(){Date.now()-n>=t?e():i=c(r)});return{clear:function(){return m(i)}}}function g(e){e&&e.clear()}function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(e,t){return!t||"object"!==I(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function b(e,t,n){return t&&w(e.prototype,t),n&&w(e,n),e}var C=function(){function e(t){y(this,e),this.element=t}return b(e,[{key:"getScrollY",value:function(){return this.element.scrollTop}},{key:"scrollTo",value:function(e,t){this.element.scrollTo(e,t)}},{key:"getWidth",value:function(){return this.element.offsetWidth}},{key:"getHeight",value:function(){return this.element.offsetHeight}},{key:"getContentHeight",value:function(){return this.element.scrollHeight}},{key:"getTopOffset",value:function(e){var t=this.element.getBoundingClientRect().top,n=this.element.clientTop;return e.getBoundingClientRect().top-t+this.getScrollY()-n}},{key:"addScrollListener",value:function(e){var t=this;return this.element.addEventListener("scroll",e),function(){return t.element.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e){var t,n=this;if("undefined"!=typeof ResizeObserver){var i=new ResizeObserver(function(t){var n=t,i=Array.isArray(n),r=0;for(n=i?n:n[Symbol.iterator]();;){if(i){if(r>=n.length)break;n[r++]}else{if((r=n.next()).done)break;r.value}return e()}});i.observe(this.element),t=function(){return i.unobserve(n.element)}}var r=(new x).onResize(e);return function(){t&&t(),r()}}}]),e}(),x=function(e){function t(){return y(this,t),v(this,p(t).call(this,window))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&S(e,t)}(t,C),b(t,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getContentHeight",value:function(){return document.documentElement.scrollHeight}},{key:"getTopOffset",value:function(e){var t=document.clientTop||document.body.clientTop||0;return e.getBoundingClientRect().top+this.getScrollY()-t}},{key:"onResize",value:function(e){return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}}]),t}();function H(e){return e.toFixed(2)+"px"}var R="It looks like you're using Internet Explorer which doesn't support CSS variables required for a <tbody/> container. VirtualScroller has been switched into \"bypass\" mode (render all items). See: https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1";function O(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function k(){if(A()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,O(["[virtual-scroller]"].concat(n)))}}function M(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i;"undefined"!=typeof window?(k.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw new Error(["[virtual-scroller]"].concat(t).join(" "))},0)):(i=console).error.apply(i,O(["[virtual-scroller]"].concat(t)))}function A(){return"undefined"!=typeof window&&window.VirtualScrollerDebug}function T(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var L=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getContainerElement=t,this.getState=n,this.initialize()}var t,n,i;return t=e,(n=[{key:"initialize",value:function(){this.reset(),this.getState()&&this.initializeFromState(this.getState())}},{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"initializeFromState",value:function(e){for(var t=e.itemHeights,n=0;n<t.length;){if(void 0===t[n]){if(void 0!==this.firstMeasuredItemIndex){this.lastMeasuredItemIndex=n-1;break}}else void 0===this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex=n),this.measuredItemsHeight+=t[n];n++}}},{key:"_measureItemHeight",value:function(e,t){var n=this.getContainerElement();if(n){var i=e-t;if(i>=0&&i<n.childNodes.length)return n.childNodes[i].getBoundingClientRect().height}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(e,t){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(k("Non-measured items gap detected. Reset first and last measured item indexes."),this.reset());for(var n=[],i=this.firstMeasuredItemIndex,r=this.lastMeasuredItemIndex,o=!1,s=e;s<=t;){if(void 0===this._get(s)){n.push(s),k("Item",s,"hasn't been previously measured");var a=this._measureItemHeight(s,e);k("Height",a),this._set(s,a),(void 0===i||s<i)&&(this.measuredItemsHeight+=a,o||(this.firstMeasuredItemIndex=s,o=!0)),(void 0===r||s>r)&&(void 0!==r&&(this.measuredItemsHeight+=a),this.lastMeasuredItemIndex=s)}else{var l=this._get(s),u=this._measureItemHeight(s,e);l!==u&&k("Item",s,"height has changed from",l,"to",u,"while it was shown, and \".onItemHeightChange(i)\" hasn't been called yet. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}s++}return n}},{key:"remeasureItemHeight",value:function(e,t){var n=this._get(e),i=this._measureItemHeight(e,t);return this._set(e,i),this.measuredItemsHeight+=i-n,i}},{key:"getAverage",value:function(){return void 0===this.lastMeasuredItemIndex?0:this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"_get",value:function(e){return this.getState().itemHeights[e]}},{key:"_set",value:function(e,t){this.getState().itemHeights[e]=t}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}])&&T(t.prototype,n),i&&T(t,i),e}();function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var P=Object.prototype.hasOwnProperty;function U(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){V(e,t,n[t])})}return e}function B(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function V(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var z=250,N=100,D=function(){function e(t,n){var i,r,o,s=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),V(this,"updateLayout",function(){return s.onUpdateShownItemIndexes({reason:j.MANUAL})}),V(this,"onScroll",function(){return s.onUpdateShownItemIndexes({reason:j.SCROLL})}),V(this,"restoreScrollPosition",function(){var e=s.getState().scrollY;void 0!==e&&s.scrollTo(0,e)}),V(this,"updateScrollPosition",function(){return s.getState().scrollY=s.getScrollY()}),V(this,"layout",function(){return s.updateLayout()}),V(this,"onResize",(i=function(e){if(s.isRendered){var t=s.shouldUpdateLayoutOnScrollableContainerResize(e);if("UPDATE_LAYOUT"===t){k("~ Scrollable container size changed, re-measure item heights. ~"),s.resized=!0;var n=s.getInitialLayoutState();k("Reset state to",n),s.setState(n)}else"UPDATE_SHOWN_ITEM_INDEXES"===t&&s.onUpdateShownItemIndexes({reason:"resize"})}},r=z,function(){for(var e=this,t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];clearTimeout(o),o=setTimeout(function(){return i.apply(e,n)},r)})),V(this,"willUpdateState",function(e,t){if(t&&s.preserveScrollPositionOnPrependItems){s.preserveScrollPositionOnPrependItems=void 0;var n=t.items,i=e.items,r=s.getItemsDiff(n,i);r&&s.captureScroll(n,i,r.prependedItemsCount)}}),V(this,"didUpdateState",function(e){var t=s.getState();if(s.onStateChange&&(function(e,t){if(U(e,t))return!0;if("object"!==E(e)||null===e||"object"!==E(t)||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!P.call(t,n[r])||!U(e[n[r]],t[n[r]]))return!1;return!0}(t,e)||s.onStateChange(t,e)),e&&s.isRendered){k("~ Rendered ~"),t.firstShownItemIndex===e.firstShownItemIndex&&t.lastShownItemIndex===e.lastShownItemIndex&&t.items===e.items||s.onRendered();var n=e.items,i=t.items;if(i!==n){var r=s.getItemsDiff(n,i);if(r){var o=r.prependedItemsCount;r.appendedItemsCount;o>0&&(s.itemHeights.onPrepend(o),void 0!==s.firstSeenItemIndex&&(s.firstSeenItemIndex+=o,s.lastSeenItemIndex+=o))}else s.itemHeights.initialize(),s.firstSeenItemIndex=void 0,s.lastSeenItemIndex=void 0;return s.updateSeenItemIndexes(),s.multiRenderLayout&&s.stopMultiRenderLayout(),s.onUpdateShownItemIndexes({reason:j.ITEMS_CHANGED})}return s.resized?(s.resized=void 0,k("~ Rendered (resize) ~"),s.multiRenderLayout&&s.stopMultiRenderLayout(),s.onUpdateShownItemIndexes({reason:"resize"})):s.multiRenderLayout?s.onMultiRenderLayoutRendered():void 0}}),V(this,"updateShownItemIndexes",function(){k("~ Layout results "+(s.bypass?"(bypass) ":"")+"~");var e=s.getShownItemIndexes(),t=e.firstShownItemIndex,n=e.lastShownItemIndex,i=e.redoLayoutAfterRender,r=s.getState().itemHeights,o=s.getBeforeItemsHeight(t,n,r),a=s.getAfterItemsHeight(t,n,r);s._getColumnsCount&&k("Columns count",s.getColumnsCount()),k("First shown item index",t),k("Last shown item index",n),k("Before items height",o),k("After items height (actual or estimated)",a),k("Average item height (calculated on previous render)",s.itemHeights.getAverage()),A()&&(k("Item heights",s.getState().itemHeights.slice()),k("Item states",s.getState().itemStates.slice())),i&&(k("Schedule a re-layout after the upcoming rerender"),s.redoLayoutAfterRender=!0),s.validateWillBeHiddenItemHeightsAndState(t,n),void 0!==s.firstSeenItemIndex&&(t>s.lastSeenItemIndex+1||n<s.firstSeenItemIndex-1)&&(s.firstSeenItemIndex=void 0,s.lastSeenItemIndex=void 0),s.onBeforeShowItems(s.getState().items,t,n,s.firstSeenItemIndex,s.lastSeenItemIndex),s.setState({firstShownItemIndex:t,lastShownItemIndex:n,beforeItemsHeight:o,afterItemsHeight:a})}),V(this,"updateShownItemIndexesRecursive",function(){s.multiRenderLayout=!0,s.updateShownItemIndexes()}),V(this,"restoreScroll",function(){var e=s.restoreScrollAfterPrepend,t=e.index,n=e.visibleAreaTop;s.restoreScrollAfterPrepend=void 0;var i=s.getItemElement(t).getBoundingClientRect().top-n;0!==i&&(k("Restore scroll position: scroll by",i),s.scrollTo(0,s.getScrollY()+i))}),V(this,"onUpdateShownItemIndexes",function(e){var t=e.reason;if(0!==s.getItemsCount()&&(!s.multiRenderLayout||t!==j.SCROLL)){if(g(s.onUserStopsScrollingTimeout),t===j.SCROLL){var n=void 0!==s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getScrollY()<s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getState().firstShownItemIndex>0||void 0!==s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getScrollY()+s.scrollableContainer.getHeight()>s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getState().lastShownItemIndex<s.getItemsCount()-1;if(k(n?"The user has scrolled far enough: force re-render":"The user hasn't scrolled too much: delay re-render"),!n)return s.onUserStopsScrollingTimeout=f(s.onUserStoppedScrolling,N)}k("~ Update layout (on ".concat(t,") ~")),s.updateShownItemIndexesRecursive()}}),V(this,"onUserStoppedScrolling",function(){s.isRendered&&s.updateLayout("stopped scrolling")});var l=a.getState,u=a.setState,h=a.onStateChange,d=a.customState,c=a.preserveScrollPositionAtBottomOnMount,m=a.shouldUpdateLayoutOnWindowResize,I=a.measureItemsBatchSize,v=a.getScrollableContainer,p=a.getColumnsCount,S=a.getItemId,y=a.tbody,w=a.bypass,b=a.estimatedItemHeight,H=a.onItemInitialRender,O=a.onItemFirstRender,T=a.scrollableContainer,B=a.preserveScrollPositionOfTheBottomOfTheListOnMount,D=a.state;k("~ Initialize ~"),D&&(n=D.items),!T&&v&&(T=v()),T?this.scrollableContainer=new C(T):"undefined"!=typeof window&&(this.scrollableContainer=new x),y&&(k("~ <tbody/> detected ~"),this.tbody=!0,"undefined"!=typeof window&&window.document.documentMode&&(k("~ <tbody/> not supported ~"),M(R),w=!0)),w&&k('~ "bypass" mode ~'),this.bypass=w,this.isItemEqual=S?function(e,t){return S(e)===S(t)}:function(e,t){return e===t},this.initialItems=n,this.estimatedItemHeight=b,this.onStateChange=h,this._shouldUpdateLayoutOnWindowResize=m,this.measureItemsBatchSize=void 0===I?50:I,this._getColumnsCount=p,H?this.onItemFirstRender=H:O&&(this.onItemFirstRender=function(e){console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=s.getState().items.indexOf(e);t>=0&&O(t)}),u?(this.getState=l,this.setState=function(e){return u(e,{willUpdateState:s.willUpdateState,didUpdateState:s.didUpdateState})}):(this.getState=function(){return s.state},this.setState=function(e){var t=s.getState(),n=_({},t,e);s.willUpdateState(n,t),s.state=n,s.didUpdateState(t)}),D&&k("Initial state (passed)",D),this.getContainerElement=t,t()&&function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}(t()),this.itemHeights=new L(this.getContainerElement,this.getState),this.scrollableContainer&&(c&&(console.warn("[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),B=c),B&&(this.preserveScrollPositionOfTheBottomOfTheListOnMount={scrollableContainerContentHeight:this.scrollableContainer.getContentHeight()})),this.setState(D||this.getInitialState(d)),k("Items count",n.length),b&&k("Estimated item height",b)}var t,n,i;return t=e,(n=[{key:"getInitialState",value:function(e){var t=this.initialItems.length,n=_({},e,this.getInitialLayoutState(),{items:this.initialItems,itemStates:new Array(t)});return k("Initial state (autogenerated)",n),k("First shown item index",n.firstShownItemIndex),k("Last shown item index",n.lastShownItemIndex),n}},{key:"getInitialLayoutState",value:function(){var e,t,n=this.initialItems,i=n.length,r=this._getColumnsCount?this._getColumnsCount(this.scrollableContainer):void 0;return i>0&&(e=0,t=this.getLastShownItemIndex(e,i,r||1)),this.preserveScrollPositionOfTheBottomOfTheListOnMount&&(e=0,t=i-1),this.onBeforeShowItems(n,e,t,this.firstSeenItemIndex,this.lastSeenItemIndex),{itemHeights:new Array(i),columnsCount:r,verticalSpacing:void 0,beforeItemsHeight:0,afterItemsHeight:0,firstShownItemIndex:e,lastShownItemIndex:t,scrollY:void 0}}},{key:"getEstimatedItemHeight",value:function(){return this.itemHeights&&this.itemHeights.getAverage()||this.estimatedItemHeight||0}},{key:"getVerticalSpacing",value:function(){return this.getState()&&this.getState().verticalSpacing||0}},{key:"getColumnsCount",value:function(){return this.getState()&&this.getState().columnsCount||1}},{key:"getEstimatedItemsCount",value:function(e){return this.getEstimatedRowsCount(e)*this.getColumnsCount()}},{key:"getEstimatedRowsCount",value:function(e){return this.getEstimatedItemHeight()?Math.ceil((e+this.getVerticalSpacing())/(this.getEstimatedItemHeight()+this.getVerticalSpacing())):1}},{key:"getEstimatedItemsCountOnScreen",value:function(e){return this.getEstimatedRowsCountOnScreen()*e}},{key:"getEstimatedRowsCountOnScreen",value:function(){return this.scrollableContainer?this.getEstimatedRowsCount(2*this.getMargin()+this.scrollableContainer.getHeight()):1}},{key:"getLastShownItemIndex",value:function(e,t,n){return this.bypass?t-1:Math.min(e+(this.getEstimatedItemsCountOnScreen(n)-1),t-1)}},{key:"getItemsCount",value:function(){return this.getState().items.length}},{key:"getMargin",value:function(){return 1*this.scrollableContainer.getHeight()}},{key:"onBeforeShowItems",value:function(e,t,n,i,r){var o=this.onItemFirstRender;if(o)if(void 0===i)for(var s=t;s<=n;)o(e[s]),s++;else{if(t<i)for(var a=t,l=Math.min(n,i-1),u=a;u<=l;)o(e[u]),u++;if(n>r)for(var h=n,d=Math.max(t,r+1);d<=h;)o(e[d]),d++}}},{key:"updateSeenItemIndexes",value:function(){var e=this.firstSeenItemIndex,t=this.lastSeenItemIndex,n=this.getState(),i=n.firstShownItemIndex,r=n.lastShownItemIndex;void 0===e?(e=i,t=r):(i<e&&(e=i),r>t&&(t=r)),this.firstSeenItemIndex=e,this.lastSeenItemIndex=t}},{key:"onMount",value:function(){console.warn("[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){console.warn("[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"listen",value:function(){if(!1===this.isRendered)throw new Error("[virtual-scroller] Can't restart a `VirtualScroller` after it has been stopped");k("~ Rendered (initial) ~"),this.isRendered=!0,this.onRendered(),this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.restoreScrollPosition(),this.updateScrollPosition(),this.removeScrollPositionListener=this.scrollableContainer.addScrollListener(this.updateScrollPosition),this.bypass||(this.removeScrollListener=this.scrollableContainer.addScrollListener(this.onScroll),this.scrollableContainerUnlistenResize=this.scrollableContainer.onResize(this.onResize)),this.tbody&&function(e){e.classList.add("VirtualScroller");var t=document.getElementById("VirtualScrollerStyle");t||((t=document.createElement("style")).id="VirtualScrollerStyle",t.innerText="\n\t\t\ttbody.VirtualScroller:before {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t\t}\n\t\t\ttbody.VirtualScroller:after {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t\t}\n\t\t".replace(/[\n\t]/g,""),document.head.appendChild(t))}(this.getContainerElement()),this.preserveScrollPositionOfTheBottomOfTheListOnMount?this.scrollTo(0,this.getScrollY()+(this.scrollableContainer.getContentHeight()-this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight)):this.onUpdateShownItemIndexes({reason:j.MOUNT})}},{key:"onRendered",value:function(){if(void 0===this.getState().verticalSpacing){k("~ Measure item vertical spacing ~");var e=this.measureVerticalSpacing();void 0===e?k("Not enough items rendered"):(k("Item vertical spacing",e),this.setState({verticalSpacing:e}))}this.measureNonPreviouslyMeasuredItemHeights(),this.tbody&&this.updateTbodyPadding()}},{key:"scrollTo",value:function(e,t){this.scrollableContainer.scrollTo(e,t)}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}},{key:"getHeight",value:function(){return this.getContainerElement().getBoundingClientRect().height}},{key:"getTopOffset",value:function(){return this.scrollableContainer.getTopOffset(this.getContainerElement())}},{key:"shouldUpdateLayoutOnScrollableContainerResize",value:function(e){if(e&&e.target===window){if(document.fullscreenElement&&this.getContainerElement().contains(document.fullscreenElement))return!1;if(this._shouldUpdateLayoutOnWindowResize&&!1===this._shouldUpdateLayoutOnWindowResize(e))return!1}var t=this.scrollableContainerWidth,n=this.scrollableContainerHeight;return this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.scrollableContainerWidth===t?this.scrollableContainerHeight!==n&&"UPDATE_SHOWN_ITEM_INDEXES":"UPDATE_LAYOUT"}},{key:"onUnmount",value:function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"stop",value:function(){this.isRendered=!1,this.removeScrollPositionListener(),this.bypass||(this.removeScrollListener(),this.scrollableContainerUnlistenResize(),g(this.onUserStopsScrollingTimeout),g(this.watchContainerElementCoordinatesTimer))}},{key:"updateTbodyPadding",value:function(){var e=this.getState(),t=e.beforeItemsHeight,n=e.afterItemsHeight;!function(e,t,n){e.style.setProperty("--VirtualScroller-paddingTop",H(t)),e.style.setProperty("--VirtualScroller-paddingBottom",H(n))}(this.getContainerElement(),t,n)}},{key:"measureVerticalSpacing",value:function(){var e=this.getContainerElement();if(e&&e.childNodes.length>1)for(var t=e.childNodes[0].getBoundingClientRect(),n=t.top,i=t.height,r=1;r<e.childNodes.length;){var o=e.childNodes[r].getBoundingClientRect(),s=o.top,a=o.height;if(s!==n)return s-(n+i);i=Math.max(i,a),r++}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(){var e=this.getState(),t=e.firstShownItemIndex,n=e.lastShownItemIndex;if(void 0!==t){k("~ Measure non-previously-measured items' heights ~");var i=this.itemHeights.measureNonPreviouslyMeasuredItemHeights(t,n);A()&&0===i.length&&k("All shown items have been previously measured")}}},{key:"remeasureItemHeight",value:function(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}},{key:"onItemStateChange",value:function(e,t){A()&&(k("~ Item state changed ~"),k("Item",e),k("Previous state\n"+JSON.stringify(this.getState().itemStates[e],null,2)),k("New state\n"+JSON.stringify(t,null,2))),this.getState().itemStates[e]=t}},{key:"onItemHeightChange",value:function(e){k("~ Re-measure item height ~"),k("Item",e);var t=this.getState().itemHeights[e];if(void 0===t)return M('"onItemHeightChange()" has been called for item '.concat(e,", but that item hasn't been rendered before."));var n=this.remeasureItemHeight(e);if(void 0===n)return k("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.");k("Previous height",t),k("New height",n),t!==n&&(k("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:j.ITEM_HEIGHT_CHANGED}))}},{key:"getItemCoordinates",value:function(e){for(var t=this.getState().itemHeights,n=this.getColumnsCount(),i=this.getTopOffset(),r=Math.floor(e/n),o=0;o<r;){for(var s=0,a=0;a<n;)s=Math.max(s,t[o*n+a]),a++;i+=s,i+=this.getVerticalSpacing(),o++}return{top:i,bottom:i+t[e],height:t[e]}}},{key:"_getVisibleItemIndexes",value:function(e,t,n){for(var i,r,o=0,s=this.getItemsCount(),a=this.getColumnsCount(),l=Math.ceil(s/a),u=0;u<l;){for(var h=s>(u+1)*a?this.getVerticalSpacing():0,d=0,c=0,m=void 0;c<a&&(m=u*a+c)<s;){var f=this.getState().itemHeights[m];if(void 0===f){k("Item index ".concat(m,' lies within the visible area or its "margins", but its height hasn\'t been measured yet. Mark the item as "shown", render the list, measure the item\'s height and redo the layout.')),void 0===i&&(i=u*a);var g=t-(n+o);return{firstNonMeasuredItemIndex:m,firstShownItemIndex:i,lastShownItemIndex:r=Math.min((u+this.getEstimatedRowsCount(g))*a-1,s-1)}}if(d=Math.max(d,f),void 0===i&&n+o+d>e&&(k("First shown row index",u),i=u*a),n+o+d+h>t)return k("Last shown row index",u),void 0!==i&&(r=Math.min((u+1)*a-1,s-1)),{firstShownItemIndex:i,lastShownItemIndex:r};c++}o+=d,o+=h,u++}return void 0!==i&&void 0===r&&k("Last item index (is fully visible)",r=s-1),{firstShownItemIndex:i,lastShownItemIndex:r}}},{key:"getVisibleItemIndexes",value:function(e,t,n){var i=this._getVisibleItemIndexes(e,t,n),r=i.firstNonMeasuredItemIndex,o=i.firstShownItemIndex,s=i.lastShownItemIndex,a=void 0!==r;if(this.restoreScrollAfterPrepend&&(s<this.restoreScrollAfterPrepend.index&&(s=this.restoreScrollAfterPrepend.index),a=!1),a&&this.measureItemsBatchSize){var l=this.getColumnsCount(),u=r+this.measureItemsBatchSize-1;s=Math.min(s,Math.ceil(u/l)*l-1)}return{firstShownItemIndex:o,lastShownItemIndex:s,redoLayoutAfterRender:a}}},{key:"getOffscreenListShownItemIndexes",value:function(){return{firstShownItemIndex:0,lastShownItemIndex:0,redoLayoutAfterRender:void 0===this.getState().itemHeights[0]}}},{key:"getItemIndexes",value:function(e,t,n,i){if(n+i>e&&n<t){var r=this.getVisibleItemIndexes(e,t,n);if(void 0!==r.firstShownItemIndex)return r;k("The entire list is off-screen. No items are visible.")}else k("The entire list is off-screen. No items are visible.")}},{key:"getBeforeItemsHeight",value:function(e,t,n){for(var i=this.getColumnsCount(),r=Math.floor(e/i),o=0,s=0;s<r;){for(var a=0,l=0;l<i;)a=Math.max(a,n[s*i+l]||this.itemHeights.getAverage()),l++;o+=a,o+=this.getVerticalSpacing(),s++}return o}},{key:"getAfterItemsHeight",value:function(e,t,n){for(var i=this.getItemsCount(),r=this.getColumnsCount(),o=Math.ceil(i/r),s=0,a=Math.floor(t/r)+1;a<o;){for(var l=0,u=0,h=void 0;u<r&&(h=a*r+u)<i;)l=Math.max(l,n[h]||this.itemHeights.getAverage()),u++;s+=this.getVerticalSpacing(),s+=l,a++}return s}},{key:"validateWillBeHiddenItemHeightsAndState",value:function(e,t){for(var n=this.getState().firstShownItemIndex;n<=this.getState().lastShownItemIndex;){if(n>=e&&n<=t);else{var i=this.getState().itemHeights[n],r=this.remeasureItemHeight(n);r!==i&&k("Item",n,"will be unmounted at next render. Its height has changed from",i,"to",r,"while it was shown. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}n++}}},{key:"watchContainerElementCoordinates",value:function(){var e=this,t=Date.now();!function n(){e.isRendered&&(void 0!==e.topOffset&&e.getTopOffset()!==e.topOffset&&e.onUpdateShownItemIndexes({reason:"top offset change"}),Date.now()-t<3e3&&(e.watchContainerElementCoordinatesTimer=f(n,500)))}()}},{key:"getShownItemIndexes",value:function(){if(this.bypass)return{firstShownItemIndex:0,lastShownItemIndex:this.getItemsCount()-1};var e=this.getTopOffset();void 0===this.topOffset&&this.watchContainerElementCoordinates(),this.topOffset=e;var t=this.getVisibleAreaBounds(),n=t.top,i=t.bottom;return this.latestLayoutVisibleAreaTopAfterIncludingMargin=n-this.getMargin(),this.latestLayoutVisibleAreaBottomAfterIncludingMargin=i+this.getMargin(),this.getItemIndexes(n-this.getMargin(),i+this.getMargin(),e,this.getHeight())||this.getOffscreenListShownItemIndexes()}},{key:"onMultiRenderLayoutRendered",value:function(){var e=this;if(this.redoLayoutAfterRender)return this.redoLayoutAfterRender=void 0,f(function(){e.isRendered&&e.updateShownItemIndexesRecursive()},0);this.stopMultiRenderLayout()}},{key:"stopMultiRenderLayout",value:function(){this.multiRenderLayout=void 0,this.redoLayoutAfterRender||this.restoreScrollAfterPrepend&&this.restoreScroll()}},{key:"captureScroll",value:function(e,t,n){0!==e.length&&0!==n&&(this.getState().firstShownItemIndex>0||this.restoreScrollAfterPrepend&&this.restoreScrollAfterPrepend.previousItems===e&&this.restoreScrollAfterPrepend.nextItems===t||(this.restoreScrollAfterPrepend={previousItems:e,nextItems:t,index:n,visibleAreaTop:this.getItemElement(0).getBoundingClientRect().top}))}},{key:"updateItems",value:function(e,t){return this.setItems(e,t)}},{key:"setItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getState().items,i=this.getState(),r=i.firstShownItemIndex,o=i.lastShownItemIndex,s=i.beforeItemsHeight,a=i.afterItemsHeight,l=i.itemStates,u=i.itemHeights,h=this.firstSeenItemIndex,d=this.lastSeenItemIndex;k("~ Update items ~");var c=this.getItemsDiff(n,e);if(c){var m=c.prependedItemsCount,f=c.appendedItemsCount;m>0&&(k("Prepend",m,"items"),u=new Array(m).concat(u),l&&(l=new Array(m).concat(l))),f>0&&(k("Append",f,"items"),u=u.concat(new Array(f)),l&&(l=l.concat(new Array(f)))),r+=m,o+=m,void 0!==h&&(h+=m,d+=m);this.getVerticalSpacing();var g=this.getColumnsCount();if(m%g==0){var I=m/g,v=Math.ceil(f/g);s+=I*(this.itemHeights.getAverage()+this.getVerticalSpacing()),a+=v*(this.getVerticalSpacing()+this.itemHeights.getAverage())}else s=this.getBeforeItemsHeight(r,o,u),a=this.getAfterItemsHeight(r,o,u)}else k("Items have changed, and it's not a simple append and/or prepend: rerender the entire list from scratch."),k("Previous items",n),k("New items",e),h=void 0,d=void 0,u=new Array(e.length),l=new Array(e.length),0===e.length?(r=void 0,o=void 0):(r=0,o=this.getLastShownItemIndex(r,e.length,this.getColumnsCount())),s=0,a=0;k("First shown item index",r),k("Last shown item index",o),k("Before items height",s),k("After items height (actual or estimated)",a),this.onBeforeShowItems(e,r,o,h,d),this.preserveScrollPositionOnPrependItems=t.preserveScrollPositionOnPrependItems||t.preserveScrollPosition,this.setState({items:e,itemStates:l,itemHeights:u,firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:s,afterItemsHeight:a})}},{key:"getItemsDiff",value:function(e,t){return function(e,t,n){var i=-1,r=-1;e.length>0&&(i=function(e,t,n){var i=0;for(;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n))>=0&&function(e,t,n,i){var r=0;for(;r<e.length;){if(t.length<=n+r||!i(t[n+r],e[r]))return!1;r++}return!0}(e,t,i,n)&&(r=i+e.length-1);if(i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(e,t,this.isItemEqual)}},{key:"getItemElement",value:function(e){return this.getContainerElement().childNodes[e]}}])&&B(t.prototype,n),i&&B(t,i),e}();var j={SCROLL:"scroll",MANUAL:"manual",ITEM_HEIGHT_CHANGED:"item height changed",ITEMS_CHANGED:"items changed",MOUNT:"mount"};return D});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).VirtualScroller=t()}(this,function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var t,n=(function(t){(function(){var e,n,i,r,o,s;"undefined"!=typeof performance&&null!==performance&&performance.now?t.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(t.exports=function(){return(e()-o)/1e6},n=process.hrtime,r=(e=function(){var e;return 1e9*(e=n())[0]+e[1]})(),s=1e9*process.uptime(),o=r-s):Date.now?(t.exports=function(){return Date.now()-i},i=Date.now()):(t.exports=function(){return(new Date).getTime()-i},i=(new Date).getTime())}).call(e)}(t={exports:{}},t.exports),t.exports),i="undefined"==typeof window?e:window,r=["moz","webkit"],o="AnimationFrame",s=i["request"+o],a=i["cancel"+o]||i["cancelRequest"+o],l=0;!s&&l<r.length;l++)s=i[r[l]+"Request"+o],a=i[r[l]+"Cancel"+o]||i[r[l]+"CancelRequest"+o];if(!s||!a){var u=0,h=0,c=[];s=function(e){if(0===c.length){var t=n(),i=Math.max(0,1e3/60-(t-u));u=i+t,setTimeout(function(){var e=c.slice(0);c.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(u)}catch(e){setTimeout(function(){throw e},0)}},Math.round(i))}return c.push({handle:++h,callback:e,cancelled:!1}),h},a=function(e){for(var t=0;t<c.length;t++)c[t].handle===e&&(c[t].cancelled=!0)}}var d=function(e){return s.call(i,e)};d.cancel=function(){a.apply(i,arguments)},d.polyfill=function(e){e||(e=i),e.requestAnimationFrame=s,e.cancelAnimationFrame=a};var m=d.cancel;function f(e,t){var n=Date.now(),i=d(function r(){Date.now()-n>=t?e():i=d(r)});return{clear:function(){return m(i)}}}function g(e){e&&e.clear()}function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(e,t){return!t||"object"!==I(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function b(e,t,n){return t&&w(e.prototype,t),n&&w(e,n),e}var C=function(){function e(t){y(this,e),this.element=t}return b(e,[{key:"getScrollY",value:function(){return this.element.scrollTop}},{key:"scrollTo",value:function(e,t){this.element.scrollTo(e,t)}},{key:"getWidth",value:function(){return this.element.offsetWidth}},{key:"getHeight",value:function(){return this.element.offsetHeight}},{key:"getContentHeight",value:function(){return this.element.scrollHeight}},{key:"getTopOffset",value:function(e){var t=this.element.getBoundingClientRect().top,n=this.element.clientTop;return e.getBoundingClientRect().top-t+this.getScrollY()-n}},{key:"addScrollListener",value:function(e){var t=this;return this.element.addEventListener("scroll",e),function(){return t.element.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e){var t,n=this;if("undefined"!=typeof ResizeObserver){var i=new ResizeObserver(function(t){var n=t,i=Array.isArray(n),r=0;for(n=i?n:n[Symbol.iterator]();;){if(i){if(r>=n.length)break;n[r++]}else{if((r=n.next()).done)break;r.value}return e()}});i.observe(this.element),t=function(){return i.unobserve(n.element)}}var r=(new x).onResize(e);return function(){t&&t(),r()}}}]),e}(),x=function(e){function t(){return y(this,t),v(this,p(t).call(this,window))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&S(e,t)}(t,C),b(t,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getContentHeight",value:function(){return document.documentElement.scrollHeight}},{key:"getTopOffset",value:function(e){var t=document.clientTop||document.body.clientTop||0;return e.getBoundingClientRect().top+this.getScrollY()-t}},{key:"onResize",value:function(e){return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}}]),t}();function H(e){return e.toFixed(2)+"px"}var T="It looks like you're using Internet Explorer which doesn't support CSS variables required for a <tbody/> container. VirtualScroller has been switched into \"bypass\" mode (render all items). See: https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1";function R(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function O(){if(A()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,R(["[virtual-scroller]"].concat(n)))}}function E(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i;"undefined"!=typeof window?(O.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw new Error(["[virtual-scroller]"].concat(t).join(" "))},0)):(i=console).error.apply(i,R(["[virtual-scroller]"].concat(t)))}function A(){return"undefined"!=typeof window&&window.VirtualScrollerDebug}function k(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var M=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getContainerElement=t,this.getState=n,this.initialize()}var t,n,i;return t=e,(n=[{key:"initialize",value:function(){this.reset(),this.getState()&&this.initializeFromState(this.getState())}},{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"initializeFromState",value:function(e){for(var t=e.itemHeights,n=0;n<t.length;){if(void 0===t[n]){if(void 0!==this.firstMeasuredItemIndex){this.lastMeasuredItemIndex=n-1;break}}else void 0===this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex=n),this.measuredItemsHeight+=t[n];n++}}},{key:"_measureItemHeight",value:function(e,t){var n=this.getContainerElement();if(n){var i=e-t;if(i>=0&&i<n.childNodes.length)return n.childNodes[i].getBoundingClientRect().height}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(e,t){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(O("Non-measured items gap detected. Reset first and last measured item indexes."),this.reset());for(var n=[],i=this.firstMeasuredItemIndex,r=this.lastMeasuredItemIndex,o=!1,s=e;s<=t;){if(void 0===this._get(s)){n.push(s),O("Item",s,"hasn't been previously measured");var a=this._measureItemHeight(s,e);O("Height",a),this._set(s,a),(void 0===i||s<i)&&(this.measuredItemsHeight+=a,o||(this.firstMeasuredItemIndex=s,o=!0)),(void 0===r||s>r)&&(void 0!==r&&(this.measuredItemsHeight+=a),this.lastMeasuredItemIndex=s)}else{var l=this._get(s),u=this._measureItemHeight(s,e);l!==u&&O("Item",s,"height has changed from",l,"to",u,"while it was shown, and \".onItemHeightChange(i)\" hasn't been called yet. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}s++}return n}},{key:"remeasureItemHeight",value:function(e,t){var n=this._get(e),i=this._measureItemHeight(e,t);return this._set(e,i),this.measuredItemsHeight+=i-n,i}},{key:"getAverage",value:function(){return void 0===this.lastMeasuredItemIndex?0:this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"_get",value:function(e){return this.getState().itemHeights[e]}},{key:"_set",value:function(e,t){this.getState().itemHeights[e]=t}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}])&&k(t.prototype,n),i&&k(t,i),e}();function L(e){return(L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var _=Object.prototype.hasOwnProperty;function P(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function V(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){B(e,t,n[t])})}return e}function U(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function B(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var N=250,z=100,D=function(){function e(t,n){var i,r,o,s=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),B(this,"updateLayout",function(){return s.onUpdateShownItemIndexes({reason:j.MANUAL})}),B(this,"onScroll",function(){return s.onUpdateShownItemIndexes({reason:j.SCROLL})}),B(this,"restoreScrollPositionFromState",function(){var e=s.getState().scrollY;void 0!==e&&s.scrollTo(0,e)}),B(this,"updateScrollPosition",function(){return s.getState().scrollY=s.getScrollY()}),B(this,"layout",function(){return s.updateLayout()}),B(this,"onResize",(i=function(e){if(s.isRendered){var t=s.shouldUpdateLayoutOnScrollableContainerResize(e);if("UPDATE_LAYOUT"===t){O("~ Scrollable container size changed, re-measure item heights. ~"),s.redoLayoutReason=j.RESIZE;var n=s.getInitialLayoutState();O("Reset state to",n),s.setState(n)}else"UPDATE_SHOWN_ITEM_INDEXES"===t&&s.onUpdateShownItemIndexes({reason:j.RESIZE})}},r=N,function(){for(var e=this,t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];clearTimeout(o),o=setTimeout(function(){return i.apply(e,n)},r)})),B(this,"willUpdateState",function(e,t){}),B(this,"didUpdateState",function(e){var t=s.getState();if(s.onStateChange&&(function(e,t){if(P(e,t))return!0;if("object"!==L(e)||null===e||"object"!==L(t)||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r<n.length;r++)if(!_.call(t,n[r])||!P(e[n[r]],t[n[r]]))return!1;return!0}(t,e)||s.onStateChange(t,e)),e&&s.isRendered){O("~ Rendered ~");var n=s.redoLayoutReason;s.redoLayoutReason=void 0;var i=e.items,r=t.items;if(r!==i){var o=!0,a=s.getItemsDiff(i,r);if(a){var l=a.prependedItemsCount;a.appendedItemsCount;l>0&&(s.itemHeights.onPrepend(l),s.restoreScrollAfterRenderValues&&(o=!1,s.restoreScrollAfterRender()))}else s.itemHeights.initialize();o&&(n=j.ITEMS_CHANGED)}return t.firstShownItemIndex===e.firstShownItemIndex&&t.lastShownItemIndex===e.lastShownItemIndex&&t.items===e.items||s.onRendered(),n?s.redoLayoutRightAfterRender({reason:n}):void 0}}),B(this,"updateShownItemIndexes",function(){O("~ Layout results "+(s.bypass?"(bypass) ":"")+"~");var e=s.getShownItemIndexes(),t=e.firstShownItemIndex,n=e.lastShownItemIndex,i=e.redoLayoutAfterMeasuringItemHeights,r=s.getState().itemHeights,o=s.getBeforeItemsHeight(t,n,r),a=s.getAfterItemsHeight(t,n,r);s._getColumnsCount&&O("Columns count",s.getColumnsCount()),O("First shown item index",t),O("Last shown item index",n),O("Before items height",o),O("After items height (actual or estimated)",a),O("Average item height (calculated on previous render)",s.itemHeights.getAverage()),A()&&(O("Item heights",s.getState().itemHeights.slice()),O("Item states",s.getState().itemStates.slice())),i&&(s.redoLayoutReason=j.ITEM_HEIGHT_NOT_MEASURED),s.validateWillBeHiddenItemHeightsAndState(t,n),s.onBeforeShowItems(s.getState().items,s.getState().itemHeights,t,n),s.setState({firstShownItemIndex:t,lastShownItemIndex:n,beforeItemsHeight:o,afterItemsHeight:a})}),B(this,"updateShownItemIndexesRecursive",function(){s.layoutInProgress=!0,s.updateShownItemIndexes()}),B(this,"onUpdateShownItemIndexes",function(e){var t=e.reason;if(0!==s.getItemsCount()){if(s.onUserStopsScrollingTimer&&(g(s.onUserStopsScrollingTimer),s.onUserStopsScrollingTimer=void 0),t===j.SCROLL){var n=void 0!==s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getScrollY()<s.latestLayoutVisibleAreaTopAfterIncludingMargin&&s.getState().firstShownItemIndex>0||void 0!==s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getScrollY()+s.scrollableContainer.getHeight()>s.latestLayoutVisibleAreaBottomAfterIncludingMargin&&s.getState().lastShownItemIndex<s.getItemsCount()-1;if(O(n?"The user has scrolled far enough: force re-render":"The user hasn't scrolled too much: delay re-render"),!n){if(s.layoutTimer)return;return void(s.onUserStopsScrollingTimer=f(function(){s.isRendered&&s.onUpdateShownItemIndexes({reason:j.STOPPED_SCROLLING})},z))}}s.layoutTimer&&(g(s.layoutTimer),s.layoutTimer=void 0),O("~ Calculate Layout (on ".concat(t,") ~")),s.updateShownItemIndexesRecursive()}});var l=a.getState,u=a.setState,h=a.onStateChange,c=a.customState,d=a.preserveScrollPositionAtBottomOnMount,m=a.shouldUpdateLayoutOnWindowResize,I=a.measureItemsBatchSize,v=a.getScrollableContainer,p=a.getColumnsCount,S=a.getItemId,y=a.tbody,w=a._useTimeoutInRenderLoop,b=a.bypass,H=a.estimatedItemHeight,R=a.onItemInitialRender,k=a.onItemFirstRender,U=a.scrollableContainer,D=a.preserveScrollPositionOfTheBottomOfTheListOnMount,F=a.state;O("~ Initialize ~"),F&&(n=F.items),!U&&v&&(U=v()),U?this.scrollableContainer=new C(U):"undefined"!=typeof window&&(this.scrollableContainer=new x),y&&(O("~ <tbody/> detected ~"),this.tbody=!0,"undefined"!=typeof window&&window.document.documentMode&&(O("~ <tbody/> not supported ~"),E(T),b=!0)),b&&O('~ "bypass" mode ~'),this.bypass=b,this._useTimeoutInRenderLoop=w,this.isItemEqual=S?function(e,t){return S(e)===S(t)}:function(e,t){return e===t},this.initialItems=n,this.estimatedItemHeight=H,this.onStateChange=h,this._shouldUpdateLayoutOnWindowResize=m,this.measureItemsBatchSize=void 0===I?50:I,this._getColumnsCount=p,R?this.onItemInitialRender=R:k&&(this.onItemInitialRender=function(e){console.warn("[virtual-scroller] `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=s.getState().items.indexOf(e);t>=0&&k(t)}),O("Items count",n.length),H&&O("Estimated item height",H),u?(this.getState=l,this.setState=function(e){O("Set state",e),u(e,{willUpdateState:s.willUpdateState,didUpdateState:s.didUpdateState})}):(this.getState=function(){return s.state},this.setState=function(e){O("Set state",e);var t=s.getState(),n=V({},t,e);s.willUpdateState(n,t),s.state=n,s.didUpdateState(t)}),F&&O("Initial state (passed)",F),this.getContainerElement=t,t()&&function(e){for(;e.firstChild;)e.removeChild(e.firstChild)}(t()),this.itemHeights=new M(this.getContainerElement,this.getState),this.scrollableContainer&&(d&&(console.warn("[virtual-scroller] `preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`"),D=d),D&&(this.preserveScrollPositionOfTheBottomOfTheListOnMount={scrollableContainerContentHeight:this.scrollableContainer.getContentHeight()})),this.setState(F||this.getInitialState(c))}var t,n,i;return t=e,(n=[{key:"getInitialState",value:function(e){var t=this.initialItems.length,n=V({},e,this.getInitialLayoutState(),{items:this.initialItems,itemStates:new Array(t)});return O("Initial state (autogenerated)",n),O("First shown item index",n.firstShownItemIndex),O("Last shown item index",n.lastShownItemIndex),n}},{key:"getInitialLayoutState",value:function(){var e,t,n=this.initialItems,i=n.length,r=this._getColumnsCount?this._getColumnsCount(this.scrollableContainer):void 0;i>0&&(e=0,t=this.getLastShownItemIndex(e,i,r||1)),this.preserveScrollPositionOfTheBottomOfTheListOnMount&&(e=0,t=i-1);var o=new Array(i);return this.onBeforeShowItems(n,o,e,t),{itemHeights:o,columnsCount:r,verticalSpacing:void 0,beforeItemsHeight:0,afterItemsHeight:0,firstShownItemIndex:e,lastShownItemIndex:t,scrollY:void 0}}},{key:"getEstimatedItemHeight",value:function(){return this.itemHeights&&this.itemHeights.getAverage()||this.estimatedItemHeight||0}},{key:"getVerticalSpacing",value:function(){return this.getState()&&this.getState().verticalSpacing||0}},{key:"getColumnsCount",value:function(){return this.getState()&&this.getState().columnsCount||1}},{key:"getEstimatedItemsCount",value:function(e){return this.getEstimatedRowsCount(e)*this.getColumnsCount()}},{key:"getEstimatedRowsCount",value:function(e){return this.getEstimatedItemHeight()?Math.ceil((e+this.getVerticalSpacing())/(this.getEstimatedItemHeight()+this.getVerticalSpacing())):1}},{key:"getEstimatedItemsCountOnScreen",value:function(e){return this.getEstimatedRowsCountOnScreen()*e}},{key:"getEstimatedRowsCountOnScreen",value:function(){return this.scrollableContainer?this.getEstimatedRowsCount(2*this.getMargin()+this.scrollableContainer.getHeight()):1}},{key:"getLastShownItemIndex",value:function(e,t,n){return this.bypass?t-1:Math.min(e+(this.getEstimatedItemsCountOnScreen(n)-1),t-1)}},{key:"getItemsCount",value:function(){return this.getState().items.length}},{key:"getMargin",value:function(){return 1*this.scrollableContainer.getHeight()}},{key:"onBeforeShowItems",value:function(e,t,n,i){if(this.onItemInitialRender)for(var r=n;r<=i;)void 0===t[r]&&this.onItemInitialRender(e[r]),r++}},{key:"onMount",value:function(){console.warn("[virtual-scroller] `.onMount()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"render",value:function(){console.warn("[virtual-scroller] `.render()` instance method name is deprecated, use `.listen()` instance method name instead."),this.listen()}},{key:"listen",value:function(){if(!1===this.isRendered)throw new Error("[virtual-scroller] Can't restart a `VirtualScroller` after it has been stopped");O("~ Rendered (initial) ~"),this.isRendered=!0,this.onRendered(),this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.restoreScrollPositionFromState(),this.updateScrollPosition(),this.removeScrollPositionListener=this.scrollableContainer.addScrollListener(this.updateScrollPosition),this.bypass||(this.removeScrollListener=this.scrollableContainer.addScrollListener(this.onScroll),this.scrollableContainerUnlistenResize=this.scrollableContainer.onResize(this.onResize)),this.tbody&&function(e){e.classList.add("VirtualScroller");var t=document.getElementById("VirtualScrollerStyle");t||((t=document.createElement("style")).id="VirtualScrollerStyle",t.innerText="\n\t\t\ttbody.VirtualScroller:before {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t\t}\n\t\t\ttbody.VirtualScroller:after {\n\t\t\t\tcontent: '';\n\t\t\t\tdisplay: table-row;\n\t\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t\t}\n\t\t".replace(/[\n\t]/g,""),document.head.appendChild(t))}(this.getContainerElement()),this.preserveScrollPositionOfTheBottomOfTheListOnMount?this.scrollTo(0,this.getScrollY()+(this.scrollableContainer.getContentHeight()-this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight)):this.onUpdateShownItemIndexes({reason:j.MOUNT})}},{key:"onRendered",value:function(){this.measureVerticalSpacing(),this.measureNonPreviouslyMeasuredItemHeights(),this.tbody&&this.updateTbodyPadding()}},{key:"scrollTo",value:function(e,t){this.scrollableContainer.scrollTo(e,t)}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}},{key:"getHeight",value:function(){return this.getContainerElement().getBoundingClientRect().height}},{key:"getTopOffset",value:function(){return this.scrollableContainer.getTopOffset(this.getContainerElement())}},{key:"shouldUpdateLayoutOnScrollableContainerResize",value:function(e){if(e&&e.target===window){if(document.fullscreenElement&&this.getContainerElement().contains(document.fullscreenElement))return!1;if(this._shouldUpdateLayoutOnWindowResize&&!1===this._shouldUpdateLayoutOnWindowResize(e))return!1}var t=this.scrollableContainerWidth,n=this.scrollableContainerHeight;return this.scrollableContainerWidth=this.scrollableContainer.getWidth(),this.scrollableContainerHeight=this.scrollableContainer.getHeight(),this.scrollableContainerWidth===t?this.scrollableContainerHeight!==n&&"UPDATE_SHOWN_ITEM_INDEXES":"UPDATE_LAYOUT"}},{key:"onUnmount",value:function(){console.warn("[virtual-scroller] `.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"destroy",value:function(){console.warn("[virtual-scroller] `.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),this.stop()}},{key:"stop",value:function(){this.isRendered=!1,this.removeScrollPositionListener(),this.bypass||(this.removeScrollListener(),this.scrollableContainerUnlistenResize(),g(this.onUserStopsScrollingTimer),g(this.watchContainerElementCoordinatesTimer),g(this.layoutTimer))}},{key:"redoLayoutRightAfterRender",value:function(e){var t=this,n=e.reason;this._useTimeoutInRenderLoop?(this.layoutTimer&&g(this.layoutTimer),this.layoutTimer=f(function(){t.layoutTimer=void 0,t.onUpdateShownItemIndexes({reason:n})},0)):this.onUpdateShownItemIndexes({reason:n})}},{key:"updateTbodyPadding",value:function(){var e=this.getState(),t=e.beforeItemsHeight,n=e.afterItemsHeight;!function(e,t,n){e.style.setProperty("--VirtualScroller-paddingTop",H(t)),e.style.setProperty("--VirtualScroller-paddingBottom",H(n))}(this.getContainerElement(),t,n)}},{key:"measureVerticalSpacing",value:function(){if(void 0===this.getState().verticalSpacing){O("~ Measure item vertical spacing ~");var e=this.measureVerticalSpacingValue();void 0===e?O("Not enough items rendered to measure vertical spacing"):(O("Item vertical spacing",e),this.setState({verticalSpacing:e}))}}},{key:"measureVerticalSpacingValue",value:function(){var e=this.getContainerElement();if(e&&e.childNodes.length>1)for(var t=e.childNodes[0].getBoundingClientRect(),n=t.top,i=t.height,r=1;r<e.childNodes.length;){var o=e.childNodes[r].getBoundingClientRect(),s=o.top,a=o.height;if(s!==n)return s-(n+i);i=Math.max(i,a),r++}}},{key:"measureNonPreviouslyMeasuredItemHeights",value:function(){var e=this.getState(),t=e.firstShownItemIndex,n=e.lastShownItemIndex;if(void 0!==t)this.itemHeights.measureNonPreviouslyMeasuredItemHeights(t,n)}},{key:"remeasureItemHeight",value:function(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}},{key:"onItemStateChange",value:function(e,t){A()&&(O("~ Item state changed ~"),O("Item",e),O("Previous state\n"+JSON.stringify(this.getState().itemStates[e],null,2)),O("New state\n"+JSON.stringify(t,null,2))),this.getState().itemStates[e]=t}},{key:"onItemHeightChange",value:function(e){O("~ Re-measure item height ~"),O("Item",e);var t=this.getState().itemHeights[e];if(void 0===t)return E('"onItemHeightChange()" has been called for item '.concat(e,", but that item hasn't been rendered before."));var n=this.remeasureItemHeight(e);if(void 0===n)return O("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.");O("Previous height",t),O("New height",n),t!==n&&(O("~ Item height has changed ~"),this.onUpdateShownItemIndexes({reason:j.ITEM_HEIGHT_CHANGED}))}},{key:"getItemCoordinates",value:function(e){for(var t=this.getState().itemHeights,n=this.getColumnsCount(),i=this.getTopOffset(),r=Math.floor(e/n),o=0;o<r;){for(var s=0,a=0;a<n;)s=Math.max(s,t[o*n+a]),a++;i+=s,i+=this.getVerticalSpacing(),o++}return{top:i,bottom:i+t[e],height:t[e]}}},{key:"_getVisibleItemIndexes",value:function(e,t,n){for(var i,r,o=0,s=this.getItemsCount(),a=this.getColumnsCount(),l=Math.ceil(s/a),u=0;u<l;){for(var h=s>(u+1)*a?this.getVerticalSpacing():0,c=0,d=0,m=void 0;d<a&&(m=u*a+d)<s;){var f=this.getState().itemHeights[m];if(void 0===f){O("Item index ".concat(m,' lies within the visible area or its "margins", but its height hasn\'t been measured yet. Mark the item as "shown", render the list, measure the item\'s height and redo the layout.')),void 0===i&&(i=u*a);var g=t-(n+o);return{firstNonMeasuredItemIndex:m,firstShownItemIndex:i,lastShownItemIndex:r=Math.min((u+this.getEstimatedRowsCount(g))*a-1,s-1)}}if(c=Math.max(c,f),void 0===i&&n+o+c>e&&(O("First shown row index",u),i=u*a),n+o+c+h>t)return O("Last shown row index",u),void 0!==i&&(r=Math.min((u+1)*a-1,s-1)),{firstShownItemIndex:i,lastShownItemIndex:r};d++}o+=c,o+=h,u++}return void 0!==i&&void 0===r&&O("Last item index (is fully visible)",r=s-1),{firstShownItemIndex:i,lastShownItemIndex:r}}},{key:"getVisibleItemIndexes",value:function(e,t,n){var i=this._getVisibleItemIndexes(e,t,n),r=i.firstNonMeasuredItemIndex,o=i.firstShownItemIndex,s=i.lastShownItemIndex,a=void 0!==r;if(this.restoreScrollAfterRenderValues&&(s<this.restoreScrollAfterRenderValues.index&&(s=this.restoreScrollAfterRenderValues.index),a=!1),a&&this.measureItemsBatchSize){var l=this.getColumnsCount(),u=r+this.measureItemsBatchSize-1;s=Math.min(s,Math.ceil(u/l)*l-1)}return{firstShownItemIndex:o,lastShownItemIndex:s,redoLayoutAfterMeasuringItemHeights:a}}},{key:"getOffscreenListShownItemIndexes",value:function(){return{firstShownItemIndex:0,lastShownItemIndex:0,redoLayoutAfterMeasuringItemHeights:void 0===this.getState().itemHeights[0]}}},{key:"getItemIndexes",value:function(e,t,n,i){if(n+i>e&&n<t){var r=this.getVisibleItemIndexes(e,t,n);if(void 0!==r.firstShownItemIndex)return r;O("The entire list is off-screen. No items are visible.")}else O("The entire list is off-screen. No items are visible.")}},{key:"getBeforeItemsHeight",value:function(e,t,n){for(var i=this.getColumnsCount(),r=Math.floor(e/i),o=0,s=0;s<r;){for(var a=0,l=0;l<i;)a=Math.max(a,n[s*i+l]||this.itemHeights.getAverage()),l++;o+=a,o+=this.getVerticalSpacing(),s++}return o}},{key:"getAfterItemsHeight",value:function(e,t,n){for(var i=this.getItemsCount(),r=this.getColumnsCount(),o=Math.ceil(i/r),s=0,a=Math.floor(t/r)+1;a<o;){for(var l=0,u=0,h=void 0;u<r&&(h=a*r+u)<i;)l=Math.max(l,n[h]||this.itemHeights.getAverage()),u++;s+=this.getVerticalSpacing(),s+=l,a++}return s}},{key:"validateWillBeHiddenItemHeightsAndState",value:function(e,t){for(var n=this.getState().firstShownItemIndex;n<=this.getState().lastShownItemIndex;){if(n>=e&&n<=t);else{var i=this.getState().itemHeights[n],r=this.remeasureItemHeight(n);r!==i&&O("Item",n,"will be unmounted at next render. Its height has changed from",i,"to",r,"while it was shown. This is not necessarily a bug, and could happen, for example, when there're several `onItemHeightChange(i)` calls issued at the same time.")}n++}}},{key:"watchContainerElementCoordinates",value:function(){var e=this,t=Date.now();!function n(){e.isRendered&&(void 0!==e.topOffset&&e.getTopOffset()!==e.topOffset&&e.onUpdateShownItemIndexes({reason:j.TOP_OFFSET_CHANGED}),Date.now()-t<3e3&&(e.watchContainerElementCoordinatesTimer=f(n,500)))}()}},{key:"getShownItemIndexes",value:function(){if(this.bypass)return{firstShownItemIndex:0,lastShownItemIndex:this.getItemsCount()-1};var e=this.getTopOffset();void 0===this.topOffset&&this.watchContainerElementCoordinates(),this.topOffset=e;var t=this.getVisibleAreaBounds(),n=t.top,i=t.bottom;return this.latestLayoutVisibleAreaTopAfterIncludingMargin=n-this.getMargin(),this.latestLayoutVisibleAreaBottomAfterIncludingMargin=i+this.getMargin(),this.getItemIndexes(n-this.getMargin(),i+this.getMargin(),e,this.getHeight())||this.getOffscreenListShownItemIndexes()}},{key:"captureScroll",value:function(e,t,n){if(0!==e.length&&0!==n){var i=this.getState().firstShownItemIndex,r=this.getItemElement(0).getBoundingClientRect().top;if(i>0){var o=this.getState(),s=(o.verticalSpacing,o.itemHeights);r=this.getItemElement(0).getBoundingClientRect().top;for(var a=i-1;a>=0;)r+=s[a]+this.getVerticalSpacing(),a--}this.restoreScrollAfterRenderValues&&this.restoreScrollAfterRenderValues.previousItems===e&&this.restoreScrollAfterRenderValues.nextItems===t||(this.restoreScrollAfterRenderValues={previousItems:e,nextItems:t,index:n,visibleAreaTop:r})}}},{key:"restoreScrollAfterRender",value:function(){O("~ Restore Scroll Position ~");var e=this.restoreScrollAfterRenderValues,t=e.index,n=e.visibleAreaTop;this.restoreScrollAfterRenderValues=void 0;var i=this.getItemElement(t).getBoundingClientRect().top-n;0===i?O("Scroll position hasn't changed"):(O("Scroll down by",i),this.scrollTo(0,this.getScrollY()+i))}},{key:"updateItems",value:function(e,t){return this.setItems(e,t)}},{key:"setItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getState().items,i=this.getState(),r=i.firstShownItemIndex,o=i.lastShownItemIndex,s=i.beforeItemsHeight,a=i.afterItemsHeight,l=i.itemStates,u=i.itemHeights;O("~ Update items ~");var h=this.getItemsDiff(n,e);if(h){var c=h.prependedItemsCount,d=h.appendedItemsCount;c>0&&(O("Prepend",c,"items"),u=new Array(c).concat(u),l&&(l=new Array(c).concat(l))),d>0&&(O("Append",d,"items"),u=u.concat(new Array(d)),l&&(l=l.concat(new Array(d)))),r+=c,o+=c;this.getVerticalSpacing();var m=this.getColumnsCount();if(c%m==0){var f=c/m,g=Math.ceil(d/m);s+=f*(this.itemHeights.getAverage()+this.getVerticalSpacing()),a+=g*(this.getVerticalSpacing()+this.itemHeights.getAverage())}else s=this.getBeforeItemsHeight(r,o,u),a=this.getAfterItemsHeight(r,o,u);c>0&&(t.preserveScrollPositionOnPrependItems||t.preserveScrollPosition)&&(r=0,s=0,this.captureScroll(n,e,c))}else O("Items have changed, and it's not a simple append and/or prepend: rerender the entire list from scratch."),O("Previous items",n),O("New items",e),u=new Array(e.length),l=new Array(e.length),0===e.length?(r=void 0,o=void 0):(r=0,o=this.getLastShownItemIndex(r,e.length,this.getColumnsCount())),s=0,a=0;O("~ Update state ~"),O("First shown item index",r),O("Last shown item index",o),O("Before items height",s),O("After items height (actual or estimated)",a),this.onBeforeShowItems(e,u,r,o),this.setState({items:e,itemStates:l,itemHeights:u,firstShownItemIndex:r,lastShownItemIndex:o,beforeItemsHeight:s,afterItemsHeight:a})}},{key:"getItemsDiff",value:function(e,t){return function(e,t,n){var i=-1,r=-1;e.length>0&&(i=function(e,t,n){var i=0;for(;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n))>=0&&function(e,t,n,i){var r=0;for(;r<e.length;){if(t.length<=n+r||!i(t[n+r],e[r]))return!1;r++}return!0}(e,t,i,n)&&(r=i+e.length-1);if(i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(e,t,this.isItemEqual)}},{key:"getItemElement",value:function(e){return this.getContainerElement().childNodes[e]}}])&&U(t.prototype,n),i&&U(t,i),e}();var j={SCROLL:"scroll",STOPPED_SCROLLING:"stopped scrolling",MANUAL:"manual",MOUNT:"mount",ITEM_HEIGHT_NOT_MEASURED:"some item height wasn't measured",RESIZE:"resize",ITEM_HEIGHT_CHANGED:"item height changed",ITEMS_CHANGED:"items changed",TOP_OFFSET_CHANGED:"top offset changed"};return D});
//# sourceMappingURL=virtual-scroller.js.map

@@ -147,2 +147,3 @@ "use strict";

}, items, {
_useTimeoutInRenderLoop: true,
estimatedItemHeight: estimatedItemHeight,

@@ -496,13 +497,18 @@ bypass: bypass,

// Consider a user clicks "Show previous" to show the items from the start.
// By the time `componentDidUpdate()` is called on `<VirtualScroller/>`
// By the time `componentDidUpdate()` is called on `<VirtualScroller/>`,
// the "Show previous" button has already been hidden
// (because there're no more "previous" items)
// which results in the scroll Y position jumping forward
// by the height of the "Show previous" button.
// This is because `<VirtualScroller/>` restores scroll Y position
// when items are prepended via `.setItems()` and it does that
// when the "Show previous" button has already been hidden
// so that's the reason for the scroll Y jump.
// by the height of that "Show previous" button.
// This is because `<VirtualScroller/>` captures scroll Y
// position when items are prepended via `.setItems()`
// when the "Show previous" button is still being shown,
// and then restores scroll Y position in `.didUpdateState()`
// when the "Show previous" button has already been hidden:
// that's the reason for the scroll Y "jump".
//
// To prevent that, scroll Y position is stored at `render()` time
// rather than later in `componentDidUpdate()`.
// To prevent that, scroll Y position is captured at `render()`
// time rather than later in `componentDidUpdate()`: this way,
// scroll Y position is captured while the "Show previous" button
// is still being shown.
//

@@ -509,0 +515,0 @@

@@ -133,2 +133,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

}, items, {
_useTimeoutInRenderLoop: true,
estimatedItemHeight: estimatedItemHeight,

@@ -482,13 +483,18 @@ bypass: bypass,

// Consider a user clicks "Show previous" to show the items from the start.
// By the time `componentDidUpdate()` is called on `<VirtualScroller/>`
// By the time `componentDidUpdate()` is called on `<VirtualScroller/>`,
// the "Show previous" button has already been hidden
// (because there're no more "previous" items)
// which results in the scroll Y position jumping forward
// by the height of the "Show previous" button.
// This is because `<VirtualScroller/>` restores scroll Y position
// when items are prepended via `.setItems()` and it does that
// when the "Show previous" button has already been hidden
// so that's the reason for the scroll Y jump.
// by the height of that "Show previous" button.
// This is because `<VirtualScroller/>` captures scroll Y
// position when items are prepended via `.setItems()`
// when the "Show previous" button is still being shown,
// and then restores scroll Y position in `.didUpdateState()`
// when the "Show previous" button has already been hidden:
// that's the reason for the scroll Y "jump".
//
// To prevent that, scroll Y position is stored at `render()` time
// rather than later in `componentDidUpdate()`.
// To prevent that, scroll Y position is captured at `render()`
// time rather than later in `componentDidUpdate()`: this way,
// scroll Y position is captured while the "Show previous" button
// is still being shown.
//

@@ -495,0 +501,0 @@

{
"name": "virtual-scroller",
"version": "1.7.1",
"version": "1.7.2",
"description": "A component for efficiently rendering large lists of variable height items",

@@ -5,0 +5,0 @@ "main": "index.commonjs.js",

@@ -218,3 +218,3 @@ # VirtualScroller

* `onItemInitialRender(item)` β€” Is called for each item the first time it's rendered. Is guaranteed to be called at least one time for each item rendered, though could also be called multiple times. For an example of using such feature, consider a list of items that must be somehow preprocessed (parsed, enhanced, etc) before being rendered, and such preprocessing puts some load on the CPU (and therefore takes some time). In such case, instead of preprocessing the whole list of items upfront, a developer could preprocess the items as they're being rendered thereby eliminating any associated lag/freezing and draining less battery.
* `onItemInitialRender(item)` β€” Is called for each `item` when it's about to be rendered for the first time. Is guaranteed to be called at least once for each item rendered, though, in "asynchronous" rendering systems like React, it could be called multiple times for a given item, because "an item is calculated to be rendered" doesn't necessarily mean that the actual rendering will take place before a later calculation supercedes the former one. This function can be used to somehow "initialize" items before they're rendered for the first time. For example, consider a list of items that must be somehow "preprocessed" (parsed, enhanced, etc) before being rendered, and such "preprocessing" puts some load on the CPU (and therefore takes some time). In such case, instead of "preprocessing" the whole list of items up front, a developer could "preprocess" the items as they're being rendered, thereby eliminating any associated lag or freezing that would be inevitable have all the items been "preprocessed" up front. If a user only wants to see a few of the items, "preprocessing" all the items up front would simply be a waste.

@@ -248,3 +248,3 @@ * `preserveScrollPositionOfTheBottomOfTheListOnMount: boolean` β€” (advanced) Set to `true` to preserve scroll position relative to the bottom of the list when it's first mounted. A possible use case: consider a forum thread only showing unread posts by default. If a user navigates to such thread, it could show "No new posts" message with a "Show previous" button above it. When the user clicks the "Show previous" button, a `<VirtualScroller/>` is mounted with a list of posts. If `preserveScrollPositionOfTheBottomOfTheListOnMount: true` is set, then, after the list of posts is shown, page scroll will be restored so that the bottom of the list remains on screen so that the user could start scrolling up to read the "previous" posts starting from the most recent ones to the oldest ones.

* `updateLayout()` β€” (advanced) Triggers a re-layout of `VirtualScroller`. It's what's called every time on page scroll or window resize. You most likely won't ever need to call this method manually. Still, it can be called manually when the list's top position changes not as a result of scrolling the page or resizing the window. For example, if some DOM elements above the list are removed (like a closeable "info" panel) or collapsed (like an "accordion" panel) then the list's top position changes which means that now some of the previoulsy shown items might go off screen and the user might be seeing a blank area where items haven't been rendered yet because they were off-screen during the previous `VirtualScroller` layout. `VirtualScroller` automatically performs a layout only on page scroll or window resize; in all other cases, when layout needs to be re-run then call it manually via this instance method.
* `updateLayout()` β€” (advanced) Triggers a re-layout of `VirtualScroller`. It's what's called every time on page scroll or window resize. You most likely won't ever need to call this method manually. Still, it can be called manually when the list's top position changes not as a result of scrolling the page or resizing the window. For example, if some DOM elements above the list are removed (like a closeable "info" panel) or collapsed (like an "accordion" panel), then the list's top position changes, which means that now some of the previoulsy shown items might go off screen, and the user might be seeing a blank area where items haven't been rendered yet because they were off-screen during the previous `VirtualScroller` layout. `VirtualScroller` automatically performs a layout only on page scroll or window resize; in all other cases, when layout needs to be re-run, call it manually via this instance method.

@@ -251,0 +251,0 @@ ## DOM

@@ -129,2 +129,3 @@ import React from 'react'

{
_useTimeoutInRenderLoop: true,
estimatedItemHeight,

@@ -480,13 +481,18 @@ bypass,

// Consider a user clicks "Show previous" to show the items from the start.
// By the time `componentDidUpdate()` is called on `<VirtualScroller/>`
// By the time `componentDidUpdate()` is called on `<VirtualScroller/>`,
// the "Show previous" button has already been hidden
// (because there're no more "previous" items)
// which results in the scroll Y position jumping forward
// by the height of the "Show previous" button.
// This is because `<VirtualScroller/>` restores scroll Y position
// when items are prepended via `.setItems()` and it does that
// when the "Show previous" button has already been hidden
// so that's the reason for the scroll Y jump.
// by the height of that "Show previous" button.
// This is because `<VirtualScroller/>` captures scroll Y
// position when items are prepended via `.setItems()`
// when the "Show previous" button is still being shown,
// and then restores scroll Y position in `.didUpdateState()`
// when the "Show previous" button has already been hidden:
// that's the reason for the scroll Y "jump".
//
// To prevent that, scroll Y position is stored at `render()` time
// rather than later in `componentDidUpdate()`.
// To prevent that, scroll Y position is captured at `render()`
// time rather than later in `componentDidUpdate()`: this way,
// scroll Y position is captured while the "Show previous" button
// is still being shown.
//

@@ -493,0 +499,0 @@ const newItems = this.props.items

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc