virtual-scroller 1.16.2 → 1.16.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +75 -35
  3. package/bundle/virtual-scroller-dom.js +1 -1
  4. package/bundle/virtual-scroller-dom.js.map +1 -1
  5. package/bundle/virtual-scroller-react.js +1 -1
  6. package/bundle/virtual-scroller-react.js.map +1 -1
  7. package/bundle/virtual-scroller.js +1 -1
  8. package/bundle/virtual-scroller.js.map +1 -1
  9. package/commonjs/DOM/ListTopOffsetWatcher.js +2 -4
  10. package/commonjs/DOM/ListTopOffsetWatcher.js.map +1 -1
  11. package/commonjs/Layout.test.js +26 -24
  12. package/commonjs/Layout.test.js.map +1 -1
  13. package/commonjs/Scroll.js +8 -11
  14. package/commonjs/Scroll.js.map +1 -1
  15. package/commonjs/VirtualScroller.constructor.js +7 -8
  16. package/commonjs/VirtualScroller.constructor.js.map +1 -1
  17. package/commonjs/VirtualScroller.js +10 -1
  18. package/commonjs/VirtualScroller.js.map +1 -1
  19. package/commonjs/VirtualScroller.layout.js +62 -20
  20. package/commonjs/VirtualScroller.layout.js.map +1 -1
  21. package/commonjs/VirtualScroller.onRender.js +25 -2
  22. package/commonjs/VirtualScroller.onRender.js.map +1 -1
  23. package/commonjs/VirtualScroller.state.js +39 -0
  24. package/commonjs/VirtualScroller.state.js.map +1 -1
  25. package/commonjs/react/useCreateVirtualScroller.js +1 -1
  26. package/commonjs/react/useCreateVirtualScroller.js.map +1 -1
  27. package/commonjs/test/VirtualScroller.js +8 -3
  28. package/commonjs/test/VirtualScroller.js.map +1 -1
  29. package/commonjs/utility/px.test.js +9 -5
  30. package/commonjs/utility/px.test.js.map +1 -1
  31. package/commonjs/utility/scheduleOnNextTick.js +25 -0
  32. package/commonjs/utility/scheduleOnNextTick.js.map +1 -0
  33. package/index.d.ts +4 -0
  34. package/modules/DOM/ListTopOffsetWatcher.js +1 -6
  35. package/modules/DOM/ListTopOffsetWatcher.js.map +1 -1
  36. package/modules/Layout.test.js +20 -19
  37. package/modules/Layout.test.js.map +1 -1
  38. package/modules/Scroll.js +8 -11
  39. package/modules/Scroll.js.map +1 -1
  40. package/modules/VirtualScroller.constructor.js +7 -8
  41. package/modules/VirtualScroller.constructor.js.map +1 -1
  42. package/modules/VirtualScroller.js +9 -1
  43. package/modules/VirtualScroller.js.map +1 -1
  44. package/modules/VirtualScroller.layout.js +61 -23
  45. package/modules/VirtualScroller.layout.js.map +1 -1
  46. package/modules/VirtualScroller.onRender.js +24 -2
  47. package/modules/VirtualScroller.onRender.js.map +1 -1
  48. package/modules/VirtualScroller.state.js +39 -1
  49. package/modules/VirtualScroller.state.js.map +1 -1
  50. package/modules/react/useCreateVirtualScroller.js +1 -1
  51. package/modules/react/useCreateVirtualScroller.js.map +1 -1
  52. package/modules/test/VirtualScroller.js +5 -2
  53. package/modules/test/VirtualScroller.js.map +1 -1
  54. package/modules/utility/px.test.js +5 -3
  55. package/modules/utility/px.test.js.map +1 -1
  56. package/modules/utility/scheduleOnNextTick.js +15 -0
  57. package/modules/utility/scheduleOnNextTick.js.map +1 -0
  58. package/package.json +6 -5
  59. package/source/DOM/ListTopOffsetWatcher.js +0 -6
  60. package/source/Layout.test.js +21 -20
  61. package/source/Scroll.js +7 -9
  62. package/source/VirtualScroller.constructor.js +7 -7
  63. package/source/VirtualScroller.js +8 -0
  64. package/source/VirtualScroller.layout.js +61 -25
  65. package/source/VirtualScroller.onRender.js +29 -3
  66. package/source/VirtualScroller.state.js +38 -0
  67. package/source/react/useCreateVirtualScroller.js +1 -1
  68. package/source/test/VirtualScroller.js +6 -2
  69. package/source/utility/px.test.js +6 -3
  70. package/source/utility/scheduleOnNextTick.js +16 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  <!-- `virtual-scroller`: in `.updateItems()` handle a case when `items.length` is the same, in which case find different items and if those items are rendered then maybe update them on screen and update their height, if the items are past rendered then maybe just discard all item heights past rendered, if the items are before rendered then maybe ignore and it will jump on scroll up which is kinda acceptable. -->
2
2
 
3
+ 1.16.4 / 08.03.2026
4
+ ===================
5
+
6
+ * Fixed freezing of the UI when rendering a very large list of items and the user suddenly moves the scrollbar to the end of the list. Now it doesn't freeze the UI because it "breaks up" such large re-render into smaller parts each happening "at next tick".
7
+
8
+ * `delayRecursiveRenderUntilNextTick: boolean` option of the "core" component is now public. It is used in React component implementation.
9
+
3
10
  1.16.0 / 26.01.2026
4
11
  ===================
5
12
 
package/README.md CHANGED
@@ -728,6 +728,54 @@ The following `state` properties are only used for saving and restoring `Virtual
728
728
 
729
729
  #####
730
730
 
731
+ <details>
732
+ <summary>External State Management</summary>
733
+
734
+ #####
735
+
736
+ By default, `VirtualScroller` stores the `state` inside a `VirtualScroller` instance and updates it "synchronously".
737
+
738
+ That works for most rendering environments, but in some exotic ones, like [React](reactjs.org), the environment itself needs to take over the state management in order to render it correctly.
739
+
740
+ To support such cases, `VirtualScroller` provides the following instance methods:
741
+
742
+ * `onRender()` — When using custom (external) state management, `.onRender()` function must be called every time right after the list has been "re-rendered" in response to a state update, including the initial "render".
743
+ * When "re-rendering" the list, it should always use the "latest" known state, i.e. the argument of the "latest" known `setState()` call, otherwise the list may not behave correctly.
744
+
745
+ * `getInitialState(): object` — Returns the initial `VirtualScroller` state for the cases when a developer configures `VirtualScroller` for custom (external) state management.
746
+
747
+ * `useState({ getState, setState, updateState? })` — Enables custom (external) state management. Expects the following parameters:
748
+
749
+ * `getState(): object` — A function that returns the current `VirtualScroller` `state`. `VirtualScroller` instance will call this function every time it needs to read anything from the `state`.
750
+
751
+ * `setState(newState: object)` — A function that sets the current `VirtualScroller` `state`. `VirtualScroller` instance will call this function every time it needs to update the `state`.
752
+ * This function must ensure that `virtualScroller.onRender()` function is called right after the new `state` has been "rendered".
753
+ * If the new `state` is going to be "rendered" "synchronously", i.e. immediately without any delay, then this `setState(newState)` function must first call the rendering function and then, immediately after, call `virtualScroller.onRender()` function.
754
+ * In such scenario, there'd really be no reason for anyone to resort to custom (external) state management because the same could be achieved by using the default state management and passing a custom "synchronous" `render()` function as a parameter.
755
+ * If the new `state` is going to be "rendered" "asynchronously", i.e. after a momentary delay, then this `setState(newState)` function must "schedule" such "asynchronous" "re-render".
756
+ * An example would be the React implementation of `VirtualScroller`: in React, any state updates are ["asynchronous"](https://reactjs.org/docs/state-and-lifecycle.html#state-updates-may-be-asynchronous) by design, i.e. state updates aren't "rendered" immediately and are instead queued and then "rendered" in a single compound state update for better performance.
757
+
758
+ * `updateState(stateUpdate: object)` — (optional) `setState()` function parameter could be replaced with `updateState()` function parameter. The only difference between the two is that `updateState()` gets called with just the portion of the state that is being updated while `setState()` gets called with the whole updated state object, so it's just a matter of developer's preference.
759
+
760
+ For a usage example, see `./source/react/VirtualScroller.js`. The steps are:
761
+
762
+ * Create a `VirtualScroller` instance.
763
+
764
+ * Get the initial state value via `virtualScroller.getInitialState()`.
765
+
766
+ * Initialize the externally managed state with the initial state value.
767
+
768
+ * Define `getState()` and `updateState()` functions for reading or updating the externally managed state.
769
+
770
+ * Call `virtualScroller.useState({ getState, updateState })`.
771
+
772
+ * "Render" the list and call `virtualScroller.start()`.
773
+
774
+ When using custom (external) state management, contrary to the default (internal) state management approach, the `render()` function parameter can't be passed to the `VirtualScroller` constructor. The reason is that `VirtualScroller` wouldn't know when exactly should it call such `render()` function because by design it can only be called right after the state has been updated, and `VirtualScroller` doesn't know when exactly does the state get updated, because state updates are done via an "external" `updateState()` function that could as well apply state updates "asynchronously" (after a short delay), like in React, rather than "synchronously" (immediately). That's why the `updateState()` function must re-render the list by itself, at any time it finds appropriate, and right after the list has been re-rendered, it must call `virtualScroller.onRender()`.
775
+ </details>
776
+
777
+ #####
778
+
731
779
  Code example:
732
780
 
733
781
  ```js
@@ -776,7 +824,7 @@ virtualScroller.stop()
776
824
  * `render(state, prevState)` — "re-renders" the list according to the new `state`.
777
825
  * The `render()` function can only be specified when it immediately re-renders the list. Sometimes, an immediate re-render is not possible. For example, in React framework, re-render is done "asynchronously", i.e. with a short delay. In such case, instead of specifying a `render` parameter when creating a `virtualScroller` instance, one should omit it and then call an instance method — `virtualScroller.useState({ getState, setState/updateState })` — where `getState` function returns the currently-rendered state and `setState/updateState` function is responsible for triggerring an eventual "re-render" of the list according to the new `state`.
778
826
 
779
- #### Options
827
+ ### Options
780
828
 
781
829
  <details>
782
830
  <summary>Available <code>options</code></summary>
@@ -839,7 +887,12 @@ virtualScroller.stop()
839
887
 
840
888
  <!-- * (alternative description) `getEstimatedItemHeight(): number` — By default, `<VirtualScroller/>` uses an average measured item height as an estimate for the height of any item that hasn't been rendered yet. This way, it is able to guess what will be the total height of the items below the current scroll position, which is required in order to display a correct scrollbar. However, if the application thinks that it has a better idea of what the average item height is gonna be, it could force `<VirtualScroller/>` to use that value instead of the average measured one. -->
841
889
 
842
- * `prerenderMarginRatio` — (currently unused) The list component renders not only the items that're currently visible but also the items that lie within some additional vertical distance (called "prerender margin") on top and bottom to account for future scrolling. This way, it doesn't have to recalculate the layout on each scroll event and is only forced to recalculate the layout if the user scrolls past the "prerender margin". Therefore, "prerender margin" is an optimization that "throttles" layout recalculation. By default, the "prerender margin" is equal to scrollable container height: this seems to be the most optimal value to account for "Page Up" / "Page Down" scrolling. This parameter is currently not customizable because the default value of `1` seems to work fine in all possible use cases.
890
+ * `prerenderMarginRatio: number` — (currently unused) The list component renders not only the items that're currently visible but also the items that lie within some additional vertical distance (called "prerender margin") on top and bottom to account for future scrolling. This way, it doesn't have to recalculate the layout on each scroll event and is only forced to recalculate the layout if the user scrolls past the "prerender margin". Therefore, "prerender margin" is an optimization that "throttles" layout recalculation. By default, the "prerender margin" is equal to scrollable container height: this seems to be the most optimal value to account for "Page Up" / "Page Down" scrolling. This parameter is currently not customizable because the default value of `1` seems to work fine in all possible use cases.
891
+
892
+ * `delayRecursiveRenderUntilNextTick: boolean` — Sometimes, a list has to be re-rendered multiple times in succession in order to finish rendering. For example, this happens at the initial render when item heights are unknown and the list has to first render and measure the first item and then immediately render a necessary amount of follow-up items. Another example when this happens is when there're a lot of items in the list and the user suddenly moves the scrollbar to the very end of the list. This causes the list to start gradually rendering all the items from top to bottom until it gets to the bottom of the list.
893
+ * Such immediate successive re-rendering may not necessarily be favored by all rendering engines out there. One example is React which really [doesn't like it](https://google.com/search?q=react+maximum+update+depth+exceeded) when one re-render is immediately followed up by another re-render. Passing `delayRecursiveRenderUntilNextTick: true` option to `VirtualScroller` constructor resolves the issue by forcing any successive re-render to not be immediate but rather happen after a momentary delay, i.e. "at next tick".
894
+ * Not specifying a `delayRecursiveRenderUntilNextTick` option will enable the default "intelligent" behavior when it performs successive re-renders immediately until it starts freezing the application for too long for it to become physically noticeable, at which point it breaks the loop by performing the next successive re-render after a momentary delay, i.e. "at next tick".
895
+ * Such behavior is most convenient and reasonable unless there's a specific requirement to always stay "synchronous" and not interfere with the execution flow in any way, which is usually when running unit tests for the component. In such cases, the default "intelligent" behavior could be disabled by passing `delayRecursiveRenderUntilNextTick: false` option to `VirtualScroller` constructor.
843
896
  </details>
844
897
 
845
898
  #####
@@ -847,7 +900,7 @@ virtualScroller.stop()
847
900
  <details>
848
901
  <summary>Instance methods</summary>
849
902
 
850
- #####
903
+ ### Instance methods
851
904
 
852
905
  * `start()` — Performs an initial render of the `VirtualScroller` and starts listening to scroll events.
853
906
 
@@ -858,38 +911,6 @@ virtualScroller.stop()
858
911
  * `setItems(newItems: any[], options: object?)` — Updates `VirtualScroller` `items`. For example, it can be used to prepend or append new items to the list. See [Updating Items](#updating-items) section for more details. Available options:
859
912
  * `preserveScrollPositionOnPrependItems: boolean` — Set to `true` to enable "restore scroll position after prepending new items" feature (should be used when implementing a "Show previous items" button).
860
913
 
861
- #### Custom (External) State Management
862
-
863
- A developer might prefer to use custom (external) state management rather than the default one. That might be the case when a certain high-order `VirtualScroller` implementation comes with a specific state management paradigm, like in React. In such case, `VirtualScroller` provides the following instance methods:
864
-
865
- * `onRender()` — When using custom (external) state management, `.onRender()` function must be called every time right after the list has been "rendered" (including the initial render). The list should always "render" only with the "latest" state where the "latest" state is defined as the argument of the latest `setState()` call. Otherwise, the component may not work correctly.
866
-
867
- * `getInitialState(): object` — Returns the initial `VirtualScroller` state for the cases when a developer configures `VirtualScroller` for custom (external) state management.
868
-
869
- * `useState({ getState, setState, updateState? })` — Enables custom (external) state management.
870
-
871
- * `getState(): object` — Returns the externally managed `VirtualScroller` `state`.
872
-
873
- * `setState(newState: object)` — Sets the externally managed `VirtualScroller` `state`. Must call `.onRender()` right after the updated `state` gets "rendered". A higher-order `VirtualScroller` implementation could either "render" the list immediately in its `setState()` function, in which case it would be better to use the default state management instead and pass a custom `render()` function, or the `setState()` function could "schedule" an "asynchronous" "re-render", like the React implementation does, in which case such `setState()` function would be called an ["asynchronous"](https://reactjs.org/docs/state-and-lifecycle.html#state-updates-may-be-asynchronous) one, meaning that state updates aren't "rendered" immediately and are instead queued and then "rendered" in a single compound state update for better performance.
874
-
875
- * `updateState(stateUpdate: object)` — (optional) `setState()` parameter could be replaced with `updateState()` parameter. The only difference between the two is that `updateState()` gets called with just the portion of the state that is being updated while `setState()` gets called with the whole updated state object, so it's just a matter of preference.
876
-
877
- For a usage example, see `./source/react/VirtualScroller.js`. The steps are:
878
-
879
- * Create a `VirtualScroller` instance.
880
-
881
- * Get the initial state value via `virtualScroller.getInitialState()`.
882
-
883
- * Initialize the externally managed state with the initial state value.
884
-
885
- * Define `getState()` and `updateState()` functions for reading or updating the externally managed state.
886
-
887
- * Call `virtualScroller.useState({ getState, updateState })`.
888
-
889
- * "Render" the list and call `virtualScroller.start()`.
890
-
891
- When using custom (external) state management, contrary to the default (internal) state management approach, the `render()` function parameter can't be passed to the `VirtualScroller` constructor. The reason is that `VirtualScroller` wouldn't know when exactly should it call such `render()` function because by design it can only be called right after the state has been updated, and `VirtualScroller` doesn't know when exactly does the state get updated, because state updates are done via an "external" `updateState()` function that could as well apply state updates "asynchronously" (after a short delay), like in React, rather than "synchronously" (immediately). That's why the `updateState()` function must re-render the list by itself, at any time it finds appropriate, and right after the list has been re-rendered, it must call `virtualScroller.onRender()`.
892
-
893
914
  #### "Advanced" (rarely used) instance methods
894
915
 
895
916
  * `onItemHeightDidChange(item)` — (advanced) If an item's height could've changed, this function should be called immediately after the item's height has potentially changed. The function re-measures the item's height (the item must still be rendered) and re-calculates `VirtualScroller` layout. An example for using this function would be having an "Expand"/"Collapse" button in a list item.
@@ -1272,6 +1293,25 @@ For now, I don't see it as a bug that would be worth fixing. The user could just
1272
1293
  #####
1273
1294
  -->
1274
1295
 
1296
+ ### Rendering items as `<table/>` rows
1297
+
1298
+ When using a `<table/>` as an items container, all column widths must be strictly defined. Otherwise, the `<table/>` will automatically adjust column widths based on the content. This "intelligent" approach would've worked in classic HTML when all data is output at once, but it won't work with `virtual-scroller` when only a small subset of data is output at a given moment, and that subset constantly changes, resulting in column widths constantly changing, which not only looks weird but it also makes all row heights contantly change, causing a warning: `"Item index N height changed unexpectedly"`.
1299
+
1300
+ When strictly defining `<table/>` column widths, just setting `width` on `<td/>` and `<th/>` elements won't really disable the real-time automatic adjustment of column widths based on the content. And even adding `max-width` and `overflow` CSS properties won't fix that. The key is to set `table-layout: fixed` on the `<table/>`. This forces the `<table/>` honor specified `width`s and enables `overflow` behavior in cells. The total width for the `<table/>` must also be defined for that to work.
1301
+
1302
+ ```css
1303
+ table {
1304
+ width: 100%;
1305
+ table-layout: fixed;
1306
+ }
1307
+
1308
+ table td, table th {
1309
+ width: 10%;
1310
+ overflow: hidden;
1311
+ text-overflow: ellipsis;
1312
+ }
1313
+ ```
1314
+
1275
1315
  ### Using `<tbody/>` in Internet Explorer
1276
1316
 
1277
1317
  Due to the [inherent limitations](https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1) of the `<tbody/>` HTML tag, when a `<tbody/>` is used as a container for the list items, the `VirtualScroller` ["core"](#core) component has to use a workaround that is based on CSS variables, and CSS variables aren't supported in Internet Explorer. Because of that, using a `<tbody/>` as a list items container won't work in Internet Explorer. In that case, `VirtualScroller` will render itself in "bypass" mode, i.e. it will just render all items from the start, without any "virtualization".
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VirtualScroller=t()}(this,function(){"use strict";function e(t){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(t)}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)}}function n(t){var n=o();return function(){var i,r=a(t);if(n){var o=a(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return function(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(this,i)}}function i(e){var t="function"==typeof Map?new Map:void 0;return i=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return r(e,arguments,a(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),s(i,e)},i(e)}function r(e,t,n){return r=o()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var r=new(Function.bind.apply(e,i));return n&&s(r,n.prototype),r},r.apply(null,arguments)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}var l=function(e){!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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}(l,e);var i,r,o,a=n(l);function l(e){var t=e.renderedElementIndex,n=e.renderedElementsCount,i=e.message;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),a.call(this,i||function(e){var t=e.renderedElementIndex,n=e.renderedElementsCount;return"Element with index ".concat(t," was not found in the list of Rendered Item Elements in the Items Container of Virtual Scroller. There're only ").concat(n," Elements there.")}({renderedElementIndex:t,renderedElementsCount:n}))}return i=l,r&&t(i.prototype,r),o&&t(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i}(i(Error));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)}}var h=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getElement=t}var t,n,i;return t=e,(n=[{key:"_getNthRenderedItemElement",value:function(e){var t=this.getElement().childNodes;if(e>t.length-1)throw new l({renderedElementIndex:e,renderedElementsCount:t.length});return t[e]}},{key:"getNthRenderedItemTopOffset",value:function(e){return this._getNthRenderedItemElement(e).getBoundingClientRect().top-this.getElement().getBoundingClientRect().top}},{key:"getNthRenderedItemHeight",value:function(e){return this._getNthRenderedItemElement(e).getBoundingClientRect().height}},{key:"getHeight",value:function(){return this.getElement().getBoundingClientRect().height}}])&&u(t.prototype,n),i&&u(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function c(e){return c="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},c(e)}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 d(e){var t=p();return function(){var n,i=v(e);if(t){var r=v(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return function(e,t){if(t&&("object"===c(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function m(e){var t="function"==typeof Map?new Map:void 0;return m=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return g(e,arguments,v(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),I(i,e)},m(e)}function g(e,t,n){return g=p()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var r=new(Function.bind.apply(e,i));return n&&I(r,n.prototype),r},g.apply(null,arguments)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function I(e,t){return I=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},I(e,t)}function v(e){return v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},v(e)}var y=function(e){!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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&I(e,t)}(o,e);var t,n,i,r=d(o);function o(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),r.call(this,"[virtual-scroller] Scrollable container not found")}return t=o,n&&f(t.prototype,n),i&&f(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}(m(Error));function S(e){return S="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},S(e)}function b(e,t){return b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},b(e,t)}function w(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,i=C(e);if(t){var r=C(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return function(e,t){if(t&&("object"===S(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function C(e){return C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},C(e)}function O(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function R(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&&R(e.prototype,t),n&&R(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var H=function(){function e(t,n){O(this,e),this.getElement=t,this.getItemsContainerElement=n}return x(e,[{key:"getScrollY",value:function(){return this.getElement().scrollTop}},{key:"scrollToY",value:function(e){this.getElement().scrollTo?this.getElement().scrollTo(0,e):this.getElement().scrollTop=e}},{key:"getWidth",value:function(){if(!this.getElement())throw new y;return this.getElement().offsetWidth}},{key:"getHeight",value:function(){if(!this.getElement())throw new y;return this.getElement().offsetHeight}},{key:"getItemsContainerTopOffset",value:function(){var e=this.getElement().getBoundingClientRect().top,t=this.getElement().clientTop;return this.getItemsContainerElement().getBoundingClientRect().top-e+this.getScrollY()-t}},{key:"onScroll",value:function(e){var t=this.getElement();return t.addEventListener("scroll",e),function(){return t.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e){var t;if("undefined"!=typeof ResizeObserver){var n=new ResizeObserver(function(t){t[0],e()}),i=this.getElement();n.observe(i),t=function(){return n.unobserve(i)}}var r=P(e,{itemsContainerElement:this.getItemsContainerElement()});return function(){t&&t(),r()}}}]),e}(),T=function(e){!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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}(n,e);var t=w(n);function n(e){return O(this,n),t.call(this,function(){return window},e)}return x(n,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getItemsContainerTopOffset",value:function(){var e=document.clientTop||document.body.clientTop||0;return this.getItemsContainerElement().getBoundingClientRect().top+this.getScrollY()-e}},{key:"onResize",value:function(e){return P(e,{itemsContainerElement:this.getItemsContainerElement()})}}]),n}(H);function P(e,t){var n=t.itemsContainerElement,i=function(){document.fullscreenElement&&!document.fullscreenElement.contains(n)||e()};return window.addEventListener("resize",i),function(){return window.removeEventListener("resize",i)}}for(var j="undefined"==typeof window?global:window,E=["moz","webkit"],M="AnimationFrame",B=j["request"+M],L=j["cancel"+M]||j["cancelRequest"+M],z=0;!B&&z<E.length;z++)B=j[E[z]+"Request"+M],L=j[E[z]+"Cancel"+M]||j[E[z]+"CancelRequest"+M];if(!B||!L){var A=0,_=0,k=[],V=1e3/60;B=function(e){if(0===k.length){var t=Date.now(),n=Math.max(0,V-(t-A));A=n+t,setTimeout(function(){var e=k.slice(0);k.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(A)}catch(e){setTimeout(function(){throw e},0)}},Math.round(n))}return k.push({handle:++_,callback:e,cancelled:!1}),_},L=function(e){for(var t=0;t<k.length;t++)k[t].handle===e&&(k[t].cancelled=!0)}}function N(e){return B.call(j,e)}function D(e,t){var n=Date.now(),i=N(function r(){Date.now()-n>=t?e():i=N(r)});return{clear:function(){return function(){L.apply(j,arguments)}(i)}}}function W(e){e&&e.clear()}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)}}var U=function(){function e(t){var n=t.getListTopOffset,i=t.onListTopOffsetChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getListTopOffset=n,this.onListTopOffsetChange=i}var t,n,i;return t=e,(n=[{key:"onListTopOffset",value:function(e){void 0===this.listTopOffsetInsideScrollableContainer&&this.start(),this.listTopOffsetInsideScrollableContainer=e}},{key:"start",value:function(){this._isActive=!0,this.watchListTopOffset()}},{key:"isStarted",value:function(){return this._isActive}},{key:"stop",value:function(){this._isActive=!1,this.watchListTopOffsetTimer&&(W(this.watchListTopOffsetTimer),this.watchListTopOffsetTimer=void 0)}},{key:"watchListTopOffset",value:function(){var e=this,t=Date.now();!function n(){e._isActive&&(void 0!==e.listTopOffsetInsideScrollableContainer&&e.getListTopOffset()!==e.listTopOffsetInsideScrollableContainer&&e.onListTopOffsetChange(),Date.now()-t<3e3&&(e.watchListTopOffsetTimer=D(n,500)))}()}}])&&F(t.prototype,n),i&&F(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}(),Y={createItemsContainer:function(e){return new h(e)},createScrollableContainer:function(e,t){return e?new H(e,t):"undefined"!=typeof window?new T(t):void 0},watchListTopOffset:function(e){var t=e.getListTopOffset,n=e.onListTopOffsetChange;return new U({getListTopOffset:t,onListTopOffsetChange:n})}};function q(e){return function(e){if(Array.isArray(e))return J(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return J(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return J(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function J(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function G(){if(X()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,q(["[virtual-scroller]"].concat(n)))}}function $(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];if(Z("VirtualScrollerWarningsAreErrors"))return Q.apply(this,n);(e=console).warn.apply(e,q(["[virtual-scroller]"].concat(n)))}function K(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).error.apply(e,q(["[virtual-scroller]"].concat(n)))}function Q(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i=function(){return new Error(["[virtual-scroller]"].concat(t).join(" "))};if("undefined"!=typeof window)K.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw i()},0);else{var r=Z("VirtualScrollerCatchError");if(r)return r(i());if(Z("VirtualScrollerThrowErrors"))throw i();K.apply(this,["ERROR"].concat(t))}}function X(){var e=Z("VirtualScrollerDebug");if(void 0!==e)return!0===e||"debug"===e}function Z(e){return"undefined"!=typeof window?window[e]:"undefined"!=typeof global?global[e]:void 0}function ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(n),!0).forEach(function(t){ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ee(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ne(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ie(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 re=function(){function e(t){var n=t.isInBypassMode,i=t.getEstimatedVisibleItemRowsCountForInitialRender,r=t.measureItemsBatchSize,o=t.getPrerenderMargin,s=t.getPrerenderMarginRatio,a=t.getVerticalSpacing,l=t.getVerticalSpacingBeforeResize,u=t.getColumnsCount,h=t.getColumnsCountBeforeResize,c=t.getItemHeight,f=t.getItemHeightBeforeResize,d=t.getBeforeResizeItemsCount,m=t.getAverageItemHeight,g=t.getMaxVisibleAreaHeight,p=t.getPreviouslyCalculatedLayout;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.isInBypassMode=n,this.getEstimatedVisibleItemRowsCountForInitialRender=i,this.measureItemsBatchSize=r,this.getPrerenderMargin=o,this.getPrerenderMarginRatio=s,this.getVerticalSpacing=a,this.getVerticalSpacingBeforeResize=l,this.getColumnsCount=u,this.getColumnsCountBeforeResize=h,this.getItemHeight=c,this.getItemHeightBeforeResize=f,this.getBeforeResizeItemsCount=d,this.getAverageItemHeight=m,this.getMaxVisibleAreaHeight=g,this.getPreviouslyCalculatedLayout=p}var t,n,i;return t=e,n=[{key:"getInitialLayoutValueWithFallback",value:function(e,t,n){try{return t()}catch(t){if(t instanceof y)return G('Scrollable container size is not known at this point, so "'.concat(e,"\" can't be calculated yet. Default to"),n),n;throw t}}},{key:"getInitialLayoutValues",value:function(e){var t,n,i=this,r=e.itemsCount,o=e.columnsCount,s=e.beforeStart,a=0,l=0;if(r>0){var u=function(){return i.getInitialLastShownItemIndex({itemsCount:r,columnsCount:o,firstShownItemIndex:t})};t=0,n=s?this.getInitialLayoutValueWithFallback("lastShownItemIndex",u,t):u();var h=this.getAverageItemHeight(),c=this.getVerticalSpacing(),f=t,d=r-(n+1);a=Math.ceil(f/o)*(c+h),l=Math.ceil(d/o)*(c+h)}return{beforeItemsHeight:a,afterItemsHeight:l,firstShownItemIndex:t,lastShownItemIndex:n}}},{key:"getInitialLastShownItemIndex",value:function(e){var t=e.itemsCount,n=e.columnsCount,i=e.firstShownItemIndex;return this.isInBypassMode()?t-1:Math.min(i+(this.getInitialRenderedRowsCount()*n-1),t-1)}},{key:"getInitialRenderedRowsCount",value:function(){var e=this.getEstimatedVisibleItemRowsCount();return"number"==typeof e?Math.ceil(e*(1+this.getPrerenderMarginRatio())):1}},{key:"getEstimatedVisibleItemRowsCount",value:function(){var e=this.getMaxVisibleAreaHeight();if("number"==typeof e){var t=this.getEstimatedRowsCountForHeight(e);if("number"==typeof t)return t}if(this.getEstimatedVisibleItemRowsCountForInitialRender){var n=this.getEstimatedVisibleItemRowsCountForInitialRender();if("number"==typeof n)return n;throw new Error("[virtual-scroller] `getEstimatedVisibleItemRowsCount()` must return a number")}}},{key:"getEstimatedRowsCountForHeight",value:function(e){var t=this.getAverageItemHeight(),n=this.getVerticalSpacing();if(t+n>0)return Math.ceil((e+n)/(t+n))}},{key:"getLayoutUpdateForItemsDiff",value:function(e,t,n){var i=e.firstShownItemIndex,r=e.lastShownItemIndex,o=e.beforeItemsHeight,s=e.afterItemsHeight,a=t.prependedItemsCount,l=t.appendedItemsCount,u=n.itemsCount,h=n.columnsCount,c=n.shouldRestoreScrollPosition,f=n.onResetGridLayout,d=this.getAverageItemHeight(),m=this.getVerticalSpacing();if(l>0&&(s+=Math.ceil(l/h)*(m+d)),a>0&&(i+=a,r+=a,o+=Math.ceil(a/h)*(d+m),c&&(i=0,o=0),a%h>0)){f(),$("~ Prepended items count",a,"is not divisible by Columns Count",h,"~"),$("Layout reset required");var g=r-i+1;if(i=0,o=0,!c&&a>g){var p=u-((r=this.getInitialLastShownItemIndex({itemsCount:u,columnsCount:h,firstShownItemIndex:i}))+1);s=Math.ceil(p/h)*(m+d)}}return{beforeItemsHeight:o,afterItemsHeight:s,firstShownItemIndex:i,lastShownItemIndex:r}}},{key:"getItemNotMeasuredIndexes",value:function(e,t){var n=this,i=t.itemsCount,r=t.firstShownItemIndex,o=t.nonMeasuredAreaHeight,s=t.indexOfTheFirstItemInTheRow;G("Item index",e,"height is required for calculations but hasn't been measured yet. Mark the item as \"shown\", rerender the list, measure the item's height and redo the layout.");var a,l=this.getColumnsCount(),u=Math.min(("number"==typeof(a=n.getEstimatedRowsCountForHeight(o))?a:Math.ceil(i/l))*l,this.measureItemsBatchSize||1/0);return void 0===r&&(r=s),{firstNonMeasuredItemIndex:e,firstShownItemIndex:r,lastShownItemIndex:Math.min(s+u-1,i-1)}}},{key:"getShownItemIndexes",value:function(e){var t=e.itemsCount,n=e.visibleAreaInsideTheList,i=this._getShownItemIndex({itemsCount:t,fromIndex:0,visibleAreaInsideTheList:n,findFirstShownItemIndex:!0});if(null===i)return this.getNonVisibleListShownItemIndexes();if(void 0!==i.firstNonMeasuredItemIndex)return i;var r=i,o=r.firstShownItemIndex,s=r.beforeItemsHeight;return null===(i=this._getShownItemIndex({itemsCount:t,fromIndex:o,beforeItemsHeight:s,visibleAreaInsideTheList:n,findLastShownItemIndex:!0}))?this.getNonVisibleListShownItemIndexes():void 0!==i.firstNonMeasuredItemIndex?i:{firstShownItemIndex:o,lastShownItemIndex:i.lastShownItemIndex}}},{key:"_getShownItemIndex",value:function(e){var t=e.beforeResize,n=e.itemsCount,i=e.visibleAreaInsideTheList,r=e.findFirstShownItemIndex,o=e.findLastShownItemIndex,s=e.fromIndex,a=e.beforeItemsHeight;if(0===s&&(a=0),void 0===a)throw new Error("[virtual-scroller] `beforeItemsHeight` not passed to `Layout.getShownItemIndexes()` when starting from index "+s);if(!t){var l=this.getBeforeResizeItemsCount();if(l>s){var u=this._getShownItemIndex(te(te({},e),{},{beforeResize:!0,itemsCount:l})),h=u.notFound,c=u.beforeItemsHeight,f=u.firstShownItemIndex,d=u.lastShownItemIndex;if(!h){var m=this.getColumnsCount();return{firstShownItemIndex:void 0===f?void 0:Math.floor(f/m)*m,lastShownItemIndex:void 0===d?void 0:Math.floor(d/m)*m,beforeItemsHeight:c}}a=c,s+=l}}for(var g=t?this.getColumnsCountBeforeResize():this.getColumnsCount(),p=t?this.getVerticalSpacingBeforeResize():this.getVerticalSpacing(),I=s;I<n;){for(var v=I,y=n>v+g?p:0,S=0,b=0;b<g&&I<n;){var w=t?this.getItemHeightBeforeResize(I):this.getItemHeight(I);if(void 0===w)return this.getItemNotMeasuredIndexes(I,{itemsCount:n,firstShownItemIndex:o?s:void 0,indexOfTheFirstItemInTheRow:v,nonMeasuredAreaHeight:i.bottom+this.getPrerenderMargin()-a});S=Math.max(S,w),b++,I++}var C=a+S,O=C>i.top-this.getPrerenderMargin(),R=C+y>=i.bottom+this.getPrerenderMargin();if(r){if(O)return{firstShownItemIndex:v,beforeItemsHeight:a}}else if(o&&R)return{lastShownItemIndex:Math.min(v+g-1,n-1)};a+=S+y}return t?{notFound:!0,beforeItemsHeight:a}:r?($("The list is supposed to be visible but no visible item has been found"),null):o?{lastShownItemIndex:n-1}:void 0}},{key:"getNonVisibleListShownItemIndexes",value:function(){var e={firstShownItemIndex:0,lastShownItemIndex:0};return void 0===this.getItemHeight(0)&&(e.firstNonMeasuredItemIndex=0),e}},{key:"getBeforeItemsHeight",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).beforeResize,n=0,i=0;if(!t){var r=this.getBeforeResizeItemsCount();r>0&&(n=this.getBeforeItemsHeight(Math.min(e,r),{beforeResize:!0}),i=r)}for(var o=t?this.getColumnsCountBeforeResize():this.getColumnsCount(),s=t?this.getVerticalSpacingBeforeResize():this.getVerticalSpacing();i<e;){for(var a=0,l=0;l<o;){var u=t?this.getItemHeightBeforeResize(i):this.getItemHeight(i);void 0===u&&(u=this.getAverageItemHeight()),a=Math.max(a,u),i++,l++}n+=a,n+=s}return n}},{key:"getAfterItemsHeight",value:function(e,t){for(var n=this.getColumnsCount(),i=0,r=e+1;r<t;){for(var o=0,s=0;s<n&&r<t;){var a=this.getItemHeight(r);void 0===a&&(a=this.getAverageItemHeight()),o=Math.max(o,a),r++,s++}i+=this.getVerticalSpacing(),i+=o}return i}},{key:"getItemTopOffset",value:function(e){for(var t=0,n=this.getBeforeResizeItemsCount(),i=0===n?0:Math.ceil(n/this.getColumnsCountBeforeResize()),r=e<n?Math.floor(e/this.getColumnsCountBeforeResize()):i,o=0;o<r;)t+=this.getItemHeightBeforeResize(o*this.getColumnsCountBeforeResize()),t+=this.getVerticalSpacingBeforeResize(),o++;for(var s=Math.floor((e-n)/this.getColumnsCount()),a=0;a<s;){for(var l=0,u=0;u<this.getColumnsCount();){var h=this.getItemHeight(n+a*this.getColumnsCount()+u);if(void 0===h)return;l=Math.max(l,h),u++}t+=l,t+=this.getVerticalSpacing(),a++}return t}}],n&&ie(t.prototype,n),i&&ie(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}(),oe="scroll",se="stopped scrolling",ae="manual",le="started",ue="non-measured item heights have been measured",he="viewport width changed",ce="viewport height changed",fe="viewport size unchanged",de="item height changed",me="items changed",ge="list top offset changed";function pe(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 Ie=function(){function e(t){var n,i,r,o=this,s=t.isInBypassMode,a=t.getWidth,l=t.getHeight,u=t.listenForResize,h=t.onResizeStart,c=t.onResizeStop,f=t.onHeightChange,d=t.onWidthChange,m=t.onNoChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),r=function(){if(o.isActive){var e=o.width,t=o.height;o.width=o.getWidth(),o.height=o.getHeight(),o.width===e?o.height===t?o.onNoChange():o.onHeightChange(t,o.height):o.onWidthChange(e,o.width)}},(i="_onResize")in(n=this)?Object.defineProperty(n,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[i]=r,this.isInBypassMode=s,this.onHeightChange=f,this.onWidthChange=d,this.onNoChange=m,this.getWidth=a,this.getHeight=l,this.listenForResize=u,this.onResize=function(e,t){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=i.onStart,o=i.onStop;return function(){for(var i=this,s=arguments.length,a=new Array(s),l=0;l<s;l++)a[l]=arguments[l];return new Promise(function(s){n?W(n):r&&r(),n=D(function(){n=void 0,o&&o(),e.apply(i,a),s()},t)})}}(this._onResize,ve,{onStart:h,onStop:c})}var t,n,i;return t=e,(n=[{key:"start",value:function(){this.isActive=!0,this.isInBypassMode()||(this.width=this.getWidth(),this.height=this.getHeight(),this.unlistenResize=this.listenForResize(this.onResize))}},{key:"stop",value:function(){this.isActive=!1,this.width=void 0,this.height=void 0,this.unlistenResize&&(this.unlistenResize(),this.unlistenResize=void 0)}}])&&pe(t.prototype,n),i&&pe(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}(),ve=250;function ye(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function Se(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ye(Object(n),!0).forEach(function(t){be(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ye(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function be(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function we(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 Ce=function(){function e(t){var n=t.getState,i=t.getVerticalSpacing,r=t.getColumnsCount;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getState=n,this.getVerticalSpacing=i,this.getColumnsCount=r}var t,n,i;return t=e,n=[{key:"initializeFromState",value:function(e){this._includesBeforeResizeInState=Boolean(e.beforeResize)}},{key:"cleanUpBeforeResizeItemHeights",value:function(){var e=this.getState(),t=e.firstShownItemIndex,n=e.lastShownItemIndex,i=e.itemHeights,r=e.beforeResize;if(r&&t<r.itemHeights.length){G('~ Clean up "before resize" item heights and correct scroll position ~');for(var o=0,s=Math.floor(r.itemHeights.length/this.getColumnsCount()),a=Math.min(s*this.getColumnsCount()-1,n),l=t;l<=a;){for(var u=0,h=0;h<this.getColumnsCount()&&l<=a;){var c=i[l];void 0===c&&(c=this.getAverageItemHeight()),u=Math.max(u,c),l++,h++}o+=u,o+=this.getVerticalSpacing()}for(var f=0,d=Math.min(r.itemHeights.length,n+1),m=Math.ceil(d/r.columnsCount),g=0===t?0:Math.floor((t-1)/r.columnsCount)+1;g<m;)f+=r.itemHeights[g*r.columnsCount],f+=r.verticalSpacing,g++;if(0===t)G('Drop all "before resize" item heights');else{var p=t,I=r.itemHeights.length-1;p===I?G("For item index",p,'— drop "before resize" height',r.itemHeights[p]):G("For item indexes from",p,"to",I,'— drop "before resize" heights',r.itemHeights.slice(p))}return r.itemHeights.splice(t,r.itemHeights.length-t),{scrollBy:o-f,beforeResize:0===t?void 0:Se({},r)}}}},{key:"snapshotBeforeResizeItemHeights",value:function(e){var t=e.firstShownItemIndex,n=e.newFirstShownItemIndex,i=this.getColumnsCount(),r=this.getVerticalSpacing();this._includesBeforeResizeInState=!0;var o=this.getState(),s=o.beforeResize,a=o.itemHeights,l=s?s.itemHeights.length:0;if(l>0){if(s.columnsCount!==i||s.verticalSpacing!==r){for(var u=0,h=Math.ceil(l/s.columnsCount),c=0;c<h;)u+=s.itemHeights[c*s.columnsCount],u+=s.verticalSpacing,c++;for(var f=0,d=t;d<n;){for(var m=0,g=0;g<i&&d<n;)m=Math.max(m,a[d]),g++,d++;f+=m,f+=r}var p=u+f,I=Math.ceil(n/i);return new Array(n).fill(Math.max(0,p/I-r))}return s.itemHeights.concat(Oe(a,n,i).slice(s.itemHeights.length))}return Oe(a,n,i)}},{key:"shouldIncludeBeforeResizeValuesInState",value:function(){return this._includesBeforeResizeInState}}],n&&we(t.prototype,n),i&&we(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Oe(e,t,n){e=e.slice(0,Math.ceil(t/n)*n);for(var i=0;i*n<t;){for(var r=0,o=0;o<n;)r=Math.max(r,e[i*n+o]),o++;for(o=0;o<n;)e[i*n+o]=r,o++;i++}return e.slice(0,t)}function Re(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 xe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var He=function(){function e(t){var n=this,i=t.isInBypassMode,r=t.scrollableContainer,o=t.itemsContainer,s=t.onScroll,a=t.initialScrollPosition,l=t.onScrollPositionChange,u=t.isImmediateLayoutScheduled,h=t.hasNonRenderedItemsAtTheTop,c=t.hasNonRenderedItemsAtTheBottom,f=t.getLatestLayoutVisibleArea,d=t.getListTopOffset,m=t.getPrerenderMargin,g=t.onScrolledToTop,p=t.waitForScrollingToStop;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),xe(this,"scrollByY",function(e){n.scrollToY(n.getScrollY()+e)}),xe(this,"onScrollListener",function(){if(n.onScrollPositionChange&&n.onScrollPositionChange(n.getScrollY()),n.onScrolledToTop&&n.getScrollY()<n.getListTopOffset()&&n.onScrolledToTop(),!n.isInBypassMode()&&!n.ignoreScrollEvents){n.cancelOnStopScrollingTimer();var e=n.getLatestLayoutVisibleArea()&&(n.getScrollY()<n.getLatestLayoutVisibleArea().top-n.getPrerenderMargin()&&n.hasNonRenderedItemsAtTheTop()||n.getScrollY()+n.scrollableContainer.getHeight()>n.getLatestLayoutVisibleArea().bottom+n.getPrerenderMargin()&&n.hasNonRenderedItemsAtTheBottom());if(G(e?"The user has scrolled far enough: perform a re-layout":"The user is scrolling: perform a re-layout when they stop scrolling"),e||!1===n.waitForScrollingToStop)return n.onScroll();n.isImmediateLayoutScheduled()||(n.shouldCallOnScrollListenerWhenStopsScrolling=!0,n.watchOnStopScrolling())}}),this.isInBypassMode=i,this.scrollableContainer=r,this.itemsContainer=o,this.onScroll=s,this.initialScrollPosition=a,this.onScrollPositionChange=l,this.isImmediateLayoutScheduled=u,this.hasNonRenderedItemsAtTheTop=h,this.hasNonRenderedItemsAtTheBottom=c,this.getLatestLayoutVisibleArea=f,this.getListTopOffset=d,this.getPrerenderMargin=m,this.onScrolledToTop=g,this.waitForScrollingToStop=p}var t,n,i;return t=e,(n=[{key:"start",value:function(){void 0!==this.initialScrollPosition&&(this.scrollToY(this.initialScrollPosition),this.initialScrollPosition=void 0),this.onScrollPositionChange&&this.onScrollPositionChange(this.getScrollY()),this.stopListeningToScroll=this.scrollableContainer.onScroll(this.onScrollListener)}},{key:"stop",value:function(){this.stopListeningToScroll(),this.stopListeningToScroll=void 0,this.shouldCallOnScrollListenerWhenStopsScrolling=void 0,this.cancelOnStopScrollingTimer()}},{key:"scrollToY",value:function(e){this.ignoreScrollEvents=!0,this.scrollableContainer.scrollToY(e),this.ignoreScrollEvents=void 0}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"cancelOnStopScrollingTimer",value:function(){this.onStopScrollingTimer&&(W(this.onStopScrollingTimer),this.onStopScrollingTimer=void 0)}},{key:"cancelScheduledLayout",value:function(){this.cancelOnStopScrollingTimer()}},{key:"watchOnStopScrolling",value:function(){var e=this;this.onStopScrollingTimer=D(function(){e.onStopScrollingTimer=void 0,e.shouldCallOnScrollListenerWhenStopsScrolling&&(e.shouldCallOnScrollListenerWhenStopsScrolling=void 0,e.onScroll({delayed:!0}))},Te)}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}}])&&Re(t.prototype,n),i&&Re(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}(),Te=100;function Pe(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 je=function(){function e(t){var n=t.itemsContainer,i=t.getListTopOffset;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.itemsContainer=n,this.getListTopOffset=i}var t,n,i;return t=e,(n=[{key:"snapshotListHeightBeforeAddingNewItems",value:function(e){var t=e.previousItems,n=e.newItems,i=e.prependedItemsCount;0!==t.length&&0!==i&&(this._snapshot={previousItems:t,newItems:n,itemIndex:i,itemTopOffset:this.itemsContainer.getNthRenderedItemTopOffset(0),listTopOffset:this.getListTopOffset()})}},{key:"getAnchorItemIndex",value:function(){return this._snapshot.itemIndex}},{key:"hasSnapshot",value:function(){return void 0!==this._snapshot}},{key:"getListBottomOffsetChange",value:function(){var e=this._snapshot,t=e.itemIndex,n=e.itemTopOffset,i=e.listTopOffset;return this.itemsContainer.getNthRenderedItemTopOffset(t)-n+(this.getListTopOffset()-i)}},{key:"reset",value:function(){this._snapshot=void 0}}])&&Pe(t.prototype,n),i&&Pe(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Ee(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 Me=function(){function e(t){var n=t.container,i=t.getItemHeight,r=t.setItemHeight;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.container=n,this._get=i,this._set=r,this.reset()}var t,n,i;return t=e,n=[{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"readItemHeightsFromState",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){return this.container.getNthRenderedItemHeight(e-t)}},{key:"measureItemHeights",value:function(e,t){if(G("~ Measure item heights ~"),void 0!==e){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(G("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);var a=this._measureItemHeight(s,e);G("Item index",s,"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&&($("Item index",s,"height changed unexpectedly: it was",l,"before, but now it is",u,'. Whenever an item\'s height changes for whatever reason, a developer must call `onItemHeightDidChange(item)` right after that change. If you are calling `onItemHeightDidChange(item)` correctly, then there\'re several other possible causes. For example, perhaps you forgot to persist the item\'s "state" by calling `setItemState(item, newState)` when that "state" did change, and so the item\'s "state" got lost when the item element was unmounted, which resulted in a different item height when the item was shown again with no previous "state". Or perhaps you\'re running your application in "devleopment" mode and `VirtualScroller` has initially rendered the list before your CSS styles or custom fonts have loaded, resulting in different item height measurements "before" and "after" the page has fully loaded.'),this._set(s,u))}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:"getAverageItemHeight",value:function(){if(void 0!==this.lastMeasuredItemIndex)return this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}],n&&Ee(t.prototype,n),i&&Ee(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Be(e,t){for(var n=0;n<e.length;)e[n]=t(n),n++;return e}function Le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function ze(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Le(Object(n),!0).forEach(function(t){Ae(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Le(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ae(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _e(e){var t=ze({},e);return e.itemHeights&&(t.itemHeights=e.itemHeights.slice()),e.itemStates&&(t.itemStates=e.itemStates.slice()),e.beforeResize&&(t.beforeResize=ze({},e.beforeResize),t.beforeResize.itemHeights=e.beforeResize.itemHeights.slice()),t}function ke(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function Ve(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ke(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ke(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function De(e){var t=this,n=e.state,i=e.getInitialItemState,r=e.onStateChange,o=e.render,s=e.items;function a(){return this.state}function l(e){this.state=e}function u(e,t){this.state=e,o(this.state,this.previousState),this.onRender()}function h(e){var t=e.getInitialItemState,n=s,i=Ve(Ve({},f.call(this,n,{beforeStart:!0})),{},{items:n,itemStates:Be(new Array(n.length),function(e){return t(n[e])})});return X()&&G("Initial state (autogenerated)",_e(i)),G("First shown item index",i.firstShownItemIndex),G("Last shown item index",i.lastShownItemIndex),i}function c(e){return X()&&G("Restore state",_e(e)),function(e,t){var n=t.columnsCount,i=e.columnsCount||1;if(i!==n)return $("~ Columns Count changed from",i,"to",n,"~"),!0;var r=Math.floor(e.firstShownItemIndex/n)*n;if(r!==e.firstShownItemIndex)return $("~ First Shown Item Index",e.firstShownItemIndex,"is not divisible by Columns Count",n,"~"),!0}(e=Ve(Ve({},e=function(e){return e.beforeResize&&0===e.beforeResize.itemHeights.length&&(e.beforeResize=void 0),e}(e)),{},{verticalSpacing:void 0}),{columnsCount:this.getActualColumnsCount()})&&($("Reset Layout"),e=Ve(Ve({},e),f.call(this,e.items,{beforeStart:!1}))),e}function f(e,t){var n=t.beforeStart,i=e.length,r=this.layout.getInitialLayoutValues({itemsCount:i,columnsCount:this.getActualColumnsCount(),beforeStart:n}),o=r.firstShownItemIndex,s=r.lastShownItemIndex,a=r.beforeItemsHeight,l=r.afterItemsHeight,u=new Array(i);return this.onBeforeShowItems(e,u,o,s),{itemHeights:u,columnsCount:this.getActualColumnsCountForState(),verticalSpacing:this.verticalSpacing,firstShownItemIndex:o,lastShownItemIndex:s,beforeItemsHeight:a,afterItemsHeight:l}}this.onStateChange=r,this._render=o,this.getInitialItemState=i,this._setItemState=function(e,n){var i=t._getItemIndexByItemOrIndex(e);void 0!==i&&(X()&&(G("~ Item state changed ~"),G("Item index",i),G("Previous state\n"+JSON.stringify(t.getState().itemStates[i],null,2)),G("New state\n"+JSON.stringify(n,null,2))),t.getState().itemStates[i]=n,t.newItemsWillBeRendered&&(t.itemStatesThatChangedWhileNewItemsWereBeingRendered||(t.itemStatesThatChangedWhileNewItemsWereBeingRendered={}),t.itemStatesThatChangedWhileNewItemsWereBeingRendered[String(i)]=n))},this.getState=function(){return t._getState()},this.updateState=function(e){X()&&(G("~ Set state ~"),G(_e(e))),e.items&&(t._isSettingNewItems||Q("A `stateUpdate` can only contain `items` property as a result of calling `.setItems()`")),t._isSettingNewItems=void 0,t.waitingForRender=!0,t.previousState=t.getState(),t.mostRecentSetStateValue||(t.mostRecentSetStateValue=t.getState()),t.mostRecentSetStateValue=Ve(Ve({},t.mostRecentSetStateValue),e),t._setState(t.mostRecentSetStateValue,e)},this.getInitialState=function(){return n?c.call(t,n):h.call(t,{getInitialItemState:i})},this.useState=function(e){var n=e.getState,i=e.setState,r=e.updateState;if(t._isActive)throw new Error("[virtual-scroller] `VirtualScroller` has already been started");if(t._getState)throw new Error("[virtual-scroller] Custom state storage has already been configured");if(o)throw new Error("[virtual-scroller] Creating a `VirtualScroller` class instance with a `render()` parameter implies using the default (internal) state storage");if(i&&r)throw new Error("[virtual-scroller] When using a custom state storage, one must supply either `setState()` or `updateState()` function but not both");if(!n||!i&&!r)throw new Error("[virtual-scroller] When using a custom state storage, one must supply both `getState()` and `setState()`/`updateState()` functions");t._usesCustomStateStorage=!0,t._getState=n,t._setState=function(e,t){i?i(e):r(t)}},this.useDefaultStateStorage=function(){if(!o)throw new Error("[virtual-scroller] When using the default (internal) state management, one must supply a `render(state, prevState)` function parameter");t._getState=a.bind(t),t._setState=u.bind(t),l.bind(t)(t.getInitialState())},this.setUpState=function(){t._usesCustomStateStorage||t.useDefaultStateStorage()}}var We=.9;function Fe(e){var t=this,n=e.getEstimatedInterItemVerticalSpacing;function i(){var e=this.getState(),t=e.firstShownItemIndex,n=e.lastShownItemIndex;G("~ Measure item vertical spacing ~");var i=function(e){var t=e.itemsContainer,n=e.renderedItemsCount;if(n>1)for(var i=t.getNthRenderedItemTopOffset(0),r=t.getNthRenderedItemHeight(0),o=1;o<n;){var s=t.getNthRenderedItemTopOffset(o),a=t.getNthRenderedItemHeight(o);if(s+We>=i+r){var l=s-(i+r);return Math.max(0,l)}r=Math.max(r,a),o++}}({itemsContainer:this.itemsContainer,renderedItemsCount:n-t+1});if(void 0!==i)return G("Item vertical spacing",i),i;G("Not enough items rendered to measure vertical spacing")}this.getVerticalSpacing=function(){var e=t.verticalSpacing;return"number"==typeof e?e:t.getEstimatedInterItemVerticalSpacing()},this.getVerticalSpacingBeforeResize=function(){var e=t.getState().beforeResize;if(e){var n=e.verticalSpacing;return"number"==typeof n?n:t.getEstimatedInterItemVerticalSpacing()}},this.getEstimatedInterItemVerticalSpacing=function(){if(n){var e=n();if("number"==typeof e)return e;throw new Error("[virtual-scroller] `getEstimatedInterItemVerticalSpacing()` must return a number")}return 0},this.measureVerticalSpacingIfNotMeasured=function(){if(void 0===t.verticalSpacing)return t.verticalSpacing=i.call(t),t.verticalSpacing}}function Ue(e){var t=this,n=e.getColumnsCount;if(n){var i={getWidth:function(){return t.scrollableContainer.getWidth()}};this.getActualColumnsCountForState=function(){var e=n(i);if(1!==e)return e}}else this.getActualColumnsCountForState=function(){};this.getActualColumnsCount=function(){return t.getActualColumnsCountForState()||1},this.getColumnsCount=function(){return t.getState()&&t.getState().columnsCount||1}}function Ye(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function qe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ye(Object(n),!0).forEach(function(t){Je(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ye(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Je(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ge(){var e=this;function t(e){var n=e.stateUpdate,o=Date.now(),s=i.call(this),a=s.firstShownItemIndex,l=s.lastShownItemIndex,u=s.shownItemsHeight,h=s.firstNonMeasuredItemIndex;if(this.listHeightMeasurement.hasSnapshot()&&(l<this.listHeightMeasurement.getAnchorItemIndex()&&(l=this.listHeightMeasurement.getAnchorItemIndex()),h=void 0),!r.call(this,a,l))return G("~ Because some of the will-be-hidden item heights (listed above) have changed since they've last been measured, redo layout. ~"),t.call(this,{stateUpdate:n});var c=this.layout.getBeforeItemsHeight(a),f=this.layout.getAfterItemsHeight(l,this.getItemsCount()),d=Date.now()-o;G("~ Calculated Layout"+(this.isInBypassMode()?" (bypass)":"")+" ~"),d<$e||$("Layout calculated in",d,"ms"),this.getColumnsCount()&&G("Columns count",this.getColumnsCount()),G("First shown item index",a),G("Last shown item index",l),G("Before items height",c),G("After items height (actual or estimated)",f),G("Average item height (used for estimated after items height calculation)",this.getAverageItemHeight()),X()&&(G("Item heights",this.getState().itemHeights.slice()),G("Item states",this.getState().itemStates.slice())),this.onBeforeShowItems(this.getState().items,this.getState().itemHeights,a,l),this.firstNonMeasuredItemIndex=h,this.previouslyCalculatedLayout=void 0===u?void 0:{firstShownItemIndex:a,lastShownItemIndex:l,beforeItemsHeight:c,shownItemsHeight:u},this.updateState(qe({firstShownItemIndex:a,lastShownItemIndex:l,beforeItemsHeight:c,afterItemsHeight:f},n))}function n(){var e=this.scroll.getVisibleAreaBounds();this.latestLayoutVisibleArea=e;var t=this.getListTopOffsetInsideScrollableContainer();return{top:e.top-t,bottom:e.bottom-t}}function i(){var e=this.getItemsCount(),t=n.call(this);return this.isInBypassMode()?{firstShownItemIndex:0,lastShownItemIndex:e-1}:t.top<this.itemsContainer.getHeight()+this.layout.getPrerenderMargin()&&t.bottom>0-this.layout.getPrerenderMargin()?this.layout.getShownItemIndexes({itemsCount:this.getItemsCount(),visibleAreaInsideTheList:t}):(G("The entire list is off-screen. No items are visible."),this.layout.getNonVisibleListShownItemIndexes())}function r(e,t){for(var n=!0,i=this.getState().firstShownItemIndex;i<=this.getState().lastShownItemIndex;){if(i>=e&&i<=t);else{var r=this.getState().itemHeights[i],a=o.call(this,i);a!==r&&(n&&(G("~ Validate will-be-hidden item heights. ~"),s.call(this,i,r,a)),n=!1,$("Item index",i,"is no longer visible and will be unmounted. Its height has changed from",r,"to",a,"since it was last measured. This is not necessarily a bug, and could happen, for example, on screen width change, or when there're several `onItemHeightDidChange(item)` calls issued at the same time, and the first one triggers a re-layout before the rest of them have had a chance to be executed."))}i++}return n}function o(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}function s(e,t,n){var i=this.previouslyCalculatedLayout;if(i){var r=n-t;e<i.firstShownItemIndex?i.beforeItemsHeight+=r:e>i.lastShownItemIndex?void 0!==i.afterItemsHeight&&(i.afterItemsHeight+=r):i.shownItemsHeight+=n-t}}this.onUpdateShownItemIndexes=function(n){var i=n.reason,r=n.stateUpdate,o=function(){r&&e.updateState(r)};return e.newItemsWillBeRendered||e.widthHasChanged||e._isResizing||0===e.getItemsCount()?o():(e.scroll.cancelScheduledLayout(),r=e.cancelLayoutTimer({stateUpdate:r}),G("~ Update Layout (on ".concat(i,") ~")),void t.call(e,{stateUpdate:r}))},this.getListTopOffsetInsideScrollableContainer=function(){var t=e.scrollableContainer.getItemsContainerTopOffset();return e.listTopOffsetWatcher&&e.listTopOffsetWatcher.onListTopOffset(t),t},this._onItemHeightDidChange=function(t){var n=e._getItemIndexByItemOrIndex(t);if(void 0!==n){var i=e.getState(),r=i.itemHeights,a=i.firstShownItemIndex,u=i.lastShownItemIndex;if(G("~ On Item Height Did Change was called ~"),G("Item index",n),!(n>=a&&n<=u))return $("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when when a developer calls `onItemHeightDidChange(item)` while looping through a batch of items.");var h=r[n];if(void 0!==h){var c;G("~ Re-measure item height ~");try{c=o.call(e,n)}catch(e){if(e instanceof l)return Q('"onItemHeightDidChange()" has been called for item index '.concat(n," but the item is not currently rendered and can't be measured. The exact error was: ").concat(e.message))}G("Previous height",h),G("New height",c),h!==c&&(G("~ Item height has changed. Should update layout. ~"),s.call(e,n,h,c),e._isActive&&(e.waitingForRender?(G("~ Another state update is already waiting to be rendered. Delay the layout update until then. ~"),e.updateLayoutAfterRenderBecauseItemHeightChanged=!0):e.onUpdateShownItemIndexes({reason:de})),e.newItemsWillBeRendered&&(e.itemHeightsThatChangedWhileNewItemsWereBeingRendered||(e.itemHeightsThatChangedWhileNewItemsWereBeingRendered={}),e.itemHeightsThatChangedWhileNewItemsWereBeingRendered[String(n)]=c))}}},this.getPrerenderMargin=function(){return e.scrollableContainer.getHeight()*e.getPrerenderMarginRatio()},this.getPrerenderMarginRatio=function(){return 1},this.onBeforeShowItems=function(t,n,i,r){if(e.onItemInitialRender)for(var o=i;o<=r;)void 0===n[o]&&e.onItemInitialRender(t[o]),o++},this.measureItemHeightsAndSpacing=function(){e.itemHeights.measureItemHeights(e.getState().firstShownItemIndex,e.getState().lastShownItemIndex);var t=e.measureVerticalSpacingIfNotMeasured();if(t&&0!==t)return{verticalSpacing:t}},this.cancelLayoutTimer=function(t){var n=t.stateUpdate;return e.layoutTimer?(W(e.layoutTimer),e.layoutTimer=void 0,n||e.layoutTimerStateUpdate?(n=qe(qe({},e.layoutTimerStateUpdate),n),e.layoutTimerStateUpdate=void 0,n):void 0):n},this.scheduleLayoutTimer=function(t){var n=t.reason,i=t.stateUpdate;e.layoutTimerStateUpdate=i,e.layoutTimer=D(function(){e.layoutTimerStateUpdate=void 0,e.layoutTimer=void 0,e.onUpdateShownItemIndexes({reason:n,stateUpdate:i})},0)}}var $e=15;function Ke(e){return Ke="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},Ke(e)}var Qe=Object.prototype.hasOwnProperty;function Xe(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function Ze(e,t){if(Xe(e,t))return!0;if("object"!==Ke(e)||null===e||"object"!==Ke(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(!Qe.call(t,n[r])||!Xe(e[n[r]],t[n[r]]))return!1;return!0}function et(e){return(e%1==0?e:e.toFixed(2))+"px"}function tt(){return!("undefined"!=typeof window&&Boolean(window.document.documentMode))}var nt="VirtualScroller",it="VirtualScrollerStyle";function rt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function ot(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rt(Object(n),!0).forEach(function(t){st(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function st(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function at(){var e=this;function t(e,t){if(e){var n=e.prependedItemsCount;e.appendedItemsCount;var i=this.getState(),r=i.itemHeights,o=i.itemStates;if(this.itemHeightsThatChangedWhileNewItemsWereBeingRendered)for(var s=0,a=Object.keys(this.itemHeightsThatChangedWhileNewItemsWereBeingRendered);s<a.length;s++){var l=a[s];r[n+Number(l)]=this.itemHeightsThatChangedWhileNewItemsWereBeingRendered[l]}if(this.itemStatesThatChangedWhileNewItemsWereBeingRendered)for(var u=0,h=Object.keys(this.itemStatesThatChangedWhileNewItemsWereBeingRendered);u<h.length;u++){var c=h[u];o[n+Number(c)]=this.itemStatesThatChangedWhileNewItemsWereBeingRendered[c]}if(0===n)return this.previouslyCalculatedLayout&&(this.previouslyCalculatedLayout.firstShownItemIndex===t.firstShownItemIndex&&this.previouslyCalculatedLayout.lastShownItemIndex===t.lastShownItemIndex||($('Unexpected (non-matching) "firstShownItemIndex" or "lastShownItemIndex" encountered in "onRender()" after appending items'),$("Previously calculated layout",this.previouslyCalculatedLayout),$("New layout",t),this.previouslyCalculatedLayout=void 0)),"SEAMLESS_APPEND";if(this.listHeightMeasurement.hasSnapshot()){if(0===t.firstShownItemIndex){G("~ Restore Scroll Position ~");var f=this.listHeightMeasurement.getListBottomOffsetChange({beforeItemsHeight:t.beforeItemsHeight});return this.listHeightMeasurement.reset(),f?(G("Scroll down by",f),this.scroll.scrollByY(f)):G("Scroll position hasn't changed"),this.previouslyCalculatedLayout&&(0===this.previouslyCalculatedLayout.firstShownItemIndex&&this.previouslyCalculatedLayout.lastShownItemIndex===t.lastShownItemIndex-n?this.previouslyCalculatedLayout={beforeItemsHeight:0,shownItemsHeight:this.previouslyCalculatedLayout.shownItemsHeight+f,firstShownItemIndex:0,lastShownItemIndex:t.lastShownItemIndex}:($('Unexpected (non-matching) "firstShownItemIndex" or "lastShownItemIndex" encountered in "onRender()" after prepending items'),$("Previously calculated layout",this.previouslyCalculatedLayout),$("New layout",t),this.previouslyCalculatedLayout=void 0)),"SEAMLESS_PREPEND"}$('Unexpected "firstShownItemIndex" '.concat(t.firstShownItemIndex,' encountered in "onRender()" after prepending items. Expected 0.'))}}this.previouslyCalculatedLayout=void 0}function n(e){var t=e.reason,n=e.stateUpdate;this._useTimeoutInRenderLoop?(n=this.cancelLayoutTimer({stateUpdate:n}),this.scheduleLayoutTimer({reason:t,stateUpdate:n})):this.onUpdateShownItemIndexes({reason:t,stateUpdate:n})}function i(){var e=Boolean(this.widthHasChanged);this.widthHasChanged=void 0;var t=void 0!==this.firstNonMeasuredItemIndex;t&&G("Non-measured item index",this.firstNonMeasuredItemIndex),this.firstNonMeasuredItemIndex=void 0,this.newItemsWillBeRendered=void 0,this.itemHeightsThatChangedWhileNewItemsWereBeingRendered=void 0,this.itemStatesThatChangedWhileNewItemsWereBeingRendered=void 0;var n=this.updateLayoutAfterRenderBecauseItemHeightChanged;return this.updateLayoutAfterRenderBecauseItemHeightChanged=void 0,{nonMeasuredItemsHaveBeenRendered:t,itemHeightHasChanged:n,widthHasChanged:e}}this._onRender=function(r,o){var s,a,l;e.waitingForRender=!1,G("~ Rendered ~"),X()&&G("State",_e(r)),e.onStateChange&&(Ze(r,o)||e.onStateChange(r)),e.isItemsContainerElementTableBody()&&(s=e.getItemsContainerElement(),a=r.beforeItemsHeight,l=r.afterItemsHeight,s.style.setProperty("--VirtualScroller-paddingTop",et(a)),s.style.setProperty("--VirtualScroller-paddingBottom",et(l))),e.mostRecentSetStateValue&&(Ze(r,e.mostRecentSetStateValue)||($("The most recent state that was set",_e(e.mostRecentSetStateValue)),Q("`VirtualScroller` has been rendered with a `state` that is not equal to the most recently set one")));var u,h=i.call(e),c=h.nonMeasuredItemsHaveBeenRendered,f=h.itemHeightHasChanged,d=h.widthHasChanged;if(f&&(u=de),o||u){if(c&&(u=ue),d&&(u=he,e.itemHeights.reset(),e.verticalSpacing=void 0),o){var m=o.items,g=r.items;if(g!==m){var p=e.getItemsDiff(m,g);if(p){var I=p.prependedItemsCount;e.itemHeights.onPrepend(I)}else e.itemHeights.reset();d||"SEAMLESS_PREPEND"!==t.call(e,p,r)&&(u=me)}}var v;if(o&&(r.firstShownItemIndex!==o.firstShownItemIndex||r.lastShownItemIndex!==o.lastShownItemIndex||r.items!==o.items)||d){var y=e.measureItemHeightsAndSpacing();y&&(v=ot(ot({},v),y))}var S=e.beforeResize.cleanUpBeforeResizeItemHeights();if(void 0!==S){var b=S.scrollBy,w=S.beforeResize;G("Correct scroll position by",b),e.scroll.scrollByY(b),v=ot(ot({},v),{},{beforeResize:w})}e._isActive?u?n.call(e,{stateUpdate:v,reason:u}):v?e.updateState(v):G("~ Finished Layout ~"):e._afterRenderStateUpdateThatWasStopped=v}}}function lt(){var e=this;this.onContainerResize=function(){e.previouslyCalculatedLayout=void 0,e.listHeightMeasurement.reset();var t=e.newItemsWillBeRendered?e.newItemsWillBeRendered.count:e.getState().itemHeights.length,n=e.newItemsWillBeRendered?e.newItemsWillBeRendered.layout:e.getState(),i={scrollableContainerWidth:e.scrollableContainer.getWidth(),firstShownItemIndex:n.firstShownItemIndex,lastShownItemIndex:n.lastShownItemIndex,beforeItemsHeight:n.beforeItemsHeight,afterItemsHeight:n.afterItemsHeight,itemHeights:new Array(t),columnsCount:e.getActualColumnsCountForState(),verticalSpacing:void 0},r=n.firstShownItemIndex,o=n.lastShownItemIndex,s=e.getActualColumnsCount(),a=Math.floor(r/s)*s,l=Math.min(Math.ceil((o+1)/s)*s,t)-1;a!==r&&(G("Columns Count changed from",e.getState().columnsCount||1,"to",s),G("First Shown Item Index needs to change from",r,"to",a)),i.firstShownItemIndex=a,i.lastShownItemIndex=l;var u=e.getVerticalSpacing(),h=e.getColumnsCount();e.shouldDiscardBeforeResizeItemHeights()||0===a?e.beforeResize.shouldIncludeBeforeResizeValuesInState()&&(i.beforeResize=void 0):i.beforeResize={verticalSpacing:u,columnsCount:h,itemHeights:e.beforeResize.snapshotBeforeResizeItemHeights({firstShownItemIndex:r,newFirstShownItemIndex:a})},e.widthHasChanged={stateUpdate:i},e.updateState(i)},this.shouldDiscardBeforeResizeItemHeights=function(){if(e.newItemsWillBeRendered){var t=e.newItemsWillBeRendered,n=t.prepend,i=t.replace;return n||i}}}function ut(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function ht(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ut(Object(n),!0).forEach(function(t){ct(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ut(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ct(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ft(){var e=this;this.getItemsCount=function(){return e.getState().items.length},this._getItemIndexByItemOrIndex=function(t){var n=t,i=e.getState().items,r=i.indexOf(n);if(r>=0)return r;if("number"==typeof t){var o=t;if(o>=0&&o<i.length)return o}else{var s=e._getItemId;if(s){var a=s(n),l=i.findIndex(function(e){return s(e)===a});if(l>=0)return l}}Q("Item not found: ".concat(JSON.stringify(n)))},this._setItems=function(t){var n,i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=e.getState().items,s=e.getState().itemStates,a=(e.widthHasChanged?e.widthHasChanged.stateUpdate:e.getState()).itemHeights;G("~ Update items ~");var l=e.getItemsDiff(o,t);if(l){var u,h=e.widthHasChanged?e.widthHasChanged.stateUpdate:e.getState(),c=h.firstShownItemIndex,f=h.lastShownItemIndex,d=h.beforeItemsHeight,m=h.afterItemsHeight,g=0===c&&(r.preserveScrollPositionOnPrependItems||r.preserveScrollPosition),p=l.prependedItemsCount,I=l.appendedItemsCount;n=e.layout.getLayoutUpdateForItemsDiff({firstShownItemIndex:c,lastShownItemIndex:f,beforeItemsHeight:d,afterItemsHeight:m},{prependedItemsCount:p,appendedItemsCount:I},{itemsCount:t.length,columnsCount:e.getActualColumnsCount(),shouldRestoreScrollPosition:g,onResetGridLayout:function(){return u=!0}}),p>0&&(G("Prepend",p,"items"),a=new Array(p).concat(a),s=Be(new Array(p),function(n){return e.getInitialItemState(t[n])}).concat(s),g?(G("Will restore scroll position"),e.listHeightMeasurement.snapshotListHeightBeforeAddingNewItems({previousItems:o,newItems:t,prependedItemsCount:p}),void 0!==e.firstNonMeasuredItemIndex&&(e.firstNonMeasuredItemIndex+=p)):(G("Reset layout"),u?(G("Reason: Prepended items count",p,"is not divisible by Columns Count",e.getActualColumnsCount()),a=new Array(t.length)):G("Reason: Prepended items' heights are unknown"),n=e.layout.getInitialLayoutValues({itemsCount:t.length,columnsCount:e.getActualColumnsCount()}),e.firstNonMeasuredItemIndex=void 0)),I>0&&(G("Append",I,"items"),a=a.concat(new Array(I)),s=s.concat(Be(new Array(I),function(n){return e.getInitialItemState(t[p+o.length+n])}))),i={prepend:p>0,append:I>0}}else G("Items have changed, and",l?"a re-layout from scratch has been requested.":"it's not a simple append and/or prepend.","Rerender the entire list from scratch."),G("Previous items",o),G("New items",t),a=new Array(t.length),s=Be(new Array(t.length),function(n){return e.getInitialItemState(t[n])}),n=e.layout.getInitialLayoutValues({itemsCount:t.length,columnsCount:e.getActualColumnsCount()}),e.firstNonMeasuredItemIndex=void 0,e.listHeightMeasurement.reset(),i={replace:!0};G("~ Update state ~"),G("First shown item index",n.firstShownItemIndex),G("Last shown item index",n.lastShownItemIndex),G("Before items height",n.beforeItemsHeight),G("After items height (actual or estimated)",n.afterItemsHeight),e.onBeforeShowItems(t,a,n.firstShownItemIndex,n.lastShownItemIndex),e.newItemsWillBeRendered=ht(ht({},i),{},{count:t.length,layout:n});var v=ht(ht({},n),{},{items:t,itemStates:s,itemHeights:a});e.beforeResize.shouldIncludeBeforeResizeValuesInState()&&(e.shouldDiscardBeforeResizeItemHeights()?v.beforeResize=void 0:v.beforeResize=e.widthHasChanged?e.widthHasChanged.stateUpdate.beforeResize:e.getState().beforeResize),e._isSettingNewItems=!0,e.updateState(v)},this.getItemsDiff=function(t,n){return function(e,t,n){var i=-1,r=-1;if(e.length>0&&(i=function(e,t,n){for(var i=0;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n),i>=0&&function(e,t,n,i){for(var r=0;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)),i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(t,n,e.isItemEqual)}}function dt(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=i.bypass,o=i.render,s=i.state,a=i.getInitialItemState,l=void 0===a?function(){}:a,u=i.onStateChange,h=i.initialScrollPosition,c=i.onScrollPositionChange,f=i.scrollableContainer,d=i.measureItemsBatchSize,m=void 0===d?50:d,g=i.getColumnsCount,p=i.getItemId,I=i.estimatedItemHeight,v=i.getEstimatedVisibleItemRowsCount,y=i.getEstimatedInterItemVerticalSpacing,S=i.onItemInitialRender,b=i.onItemFirstRender,w=i._useTimeoutInRenderLoop,C=i._waitForScrollingToStop,O=i.engine,R=i.getEstimatedItemHeight,x=i.getScrollableContainer;if(G("~ Initialize ~"),this.engine=O||Y,R||"number"!=typeof I||(R=function(){return I}),!x&&f&&(x=function(){return f}),this.getItemsContainerElement=function(){var t=e();if(null===t)throw new Error("[virtual-scroller] Items container element is `null`");return t},i.getState||i.setState)throw new Error("[virtual-scroller] `getState`/`setState` options usage has changed in the new version. See the readme for more details.");r&&G('~ "bypass" mode ~'),this._bypass=r,this._useTimeoutInRenderLoop=w,this._getItemId=p,this.isItemEqual=p?function(e,t){return p(e)===p(t)}:function(e,t){return e===t},S?this.onItemInitialRender=S:b&&(this.onItemInitialRender=function(e){$("`onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=n.getState().items.indexOf(e);t>=0&&b(t)}),s&&(t=s.items),G("Items count",t.length),R&&G("Estimated item height",R()),De.call(this,{state:s,getInitialItemState:l,onStateChange:u,render:o,items:t}),Fe.call(this,{getEstimatedInterItemVerticalSpacing:y}),Ue.call(this,{getColumnsCount:g}),Ge.call(this),at.call(this),lt.call(this),ft.call(this),mt.call(this,{getScrollableContainer:x,getEstimatedItemHeight:R,getEstimatedVisibleItemRowsCount:v,measureItemsBatchSize:m,initialScrollPosition:h,onScrollPositionChange:c,waitForScrollingToStop:C}),s&&(this.itemHeights.readItemHeightsFromState(s),this.beforeResize.initializeFromState(s))}function mt(e){var t=this,n=e.getScrollableContainer,i=e.getEstimatedItemHeight,r=e.getEstimatedVisibleItemRowsCount,o=e.measureItemsBatchSize,s=e.initialScrollPosition,a=e.onScrollPositionChange,l=e.waitForScrollingToStop;this.itemsContainer=this.engine.createItemsContainer(this.getItemsContainerElement),this.isItemsContainerElementTableBody=function(){return t.engine===Y&&"TBODY"===t.getItemsContainerElement().tagName},this.isInBypassMode=function(){return t._bypass},this.scrollableContainer=this.engine.createScrollableContainer(n,this.getItemsContainerElement),this.itemHeights=new Me({container:this.itemsContainer,getItemHeight:function(e){return t.getState().itemHeights[e]},setItemHeight:function(e,n){return t.getState().itemHeights[e]=n}}),this.getAverageItemHeight=function(){var e=t.itemHeights.getAverageItemHeight();return"number"==typeof e?e:t.getEstimatedItemHeight()},this.getEstimatedItemHeight=function(){if(i){var e=i();if("number"==typeof e)return e;throw new Error("[virtual-scroller] `getEstimatedItemHeight()` must return a number")}return 0},this.layout=new re({isInBypassMode:this.isInBypassMode,getEstimatedVisibleItemRowsCountForInitialRender:r,measureItemsBatchSize:o,getPrerenderMargin:function(){return t.getPrerenderMargin()},getPrerenderMarginRatio:function(){return t.getPrerenderMarginRatio()},getVerticalSpacing:function(){return t.getVerticalSpacing()},getVerticalSpacingBeforeResize:function(){return t.getVerticalSpacingBeforeResize()},getColumnsCount:function(){return t.getColumnsCount()},getColumnsCountBeforeResize:function(){return t.getState().beforeResize&&t.getState().beforeResize.columnsCount},getItemHeight:function(e){return t.getState().itemHeights[e]},getItemHeightBeforeResize:function(e){return t.getState().beforeResize&&t.getState().beforeResize.itemHeights[e]},getBeforeResizeItemsCount:function(){return t.getState().beforeResize?t.getState().beforeResize.itemHeights.length:0},getAverageItemHeight:function(){return t.getAverageItemHeight()},getMaxVisibleAreaHeight:function(){return t.scrollableContainer&&t.scrollableContainer.getHeight()},getPreviouslyCalculatedLayout:function(){return t.previouslyCalculatedLayout}}),this.scrollableContainerResizeHandler=new Ie({isInBypassMode:this.isInBypassMode,getWidth:function(){return t.scrollableContainer.getWidth()},getHeight:function(){return t.scrollableContainer.getHeight()},listenForResize:function(e){return t.scrollableContainer.onResize(e)},onResizeStart:function(){G("~ Scrollable container resize started ~"),t._isResizing=!0},onResizeStop:function(){G("~ Scrollable container resize finished ~"),t._isResizing=void 0},onNoChange:function(){t.onUpdateShownItemIndexes({reason:fe})},onHeightChange:function(){return t.onUpdateShownItemIndexes({reason:ce})},onWidthChange:function(e,n){G("~ Scrollable container width changed from",e,"to",n,"~"),t.onContainerResize()}}),this.scroll=new He({isInBypassMode:this.isInBypassMode,scrollableContainer:this.scrollableContainer,itemsContainer:this.itemsContainer,waitForScrollingToStop:l,onScroll:function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).delayed;t.onUpdateShownItemIndexes({reason:e?se:oe})},initialScrollPosition:s,onScrollPositionChange:a,isImmediateLayoutScheduled:function(){return Boolean(t.layoutTimer)},hasNonRenderedItemsAtTheTop:function(){return t.getState().firstShownItemIndex>0},hasNonRenderedItemsAtTheBottom:function(){return t.getState().lastShownItemIndex<t.getItemsCount()-1},getLatestLayoutVisibleArea:function(){return t.latestLayoutVisibleArea},getListTopOffset:this.getListTopOffsetInsideScrollableContainer,getPrerenderMargin:function(){return t.getPrerenderMargin()}}),this.listHeightMeasurement=new je({itemsContainer:this.itemsContainer,getListTopOffset:this.getListTopOffsetInsideScrollableContainer}),this.engine.watchListTopOffset&&(this.listTopOffsetWatcher=this.engine.watchListTopOffset({getListTopOffset:this.getListTopOffsetInsideScrollableContainer,onListTopOffsetChange:function(e){return e.reason,t.onUpdateShownItemIndexes({reason:ge})}})),this.beforeResize=new Ce({getState:this.getState,getVerticalSpacing:this.getVerticalSpacing,getColumnsCount:this.getColumnsCount})}function gt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function pt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?gt(Object(n),!0).forEach(function(t){vt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function It(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 vt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var yt=function(){function e(t,n){var i=this,r=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),vt(this,"stop",function(){if(!i._isActive)throw new Error("[virtual-scroller] Can't stop a `VirtualScroller` that hasn't been started");i._isActive=!1,G("~ Stop ~"),i.scrollableContainerResizeHandler.stop(),i.scroll.stop(),i.listTopOffsetWatcher&&i.listTopOffsetWatcher.isStarted()&&i.listTopOffsetWatcher.stop(),i.cancelLayoutTimer({})}),vt(this,"updateLayout",function(){i.hasToBeStarted(),i.onUpdateShownItemIndexes({reason:ae})}),vt(this,"onRender",function(){i._onRender(i.getState(),i.previousState)}),dt.call(this,t,n,r)}var t,n,i;return t=e,n=[{key:"start",value:function(){if(this._isActive)throw new Error("[virtual-scroller] `VirtualScroller` has already been started");var e=!1===this._isActive;e||(this.setUpState(),this.waitingForRender=!0,this._render&&this._render(this.getState())),G(e?"~ Start (restart) ~":"~ Start ~"),this._isActive=!0,this.listHeightMeasurement.reset(),this._isResizing=void 0,this._isSettingNewItems=void 0,this.isInBypassMode()||this.isItemsContainerElementTableBody()&&(tt()?this.getItemsContainerElement().classList.contains(nt)&&Boolean(document.getElementById(it))||(G("~ <tbody/> container ~"),function(e){e.classList.add(nt);var t=document.createElement("style");t.id=it,t.innerText="\n\t\ttbody.".concat(nt,":before {\n\t\t\tcontent: '';\n\t\t\tdisplay: table-row;\n\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t}\n\t\ttbody.").concat(nt,":after {\n\t\t\tcontent: '';\n\t\t\tdisplay: table-row;\n\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t}\n\t").replace(/[\n\t]/g,""),document.head.appendChild(t)}(this.getItemsContainerElement())):(G("~ <tbody/> container not supported ~"),Q("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"),G('~ enter "bypass" mode ~'),this._bypass=!0));var t=this._afterRenderStateUpdateThatWasStopped;this._afterRenderStateUpdateThatWasStopped=void 0,this.verticalSpacing=void 0;var n=this.measureItemHeightsAndSpacing();if(n&&(t=pt(pt({},t),n)),this.scrollableContainerResizeHandler.start(),this.scroll.start(),void 0===this.getState().scrollableContainerWidth){var i=this.scrollableContainer.getWidth();t=pt(pt({},t),{},{scrollableContainerWidth:i})}else{var r=this.scrollableContainer.getWidth(),o=this.getState().scrollableContainerWidth;if(r!==o)return G("~ Scrollable container width changed from",o,"to",r,"~"),this.onContainerResize()}if(this._usesCustomStateStorage&&this.getActualColumnsCount()!==(this.getState().columnsCount||1))return this.onContainerResize();this.onUpdateShownItemIndexes({reason:le,stateUpdate:t})}},{key:"hasToBeStarted",value:function(){if(!this._isActive)throw new Error("[virtual-scroller] `VirtualScroller` hasn't been started")}},{key:"getItemScrollPosition",value:function(e){var t=this._getItemIndexByItemOrIndex(e);if(void 0!==t){var n=this.layout.getItemTopOffset(t);if(void 0!==n)return this.getListTopOffsetInsideScrollableContainer()+n}}},{key:"onItemHeightChange",value:function(e){$("`.onItemHeightChange(item)` method was renamed to `.onItemHeightDidChange(item)`"),this.onItemHeightDidChange(e)}},{key:"onItemHeightDidChange",value:function(e){this._onItemHeightDidChange(e)}},{key:"setItemState",value:function(e,t){this._setItemState(e,t)}},{key:"onItemStateChange",value:function(e,t){this.setItemState(e,t)}},{key:"setItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.hasToBeStarted(),this._setItems(e,t)}}],n&&It(t.prototype,n),i&&It(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}(),St=["onMount","onItemUnmount","readyToStart","readyToRender"];function bt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function wt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?bt(Object(n),!0).forEach(function(t){Rt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ct(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 Ot(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 Rt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var xt=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),Rt(this,"render",function(e,t){var n=e.items,i=e.firstShownItemIndex,o=e.lastShownItemIndex,s=e.beforeItemsHeight,a=e.afterItemsHeight,l=r.getItemsContainerElement();r.virtualScroller.isItemsContainerElementTableBody()||(l.style.paddingTop=et(s),l.style.paddingBottom=et(a));var u=t&&n===t.items&&n.length>0;if(u)for(var h=t.lastShownItemIndex;h>=t.firstShownItemIndex;)h>=i&&h<=o||(G("DOM: Remove element for item index",h),r.unmountItem(l.childNodes[h-t.firstShownItemIndex])),h--;else for(G("DOM: Rerender the list from scratch");l.firstChild;)r.unmountItem(l.firstChild);for(var c=u,f=c&&l.firstChild,d=i;d<=o;){if(u&&d>=t.firstShownItemIndex&&d<=t.lastShownItemIndex)c&&(c=!1);else{var m=r.renderItem(n[d]);c?(G("DOM: Prepend element for item index",d),l.insertBefore(m,f)):(G("DOM: Append element for item index",d),l.appendChild(m))}d++}r._isMounted||(r._isMounted=!0,r._onMount&&r._onMount())}),Rt(this,"onUnmount",function(){$("`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),Rt(this,"destroy",function(){$("`.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),Rt(this,"stop",function(){r.virtualScroller.stop()}),Rt(this,"start",function(){if(r._isInitialRender){r._isInitialRender=!1;for(var e=r.getItemsContainerElement();e.firstChild;)e.removeChild(e.firstChild)}r.virtualScroller.start()}),this.getItemsContainerElement="function"==typeof t?t:function(){return t},this.renderItem=i,this._isInitialRender=!0;var s=o.onMount,a=o.onItemUnmount,l=o.readyToStart,u=o.readyToRender,h=Ct(o,St);this._onMount=s,this.onItemUnmount=a,this.virtualScroller=new yt(this.getItemsContainerElement,n,wt(wt({},h),{},{render:this.render})),!1===u||(!1===l?this.render(this.virtualScroller.getInitialState()):this.start())}var t,n,i;return t=e,(n=[{key:"unmountItem",value:function(e){this.getItemsContainerElement().removeChild(e),this.onItemUnmount&&this.onItemUnmount(e)}},{key:"onItemHeightChange",value:function(e){$("`.onItemHeightChange(item)` method was renamed to `.onItemHeightDidChange(item)`"),this.onItemHeightDidChange(e)}},{key:"onItemHeightDidChange",value:function(e){this.virtualScroller.onItemHeightDidChange(e)}},{key:"setItemState",value:function(e,t){this.virtualScroller.setItemState(e,t)}},{key:"updateItems",value:function(e,t){$("`.updateItems()` method was renamed to `.setItems(i)`"),this.setItems(e,t)}},{key:"setItems",value:function(e,t){this.virtualScroller.setItems(e,t)}}])&&Ot(t.prototype,n),i&&Ot(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();return xt});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VirtualScroller=t()}(this,function(){"use strict";function e(t){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(t)}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)}}function n(t){var n=o();return function(){var i,r=a(t);if(n){var o=a(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return function(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(this,i)}}function i(e){var t="function"==typeof Map?new Map:void 0;return i=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return r(e,arguments,a(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),s(i,e)},i(e)}function r(e,t,n){return r=o()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var r=new(Function.bind.apply(e,i));return n&&s(r,n.prototype),r},r.apply(null,arguments)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function s(e,t){return s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},s(e,t)}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}var l=function(e){!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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}(l,e);var i,r,o,a=n(l);function l(e){var t=e.renderedElementIndex,n=e.renderedElementsCount,i=e.message;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),a.call(this,i||function(e){var t=e.renderedElementIndex,n=e.renderedElementsCount;return"Element with index ".concat(t," was not found in the list of Rendered Item Elements in the Items Container of Virtual Scroller. There're only ").concat(n," Elements there.")}({renderedElementIndex:t,renderedElementsCount:n}))}return i=l,r&&t(i.prototype,r),o&&t(i,o),Object.defineProperty(i,"prototype",{writable:!1}),i}(i(Error));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)}}var h=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getElement=t}var t,n,i;return t=e,(n=[{key:"_getNthRenderedItemElement",value:function(e){var t=this.getElement().childNodes;if(e>t.length-1)throw new l({renderedElementIndex:e,renderedElementsCount:t.length});return t[e]}},{key:"getNthRenderedItemTopOffset",value:function(e){return this._getNthRenderedItemElement(e).getBoundingClientRect().top-this.getElement().getBoundingClientRect().top}},{key:"getNthRenderedItemHeight",value:function(e){return this._getNthRenderedItemElement(e).getBoundingClientRect().height}},{key:"getHeight",value:function(){return this.getElement().getBoundingClientRect().height}}])&&u(t.prototype,n),i&&u(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function c(e){return c="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},c(e)}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 d(e){var t=p();return function(){var n,i=v(e);if(t){var r=v(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return function(e,t){if(t&&("object"===c(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function m(e){var t="function"==typeof Map?new Map:void 0;return m=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return g(e,arguments,v(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),I(i,e)},m(e)}function g(e,t,n){return g=p()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var r=new(Function.bind.apply(e,i));return n&&I(r,n.prototype),r},g.apply(null,arguments)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function I(e,t){return I=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},I(e,t)}function v(e){return v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},v(e)}var y=function(e){!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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&I(e,t)}(o,e);var t,n,i,r=d(o);function o(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),r.call(this,"[virtual-scroller] Scrollable container not found")}return t=o,n&&f(t.prototype,n),i&&f(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}(m(Error));function S(e){return S="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},S(e)}function b(e,t){return b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},b(e,t)}function w(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,i=C(e);if(t){var r=C(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return function(e,t){if(t&&("object"===S(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function C(e){return C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},C(e)}function O(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function R(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&&R(e.prototype,t),n&&R(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var H=function(){function e(t,n){O(this,e),this.getElement=t,this.getItemsContainerElement=n}return x(e,[{key:"getScrollY",value:function(){return this.getElement().scrollTop}},{key:"scrollToY",value:function(e){this.getElement().scrollTo?this.getElement().scrollTo(0,e):this.getElement().scrollTop=e}},{key:"getWidth",value:function(){if(!this.getElement())throw new y;return this.getElement().offsetWidth}},{key:"getHeight",value:function(){if(!this.getElement())throw new y;return this.getElement().offsetHeight}},{key:"getItemsContainerTopOffset",value:function(){var e=this.getElement().getBoundingClientRect().top,t=this.getElement().clientTop;return this.getItemsContainerElement().getBoundingClientRect().top-e+this.getScrollY()-t}},{key:"onScroll",value:function(e){var t=this.getElement();return t.addEventListener("scroll",e),function(){return t.removeEventListener("scroll",e)}}},{key:"onResize",value:function(e){var t;if("undefined"!=typeof ResizeObserver){var n=new ResizeObserver(function(t){t[0],e()}),i=this.getElement();n.observe(i),t=function(){return n.unobserve(i)}}var r=P(e,{itemsContainerElement:this.getItemsContainerElement()});return function(){t&&t(),r()}}}]),e}(),T=function(e){!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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}(n,e);var t=w(n);function n(e){return O(this,n),t.call(this,function(){return window},e)}return x(n,[{key:"getScrollY",value:function(){return window.pageYOffset}},{key:"getWidth",value:function(){return window.innerWidth}},{key:"getHeight",value:function(){return window.innerHeight}},{key:"getItemsContainerTopOffset",value:function(){var e=document.clientTop||document.body.clientTop||0;return this.getItemsContainerElement().getBoundingClientRect().top+this.getScrollY()-e}},{key:"onResize",value:function(e){return P(e,{itemsContainerElement:this.getItemsContainerElement()})}}]),n}(H);function P(e,t){var n=t.itemsContainerElement,i=function(){document.fullscreenElement&&!document.fullscreenElement.contains(n)||e()};return window.addEventListener("resize",i),function(){return window.removeEventListener("resize",i)}}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)}}var E=function(){function e(t){var n=t.getListTopOffset,i=t.onListTopOffsetChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getListTopOffset=n,this.onListTopOffsetChange=i}var t,n,i;return t=e,(n=[{key:"onListTopOffset",value:function(e){void 0===this.listTopOffsetInsideScrollableContainer&&this.start(),this.listTopOffsetInsideScrollableContainer=e}},{key:"start",value:function(){this._isActive=!0,this.watchListTopOffset()}},{key:"isStarted",value:function(){return this._isActive}},{key:"stop",value:function(){this._isActive=!1,this.watchListTopOffsetTimer&&(clearTimeout(this.watchListTopOffsetTimer),this.watchListTopOffsetTimer=void 0)}},{key:"watchListTopOffset",value:function(){var e=this,t=Date.now();!function n(){e._isActive&&(void 0!==e.listTopOffsetInsideScrollableContainer&&e.getListTopOffset()!==e.listTopOffsetInsideScrollableContainer&&e.onListTopOffsetChange(),Date.now()-t<3e3&&(e.watchListTopOffsetTimer=setTimeout(n,500)))}()}}])&&j(t.prototype,n),i&&j(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}(),M={createItemsContainer:function(e){return new h(e)},createScrollableContainer:function(e,t){return e?new H(e,t):"undefined"!=typeof window?new T(t):void 0},watchListTopOffset:function(e){var t=e.getListTopOffset,n=e.onListTopOffsetChange;return new E({getListTopOffset:t,onListTopOffsetChange:n})}};function B(e){return function(e){if(Array.isArray(e))return L(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return L(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return L(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function A(){if(V()){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).log.apply(e,B(["[virtual-scroller]"].concat(n)))}}function _(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];if(N("VirtualScrollerWarningsAreErrors"))return k.apply(this,n);(e=console).warn.apply(e,B(["[virtual-scroller]"].concat(n)))}function z(){for(var e,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];(e=console).error.apply(e,B(["[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=function(){return new Error(["[virtual-scroller]"].concat(t).join(" "))};if("undefined"!=typeof window)z.apply(this,["ERROR"].concat(t)),setTimeout(function(){throw i()},0);else{var r=N("VirtualScrollerCatchError");if(r)return r(i());if(N("VirtualScrollerThrowErrors"))throw i();z.apply(this,["ERROR"].concat(t))}}function V(){var e=N("VirtualScrollerDebug");if(void 0!==e)return!0===e||"debug"===e}function N(e){return"undefined"!=typeof window?window[e]:"undefined"!=typeof global?global[e]:void 0}function D(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?D(Object(n),!0).forEach(function(t){W(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):D(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}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}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)}}for(var Y=function(){function e(t){var n=t.isInBypassMode,i=t.getEstimatedVisibleItemRowsCountForInitialRender,r=t.measureItemsBatchSize,o=t.getPrerenderMargin,s=t.getPrerenderMarginRatio,a=t.getVerticalSpacing,l=t.getVerticalSpacingBeforeResize,u=t.getColumnsCount,h=t.getColumnsCountBeforeResize,c=t.getItemHeight,f=t.getItemHeightBeforeResize,d=t.getBeforeResizeItemsCount,m=t.getAverageItemHeight,g=t.getMaxVisibleAreaHeight,p=t.getPreviouslyCalculatedLayout;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.isInBypassMode=n,this.getEstimatedVisibleItemRowsCountForInitialRender=i,this.measureItemsBatchSize=r,this.getPrerenderMargin=o,this.getPrerenderMarginRatio=s,this.getVerticalSpacing=a,this.getVerticalSpacingBeforeResize=l,this.getColumnsCount=u,this.getColumnsCountBeforeResize=h,this.getItemHeight=c,this.getItemHeightBeforeResize=f,this.getBeforeResizeItemsCount=d,this.getAverageItemHeight=m,this.getMaxVisibleAreaHeight=g,this.getPreviouslyCalculatedLayout=p}var t,n,i;return t=e,n=[{key:"getInitialLayoutValueWithFallback",value:function(e,t,n){try{return t()}catch(t){if(t instanceof y)return A('Scrollable container size is not known at this point, so "'.concat(e,"\" can't be calculated yet. Default to"),n),n;throw t}}},{key:"getInitialLayoutValues",value:function(e){var t,n,i=this,r=e.itemsCount,o=e.columnsCount,s=e.beforeStart,a=0,l=0;if(r>0){var u=function(){return i.getInitialLastShownItemIndex({itemsCount:r,columnsCount:o,firstShownItemIndex:t})};t=0,n=s?this.getInitialLayoutValueWithFallback("lastShownItemIndex",u,t):u();var h=this.getAverageItemHeight(),c=this.getVerticalSpacing(),f=t,d=r-(n+1);a=Math.ceil(f/o)*(c+h),l=Math.ceil(d/o)*(c+h)}return{beforeItemsHeight:a,afterItemsHeight:l,firstShownItemIndex:t,lastShownItemIndex:n}}},{key:"getInitialLastShownItemIndex",value:function(e){var t=e.itemsCount,n=e.columnsCount,i=e.firstShownItemIndex;return this.isInBypassMode()?t-1:Math.min(i+(this.getInitialRenderedRowsCount()*n-1),t-1)}},{key:"getInitialRenderedRowsCount",value:function(){var e=this.getEstimatedVisibleItemRowsCount();return"number"==typeof e?Math.ceil(e*(1+this.getPrerenderMarginRatio())):1}},{key:"getEstimatedVisibleItemRowsCount",value:function(){var e=this.getMaxVisibleAreaHeight();if("number"==typeof e){var t=this.getEstimatedRowsCountForHeight(e);if("number"==typeof t)return t}if(this.getEstimatedVisibleItemRowsCountForInitialRender){var n=this.getEstimatedVisibleItemRowsCountForInitialRender();if("number"==typeof n)return n;throw new Error("[virtual-scroller] `getEstimatedVisibleItemRowsCount()` must return a number")}}},{key:"getEstimatedRowsCountForHeight",value:function(e){var t=this.getAverageItemHeight(),n=this.getVerticalSpacing();if(t+n>0)return Math.ceil((e+n)/(t+n))}},{key:"getLayoutUpdateForItemsDiff",value:function(e,t,n){var i=e.firstShownItemIndex,r=e.lastShownItemIndex,o=e.beforeItemsHeight,s=e.afterItemsHeight,a=t.prependedItemsCount,l=t.appendedItemsCount,u=n.itemsCount,h=n.columnsCount,c=n.shouldRestoreScrollPosition,f=n.onResetGridLayout,d=this.getAverageItemHeight(),m=this.getVerticalSpacing();if(l>0&&(s+=Math.ceil(l/h)*(m+d)),a>0&&(i+=a,r+=a,o+=Math.ceil(a/h)*(d+m),c&&(i=0,o=0),a%h>0)){f(),_("~ Prepended items count",a,"is not divisible by Columns Count",h,"~"),_("Layout reset required");var g=r-i+1;if(i=0,o=0,!c&&a>g){var p=u-((r=this.getInitialLastShownItemIndex({itemsCount:u,columnsCount:h,firstShownItemIndex:i}))+1);s=Math.ceil(p/h)*(m+d)}}return{beforeItemsHeight:o,afterItemsHeight:s,firstShownItemIndex:i,lastShownItemIndex:r}}},{key:"getItemNotMeasuredIndexes",value:function(e,t){var n=this,i=t.itemsCount,r=t.firstShownItemIndex,o=t.nonMeasuredAreaHeight,s=t.indexOfTheFirstItemInTheRow;A("Item index",e,"height is required for calculations but hasn't been measured yet. Mark the item as \"shown\", rerender the list, measure the item's height and redo the layout.");var a,l=this.getColumnsCount(),u=Math.min(("number"==typeof(a=n.getEstimatedRowsCountForHeight(o))?a:Math.ceil(i/l))*l,this.measureItemsBatchSize||1/0);return void 0===r&&(r=s),{firstNonMeasuredItemIndex:e,firstShownItemIndex:r,lastShownItemIndex:Math.min(s+u-1,i-1)}}},{key:"getShownItemIndexes",value:function(e){var t=e.itemsCount,n=e.visibleAreaInsideTheList,i=this._getShownItemIndex({itemsCount:t,fromIndex:0,visibleAreaInsideTheList:n,findFirstShownItemIndex:!0});if(null===i)return this.getNonVisibleListShownItemIndexes();if(void 0!==i.firstNonMeasuredItemIndex)return i;var r=i,o=r.firstShownItemIndex,s=r.beforeItemsHeight;return null===(i=this._getShownItemIndex({itemsCount:t,fromIndex:o,beforeItemsHeight:s,visibleAreaInsideTheList:n,findLastShownItemIndex:!0}))?this.getNonVisibleListShownItemIndexes():void 0!==i.firstNonMeasuredItemIndex?i:{firstShownItemIndex:o,lastShownItemIndex:i.lastShownItemIndex}}},{key:"_getShownItemIndex",value:function(e){var t=e.beforeResize,n=e.itemsCount,i=e.visibleAreaInsideTheList,r=e.findFirstShownItemIndex,o=e.findLastShownItemIndex,s=e.fromIndex,a=e.beforeItemsHeight;if(0===s&&(a=0),void 0===a)throw new Error("[virtual-scroller] `beforeItemsHeight` not passed to `Layout.getShownItemIndexes()` when starting from index "+s);if(!t){var l=this.getBeforeResizeItemsCount();if(l>s){var u=this._getShownItemIndex(U(U({},e),{},{beforeResize:!0,itemsCount:l})),h=u.notFound,c=u.beforeItemsHeight,f=u.firstShownItemIndex,d=u.lastShownItemIndex;if(!h){var m=this.getColumnsCount();return{firstShownItemIndex:void 0===f?void 0:Math.floor(f/m)*m,lastShownItemIndex:void 0===d?void 0:Math.floor(d/m)*m,beforeItemsHeight:c}}a=c,s+=l}}for(var g=t?this.getColumnsCountBeforeResize():this.getColumnsCount(),p=t?this.getVerticalSpacingBeforeResize():this.getVerticalSpacing(),I=s;I<n;){for(var v=I,y=n>v+g?p:0,S=0,b=0;b<g&&I<n;){var w=t?this.getItemHeightBeforeResize(I):this.getItemHeight(I);if(void 0===w)return this.getItemNotMeasuredIndexes(I,{itemsCount:n,firstShownItemIndex:o?s:void 0,indexOfTheFirstItemInTheRow:v,nonMeasuredAreaHeight:i.bottom+this.getPrerenderMargin()-a});S=Math.max(S,w),b++,I++}var C=a+S,O=C>i.top-this.getPrerenderMargin(),R=C+y>=i.bottom+this.getPrerenderMargin();if(r){if(O)return{firstShownItemIndex:v,beforeItemsHeight:a}}else if(o&&R)return{lastShownItemIndex:Math.min(v+g-1,n-1)};a+=S+y}return t?{notFound:!0,beforeItemsHeight:a}:r?(_("The list is supposed to be visible but no visible item has been found"),null):o?{lastShownItemIndex:n-1}:void 0}},{key:"getNonVisibleListShownItemIndexes",value:function(){var e={firstShownItemIndex:0,lastShownItemIndex:0};return void 0===this.getItemHeight(0)&&(e.firstNonMeasuredItemIndex=0),e}},{key:"getBeforeItemsHeight",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).beforeResize,n=0,i=0;if(!t){var r=this.getBeforeResizeItemsCount();r>0&&(n=this.getBeforeItemsHeight(Math.min(e,r),{beforeResize:!0}),i=r)}for(var o=t?this.getColumnsCountBeforeResize():this.getColumnsCount(),s=t?this.getVerticalSpacingBeforeResize():this.getVerticalSpacing();i<e;){for(var a=0,l=0;l<o;){var u=t?this.getItemHeightBeforeResize(i):this.getItemHeight(i);void 0===u&&(u=this.getAverageItemHeight()),a=Math.max(a,u),i++,l++}n+=a,n+=s}return n}},{key:"getAfterItemsHeight",value:function(e,t){for(var n=this.getColumnsCount(),i=0,r=e+1;r<t;){for(var o=0,s=0;s<n&&r<t;){var a=this.getItemHeight(r);void 0===a&&(a=this.getAverageItemHeight()),o=Math.max(o,a),r++,s++}i+=this.getVerticalSpacing(),i+=o}return i}},{key:"getItemTopOffset",value:function(e){for(var t=0,n=this.getBeforeResizeItemsCount(),i=0===n?0:Math.ceil(n/this.getColumnsCountBeforeResize()),r=e<n?Math.floor(e/this.getColumnsCountBeforeResize()):i,o=0;o<r;)t+=this.getItemHeightBeforeResize(o*this.getColumnsCountBeforeResize()),t+=this.getVerticalSpacingBeforeResize(),o++;for(var s=Math.floor((e-n)/this.getColumnsCount()),a=0;a<s;){for(var l=0,u=0;u<this.getColumnsCount();){var h=this.getItemHeight(n+a*this.getColumnsCount()+u);if(void 0===h)return;l=Math.max(l,h),u++}t+=l,t+=this.getVerticalSpacing(),a++}return t}}],n&&F(t.prototype,n),i&&F(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}(),q="scroll",J="stopped scrolling",G="manual",$="started",K="non-measured item heights have been measured",Q="viewport width changed",X="viewport height changed",Z="viewport size unchanged",ee="item height changed",te="items changed",ne="list top offset changed",ie="undefined"==typeof window?global:window,re=["moz","webkit"],oe="AnimationFrame",se=ie["request"+oe],ae=ie["cancel"+oe]||ie["cancelRequest"+oe],le=0;!se&&le<re.length;le++)se=ie[re[le]+"Request"+oe],ae=ie[re[le]+"Cancel"+oe]||ie[re[le]+"CancelRequest"+oe];if(!se||!ae){var ue=0,he=0,ce=[],fe=1e3/60;se=function(e){if(0===ce.length){var t=Date.now(),n=Math.max(0,fe-(t-ue));ue=n+t,setTimeout(function(){var e=ce.slice(0);ce.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(ue)}catch(e){setTimeout(function(){throw e},0)}},Math.round(n))}return ce.push({handle:++he,callback:e,cancelled:!1}),he},ae=function(e){for(var t=0;t<ce.length;t++)ce[t].handle===e&&(ce[t].cancelled=!0)}}function de(e){return se.call(ie,e)}function me(e,t){var n=Date.now(),i=de(function r(){Date.now()-n>=t?e():i=de(r)});return{clear:function(){return function(){ae.apply(ie,arguments)}(i)}}}function ge(e){e&&e.clear()}function pe(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 Ie=function(){function e(t){var n,i,r,o=this,s=t.isInBypassMode,a=t.getWidth,l=t.getHeight,u=t.listenForResize,h=t.onResizeStart,c=t.onResizeStop,f=t.onHeightChange,d=t.onWidthChange,m=t.onNoChange;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),r=function(){if(o.isActive){var e=o.width,t=o.height;o.width=o.getWidth(),o.height=o.getHeight(),o.width===e?o.height===t?o.onNoChange():o.onHeightChange(t,o.height):o.onWidthChange(e,o.width)}},(i="_onResize")in(n=this)?Object.defineProperty(n,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[i]=r,this.isInBypassMode=s,this.onHeightChange=f,this.onWidthChange=d,this.onNoChange=m,this.getWidth=a,this.getHeight=l,this.listenForResize=u,this.onResize=function(e,t){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=i.onStart,o=i.onStop;return function(){for(var i=this,s=arguments.length,a=new Array(s),l=0;l<s;l++)a[l]=arguments[l];return new Promise(function(s){n?ge(n):r&&r(),n=me(function(){n=void 0,o&&o(),e.apply(i,a),s()},t)})}}(this._onResize,ve,{onStart:h,onStop:c})}var t,n,i;return t=e,(n=[{key:"start",value:function(){this.isActive=!0,this.isInBypassMode()||(this.width=this.getWidth(),this.height=this.getHeight(),this.unlistenResize=this.listenForResize(this.onResize))}},{key:"stop",value:function(){this.isActive=!1,this.width=void 0,this.height=void 0,this.unlistenResize&&(this.unlistenResize(),this.unlistenResize=void 0)}}])&&pe(t.prototype,n),i&&pe(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}(),ve=250;function ye(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function Se(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ye(Object(n),!0).forEach(function(t){be(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ye(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function be(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function we(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 Ce=function(){function e(t){var n=t.getState,i=t.getVerticalSpacing,r=t.getColumnsCount;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getState=n,this.getVerticalSpacing=i,this.getColumnsCount=r}var t,n,i;return t=e,n=[{key:"initializeFromState",value:function(e){this._includesBeforeResizeInState=Boolean(e.beforeResize)}},{key:"cleanUpBeforeResizeItemHeights",value:function(){var e=this.getState(),t=e.firstShownItemIndex,n=e.lastShownItemIndex,i=e.itemHeights,r=e.beforeResize;if(r&&t<r.itemHeights.length){A('~ Clean up "before resize" item heights and correct scroll position ~');for(var o=0,s=Math.floor(r.itemHeights.length/this.getColumnsCount()),a=Math.min(s*this.getColumnsCount()-1,n),l=t;l<=a;){for(var u=0,h=0;h<this.getColumnsCount()&&l<=a;){var c=i[l];void 0===c&&(c=this.getAverageItemHeight()),u=Math.max(u,c),l++,h++}o+=u,o+=this.getVerticalSpacing()}for(var f=0,d=Math.min(r.itemHeights.length,n+1),m=Math.ceil(d/r.columnsCount),g=0===t?0:Math.floor((t-1)/r.columnsCount)+1;g<m;)f+=r.itemHeights[g*r.columnsCount],f+=r.verticalSpacing,g++;if(0===t)A('Drop all "before resize" item heights');else{var p=t,I=r.itemHeights.length-1;p===I?A("For item index",p,'— drop "before resize" height',r.itemHeights[p]):A("For item indexes from",p,"to",I,'— drop "before resize" heights',r.itemHeights.slice(p))}return r.itemHeights.splice(t,r.itemHeights.length-t),{scrollBy:o-f,beforeResize:0===t?void 0:Se({},r)}}}},{key:"snapshotBeforeResizeItemHeights",value:function(e){var t=e.firstShownItemIndex,n=e.newFirstShownItemIndex,i=this.getColumnsCount(),r=this.getVerticalSpacing();this._includesBeforeResizeInState=!0;var o=this.getState(),s=o.beforeResize,a=o.itemHeights,l=s?s.itemHeights.length:0;if(l>0){if(s.columnsCount!==i||s.verticalSpacing!==r){for(var u=0,h=Math.ceil(l/s.columnsCount),c=0;c<h;)u+=s.itemHeights[c*s.columnsCount],u+=s.verticalSpacing,c++;for(var f=0,d=t;d<n;){for(var m=0,g=0;g<i&&d<n;)m=Math.max(m,a[d]),g++,d++;f+=m,f+=r}var p=u+f,I=Math.ceil(n/i);return new Array(n).fill(Math.max(0,p/I-r))}return s.itemHeights.concat(Oe(a,n,i).slice(s.itemHeights.length))}return Oe(a,n,i)}},{key:"shouldIncludeBeforeResizeValuesInState",value:function(){return this._includesBeforeResizeInState}}],n&&we(t.prototype,n),i&&we(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Oe(e,t,n){e=e.slice(0,Math.ceil(t/n)*n);for(var i=0;i*n<t;){for(var r=0,o=0;o<n;)r=Math.max(r,e[i*n+o]),o++;for(o=0;o<n;)e[i*n+o]=r,o++;i++}return e.slice(0,t)}function Re(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 xe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var He=function(){function e(t){var n=this,i=t.isInBypassMode,r=t.scrollableContainer,o=t.itemsContainer,s=t.onScroll,a=t.initialScrollPosition,l=t.onScrollPositionChange,u=t.isImmediateLayoutScheduled,h=t.hasNonRenderedItemsAtTheTop,c=t.hasNonRenderedItemsAtTheBottom,f=t.getLatestLayoutVisibleArea,d=t.getListTopOffset,m=t.getPrerenderMargin,g=t.onScrolledToTop,p=t.delayUnnecessaryRerenderUntilStopsScrolling;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),xe(this,"scrollByY",function(e){n.scrollToY(n.getScrollY()+e)}),xe(this,"onScrollListener",function(){if(n.onScrollPositionChange&&n.onScrollPositionChange(n.getScrollY()),n.onScrolledToTop&&n.getScrollY()<n.getListTopOffset()&&n.onScrolledToTop(),!n.isInBypassMode()&&!n.ignoreScrollEvents){if(n.cancelOnStopScrollingTimer(),n.getLatestLayoutVisibleArea()&&(n.getScrollY()<n.getLatestLayoutVisibleArea().top-n.getPrerenderMargin()&&n.hasNonRenderedItemsAtTheTop()||n.getScrollY()+n.scrollableContainer.getHeight()>n.getLatestLayoutVisibleArea().bottom+n.getPrerenderMargin()&&n.hasNonRenderedItemsAtTheBottom())||!1===n.delayUnnecessaryRerenderUntilStopsScrolling)return A("The user has scrolled far enough: perform a re-layout"),n.onScroll();A("The user is scrolling: perform a re-layout when they stop scrolling"),n.isImmediateLayoutScheduled()||(n.shouldCallOnScrollListenerWhenStopsScrolling=!0,n.watchOnStopScrolling())}}),this.isInBypassMode=i,this.scrollableContainer=r,this.itemsContainer=o,this.onScroll=s,this.initialScrollPosition=a,this.onScrollPositionChange=l,this.isImmediateLayoutScheduled=u,this.hasNonRenderedItemsAtTheTop=h,this.hasNonRenderedItemsAtTheBottom=c,this.getLatestLayoutVisibleArea=f,this.getListTopOffset=d,this.getPrerenderMargin=m,this.onScrolledToTop=g,this.delayUnnecessaryRerenderUntilStopsScrolling=p}var t,n,i;return t=e,(n=[{key:"start",value:function(){void 0!==this.initialScrollPosition&&(this.scrollToY(this.initialScrollPosition),this.initialScrollPosition=void 0),this.onScrollPositionChange&&this.onScrollPositionChange(this.getScrollY()),this.stopListeningToScroll=this.scrollableContainer.onScroll(this.onScrollListener)}},{key:"stop",value:function(){this.stopListeningToScroll(),this.stopListeningToScroll=void 0,this.shouldCallOnScrollListenerWhenStopsScrolling=void 0,this.cancelOnStopScrollingTimer()}},{key:"scrollToY",value:function(e){this.ignoreScrollEvents=!0,this.scrollableContainer.scrollToY(e),this.ignoreScrollEvents=void 0}},{key:"getScrollY",value:function(){return this.scrollableContainer.getScrollY()}},{key:"cancelOnStopScrollingTimer",value:function(){this.onStopScrollingTimer&&(ge(this.onStopScrollingTimer),this.onStopScrollingTimer=void 0)}},{key:"cancelScheduledLayout",value:function(){this.cancelOnStopScrollingTimer()}},{key:"watchOnStopScrolling",value:function(){var e=this;this.onStopScrollingTimer=me(function(){e.onStopScrollingTimer=void 0,e.shouldCallOnScrollListenerWhenStopsScrolling&&(e.shouldCallOnScrollListenerWhenStopsScrolling=void 0,e.onScroll({delayed:!0}))},Te)}},{key:"getVisibleAreaBounds",value:function(){var e=this.getScrollY();return{top:e,bottom:e+this.scrollableContainer.getHeight()}}}])&&Re(t.prototype,n),i&&Re(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}(),Te=100;function Pe(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 je=function(){function e(t){var n=t.itemsContainer,i=t.getListTopOffset;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.itemsContainer=n,this.getListTopOffset=i}var t,n,i;return t=e,(n=[{key:"snapshotListHeightBeforeAddingNewItems",value:function(e){var t=e.previousItems,n=e.newItems,i=e.prependedItemsCount;0!==t.length&&0!==i&&(this._snapshot={previousItems:t,newItems:n,itemIndex:i,itemTopOffset:this.itemsContainer.getNthRenderedItemTopOffset(0),listTopOffset:this.getListTopOffset()})}},{key:"getAnchorItemIndex",value:function(){return this._snapshot.itemIndex}},{key:"hasSnapshot",value:function(){return void 0!==this._snapshot}},{key:"getListBottomOffsetChange",value:function(){var e=this._snapshot,t=e.itemIndex,n=e.itemTopOffset,i=e.listTopOffset;return this.itemsContainer.getNthRenderedItemTopOffset(t)-n+(this.getListTopOffset()-i)}},{key:"reset",value:function(){this._snapshot=void 0}}])&&Pe(t.prototype,n),i&&Pe(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Ee(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 Me=function(){function e(t){var n=t.container,i=t.getItemHeight,r=t.setItemHeight;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.container=n,this._get=i,this._set=r,this.reset()}var t,n,i;return t=e,n=[{key:"reset",value:function(){this.measuredItemsHeight=0,this.firstMeasuredItemIndex=void 0,this.lastMeasuredItemIndex=void 0}},{key:"readItemHeightsFromState",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){return this.container.getNthRenderedItemHeight(e-t)}},{key:"measureItemHeights",value:function(e,t){if(A("~ Measure item heights ~"),void 0!==e){void 0!==this.firstMeasuredItemIndex&&(e>this.lastMeasuredItemIndex+1||t<this.firstMeasuredItemIndex-1)&&(A("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);var a=this._measureItemHeight(s,e);A("Item index",s,"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&&(_("Item index",s,"height changed unexpectedly: it was",l,"before, but now it is",u,'. Whenever an item\'s height changes for whatever reason, a developer must call `onItemHeightDidChange(item)` right after that change. If you are calling `onItemHeightDidChange(item)` correctly, then there\'re several other possible causes. For example, perhaps you forgot to persist the item\'s "state" by calling `setItemState(item, newState)` when that "state" did change, and so the item\'s "state" got lost when the item element was unmounted, which resulted in a different item height when the item was shown again with no previous "state". Or perhaps you\'re running your application in "devleopment" mode and `VirtualScroller` has initially rendered the list before your CSS styles or custom fonts have loaded, resulting in different item height measurements "before" and "after" the page has fully loaded.'),this._set(s,u))}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:"getAverageItemHeight",value:function(){if(void 0!==this.lastMeasuredItemIndex)return this.measuredItemsHeight/(this.lastMeasuredItemIndex-this.firstMeasuredItemIndex+1)}},{key:"onPrepend",value:function(e){void 0!==this.firstMeasuredItemIndex&&(this.firstMeasuredItemIndex+=e,this.lastMeasuredItemIndex+=e)}}],n&&Ee(t.prototype,n),i&&Ee(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Be(e,t){for(var n=0;n<e.length;)e[n]=t(n),n++;return e}function Le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function Ae(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Le(Object(n),!0).forEach(function(t){_e(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Le(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ze(e){var t=Ae({},e);return e.itemHeights&&(t.itemHeights=e.itemHeights.slice()),e.itemStates&&(t.itemStates=e.itemStates.slice()),e.beforeResize&&(t.beforeResize=Ae({},e.beforeResize),t.beforeResize.itemHeights=e.beforeResize.itemHeights.slice()),t}function ke(e){return me(e,0)}function Ve(e){ge(e)}function Ne(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function De(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ne(Object(n),!0).forEach(function(t){Ue(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ne(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ue(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function We(e){var t=this,n=e.state,i=e.getInitialItemState,r=e.onStateChange,o=e.render,s=e.items;function a(){return this.state}function l(e){this.state=e}function u(e,t){this.state=e,o(this.state,this.previousState),this.onRender()}function h(e){var t=e.getInitialItemState,n=s,i=De(De({},f.call(this,n,{beforeStart:!0})),{},{items:n,itemStates:Be(new Array(n.length),function(e){return t(n[e])})});return V()&&A("Initial state (autogenerated)",ze(i)),A("First shown item index",i.firstShownItemIndex),A("Last shown item index",i.lastShownItemIndex),i}function c(e){return V()&&A("Restore state",ze(e)),function(e,t){var n=t.columnsCount,i=e.columnsCount||1;if(i!==n)return _("~ Columns Count changed from",i,"to",n,"~"),!0;var r=Math.floor(e.firstShownItemIndex/n)*n;if(r!==e.firstShownItemIndex)return _("~ First Shown Item Index",e.firstShownItemIndex,"is not divisible by Columns Count",n,"~"),!0}(e=De(De({},e=function(e){return e.beforeResize&&0===e.beforeResize.itemHeights.length&&(e.beforeResize=void 0),e}(e)),{},{verticalSpacing:void 0}),{columnsCount:this.getActualColumnsCount()})&&(_("Reset Layout"),e=De(De({},e),f.call(this,e.items,{beforeStart:!1}))),e}function f(e,t){var n=t.beforeStart,i=e.length,r=this.layout.getInitialLayoutValues({itemsCount:i,columnsCount:this.getActualColumnsCount(),beforeStart:n}),o=r.firstShownItemIndex,s=r.lastShownItemIndex,a=r.beforeItemsHeight,l=r.afterItemsHeight,u=new Array(i);return this.onBeforeShowItems(e,u,o,s),{itemHeights:u,columnsCount:this.getActualColumnsCountForState(),verticalSpacing:this.verticalSpacing,firstShownItemIndex:o,lastShownItemIndex:s,beforeItemsHeight:a,afterItemsHeight:l}}this.onStateChange=r,this._render=o,this.getInitialItemState=i,this._setItemState=function(e,n){var i=t._getItemIndexByItemOrIndex(e);void 0!==i&&(V()&&(A("~ Item state changed ~"),A("Item index",i),A("Previous state\n"+JSON.stringify(t.getState().itemStates[i],null,2)),A("New state\n"+JSON.stringify(n,null,2))),t.getState().itemStates[i]=n,t.newItemsWillBeRendered&&(t.itemStatesThatChangedWhileNewItemsWereBeingRendered||(t.itemStatesThatChangedWhileNewItemsWereBeingRendered={}),t.itemStatesThatChangedWhileNewItemsWereBeingRendered[String(i)]=n))},this.getState=function(){return t._getState()},this.updateState=function(e){V()&&(A("~ Set state ~"),A(ze(e))),void 0===t._stateUpdateSequenceStartedAt&&(t._stateUpdateSequenceStartedAt=Date.now(),t._stateUpdateSequenceStartedAtResetTimer=ke(function(){t._stateUpdateSequenceStartedAtResetTimer=void 0,t._stateUpdateSequenceStartedAt=void 0})),e.items&&(t._isSettingNewItems||k("A `stateUpdate` can only contain `items` property as a result of calling `.setItems()`")),t._isSettingNewItems=void 0,t.waitingForRender=!0,t.previousState=t.getState(),t.mostRecentSetStateValue||(t.mostRecentSetStateValue=t.getState()),t.mostRecentSetStateValue=De(De({},t.mostRecentSetStateValue),e),t._setState(t.mostRecentSetStateValue,e)},this.getInitialState=function(){return n?c.call(t,n):h.call(t,{getInitialItemState:i})},this.useState=function(e){var n=e.getState,i=e.setState,r=e.updateState;if(t._isActive)throw new Error("[virtual-scroller] `VirtualScroller` has already been started");if(t._getState)throw new Error("[virtual-scroller] Custom state storage has already been configured");if(o)throw new Error("[virtual-scroller] Creating a `VirtualScroller` class instance with a `render()` parameter implies using the default (internal) state storage");if(i&&r)throw new Error("[virtual-scroller] When using a custom state storage, one must supply either `setState()` or `updateState()` function but not both");if(!n||!i&&!r)throw new Error("[virtual-scroller] When using a custom state storage, one must supply both `getState()` and `setState()`/`updateState()` functions");t._usesCustomStateStorage=!0,t._getState=n,t._setState=function(e,t){i?i(e):r(t)}},this.useDefaultStateStorage=function(){if(!o)throw new Error("[virtual-scroller] When using the default (internal) state management, one must supply a `render(state, prevState)` function parameter");t._getState=a.bind(t),t._setState=u.bind(t),l.bind(t)(t.getInitialState())},this.setUpState=function(){t._usesCustomStateStorage||t.useDefaultStateStorage()}}var Fe=.9;function Ye(e){var t=this,n=e.getEstimatedInterItemVerticalSpacing;function i(){var e=this.getState(),t=e.firstShownItemIndex,n=e.lastShownItemIndex;A("~ Measure item vertical spacing ~");var i=function(e){var t=e.itemsContainer,n=e.renderedItemsCount;if(n>1)for(var i=t.getNthRenderedItemTopOffset(0),r=t.getNthRenderedItemHeight(0),o=1;o<n;){var s=t.getNthRenderedItemTopOffset(o),a=t.getNthRenderedItemHeight(o);if(s+Fe>=i+r){var l=s-(i+r);return Math.max(0,l)}r=Math.max(r,a),o++}}({itemsContainer:this.itemsContainer,renderedItemsCount:n-t+1});if(void 0!==i)return A("Item vertical spacing",i),i;A("Not enough items rendered to measure vertical spacing")}this.getVerticalSpacing=function(){var e=t.verticalSpacing;return"number"==typeof e?e:t.getEstimatedInterItemVerticalSpacing()},this.getVerticalSpacingBeforeResize=function(){var e=t.getState().beforeResize;if(e){var n=e.verticalSpacing;return"number"==typeof n?n:t.getEstimatedInterItemVerticalSpacing()}},this.getEstimatedInterItemVerticalSpacing=function(){if(n){var e=n();if("number"==typeof e)return e;throw new Error("[virtual-scroller] `getEstimatedInterItemVerticalSpacing()` must return a number")}return 0},this.measureVerticalSpacingIfNotMeasured=function(){if(void 0===t.verticalSpacing)return t.verticalSpacing=i.call(t),t.verticalSpacing}}function qe(e){var t=this,n=e.getColumnsCount;if(n){var i={getWidth:function(){return t.scrollableContainer.getWidth()}};this.getActualColumnsCountForState=function(){var e=n(i);if(1!==e)return e}}else this.getActualColumnsCountForState=function(){};this.getActualColumnsCount=function(){return t.getActualColumnsCountForState()||1},this.getColumnsCount=function(){return t.getState()&&t.getState().columnsCount||1}}function Je(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function Ge(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Je(Object(n),!0).forEach(function(t){$e(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Je(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function $e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ke(){var e=this;function t(e){var n=e.stateUpdate,o=Date.now(),s=i.call(this),a=s.firstShownItemIndex,l=s.lastShownItemIndex,u=s.shownItemsHeight,h=s.firstNonMeasuredItemIndex;if(this.listHeightMeasurement.hasSnapshot()&&(l<this.listHeightMeasurement.getAnchorItemIndex()&&(l=this.listHeightMeasurement.getAnchorItemIndex()),h=void 0),!r.call(this,a,l))return A("~ Because some of the will-be-hidden item heights (listed above) have changed since they've last been measured, redo layout. ~"),t.call(this,{stateUpdate:n});var c=this.layout.getBeforeItemsHeight(a),f=this.layout.getAfterItemsHeight(l,this.getItemsCount()),d=Date.now()-o;A("~ Calculated Layout"+(this.isInBypassMode()?" (bypass)":"")+" ~"),d<Qe||_("Layout calculation time too high:",d,"ms"),this.getColumnsCount()&&A("Columns count",this.getColumnsCount()),A("First shown item index",a),A("Last shown item index",l),A("Before items height",c),A("After items height (actual or estimated)",f),A('Average item height (will be used to calculate estimated "after items height")',this.getAverageItemHeight()),V()&&(A("Item heights",this.getState().itemHeights.slice()),A("Item states",this.getState().itemStates.slice())),this.onBeforeShowItems(this.getState().items,this.getState().itemHeights,a,l),this.firstNonMeasuredItemIndex=h,this.previouslyCalculatedLayout=void 0===u?void 0:{firstShownItemIndex:a,lastShownItemIndex:l,beforeItemsHeight:c,shownItemsHeight:u},this.updateState(Ge({firstShownItemIndex:a,lastShownItemIndex:l,beforeItemsHeight:c,afterItemsHeight:f},n))}function n(){var e=this.scroll.getVisibleAreaBounds();this.latestLayoutVisibleArea=e;var t=this.getListTopOffsetInsideScrollableContainer();return{top:e.top-t,bottom:e.bottom-t}}function i(){var e=this.getItemsCount(),t=n.call(this);return this.isInBypassMode()?{firstShownItemIndex:0,lastShownItemIndex:e-1}:t.top<this.itemsContainer.getHeight()+this.layout.getPrerenderMargin()&&t.bottom>0-this.layout.getPrerenderMargin()?this.layout.getShownItemIndexes({itemsCount:this.getItemsCount(),visibleAreaInsideTheList:t}):(A("The entire list is off-screen. No items are visible."),this.layout.getNonVisibleListShownItemIndexes())}function r(e,t){for(var n=!0,i=this.getState().firstShownItemIndex;i<=this.getState().lastShownItemIndex;){if(i>=e&&i<=t);else{var r=this.getState().itemHeights[i],a=o.call(this,i);a!==r&&(n&&(A("~ Validate will-be-hidden item heights. ~"),s.call(this,i,r,a)),n=!1,_("Item index",i,"is no longer visible and will be unmounted. Its height has changed from",r,"to",a,"since it was last measured. This is not necessarily a bug, and could happen, for example, on screen width change, or when there're several `onItemHeightDidChange(item)` calls issued at the same time, and the first one triggers a re-layout before the rest of them have had a chance to be executed."))}i++}return n}function o(e){var t=this.getState().firstShownItemIndex;return this.itemHeights.remeasureItemHeight(e,t)}function s(e,t,n){var i=this.previouslyCalculatedLayout;if(i){var r=n-t;e<i.firstShownItemIndex?i.beforeItemsHeight+=r:e>i.lastShownItemIndex?void 0!==i.afterItemsHeight&&(i.afterItemsHeight+=r):i.shownItemsHeight+=n-t}}this.onUpdateShownItemIndexes=function(n){var i=n.reason,r=n.stateUpdate,o=function(){r&&e.updateState(r)};return e.newItemsWillBeRendered||e.widthHasChanged||e._isResizing||0===e.getItemsCount()?o():(e.scroll.cancelScheduledLayout(),r=e.cancelLayoutTimer({stateUpdate:r}),A("~ Update Layout (on ".concat(i,") ~")),void t.call(e,{stateUpdate:r}))},this.getListTopOffsetInsideScrollableContainer=function(){var t=e.scrollableContainer.getItemsContainerTopOffset();return e.listTopOffsetWatcher&&e.listTopOffsetWatcher.onListTopOffset(t),t},this._onItemHeightDidChange=function(t){var n=e._getItemIndexByItemOrIndex(t);if(void 0!==n){var i=e.getState(),r=i.itemHeights,a=i.firstShownItemIndex,u=i.lastShownItemIndex;if(A("~ On Item Height Did Change was called ~"),A("Item index",n),!(n>=a&&n<=u))return _("The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when when a developer calls `onItemHeightDidChange(item)` while looping through a batch of items.");var h=r[n];if(void 0!==h){var c;A("~ Re-measure item height ~");try{c=o.call(e,n)}catch(e){if(e instanceof l)return k('"onItemHeightDidChange()" has been called for item index '.concat(n," but the item is not currently rendered and can't be measured. The exact error was: ").concat(e.message))}A("Previous height",h),A("New height",c),h!==c&&(A("~ Item height has changed. Should update layout. ~"),s.call(e,n,h,c),e._isActive&&(e.waitingForRender?(A("~ Another state update is already waiting to be rendered. Delay the layout update until then. ~"),e.updateLayoutAfterRenderBecauseItemHeightChanged=!0):e.onUpdateShownItemIndexes({reason:ee})),e.newItemsWillBeRendered&&(e.itemHeightsThatChangedWhileNewItemsWereBeingRendered||(e.itemHeightsThatChangedWhileNewItemsWereBeingRendered={}),e.itemHeightsThatChangedWhileNewItemsWereBeingRendered[String(n)]=c))}}},this.getPrerenderMargin=function(){return e.scrollableContainer.getHeight()*e.getPrerenderMarginRatio()},this.getPrerenderMarginRatio=function(){return 1},this.onBeforeShowItems=function(t,n,i,r){if(e.onItemInitialRender)for(var o=i;o<=r;)void 0===n[o]&&e.onItemInitialRender(t[o]),o++},this.measureItemHeightsAndSpacing=function(){e.itemHeights.measureItemHeights(e.getState().firstShownItemIndex,e.getState().lastShownItemIndex);var t=e.measureVerticalSpacingIfNotMeasured();if(t&&0!==t)return{verticalSpacing:t}},this.cancelLayoutTimer=function(t){var n=t.stateUpdate;return e.layoutTimer?(Ve(e.layoutTimer),e.layoutTimer=void 0,n||e.layoutTimerStateUpdate?(n=Ge(Ge({},e.layoutTimerStateUpdate),n),e.layoutTimerStateUpdate=void 0,n):void 0):n},this.scheduleLayoutTimer=function(t){var n=t.reason,i=t.stateUpdate;e.layoutTimerStateUpdate=i,e.layoutTimer=ke(function(){e.layoutTimerStateUpdate=void 0,e.layoutTimer=void 0,e.onUpdateShownItemIndexes({reason:n,stateUpdate:i})})}}var Qe=1e3/60;function Xe(e){return Xe="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},Xe(e)}var Ze=Object.prototype.hasOwnProperty;function et(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function tt(e,t){if(et(e,t))return!0;if("object"!==Xe(e)||null===e||"object"!==Xe(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(!Ze.call(t,n[r])||!et(e[n[r]],t[n[r]]))return!1;return!0}function nt(e){return(e%1==0?e:e.toFixed(2))+"px"}function it(){return!("undefined"!=typeof window&&Boolean(window.document.documentMode))}var rt="VirtualScroller",ot="VirtualScrollerStyle";function st(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function at(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?st(Object(n),!0).forEach(function(t){lt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):st(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function lt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ut(){var e=this;function t(e,t){if(e){var n=e.prependedItemsCount;e.appendedItemsCount;var i=this.getState(),r=i.itemHeights,o=i.itemStates;if(this.itemHeightsThatChangedWhileNewItemsWereBeingRendered)for(var s=0,a=Object.keys(this.itemHeightsThatChangedWhileNewItemsWereBeingRendered);s<a.length;s++){var l=a[s];r[n+Number(l)]=this.itemHeightsThatChangedWhileNewItemsWereBeingRendered[l]}if(this.itemStatesThatChangedWhileNewItemsWereBeingRendered)for(var u=0,h=Object.keys(this.itemStatesThatChangedWhileNewItemsWereBeingRendered);u<h.length;u++){var c=h[u];o[n+Number(c)]=this.itemStatesThatChangedWhileNewItemsWereBeingRendered[c]}if(0===n)return this.previouslyCalculatedLayout&&(this.previouslyCalculatedLayout.firstShownItemIndex===t.firstShownItemIndex&&this.previouslyCalculatedLayout.lastShownItemIndex===t.lastShownItemIndex||(_('Unexpected (non-matching) "firstShownItemIndex" or "lastShownItemIndex" encountered in "onRender()" after appending items'),_("Previously calculated layout",this.previouslyCalculatedLayout),_("New layout",t),this.previouslyCalculatedLayout=void 0)),"SEAMLESS_APPEND";if(this.listHeightMeasurement.hasSnapshot()){if(0===t.firstShownItemIndex){A("~ Restore Scroll Position ~");var f=this.listHeightMeasurement.getListBottomOffsetChange({beforeItemsHeight:t.beforeItemsHeight});return this.listHeightMeasurement.reset(),f?(A("Scroll down by",f),this.scroll.scrollByY(f)):A("Scroll position hasn't changed"),this.previouslyCalculatedLayout&&(0===this.previouslyCalculatedLayout.firstShownItemIndex&&this.previouslyCalculatedLayout.lastShownItemIndex===t.lastShownItemIndex-n?this.previouslyCalculatedLayout={beforeItemsHeight:0,shownItemsHeight:this.previouslyCalculatedLayout.shownItemsHeight+f,firstShownItemIndex:0,lastShownItemIndex:t.lastShownItemIndex}:(_('Unexpected (non-matching) "firstShownItemIndex" or "lastShownItemIndex" encountered in "onRender()" after prepending items'),_("Previously calculated layout",this.previouslyCalculatedLayout),_("New layout",t),this.previouslyCalculatedLayout=void 0)),"SEAMLESS_PREPEND"}_('Unexpected "firstShownItemIndex" '.concat(t.firstShownItemIndex,' encountered in "onRender()" after prepending items. Expected 0.'))}}this.previouslyCalculatedLayout=void 0}function n(e){var t=e.reason,n=e.stateUpdate;this._delayRecursiveRenderUntilNextTick||!1!==this._delayRecursiveRenderUntilNextTick&&void 0!==this._stateUpdateSequenceStartedAt&&Date.now()-this._stateUpdateSequenceStartedAt>ht?(n=this.cancelLayoutTimer({stateUpdate:n}),this.scheduleLayoutTimer({reason:t,stateUpdate:n})):this.onUpdateShownItemIndexes({reason:t,stateUpdate:n})}function i(){var e=Boolean(this.widthHasChanged);this.widthHasChanged=void 0;var t=void 0!==this.firstNonMeasuredItemIndex;t&&A("Non-measured item index",this.firstNonMeasuredItemIndex),this.firstNonMeasuredItemIndex=void 0,this.newItemsWillBeRendered=void 0,this.itemHeightsThatChangedWhileNewItemsWereBeingRendered=void 0,this.itemStatesThatChangedWhileNewItemsWereBeingRendered=void 0;var n=this.updateLayoutAfterRenderBecauseItemHeightChanged;return this.updateLayoutAfterRenderBecauseItemHeightChanged=void 0,{nonMeasuredItemsHaveBeenRendered:t,itemHeightHasChanged:n,widthHasChanged:e}}this._onRender=function(r,o){var s,a,l;e.waitingForRender=!1,A("~ Rendered ~"),V()&&A("State",ze(r)),e.onStateChange&&(tt(r,o)||e.onStateChange(r)),e.isItemsContainerElementTableBody()&&(s=e.getItemsContainerElement(),a=r.beforeItemsHeight,l=r.afterItemsHeight,s.style.setProperty("--VirtualScroller-paddingTop",nt(a)),s.style.setProperty("--VirtualScroller-paddingBottom",nt(l))),e.mostRecentSetStateValue&&(tt(r,e.mostRecentSetStateValue)||(_("The most recent state that was set",ze(e.mostRecentSetStateValue)),k("`VirtualScroller` has been rendered with a `state` that is not equal to the most recently set one")));var u,h=i.call(e),c=h.nonMeasuredItemsHaveBeenRendered,f=h.itemHeightHasChanged,d=h.widthHasChanged;if(f&&(u=ee),o||u){if(c&&(u=K),d&&(u=Q,e.itemHeights.reset(),e.verticalSpacing=void 0),o){var m=o.items,g=r.items;if(g!==m){var p=e.getItemsDiff(m,g);if(p){var I=p.prependedItemsCount;e.itemHeights.onPrepend(I)}else e.itemHeights.reset();d||"SEAMLESS_PREPEND"!==t.call(e,p,r)&&(u=te)}}var v;if(o&&(r.firstShownItemIndex!==o.firstShownItemIndex||r.lastShownItemIndex!==o.lastShownItemIndex||r.items!==o.items)||d){var y=e.measureItemHeightsAndSpacing();y&&(v=at(at({},v),y))}var S=e.beforeResize.cleanUpBeforeResizeItemHeights();if(void 0!==S){var b=S.scrollBy,w=S.beforeResize;A("Correct scroll position by",b),e.scroll.scrollByY(b),v=at(at({},v),{},{beforeResize:w})}e._isActive?u?n.call(e,{stateUpdate:v,reason:u}):v?e.updateState(v):A("~ Finished Layout ~"):e._afterRenderStateUpdateThatWasStopped=v}}}var ht=1e3/60;function ct(){var e=this;this.onContainerResize=function(){e.previouslyCalculatedLayout=void 0,e.listHeightMeasurement.reset();var t=e.newItemsWillBeRendered?e.newItemsWillBeRendered.count:e.getState().itemHeights.length,n=e.newItemsWillBeRendered?e.newItemsWillBeRendered.layout:e.getState(),i={scrollableContainerWidth:e.scrollableContainer.getWidth(),firstShownItemIndex:n.firstShownItemIndex,lastShownItemIndex:n.lastShownItemIndex,beforeItemsHeight:n.beforeItemsHeight,afterItemsHeight:n.afterItemsHeight,itemHeights:new Array(t),columnsCount:e.getActualColumnsCountForState(),verticalSpacing:void 0},r=n.firstShownItemIndex,o=n.lastShownItemIndex,s=e.getActualColumnsCount(),a=Math.floor(r/s)*s,l=Math.min(Math.ceil((o+1)/s)*s,t)-1;a!==r&&(A("Columns Count changed from",e.getState().columnsCount||1,"to",s),A("First Shown Item Index needs to change from",r,"to",a)),i.firstShownItemIndex=a,i.lastShownItemIndex=l;var u=e.getVerticalSpacing(),h=e.getColumnsCount();e.shouldDiscardBeforeResizeItemHeights()||0===a?e.beforeResize.shouldIncludeBeforeResizeValuesInState()&&(i.beforeResize=void 0):i.beforeResize={verticalSpacing:u,columnsCount:h,itemHeights:e.beforeResize.snapshotBeforeResizeItemHeights({firstShownItemIndex:r,newFirstShownItemIndex:a})},e.widthHasChanged={stateUpdate:i},e.updateState(i)},this.shouldDiscardBeforeResizeItemHeights=function(){if(e.newItemsWillBeRendered){var t=e.newItemsWillBeRendered,n=t.prepend,i=t.replace;return n||i}}}function ft(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function dt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ft(Object(n),!0).forEach(function(t){mt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ft(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function mt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gt(){var e=this;this.getItemsCount=function(){return e.getState().items.length},this._getItemIndexByItemOrIndex=function(t){var n=t,i=e.getState().items,r=i.indexOf(n);if(r>=0)return r;if("number"==typeof t){var o=t;if(o>=0&&o<i.length)return o}else{var s=e._getItemId;if(s){var a=s(n),l=i.findIndex(function(e){return s(e)===a});if(l>=0)return l}}k("Item not found: ".concat(JSON.stringify(n)))},this._setItems=function(t){var n,i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=e.getState().items,s=e.getState().itemStates,a=(e.widthHasChanged?e.widthHasChanged.stateUpdate:e.getState()).itemHeights;A("~ Update items ~");var l=e.getItemsDiff(o,t);if(l){var u,h=e.widthHasChanged?e.widthHasChanged.stateUpdate:e.getState(),c=h.firstShownItemIndex,f=h.lastShownItemIndex,d=h.beforeItemsHeight,m=h.afterItemsHeight,g=0===c&&(r.preserveScrollPositionOnPrependItems||r.preserveScrollPosition),p=l.prependedItemsCount,I=l.appendedItemsCount;n=e.layout.getLayoutUpdateForItemsDiff({firstShownItemIndex:c,lastShownItemIndex:f,beforeItemsHeight:d,afterItemsHeight:m},{prependedItemsCount:p,appendedItemsCount:I},{itemsCount:t.length,columnsCount:e.getActualColumnsCount(),shouldRestoreScrollPosition:g,onResetGridLayout:function(){return u=!0}}),p>0&&(A("Prepend",p,"items"),a=new Array(p).concat(a),s=Be(new Array(p),function(n){return e.getInitialItemState(t[n])}).concat(s),g?(A("Will restore scroll position"),e.listHeightMeasurement.snapshotListHeightBeforeAddingNewItems({previousItems:o,newItems:t,prependedItemsCount:p}),void 0!==e.firstNonMeasuredItemIndex&&(e.firstNonMeasuredItemIndex+=p)):(A("Reset layout"),u?(A("Reason: Prepended items count",p,"is not divisible by Columns Count",e.getActualColumnsCount()),a=new Array(t.length)):A("Reason: Prepended items' heights are unknown"),n=e.layout.getInitialLayoutValues({itemsCount:t.length,columnsCount:e.getActualColumnsCount()}),e.firstNonMeasuredItemIndex=void 0)),I>0&&(A("Append",I,"items"),a=a.concat(new Array(I)),s=s.concat(Be(new Array(I),function(n){return e.getInitialItemState(t[p+o.length+n])}))),i={prepend:p>0,append:I>0}}else A("Items have changed, and",l?"a re-layout from scratch has been requested.":"it's not a simple append and/or prepend.","Rerender the entire list from scratch."),A("Previous items",o),A("New items",t),a=new Array(t.length),s=Be(new Array(t.length),function(n){return e.getInitialItemState(t[n])}),n=e.layout.getInitialLayoutValues({itemsCount:t.length,columnsCount:e.getActualColumnsCount()}),e.firstNonMeasuredItemIndex=void 0,e.listHeightMeasurement.reset(),i={replace:!0};A("~ Update state ~"),A("First shown item index",n.firstShownItemIndex),A("Last shown item index",n.lastShownItemIndex),A("Before items height",n.beforeItemsHeight),A("After items height (actual or estimated)",n.afterItemsHeight),e.onBeforeShowItems(t,a,n.firstShownItemIndex,n.lastShownItemIndex),e.newItemsWillBeRendered=dt(dt({},i),{},{count:t.length,layout:n});var v=dt(dt({},n),{},{items:t,itemStates:s,itemHeights:a});e.beforeResize.shouldIncludeBeforeResizeValuesInState()&&(e.shouldDiscardBeforeResizeItemHeights()?v.beforeResize=void 0:v.beforeResize=e.widthHasChanged?e.widthHasChanged.stateUpdate.beforeResize:e.getState().beforeResize),e._isSettingNewItems=!0,e.updateState(v)},this.getItemsDiff=function(t,n){return function(e,t,n){var i=-1,r=-1;if(e.length>0&&(i=function(e,t,n){for(var i=0;i<e.length;){if(n(e[i],t))return i;i++}return-1}(t,e[0],n),i>=0&&function(e,t,n,i){for(var r=0;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)),i>=0&&r>=0)return{prependedItemsCount:i,appendedItemsCount:t.length-(r+1)}}(t,n,e.isItemEqual)}}function pt(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=i.bypass,o=i.render,s=i.state,a=i.getInitialItemState,l=void 0===a?function(){}:a,u=i.onStateChange,h=i.initialScrollPosition,c=i.onScrollPositionChange,f=i.scrollableContainer,d=i.measureItemsBatchSize,m=void 0===d?50:d,g=i.getColumnsCount,p=i.getItemId,I=i.estimatedItemHeight,v=i.getEstimatedVisibleItemRowsCount,y=i.getEstimatedInterItemVerticalSpacing,S=i.onItemInitialRender,b=i.onItemFirstRender,w=i.delayRecursiveRenderUntilNextTick,C=i._delayUnnecessaryRerenderUntilStopsScrolling,O=i.engine,R=i.getEstimatedItemHeight,x=i.getScrollableContainer;if(A("~ Initialize ~"),this.engine=O||M,R||"number"!=typeof I||(R=function(){return I}),!x&&f&&(x=function(){return f}),this.getItemsContainerElement=function(){var t=e();if(null===t)throw new Error("[virtual-scroller] Items container element is `null`");return t},i.getState||i.setState)throw new Error("[virtual-scroller] `getState`/`setState` options usage has changed in the new version. See the readme for more details.");r&&A('~ "bypass" mode ~'),this._bypass=r,this._delayRecursiveRenderUntilNextTick=w,this._getItemId=p,this.isItemEqual=p?function(e,t){return p(e)===p(t)}:function(e,t){return e===t},S?this.onItemInitialRender=S:b&&(this.onItemInitialRender=function(e){_("`onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.");var t=n.getState().items.indexOf(e);t>=0&&b(t)}),s&&(t=s.items),A("Items count",t.length),R&&A("Estimated item height",R()),We.call(this,{state:s,getInitialItemState:l,onStateChange:u,render:o,items:t}),Ye.call(this,{getEstimatedInterItemVerticalSpacing:y}),qe.call(this,{getColumnsCount:g}),Ke.call(this),ut.call(this),ct.call(this),gt.call(this),It.call(this,{getScrollableContainer:x,getEstimatedItemHeight:R,getEstimatedVisibleItemRowsCount:v,measureItemsBatchSize:m,initialScrollPosition:h,onScrollPositionChange:c,delayUnnecessaryRerenderUntilStopsScrolling:C}),s&&(this.itemHeights.readItemHeightsFromState(s),this.beforeResize.initializeFromState(s))}function It(e){var t=this,n=e.getScrollableContainer,i=e.getEstimatedItemHeight,r=e.getEstimatedVisibleItemRowsCount,o=e.measureItemsBatchSize,s=e.initialScrollPosition,a=e.onScrollPositionChange,l=e.delayUnnecessaryRerenderUntilStopsScrolling;this.itemsContainer=this.engine.createItemsContainer(this.getItemsContainerElement),this.isItemsContainerElementTableBody=function(){return t.engine===M&&"TBODY"===t.getItemsContainerElement().tagName},this.isInBypassMode=function(){return t._bypass},this.scrollableContainer=this.engine.createScrollableContainer(n,this.getItemsContainerElement),this.itemHeights=new Me({container:this.itemsContainer,getItemHeight:function(e){return t.getState().itemHeights[e]},setItemHeight:function(e,n){return t.getState().itemHeights[e]=n}}),this.getAverageItemHeight=function(){var e=t.itemHeights.getAverageItemHeight();return"number"==typeof e?e:t.getEstimatedItemHeight()},this.getEstimatedItemHeight=function(){if(i){var e=i();if("number"==typeof e)return e;throw new Error("[virtual-scroller] `getEstimatedItemHeight()` must return a number")}return 0},this.layout=new Y({isInBypassMode:this.isInBypassMode,getEstimatedVisibleItemRowsCountForInitialRender:r,measureItemsBatchSize:o,getPrerenderMargin:function(){return t.getPrerenderMargin()},getPrerenderMarginRatio:function(){return t.getPrerenderMarginRatio()},getVerticalSpacing:function(){return t.getVerticalSpacing()},getVerticalSpacingBeforeResize:function(){return t.getVerticalSpacingBeforeResize()},getColumnsCount:function(){return t.getColumnsCount()},getColumnsCountBeforeResize:function(){return t.getState().beforeResize&&t.getState().beforeResize.columnsCount},getItemHeight:function(e){return t.getState().itemHeights[e]},getItemHeightBeforeResize:function(e){return t.getState().beforeResize&&t.getState().beforeResize.itemHeights[e]},getBeforeResizeItemsCount:function(){return t.getState().beforeResize?t.getState().beforeResize.itemHeights.length:0},getAverageItemHeight:function(){return t.getAverageItemHeight()},getMaxVisibleAreaHeight:function(){return t.scrollableContainer&&t.scrollableContainer.getHeight()},getPreviouslyCalculatedLayout:function(){return t.previouslyCalculatedLayout}}),this.scrollableContainerResizeHandler=new Ie({isInBypassMode:this.isInBypassMode,getWidth:function(){return t.scrollableContainer.getWidth()},getHeight:function(){return t.scrollableContainer.getHeight()},listenForResize:function(e){return t.scrollableContainer.onResize(e)},onResizeStart:function(){A("~ Scrollable container resize started ~"),t._isResizing=!0},onResizeStop:function(){A("~ Scrollable container resize finished ~"),t._isResizing=void 0},onNoChange:function(){t.onUpdateShownItemIndexes({reason:Z})},onHeightChange:function(){return t.onUpdateShownItemIndexes({reason:X})},onWidthChange:function(e,n){A("~ Scrollable container width changed from",e,"to",n,"~"),t.onContainerResize()}}),this.scroll=new He({isInBypassMode:this.isInBypassMode,scrollableContainer:this.scrollableContainer,itemsContainer:this.itemsContainer,delayUnnecessaryRerenderUntilStopsScrolling:l,onScroll:function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).delayed;t.onUpdateShownItemIndexes({reason:e?J:q})},initialScrollPosition:s,onScrollPositionChange:a,isImmediateLayoutScheduled:function(){return Boolean(t.layoutTimer)},hasNonRenderedItemsAtTheTop:function(){return t.getState().firstShownItemIndex>0},hasNonRenderedItemsAtTheBottom:function(){return t.getState().lastShownItemIndex<t.getItemsCount()-1},getLatestLayoutVisibleArea:function(){return t.latestLayoutVisibleArea},getListTopOffset:this.getListTopOffsetInsideScrollableContainer,getPrerenderMargin:function(){return t.getPrerenderMargin()}}),this.listHeightMeasurement=new je({itemsContainer:this.itemsContainer,getListTopOffset:this.getListTopOffsetInsideScrollableContainer}),this.engine.watchListTopOffset&&(this.listTopOffsetWatcher=this.engine.watchListTopOffset({getListTopOffset:this.getListTopOffsetInsideScrollableContainer,onListTopOffsetChange:function(){return t.onUpdateShownItemIndexes({reason:ne})}})),this.beforeResize=new Ce({getState:this.getState,getVerticalSpacing:this.getVerticalSpacing,getColumnsCount:this.getColumnsCount})}function vt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function yt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vt(Object(n),!0).forEach(function(t){bt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function St(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 bt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var wt=function(){function e(t,n){var i=this,r=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),bt(this,"stop",function(){if(!i._isActive)throw new Error("[virtual-scroller] Can't stop a `VirtualScroller` that hasn't been started");i._isActive=!1,A("~ Stop ~"),i.scrollableContainerResizeHandler.stop(),i.scroll.stop(),i.listTopOffsetWatcher&&i.listTopOffsetWatcher.isStarted()&&i.listTopOffsetWatcher.stop(),i.cancelLayoutTimer({}),void 0!==i._stateUpdateSequenceStartedAtResetTimer&&(Ve(i._stateUpdateSequenceStartedAtResetTimer),i._stateUpdateSequenceStartedAtResetTimer=void 0)}),bt(this,"updateLayout",function(){i.hasToBeStarted(),i.onUpdateShownItemIndexes({reason:G})}),bt(this,"onRender",function(){i._onRender(i.getState(),i.previousState)}),pt.call(this,t,n,r)}var t,n,i;return t=e,n=[{key:"start",value:function(){if(this._isActive)throw new Error("[virtual-scroller] `VirtualScroller` has already been started");var e=!1===this._isActive;e||(this.setUpState(),this.waitingForRender=!0,this._render&&this._render(this.getState())),A(e?"~ Start (restart) ~":"~ Start ~"),this._isActive=!0,this.listHeightMeasurement.reset(),this._isResizing=void 0,this._isSettingNewItems=void 0,this.isInBypassMode()||this.isItemsContainerElementTableBody()&&(it()?this.getItemsContainerElement().classList.contains(rt)&&Boolean(document.getElementById(ot))||(A("~ <tbody/> container ~"),function(e){e.classList.add(rt);var t=document.createElement("style");t.id=ot,t.innerText="\n\t\ttbody.".concat(rt,":before {\n\t\t\tcontent: '';\n\t\t\tdisplay: table-row;\n\t\t\theight: var(--VirtualScroller-paddingTop);\n\t\t}\n\t\ttbody.").concat(rt,":after {\n\t\t\tcontent: '';\n\t\t\tdisplay: table-row;\n\t\t\theight: var(--VirtualScroller-paddingBottom);\n\t\t}\n\t").replace(/[\n\t]/g,""),document.head.appendChild(t)}(this.getItemsContainerElement())):(A("~ <tbody/> container not supported ~"),k("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"),A('~ enter "bypass" mode ~'),this._bypass=!0));var t=this._afterRenderStateUpdateThatWasStopped;this._afterRenderStateUpdateThatWasStopped=void 0,this.verticalSpacing=void 0;var n=this.measureItemHeightsAndSpacing();if(n&&(t=yt(yt({},t),n)),this.scrollableContainerResizeHandler.start(),this.scroll.start(),void 0===this.getState().scrollableContainerWidth){var i=this.scrollableContainer.getWidth();t=yt(yt({},t),{},{scrollableContainerWidth:i})}else{var r=this.scrollableContainer.getWidth(),o=this.getState().scrollableContainerWidth;if(r!==o)return A("~ Scrollable container width changed from",o,"to",r,"~"),this.onContainerResize()}if(this._usesCustomStateStorage&&this.getActualColumnsCount()!==(this.getState().columnsCount||1))return this.onContainerResize();this.onUpdateShownItemIndexes({reason:$,stateUpdate:t})}},{key:"hasToBeStarted",value:function(){if(!this._isActive)throw new Error("[virtual-scroller] `VirtualScroller` hasn't been started")}},{key:"getItemScrollPosition",value:function(e){var t=this._getItemIndexByItemOrIndex(e);if(void 0!==t){var n=this.layout.getItemTopOffset(t);if(void 0!==n)return this.getListTopOffsetInsideScrollableContainer()+n}}},{key:"onItemHeightChange",value:function(e){_("`.onItemHeightChange(item)` method was renamed to `.onItemHeightDidChange(item)`"),this.onItemHeightDidChange(e)}},{key:"onItemHeightDidChange",value:function(e){this._onItemHeightDidChange(e)}},{key:"setItemState",value:function(e,t){this._setItemState(e,t)}},{key:"onItemStateChange",value:function(e,t){this.setItemState(e,t)}},{key:"setItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.hasToBeStarted(),this._setItems(e,t)}}],n&&St(t.prototype,n),i&&St(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}(),Ct=["onMount","onItemUnmount","readyToStart","readyToRender"];function Ot(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function Rt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ot(Object(n),!0).forEach(function(t){Tt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ot(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xt(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 Ht(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 Tt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Pt=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),Tt(this,"render",function(e,t){var n=e.items,i=e.firstShownItemIndex,o=e.lastShownItemIndex,s=e.beforeItemsHeight,a=e.afterItemsHeight,l=r.getItemsContainerElement();r.virtualScroller.isItemsContainerElementTableBody()||(l.style.paddingTop=nt(s),l.style.paddingBottom=nt(a));var u=t&&n===t.items&&n.length>0;if(u)for(var h=t.lastShownItemIndex;h>=t.firstShownItemIndex;)h>=i&&h<=o||(A("DOM: Remove element for item index",h),r.unmountItem(l.childNodes[h-t.firstShownItemIndex])),h--;else for(A("DOM: Rerender the list from scratch");l.firstChild;)r.unmountItem(l.firstChild);for(var c=u,f=c&&l.firstChild,d=i;d<=o;){if(u&&d>=t.firstShownItemIndex&&d<=t.lastShownItemIndex)c&&(c=!1);else{var m=r.renderItem(n[d]);c?(A("DOM: Prepend element for item index",d),l.insertBefore(m,f)):(A("DOM: Append element for item index",d),l.appendChild(m))}d++}r._isMounted||(r._isMounted=!0,r._onMount&&r._onMount())}),Tt(this,"onUnmount",function(){_("`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),Tt(this,"destroy",function(){_("`.destroy()` instance method name is deprecated, use `.stop()` instance method name instead."),r.stop()}),Tt(this,"stop",function(){r.virtualScroller.stop()}),Tt(this,"start",function(){if(r._isInitialRender){r._isInitialRender=!1;for(var e=r.getItemsContainerElement();e.firstChild;)e.removeChild(e.firstChild)}r.virtualScroller.start()}),this.getItemsContainerElement="function"==typeof t?t:function(){return t},this.renderItem=i,this._isInitialRender=!0;var s=o.onMount,a=o.onItemUnmount,l=o.readyToStart,u=o.readyToRender,h=xt(o,Ct);this._onMount=s,this.onItemUnmount=a,this.virtualScroller=new wt(this.getItemsContainerElement,n,Rt(Rt({},h),{},{render:this.render})),!1===u||(!1===l?this.render(this.virtualScroller.getInitialState()):this.start())}var t,n,i;return t=e,(n=[{key:"unmountItem",value:function(e){this.getItemsContainerElement().removeChild(e),this.onItemUnmount&&this.onItemUnmount(e)}},{key:"onItemHeightChange",value:function(e){_("`.onItemHeightChange(item)` method was renamed to `.onItemHeightDidChange(item)`"),this.onItemHeightDidChange(e)}},{key:"onItemHeightDidChange",value:function(e){this.virtualScroller.onItemHeightDidChange(e)}},{key:"setItemState",value:function(e,t){this.virtualScroller.setItemState(e,t)}},{key:"updateItems",value:function(e,t){_("`.updateItems()` method was renamed to `.setItems(i)`"),this.setItems(e,t)}},{key:"setItems",value:function(e,t){this.virtualScroller.setItems(e,t)}}])&&Ht(t.prototype,n),i&&Ht(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();return Pt});
2
2
  //# sourceMappingURL=virtual-scroller-dom.js.map