react-virtuoso 4.8.0-development → 4.9.0

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.
package/README.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/react-virtuoso.svg?style=flat)](//badge.fury.io/js/react-virtuoso)
4
4
 
5
- **React Virtuoso** is the most powerful React virtual list/table component, full stop. Here's why:
5
+ **React Virtuoso** - the most complete React virtualization rendering list/table/grid family of components.
6
6
 
7
7
  - Variable sized items out of the box; no manual measurements or hard-coding item heights is necessary;
8
- - Support for [reverse (bottom up) scrolling and prepending items](https://virtuoso.dev/prepend-items/) (chat, feeds, etc);
8
+ - [Chat message list UI](https://virtuoso.dev/virtuoso-message-list/) **NEW**;
9
9
  - [Grouped mode with sticky headers](https://virtuoso.dev/grouped-by-first-letter/);
10
10
  - [Responsive grid layout](https://virtuoso.dev/grid-responsive-columns/);
11
11
  - [Table Support](https://virtuoso.dev/hello-table/);
@@ -40,6 +40,11 @@ const App = () => {
40
40
  ReactDOM.render(<App />, document.getElementById('root'))
41
41
  ```
42
42
 
43
+ ## [Message List](https://virtuoso.dev/virtuoso-message-list/)
44
+
45
+ The Virtuoso message list component is built specifically for human/chatbot conversations. In addition to the virtualized rendering, the component exposes an imperative data management
46
+ API that gives you the necessary control over the scroll position when older messages are loaded, new messages arrive, and when the user submits a message. The scroll position can update instantly or with a smooth scroll animation.
47
+
43
48
  ## [Grouped Mode](https://virtuoso.dev/grouped-by-first-letter/)
44
49
 
45
50
  The `GroupedVirtuoso` component is a variant of the "flat" `Virtuoso`, with the following differences:
@@ -90,12 +95,7 @@ To run the tests, use `npm run test`.
90
95
  An end-to-end browser-based test suite is runnable with `npm run e2e`, with the pages being `e2e/*.tsx` and the tests `e2e/*.test.ts`.
91
96
 
92
97
  A convenient way to debug something is to preview the test cases in the browser.
93
- To do that, run `npm run browse-examples` - it will open a crude UI that lets you browse the components in the `e2e` folder.
94
-
95
- ### Docs
96
-
97
- The documentation site is built with docusaurus and the content is available in the `site/docs` directory.
98
- The API reference is generated from the doc comments in `src/components.tsx`.
98
+ To do that, run `npm run dev` - it will launch a Ladle server that lets you browse the components in the `examples` folder.
99
99
 
100
100
  ## License
101
101
 
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("react-dom"),o=0,n=1,r=2,i=4;function l(e,t){return o=>e(t(o))}function s(e,t){return t(e)}function c(e,t){return o=>e(t,o)}function a(e,t){return()=>e(t)}function u(e,t){return t(e),e}function d(...e){return e}function m(e){e()}function f(e){return()=>e}function h(e){return void 0!==e}function g(){}function p(e,t){return e(n,t)}function v(e,t){e(o,t)}function I(e){e(r)}function x(e){return e(i)}function T(e,t){return p(e,c(t,o))}function w(e,t){const o=e(n,(e=>{o(),t(e)}));return o}function S(){const e=[];return(t,i)=>{switch(t){case r:return void e.splice(0,e.length);case n:return e.push(i),()=>{const t=e.indexOf(i);t>-1&&e.splice(t,1)};case o:return void e.slice().forEach((e=>{e(i)}));default:throw new Error(`unrecognized action ${t}`)}}}function C(e){let t=e;const r=S();return(e,l)=>{switch(e){case n:l(t);break;case o:t=l;break;case i:return t}return r(e,l)}}function E(e){return u(S(),(t=>T(e,t)))}function H(e,t){return u(C(t),(t=>T(e,t)))}function y(e,...t){const o=function(...e){return t=>e.reduceRight(s,t)}(...t);return(t,i)=>{switch(t){case n:return p(e,o(i));case r:return void I(e)}}}function b(e,t){return e===t}function R(e=b){let t;return o=>n=>{e(t,n)||(t=n,o(n))}}function z(e){return t=>o=>{e(o)&&t(o)}}function B(e){return t=>l(t,e)}function k(e){return t=>()=>t(e)}function L(e,t){return o=>n=>o(t=e(t,n))}function P(e){return t=>o=>{e>0?e--:t(o)}}function M(e){let t,o=null;return n=>r=>{o=r,t||(t=setTimeout((()=>{t=void 0,n(o)}),e))}}function O(e){let t,o;return n=>r=>{t=r,o&&clearTimeout(o),o=setTimeout((()=>{n(t)}),e)}}function F(...e){const t=new Array(e.length);let o=0,n=null;const r=Math.pow(2,e.length)-1;return e.forEach(((e,i)=>{const l=Math.pow(2,i);p(e,(e=>{const s=o;o|=l,t[i]=e,s!==r&&o===r&&n&&(n(),n=null)}))})),e=>i=>{const l=()=>e([i].concat(t));o===r?l():n=l}}function W(...e){return function(t,o){switch(t){case n:return function(...e){return()=>{e.map(m)}}(...e.map((e=>p(e,o))));case r:return;default:throw new Error(`unrecognized action ${t}`)}}}function V(e,t=b){return y(e,R(t))}function A(...e){const t=S(),o=new Array(e.length);let i=0;const l=Math.pow(2,e.length)-1;return e.forEach(((e,n)=>{const r=Math.pow(2,n);p(e,(e=>{o[n]=e,i|=r,i===l&&v(t,o)}))})),function(e,s){switch(e){case n:return i===l&&s(o),p(t,s);case r:return I(t);default:throw new Error(`unrecognized action ${e}`)}}}function D(e,t=[],{singleton:o}={singleton:!0}){return{id:G(),constructor:e,dependencies:t,singleton:o}}const G=()=>Symbol();const N="undefined"!=typeof document?e.useLayoutEffect:e.useEffect;function _(t,o,i){const l=Object.keys(o.required||{}),s=Object.keys(o.optional||{}),d=Object.keys(o.methods||{}),m=Object.keys(o.events||{}),h=e.createContext({});function T(e,t){e.propsReady&&v(e.propsReady,!1);for(const n of l){v(e[o.required[n]],t[n])}for(const n of s)if(n in t){v(e[o.optional[n]],t[n])}e.propsReady&&v(e.propsReady,!0)}function w(e){return m.reduce(((t,i)=>(t[i]=function(e){let t,o;const i=()=>t&&t();return function(l,s){switch(l){case n:if(s){if(o===s)return;return i(),o=s,t=p(e,s),t}return i(),g;case r:return i(),void(o=null);default:throw new Error(`unrecognized action ${l}`)}}}(e[o.events[i]]),t)),{})}const S=e.forwardRef(((n,r)=>{const{children:c,...g}=n,[x]=e.useState((()=>u(function(e){const t=new Map,o=({id:e,constructor:n,dependencies:r,singleton:i})=>{if(i&&t.has(e))return t.get(e);const l=n(r.map((e=>o(e))));return i&&t.set(e,l),l};return o(e)}(t),(e=>T(e,g))))),[S]=e.useState(a(w,x));return N((()=>{for(const e of m)e in g&&p(S[e],g[e]);return()=>{Object.values(S).map(I)}}),[g,S,x]),N((()=>{T(x,g)})),e.useImperativeHandle(r,f(function(e){return d.reduce(((t,n)=>(t[n]=t=>{v(e[o.methods[n]],t)},t)),{})}(x))),e.createElement(h.Provider,{value:x},i?e.createElement(i,function(e,t){const o={},n={};let r=0;const i=e.length;for(;r<i;)n[e[r]]=1,r+=1;for(const l in t)n.hasOwnProperty(l)||(o[l]=t[l]);return o}([...l,...s,...m],g),c):c)}));return{Component:S,usePublisher:t=>e.useCallback(c(v,e.useContext(h)[t]),[t]),useEmitterValue:e.version.startsWith("18")?t=>{const o=e.useContext(h)[t],n=e.useCallback((e=>p(o,e)),[o]);return e.useSyncExternalStore(n,(()=>x(o)),(()=>x(o)))}:t=>{const o=e.useContext(h)[t],[n,r]=e.useState(a(x,o));return N((()=>p(o,(e=>{e!==n&&r(f(e))}))),[o,n]),n},useEmitter:(t,o)=>{const n=e.useContext(h)[t];N((()=>p(n,o)),[o,n])}}}const U="undefined"!=typeof document?e.useLayoutEffect:e.useEffect;var $=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))($||{});const j={0:"debug",1:"log",2:"warn",3:"error"},K=D((()=>{const e=C(3);return{log:C(((t,o,n=1)=>{var r;n>=(null!=(r=("undefined"==typeof globalThis?window:globalThis).VIRTUOSO_LOG_LEVEL)?r:x(e))&&console[j[n]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,o)})),logLevel:e}}),[],{singleton:!0});function q(t,o=!0){const n=e.useRef(null);let r=e=>{};if("undefined"!=typeof ResizeObserver){const i=e.useMemo((()=>new ResizeObserver((e=>{const o=e[0].target;null!==o.offsetParent&&t(o)}))),[t]);r=e=>{e&&o?(i.observe(e),n.current=e):(n.current&&i.unobserve(n.current),n.current=null)}}return{ref:n,callbackRef:r}}function Y(e,t=!0){return q(e,t).callbackRef}function Z(t,o,n,r,i,l,s){const c=e.useCallback((e=>{const n=function(e,t,o,n){const r=e.length;if(0===r)return null;const i=[];for(let l=0;l<r;l++){const r=e.item(l);if(!r||void 0===r.dataset.index)continue;const s=parseInt(r.dataset.index),c=parseFloat(r.dataset.knownSize),a=t(r,o);if(0===a&&n("Zero-sized element, this should not happen",{child:r},$.ERROR),a===c)continue;const u=i[i.length-1];0===i.length||u.size!==a||u.endIndex!==s-1?i.push({startIndex:s,endIndex:s,size:a}):i[i.length-1].endIndex++}return i}(e.children,o,"offsetHeight",i);let c=e.parentElement;for(;!c.dataset.virtuosoScroller;)c=c.parentElement;const a="window"===c.lastElementChild.dataset.viewportType,u=s?s.scrollTop:a?window.pageYOffset||document.documentElement.scrollTop:c.scrollTop,d=s?s.scrollHeight:a?document.documentElement.scrollHeight:c.scrollHeight,m=s?s.offsetHeight:a?window.innerHeight:c.offsetHeight;r({scrollTop:Math.max(u,0),scrollHeight:d,viewportHeight:m}),null==l||l(function(e,t,o){"normal"===t||(null==t?void 0:t.endsWith("px"))||o(`${e} was not resolved to pixel value correctly`,t,$.WARN);if("normal"===t)return 0;return parseInt(null!=t?t:"0",10)}("row-gap",getComputedStyle(e).rowGap,i)),null!==n&&t(n)}),[t,o,i,l,s,r]);return q(c,n)}function J(e,t){return Math.round(e.getBoundingClientRect()[t])}function Q(e,t){return Math.abs(e-t)<1.01}function X(o,n,r,i=g,l){const s=e.useRef(null),c=e.useRef(null),a=e.useRef(null),u=e.useCallback((e=>{const r=e.target,i=r===window||r===document,l=i?window.pageYOffset||document.documentElement.scrollTop:r.scrollTop,s=i?document.documentElement.scrollHeight:r.scrollHeight,u=i?window.innerHeight:r.offsetHeight,d=()=>{o({scrollTop:Math.max(l,0),scrollHeight:s,viewportHeight:u})};e.suppressFlushSync?d():t.flushSync(d),null!==c.current&&(l===c.current||l<=0||l===s-u)&&(c.current=null,n(!0),a.current&&(clearTimeout(a.current),a.current=null))}),[o,n]);return e.useEffect((()=>{const e=l||s.current;return i(l||s.current),u({target:e,suppressFlushSync:!0}),e.addEventListener("scroll",u,{passive:!0}),()=>{i(null),e.removeEventListener("scroll",u)}}),[s,u,r,i,l]),{scrollerRef:s,scrollByCallback:function(e){s.current.scrollBy(e)},scrollToCallback:function(e){const t=s.current;if(!t||"offsetHeight"in t&&0===t.offsetHeight)return;const r="smooth"===e.behavior;let i,l,u;t===window?(l=Math.max(J(document.documentElement,"height"),document.documentElement.scrollHeight),i=window.innerHeight,u=document.documentElement.scrollTop):(l=t.scrollHeight,i=J(t,"height"),u=t.scrollTop);const d=l-i;if(e.top=Math.ceil(Math.max(Math.min(d,e.top),0)),Q(i,l)||e.top===u)return o({scrollTop:u,scrollHeight:l,viewportHeight:i}),void(r&&n(!0));r?(c.current=e.top,a.current&&clearTimeout(a.current),a.current=setTimeout((()=>{a.current=null,c.current=null,n(!0)}),1e3)):c.current=null,t.scrollTo(e)}}}const ee=D((()=>{const e=S(),t=S(),o=C(0),n=S(),r=C(0),i=S(),l=S(),s=C(0),c=C(0),a=C(0),u=C(0),d=S(),m=S(),f=C(!1);return T(y(e,B((({scrollTop:e})=>e))),t),T(y(e,B((({scrollHeight:e})=>e))),l),T(t,r),{scrollContainerState:e,scrollTop:t,viewportHeight:i,headerHeight:s,fixedHeaderHeight:c,fixedFooterHeight:a,footerHeight:u,scrollHeight:l,smoothScrollTargetReached:n,scrollTo:d,scrollBy:m,statefulScrollTop:r,deviation:o,scrollingInProgress:f}}),[],{singleton:!0}),te={lvl:0};function oe(e,t,o,n=te,r=te){return{k:e,v:t,lvl:o,l:n,r:r}}function ne(e){return e===te}function re(){return te}function ie(e,t){if(ne(e))return te;const{k:o,l:n,r:r}=e;if(t===o){if(ne(n))return r;if(ne(r))return n;{const[t,o]=de(n);return pe(fe(e,{k:t,v:o,l:me(n)}))}}return pe(fe(e,t<o?{l:ie(n,t)}:{r:ie(r,t)}))}function le(e,t){if(!ne(e))return t===e.k?e.v:t<e.k?le(e.l,t):le(e.r,t)}function se(e,t,o="k"){if(ne(e))return[-1/0,void 0];if(Number(e[o])===t)return[e.k,e.v];if(Number(e[o])<t){const n=se(e.r,t,o);return n[0]===-1/0?[e.k,e.v]:n}return se(e.l,t,o)}function ce(e,t,o){return ne(e)?oe(t,o,1):t===e.k?fe(e,{k:t,v:o}):t<e.k?ge(fe(e,{l:ce(e.l,t,o)})):ge(fe(e,{r:ce(e.r,t,o)}))}function ae(e,t,o){if(ne(e))return[];const{k:n,v:r,l:i,r:l}=e;let s=[];return n>t&&(s=s.concat(ae(i,t,o))),n>=t&&n<=o&&s.push({k:n,v:r}),n<=o&&(s=s.concat(ae(l,t,o))),s}function ue(e){return ne(e)?[]:[...ue(e.l),{k:e.k,v:e.v},...ue(e.r)]}function de(e){return ne(e.r)?[e.k,e.v]:de(e.r)}function me(e){return ne(e.r)?e.l:pe(fe(e,{r:me(e.r)}))}function fe(e,t){return oe(void 0!==t.k?t.k:e.k,void 0!==t.v?t.v:e.v,void 0!==t.lvl?t.lvl:e.lvl,void 0!==t.l?t.l:e.l,void 0!==t.r?t.r:e.r)}function he(e){return ne(e)||e.lvl>e.r.lvl}function ge(e){return xe(Te(e))}function pe(e){const{l:t,r:o,lvl:n}=e;if(o.lvl>=n-1&&t.lvl>=n-1)return e;if(n>o.lvl+1){if(he(t))return Te(fe(e,{lvl:n-1}));if(ne(t)||ne(t.r))throw new Error("Unexpected empty nodes");return fe(t.r,{l:fe(t,{r:t.r.l}),r:fe(e,{l:t.r.r,lvl:n-1}),lvl:n})}if(he(e))return xe(fe(e,{lvl:n-1}));if(ne(o)||ne(o.l))throw new Error("Unexpected empty nodes");{const t=o.l,r=he(t)?o.lvl-1:o.lvl;return fe(t,{l:fe(e,{r:t.l,lvl:n-1}),r:xe(fe(o,{l:t.r,lvl:r})),lvl:t.lvl+1})}}function ve(e,t,o){if(ne(e))return[];const n=se(e,t)[0];return Ie(ae(e,n,o),(({k:e,v:t})=>({index:e,value:t})))}function Ie(e,t){const o=e.length;if(0===o)return[];let{index:n,value:r}=t(e[0]);const i=[];for(let l=1;l<o;l++){const{index:o,value:s}=t(e[l]);i.push({start:n,end:o-1,value:r}),n=o,r=s}return i.push({start:n,end:1/0,value:r}),i}function xe(e){const{r:t,lvl:o}=e;return ne(t)||ne(t.r)||t.lvl!==o||t.r.lvl!==o?e:fe(t,{l:fe(e,{r:t.l}),lvl:o+1})}function Te(e){const{l:t}=e;return ne(t)||t.lvl!==e.lvl?e:fe(t,{r:fe(e,{l:t.r})})}function we(e,t,o,n=0){let r=e.length-1;for(;n<=r;){const i=Math.floor((n+r)/2),l=o(e[i],t);if(0===l)return i;if(-1===l){if(r-n<2)return i-1;r=i-1}else{if(r===n)return i;n=i+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function Se(e,t,o){return e[we(e,t,o)]}const Ce=D((()=>({recalcInProgress:C(!1)})),[],{singleton:!0});function Ee(e){const{size:t,startIndex:o,endIndex:n}=e;return e=>e.start===o&&(e.end===n||e.end===1/0)&&e.value===t}function He(e,t){let o=0,n=0;for(;o<e;)o+=t[n+1]-t[n]-1,n++;return n-(o===e?0:1)}function ye({index:e},t){return t===e?0:t<e?-1:1}function be({offset:e},t){return t===e?0:t<e?-1:1}function Re(e){return{index:e.index,value:e}}function ze(e,t,o,n=0){return n>0&&(t=Math.max(t,Se(e,n,ye).offset)),Ie(function(e,t,o,n){const r=we(e,t,n),i=we(e,o,n,r);return e.slice(r,i+1)}(e,t,o,be),Re)}function Be(e,t,o,n){let r=e,i=0,l=0,s=0,c=0;if(0!==t){c=we(r,t-1,ye);s=r[c].offset;const e=se(o,t-1);i=e[0],l=e[1],r.length&&r[c].size===se(o,t)[1]&&(c-=1),r=r.slice(0,c+1)}else r=[];for(const{start:a,value:u}of ve(o,t,1/0)){const e=a-i,t=e*l+s+e*n;r.push({offset:t,size:u,index:a}),i=a,s=t,l=u}return{offsetTree:r,lastIndex:i,lastOffset:s,lastSize:l}}function ke(e,[t,o,n,r]){t.length>0&&n("received item sizes",t,$.DEBUG);const i=e.sizeTree;let l=i,s=0;if(o.length>0&&ne(i)&&2===t.length){const e=t[0].size,n=t[1].size;l=o.reduce(((t,o)=>ce(ce(t,o,e),o+1,n)),l)}else[l,s]=function(e,t){let o=ne(e)?0:1/0;for(const n of t){const{size:t,startIndex:r,endIndex:i}=n;if(o=Math.min(o,r),ne(e)){e=ce(e,0,t);continue}const l=ve(e,r-1,i+1);if(l.some(Ee(n)))continue;let s=!1,c=!1;for(const{start:o,end:n,value:a}of l)s?(i>=o||t===a)&&(e=ie(e,o)):(c=a!==t,s=!0),n>i&&i>=o&&a!==t&&(e=ce(e,i+1,a));c&&(e=ce(e,r,t))}return[e,o]}(l,t);if(l===i)return e;const{offsetTree:c,lastIndex:a,lastSize:u,lastOffset:d}=Be(e.offsetTree,s,l,r);return{sizeTree:l,offsetTree:c,lastIndex:a,lastOffset:d,lastSize:u,groupOffsetTree:o.reduce(((e,t)=>ce(e,t,Le(t,c,r))),re()),groupIndices:o}}function Le(e,t,o){if(0===t.length)return 0;const{offset:n,index:r,size:i}=Se(t,e,ye),l=e-r,s=i*l+(l-1)*o+n;return s>0?s+o:s}function Pe(e,t,o){if(function(e){return void 0!==e.groupIndex}(e))return t.groupIndices[e.groupIndex]+1;{let n=Me("LAST"===e.index?o:e.index,t);return n=Math.max(0,n,Math.min(o,n)),n}}function Me(e,t){if(!Oe(t))return e;let o=0;for(;t.groupIndices[o]<=e+o;)o++;return e+o}function Oe(e){return!ne(e.groupOffsetTree)}const Fe={offsetHeight:"height",offsetWidth:"width"},We=D((([{log:e},{recalcInProgress:t}])=>{const o=S(),n=S(),r=H(n,0),i=S(),l=S(),s=C(0),c=C([]),a=C(void 0),u=C(void 0),d=C(((e,t)=>J(e,Fe[t]))),m=C(void 0),f=C(0),h={offsetTree:[],sizeTree:re(),groupOffsetTree:re(),lastIndex:0,lastOffset:0,lastSize:0,groupIndices:[]},g=H(y(o,F(c,e,f),L(ke,h),R()),h),I=H(y(c,R(),L(((e,t)=>({prev:e.current,current:t})),{prev:[],current:[]}),B((({prev:e})=>e))),[]);T(y(c,z((e=>e.length>0)),F(g,f),B((([e,t,o])=>{const n=e.reduce(((e,n,r)=>ce(e,n,Le(n,t.offsetTree,o)||r)),re());return{...t,groupIndices:e,groupOffsetTree:n}}))),g),T(y(n,F(g),z((([e,{lastIndex:t}])=>e<t)),B((([e,{lastIndex:t,lastSize:o}])=>[{startIndex:e,endIndex:t,size:o}]))),o),T(a,u);const w=H(y(a,B((e=>void 0===e))),!0);T(y(u,z((e=>void 0!==e&&ne(x(g).sizeTree))),B((e=>[{startIndex:0,endIndex:0,size:e}]))),o);const b=E(y(o,F(g),L((({sizes:e},[t,o])=>({changed:o!==e,sizes:o})),{changed:!1,sizes:h}),B((e=>e.changed))));p(y(s,L(((e,t)=>({diff:e.prev-t,prev:t})),{diff:0,prev:0}),B((e=>e.diff))),(e=>{const{groupIndices:o}=x(g);if(e>0)v(t,!0),v(i,e+He(e,o));else if(e<0){const t=x(I);t.length>0&&(e-=He(-e,t)),v(l,e)}})),p(y(s,F(e)),(([e,t])=>{e<0&&t("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:s},$.ERROR)}));const k=E(i);T(y(i,F(g),B((([e,t])=>{const o=t.groupIndices.length>0,n=[],r=t.lastSize;if(o){const o=le(t.sizeTree,0);let i=0,l=0;for(;i<e;){const e=t.groupIndices[l],s=t.groupIndices.length===l+1?1/0:t.groupIndices[l+1]-e-1;n.push({startIndex:e,endIndex:e,size:o}),n.push({startIndex:e+1,endIndex:e+1+s-1,size:r}),l++,i+=s+1}const s=ue(t.sizeTree);return i!==e&&s.shift(),s.reduce(((t,{k:o,v:n})=>{let r=t.ranges;return 0!==t.prevSize&&(r=[...t.ranges,{startIndex:t.prevIndex,endIndex:o+e-1,size:t.prevSize}]),{ranges:r,prevIndex:o+e,prevSize:n}}),{ranges:n,prevIndex:e,prevSize:0}).ranges}return ue(t.sizeTree).reduce(((t,{k:o,v:n})=>({ranges:[...t.ranges,{startIndex:t.prevIndex,endIndex:o+e-1,size:t.prevSize}],prevIndex:o+e,prevSize:n})),{ranges:[],prevIndex:0,prevSize:r}).ranges}))),o);const P=E(y(l,F(g,f),B((([e,{offsetTree:t},o])=>Le(-e,t,o)))));return T(y(l,F(g,f),B((([e,t,o])=>{if(t.groupIndices.length>0){if(ne(t.sizeTree))return t;let n=re();const r=x(I);let i=0,l=0,s=0;for(;i<-e;){s=r[l];const e=r[l+1]-s-1;l++,i+=e+1}n=ue(t.sizeTree).reduce(((t,{k:o,v:n})=>ce(t,Math.max(0,o+e),n)),n);if(i!==-e){n=ce(n,0,le(t.sizeTree,s));n=ce(n,1,se(t.sizeTree,1-e)[1])}return{...t,sizeTree:n,...Be(t.offsetTree,0,n,o)}}{const n=ue(t.sizeTree).reduce(((t,{k:o,v:n})=>ce(t,Math.max(0,o+e),n)),re());return{...t,sizeTree:n,...Be(t.offsetTree,0,n,o)}}}))),g),{data:m,totalCount:n,sizeRanges:o,groupIndices:c,defaultItemSize:u,fixedItemSize:a,unshiftWith:i,shiftWith:l,shiftWithOffset:P,beforeUnshiftWith:k,firstItemIndex:s,gap:f,sizes:g,listRefresh:b,statefulTotalCount:r,trackItemSizes:w,itemSize:d}}),d(K,Ce),{singleton:!0}),Ve="undefined"!=typeof document&&"scrollBehavior"in document.documentElement.style;function Ae(e){const t="number"==typeof e?{index:e}:e;return t.align||(t.align="start"),t.behavior&&Ve||(t.behavior="auto"),t.offset||(t.offset=0),t}const De=D((([{sizes:e,totalCount:t,listRefresh:o,gap:n},{scrollingInProgress:r,viewportHeight:i,scrollTo:l,smoothScrollTargetReached:s,headerHeight:c,footerHeight:a,fixedHeaderHeight:u,fixedFooterHeight:d},{log:m}])=>{const f=S(),h=S(),g=C(0);let I=null,x=null,E=null;function H(){I&&(I(),I=null),E&&(E(),E=null),x&&(clearTimeout(x),x=null),v(r,!1)}return T(y(f,F(e,i,t,g,c,a,m),F(n,u,d),B((([[e,t,n,i,l,c,a,u],d,m,g])=>{const T=Ae(e),{align:S,behavior:C,offset:b}=T,R=i-1,z=Pe(T,t,R);let B=Le(z,t.offsetTree,d)+c;"end"===S?(B+=m+se(t.sizeTree,z)[1]-n+g,z===R&&(B+=a)):"center"===S?B+=(m+se(t.sizeTree,z)[1]-n+g)/2:B-=l,b&&(B+=b);const k=t=>{H(),t?(u("retrying to scroll to",{location:e},$.DEBUG),v(f,e)):(v(h,!0),u("list did not change, scroll successful",{},$.DEBUG))};if(H(),"smooth"===C){let e=!1;E=p(o,(t=>{e=e||t})),I=w(s,(()=>{k(e)}))}else I=w(y(o,(L=150,e=>{const t=setTimeout((()=>{e(!1)}),L);return o=>{o&&(e(!0),clearTimeout(t))}})),k);var L;return x=setTimeout((()=>{H()}),1200),v(r,!0),u("scrolling from index to",{index:z,top:B,behavior:C},$.DEBUG),{top:B,behavior:C}}))),l),{scrollToIndex:f,scrollTargetReached:h,topListHeight:g}}),d(We,ee,K),{singleton:!0});const Ge="up",Ne="down",_e={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollTop:0,viewportHeight:0,scrollHeight:0}},Ue=D((([{scrollContainerState:e,scrollTop:t,viewportHeight:o,headerHeight:n,footerHeight:r,scrollBy:i}])=>{const l=C(!1),s=C(!0),c=S(),a=S(),u=C(4),d=C(0),m=H(y(W(y(V(t),P(1),k(!0)),y(V(t),P(1),k(!1),O(100))),R()),!1),f=H(y(W(y(i,k(!0)),y(i,k(!1),O(200))),R()),!1);T(y(A(V(t),V(d)),B((([e,t])=>e<=t)),R()),s),T(y(s,M(50)),a);const h=E(y(A(e,V(o),V(n),V(r),V(u)),L(((e,[{scrollTop:t,scrollHeight:o},n,r,i,l])=>{const s={viewportHeight:n,scrollTop:t,scrollHeight:o};if(t+n-o>-l){let o,n;return t>e.state.scrollTop?(o="SCROLLED_DOWN",n=e.state.scrollTop-t):(o="SIZE_DECREASED",n=e.state.scrollTop-t||e.scrollTopDelta),{atBottom:!0,state:s,atBottomBecause:o,scrollTopDelta:n}}let c;return c=s.scrollHeight>e.state.scrollHeight?"SIZE_INCREASED":n<e.state.viewportHeight?"VIEWPORT_HEIGHT_DECREASING":t<e.state.scrollTop?"SCROLLING_UPWARDS":"NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:c,state:s}}),_e),R(((e,t)=>e&&e.atBottom===t.atBottom)))),g=H(y(e,L(((e,{scrollTop:t,scrollHeight:o,viewportHeight:n})=>{if(Q(e.scrollHeight,o))return{scrollTop:t,scrollHeight:o,jump:0,changed:!1};{const r=o-(t+n)<1;return e.scrollTop!==t&&r?{scrollHeight:o,scrollTop:t,jump:e.scrollTop-t,changed:!0}:{scrollHeight:o,scrollTop:t,jump:0,changed:!0}}}),{scrollHeight:0,jump:0,scrollTop:0,changed:!1}),z((e=>e.changed)),B((e=>e.jump))),0);T(y(h,B((e=>e.atBottom))),l),T(y(l,M(50)),c);const p=C(Ne);T(y(e,B((({scrollTop:e})=>e)),R(),L(((e,t)=>x(f)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?Ge:Ne,prevScrollTop:t}),{direction:Ne,prevScrollTop:0}),B((e=>e.direction))),p),T(y(e,M(50),k("none")),p);const v=C(0);return T(y(m,z((e=>!e)),k(0)),v),T(y(t,M(100),F(m),z((([e,t])=>!!t)),L((([e,t],[o])=>[t,o]),[0,0]),B((([e,t])=>t-e))),v),{isScrolling:m,isAtTop:s,isAtBottom:l,atBottomState:h,atTopStateChange:a,atBottomStateChange:c,scrollDirection:p,atBottomThreshold:u,atTopThreshold:d,scrollVelocity:v,lastJumpDueToItemResize:g}}),d(ee)),$e=D((([{log:e}])=>{const t=C(!1),o=E(y(t,z((e=>e)),R()));return p(t,(t=>{t&&x(e)("props updated",{},$.DEBUG)})),{propsReady:t,didMount:o}}),d(K),{singleton:!0});function je(e,t){0==e?t():requestAnimationFrame((()=>je(e-1,t)))}function Ke(e,t){const o=t-1;return"number"==typeof e?e:"LAST"===e.index?o:e.index}const qe=D((([{sizes:e,listRefresh:t,defaultItemSize:o},{scrollTop:n},{scrollToIndex:r,scrollTargetReached:i},{didMount:l}])=>{const s=C(!0),c=C(0),a=C(!0);return T(y(l,F(c),z((([e,t])=>!!t)),k(!1)),s),T(y(l,F(c),z((([e,t])=>!!t)),k(!1)),a),p(y(A(t,l),F(s,e,o,a),z((([[,e],t,{sizeTree:o},n,r])=>e&&(!ne(o)||h(n))&&!t&&!r)),F(c)),(([,e])=>{w(i,(()=>{v(a,!0)})),je(3,(()=>{w(n,(()=>{v(s,!0)})),v(r,e)}))})),{scrolledToInitialItem:s,initialTopMostItemIndex:c,initialItemFinalLocationReached:a}}),d(We,ee,De,$e),{singleton:!0});function Ye(e){return!!e&&("smooth"===e?"smooth":"auto")}const Ze=D((([{totalCount:e,listRefresh:t},{isAtBottom:o,atBottomState:n},{scrollToIndex:r},{scrolledToInitialItem:i},{propsReady:l,didMount:s},{log:c},{scrollingInProgress:a}])=>{const u=C(!1),d=S();let m=null;function f(e){v(r,{index:"LAST",align:"end",behavior:e})}function h(e){const t=w(n,(t=>{!e||t.atBottom||"SIZE_INCREASED"!==t.notAtBottomBecause||m||(x(c)("scrolling to bottom due to increased size",{},$.DEBUG),f("auto"))}));setTimeout(t,100)}return p(y(A(y(V(e),P(1)),s),F(V(u),o,i,a),B((([[e,t],o,n,r,i])=>{let l=t&&r,s="auto";return l&&(s=((e,t)=>"function"==typeof e?Ye(e(t)):t&&Ye(e))(o,n||i),l=l&&!!s),{totalCount:e,shouldFollow:l,followOutputBehavior:s}})),z((({shouldFollow:e})=>e))),(({totalCount:e,followOutputBehavior:o})=>{m&&(m(),m=null),m=w(t,(()=>{x(c)("following output to ",{totalCount:e},$.DEBUG),f(o),m=null}))})),p(y(A(V(u),e,l),z((([e,,t])=>e&&t)),L((({value:e},[,t])=>({refreshed:e===t,value:t})),{refreshed:!1,value:0}),z((({refreshed:e})=>e)),F(u,e)),(([,e])=>{x(i)&&h(!1!==e)})),p(d,(()=>{h(!1!==x(u))})),p(A(V(u),n),(([e,t])=>{e&&!t.atBottom&&"VIEWPORT_HEIGHT_DECREASING"===t.notAtBottomBecause&&f("auto")})),{followOutput:u,autoscrollToBottom:d}}),d(We,Ue,De,qe,$e,K,ee));function Je(e){return e.reduce(((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e)),{totalCount:0,groupIndices:[]})}const Qe=D((([{totalCount:e,groupIndices:t,sizes:o},{scrollTop:n,headerHeight:r}])=>{const i=S(),l=S(),s=E(y(i,B(Je)));return T(y(s,B((e=>e.totalCount))),e),T(y(s,B((e=>e.groupIndices))),t),T(y(A(n,o,r),z((([e,t])=>Oe(t))),B((([e,t,o])=>se(t.groupOffsetTree,Math.max(e-o,0),"v")[0])),R(),B((e=>[e]))),l),{groupCounts:i,topItemsIndexes:l}}),d(We,ee));function Xe(e,t){return!(!e||e[0]!==t[0]||e[1]!==t[1])}function et(e,t){return!(!e||e.startIndex!==t.startIndex||e.endIndex!==t.endIndex)}const tt="top",ot="bottom",nt="none";function rt(e,t,o){return"number"==typeof e?o===Ge&&t===tt||o===Ne&&t===ot?e:0:o===Ge?t===tt?e.main:e.reverse:t===ot?e.main:e.reverse}function it(e,t){return"number"==typeof e?e:e[t]||0}const lt=D((([{scrollTop:e,viewportHeight:t,deviation:o,headerHeight:n,fixedHeaderHeight:r}])=>{const i=S(),l=C(0),s=C(0),c=C(0);return{listBoundary:i,overscan:c,topListHeight:l,increaseViewportBy:s,visibleRange:H(y(A(V(e),V(t),V(n),V(i,Xe),V(c),V(l),V(r),V(o),V(s)),B((([e,t,o,[n,r],i,l,s,c,a])=>{const u=e-c,d=l+s,m=Math.max(o-u,0);let f=nt;const h=it(a,tt),g=it(a,ot);return n-=c,r+=o+s,(n+=o+s)>e+d-h&&(f=Ge),(r-=c)<e-m+t+g&&(f=Ne),f!==nt?[Math.max(u-o-rt(i,tt,f)-h,0),u-m-s+t+rt(i,ot,f)+g]:null})),z((e=>null!=e)),R(Xe)),[0,0])}}),d(ee),{singleton:!0});const st={items:[],topItems:[],offsetTop:0,offsetBottom:0,top:0,bottom:0,topListHeight:0,totalCount:0,firstItemIndex:0};function ct(e,t,o){if(0===e.length)return[];if(!Oe(t))return e.map((e=>({...e,index:e.index+o,originalIndex:e.index})));const n=e[0].index,r=e[e.length-1].index,i=[],l=ve(t.groupOffsetTree,n,r);let s,c=0;for(const a of e){let e;(!s||s.end<a.index)&&(s=l.shift(),c=t.groupIndices.indexOf(s.start)),e=a.index===s.start?{type:"group",index:c}:{index:a.index-(c+1)+o,groupIndex:c},i.push({...e,size:a.size,offset:a.offset,originalIndex:a.index,data:a.data})}return i}function at(e,t,o,n,r,i){const{lastSize:l,lastOffset:s,lastIndex:c}=r;let a=0,u=0;if(e.length>0){a=e[0].offset;const t=e[e.length-1];u=t.offset+t.size}const d=o-c,m=a,f=s+d*l+(d-1)*n-u;return{items:ct(e,r,i),topItems:ct(t,r,i),topListHeight:t.reduce(((e,t)=>t.size+e),0),offsetTop:a,offsetBottom:f,top:m,bottom:u,totalCount:o,firstItemIndex:i}}function ut(e,t,o,n,r,i){let l=0;if(o.groupIndices.length>0)for(const a of o.groupIndices){if(a-l>=e)break;l++}const s=e+l,c=Ke(t,s);return at(Array.from({length:s}).map(((e,t)=>({index:t+c,size:0,offset:0,data:i[t+c]}))),[],s,r,o,n)}const dt=D((([{sizes:e,totalCount:t,data:o,firstItemIndex:n,gap:r},i,{visibleRange:l,listBoundary:s,topListHeight:c},{scrolledToInitialItem:a,initialTopMostItemIndex:d},{topListHeight:m},f,{didMount:g},{recalcInProgress:p}])=>{const v=C([]),I=C(0),w=S();T(i.topItemsIndexes,v);const b=H(y(A(g,p,V(l,Xe),V(t),V(e),V(d),a,V(v),V(n),V(r),o),z((([e,t,,o,,,,,,,n])=>{const r=n&&n.length!==o;return e&&!t&&!r})),B((([,,[e,t],o,n,r,i,l,s,c,a])=>{const d=n,{sizeTree:m,offsetTree:f}=d,h=x(I);if(0===o)return{...st,totalCount:o};if(0===e&&0===t)return 0===h?{...st,totalCount:o}:ut(h,r,n,s,c,a||[]);if(ne(m)){if(h>0)return null;const e=at(function(e,t,o){if(Oe(t)){const n=Me(e,t);return[{index:se(t.groupOffsetTree,n)[0],size:0,offset:0},{index:n,size:0,offset:0,data:o&&o[0]}]}return[{index:e,size:0,offset:0,data:o&&o[0]}]}(Ke(r,o),d,a),[],o,c,d,s);return e}const g=[];if(l.length>0){const e=l[0],t=l[l.length-1];let o=0;for(const n of ve(m,e,t)){const r=n.value,i=Math.max(n.start,e),l=Math.min(n.end,t);for(let e=i;e<=l;e++)g.push({index:e,size:r,offset:o,data:a&&a[e]}),o+=r}}if(!i)return at([],g,o,c,d,s);const p=l.length>0?l[l.length-1]+1:0,v=ze(f,e,t,p);if(0===v.length)return null;const T=o-1;return at(u([],(o=>{for(const n of v){const r=n.value;let i=r.offset,l=n.start;const s=r.size;if(r.offset<e){l+=Math.floor((e-r.offset+c)/(s+c));const t=l-n.start;i+=t*s+t*c}l<p&&(i+=(p-l)*s,l=p);const u=Math.min(n.end,T);for(let e=l;e<=u&&!(i>=t);e++)o.push({index:e,size:s,offset:i,data:a&&a[e]}),i+=s+c}})),g,o,c,d,s)})),z((e=>null!==e)),R()),st);T(y(o,z(h),B((e=>null==e?void 0:e.length))),t),T(y(b,B((e=>e.topListHeight))),m),T(m,c),T(y(b,B((e=>[e.top,e.bottom]))),s),T(y(b,B((e=>e.items))),w);return{listState:b,topItemsIndexes:v,endReached:E(y(b,z((({items:e})=>e.length>0)),F(t,o),z((([{items:e},t])=>e[e.length-1].originalIndex===t-1)),B((([,e,t])=>[e-1,t])),R(Xe),B((([e])=>e)))),startReached:E(y(b,M(200),z((({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length)),B((({items:e})=>e[0].index)),R())),rangeChanged:E(y(b,z((({items:e})=>e.length>0)),B((({items:e})=>{let t=0,o=e.length-1;for(;"group"===e[t].type&&t<o;)t++;for(;"group"===e[o].type&&o>t;)o--;return{startIndex:e[t].index,endIndex:e[o].index}})),R(et))),itemsRendered:w,initialItemCount:I,...f}}),d(We,Qe,lt,qe,De,Ue,$e,Ce),{singleton:!0}),mt=D((([{sizes:e,firstItemIndex:t,data:o,gap:n},{initialTopMostItemIndex:r},{initialItemCount:i,listState:l},{didMount:s}])=>(T(y(s,F(i),z((([,e])=>0!==e)),F(r,e,t,n,o),B((([[,e],t,o,n,r,i=[]])=>ut(e,t,o,n,r,i)))),l),{})),d(We,qe,dt,$e),{singleton:!0}),ft=D((([{scrollVelocity:e}])=>{const t=C(!1),o=S(),n=C(!1);return T(y(e,F(n,t,o),z((([e,t])=>!!t)),B((([e,t,o,n])=>{const{exit:r,enter:i}=t;if(o){if(r(e,n))return!1}else if(i(e,n))return!0;return o})),R()),t),p(y(A(t,e,o),F(n)),(([[e,t,o],n])=>e&&n&&n.change&&n.change(t,o))),{isSeeking:t,scrollSeekConfiguration:n,scrollVelocity:e,scrollSeekRangeChanged:o}}),d(Ue),{singleton:!0}),ht=D((([{topItemsIndexes:e}])=>{const t=C(0);return T(y(t,z((e=>e>0)),B((e=>Array.from({length:e}).map(((e,t)=>t))))),e),{topItemCount:t}}),d(dt)),gt=D((([{footerHeight:e,headerHeight:t,fixedHeaderHeight:o,fixedFooterHeight:n},{listState:r}])=>{const i=S(),l=H(y(A(e,n,t,o,r),B((([e,t,o,n,r])=>e+t+o+n+r.offsetBottom+r.bottom))),0);return T(V(l),i),{totalListHeight:l,totalListHeightChanged:i}}),d(ee,dt),{singleton:!0});function pt(e){let t,o=!1;return()=>(o||(o=!0,t=e()),t)}const vt=pt((()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent))),It=D((([{scrollBy:e,scrollTop:t,deviation:o,scrollingInProgress:n},{isScrolling:r,isAtBottom:i,scrollDirection:l,lastJumpDueToItemResize:s},{listState:c},{beforeUnshiftWith:a,shiftWithOffset:u,sizes:d,gap:m},{log:f},{recalcInProgress:h}])=>{const g=E(y(c,F(s),L((([,e,t,o],[{items:n,totalCount:r,bottom:i,offsetBottom:l},s])=>{const c=i+l;let a=0;if(t===r&&e.length>0&&n.length>0){0===n[0].originalIndex&&0===e[0].originalIndex||(a=c-o,0!==a&&(a+=s))}return[a,n,r,c]}),[0,[],0,0]),z((([e])=>0!==e)),F(t,l,n,i,f,h),z((([,e,t,o,,,n])=>!n&&!o&&0!==e&&t===Ge)),B((([[e],,,,,t])=>(t("Upward scrolling compensation",{amount:e},$.DEBUG),e)))));function I(t){t>0?(v(e,{top:-t,behavior:"auto"}),v(o,0)):(v(o,0),v(e,{top:-t,behavior:"auto"}))}return p(y(g,F(o,r)),(([e,t,n])=>{n&&vt()?v(o,t-e):I(-e)})),p(y(A(H(r,!1),o,h),z((([e,t,o])=>!e&&!o&&0!==t)),B((([e,t])=>t)),M(1)),I),T(y(u,B((e=>({top:-e})))),e),p(y(a,F(d,m),B((([e,{lastSize:t,groupIndices:o,sizeTree:n},r])=>{function i(e){return e*(t+r)}if(0===o.length)return i(e);{let t=0;const r=le(n,0);let l=0,s=0;for(;l<e;){l++,t+=r;let n=o.length===s+1?1/0:o[s+1]-o[s]-1;l+n>e&&(t-=r,n=e-l+1),l+=n,t+=i(n),s++}return t}}))),(t=>{v(o,t),requestAnimationFrame((()=>{v(e,{top:t}),requestAnimationFrame((()=>{v(o,0),v(h,!1)}))}))})),{deviation:o}}),d(ee,Ue,dt,We,K,Ce)),xt=D((([{didMount:e},{scrollTo:t},{listState:o}])=>{const n=C(0);return p(y(e,F(n),z((([,e])=>0!==e)),B((([,e])=>({top:e})))),(e=>{w(y(o,P(1),z((e=>e.items.length>1))),(()=>{requestAnimationFrame((()=>{v(t,e)}))}))})),{initialScrollTop:n}}),d($e,ee,dt),{singleton:!0}),Tt=D((([{viewportHeight:e},{totalListHeight:t}])=>{const o=C(!1);return{alignToBottom:o,paddingTopAddition:H(y(A(o,e,t),z((([e])=>e)),B((([,e,t])=>Math.max(0,e-t))),M(0),R()),0)}}),d(ee,gt),{singleton:!0}),wt=D((([{scrollTo:e,scrollContainerState:t}])=>{const o=S(),n=S(),r=S(),i=C(!1),l=C(void 0);return T(y(A(o,n),B((([{viewportHeight:e,scrollTop:t,scrollHeight:o},{offsetTop:n}])=>({scrollTop:Math.max(0,t-n),scrollHeight:o,viewportHeight:e})))),t),T(y(e,F(n),B((([e,{offsetTop:t}])=>({...e,top:e.top+t})))),r),{useWindowScroll:i,customScrollParent:l,windowScrollContainerState:o,windowViewportRect:n,windowScrollTo:r}}),d(ee)),St=({itemTop:e,itemBottom:t,viewportTop:o,viewportBottom:n,locationParams:{behavior:r,align:i,...l}})=>e<o?{...l,behavior:r,align:null!=i?i:"start"}:t>n?{...l,behavior:r,align:null!=i?i:"end"}:null,Ct=D((([{sizes:e,totalCount:t,gap:o},{scrollTop:n,viewportHeight:r,headerHeight:i,fixedHeaderHeight:l,fixedFooterHeight:s,scrollingInProgress:c},{scrollToIndex:a}])=>{const u=S();return T(y(u,F(e,r,t,i,l,s,n),F(o),B((([[e,t,o,n,r,i,l,s],a])=>{const{done:u,behavior:d,align:m,calculateViewLocation:f=St,...h}=e,g=Pe(e,t,n-1),p=Le(g,t.offsetTree,a)+r+i,v=f({itemTop:p,itemBottom:p+se(t.sizeTree,g)[1],viewportTop:s+i,viewportBottom:s+o-l,locationParams:{behavior:d,align:m,...h}});return v?u&&w(y(c,z((e=>!1===e)),P(x(c)?1:2)),u):u&&u(),v})),z((e=>null!==e))),a),{scrollIntoView:u}}),d(We,ee,De,dt,K),{singleton:!0}),Et=D((([{sizes:e,sizeRanges:t},{scrollTop:o},{initialTopMostItemIndex:n},{didMount:r},{useWindowScroll:i,windowScrollContainerState:l,windowViewportRect:s}])=>{const c=S(),a=C(void 0),u=C(null),d=C(null);return T(l,u),T(s,d),p(y(c,F(e,o,i,u,d)),(([e,t,o,n,r,i])=>{const l=ue(t.sizeTree).map((({k:e,v:t},o,n)=>{const r=n[o+1];return{startIndex:e,endIndex:r?r.k-1:1/0,size:t}}));n&&null!==r&&null!==i&&(o=r.scrollTop-i.offsetTop),e({ranges:l,scrollTop:o})})),T(y(a,z(h),B(Ht)),n),T(y(r,F(a),z((([,e])=>void 0!==e)),R(),B((([,e])=>e.ranges))),t),{getState:c,restoreStateFrom:a}}),d(We,ee,qe,$e,wt));function Ht(e){return{offset:e.scrollTop,index:0,align:"start"}}const yt=D((([e,t,o,n,r,i,l,s,c,a])=>({...e,...t,...o,...n,...r,...i,...l,...s,...c,...a})),d(lt,mt,$e,ft,gt,xt,Tt,wt,Ct,K)),bt=D((([{totalCount:e,sizeRanges:t,fixedItemSize:o,defaultItemSize:n,trackItemSizes:r,itemSize:i,data:l,firstItemIndex:s,groupIndices:c,statefulTotalCount:a,gap:u,sizes:d},{initialTopMostItemIndex:m,scrolledToInitialItem:f,initialItemFinalLocationReached:h},g,p,v,{listState:I,topItemsIndexes:x,...w},{scrollToIndex:S},C,{topItemCount:E},{groupCounts:H},b])=>(T(w.rangeChanged,b.scrollSeekRangeChanged),T(y(b.windowViewportRect,B((e=>e.visibleHeight))),g.viewportHeight),{totalCount:e,data:l,firstItemIndex:s,sizeRanges:t,initialTopMostItemIndex:m,scrolledToInitialItem:f,initialItemFinalLocationReached:h,topItemsIndexes:x,topItemCount:E,groupCounts:H,fixedItemHeight:o,defaultItemHeight:n,gap:u,...v,statefulTotalCount:a,listState:I,scrollToIndex:S,trackItemSizes:r,itemSize:i,groupIndices:c,...w,...b,...g,sizes:d,...p})),d(We,qe,ee,Et,Ze,dt,De,It,ht,Qe,yt)),Rt="-webkit-sticky",zt="sticky",Bt=pt((()=>{if("undefined"==typeof document)return zt;const e=document.createElement("div");return e.style.position=Rt,e.style.position===Rt?Rt:zt}));function kt(t,o){const n=e.useRef(null),r=e.useCallback((e=>{if(null===e||!e.offsetParent)return;const r=e.getBoundingClientRect(),i=r.width;let l,s;if(o){const e=o.getBoundingClientRect(),t=r.top-e.top;l=e.height-Math.max(0,t),s=t+o.scrollTop}else l=window.innerHeight-Math.max(0,r.top),s=r.top+window.pageYOffset;n.current={offsetTop:s,visibleHeight:l,visibleWidth:i},t(n.current)}),[t,o]),{callbackRef:i,ref:l}=q(r),s=e.useCallback((()=>{r(l.current)}),[r,l]);return e.useEffect((()=>{if(o){o.addEventListener("scroll",s);const e=new ResizeObserver(s);return e.observe(o),()=>{o.removeEventListener("scroll",s),e.unobserve(o)}}return window.addEventListener("scroll",s),window.addEventListener("resize",s),()=>{window.removeEventListener("scroll",s),window.removeEventListener("resize",s)}}),[s,o]),i}const Lt=e.createContext(void 0),Pt=e.createContext(void 0);function Mt(e){return e}const Ot=D((([e,t])=>({...e,...t})),d(bt,D((()=>{const e=C((e=>`Item ${e}`)),t=C(null),o=C((e=>`Group ${e}`)),n=C({}),r=C(Mt),i=C("div"),l=C(g),s=(e,t=null)=>H(y(n,B((t=>t[e])),R()),t);return{context:t,itemContent:e,groupContent:o,components:n,computeItemKey:r,headerFooterTag:i,scrollerRef:l,FooterComponent:s("Footer"),HeaderComponent:s("Header"),TopItemListComponent:s("TopItemList"),ListComponent:s("List","div"),ItemComponent:s("Item","div"),GroupComponent:s("Group","div"),ScrollerComponent:s("Scroller","div"),EmptyPlaceholder:s("EmptyPlaceholder"),ScrollSeekPlaceholder:s("ScrollSeekPlaceholder")}})))),Ft=({height:t})=>e.createElement("div",{style:{height:t}}),Wt={position:Bt(),zIndex:1,overflowAnchor:"none"},Vt={overflowAnchor:"none"},At=e.memo((function({showTopList:t=!1}){const o=to("listState"),n=eo("sizeRanges"),r=to("useWindowScroll"),i=to("customScrollParent"),l=eo("windowScrollContainerState"),s=eo("scrollContainerState"),c=i||r?l:s,a=to("itemContent"),u=to("context"),d=to("groupContent"),m=to("trackItemSizes"),f=to("itemSize"),h=to("log"),p=eo("gap"),{callbackRef:v}=Z(n,f,m,t?g:c,h,p,i),[I,x]=e.useState(0);oo("deviation",(e=>{I!==e&&x(e)}));const T=to("EmptyPlaceholder"),w=to("ScrollSeekPlaceholder")||Ft,S=to("ListComponent"),C=to("ItemComponent"),E=to("GroupComponent"),H=to("computeItemKey"),y=to("isSeeking"),b=to("groupIndices").length>0,R=to("alignToBottom"),z=to("initialItemFinalLocationReached"),B=t?{}:{boxSizing:"border-box",paddingTop:o.offsetTop,paddingBottom:o.offsetBottom,marginTop:0!==I?I:R?"auto":0,...z?{}:{visibility:"hidden"}};return!t&&0===o.totalCount&&T?e.createElement(T,_t(T,u)):e.createElement(S,{..._t(S,u),ref:v,style:B,"data-test-id":t?"virtuoso-top-item-list":"virtuoso-item-list"},(t?o.topItems:o.items).map((t=>{const n=t.originalIndex,r=H(n+o.firstItemIndex,t.data,u);return y?e.createElement(w,{..._t(w,u),key:r,index:t.index,height:t.size,type:t.type||"item",..."group"===t.type?{}:{groupIndex:t.groupIndex}}):"group"===t.type?e.createElement(E,{..._t(E,u),key:r,"data-index":n,"data-known-size":t.size,"data-item-index":t.index,style:Wt},d(t.index,u)):e.createElement(C,{..._t(C,u),...Ut(C,t.data),key:r,"data-index":n,"data-known-size":t.size,"data-item-index":t.index,"data-item-group-index":t.groupIndex,style:Vt},b?a(t.index,t.groupIndex,t.data,u):a(t.index,t.data,u))})))})),Dt={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Gt=e=>({width:"100%",height:"100%",position:"absolute",top:0,...e?{display:"flex",flexDirection:"column"}:{}}),Nt={width:"100%",position:Bt(),top:0,zIndex:1};function _t(e,t){if("string"!=typeof e)return{context:t}}function Ut(e,t){return{item:"string"==typeof e?void 0:t}}const $t=e.memo((function(){const t=to("HeaderComponent"),o=eo("headerHeight"),n=to("headerFooterTag"),r=Y((e=>o(J(e,"height")))),i=to("context");return t?e.createElement(n,{ref:r},e.createElement(t,_t(t,i))):null})),jt=e.memo((function(){const t=to("FooterComponent"),o=eo("footerHeight"),n=to("headerFooterTag"),r=Y((e=>o(J(e,"height")))),i=to("context");return t?e.createElement(n,{ref:r},e.createElement(t,_t(t,i))):null}));function Kt({usePublisher:t,useEmitter:o,useEmitterValue:n}){return e.memo((function({style:r,children:i,...l}){const s=t("scrollContainerState"),c=n("ScrollerComponent"),a=t("smoothScrollTargetReached"),u=n("scrollerRef"),d=n("context"),{scrollerRef:m,scrollByCallback:f,scrollToCallback:h}=X(s,a,c,u);return o("scrollTo",h),o("scrollBy",f),e.createElement(c,{ref:m,style:{...Dt,...r},"data-test-id":"virtuoso-scroller","data-virtuoso-scroller":!0,tabIndex:0,...l,..._t(c,d)},i)}))}function qt({usePublisher:t,useEmitter:o,useEmitterValue:n}){return e.memo((function({style:r,children:i,...l}){const s=t("windowScrollContainerState"),c=n("ScrollerComponent"),a=t("smoothScrollTargetReached"),u=n("totalListHeight"),d=n("deviation"),m=n("customScrollParent"),f=n("context"),{scrollerRef:h,scrollByCallback:p,scrollToCallback:v}=X(s,a,c,g,m);return U((()=>(h.current=m||window,()=>{h.current=null})),[h,m]),o("windowScrollTo",v),o("scrollBy",p),e.createElement(c,{style:{position:"relative",...r,...0!==u?{height:u+d}:{}},"data-virtuoso-scroller":!0,...l,..._t(c,f)},i)}))}const Yt=({children:t})=>{const o=e.useContext(Lt),n=eo("viewportHeight"),r=eo("fixedItemHeight"),i=to("alignToBottom"),s=Y(l(n,(e=>J(e,"height"))));return e.useEffect((()=>{o&&(n(o.viewportHeight),r(o.itemHeight))}),[o,n,r]),e.createElement("div",{style:Gt(i),ref:s,"data-viewport-type":"element"},t)},Zt=({children:t})=>{const o=e.useContext(Lt),n=eo("windowViewportRect"),r=eo("fixedItemHeight"),i=to("customScrollParent"),l=kt(n,i),s=to("alignToBottom");return e.useEffect((()=>{o&&(r(o.itemHeight),n({offsetTop:0,visibleHeight:o.viewportHeight,visibleWidth:100}))}),[o,n,r]),e.createElement("div",{ref:l,style:Gt(s),"data-viewport-type":"window"},t)},Jt=({children:t})=>{const o=to("TopItemListComponent")||"div",n=to("headerHeight"),r={...Nt,marginTop:`${n}px`},i=to("context");return e.createElement(o,{style:r,..._t(o,i)},t)},Qt=e.memo((function(t){const o=to("useWindowScroll"),n=to("topItemsIndexes").length>0,r=to("customScrollParent"),i=r||o?ro:no,l=r||o?Zt:Yt;return e.createElement(i,{...t},n&&e.createElement(Jt,null,e.createElement(At,{showTopList:!0})),e.createElement(l,null,e.createElement($t,null),e.createElement(At,null),e.createElement(jt,null)))})),{Component:Xt,usePublisher:eo,useEmitterValue:to,useEmitter:oo}=_(Ot,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Qt),no=Kt({usePublisher:eo,useEmitterValue:to,useEmitter:oo}),ro=qt({usePublisher:eo,useEmitterValue:to,useEmitter:oo}),io=Xt,lo=Xt,so={items:[],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},co={items:[{index:0}],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},{round:ao,ceil:uo,floor:mo,min:fo,max:ho}=Math;function go(e,t,o){return Array.from({length:t-e+1}).map(((t,n)=>{const r=null===o?null:o[n+e];return{index:n+e,data:r}}))}function po(e,t){return e&&e.column===t.column&&e.row===t.row}function vo(e,t){return e&&e.width===t.width&&e.height===t.height}const Io=D((([{overscan:e,visibleRange:t,listBoundary:o},{scrollTop:n,viewportHeight:r,scrollBy:i,scrollTo:l,smoothScrollTargetReached:s,scrollContainerState:c,footerHeight:a,headerHeight:u},d,m,{propsReady:f,didMount:h},{windowViewportRect:g,useWindowScroll:I,customScrollParent:x,windowScrollContainerState:b,windowScrollTo:L},O])=>{const W=C(0),D=C(0),G=C(so),N=C({height:0,width:0}),_=C({height:0,width:0}),U=S(),$=S(),j=C(0),K=C(null),q=C({row:0,column:0}),Y=S(),Z=S(),J=C(!1),Q=C(0),X=C(!0),ee=C(!1);p(y(h,F(Q),z((([e,t])=>!!t))),(()=>{v(X,!1),v(D,0)})),p(y(A(h,X,_,N,Q,ee),z((([e,t,o,n,,r])=>e&&!t&&0!==o.height&&0!==n.height&&!r))),(([,,,,e])=>{v(ee,!0),je(1,(()=>{v(U,e)})),w(y(n),(()=>{v(o,[0,0]),v(X,!0)}))})),T(y(Z,z((e=>null!=e&&e.scrollTop>0)),k(0)),D),p(y(h,F(Z),z((([,e])=>null!=e))),(([,e])=>{e&&(v(N,e.viewport),v(_,null==e?void 0:e.item),v(q,e.gap),e.scrollTop>0&&(v(J,!0),w(y(n,P(1)),(e=>{v(J,!1)})),v(l,{top:e.scrollTop})))})),T(y(N,B((({height:e})=>e))),r),T(y(A(V(N,vo),V(_,vo),V(q,((e,t)=>e&&e.column===t.column&&e.row===t.row)),V(n)),B((([e,t,o,n])=>({viewport:e,item:t,gap:o,scrollTop:n})))),Y),T(y(A(V(W),t,V(q,po),V(_,vo),V(N,vo),V(K),V(D),V(J),V(X),V(Q)),z((([,,,,,,,e])=>!e)),B((([e,[t,o],n,r,i,l,s,,c,a])=>{const{row:u,column:d}=n,{height:m,width:f}=r,{width:h}=i;if(0===s&&(0===e||0===h))return so;if(0===f){const t=Ke(a,e);return function(e){return{...co,items:e}}(go(t,0===t?Math.max(s-1,0):t,l))}const g=wo(h,f,d);let p,v;c?0===t&&0===o&&s>0?(p=0,v=s-1):(p=g*mo((t+u)/(m+u)),v=g*uo((o+u)/(m+u))-1,v=fo(e-1,ho(v,g-1)),p=fo(v,ho(0,p))):(p=0,v=-1);const I=go(p,v,l),{top:x,bottom:T}=xo(i,n,r,I),w=uo(e/g);return{items:I,offsetTop:x,offsetBottom:w*m+(w-1)*u-T,top:x,bottom:T,itemHeight:m,itemWidth:f}}))),G),T(y(K,z((e=>null!==e)),B((e=>e.length))),W),T(y(A(N,_,G,q),z((([e,t,{items:o}])=>o.length>0&&0!==t.height&&0!==e.height)),B((([e,t,{items:o},n])=>{const{top:r,bottom:i}=xo(e,n,t,o);return[r,i]})),R(Xe)),o);const te=C(!1);T(y(n,F(te),B((([e,t])=>t||0!==e))),te);const oe=E(y(V(G),z((({items:e})=>e.length>0)),F(W,te),z((([{items:e},t,o])=>o&&e[e.length-1].index===t-1)),B((([,e])=>e-1)),R())),ne=E(y(V(G),z((({items:e})=>e.length>0&&0===e[0].index)),k(0),R())),re=E(y(V(G),F(J),z((([{items:e},t])=>e.length>0&&!t)),B((([{items:e}])=>({startIndex:e[0].index,endIndex:e[e.length-1].index}))),R(et),M(0)));T(re,m.scrollSeekRangeChanged),T(y(U,F(N,_,W,q),B((([e,t,o,n,r])=>{const i=Ae(e),{align:l,behavior:s,offset:c}=i;let a=i.index;"LAST"===a&&(a=n-1),a=ho(0,a,fo(n-1,a));let u=To(t,r,o,a);return"end"===l?u=ao(u-t.height+o.height):"center"===l&&(u=ao(u-t.height/2+o.height/2)),c&&(u+=c),{top:u,behavior:s}}))),l);const ie=H(y(G,B((e=>e.offsetBottom+e.bottom))),0);return T(y(g,B((e=>({width:e.visibleWidth,height:e.visibleHeight})))),N),{data:K,totalCount:W,viewportDimensions:N,itemDimensions:_,scrollTop:n,scrollHeight:$,overscan:e,scrollBy:i,scrollTo:l,scrollToIndex:U,smoothScrollTargetReached:s,windowViewportRect:g,windowScrollTo:L,useWindowScroll:I,customScrollParent:x,windowScrollContainerState:b,deviation:j,scrollContainerState:c,footerHeight:a,headerHeight:u,initialItemCount:D,gap:q,restoreStateFrom:Z,...m,initialTopMostItemIndex:Q,gridState:G,totalListHeight:ie,...d,startReached:ne,endReached:oe,rangeChanged:re,stateChanged:Y,propsReady:f,stateRestoreInProgress:J,...O}}),d(lt,ee,Ue,ft,$e,wt,K));function xo(e,t,o,n){const{height:r}=o;if(void 0===r||0===n.length)return{top:0,bottom:0};return{top:To(e,t,o,n[0].index),bottom:To(e,t,o,n[n.length-1].index)+r}}function To(e,t,o,n){const r=wo(e.width,o.width,t.column),i=mo(n/r),l=i*o.height+ho(0,i-1)*t.row;return l>0?l+t.row:l}function wo(e,t,o){return ho(1,mo((e+o)/(mo(t)+o)))}const So=D((([e,t])=>({...e,...t})),d(Io,D((()=>{const e=C((e=>`Item ${e}`)),t=C({}),o=C(null),n=C("virtuoso-grid-item"),r=C("virtuoso-grid-list"),i=C(Mt),l=C("div"),s=C(g),c=(e,o=null)=>H(y(t,B((t=>t[e])),R()),o);return{context:o,itemContent:e,components:t,computeItemKey:i,itemClassName:n,listClassName:r,headerFooterTag:l,scrollerRef:s,FooterComponent:c("Footer"),HeaderComponent:c("Header"),ListComponent:c("List","div"),ItemComponent:c("Item","div"),ScrollerComponent:c("Scroller","div"),ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}})))),Co=e.memo((function(){const t=ko("gridState"),o=ko("listClassName"),n=ko("itemClassName"),r=ko("itemContent"),i=ko("computeItemKey"),l=ko("isSeeking"),s=Bo("scrollHeight"),c=ko("ItemComponent"),a=ko("ListComponent"),u=ko("ScrollSeekPlaceholder"),d=ko("context"),m=Bo("itemDimensions"),f=Bo("gap"),h=ko("log"),g=ko("stateRestoreInProgress"),p=Y((e=>{const t=e.parentElement.parentElement.scrollHeight;s(t);const o=e.firstChild;if(o){const{width:e,height:t}=o.getBoundingClientRect();m({width:e,height:t})}f({row:Oo("row-gap",getComputedStyle(e).rowGap,h),column:Oo("column-gap",getComputedStyle(e).columnGap,h)})}));return g?null:e.createElement(a,{ref:p,className:o,..._t(a,d),style:{paddingTop:t.offsetTop,paddingBottom:t.offsetBottom},"data-test-id":"virtuoso-item-list"},t.items.map((o=>{const s=i(o.index,o.data,d);return l?e.createElement(u,{key:s,..._t(u,d),index:o.index,height:t.itemHeight,width:t.itemWidth}):e.createElement(c,{..._t(c,d),className:n,"data-index":o.index,key:s},r(o.index,o.data,d))})))})),Eo=e.memo((function(){const t=ko("HeaderComponent"),o=Bo("headerHeight"),n=ko("headerFooterTag"),r=Y((e=>o(J(e,"height")))),i=ko("context");return t?e.createElement(n,{ref:r},e.createElement(t,_t(t,i))):null})),Ho=e.memo((function(){const t=ko("FooterComponent"),o=Bo("footerHeight"),n=ko("headerFooterTag"),r=Y((e=>o(J(e,"height")))),i=ko("context");return t?e.createElement(n,{ref:r},e.createElement(t,_t(t,i))):null})),yo=({children:t})=>{const o=e.useContext(Pt),n=Bo("itemDimensions"),r=Bo("viewportDimensions"),i=Y((e=>{r(e.getBoundingClientRect())}));return e.useEffect((()=>{o&&(r({height:o.viewportHeight,width:o.viewportWidth}),n({height:o.itemHeight,width:o.itemWidth}))}),[o,r,n]),e.createElement("div",{style:Gt(!1),ref:i},t)},bo=({children:t})=>{const o=e.useContext(Pt),n=Bo("windowViewportRect"),r=Bo("itemDimensions"),i=ko("customScrollParent"),l=kt(n,i);return e.useEffect((()=>{o&&(r({height:o.itemHeight,width:o.itemWidth}),n({offsetTop:0,visibleHeight:o.viewportHeight,visibleWidth:o.viewportWidth}))}),[o,n,r]),e.createElement("div",{ref:l,style:Gt(!1)},t)},Ro=e.memo((function({...t}){const o=ko("useWindowScroll"),n=ko("customScrollParent"),r=n||o?Mo:Po,i=n||o?bo:yo;return e.createElement(r,{...t},e.createElement(i,null,e.createElement(Eo,null),e.createElement(Co,null),e.createElement(Ho,null)))})),{Component:zo,usePublisher:Bo,useEmitterValue:ko,useEmitter:Lo}=_(So,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged"}},Ro),Po=Kt({usePublisher:Bo,useEmitterValue:ko,useEmitter:Lo}),Mo=qt({usePublisher:Bo,useEmitterValue:ko,useEmitter:Lo});function Oo(e,t,o){return"normal"===t||(null==t?void 0:t.endsWith("px"))||o(`${e} was not resolved to pixel value correctly`,t,$.WARN),"normal"===t?0:parseInt(null!=t?t:"0",10)}const Fo=zo,Wo=D((([e,t])=>({...e,...t})),d(bt,D((()=>{const t=C((t=>e.createElement("td",null,"Item $",t))),o=C(null),n=C(null),r=C(null),i=C({}),l=C(Mt),s=C(g),c=(e,t=null)=>H(y(i,B((t=>t[e])),R()),t);return{context:o,itemContent:t,fixedHeaderContent:n,fixedFooterContent:r,components:i,computeItemKey:l,scrollerRef:s,TableComponent:c("Table","table"),TableHeadComponent:c("TableHead","thead"),TableFooterComponent:c("TableFoot","tfoot"),TableBodyComponent:c("TableBody","tbody"),TableRowComponent:c("TableRow","tr"),ScrollerComponent:c("Scroller","div"),EmptyPlaceholder:c("EmptyPlaceholder"),ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),FillerRow:c("FillerRow")}})))),Vo=({height:t})=>e.createElement("tr",null,e.createElement("td",{style:{height:t}})),Ao=({height:t})=>e.createElement("tr",null,e.createElement("td",{style:{height:t,padding:0,border:0}})),Do={overflowAnchor:"none"},Go=e.memo((function(){const t=Ko("listState"),o=jo("sizeRanges"),n=Ko("useWindowScroll"),r=Ko("customScrollParent"),i=jo("windowScrollContainerState"),l=jo("scrollContainerState"),s=r||n?i:l,c=Ko("itemContent"),a=Ko("trackItemSizes"),u=Ko("itemSize"),d=Ko("log"),{callbackRef:m,ref:f}=Z(o,u,a,s,d,void 0,r),[h,g]=e.useState(0);qo("deviation",(e=>{h!==e&&(f.current.style.marginTop=`${e}px`,g(e))}));const p=Ko("EmptyPlaceholder"),v=Ko("ScrollSeekPlaceholder")||Vo,I=Ko("FillerRow")||Ao,x=Ko("TableBodyComponent"),T=Ko("TableRowComponent"),w=Ko("computeItemKey"),S=Ko("isSeeking"),C=Ko("paddingTopAddition"),E=Ko("firstItemIndex"),H=Ko("statefulTotalCount"),y=Ko("context");if(0===H&&p)return e.createElement(p,_t(p,y));const b=t.offsetTop+C+h,R=t.offsetBottom,z=b>0?e.createElement(I,{height:b,key:"padding-top",context:y}):null,B=R>0?e.createElement(I,{height:R,key:"padding-bottom",context:y}):null,k=t.items.map((t=>{const o=t.originalIndex,n=w(o+E,t.data,y);return S?e.createElement(v,{..._t(v,y),key:n,index:t.index,height:t.size,type:t.type||"item"}):e.createElement(T,{..._t(T,y),...Ut(T,t.data),key:n,"data-index":o,"data-known-size":t.size,"data-item-index":t.index,style:Do},c(t.index,t.data,y))}));return e.createElement(x,{ref:m,"data-test-id":"virtuoso-item-list",..._t(x,y)},[z,...k,B])})),No=({children:t})=>{const o=e.useContext(Lt),n=jo("viewportHeight"),r=jo("fixedItemHeight"),i=Y(l(n,(e=>J(e,"height"))));return e.useEffect((()=>{o&&(n(o.viewportHeight),r(o.itemHeight))}),[o,n,r]),e.createElement("div",{style:Gt(!1),ref:i,"data-viewport-type":"element"},t)},_o=({children:t})=>{const o=e.useContext(Lt),n=jo("windowViewportRect"),r=jo("fixedItemHeight"),i=Ko("customScrollParent"),l=kt(n,i);return e.useEffect((()=>{o&&(r(o.itemHeight),n({offsetTop:0,visibleHeight:o.viewportHeight,visibleWidth:100}))}),[o,n,r]),e.createElement("div",{ref:l,style:Gt(!1),"data-viewport-type":"window"},t)},Uo=e.memo((function(t){const o=Ko("useWindowScroll"),n=Ko("customScrollParent"),r=jo("fixedHeaderHeight"),i=jo("fixedFooterHeight"),s=Ko("fixedHeaderContent"),c=Ko("fixedFooterContent"),a=Ko("context"),u=Y(l(r,(e=>J(e,"height")))),d=Y(l(i,(e=>J(e,"height")))),m=n||o?Zo:Yo,f=n||o?_o:No,h=Ko("TableComponent"),g=Ko("TableHeadComponent"),p=Ko("TableFooterComponent"),v=s?e.createElement(g,{key:"TableHead",style:{zIndex:2,position:"sticky",top:0},ref:u,..._t(g,a)},s()):null,I=c?e.createElement(p,{key:"TableFoot",style:{zIndex:1,position:"sticky",bottom:0},ref:d,..._t(p,a)},c()):null;return e.createElement(m,{...t},e.createElement(f,null,e.createElement(h,{style:{borderSpacing:0,overflowAnchor:"none"},..._t(h,a)},[v,e.createElement(Go,{key:"TableBody"}),I])))})),{Component:$o,usePublisher:jo,useEmitterValue:Ko,useEmitter:qo}=_(Wo,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",firstItemIndex:"firstItemIndex",itemContent:"itemContent",fixedHeaderContent:"fixedHeaderContent",fixedFooterContent:"fixedFooterContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",topItemCount:"topItemCount",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",groupCounts:"groupCounts",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Uo),Yo=Kt({usePublisher:jo,useEmitterValue:Ko,useEmitter:qo}),Zo=qt({usePublisher:jo,useEmitterValue:Ko,useEmitter:qo}),Jo=$o;exports.GroupedVirtuoso=lo,exports.LogLevel=$,exports.TableVirtuoso=Jo,exports.Virtuoso=io,exports.VirtuosoGrid=Fo,exports.VirtuosoGridMockContext=Pt,exports.VirtuosoMockContext=Lt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("react-dom"),o=0,n=1,r=2,i=4;function l(e,t){return o=>e(t(o))}function s(e,t){return t(e)}function c(e,t){return o=>e(t,o)}function a(e,t){return()=>e(t)}function u(e,t){return t(e),e}function d(...e){return e}function m(e){e()}function f(e){return()=>e}function h(e){return void 0!==e}function g(){}function p(e,t){return e(n,t)}function v(e,t){e(o,t)}function I(e){e(r)}function x(e){return e(i)}function T(e,t){return p(e,c(t,o))}function w(e,t){const o=e(n,(e=>{o(),t(e)}));return o}function S(){const e=[];return(t,i)=>{switch(t){case r:return void e.splice(0,e.length);case n:return e.push(i),()=>{const t=e.indexOf(i);t>-1&&e.splice(t,1)};case o:return void e.slice().forEach((e=>{e(i)}));default:throw new Error(`unrecognized action ${t}`)}}}function C(e){let t=e;const r=S();return(e,l)=>{switch(e){case n:l(t);break;case o:t=l;break;case i:return t}return r(e,l)}}function E(e){return u(S(),(t=>T(e,t)))}function H(e,t){return u(C(t),(t=>T(e,t)))}function y(e,...t){const o=function(...e){return t=>e.reduceRight(s,t)}(...t);return(t,i)=>{switch(t){case n:return p(e,o(i));case r:return void I(e)}}}function b(e,t){return e===t}function z(e=b){let t;return o=>n=>{e(t,n)||(t=n,o(n))}}function R(e){return t=>o=>{e(o)&&t(o)}}function k(e){return t=>l(t,e)}function B(e){return t=>()=>t(e)}function L(e,t){return o=>n=>o(t=e(t,n))}function O(e){return t=>o=>{e>0?e--:t(o)}}function F(e){let t,o=null;return n=>r=>{o=r,t||(t=setTimeout((()=>{t=void 0,n(o)}),e))}}function M(e){let t,o;return n=>r=>{t=r,o&&clearTimeout(o),o=setTimeout((()=>{n(t)}),e)}}function P(...e){const t=new Array(e.length);let o=0,n=null;const r=Math.pow(2,e.length)-1;return e.forEach(((e,i)=>{const l=Math.pow(2,i);p(e,(e=>{const s=o;o|=l,t[i]=e,s!==r&&o===r&&n&&(n(),n=null)}))})),e=>i=>{const l=()=>e([i].concat(t));o===r?l():n=l}}function W(...e){return function(t,o){switch(t){case n:return function(...e){return()=>{e.map(m)}}(...e.map((e=>p(e,o))));case r:return;default:throw new Error(`unrecognized action ${t}`)}}}function A(e,t=b){return y(e,z(t))}function V(...e){const t=S(),o=new Array(e.length);let i=0;const l=Math.pow(2,e.length)-1;return e.forEach(((e,n)=>{const r=Math.pow(2,n);p(e,(e=>{o[n]=e,i|=r,i===l&&v(t,o)}))})),function(e,s){switch(e){case n:return i===l&&s(o),p(t,s);case r:return I(t);default:throw new Error(`unrecognized action ${e}`)}}}function D(e,t=[],{singleton:o}={singleton:!0}){return{id:G(),constructor:e,dependencies:t,singleton:o}}const G=()=>Symbol();const N="undefined"!=typeof document?e.useLayoutEffect:e.useEffect;function _(t,o,i){const l=Object.keys(o.required||{}),s=Object.keys(o.optional||{}),d=Object.keys(o.methods||{}),m=Object.keys(o.events||{}),h=e.createContext({});function T(e,t){e.propsReady&&v(e.propsReady,!1);for(const n of l){v(e[o.required[n]],t[n])}for(const n of s)if(n in t){v(e[o.optional[n]],t[n])}e.propsReady&&v(e.propsReady,!0)}function w(e){return m.reduce(((t,i)=>(t[i]=function(e){let t,o;const i=()=>t&&t();return function(l,s){switch(l){case n:if(s){if(o===s)return;return i(),o=s,t=p(e,s),t}return i(),g;case r:return i(),void(o=null);default:throw new Error(`unrecognized action ${l}`)}}}(e[o.events[i]]),t)),{})}const S=e.forwardRef(((n,r)=>{const{children:c,...g}=n,[x]=e.useState((()=>u(function(e){const t=new Map,o=({id:e,constructor:n,dependencies:r,singleton:i})=>{if(i&&t.has(e))return t.get(e);const l=n(r.map((e=>o(e))));return i&&t.set(e,l),l};return o(e)}(t),(e=>T(e,g))))),[S]=e.useState(a(w,x));return N((()=>{for(const e of m)e in g&&p(S[e],g[e]);return()=>{Object.values(S).map(I)}}),[g,S,x]),N((()=>{T(x,g)})),e.useImperativeHandle(r,f(function(e){return d.reduce(((t,n)=>(t[n]=t=>{v(e[o.methods[n]],t)},t)),{})}(x))),e.createElement(h.Provider,{value:x},i?e.createElement(i,function(e,t){const o={},n={};let r=0;const i=e.length;for(;r<i;)n[e[r]]=1,r+=1;for(const l in t)n.hasOwnProperty(l)||(o[l]=t[l]);return o}([...l,...s,...m],g),c):c)}));return{Component:S,usePublisher:t=>e.useCallback(c(v,e.useContext(h)[t]),[t]),useEmitterValue:e.version.startsWith("18")?t=>{const o=e.useContext(h)[t],n=e.useCallback((e=>p(o,e)),[o]);return e.useSyncExternalStore(n,(()=>x(o)),(()=>x(o)))}:t=>{const o=e.useContext(h)[t],[n,r]=e.useState(a(x,o));return N((()=>p(o,(e=>{e!==n&&r(f(e))}))),[o,n]),n},useEmitter:(t,o)=>{const n=e.useContext(h)[t];N((()=>p(n,o)),[o,n])}}}const U="undefined"!=typeof document?e.useLayoutEffect:e.useEffect;var $=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))($||{});const j={0:"debug",1:"log",2:"warn",3:"error"},K=D((()=>{const e=C(3);return{log:C(((t,o,n=1)=>{var r;n>=(null!=(r=("undefined"==typeof globalThis?window:globalThis).VIRTUOSO_LOG_LEVEL)?r:x(e))&&console[j[n]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,o)})),logLevel:e}}),[],{singleton:!0});function q(t,o,n){const r=e.useRef(null);let i=e=>{};if("undefined"!=typeof ResizeObserver){const l=e.useMemo((()=>new ResizeObserver((e=>{const o=()=>{const o=e[0].target;null!==o.offsetParent&&t(o)};n?o():requestAnimationFrame(o)}))),[t]);i=e=>{e&&o?(l.observe(e),r.current=e):(r.current&&l.unobserve(r.current),r.current=null)}}return{ref:r,callbackRef:i}}function Y(e,t,o){return q(e,t,o).callbackRef}function Z(t,o,n,r,i,l,s,c,a){const u=e.useCallback((e=>{const n=function(e,t,o,n){const r=e.length;if(0===r)return null;const i=[];for(let l=0;l<r;l++){const r=e.item(l);if(!r||void 0===r.dataset.index)continue;const s=parseInt(r.dataset.index),c=parseFloat(r.dataset.knownSize),a=t(r,o);if(0===a&&n("Zero-sized element, this should not happen",{child:r},$.ERROR),a===c)continue;const u=i[i.length-1];0===i.length||u.size!==a||u.endIndex!==s-1?i.push({startIndex:s,endIndex:s,size:a}):i[i.length-1].endIndex++}return i}(e.children,o,c?"offsetWidth":"offsetHeight",i);let a=e.parentElement;for(;!a.dataset.virtuosoScroller;)a=a.parentElement;const u="window"===a.lastElementChild.dataset.viewportType,d=s?c?s.scrollLeft:s.scrollTop:u?c?window.pageXOffset||document.documentElement.scrollLeft:window.pageYOffset||document.documentElement.scrollTop:c?a.scrollLeft:a.scrollTop,m=s?c?s.scrollWidth:s.scrollHeight:u?c?document.documentElement.scrollWidth:document.documentElement.scrollHeight:c?a.scrollWidth:a.scrollHeight,f=s?c?s.offsetWidth:s.offsetHeight:u?c?window.innerWidth:window.innerHeight:c?a.offsetWidth:a.offsetHeight;r({scrollTop:Math.max(d,0),scrollHeight:m,viewportHeight:f}),null==l||l(c?X("column-gap",getComputedStyle(e).columnGap,i):X("row-gap",getComputedStyle(e).rowGap,i)),null!==n&&t(n)}),[t,o,i,l,s,r]);return q(u,n,a)}function X(e,t,o){return"normal"===t||(null==t?void 0:t.endsWith("px"))||o(`${e} was not resolved to pixel value correctly`,t,$.WARN),"normal"===t?0:parseInt(null!=t?t:"0",10)}function J(e,t){return Math.round(e.getBoundingClientRect()[t])}function Q(e,t){return Math.abs(e-t)<1.01}function ee(o,n,r,i=g,l,s){const c=e.useRef(null),a=e.useRef(null),u=e.useRef(null),d=e.useCallback((e=>{const r=e.target,i=r===window||r===document,l=s?i?window.pageXOffset||document.documentElement.scrollLeft:r.scrollLeft:i?window.pageYOffset||document.documentElement.scrollTop:r.scrollTop,c=s?i?document.documentElement.scrollWidth:r.scrollWidth:i?document.documentElement.scrollHeight:r.scrollHeight,d=s?i?window.innerWidth:r.offsetWidth:i?window.innerHeight:r.offsetHeight,m=()=>{o({scrollTop:Math.max(l,0),scrollHeight:c,viewportHeight:d})};e.suppressFlushSync?m():t.flushSync(m),null!==a.current&&(l===a.current||l<=0||l===c-d)&&(a.current=null,n(!0),u.current&&(clearTimeout(u.current),u.current=null))}),[o,n]);return e.useEffect((()=>{const e=l||c.current;return i(l||c.current),d({target:e,suppressFlushSync:!0}),e.addEventListener("scroll",d,{passive:!0}),()=>{i(null),e.removeEventListener("scroll",d)}}),[c,d,r,i,l]),{scrollerRef:c,scrollByCallback:function(e){s&&(e={left:e.top,behavior:e.behavior}),c.current.scrollBy(e)},scrollToCallback:function(e){const t=c.current;if(!t||(s?"offsetWidth"in t&&0===t.offsetWidth:"offsetHeight"in t&&0===t.offsetHeight))return;const r="smooth"===e.behavior;let i,l,d;t===window?(l=Math.max(J(document.documentElement,s?"width":"height"),s?document.documentElement.scrollWidth:document.documentElement.scrollHeight),i=s?window.innerWidth:window.innerHeight,d=s?document.documentElement.scrollLeft:document.documentElement.scrollTop):(l=t[s?"scrollWidth":"scrollHeight"],i=J(t,s?"width":"height"),d=t[s?"scrollLeft":"scrollTop"]);const m=l-i;if(e.top=Math.ceil(Math.max(Math.min(m,e.top),0)),Q(i,l)||e.top===d)return o({scrollTop:d,scrollHeight:l,viewportHeight:i}),void(r&&n(!0));r?(a.current=e.top,u.current&&clearTimeout(u.current),u.current=setTimeout((()=>{u.current=null,a.current=null,n(!0)}),1e3)):a.current=null,s&&(e={left:e.top,behavior:e.behavior}),t.scrollTo(e)}}}const te=D((()=>{const e=S(),t=S(),o=C(0),n=S(),r=C(0),i=S(),l=S(),s=C(0),c=C(0),a=C(0),u=C(0),d=S(),m=S(),f=C(!1),h=C(!1),g=C(!1);return T(y(e,k((({scrollTop:e})=>e))),t),T(y(e,k((({scrollHeight:e})=>e))),l),T(t,r),{scrollContainerState:e,scrollTop:t,viewportHeight:i,headerHeight:s,fixedHeaderHeight:c,fixedFooterHeight:a,footerHeight:u,scrollHeight:l,smoothScrollTargetReached:n,horizontalDirection:h,skipAnimationFrameInResizeObserver:g,scrollTo:d,scrollBy:m,statefulScrollTop:r,deviation:o,scrollingInProgress:f}}),[],{singleton:!0}),oe={lvl:0};function ne(e,t,o,n=oe,r=oe){return{k:e,v:t,lvl:o,l:n,r:r}}function re(e){return e===oe}function ie(){return oe}function le(e,t){if(re(e))return oe;const{k:o,l:n,r:r}=e;if(t===o){if(re(n))return r;if(re(r))return n;{const[t,o]=me(n);return ve(he(e,{k:t,v:o,l:fe(n)}))}}return ve(he(e,t<o?{l:le(n,t)}:{r:le(r,t)}))}function se(e,t){if(!re(e))return t===e.k?e.v:t<e.k?se(e.l,t):se(e.r,t)}function ce(e,t,o="k"){if(re(e))return[-1/0,void 0];if(Number(e[o])===t)return[e.k,e.v];if(Number(e[o])<t){const n=ce(e.r,t,o);return n[0]===-1/0?[e.k,e.v]:n}return ce(e.l,t,o)}function ae(e,t,o){return re(e)?ne(t,o,1):t===e.k?he(e,{k:t,v:o}):t<e.k?pe(he(e,{l:ae(e.l,t,o)})):pe(he(e,{r:ae(e.r,t,o)}))}function ue(e,t,o){if(re(e))return[];const{k:n,v:r,l:i,r:l}=e;let s=[];return n>t&&(s=s.concat(ue(i,t,o))),n>=t&&n<=o&&s.push({k:n,v:r}),n<=o&&(s=s.concat(ue(l,t,o))),s}function de(e){return re(e)?[]:[...de(e.l),{k:e.k,v:e.v},...de(e.r)]}function me(e){return re(e.r)?[e.k,e.v]:me(e.r)}function fe(e){return re(e.r)?e.l:ve(he(e,{r:fe(e.r)}))}function he(e,t){return ne(void 0!==t.k?t.k:e.k,void 0!==t.v?t.v:e.v,void 0!==t.lvl?t.lvl:e.lvl,void 0!==t.l?t.l:e.l,void 0!==t.r?t.r:e.r)}function ge(e){return re(e)||e.lvl>e.r.lvl}function pe(e){return Te(we(e))}function ve(e){const{l:t,r:o,lvl:n}=e;if(o.lvl>=n-1&&t.lvl>=n-1)return e;if(n>o.lvl+1){if(ge(t))return we(he(e,{lvl:n-1}));if(re(t)||re(t.r))throw new Error("Unexpected empty nodes");return he(t.r,{l:he(t,{r:t.r.l}),r:he(e,{l:t.r.r,lvl:n-1}),lvl:n})}if(ge(e))return Te(he(e,{lvl:n-1}));if(re(o)||re(o.l))throw new Error("Unexpected empty nodes");{const t=o.l,r=ge(t)?o.lvl-1:o.lvl;return he(t,{l:he(e,{r:t.l,lvl:n-1}),r:Te(he(o,{l:t.r,lvl:r})),lvl:t.lvl+1})}}function Ie(e,t,o){if(re(e))return[];const n=ce(e,t)[0];return xe(ue(e,n,o),(({k:e,v:t})=>({index:e,value:t})))}function xe(e,t){const o=e.length;if(0===o)return[];let{index:n,value:r}=t(e[0]);const i=[];for(let l=1;l<o;l++){const{index:o,value:s}=t(e[l]);i.push({start:n,end:o-1,value:r}),n=o,r=s}return i.push({start:n,end:1/0,value:r}),i}function Te(e){const{r:t,lvl:o}=e;return re(t)||re(t.r)||t.lvl!==o||t.r.lvl!==o?e:he(t,{l:he(e,{r:t.l}),lvl:o+1})}function we(e){const{l:t}=e;return re(t)||t.lvl!==e.lvl?e:he(t,{r:he(e,{l:t.r})})}function Se(e,t,o,n=0){let r=e.length-1;for(;n<=r;){const i=Math.floor((n+r)/2),l=o(e[i],t);if(0===l)return i;if(-1===l){if(r-n<2)return i-1;r=i-1}else{if(r===n)return i;n=i+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function Ce(e,t,o){return e[Se(e,t,o)]}const Ee=D((()=>({recalcInProgress:C(!1)})),[],{singleton:!0});function He(e){const{size:t,startIndex:o,endIndex:n}=e;return e=>e.start===o&&(e.end===n||e.end===1/0)&&e.value===t}function ye(e,t){let o=0,n=0;for(;o<e;)o+=t[n+1]-t[n]-1,n++;return n-(o===e?0:1)}function be({index:e},t){return t===e?0:t<e?-1:1}function ze({offset:e},t){return t===e?0:t<e?-1:1}function Re(e){return{index:e.index,value:e}}function ke(e,t,o,n=0){return n>0&&(t=Math.max(t,Ce(e,n,be).offset)),xe(function(e,t,o,n){const r=Se(e,t,n),i=Se(e,o,n,r);return e.slice(r,i+1)}(e,t,o,ze),Re)}function Be(e,t,o,n){let r=e,i=0,l=0,s=0,c=0;if(0!==t){c=Se(r,t-1,be);s=r[c].offset;const e=ce(o,t-1);i=e[0],l=e[1],r.length&&r[c].size===ce(o,t)[1]&&(c-=1),r=r.slice(0,c+1)}else r=[];for(const{start:a,value:u}of Ie(o,t,1/0)){const e=a-i,t=e*l+s+e*n;r.push({offset:t,size:u,index:a}),i=a,s=t,l=u}return{offsetTree:r,lastIndex:i,lastOffset:s,lastSize:l}}function Le(e,[t,o,n,r]){t.length>0&&n("received item sizes",t,$.DEBUG);const i=e.sizeTree;let l=i,s=0;if(o.length>0&&re(i)&&2===t.length){const e=t[0].size,n=t[1].size;l=o.reduce(((t,o)=>ae(ae(t,o,e),o+1,n)),l)}else[l,s]=function(e,t){let o=re(e)?0:1/0;for(const n of t){const{size:t,startIndex:r,endIndex:i}=n;if(o=Math.min(o,r),re(e)){e=ae(e,0,t);continue}const l=Ie(e,r-1,i+1);if(l.some(He(n)))continue;let s=!1,c=!1;for(const{start:o,end:n,value:a}of l)s?(i>=o||t===a)&&(e=le(e,o)):(c=a!==t,s=!0),n>i&&i>=o&&a!==t&&(e=ae(e,i+1,a));c&&(e=ae(e,r,t))}return[e,o]}(l,t);if(l===i)return e;const{offsetTree:c,lastIndex:a,lastSize:u,lastOffset:d}=Be(e.offsetTree,s,l,r);return{sizeTree:l,offsetTree:c,lastIndex:a,lastOffset:d,lastSize:u,groupOffsetTree:o.reduce(((e,t)=>ae(e,t,Oe(t,c,r))),ie()),groupIndices:o}}function Oe(e,t,o){if(0===t.length)return 0;const{offset:n,index:r,size:i}=Ce(t,e,be),l=e-r,s=i*l+(l-1)*o+n;return s>0?s+o:s}function Fe(e,t,o){if(function(e){return void 0!==e.groupIndex}(e))return t.groupIndices[e.groupIndex]+1;{let n=Me("LAST"===e.index?o:e.index,t);return n=Math.max(0,n,Math.min(o,n)),n}}function Me(e,t){if(!Pe(t))return e;let o=0;for(;t.groupIndices[o]<=e+o;)o++;return e+o}function Pe(e){return!re(e.groupOffsetTree)}const We={offsetHeight:"height",offsetWidth:"width"},Ae=D((([{log:e},{recalcInProgress:t}])=>{const o=S(),n=S(),r=H(n,0),i=S(),l=S(),s=C(0),c=C([]),a=C(void 0),u=C(void 0),d=C(((e,t)=>J(e,We[t]))),m=C(void 0),f=C(0),h={offsetTree:[],sizeTree:ie(),groupOffsetTree:ie(),lastIndex:0,lastOffset:0,lastSize:0,groupIndices:[]},g=H(y(o,P(c,e,f),L(Le,h),z()),h),I=H(y(c,z(),L(((e,t)=>({prev:e.current,current:t})),{prev:[],current:[]}),k((({prev:e})=>e))),[]);T(y(c,R((e=>e.length>0)),P(g,f),k((([e,t,o])=>{const n=e.reduce(((e,n,r)=>ae(e,n,Oe(n,t.offsetTree,o)||r)),ie());return{...t,groupIndices:e,groupOffsetTree:n}}))),g),T(y(n,P(g),R((([e,{lastIndex:t}])=>e<t)),k((([e,{lastIndex:t,lastSize:o}])=>[{startIndex:e,endIndex:t,size:o}]))),o),T(a,u);const w=H(y(a,k((e=>void 0===e))),!0);T(y(u,R((e=>void 0!==e&&re(x(g).sizeTree))),k((e=>[{startIndex:0,endIndex:0,size:e}]))),o);const b=E(y(o,P(g),L((({sizes:e},[t,o])=>({changed:o!==e,sizes:o})),{changed:!1,sizes:h}),k((e=>e.changed))));p(y(s,L(((e,t)=>({diff:e.prev-t,prev:t})),{diff:0,prev:0}),k((e=>e.diff))),(e=>{const{groupIndices:o}=x(g);if(e>0)v(t,!0),v(i,e+ye(e,o));else if(e<0){const t=x(I);t.length>0&&(e-=ye(-e,t)),v(l,e)}})),p(y(s,P(e)),(([e,t])=>{e<0&&t("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:s},$.ERROR)}));const B=E(i);T(y(i,P(g),k((([e,t])=>{const o=t.groupIndices.length>0,n=[],r=t.lastSize;if(o){const o=se(t.sizeTree,0);let i=0,l=0;for(;i<e;){const e=t.groupIndices[l],s=t.groupIndices.length===l+1?1/0:t.groupIndices[l+1]-e-1;n.push({startIndex:e,endIndex:e,size:o}),n.push({startIndex:e+1,endIndex:e+1+s-1,size:r}),l++,i+=s+1}const s=de(t.sizeTree);return i!==e&&s.shift(),s.reduce(((t,{k:o,v:n})=>{let r=t.ranges;return 0!==t.prevSize&&(r=[...t.ranges,{startIndex:t.prevIndex,endIndex:o+e-1,size:t.prevSize}]),{ranges:r,prevIndex:o+e,prevSize:n}}),{ranges:n,prevIndex:e,prevSize:0}).ranges}return de(t.sizeTree).reduce(((t,{k:o,v:n})=>({ranges:[...t.ranges,{startIndex:t.prevIndex,endIndex:o+e-1,size:t.prevSize}],prevIndex:o+e,prevSize:n})),{ranges:[],prevIndex:0,prevSize:r}).ranges}))),o);const O=E(y(l,P(g,f),k((([e,{offsetTree:t},o])=>Oe(-e,t,o)))));return T(y(l,P(g,f),k((([e,t,o])=>{if(t.groupIndices.length>0){if(re(t.sizeTree))return t;let n=ie();const r=x(I);let i=0,l=0,s=0;for(;i<-e;){s=r[l];const e=r[l+1]-s-1;l++,i+=e+1}n=de(t.sizeTree).reduce(((t,{k:o,v:n})=>ae(t,Math.max(0,o+e),n)),n);if(i!==-e){n=ae(n,0,se(t.sizeTree,s));n=ae(n,1,ce(t.sizeTree,1-e)[1])}return{...t,sizeTree:n,...Be(t.offsetTree,0,n,o)}}{const n=de(t.sizeTree).reduce(((t,{k:o,v:n})=>ae(t,Math.max(0,o+e),n)),ie());return{...t,sizeTree:n,...Be(t.offsetTree,0,n,o)}}}))),g),{data:m,totalCount:n,sizeRanges:o,groupIndices:c,defaultItemSize:u,fixedItemSize:a,unshiftWith:i,shiftWith:l,shiftWithOffset:O,beforeUnshiftWith:B,firstItemIndex:s,gap:f,sizes:g,listRefresh:b,statefulTotalCount:r,trackItemSizes:w,itemSize:d}}),d(K,Ee),{singleton:!0}),Ve="undefined"!=typeof document&&"scrollBehavior"in document.documentElement.style;function De(e){const t="number"==typeof e?{index:e}:e;return t.align||(t.align="start"),t.behavior&&Ve||(t.behavior="auto"),t.offset||(t.offset=0),t}const Ge=D((([{sizes:e,totalCount:t,listRefresh:o,gap:n},{scrollingInProgress:r,viewportHeight:i,scrollTo:l,smoothScrollTargetReached:s,headerHeight:c,footerHeight:a,fixedHeaderHeight:u,fixedFooterHeight:d},{log:m}])=>{const f=S(),h=S(),g=C(0);let I=null,x=null,E=null;function H(){I&&(I(),I=null),E&&(E(),E=null),x&&(clearTimeout(x),x=null),v(r,!1)}return T(y(f,P(e,i,t,g,c,a,m),P(n,u,d),k((([[e,t,n,i,l,c,a,u],d,m,g])=>{const T=De(e),{align:S,behavior:C,offset:b}=T,z=i-1,R=Fe(T,t,z);let k=Oe(R,t.offsetTree,d)+c;"end"===S?(k+=m+ce(t.sizeTree,R)[1]-n+g,R===z&&(k+=a)):"center"===S?k+=(m+ce(t.sizeTree,R)[1]-n+g)/2:k-=l,b&&(k+=b);const B=t=>{H(),t?(u("retrying to scroll to",{location:e},$.DEBUG),v(f,e)):(v(h,!0),u("list did not change, scroll successful",{},$.DEBUG))};if(H(),"smooth"===C){let e=!1;E=p(o,(t=>{e=e||t})),I=w(s,(()=>{B(e)}))}else I=w(y(o,(L=150,e=>{const t=setTimeout((()=>{e(!1)}),L);return o=>{o&&(e(!0),clearTimeout(t))}})),B);var L;return x=setTimeout((()=>{H()}),1200),v(r,!0),u("scrolling from index to",{index:R,top:k,behavior:C},$.DEBUG),{top:k,behavior:C}}))),l),{scrollToIndex:f,scrollTargetReached:h,topListHeight:g}}),d(Ae,te,K),{singleton:!0});const Ne="up",_e="down",Ue={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollTop:0,viewportHeight:0,scrollHeight:0}},$e=D((([{scrollContainerState:e,scrollTop:t,viewportHeight:o,headerHeight:n,footerHeight:r,scrollBy:i}])=>{const l=C(!1),s=C(!0),c=S(),a=S(),u=C(4),d=C(0),m=H(y(W(y(A(t),O(1),B(!0)),y(A(t),O(1),B(!1),M(100))),z()),!1),f=H(y(W(y(i,B(!0)),y(i,B(!1),M(200))),z()),!1);T(y(V(A(t),A(d)),k((([e,t])=>e<=t)),z()),s),T(y(s,F(50)),a);const h=E(y(V(e,A(o),A(n),A(r),A(u)),L(((e,[{scrollTop:t,scrollHeight:o},n,r,i,l])=>{const s={viewportHeight:n,scrollTop:t,scrollHeight:o};if(t+n-o>-l){let o,n;return t>e.state.scrollTop?(o="SCROLLED_DOWN",n=e.state.scrollTop-t):(o="SIZE_DECREASED",n=e.state.scrollTop-t||e.scrollTopDelta),{atBottom:!0,state:s,atBottomBecause:o,scrollTopDelta:n}}let c;return c=s.scrollHeight>e.state.scrollHeight?"SIZE_INCREASED":n<e.state.viewportHeight?"VIEWPORT_HEIGHT_DECREASING":t<e.state.scrollTop?"SCROLLING_UPWARDS":"NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:c,state:s}}),Ue),z(((e,t)=>e&&e.atBottom===t.atBottom)))),g=H(y(e,L(((e,{scrollTop:t,scrollHeight:o,viewportHeight:n})=>{if(Q(e.scrollHeight,o))return{scrollTop:t,scrollHeight:o,jump:0,changed:!1};{const r=o-(t+n)<1;return e.scrollTop!==t&&r?{scrollHeight:o,scrollTop:t,jump:e.scrollTop-t,changed:!0}:{scrollHeight:o,scrollTop:t,jump:0,changed:!0}}}),{scrollHeight:0,jump:0,scrollTop:0,changed:!1}),R((e=>e.changed)),k((e=>e.jump))),0);T(y(h,k((e=>e.atBottom))),l),T(y(l,F(50)),c);const p=C(_e);T(y(e,k((({scrollTop:e})=>e)),z(),L(((e,t)=>x(f)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?Ne:_e,prevScrollTop:t}),{direction:_e,prevScrollTop:0}),k((e=>e.direction))),p),T(y(e,F(50),B("none")),p);const v=C(0);return T(y(m,R((e=>!e)),B(0)),v),T(y(t,F(100),P(m),R((([e,t])=>!!t)),L((([e,t],[o])=>[t,o]),[0,0]),k((([e,t])=>t-e))),v),{isScrolling:m,isAtTop:s,isAtBottom:l,atBottomState:h,atTopStateChange:a,atBottomStateChange:c,scrollDirection:p,atBottomThreshold:u,atTopThreshold:d,scrollVelocity:v,lastJumpDueToItemResize:g}}),d(te)),je=D((([{log:e}])=>{const t=C(!1),o=E(y(t,R((e=>e)),z()));return p(t,(t=>{t&&x(e)("props updated",{},$.DEBUG)})),{propsReady:t,didMount:o}}),d(K),{singleton:!0});function Ke(e,t){0==e?t():requestAnimationFrame((()=>Ke(e-1,t)))}function qe(e,t){const o=t-1;return"number"==typeof e?e:"LAST"===e.index?o:e.index}const Ye=D((([{sizes:e,listRefresh:t,defaultItemSize:o},{scrollTop:n},{scrollToIndex:r,scrollTargetReached:i},{didMount:l}])=>{const s=C(!0),c=C(0),a=C(!0);return T(y(l,P(c),R((([e,t])=>!!t)),B(!1)),s),T(y(l,P(c),R((([e,t])=>!!t)),B(!1)),a),p(y(V(t,l),P(s,e,o,a),R((([[,e],t,{sizeTree:o},n,r])=>e&&(!re(o)||h(n))&&!t&&!r)),P(c)),(([,e])=>{w(i,(()=>{v(a,!0)})),Ke(4,(()=>{w(n,(()=>{v(s,!0)})),v(r,e)}))})),{scrolledToInitialItem:s,initialTopMostItemIndex:c,initialItemFinalLocationReached:a}}),d(Ae,te,Ge,je),{singleton:!0});function Ze(e){return!!e&&("smooth"===e?"smooth":"auto")}const Xe=D((([{totalCount:e,listRefresh:t},{isAtBottom:o,atBottomState:n},{scrollToIndex:r},{scrolledToInitialItem:i},{propsReady:l,didMount:s},{log:c},{scrollingInProgress:a}])=>{const u=C(!1),d=S();let m=null;function f(e){v(r,{index:"LAST",align:"end",behavior:e})}function h(e){const t=w(n,(t=>{!e||t.atBottom||"SIZE_INCREASED"!==t.notAtBottomBecause||m||(x(c)("scrolling to bottom due to increased size",{},$.DEBUG),f("auto"))}));setTimeout(t,100)}return p(y(V(y(A(e),O(1)),s),P(A(u),o,i,a),k((([[e,t],o,n,r,i])=>{let l=t&&r,s="auto";return l&&(s=((e,t)=>"function"==typeof e?Ze(e(t)):t&&Ze(e))(o,n||i),l=l&&!!s),{totalCount:e,shouldFollow:l,followOutputBehavior:s}})),R((({shouldFollow:e})=>e))),(({totalCount:e,followOutputBehavior:o})=>{m&&(m(),m=null),m=w(t,(()=>{x(c)("following output to ",{totalCount:e},$.DEBUG),f(o),m=null}))})),p(y(V(A(u),e,l),R((([e,,t])=>e&&t)),L((({value:e},[,t])=>({refreshed:e===t,value:t})),{refreshed:!1,value:0}),R((({refreshed:e})=>e)),P(u,e)),(([,e])=>{x(i)&&h(!1!==e)})),p(d,(()=>{h(!1!==x(u))})),p(V(A(u),n),(([e,t])=>{e&&!t.atBottom&&"VIEWPORT_HEIGHT_DECREASING"===t.notAtBottomBecause&&f("auto")})),{followOutput:u,autoscrollToBottom:d}}),d(Ae,$e,Ge,Ye,je,K,te));function Je(e){return e.reduce(((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e)),{totalCount:0,groupIndices:[]})}const Qe=D((([{totalCount:e,groupIndices:t,sizes:o},{scrollTop:n,headerHeight:r}])=>{const i=S(),l=S(),s=E(y(i,k(Je)));return T(y(s,k((e=>e.totalCount))),e),T(y(s,k((e=>e.groupIndices))),t),T(y(V(n,o,r),R((([e,t])=>Pe(t))),k((([e,t,o])=>ce(t.groupOffsetTree,Math.max(e-o,0),"v")[0])),z(),k((e=>[e]))),l),{groupCounts:i,topItemsIndexes:l}}),d(Ae,te));function et(e,t){return!(!e||e[0]!==t[0]||e[1]!==t[1])}function tt(e,t){return!(!e||e.startIndex!==t.startIndex||e.endIndex!==t.endIndex)}const ot="top",nt="bottom",rt="none";function it(e,t,o){return"number"==typeof e?o===Ne&&t===ot||o===_e&&t===nt?e:0:o===Ne?t===ot?e.main:e.reverse:t===nt?e.main:e.reverse}function lt(e,t){return"number"==typeof e?e:e[t]||0}const st=D((([{scrollTop:e,viewportHeight:t,deviation:o,headerHeight:n,fixedHeaderHeight:r}])=>{const i=S(),l=C(0),s=C(0),c=C(0);return{listBoundary:i,overscan:c,topListHeight:l,increaseViewportBy:s,visibleRange:H(y(V(A(e),A(t),A(n),A(i,et),A(c),A(l),A(r),A(o),A(s)),k((([e,t,o,[n,r],i,l,s,c,a])=>{const u=e-c,d=l+s,m=Math.max(o-u,0);let f=rt;const h=lt(a,ot),g=lt(a,nt);return n-=c,r+=o+s,(n+=o+s)>e+d-h&&(f=Ne),(r-=c)<e-m+t+g&&(f=_e),f!==rt?[Math.max(u-o-it(i,ot,f)-h,0),u-m-s+t+it(i,nt,f)+g]:null})),R((e=>null!=e)),z(et)),[0,0])}}),d(te),{singleton:!0});const ct={items:[],topItems:[],offsetTop:0,offsetBottom:0,top:0,bottom:0,topListHeight:0,totalCount:0,firstItemIndex:0};function at(e,t,o){if(0===e.length)return[];if(!Pe(t))return e.map((e=>({...e,index:e.index+o,originalIndex:e.index})));const n=e[0].index,r=e[e.length-1].index,i=[],l=Ie(t.groupOffsetTree,n,r);let s,c=0;for(const a of e){let e;(!s||s.end<a.index)&&(s=l.shift(),c=t.groupIndices.indexOf(s.start)),e=a.index===s.start?{type:"group",index:c}:{index:a.index-(c+1)+o,groupIndex:c},i.push({...e,size:a.size,offset:a.offset,originalIndex:a.index,data:a.data})}return i}function ut(e,t,o,n,r,i){const{lastSize:l,lastOffset:s,lastIndex:c}=r;let a=0,u=0;if(e.length>0){a=e[0].offset;const t=e[e.length-1];u=t.offset+t.size}const d=o-c,m=a,f=s+d*l+(d-1)*n-u;return{items:at(e,r,i),topItems:at(t,r,i),topListHeight:t.reduce(((e,t)=>t.size+e),0),offsetTop:a,offsetBottom:f,top:m,bottom:u,totalCount:o,firstItemIndex:i}}function dt(e,t,o,n,r,i){let l=0;if(o.groupIndices.length>0)for(const a of o.groupIndices){if(a-l>=e)break;l++}const s=e+l,c=qe(t,s);return ut(Array.from({length:s}).map(((e,t)=>({index:t+c,size:0,offset:0,data:i[t+c]}))),[],s,r,o,n)}const mt=D((([{sizes:e,totalCount:t,data:o,firstItemIndex:n,gap:r},i,{visibleRange:l,listBoundary:s,topListHeight:c},{scrolledToInitialItem:a,initialTopMostItemIndex:d},{topListHeight:m},f,{didMount:g},{recalcInProgress:p}])=>{const v=C([]),I=C(0),w=S();T(i.topItemsIndexes,v);const b=H(y(V(g,p,A(l,et),A(t),A(e),A(d),a,A(v),A(n),A(r),o),R((([e,t,,o,,,,,,,n])=>{const r=n&&n.length!==o;return e&&!t&&!r})),k((([,,[e,t],o,n,r,i,l,s,c,a])=>{const d=n,{sizeTree:m,offsetTree:f}=d,h=x(I);if(0===o)return{...ct,totalCount:o};if(0===e&&0===t)return 0===h?{...ct,totalCount:o}:dt(h,r,n,s,c,a||[]);if(re(m)){if(h>0)return null;const e=ut(function(e,t,o){if(Pe(t)){const n=Me(e,t);return[{index:ce(t.groupOffsetTree,n)[0],size:0,offset:0},{index:n,size:0,offset:0,data:o&&o[0]}]}return[{index:e,size:0,offset:0,data:o&&o[0]}]}(qe(r,o),d,a),[],o,c,d,s);return e}const g=[];if(l.length>0){const e=l[0],t=l[l.length-1];let o=0;for(const n of Ie(m,e,t)){const r=n.value,i=Math.max(n.start,e),l=Math.min(n.end,t);for(let e=i;e<=l;e++)g.push({index:e,size:r,offset:o,data:a&&a[e]}),o+=r}}if(!i)return ut([],g,o,c,d,s);const p=l.length>0?l[l.length-1]+1:0,v=ke(f,e,t,p);if(0===v.length)return null;const T=o-1;return ut(u([],(o=>{for(const n of v){const r=n.value;let i=r.offset,l=n.start;const s=r.size;if(r.offset<e){l+=Math.floor((e-r.offset+c)/(s+c));const t=l-n.start;i+=t*s+t*c}l<p&&(i+=(p-l)*s,l=p);const u=Math.min(n.end,T);for(let e=l;e<=u&&!(i>=t);e++)o.push({index:e,size:s,offset:i,data:a&&a[e]}),i+=s+c}})),g,o,c,d,s)})),R((e=>null!==e)),z()),ct);T(y(o,R(h),k((e=>null==e?void 0:e.length))),t),T(y(b,k((e=>e.topListHeight))),m),T(m,c),T(y(b,k((e=>[e.top,e.bottom]))),s),T(y(b,k((e=>e.items))),w);return{listState:b,topItemsIndexes:v,endReached:E(y(b,R((({items:e})=>e.length>0)),P(t,o),R((([{items:e},t])=>e[e.length-1].originalIndex===t-1)),k((([,e,t])=>[e-1,t])),z(et),k((([e])=>e)))),startReached:E(y(b,F(200),R((({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length)),k((({items:e})=>e[0].index)),z())),rangeChanged:E(y(b,R((({items:e})=>e.length>0)),k((({items:e})=>{let t=0,o=e.length-1;for(;"group"===e[t].type&&t<o;)t++;for(;"group"===e[o].type&&o>t;)o--;return{startIndex:e[t].index,endIndex:e[o].index}})),z(tt))),itemsRendered:w,initialItemCount:I,...f}}),d(Ae,Qe,st,Ye,Ge,$e,je,Ee),{singleton:!0}),ft=D((([{sizes:e,firstItemIndex:t,data:o,gap:n},{initialTopMostItemIndex:r},{initialItemCount:i,listState:l},{didMount:s}])=>(T(y(s,P(i),R((([,e])=>0!==e)),P(r,e,t,n,o),k((([[,e],t,o,n,r,i=[]])=>dt(e,t,o,n,r,i)))),l),{})),d(Ae,Ye,mt,je),{singleton:!0}),ht=D((([{scrollVelocity:e}])=>{const t=C(!1),o=S(),n=C(!1);return T(y(e,P(n,t,o),R((([e,t])=>!!t)),k((([e,t,o,n])=>{const{exit:r,enter:i}=t;if(o){if(r(e,n))return!1}else if(i(e,n))return!0;return o})),z()),t),p(y(V(t,e,o),P(n)),(([[e,t,o],n])=>e&&n&&n.change&&n.change(t,o))),{isSeeking:t,scrollSeekConfiguration:n,scrollVelocity:e,scrollSeekRangeChanged:o}}),d($e),{singleton:!0}),gt=D((([{topItemsIndexes:e}])=>{const t=C(0);return T(y(t,R((e=>e>0)),k((e=>Array.from({length:e}).map(((e,t)=>t))))),e),{topItemCount:t}}),d(mt)),pt=D((([{footerHeight:e,headerHeight:t,fixedHeaderHeight:o,fixedFooterHeight:n},{listState:r}])=>{const i=S(),l=H(y(V(e,n,t,o,r),k((([e,t,o,n,r])=>e+t+o+n+r.offsetBottom+r.bottom))),0);return T(A(l),i),{totalListHeight:l,totalListHeightChanged:i}}),d(te,mt),{singleton:!0});function vt(e){let t,o=!1;return()=>(o||(o=!0,t=e()),t)}const It=vt((()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent))),xt=D((([{scrollBy:e,scrollTop:t,deviation:o,scrollingInProgress:n},{isScrolling:r,isAtBottom:i,scrollDirection:l,lastJumpDueToItemResize:s},{listState:c},{beforeUnshiftWith:a,shiftWithOffset:u,sizes:d,gap:m},{log:f},{recalcInProgress:h}])=>{const g=E(y(c,P(s),L((([,e,t,o],[{items:n,totalCount:r,bottom:i,offsetBottom:l},s])=>{const c=i+l;let a=0;if(t===r&&e.length>0&&n.length>0){0===n[0].originalIndex&&0===e[0].originalIndex||(a=c-o,0!==a&&(a+=s))}return[a,n,r,c]}),[0,[],0,0]),R((([e])=>0!==e)),P(t,l,n,i,f,h),R((([,e,t,o,,,n])=>!n&&!o&&0!==e&&t===Ne)),k((([[e],,,,,t])=>(t("Upward scrolling compensation",{amount:e},$.DEBUG),e)))));function I(t){t>0?(v(e,{top:-t,behavior:"auto"}),v(o,0)):(v(o,0),v(e,{top:-t,behavior:"auto"}))}return p(y(g,P(o,r)),(([e,t,n])=>{n&&It()?v(o,t-e):I(-e)})),p(y(V(H(r,!1),o,h),R((([e,t,o])=>!e&&!o&&0!==t)),k((([e,t])=>t)),F(1)),I),T(y(u,k((e=>({top:-e})))),e),p(y(a,P(d,m),k((([e,{lastSize:t,groupIndices:o,sizeTree:n},r])=>{function i(e){return e*(t+r)}if(0===o.length)return i(e);{let t=0;const r=se(n,0);let l=0,s=0;for(;l<e;){l++,t+=r;let n=o.length===s+1?1/0:o[s+1]-o[s]-1;l+n>e&&(t-=r,n=e-l+1),l+=n,t+=i(n),s++}return t}}))),(t=>{v(o,t),requestAnimationFrame((()=>{v(e,{top:t}),requestAnimationFrame((()=>{v(o,0),v(h,!1)}))}))})),{deviation:o}}),d(te,$e,mt,Ae,K,Ee)),Tt=D((([{didMount:e},{scrollTo:t},{listState:o}])=>{const n=C(0);return p(y(e,P(n),R((([,e])=>0!==e)),k((([,e])=>({top:e})))),(e=>{w(y(o,O(1),R((e=>e.items.length>1))),(()=>{requestAnimationFrame((()=>{v(t,e)}))}))})),{initialScrollTop:n}}),d(je,te,mt),{singleton:!0}),wt=D((([{viewportHeight:e},{totalListHeight:t}])=>{const o=C(!1);return{alignToBottom:o,paddingTopAddition:H(y(V(o,e,t),R((([e])=>e)),k((([,e,t])=>Math.max(0,e-t))),F(0),z()),0)}}),d(te,pt),{singleton:!0}),St=D((([{scrollTo:e,scrollContainerState:t}])=>{const o=S(),n=S(),r=S(),i=C(!1),l=C(void 0);return T(y(V(o,n),k((([{viewportHeight:e,scrollTop:t,scrollHeight:o},{offsetTop:n}])=>({scrollTop:Math.max(0,t-n),scrollHeight:o,viewportHeight:e})))),t),T(y(e,P(n),k((([e,{offsetTop:t}])=>({...e,top:e.top+t})))),r),{useWindowScroll:i,customScrollParent:l,windowScrollContainerState:o,windowViewportRect:n,windowScrollTo:r}}),d(te)),Ct=({itemTop:e,itemBottom:t,viewportTop:o,viewportBottom:n,locationParams:{behavior:r,align:i,...l}})=>e<o?{...l,behavior:r,align:null!=i?i:"start"}:t>n?{...l,behavior:r,align:null!=i?i:"end"}:null,Et=D((([{sizes:e,totalCount:t,gap:o},{scrollTop:n,viewportHeight:r,headerHeight:i,fixedHeaderHeight:l,fixedFooterHeight:s,scrollingInProgress:c},{scrollToIndex:a}])=>{const u=S();return T(y(u,P(e,r,t,i,l,s,n),P(o),k((([[e,t,o,n,r,i,l,s],a])=>{const{done:u,behavior:d,align:m,calculateViewLocation:f=Ct,...h}=e,g=Fe(e,t,n-1),p=Oe(g,t.offsetTree,a)+r+i,v=f({itemTop:p,itemBottom:p+ce(t.sizeTree,g)[1],viewportTop:s+i,viewportBottom:s+o-l,locationParams:{behavior:d,align:m,...h}});return v?u&&w(y(c,R((e=>!1===e)),O(x(c)?1:2)),u):u&&u(),v})),R((e=>null!==e))),a),{scrollIntoView:u}}),d(Ae,te,Ge,mt,K),{singleton:!0}),Ht=D((([{sizes:e,sizeRanges:t},{scrollTop:o,headerHeight:n},{initialTopMostItemIndex:r},{didMount:i},{useWindowScroll:l,windowScrollContainerState:s,windowViewportRect:c}])=>{const a=S(),u=C(void 0),d=C(null),m=C(null);return T(s,d),T(c,m),p(y(a,P(e,o,l,d,m,n)),(([e,t,o,n,r,i,l])=>{const s=de(t.sizeTree).map((({k:e,v:t},o,n)=>{const r=n[o+1];return{startIndex:e,endIndex:r?r.k-1:1/0,size:t}}));n&&null!==r&&null!==i&&(o=r.scrollTop-i.offsetTop),e({ranges:s,scrollTop:o-=l})})),T(y(u,R(h),k(yt)),r),T(y(i,P(u),R((([,e])=>void 0!==e)),z(),k((([,e])=>e.ranges))),t),{getState:a,restoreStateFrom:u}}),d(Ae,te,Ye,je,St));function yt(e){return{offset:e.scrollTop,index:0,align:"start"}}const bt=D((([e,t,o,n,r,i,l,s,c,a])=>({...e,...t,...o,...n,...r,...i,...l,...s,...c,...a})),d(st,ft,je,ht,pt,Tt,wt,St,Et,K)),zt=D((([{totalCount:e,sizeRanges:t,fixedItemSize:o,defaultItemSize:n,trackItemSizes:r,itemSize:i,data:l,firstItemIndex:s,groupIndices:c,statefulTotalCount:a,gap:u,sizes:d},{initialTopMostItemIndex:m,scrolledToInitialItem:f,initialItemFinalLocationReached:h},g,p,v,{listState:I,topItemsIndexes:x,...w},{scrollToIndex:S},C,{topItemCount:E},{groupCounts:H},b])=>(T(w.rangeChanged,b.scrollSeekRangeChanged),T(y(b.windowViewportRect,k((e=>e.visibleHeight))),g.viewportHeight),{totalCount:e,data:l,firstItemIndex:s,sizeRanges:t,initialTopMostItemIndex:m,scrolledToInitialItem:f,initialItemFinalLocationReached:h,topItemsIndexes:x,topItemCount:E,groupCounts:H,fixedItemHeight:o,defaultItemHeight:n,gap:u,...v,statefulTotalCount:a,listState:I,scrollToIndex:S,trackItemSizes:r,itemSize:i,groupIndices:c,...w,...b,...g,sizes:d,...p})),d(Ae,Ye,te,Ht,Xe,mt,Ge,xt,gt,Qe,bt)),Rt="-webkit-sticky",kt="sticky",Bt=vt((()=>{if("undefined"==typeof document)return kt;const e=document.createElement("div");return e.style.position=Rt,e.style.position===Rt?Rt:kt}));function Lt(t,o,n){const r=e.useRef(null),i=e.useCallback((e=>{if(null===e||!e.offsetParent)return;const n=e.getBoundingClientRect(),i=n.width;let l,s;if(o){const e=o.getBoundingClientRect(),t=n.top-e.top;l=e.height-Math.max(0,t),s=t+o.scrollTop}else l=window.innerHeight-Math.max(0,n.top),s=n.top+window.pageYOffset;r.current={offsetTop:s,visibleHeight:l,visibleWidth:i},t(r.current)}),[t,o]),{callbackRef:l,ref:s}=q(i,!0,n),c=e.useCallback((()=>{i(s.current)}),[i,s]);return e.useEffect((()=>{if(o){o.addEventListener("scroll",c);const e=new ResizeObserver((()=>{requestAnimationFrame(c)}));return e.observe(o),()=>{o.removeEventListener("scroll",c),e.unobserve(o)}}return window.addEventListener("scroll",c),window.addEventListener("resize",c),()=>{window.removeEventListener("scroll",c),window.removeEventListener("resize",c)}}),[c,o]),l}const Ot=e.createContext(void 0),Ft=e.createContext(void 0);function Mt(e){return e}const Pt=D((([e,t])=>({...e,...t})),d(zt,D((()=>{const e=C((e=>`Item ${e}`)),t=C(null),o=C((e=>`Group ${e}`)),n=C({}),r=C(Mt),i=C("div"),l=C(g),s=(e,t=null)=>H(y(n,k((t=>t[e])),z()),t);return{context:t,itemContent:e,groupContent:o,components:n,computeItemKey:r,headerFooterTag:i,scrollerRef:l,FooterComponent:s("Footer"),HeaderComponent:s("Header"),TopItemListComponent:s("TopItemList"),ListComponent:s("List","div"),ItemComponent:s("Item","div"),GroupComponent:s("Group","div"),ScrollerComponent:s("Scroller","div"),EmptyPlaceholder:s("EmptyPlaceholder"),ScrollSeekPlaceholder:s("ScrollSeekPlaceholder")}})))),Wt=({height:t})=>e.createElement("div",{style:{height:t}}),At={position:Bt(),zIndex:1,overflowAnchor:"none"},Vt={overflowAnchor:"none"},Dt={...Vt,display:"inline-block",height:"100%"},Gt=e.memo((function({showTopList:t=!1}){const o=ro("listState"),n=no("sizeRanges"),r=ro("useWindowScroll"),i=ro("customScrollParent"),l=no("windowScrollContainerState"),s=no("scrollContainerState"),c=i||r?l:s,a=ro("itemContent"),u=ro("context"),d=ro("groupContent"),m=ro("trackItemSizes"),f=ro("itemSize"),h=ro("log"),p=no("gap"),v=ro("horizontalDirection"),{callbackRef:I}=Z(n,f,m,t?g:c,h,p,i,v,ro("skipAnimationFrameInResizeObserver")),[x,T]=e.useState(0);io("deviation",(e=>{x!==e&&T(e)}));const w=ro("EmptyPlaceholder"),S=ro("ScrollSeekPlaceholder")||Wt,C=ro("ListComponent"),E=ro("ItemComponent"),H=ro("GroupComponent"),y=ro("computeItemKey"),b=ro("isSeeking"),z=ro("groupIndices").length>0,R=ro("alignToBottom"),k=ro("initialItemFinalLocationReached"),B=t?{}:{boxSizing:"border-box",...v?{whiteSpace:"nowrap",display:"inline-block",height:"100%",paddingLeft:o.offsetTop,paddingRight:o.offsetBottom,marginLeft:0!==x?x:R?"auto":0}:{marginTop:0!==x?x:R?"auto":0,paddingTop:o.offsetTop,paddingBottom:o.offsetBottom},...k?{}:{visibility:"hidden"}};return!t&&0===o.totalCount&&w?e.createElement(w,jt(w,u)):e.createElement(C,{...jt(C,u),ref:I,style:B,"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list"},(t?o.topItems:o.items).map((t=>{const n=t.originalIndex,r=y(n+o.firstItemIndex,t.data,u);return b?e.createElement(S,{...jt(S,u),key:r,index:t.index,height:t.size,type:t.type||"item",..."group"===t.type?{}:{groupIndex:t.groupIndex}}):"group"===t.type?e.createElement(H,{...jt(H,u),key:r,"data-index":n,"data-known-size":t.size,"data-item-index":t.index,style:At},d(t.index,u)):e.createElement(E,{...jt(E,u),...Kt(E,t.data),key:r,"data-index":n,"data-known-size":t.size,"data-item-index":t.index,"data-item-group-index":t.groupIndex,style:v?Dt:Vt},z?a(t.index,t.groupIndex,t.data,u):a(t.index,t.data,u))})))})),Nt={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},_t={outline:"none",overflowX:"auto",position:"relative"},Ut=e=>({width:"100%",height:"100%",position:"absolute",top:0,...e?{display:"flex",flexDirection:"column"}:{}}),$t={width:"100%",position:Bt(),top:0,zIndex:1};function jt(e,t){if("string"!=typeof e)return{context:t}}function Kt(e,t){return{item:"string"==typeof e?void 0:t}}const qt=e.memo((function(){const t=ro("HeaderComponent"),o=no("headerHeight"),n=ro("headerFooterTag"),r=Y(e.useMemo((()=>e=>o(J(e,"height"))),[o]),!0,ro("skipAnimationFrameInResizeObserver")),i=ro("context");return t?e.createElement(n,{ref:r},e.createElement(t,jt(t,i))):null})),Yt=e.memo((function(){const t=ro("FooterComponent"),o=no("footerHeight"),n=ro("headerFooterTag"),r=Y(e.useMemo((()=>e=>o(J(e,"height"))),[o]),!0,ro("skipAnimationFrameInResizeObserver")),i=ro("context");return t?e.createElement(n,{ref:r},e.createElement(t,jt(t,i))):null}));function Zt({usePublisher:t,useEmitter:o,useEmitterValue:n}){return e.memo((function({style:r,children:i,...l}){const s=t("scrollContainerState"),c=n("ScrollerComponent"),a=t("smoothScrollTargetReached"),u=n("scrollerRef"),d=n("context"),m=n("horizontalDirection")||!1,{scrollerRef:f,scrollByCallback:h,scrollToCallback:g}=ee(s,a,c,u,void 0,m);o("scrollTo",g),o("scrollBy",h);const p=m?_t:Nt;return e.createElement(c,{ref:f,style:{...p,...r},"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,tabIndex:0,...l,...jt(c,d)},i)}))}function Xt({usePublisher:t,useEmitter:o,useEmitterValue:n}){return e.memo((function({style:r,children:i,...l}){const s=t("windowScrollContainerState"),c=n("ScrollerComponent"),a=t("smoothScrollTargetReached"),u=n("totalListHeight"),d=n("deviation"),m=n("customScrollParent"),f=n("context"),{scrollerRef:h,scrollByCallback:p,scrollToCallback:v}=ee(s,a,c,g,m);return U((()=>(h.current=m||window,()=>{h.current=null})),[h,m]),o("windowScrollTo",v),o("scrollBy",p),e.createElement(c,{style:{position:"relative",...r,...0!==u?{height:u+d}:{}},"data-virtuoso-scroller":!0,...l,...jt(c,f)},i)}))}const Jt=({children:t})=>{const o=e.useContext(Ot),n=no("viewportHeight"),r=no("fixedItemHeight"),i=ro("alignToBottom"),s=ro("horizontalDirection"),c=Y(e.useMemo((()=>l(n,(e=>J(e,s?"width":"height")))),[n,s]),!0,ro("skipAnimationFrameInResizeObserver"));return e.useEffect((()=>{o&&(n(o.viewportHeight),r(o.itemHeight))}),[o,n,r]),e.createElement("div",{style:Ut(i),ref:c,"data-viewport-type":"element"},t)},Qt=({children:t})=>{const o=e.useContext(Ot),n=no("windowViewportRect"),r=no("fixedItemHeight"),i=ro("customScrollParent"),l=Lt(n,i,ro("skipAnimationFrameInResizeObserver")),s=ro("alignToBottom");return e.useEffect((()=>{o&&(r(o.itemHeight),n({offsetTop:0,visibleHeight:o.viewportHeight,visibleWidth:100}))}),[o,n,r]),e.createElement("div",{ref:l,style:Ut(s),"data-viewport-type":"window"},t)},eo=({children:t})=>{const o=ro("TopItemListComponent")||"div",n=ro("headerHeight"),r={...$t,marginTop:`${n}px`},i=ro("context");return e.createElement(o,{style:r,...jt(o,i)},t)},to=e.memo((function(t){const o=ro("useWindowScroll"),n=ro("topItemsIndexes").length>0,r=ro("customScrollParent"),i=r||o?so:lo,l=r||o?Qt:Jt;return e.createElement(i,{...t},n&&e.createElement(eo,null,e.createElement(Gt,{showTopList:!0})),e.createElement(l,null,e.createElement(qt,null),e.createElement(Gt,null),e.createElement(Yt,null)))})),{Component:oo,usePublisher:no,useEmitterValue:ro,useEmitter:io}=_(Pt,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},to),lo=Zt({usePublisher:no,useEmitterValue:ro,useEmitter:io}),so=Xt({usePublisher:no,useEmitterValue:ro,useEmitter:io}),co=oo,ao=oo,uo={items:[],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},mo={items:[{index:0}],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},{round:fo,ceil:ho,floor:go,min:po,max:vo}=Math;function Io(e,t,o){return Array.from({length:t-e+1}).map(((t,n)=>{const r=null===o?null:o[n+e];return{index:n+e,data:r}}))}function xo(e,t){return e&&e.column===t.column&&e.row===t.row}function To(e,t){return e&&e.width===t.width&&e.height===t.height}const wo=D((([{overscan:e,visibleRange:t,listBoundary:o},{scrollTop:n,viewportHeight:r,scrollBy:i,scrollTo:l,smoothScrollTargetReached:s,scrollContainerState:c,footerHeight:a,headerHeight:u},d,m,{propsReady:f,didMount:h},{windowViewportRect:g,useWindowScroll:I,customScrollParent:x,windowScrollContainerState:b,windowScrollTo:L},M])=>{const W=C(0),D=C(0),G=C(uo),N=C({height:0,width:0}),_=C({height:0,width:0}),U=S(),$=S(),j=C(0),K=C(null),q=C({row:0,column:0}),Y=S(),Z=S(),X=C(!1),J=C(0),Q=C(!0),ee=C(!1),te=C(!1);p(y(h,P(J),R((([e,t])=>!!t))),(()=>{v(Q,!1),v(D,0)})),p(y(V(h,Q,_,N,J,ee),R((([e,t,o,n,,r])=>e&&!t&&0!==o.height&&0!==n.height&&!r))),(([,,,,e])=>{v(ee,!0),Ke(1,(()=>{v(U,e)})),w(y(n),(()=>{v(o,[0,0]),v(Q,!0)}))})),T(y(Z,R((e=>null!=e&&e.scrollTop>0)),B(0)),D),p(y(h,P(Z),R((([,e])=>null!=e))),(([,e])=>{e&&(v(N,e.viewport),v(_,null==e?void 0:e.item),v(q,e.gap),e.scrollTop>0&&(v(X,!0),w(y(n,O(1)),(e=>{v(X,!1)})),v(l,{top:e.scrollTop})))})),T(y(N,k((({height:e})=>e))),r),T(y(V(A(N,To),A(_,To),A(q,((e,t)=>e&&e.column===t.column&&e.row===t.row)),A(n)),k((([e,t,o,n])=>({viewport:e,item:t,gap:o,scrollTop:n})))),Y),T(y(V(A(W),t,A(q,xo),A(_,To),A(N,To),A(K),A(D),A(X),A(Q),A(J)),R((([,,,,,,,e])=>!e)),k((([e,[t,o],n,r,i,l,s,,c,a])=>{const{row:u,column:d}=n,{height:m,width:f}=r,{width:h}=i;if(0===s&&(0===e||0===h))return uo;if(0===f){const t=qe(a,e);return function(e){return{...mo,items:e}}(Io(t,0===t?Math.max(s-1,0):t,l))}const g=Eo(h,f,d);let p,v;c?0===t&&0===o&&s>0?(p=0,v=s-1):(p=g*go((t+u)/(m+u)),v=g*ho((o+u)/(m+u))-1,v=po(e-1,vo(v,g-1)),p=po(v,vo(0,p))):(p=0,v=-1);const I=Io(p,v,l),{top:x,bottom:T}=So(i,n,r,I),w=ho(e/g);return{items:I,offsetTop:x,offsetBottom:w*m+(w-1)*u-T,top:x,bottom:T,itemHeight:m,itemWidth:f}}))),G),T(y(K,R((e=>null!==e)),k((e=>e.length))),W),T(y(V(N,_,G,q),R((([e,t,{items:o}])=>o.length>0&&0!==t.height&&0!==e.height)),k((([e,t,{items:o},n])=>{const{top:r,bottom:i}=So(e,n,t,o);return[r,i]})),z(et)),o);const oe=C(!1);T(y(n,P(oe),k((([e,t])=>t||0!==e))),oe);const ne=E(y(A(G),R((({items:e})=>e.length>0)),P(W,oe),R((([{items:e},t,o])=>o&&e[e.length-1].index===t-1)),k((([,e])=>e-1)),z())),re=E(y(A(G),R((({items:e})=>e.length>0&&0===e[0].index)),B(0),z())),ie=E(y(A(G),P(X),R((([{items:e},t])=>e.length>0&&!t)),k((([{items:e}])=>({startIndex:e[0].index,endIndex:e[e.length-1].index}))),z(tt),F(0)));T(ie,m.scrollSeekRangeChanged),T(y(U,P(N,_,W,q),k((([e,t,o,n,r])=>{const i=De(e),{align:l,behavior:s,offset:c}=i;let a=i.index;"LAST"===a&&(a=n-1),a=vo(0,a,po(n-1,a));let u=Co(t,r,o,a);return"end"===l?u=fo(u-t.height+o.height):"center"===l&&(u=fo(u-t.height/2+o.height/2)),c&&(u+=c),{top:u,behavior:s}}))),l);const le=H(y(G,k((e=>e.offsetBottom+e.bottom))),0);return T(y(g,k((e=>({width:e.visibleWidth,height:e.visibleHeight})))),N),{data:K,totalCount:W,viewportDimensions:N,itemDimensions:_,scrollTop:n,scrollHeight:$,overscan:e,scrollBy:i,scrollTo:l,scrollToIndex:U,smoothScrollTargetReached:s,windowViewportRect:g,windowScrollTo:L,useWindowScroll:I,customScrollParent:x,windowScrollContainerState:b,deviation:j,scrollContainerState:c,footerHeight:a,headerHeight:u,initialItemCount:D,gap:q,restoreStateFrom:Z,...m,initialTopMostItemIndex:J,horizontalDirection:te,gridState:G,totalListHeight:le,...d,startReached:re,endReached:ne,rangeChanged:ie,stateChanged:Y,propsReady:f,stateRestoreInProgress:X,...M}}),d(st,te,$e,ht,je,St,K));function So(e,t,o,n){const{height:r}=o;if(void 0===r||0===n.length)return{top:0,bottom:0};return{top:Co(e,t,o,n[0].index),bottom:Co(e,t,o,n[n.length-1].index)+r}}function Co(e,t,o,n){const r=Eo(e.width,o.width,t.column),i=go(n/r),l=i*o.height+vo(0,i-1)*t.row;return l>0?l+t.row:l}function Eo(e,t,o){return vo(1,go((e+o)/(go(t)+o)))}const Ho=D((([e,t])=>({...e,...t})),d(wo,D((()=>{const e=C((e=>`Item ${e}`)),t=C({}),o=C(null),n=C("virtuoso-grid-item"),r=C("virtuoso-grid-list"),i=C(Mt),l=C("div"),s=C(g),c=(e,o=null)=>H(y(t,k((t=>t[e])),z()),o);return{context:o,itemContent:e,components:t,computeItemKey:i,itemClassName:n,listClassName:r,headerFooterTag:l,scrollerRef:s,FooterComponent:c("Footer"),HeaderComponent:c("Header"),ListComponent:c("List","div"),ItemComponent:c("Item","div"),ScrollerComponent:c("Scroller","div"),ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}})))),yo=e.memo((function(){const t=Fo("gridState"),o=Fo("listClassName"),n=Fo("itemClassName"),r=Fo("itemContent"),i=Fo("computeItemKey"),l=Fo("isSeeking"),s=Oo("scrollHeight"),c=Fo("ItemComponent"),a=Fo("ListComponent"),u=Fo("ScrollSeekPlaceholder"),d=Fo("context"),m=Oo("itemDimensions"),f=Oo("gap"),h=Fo("log"),g=Fo("stateRestoreInProgress"),p=Y(e.useMemo((()=>e=>{const t=e.parentElement.parentElement.scrollHeight;s(t);const o=e.firstChild;if(o){const{width:e,height:t}=o.getBoundingClientRect();m({width:e,height:t})}f({row:Ao("row-gap",getComputedStyle(e).rowGap,h),column:Ao("column-gap",getComputedStyle(e).columnGap,h)})}),[s,m,f,h]),!0,!1);return g?null:e.createElement(a,{ref:p,className:o,...jt(a,d),style:{paddingTop:t.offsetTop,paddingBottom:t.offsetBottom},"data-testid":"virtuoso-item-list"},t.items.map((o=>{const s=i(o.index,o.data,d);return l?e.createElement(u,{key:s,...jt(u,d),index:o.index,height:t.itemHeight,width:t.itemWidth}):e.createElement(c,{...jt(c,d),className:n,"data-index":o.index,key:s},r(o.index,o.data,d))})))})),bo=e.memo((function(){const t=Fo("HeaderComponent"),o=Oo("headerHeight"),n=Fo("headerFooterTag"),r=Y(e.useMemo((()=>e=>o(J(e,"height"))),[o]),!0,!1),i=Fo("context");return t?e.createElement(n,{ref:r},e.createElement(t,jt(t,i))):null})),zo=e.memo((function(){const t=Fo("FooterComponent"),o=Oo("footerHeight"),n=Fo("headerFooterTag"),r=Y(e.useMemo((()=>e=>o(J(e,"height"))),[o]),!0,!1),i=Fo("context");return t?e.createElement(n,{ref:r},e.createElement(t,jt(t,i))):null})),Ro=({children:t})=>{const o=e.useContext(Ft),n=Oo("itemDimensions"),r=Oo("viewportDimensions"),i=Y(e.useMemo((()=>e=>{r(e.getBoundingClientRect())}),[r]),!0,!1);return e.useEffect((()=>{o&&(r({height:o.viewportHeight,width:o.viewportWidth}),n({height:o.itemHeight,width:o.itemWidth}))}),[o,r,n]),e.createElement("div",{style:Ut(!1),ref:i},t)},ko=({children:t})=>{const o=e.useContext(Ft),n=Oo("windowViewportRect"),r=Oo("itemDimensions"),i=Fo("customScrollParent"),l=Lt(n,i,!1);return e.useEffect((()=>{o&&(r({height:o.itemHeight,width:o.itemWidth}),n({offsetTop:0,visibleHeight:o.viewportHeight,visibleWidth:o.viewportWidth}))}),[o,n,r]),e.createElement("div",{ref:l,style:Ut(!1)},t)},Bo=e.memo((function({...t}){const o=Fo("useWindowScroll"),n=Fo("customScrollParent"),r=n||o?Wo:Po,i=n||o?ko:Ro;return e.createElement(r,{...t},e.createElement(i,null,e.createElement(bo,null),e.createElement(yo,null),e.createElement(zo,null)))})),{Component:Lo,usePublisher:Oo,useEmitterValue:Fo,useEmitter:Mo}=_(Ho,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged"}},Bo),Po=Zt({usePublisher:Oo,useEmitterValue:Fo,useEmitter:Mo}),Wo=Xt({usePublisher:Oo,useEmitterValue:Fo,useEmitter:Mo});function Ao(e,t,o){return"normal"===t||(null==t?void 0:t.endsWith("px"))||o(`${e} was not resolved to pixel value correctly`,t,$.WARN),"normal"===t?0:parseInt(null!=t?t:"0",10)}const Vo=Lo,Do=D((([e,t])=>({...e,...t})),d(zt,D((()=>{const t=C((t=>e.createElement("td",null,"Item $",t))),o=C(null),n=C(null),r=C(null),i=C({}),l=C(Mt),s=C(g),c=(e,t=null)=>H(y(i,k((t=>t[e])),z()),t);return{context:o,itemContent:t,fixedHeaderContent:n,fixedFooterContent:r,components:i,computeItemKey:l,scrollerRef:s,TableComponent:c("Table","table"),TableHeadComponent:c("TableHead","thead"),TableFooterComponent:c("TableFoot","tfoot"),TableBodyComponent:c("TableBody","tbody"),TableRowComponent:c("TableRow","tr"),ScrollerComponent:c("Scroller","div"),EmptyPlaceholder:c("EmptyPlaceholder"),ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),FillerRow:c("FillerRow")}})))),Go=({height:t})=>e.createElement("tr",null,e.createElement("td",{style:{height:t}})),No=({height:t})=>e.createElement("tr",null,e.createElement("td",{style:{height:t,padding:0,border:0}})),_o={overflowAnchor:"none"},Uo=e.memo((function(){const t=Zo("listState"),o=Yo("sizeRanges"),n=Zo("useWindowScroll"),r=Zo("customScrollParent"),i=Yo("windowScrollContainerState"),l=Yo("scrollContainerState"),s=r||n?i:l,c=Zo("itemContent"),a=Zo("trackItemSizes"),u=Zo("itemSize"),d=Zo("log"),{callbackRef:m,ref:f}=Z(o,u,a,s,d,void 0,r,!1,Zo("skipAnimationFrameInResizeObserver")),[h,g]=e.useState(0);Xo("deviation",(e=>{h!==e&&(f.current.style.marginTop=`${e}px`,g(e))}));const p=Zo("EmptyPlaceholder"),v=Zo("ScrollSeekPlaceholder")||Go,I=Zo("FillerRow")||No,x=Zo("TableBodyComponent"),T=Zo("TableRowComponent"),w=Zo("computeItemKey"),S=Zo("isSeeking"),C=Zo("paddingTopAddition"),E=Zo("firstItemIndex"),H=Zo("statefulTotalCount"),y=Zo("context");if(0===H&&p)return e.createElement(p,jt(p,y));const b=t.offsetTop+C+h,z=t.offsetBottom,R=b>0?e.createElement(I,{height:b,key:"padding-top",context:y}):null,k=z>0?e.createElement(I,{height:z,key:"padding-bottom",context:y}):null,B=t.items.map((t=>{const o=t.originalIndex,n=w(o+E,t.data,y);return S?e.createElement(v,{...jt(v,y),key:n,index:t.index,height:t.size,type:t.type||"item"}):e.createElement(T,{...jt(T,y),...Kt(T,t.data),key:n,"data-index":o,"data-known-size":t.size,"data-item-index":t.index,style:_o},c(t.index,t.data,y))}));return e.createElement(x,{ref:m,"data-testid":"virtuoso-item-list",...jt(x,y)},[R,...B,k])})),$o=({children:t})=>{const o=e.useContext(Ot),n=Yo("viewportHeight"),r=Yo("fixedItemHeight"),i=Y(e.useMemo((()=>l(n,(e=>J(e,"height")))),[n]),!0,Zo("skipAnimationFrameInResizeObserver"));return e.useEffect((()=>{o&&(n(o.viewportHeight),r(o.itemHeight))}),[o,n,r]),e.createElement("div",{style:Ut(!1),ref:i,"data-viewport-type":"element"},t)},jo=({children:t})=>{const o=e.useContext(Ot),n=Yo("windowViewportRect"),r=Yo("fixedItemHeight"),i=Zo("customScrollParent"),l=Lt(n,i,Zo("skipAnimationFrameInResizeObserver"));return e.useEffect((()=>{o&&(r(o.itemHeight),n({offsetTop:0,visibleHeight:o.viewportHeight,visibleWidth:100}))}),[o,n,r]),e.createElement("div",{ref:l,style:Ut(!1),"data-viewport-type":"window"},t)},Ko=e.memo((function(t){const o=Zo("useWindowScroll"),n=Zo("customScrollParent"),r=Yo("fixedHeaderHeight"),i=Yo("fixedFooterHeight"),s=Zo("fixedHeaderContent"),c=Zo("fixedFooterContent"),a=Zo("context"),u=Y(e.useMemo((()=>l(r,(e=>J(e,"height")))),[r]),!0,Zo("skipAnimationFrameInResizeObserver")),d=Y(e.useMemo((()=>l(i,(e=>J(e,"height")))),[i]),!0,Zo("skipAnimationFrameInResizeObserver")),m=n||o?Qo:Jo,f=n||o?jo:$o,h=Zo("TableComponent"),g=Zo("TableHeadComponent"),p=Zo("TableFooterComponent"),v=s?e.createElement(g,{key:"TableHead",style:{zIndex:2,position:"sticky",top:0},ref:u,...jt(g,a)},s()):null,I=c?e.createElement(p,{key:"TableFoot",style:{zIndex:1,position:"sticky",bottom:0},ref:d,...jt(p,a)},c()):null;return e.createElement(m,{...t},e.createElement(f,null,e.createElement(h,{style:{borderSpacing:0,overflowAnchor:"none"},...jt(h,a)},[v,e.createElement(Uo,{key:"TableBody"}),I])))})),{Component:qo,usePublisher:Yo,useEmitterValue:Zo,useEmitter:Xo}=_(Do,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",firstItemIndex:"firstItemIndex",itemContent:"itemContent",fixedHeaderContent:"fixedHeaderContent",fixedFooterContent:"fixedFooterContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",topItemCount:"topItemCount",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",groupCounts:"groupCounts",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Ko),Jo=Zt({usePublisher:Yo,useEmitterValue:Zo,useEmitter:Xo}),Qo=Xt({usePublisher:Yo,useEmitterValue:Zo,useEmitter:Xo}),en=qo;exports.GroupedVirtuoso=ao,exports.LogLevel=$,exports.TableVirtuoso=en,exports.Virtuoso=co,exports.VirtuosoGrid=Vo,exports.VirtuosoGridMockContext=Ft,exports.VirtuosoMockContext=Ot;
package/dist/index.d.ts CHANGED
@@ -181,16 +181,18 @@ export declare interface GridItemContent<D, C> {
181
181
  (index: number, data: D, context: C): React_2.ReactNode;
182
182
  }
183
183
 
184
- export declare interface GridItemProps {
184
+ /**
185
+ * Passed to the Components.Item custom component
186
+ */
187
+ export declare type GridItemProps = Pick<React_2.ComponentProps<'div'>, 'style' | 'children' | 'className'> & {
185
188
  'data-index': number;
186
- className?: string;
187
- }
189
+ } & React_2.RefAttributes<HTMLDivElement>;
188
190
 
189
191
  /**
190
192
  * Passed to the Components.List custom component
191
193
  */
192
194
  export declare type GridListProps = Pick<React_2.ComponentProps<'div'>, 'style' | 'children' | 'className'> & {
193
- 'data-test-id': string;
195
+ 'data-testid': string;
194
196
  } & React_2.RefAttributes<HTMLDivElement>;
195
197
 
196
198
  export declare type GridRootProps = Omit<React_2.HTMLProps<HTMLDivElement>, 'ref' | 'data'>;
@@ -258,7 +260,7 @@ export declare interface GroupedVirtuosoProps<D, C> extends Omit<VirtuosoProps<D
258
260
  * As an example, if you prepend 2 groups with 20 and 30 items each, the firstItemIndex should be decreased with 50.
259
261
  *
260
262
  * You can also prepend more items to the first group, for example:
261
- * \{ groupCounts: [20, 30], firstItemIndex: 1000 \} can become \{ groupCounts: [10, 30, 30], firstItemIndex: 980 \}
263
+ * `{ groupCounts: [20, 30], firstItemIndex: 1000 }` can become `{ groupCounts: [10, 30, 30], firstItemIndex: 980 }`
262
264
  *
263
265
  * Warning: the firstItemIndex should **be a positive number**, based on the total amount of items to be displayed.
264
266
  */
@@ -314,7 +316,7 @@ export declare type ListItem<D> = RecordItem<D> | GroupItem<D>;
314
316
  * Passed to the Components.List custom component
315
317
  */
316
318
  export declare type ListProps = Pick<React_2.ComponentProps<'div'>, 'style' | 'children'> & {
317
- 'data-test-id': string;
319
+ 'data-testid': string;
318
320
  } & React_2.RefAttributes<HTMLDivElement>;
319
321
 
320
322
  export declare interface ListRange {
@@ -363,7 +365,7 @@ export declare interface ScrollContainerState {
363
365
  * Passed to the Components.Scroller custom component
364
366
  */
365
367
  export declare type ScrollerProps = Pick<React_2.ComponentProps<'div'>, 'style' | 'children' | 'tabIndex'> & {
366
- 'data-test-id'?: string;
368
+ 'data-testid'?: string;
367
369
  'data-virtuoso-scroller'?: boolean;
368
370
  } & React_2.RefAttributes<HTMLDivElement>;
369
371
 
@@ -451,7 +453,7 @@ export declare interface StateSnapshot {
451
453
  * Passed to the Components.TableBody custom component
452
454
  */
453
455
  export declare type TableBodyProps = Pick<React_2.ComponentProps<'tbody'>, 'style' | 'children' | 'className'> & {
454
- 'data-test-id': string;
456
+ 'data-testid': string;
455
457
  } & React_2.RefAttributes<HTMLTableSectionElement>;
456
458
 
457
459
  /**
@@ -578,8 +580,9 @@ export declare interface TableVirtuosoProps<D, C> extends Omit<VirtuosoProps<D,
578
580
  };
579
581
  /**
580
582
  * Set to a value between 0 and totalCount - 1 to make the list start scrolled to that item.
583
+ * Pass in an object to achieve additional effects similar to `scrollToIndex`.
581
584
  */
582
- initialTopMostItemIndex?: number;
585
+ initialTopMostItemIndex?: number | IndexLocationWithAlign;
583
586
  /**
584
587
  * Set this value to offset the initial location of the list.
585
588
  * Warning: using this property will still run a render cycle at the scrollTop: 0 list window.
@@ -1088,6 +1091,16 @@ export declare interface VirtuosoProps<D, C> extends ListRootProps {
1088
1091
  * This is useful when you want to keep the list state when the component is unmounted and remounted, for example when navigating to a different page.
1089
1092
  */
1090
1093
  restoreStateFrom?: StateSnapshot;
1094
+ /**
1095
+ * When set, turns the scroller into a horizontal list. The items are positioned with `inline-block`.
1096
+ */
1097
+ horizontalDirection?: boolean;
1098
+ /**
1099
+ * When set, the resize observer used to measure the items will not use `requestAnimationFrame` to report the size changes.
1100
+ * Setting this to true will improve performance and reduce flickering, but will cause benign errors to be reported in the console if the size of the items changes while they are being measured.
1101
+ * See https://github.com/petyosi/react-virtuoso/issues/1049 for more information.
1102
+ */
1103
+ skipAnimationFrameInResizeObserver?: boolean;
1091
1104
  }
1092
1105
 
1093
1106
  export declare interface WindowViewportInfo {
package/dist/index.mjs CHANGED
@@ -492,17 +492,20 @@ const loggerSystem = system(
492
492
  [],
493
493
  { singleton: true }
494
494
  );
495
- function useSizeWithElRef(callback, enabled = true) {
495
+ function useSizeWithElRef(callback, enabled, skipAnimationFrame) {
496
496
  const ref = React.useRef(null);
497
497
  let callbackRef = (_el) => {
498
498
  };
499
499
  if (typeof ResizeObserver !== "undefined") {
500
500
  const observer = React.useMemo(() => {
501
501
  return new ResizeObserver((entries) => {
502
- const element = entries[0].target;
503
- if (element.offsetParent !== null) {
504
- callback(element);
505
- }
502
+ const code = () => {
503
+ const element = entries[0].target;
504
+ if (element.offsetParent !== null) {
505
+ callback(element);
506
+ }
507
+ };
508
+ skipAnimationFrame ? code() : requestAnimationFrame(code);
506
509
  });
507
510
  }, [callback]);
508
511
  callbackRef = (elRef) => {
@@ -519,34 +522,36 @@ function useSizeWithElRef(callback, enabled = true) {
519
522
  }
520
523
  return { ref, callbackRef };
521
524
  }
522
- function useSize(callback, enabled = true) {
523
- return useSizeWithElRef(callback, enabled).callbackRef;
525
+ function useSize(callback, enabled, skipAnimationFrame) {
526
+ return useSizeWithElRef(callback, enabled, skipAnimationFrame).callbackRef;
524
527
  }
525
- function useChangedListContentsSizes(callback, itemSize, enabled, scrollContainerStateCallback, log, gap, customScrollParent) {
528
+ function useChangedListContentsSizes(callback, itemSize, enabled, scrollContainerStateCallback, log, gap, customScrollParent, horizontalDirection, skipAnimationFrame) {
526
529
  const memoedCallback = React.useCallback(
527
530
  (el) => {
528
- const ranges = getChangedChildSizes(el.children, itemSize, "offsetHeight", log);
531
+ const ranges = getChangedChildSizes(el.children, itemSize, horizontalDirection ? "offsetWidth" : "offsetHeight", log);
529
532
  let scrollableElement = el.parentElement;
530
533
  while (!scrollableElement.dataset["virtuosoScroller"]) {
531
534
  scrollableElement = scrollableElement.parentElement;
532
535
  }
533
536
  const windowScrolling = scrollableElement.lastElementChild.dataset["viewportType"] === "window";
534
- const scrollTop = customScrollParent ? customScrollParent.scrollTop : windowScrolling ? window.pageYOffset || document.documentElement.scrollTop : scrollableElement.scrollTop;
535
- const scrollHeight = customScrollParent ? customScrollParent.scrollHeight : windowScrolling ? document.documentElement.scrollHeight : scrollableElement.scrollHeight;
536
- const viewportHeight = customScrollParent ? customScrollParent.offsetHeight : windowScrolling ? window.innerHeight : scrollableElement.offsetHeight;
537
+ const scrollTop = customScrollParent ? horizontalDirection ? customScrollParent.scrollLeft : customScrollParent.scrollTop : windowScrolling ? horizontalDirection ? window.pageXOffset || document.documentElement.scrollLeft : window.pageYOffset || document.documentElement.scrollTop : horizontalDirection ? scrollableElement.scrollLeft : scrollableElement.scrollTop;
538
+ const scrollHeight = customScrollParent ? horizontalDirection ? customScrollParent.scrollWidth : customScrollParent.scrollHeight : windowScrolling ? horizontalDirection ? document.documentElement.scrollWidth : document.documentElement.scrollHeight : horizontalDirection ? scrollableElement.scrollWidth : scrollableElement.scrollHeight;
539
+ const viewportHeight = customScrollParent ? horizontalDirection ? customScrollParent.offsetWidth : customScrollParent.offsetHeight : windowScrolling ? horizontalDirection ? window.innerWidth : window.innerHeight : horizontalDirection ? scrollableElement.offsetWidth : scrollableElement.offsetHeight;
537
540
  scrollContainerStateCallback({
538
541
  scrollTop: Math.max(scrollTop, 0),
539
542
  scrollHeight,
540
543
  viewportHeight
541
544
  });
542
- gap == null ? void 0 : gap(resolveGapValue$1("row-gap", getComputedStyle(el).rowGap, log));
545
+ gap == null ? void 0 : gap(
546
+ horizontalDirection ? resolveGapValue$1("column-gap", getComputedStyle(el).columnGap, log) : resolveGapValue$1("row-gap", getComputedStyle(el).rowGap, log)
547
+ );
543
548
  if (ranges !== null) {
544
549
  callback(ranges);
545
550
  }
546
551
  },
547
552
  [callback, itemSize, log, gap, customScrollParent, scrollContainerStateCallback]
548
553
  );
549
- return useSizeWithElRef(memoedCallback, enabled);
554
+ return useSizeWithElRef(memoedCallback, enabled, skipAnimationFrame);
550
555
  }
551
556
  function getChangedChildSizes(children, itemSize, field, log) {
552
557
  const length = children.length;
@@ -592,7 +597,7 @@ function correctItemSize(el, dimension) {
592
597
  function approximatelyEqual(num1, num2) {
593
598
  return Math.abs(num1 - num2) < 1.01;
594
599
  }
595
- function useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, scrollerElement, scrollerRefCallback = noop, customScrollParent) {
600
+ function useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, scrollerElement, scrollerRefCallback = noop, customScrollParent, horizontalDirection) {
596
601
  const scrollerRef = React.useRef(null);
597
602
  const scrollTopTarget = React.useRef(null);
598
603
  const timeoutRef = React.useRef(null);
@@ -600,9 +605,9 @@ function useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, s
600
605
  (ev) => {
601
606
  const el = ev.target;
602
607
  const windowScroll = el === window || el === document;
603
- const scrollTop = windowScroll ? window.pageYOffset || document.documentElement.scrollTop : el.scrollTop;
604
- const scrollHeight = windowScroll ? document.documentElement.scrollHeight : el.scrollHeight;
605
- const viewportHeight = windowScroll ? window.innerHeight : el.offsetHeight;
608
+ const scrollTop = horizontalDirection ? windowScroll ? window.pageXOffset || document.documentElement.scrollLeft : el.scrollLeft : windowScroll ? window.pageYOffset || document.documentElement.scrollTop : el.scrollTop;
609
+ const scrollHeight = horizontalDirection ? windowScroll ? document.documentElement.scrollWidth : el.scrollWidth : windowScroll ? document.documentElement.scrollHeight : el.scrollHeight;
610
+ const viewportHeight = horizontalDirection ? windowScroll ? window.innerWidth : el.offsetWidth : windowScroll ? window.innerHeight : el.offsetHeight;
606
611
  const call2 = () => {
607
612
  scrollContainerStateCallback({
608
613
  scrollTop: Math.max(scrollTop, 0),
@@ -640,7 +645,7 @@ function useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, s
640
645
  }, [scrollerRef, handler, scrollerElement, scrollerRefCallback, customScrollParent]);
641
646
  function scrollToCallback(location) {
642
647
  const scrollerElement2 = scrollerRef.current;
643
- if (!scrollerElement2 || "offsetHeight" in scrollerElement2 && scrollerElement2.offsetHeight === 0) {
648
+ if (!scrollerElement2 || (horizontalDirection ? "offsetWidth" in scrollerElement2 && scrollerElement2.offsetWidth === 0 : "offsetHeight" in scrollerElement2 && scrollerElement2.offsetHeight === 0)) {
644
649
  return;
645
650
  }
646
651
  const isSmooth = location.behavior === "smooth";
@@ -648,13 +653,16 @@ function useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, s
648
653
  let scrollHeight;
649
654
  let scrollTop;
650
655
  if (scrollerElement2 === window) {
651
- scrollHeight = Math.max(correctItemSize(document.documentElement, "height"), document.documentElement.scrollHeight);
652
- offsetHeight = window.innerHeight;
653
- scrollTop = document.documentElement.scrollTop;
656
+ scrollHeight = Math.max(
657
+ correctItemSize(document.documentElement, horizontalDirection ? "width" : "height"),
658
+ horizontalDirection ? document.documentElement.scrollWidth : document.documentElement.scrollHeight
659
+ );
660
+ offsetHeight = horizontalDirection ? window.innerWidth : window.innerHeight;
661
+ scrollTop = horizontalDirection ? document.documentElement.scrollLeft : document.documentElement.scrollTop;
654
662
  } else {
655
- scrollHeight = scrollerElement2.scrollHeight;
656
- offsetHeight = correctItemSize(scrollerElement2, "height");
657
- scrollTop = scrollerElement2.scrollTop;
663
+ scrollHeight = scrollerElement2[horizontalDirection ? "scrollWidth" : "scrollHeight"];
664
+ offsetHeight = correctItemSize(scrollerElement2, horizontalDirection ? "width" : "height");
665
+ scrollTop = scrollerElement2[horizontalDirection ? "scrollLeft" : "scrollTop"];
658
666
  }
659
667
  const maxScrollTop = scrollHeight - offsetHeight;
660
668
  location.top = Math.ceil(Math.max(Math.min(maxScrollTop, location.top), 0));
@@ -678,9 +686,15 @@ function useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, s
678
686
  } else {
679
687
  scrollTopTarget.current = null;
680
688
  }
689
+ if (horizontalDirection) {
690
+ location = { left: location.top, behavior: location.behavior };
691
+ }
681
692
  scrollerElement2.scrollTo(location);
682
693
  }
683
694
  function scrollByCallback(location) {
695
+ if (horizontalDirection) {
696
+ location = { left: location.top, behavior: location.behavior };
697
+ }
684
698
  scrollerRef.current.scrollBy(location);
685
699
  }
686
700
  return { scrollerRef, scrollByCallback, scrollToCallback };
@@ -701,6 +715,8 @@ const domIOSystem = system(
701
715
  const scrollTo = stream();
702
716
  const scrollBy = stream();
703
717
  const scrollingInProgress = statefulStream(false);
718
+ const horizontalDirection = statefulStream(false);
719
+ const skipAnimationFrameInResizeObserver = statefulStream(false);
704
720
  connect(
705
721
  pipe(
706
722
  scrollContainerState,
@@ -727,6 +743,8 @@ const domIOSystem = system(
727
743
  footerHeight,
728
744
  scrollHeight,
729
745
  smoothScrollTargetReached,
746
+ horizontalDirection,
747
+ skipAnimationFrameInResizeObserver,
730
748
  // signals
731
749
  scrollTo,
732
750
  scrollBy,
@@ -1853,7 +1871,7 @@ const initialTopMostItemIndexSystem = system(
1853
1871
  handleNext(scrollTargetReached, () => {
1854
1872
  publish(initialItemFinalLocationReached, true);
1855
1873
  });
1856
- skipFrames(3, () => {
1874
+ skipFrames(4, () => {
1857
1875
  handleNext(scrollTop, () => {
1858
1876
  publish(scrolledToInitialItem, true);
1859
1877
  });
@@ -2824,7 +2842,7 @@ const scrollIntoViewSystem = system(
2824
2842
  const stateLoadSystem = system(
2825
2843
  ([
2826
2844
  { sizes, sizeRanges },
2827
- { scrollTop },
2845
+ { scrollTop, headerHeight },
2828
2846
  { initialTopMostItemIndex },
2829
2847
  { didMount },
2830
2848
  { useWindowScroll, windowScrollContainerState, windowViewportRect }
@@ -2836,12 +2854,16 @@ const stateLoadSystem = system(
2836
2854
  connect(windowScrollContainerState, statefulWindowScrollContainerState);
2837
2855
  connect(windowViewportRect, statefulWindowViewportRect);
2838
2856
  subscribe(
2839
- pipe(getState, withLatestFrom(sizes, scrollTop, useWindowScroll, statefulWindowScrollContainerState, statefulWindowViewportRect)),
2840
- ([callback, sizes2, scrollTop2, useWindowScroll2, windowScrollContainerState2, windowViewportRect2]) => {
2857
+ pipe(
2858
+ getState,
2859
+ withLatestFrom(sizes, scrollTop, useWindowScroll, statefulWindowScrollContainerState, statefulWindowViewportRect, headerHeight)
2860
+ ),
2861
+ ([callback, sizes2, scrollTop2, useWindowScroll2, windowScrollContainerState2, windowViewportRect2, headerHeight2]) => {
2841
2862
  const ranges = sizeTreeToRanges(sizes2.sizeTree);
2842
2863
  if (useWindowScroll2 && windowScrollContainerState2 !== null && windowViewportRect2 !== null) {
2843
2864
  scrollTop2 = windowScrollContainerState2.scrollTop - windowViewportRect2.offsetTop;
2844
2865
  }
2866
+ scrollTop2 -= headerHeight2;
2845
2867
  callback({ ranges, scrollTop: scrollTop2 });
2846
2868
  }
2847
2869
  );
@@ -2998,7 +3020,7 @@ const positionStickyCssValue = simpleMemoize(() => {
2998
3020
  node.style.position = WEBKIT_STICKY;
2999
3021
  return node.style.position === WEBKIT_STICKY ? WEBKIT_STICKY : STICKY;
3000
3022
  });
3001
- function useWindowViewportRectRef(callback, customScrollParent) {
3023
+ function useWindowViewportRectRef(callback, customScrollParent, skipAnimationFrame) {
3002
3024
  const viewportInfo = React.useRef(null);
3003
3025
  const calculateInfo = React.useCallback(
3004
3026
  (element) => {
@@ -3026,14 +3048,16 @@ function useWindowViewportRectRef(callback, customScrollParent) {
3026
3048
  },
3027
3049
  [callback, customScrollParent]
3028
3050
  );
3029
- const { callbackRef, ref } = useSizeWithElRef(calculateInfo);
3051
+ const { callbackRef, ref } = useSizeWithElRef(calculateInfo, true, skipAnimationFrame);
3030
3052
  const scrollAndResizeEventHandler = React.useCallback(() => {
3031
3053
  calculateInfo(ref.current);
3032
3054
  }, [calculateInfo, ref]);
3033
3055
  React.useEffect(() => {
3034
3056
  if (customScrollParent) {
3035
3057
  customScrollParent.addEventListener("scroll", scrollAndResizeEventHandler);
3036
- const observer = new ResizeObserver(scrollAndResizeEventHandler);
3058
+ const observer = new ResizeObserver(() => {
3059
+ requestAnimationFrame(scrollAndResizeEventHandler);
3060
+ });
3037
3061
  observer.observe(customScrollParent);
3038
3062
  return () => {
3039
3063
  customScrollParent.removeEventListener("scroll", scrollAndResizeEventHandler);
@@ -3098,6 +3122,7 @@ const combinedSystem$2 = /* @__PURE__ */ system(([listSystem2, propsSystem]) =>
3098
3122
  const DefaultScrollSeekPlaceholder$1 = ({ height }) => /* @__PURE__ */ React.createElement("div", { style: { height } });
3099
3123
  const GROUP_STYLE = { position: positionStickyCssValue(), zIndex: 1, overflowAnchor: "none" };
3100
3124
  const ITEM_STYLE$1 = { overflowAnchor: "none" };
3125
+ const HORIZONTAL_ITEM_STYLE = { ...ITEM_STYLE$1, display: "inline-block", height: "100%" };
3101
3126
  const Items$1 = /* @__PURE__ */ React.memo(function VirtuosoItems({ showTopList = false }) {
3102
3127
  const listState = useEmitterValue$2("listState");
3103
3128
  const sizeRanges = usePublisher$2("sizeRanges");
@@ -3113,6 +3138,7 @@ const Items$1 = /* @__PURE__ */ React.memo(function VirtuosoItems({ showTopList
3113
3138
  const itemSize = useEmitterValue$2("itemSize");
3114
3139
  const log = useEmitterValue$2("log");
3115
3140
  const listGap = usePublisher$2("gap");
3141
+ const horizontalDirection = useEmitterValue$2("horizontalDirection");
3116
3142
  const { callbackRef } = useChangedListContentsSizes(
3117
3143
  sizeRanges,
3118
3144
  itemSize,
@@ -3120,7 +3146,9 @@ const Items$1 = /* @__PURE__ */ React.memo(function VirtuosoItems({ showTopList
3120
3146
  showTopList ? noop : scrollContainerStateCallback,
3121
3147
  log,
3122
3148
  listGap,
3123
- customScrollParent
3149
+ customScrollParent,
3150
+ horizontalDirection,
3151
+ useEmitterValue$2("skipAnimationFrameInResizeObserver")
3124
3152
  );
3125
3153
  const [deviation, setDeviation] = React.useState(0);
3126
3154
  useEmitter$2("deviation", (value) => {
@@ -3140,9 +3168,18 @@ const Items$1 = /* @__PURE__ */ React.memo(function VirtuosoItems({ showTopList
3140
3168
  const initialItemFinalLocationReached = useEmitterValue$2("initialItemFinalLocationReached");
3141
3169
  const containerStyle = showTopList ? {} : {
3142
3170
  boxSizing: "border-box",
3143
- paddingTop: listState.offsetTop,
3144
- paddingBottom: listState.offsetBottom,
3145
- marginTop: deviation !== 0 ? deviation : alignToBottom ? "auto" : 0,
3171
+ ...horizontalDirection ? {
3172
+ whiteSpace: "nowrap",
3173
+ display: "inline-block",
3174
+ height: "100%",
3175
+ paddingLeft: listState.offsetTop,
3176
+ paddingRight: listState.offsetBottom,
3177
+ marginLeft: deviation !== 0 ? deviation : alignToBottom ? "auto" : 0
3178
+ } : {
3179
+ marginTop: deviation !== 0 ? deviation : alignToBottom ? "auto" : 0,
3180
+ paddingTop: listState.offsetTop,
3181
+ paddingBottom: listState.offsetBottom
3182
+ },
3146
3183
  ...initialItemFinalLocationReached ? {} : { visibility: "hidden" }
3147
3184
  };
3148
3185
  if (!showTopList && listState.totalCount === 0 && EmptyPlaceholder) {
@@ -3154,7 +3191,7 @@ const Items$1 = /* @__PURE__ */ React.memo(function VirtuosoItems({ showTopList
3154
3191
  ...contextPropIfNotDomElement(ListComponent, context),
3155
3192
  ref: callbackRef,
3156
3193
  style: containerStyle,
3157
- "data-test-id": showTopList ? "virtuoso-top-item-list" : "virtuoso-item-list"
3194
+ "data-testid": showTopList ? "virtuoso-top-item-list" : "virtuoso-item-list"
3158
3195
  },
3159
3196
  (showTopList ? listState.topItems : listState.items).map((item) => {
3160
3197
  const index = item.originalIndex;
@@ -3193,7 +3230,7 @@ const Items$1 = /* @__PURE__ */ React.memo(function VirtuosoItems({ showTopList
3193
3230
  "data-known-size": item.size,
3194
3231
  "data-item-index": item.index,
3195
3232
  "data-item-group-index": item.groupIndex,
3196
- style: ITEM_STYLE$1
3233
+ style: horizontalDirection ? HORIZONTAL_ITEM_STYLE : ITEM_STYLE$1
3197
3234
  },
3198
3235
  hasGroups2 ? itemContent(item.index, item.groupIndex, item.data, context) : itemContent(item.index, item.data, context)
3199
3236
  );
@@ -3208,6 +3245,11 @@ const scrollerStyle = {
3208
3245
  position: "relative",
3209
3246
  WebkitOverflowScrolling: "touch"
3210
3247
  };
3248
+ const horizontalScrollerStyle = {
3249
+ outline: "none",
3250
+ overflowX: "auto",
3251
+ position: "relative"
3252
+ };
3211
3253
  const viewportStyle = (alignToBottom) => ({
3212
3254
  width: "100%",
3213
3255
  height: "100%",
@@ -3234,7 +3276,11 @@ const Header$1 = /* @__PURE__ */ React.memo(function VirtuosoHeader() {
3234
3276
  const Header2 = useEmitterValue$2("HeaderComponent");
3235
3277
  const headerHeight = usePublisher$2("headerHeight");
3236
3278
  const headerFooterTag = useEmitterValue$2("headerFooterTag");
3237
- const ref = useSize((el) => headerHeight(correctItemSize(el, "height")));
3279
+ const ref = useSize(
3280
+ React.useMemo(() => (el) => headerHeight(correctItemSize(el, "height")), [headerHeight]),
3281
+ true,
3282
+ useEmitterValue$2("skipAnimationFrameInResizeObserver")
3283
+ );
3238
3284
  const context = useEmitterValue$2("context");
3239
3285
  return Header2 ? React.createElement(headerFooterTag, { ref }, React.createElement(Header2, contextPropIfNotDomElement(Header2, context))) : null;
3240
3286
  });
@@ -3242,7 +3288,11 @@ const Footer$1 = /* @__PURE__ */ React.memo(function VirtuosoFooter() {
3242
3288
  const Footer2 = useEmitterValue$2("FooterComponent");
3243
3289
  const footerHeight = usePublisher$2("footerHeight");
3244
3290
  const headerFooterTag = useEmitterValue$2("headerFooterTag");
3245
- const ref = useSize((el) => footerHeight(correctItemSize(el, "height")));
3291
+ const ref = useSize(
3292
+ React.useMemo(() => (el) => footerHeight(correctItemSize(el, "height")), [footerHeight]),
3293
+ true,
3294
+ useEmitterValue$2("skipAnimationFrameInResizeObserver")
3295
+ );
3246
3296
  const context = useEmitterValue$2("context");
3247
3297
  return Footer2 ? React.createElement(headerFooterTag, { ref }, React.createElement(Footer2, contextPropIfNotDomElement(Footer2, context))) : null;
3248
3298
  });
@@ -3253,20 +3303,24 @@ function buildScroller({ usePublisher: usePublisher2, useEmitter: useEmitter2, u
3253
3303
  const smoothScrollTargetReached = usePublisher2("smoothScrollTargetReached");
3254
3304
  const scrollerRefCallback = useEmitterValue2("scrollerRef");
3255
3305
  const context = useEmitterValue2("context");
3306
+ const horizontalDirection = useEmitterValue2("horizontalDirection") || false;
3256
3307
  const { scrollerRef, scrollByCallback, scrollToCallback } = useScrollTop(
3257
3308
  scrollContainerStateCallback,
3258
3309
  smoothScrollTargetReached,
3259
3310
  ScrollerComponent,
3260
- scrollerRefCallback
3311
+ scrollerRefCallback,
3312
+ void 0,
3313
+ horizontalDirection
3261
3314
  );
3262
3315
  useEmitter2("scrollTo", scrollToCallback);
3263
3316
  useEmitter2("scrollBy", scrollByCallback);
3317
+ const defaultStyle = horizontalDirection ? horizontalScrollerStyle : scrollerStyle;
3264
3318
  return React.createElement(
3265
3319
  ScrollerComponent,
3266
3320
  {
3267
3321
  ref: scrollerRef,
3268
- style: { ...scrollerStyle, ...style },
3269
- "data-test-id": "virtuoso-scroller",
3322
+ style: { ...defaultStyle, ...style },
3323
+ "data-testid": "virtuoso-scroller",
3270
3324
  "data-virtuoso-scroller": true,
3271
3325
  tabIndex: 0,
3272
3326
  ...props,
@@ -3319,7 +3373,12 @@ const Viewport$2 = ({ children }) => {
3319
3373
  const viewportHeight = usePublisher$2("viewportHeight");
3320
3374
  const fixedItemHeight = usePublisher$2("fixedItemHeight");
3321
3375
  const alignToBottom = useEmitterValue$2("alignToBottom");
3322
- const viewportRef = useSize(compose(viewportHeight, (el) => correctItemSize(el, "height")));
3376
+ const horizontalDirection = useEmitterValue$2("horizontalDirection");
3377
+ const viewportSizeCallbackMemo = React.useMemo(
3378
+ () => compose(viewportHeight, (el) => correctItemSize(el, horizontalDirection ? "width" : "height")),
3379
+ [viewportHeight, horizontalDirection]
3380
+ );
3381
+ const viewportRef = useSize(viewportSizeCallbackMemo, true, useEmitterValue$2("skipAnimationFrameInResizeObserver"));
3323
3382
  React.useEffect(() => {
3324
3383
  if (ctx) {
3325
3384
  viewportHeight(ctx.viewportHeight);
@@ -3333,7 +3392,11 @@ const WindowViewport$2 = ({ children }) => {
3333
3392
  const windowViewportRect = usePublisher$2("windowViewportRect");
3334
3393
  const fixedItemHeight = usePublisher$2("fixedItemHeight");
3335
3394
  const customScrollParent = useEmitterValue$2("customScrollParent");
3336
- const viewportRef = useWindowViewportRectRef(windowViewportRect, customScrollParent);
3395
+ const viewportRef = useWindowViewportRectRef(
3396
+ windowViewportRect,
3397
+ customScrollParent,
3398
+ useEmitterValue$2("skipAnimationFrameInResizeObserver")
3399
+ );
3337
3400
  const alignToBottom = useEmitterValue$2("alignToBottom");
3338
3401
  React.useEffect(() => {
3339
3402
  if (ctx) {
@@ -3396,7 +3459,9 @@ const {
3396
3459
  useWindowScroll: "useWindowScroll",
3397
3460
  customScrollParent: "customScrollParent",
3398
3461
  scrollerRef: "scrollerRef",
3399
- logLevel: "logLevel"
3462
+ logLevel: "logLevel",
3463
+ horizontalDirection: "horizontalDirection",
3464
+ skipAnimationFrameInResizeObserver: "skipAnimationFrameInResizeObserver"
3400
3465
  },
3401
3466
  methods: {
3402
3467
  scrollToIndex: "scrollToIndex",
@@ -3487,6 +3552,7 @@ const gridSystem = /* @__PURE__ */ system(
3487
3552
  const initialTopMostItemIndex = statefulStream(0);
3488
3553
  const scrolledToInitialItem = statefulStream(true);
3489
3554
  const scrollScheduled = statefulStream(false);
3555
+ const horizontalDirection = statefulStream(false);
3490
3556
  subscribe(
3491
3557
  pipe(
3492
3558
  didMount,
@@ -3775,6 +3841,7 @@ const gridSystem = /* @__PURE__ */ system(
3775
3841
  restoreStateFrom,
3776
3842
  ...scrollSeek,
3777
3843
  initialTopMostItemIndex,
3844
+ horizontalDirection,
3778
3845
  // output
3779
3846
  gridState,
3780
3847
  totalListHeight,
@@ -3863,19 +3930,26 @@ const GridItems = /* @__PURE__ */ React.memo(function GridItems2() {
3863
3930
  const gridGap = usePublisher$1("gap");
3864
3931
  const log = useEmitterValue$1("log");
3865
3932
  const stateRestoreInProgress = useEmitterValue$1("stateRestoreInProgress");
3866
- const listRef = useSize((el) => {
3867
- const scrollHeight = el.parentElement.parentElement.scrollHeight;
3868
- scrollHeightCallback(scrollHeight);
3869
- const firstItem = el.firstChild;
3870
- if (firstItem) {
3871
- const { width, height } = firstItem.getBoundingClientRect();
3872
- itemDimensions({ width, height });
3873
- }
3874
- gridGap({
3875
- row: resolveGapValue("row-gap", getComputedStyle(el).rowGap, log),
3876
- column: resolveGapValue("column-gap", getComputedStyle(el).columnGap, log)
3877
- });
3878
- });
3933
+ const listRef = useSize(
3934
+ React.useMemo(
3935
+ () => (el) => {
3936
+ const scrollHeight = el.parentElement.parentElement.scrollHeight;
3937
+ scrollHeightCallback(scrollHeight);
3938
+ const firstItem = el.firstChild;
3939
+ if (firstItem) {
3940
+ const { width, height } = firstItem.getBoundingClientRect();
3941
+ itemDimensions({ width, height });
3942
+ }
3943
+ gridGap({
3944
+ row: resolveGapValue("row-gap", getComputedStyle(el).rowGap, log),
3945
+ column: resolveGapValue("column-gap", getComputedStyle(el).columnGap, log)
3946
+ });
3947
+ },
3948
+ [scrollHeightCallback, itemDimensions, gridGap, log]
3949
+ ),
3950
+ true,
3951
+ false
3952
+ );
3879
3953
  if (stateRestoreInProgress) {
3880
3954
  return null;
3881
3955
  }
@@ -3886,7 +3960,7 @@ const GridItems = /* @__PURE__ */ React.memo(function GridItems2() {
3886
3960
  className: listClassName,
3887
3961
  ...contextPropIfNotDomElement(ListComponent, context),
3888
3962
  style: { paddingTop: gridState.offsetTop, paddingBottom: gridState.offsetBottom },
3889
- "data-test-id": "virtuoso-item-list"
3963
+ "data-testid": "virtuoso-item-list"
3890
3964
  },
3891
3965
  gridState.items.map((item) => {
3892
3966
  const key = computeItemKey(item.index, item.data, context);
@@ -3908,7 +3982,11 @@ const Header = React.memo(function VirtuosoHeader2() {
3908
3982
  const Header2 = useEmitterValue$1("HeaderComponent");
3909
3983
  const headerHeight = usePublisher$1("headerHeight");
3910
3984
  const headerFooterTag = useEmitterValue$1("headerFooterTag");
3911
- const ref = useSize((el) => headerHeight(correctItemSize(el, "height")));
3985
+ const ref = useSize(
3986
+ React.useMemo(() => (el) => headerHeight(correctItemSize(el, "height")), [headerHeight]),
3987
+ true,
3988
+ false
3989
+ );
3912
3990
  const context = useEmitterValue$1("context");
3913
3991
  return Header2 ? React.createElement(headerFooterTag, { ref }, React.createElement(Header2, contextPropIfNotDomElement(Header2, context))) : null;
3914
3992
  });
@@ -3916,7 +3994,11 @@ const Footer = React.memo(function VirtuosoGridFooter() {
3916
3994
  const Footer2 = useEmitterValue$1("FooterComponent");
3917
3995
  const footerHeight = usePublisher$1("footerHeight");
3918
3996
  const headerFooterTag = useEmitterValue$1("headerFooterTag");
3919
- const ref = useSize((el) => footerHeight(correctItemSize(el, "height")));
3997
+ const ref = useSize(
3998
+ React.useMemo(() => (el) => footerHeight(correctItemSize(el, "height")), [footerHeight]),
3999
+ true,
4000
+ false
4001
+ );
3920
4002
  const context = useEmitterValue$1("context");
3921
4003
  return Footer2 ? React.createElement(headerFooterTag, { ref }, React.createElement(Footer2, contextPropIfNotDomElement(Footer2, context))) : null;
3922
4004
  });
@@ -3924,9 +4006,16 @@ const Viewport$1 = ({ children }) => {
3924
4006
  const ctx = React.useContext(VirtuosoGridMockContext);
3925
4007
  const itemDimensions = usePublisher$1("itemDimensions");
3926
4008
  const viewportDimensions = usePublisher$1("viewportDimensions");
3927
- const viewportRef = useSize((el) => {
3928
- viewportDimensions(el.getBoundingClientRect());
3929
- });
4009
+ const viewportRef = useSize(
4010
+ React.useMemo(
4011
+ () => (el) => {
4012
+ viewportDimensions(el.getBoundingClientRect());
4013
+ },
4014
+ [viewportDimensions]
4015
+ ),
4016
+ true,
4017
+ false
4018
+ );
3930
4019
  React.useEffect(() => {
3931
4020
  if (ctx) {
3932
4021
  viewportDimensions({ height: ctx.viewportHeight, width: ctx.viewportWidth });
@@ -3940,7 +4029,7 @@ const WindowViewport$1 = ({ children }) => {
3940
4029
  const windowViewportRect = usePublisher$1("windowViewportRect");
3941
4030
  const itemDimensions = usePublisher$1("itemDimensions");
3942
4031
  const customScrollParent = useEmitterValue$1("customScrollParent");
3943
- const viewportRef = useWindowViewportRectRef(windowViewportRect, customScrollParent);
4032
+ const viewportRef = useWindowViewportRectRef(windowViewportRect, customScrollParent, false);
3944
4033
  React.useEffect(() => {
3945
4034
  if (ctx) {
3946
4035
  itemDimensions({ height: ctx.itemHeight, width: ctx.itemWidth });
@@ -4075,7 +4164,9 @@ const Items = /* @__PURE__ */ React.memo(function VirtuosoItems2() {
4075
4164
  scrollContainerStateCallback,
4076
4165
  log,
4077
4166
  void 0,
4078
- customScrollParent
4167
+ customScrollParent,
4168
+ false,
4169
+ useEmitterValue("skipAnimationFrameInResizeObserver")
4079
4170
  );
4080
4171
  const [deviation, setDeviation] = React.useState(0);
4081
4172
  useEmitter("deviation", (value) => {
@@ -4130,7 +4221,7 @@ const Items = /* @__PURE__ */ React.memo(function VirtuosoItems2() {
4130
4221
  });
4131
4222
  return React.createElement(
4132
4223
  TableBodyComponent,
4133
- { ref: callbackRef, "data-test-id": "virtuoso-item-list", ...contextPropIfNotDomElement(TableBodyComponent, context) },
4224
+ { ref: callbackRef, "data-testid": "virtuoso-item-list", ...contextPropIfNotDomElement(TableBodyComponent, context) },
4134
4225
  [paddingTopEl, ...items, paddingBottomEl]
4135
4226
  );
4136
4227
  });
@@ -4138,7 +4229,11 @@ const Viewport = ({ children }) => {
4138
4229
  const ctx = React.useContext(VirtuosoMockContext);
4139
4230
  const viewportHeight = usePublisher("viewportHeight");
4140
4231
  const fixedItemHeight = usePublisher("fixedItemHeight");
4141
- const viewportRef = useSize(compose(viewportHeight, (el) => correctItemSize(el, "height")));
4232
+ const viewportRef = useSize(
4233
+ React.useMemo(() => compose(viewportHeight, (el) => correctItemSize(el, "height")), [viewportHeight]),
4234
+ true,
4235
+ useEmitterValue("skipAnimationFrameInResizeObserver")
4236
+ );
4142
4237
  React.useEffect(() => {
4143
4238
  if (ctx) {
4144
4239
  viewportHeight(ctx.viewportHeight);
@@ -4152,7 +4247,11 @@ const WindowViewport = ({ children }) => {
4152
4247
  const windowViewportRect = usePublisher("windowViewportRect");
4153
4248
  const fixedItemHeight = usePublisher("fixedItemHeight");
4154
4249
  const customScrollParent = useEmitterValue("customScrollParent");
4155
- const viewportRef = useWindowViewportRectRef(windowViewportRect, customScrollParent);
4250
+ const viewportRef = useWindowViewportRectRef(
4251
+ windowViewportRect,
4252
+ customScrollParent,
4253
+ useEmitterValue("skipAnimationFrameInResizeObserver")
4254
+ );
4156
4255
  React.useEffect(() => {
4157
4256
  if (ctx) {
4158
4257
  fixedItemHeight(ctx.itemHeight);
@@ -4169,8 +4268,16 @@ const TableRoot = /* @__PURE__ */ React.memo(function TableVirtuosoRoot(props) {
4169
4268
  const fixedHeaderContent = useEmitterValue("fixedHeaderContent");
4170
4269
  const fixedFooterContent = useEmitterValue("fixedFooterContent");
4171
4270
  const context = useEmitterValue("context");
4172
- const theadRef = useSize(compose(fixedHeaderHeight, (el) => correctItemSize(el, "height")));
4173
- const tfootRef = useSize(compose(fixedFooterHeight, (el) => correctItemSize(el, "height")));
4271
+ const theadRef = useSize(
4272
+ React.useMemo(() => compose(fixedHeaderHeight, (el) => correctItemSize(el, "height")), [fixedHeaderHeight]),
4273
+ true,
4274
+ useEmitterValue("skipAnimationFrameInResizeObserver")
4275
+ );
4276
+ const tfootRef = useSize(
4277
+ React.useMemo(() => compose(fixedFooterHeight, (el) => correctItemSize(el, "height")), [fixedFooterHeight]),
4278
+ true,
4279
+ useEmitterValue("skipAnimationFrameInResizeObserver")
4280
+ );
4174
4281
  const TheScroller = customScrollParent || useWindowScroll ? WindowScroller : Scroller;
4175
4282
  const TheViewport = customScrollParent || useWindowScroll ? WindowViewport : Viewport;
4176
4283
  const TheTable = useEmitterValue("TableComponent");
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "react-virtuoso",
3
3
  "author": "Petyo Ivanov",
4
4
  "sideEffects": false,
5
- "version": "4.8.0-development",
5
+ "version": "4.9.0",
6
6
  "homepage": "https://virtuoso.dev/",
7
7
  "license": "MIT",
8
8
  "source": "src/index.tsx",
@@ -26,24 +26,28 @@
26
26
  "files": [
27
27
  "dist"
28
28
  ],
29
+ "scripts": {
30
+ "build": "vite build",
31
+ "test": "vitest run",
32
+ "test:watch": "vitest watch",
33
+ "e2e": "playwright test",
34
+ "lint": "eslint src test e2e --ext .ts,.tsx",
35
+ "typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
36
+ "dev": "LADLE=true ladle serve",
37
+ "prepare": "pnpm run build && husky install",
38
+ "semantic-release": "semantic-release"
39
+ },
29
40
  "peerDependencies": {
30
41
  "react": ">=16 || >=17 || >= 18",
31
42
  "react-dom": ">=16 || >=17 || >= 18"
32
43
  },
33
44
  "devDependencies": {
34
- "@codesandbox/sandpack-react": "^2.6.3",
35
- "@codesandbox/sandpack-themes": "^2.0.21",
36
45
  "@commitlint/cli": "^17.6.3",
37
46
  "@commitlint/config-conventional": "^17.6.3",
38
- "@docusaurus/core": "2.4.0",
39
- "@docusaurus/module-type-aliases": "2.4.0",
40
- "@docusaurus/plugin-google-gtag": "^2.4.0",
41
- "@docusaurus/preset-classic": "2.4.0",
42
47
  "@emotion/core": "^11.0.0",
43
48
  "@emotion/styled": "^11.10.8",
44
49
  "@faker-js/faker": "^7.6.0",
45
50
  "@ladle/react": "^2.12.3",
46
- "@mdx-js/react": "^1.6.22",
47
51
  "@playwright/test": "^1.33.0",
48
52
  "@tanstack/react-table": "^8.9.11",
49
53
  "@testing-library/react": "^14.0.0",
@@ -57,7 +61,6 @@
57
61
  "@typescript-eslint/parser": "^5.59.2",
58
62
  "@vitejs/plugin-react": "^4.0.0",
59
63
  "clsx": "^1.2.1",
60
- "docusaurus-plugin-typedoc": "^0.19.2",
61
64
  "eslint": "^8.39.0",
62
65
  "eslint-config-prettier": "^8.8.0",
63
66
  "eslint-plugin-html": "^7.1.0",
@@ -101,18 +104,5 @@
101
104
  "repository": {
102
105
  "type": "git",
103
106
  "url": "https://github.com/petyosi/react-virtuoso.git"
104
- },
105
- "scripts": {
106
- "build": "vite build",
107
- "test": "vitest run",
108
- "test:watch": "vitest watch",
109
- "e2e": "playwright test",
110
- "lint": "eslint src test e2e --ext .ts,.tsx",
111
- "typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
112
- "dev": "LADLE=true ladle serve",
113
- "semantic-release": "semantic-release",
114
- "docs:start": "docusaurus start --config docusaurus/docusaurus.config.js",
115
- "docs:build": "docusaurus build --config docusaurus/docusaurus.config.js",
116
- "docs:deploy": "docusaurus deploy --config docusaurus/docusaurus.config.js"
117
107
  }
118
- }
108
+ }