react-virtuoso
Advanced tools
Comparing version 0.13.1 to 0.13.2
@@ -1,2 +0,2 @@ | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react"),r=t(n),i=t(require("resize-observer-polyfill")),o=n.createContext(void 0);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?function(t,e){return e(t)}:1===t.length?t[0]:function(e,n){var r=function(t){return n(t)};t.slice().reverse().forEach((function(t){var e=r;r=function(n){return t(n,e)}})),r(e)}}function u(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=s.apply(void 0,e);return a(t,r)}}function a(t,e){var n=function(n){return t((function(t){return e(t,n)}))};return{subscribe:n,pipe:u(n)}}function l(t,e){void 0===e&&(e=!0);var n=[],r=t,i=function(t){return n.push(t),void 0!==r&&t(r),function(){n=n.filter((function(e){return e!==t}))}};return{next:function(t){e&&t===r||(r=t,n.forEach((function(e){return e(t)})))},subscribe:i,pipe:u(i),subscribers:n}}function f(){var t=[],e=function(e){return t.push(e),function(){t=t.filter((function(t){return t!==e}))}};return{next:function(e){t.forEach((function(t){return t(e)}))},subscribe:e,pipe:u(e),subscribers:t}}function c(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Array(t.length).fill(!1),r=Array(t.length),i=[],o=function(t){n.every((function(t){return t}))&&t.forEach((function(t){return t(r)}))};t.forEach((function(t,e){t.subscribe((function(t){n[e]=!0,r[e]=t,o(i)}))}));var s=function(t){return i.push(t),o([t]),function(){i=i.filter((function(e){return e!==t}))}};return{subscribe:s,pipe:u(s)}}function h(t){return function(e,n){n(t(e))}}function p(t){return function(e,n){return n(t)}}function d(t){return function(e,n){t>0?t--:n(e)}}function v(t){return function(e,n){t(e)&&n(e)}}function g(t){var e;return void 0===t&&(t=function(t,e){return t!==e}),function(n,r){t(e,n)&&(e=n,r(n))}}function m(t,e){var n=e;return function(e,r){r(n=t(n,e))}}function y(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Array(t.length).fill(!1),i=Array(t.length);return t.forEach((function(t,e){t.subscribe((function(t){i[e]=t,r[e]=!0}))})),function(t,n){r.every((function(t){return t}))&&n(e.__spreadArrays([t],i))}}var x=function(t){var e,n,r=l(!1);return t.pipe(d(1),p(!0)).subscribe(r.next),t.pipe(d(1),p(!1),(function(t,r){e=t,n&&clearTimeout(n),n=setTimeout((function(){r(e)}),200)})).subscribe(r.next),r},$=new(function(){function t(){this.level=0}return t.prototype.rebalance=function(){return this},t.prototype.adjust=function(){return this},t.prototype.shift=function(){return this},t.prototype.remove=function(){return this},t.prototype.find=function(){},t.prototype.findWith=function(){},t.prototype.findMax=function(){return-Infinity},t.prototype.findMaxValue=function(){},t.prototype.insert=function(t,e){return new T({key:t,value:e,level:1})},t.prototype.walkWithin=function(){return[]},t.prototype.walk=function(){return[]},t.prototype.ranges=function(){return[]},t.prototype.rangesWithin=function(){return[]},t.prototype.empty=function(){return!0},t.prototype.isSingle=function(){return!0},t.prototype.isInvariant=function(){return!0},t.prototype.keys=function(){return[]},t}());Object.freeze($);var I=function(t){function n(e){return t.call(this,"Unreachable case: "+e)||this}return e.__extends(n,t),n}(Error),T=function(){function t(t){var e=t.value,n=t.level,r=t.left,i=void 0===r?$:r,o=t.right,s=void 0===o?$:o;this.key=t.key,this.value=e,this.level=n,this.left=i,this.right=s}return t.prototype.shift=function(t){return this.clone({key:this.key+t,left:this.left.shift(t),right:this.right.shift(t)})},t.prototype.remove=function(t){var e=this.left,n=this.right;if(t===this.key){if(e.empty())return n;if(n.empty())return e;var r=e.last();return this.clone({key:r[0],value:r[1],left:e.deleteLast()}).adjust()}return t<this.key?this.clone({left:e.remove(t)}).adjust():this.clone({right:n.remove(t)}).adjust()},t.prototype.empty=function(){return!1},t.prototype.find=function(t){return t===this.key?this.value:t<this.key?this.left.find(t):this.right.find(t)},t.prototype.findWith=function(t){var e=t(this.value);switch(e){case-1:return this.left.findWith(t);case 0:return[this.key,this.value];case 1:return this.right.findWith(t);default:throw new I(e)}},t.prototype.findMax=function(t){if(this.key===t)return t;if(this.key<t){var e=this.right.findMax(t);return-Infinity===e?this.key:e}return this.left.findMax(t)},t.prototype.findMaxValue=function(t){if(this.key===t)return this.value;if(this.key<t){var e=this.right.findMaxValue(t);return void 0===e?this.value:e}return this.left.findMaxValue(t)},t.prototype.insert=function(t,e){return t===this.key?this.clone({key:t,value:e}):t<this.key?this.clone({left:this.left.insert(t,e)}).rebalance():this.clone({right:this.right.insert(t,e)}).rebalance()},t.prototype.walkWithin=function(t,e){var n=this.key,r=this.value,i=[];return n>t&&(i=i.concat(this.left.walkWithin(t,e))),n>=t&&n<=e&&i.push({key:n,value:r}),n<=e&&(i=i.concat(this.right.walkWithin(t,e))),i},t.prototype.walk=function(){return e.__spreadArrays(this.left.walk(),[{key:this.key,value:this.value}],this.right.walk())},t.prototype.last=function(){return this.right.empty()?[this.key,this.value]:this.right.last()},t.prototype.deleteLast=function(){return this.right.empty()?this.left:this.clone({right:this.right.deleteLast()}).adjust()},t.prototype.clone=function(e){return new t({key:void 0!==e.key?e.key:this.key,value:void 0!==e.value?e.value:this.value,level:void 0!==e.level?e.level:this.level,left:void 0!==e.left?e.left:this.left,right:void 0!==e.right?e.right:this.right})},t.prototype.isSingle=function(){return this.level>this.right.level},t.prototype.rebalance=function(){return this.skew().split()},t.prototype.adjust=function(){var t=this.left,e=this.right,n=this.level;if(e.level>=n-1&&t.level>=n-1)return this;if(n>e.level+1){if(t.isSingle())return this.clone({level:n-1}).skew();if(t.empty()||t.right.empty())throw new Error("Unexpected empty nodes");return t.right.clone({left:t.clone({right:t.right.left}),right:this.clone({left:t.right.right,level:n-1}),level:n})}if(this.isSingle())return this.clone({level:n-1}).split();if(e.empty()||e.left.empty())throw new Error("Unexpected empty nodes");var r=e.left,i=r.isSingle()?e.level-1:e.level;return r.clone({left:this.clone({right:r.left,level:n-1}),right:e.clone({left:r.right,level:i}).split(),level:r.level+1})},t.prototype.isInvariant=function(){var t=this.left,e=this.right,n=this.level;return n===t.level+1&&(n===e.level||n===e.level+1)&&!(!e.empty()&&n<=e.right.level)&&t.isInvariant()&&e.isInvariant()},t.prototype.keys=function(){return e.__spreadArrays(this.left.keys(),[this.key],this.right.keys())},t.prototype.ranges=function(){return this.toRanges(this.walk())},t.prototype.rangesWithin=function(t,e){return this.toRanges(this.walkWithin(t,e))},t.prototype.toRanges=function(t){if(0===t.length)return[];for(var e=t[0],n=e.key,r=e.value,i=[],o=1;o<=t.length;o++){var s=t[o];i.push({start:n,end:s?s.key-1:Infinity,value:r}),s&&(n=s.key,r=s.value)}return i},t.prototype.split=function(){var t=this.right,e=this.level;return t.empty()||t.right.empty()||t.level!==e||t.right.level!==e?this:t.clone({left:this.clone({right:t.left}),level:e+1})},t.prototype.skew=function(){var t=this.left;return t.empty()||t.level!==this.level?this:t.clone({right:this.clone({left:t.right})})},t}(),C=function(){function t(t){this.root=t}return t.empty=function(){return new t($)},t.prototype.find=function(t){return this.root.find(t)},t.prototype.findMax=function(t){return this.root.findMax(t)},t.prototype.findMaxValue=function(t){if(this.empty())throw new Error("Searching for max value in an empty tree");return this.root.findMaxValue(t)},t.prototype.findWith=function(t){return this.root.findWith(t)},t.prototype.insert=function(e,n){return new t(this.root.insert(e,n))},t.prototype.remove=function(e){return new t(this.root.remove(e))},t.prototype.shift=function(e){if(this.empty())return this;var n=this.root.findMaxValue(Infinity);return new t(this.root.shift(e).insert(0,n))},t.prototype.empty=function(){return this.root.empty()},t.prototype.keys=function(){return this.root.keys()},t.prototype.walk=function(){return this.root.walk()},t.prototype.walkWithin=function(t,e){var n=this.root.findMax(t);return this.root.walkWithin(n,e)},t.prototype.ranges=function(){return this.root.ranges()},t.prototype.rangesWithin=function(t,e){var n=this.root.findMax(t);return this.root.rangesWithin(n,e)},t.prototype.isInvariant=function(){return this.root.isInvariant()},t}(),b=function(){function t(){}return t.prototype.transpose=function(t){return t.map((function(t){return{groupIndex:0,index:t.index,offset:t.offset,size:t.size,transposedIndex:t.index,type:"item"}}))},t}(),k=function(){function t(t){this.count=t.reduce((function(t,e){return t+e+1}),0);for(var e=C.empty(),n=0,r=0,i=0,o=t;i<o.length;i++){var s=o[i];e=e.insert(r,[n,r]),n++,r+=s+1}this.tree=e}return t.prototype.totalCount=function(){return this.count},t.prototype.transpose=function(t){var e=this;return t.map((function(t){var n=e.tree.find(t.index);if(n)return{groupIndex:n[0],index:t.index,offset:t.offset,size:t.size,type:"group"};var r=e.tree.findMaxValue(t.index)[0];return{groupIndex:r,index:t.index,offset:t.offset,size:t.size,transposedIndex:t.index-r-1,type:"item"}}))},t.prototype.groupIndices=function(){return this.tree.keys()},t}(),w=function(t){return t.length>0?t[0].offset:0},H=function(){function t(t,e,n,r){if(void 0===e&&(e=C.empty()),void 0===n&&(n=[]),void 0===r&&(r=0),this.initialTopMostItemIndex=0,this.rangeSize=0,this.maxRangeSize=Infinity,this.rangeSizeExceededCallback=function(){},this.rangeTree=t,this.nanIndices=n,this.initialTopMostItemIndex=r,e.empty())for(var i=0,o=!1,s=0,u=t.ranges();s<u.length;s++){var a=u[s],l=a.start,f=a.end,c=a.value;this.rangeSize++,isNaN(c)?(this.nanIndices.push(l),o||(e=e.insert(i,{startIndex:l,endIndex:Infinity,size:c})),o=!0):o||(e=e.insert(i,{startIndex:l,endIndex:f,size:c}),i+=(f-l+1)*c)}this.offsetTree=e}return t.create=function(){return new t(C.empty())},t.prototype.empty=function(){return this.rangeTree.empty()},t.prototype.fromTree=function(e){return new t(e,void 0,void 0,this.initialTopMostItemIndex)},t.prototype.insert=function(t,e,n){var r=this.rangeTree;if(r.empty())return this.fromTree(r.insert(0,n));if(this.rangeSize>this.maxRangeSize)return this.rangeSizeExceededCallback(),this.fromTree(C.empty().insert(0,this.getDefaultSize()));if(this.nanIndices.length&&this.nanIndices.indexOf(e)>-1){if(r.find(this.nanIndices[0]-1)===n)return this.fromTree(C.empty().insert(0,n));for(var i=0,o=this.nanIndices;i<o.length;i++)r=r.insert(o[i],n);return this.fromTree(r)}var s=r.rangesWithin(t-1,e+1);if(s.some((function(r){return r.start===t&&(r.end===e||Infinity===r.end)&&r.value===n})))return this;for(var u=!1,a=!1,l=0,f=s;l<f.length;l++){var c=f[l],h=c.start,p=c.end,d=c.value;u?(e>=h||n===d)&&(r=r.remove(h)):(a=d!==n,u=!0),p>e&&e>=h&&(d===n||isNaN(d)||(r=r.insert(e+1,d)))}return a&&(r=r.insert(t,n)),r===this.rangeTree?this:this.fromTree(r)},t.prototype.insertSpots=function(e,n){if(this.empty()){for(var r=this.rangeTree,i=0,o=e;i<o.length;i++){var s=o[i];r=r.insert(s,n).insert(s+1,NaN)}return new t(r)}throw new Error("attempting to overwrite non-empty tree")},t.prototype.offsetOf=function(t){if(this.offsetTree.empty())return 0;var e=this.offsetTree.findWith((function(e){return e.startIndex>t?-1:e.endIndex<t?1:0}));if(e){var n=e[1];return e[0]+(t-n.startIndex)*n.size}throw new Error("Requested offset outside of the known ones, index: "+t)},t.prototype.itemAt=function(t){return{index:t,size:this.rangeTree.findMaxValue(t),offset:NaN}},t.prototype.indexRange=function(t,e){if(this.rangeTree.empty())return[{index:this.initialTopMostItemIndex,size:0,offset:NaN}];for(var n=[],r=0,i=this.rangeTree.rangesWithin(t,e);r<i.length;r++)for(var o=i[r],s=Math.max(t,o.start),u=Math.min(e,void 0===o.end?Infinity:o.end),a=s;a<=u;a++)n.push({index:a,size:o.value,offset:NaN});return n},t.prototype.range=function(t,e,n,r){if(void 0===n&&(n=0),void 0===r&&(r=Infinity),this.offsetTree.empty())return[{index:this.initialTopMostItemIndex,size:0,offset:0}];for(var i=[],o=0,s=this.offsetTree.rangesWithin(t,e);o<s.length;o++){var u=s[o],a=u.start,l=u.value,f=l.startIndex,c=l.endIndex,h=l.size,p=a,d=f;if(a<t&&(p+=((d+=Math.floor((t-a)/h))-f)*h),d<n&&(p+=(n-d)*h,d=n),isNaN(h))return i.push({index:d,size:0,offset:p}),i;c=Math.min(c,r);for(var v=d;v<=c&&!(p>e);v++)i.push({index:v,size:h,offset:p}),p+=h}return i},t.prototype.total=function(t){for(var e=0,n=0,r=this.rangeTree.rangesWithin(0,t);n<r.length;n++){var i=r[n],o=i.start,s=i.end,u=i.value;e+=((s=Math.min(s,t))-o+1)*(isNaN(u)?0:u)}return e},t.prototype.getOffsets=function(t){var e=this,n=C.empty();return t.forEach((function(t){var r=e.offsetOf(t);n=n.insert(r,t)})),new M(n)},t.prototype.setInitialIndex=function(e){return new t(this.rangeTree,this.offsetTree,this.nanIndices,e)},t.prototype.getDefaultSize=function(){return this.rangeTree.findMaxValue(Infinity)},t.prototype.adjustForPrependedItems=function(t){return this.fromTree(this.rangeTree.shift(t))},t.prototype.configureMaxRangeSize=function(t,e){this.maxRangeSize=t,this.rangeSizeExceededCallback=e},t}(),M=function(){function t(t){this.tree=t}return t.prototype.findMaxValue=function(t){return this.tree.findMaxValue(t)},t.prototype.empty=function(){return this.tree.empty()},t}();function S(t){var e;return function(n){e&&e(),n&&(e=t.subscribe(n))}}function L(t){return t.next}var E=function(t){var e=t.overscan,n=void 0===e?0:e,r=t.totalCount,i=void 0===r?0:r,o=t.itemHeight,s=t.initialTopMostItemIndex,u=t.defaultItemHeight,a=l(new b),d=l(0),$=l(0),I=x($),T=function(){var t=l([]),e=t.pipe(h((function(t){return t.reduce((function(t,e){return t+e.size}),0)}))),n=t.pipe(h((function(t){return t.length&&t[t.length-1].index+1})));return{topList$:t,topListHeight$:e,minListIndex$:n}}(),C=T.topList$,M=T.minListIndex$,E=T.topListHeight$,R=function(t){var e=t.totalCount,n=t.itemHeight,r=t.defaultItemHeight,i=t.initialTopMostItemIndex,o=t.viewportHeight$,s=t.scrollTop$,u=t.topList$,a=t.transposer$,p=l(0),d=l(e),g=l(),m=function(t){var e=t.itemHeights$,n=t.viewportHeight$,r=l(),i=l(!1),o=r.subscribe((function(t){e.next([{start:0,end:0,size:30}]),n.next(30*t),i.next(!0),o()}));return{initialItemCount$:r,pendingRenderAfterInitial$:i}}({itemHeights$:g,viewportHeight$:o}),x=m.pendingRenderAfterInitial$,$=m.initialItemCount$,I=f(),T=H.create();n&&(T=T.insert(0,0,n)),r&&(T=T.insert(0,0,r)),i&&(T=T.setInitialIndex(i));var C=l(T),b=function(t){var e=t.offsetList$,n=t.scrollTop$,r=t.topList$,i=t.transposer$,o=l([]),s=c(e,o).pipe(h((function(t){return t[0].getOffsets(t[1])})));return c(e,s,n).pipe(v((function(t){return!t[1].empty()&&!t[0].empty()})),y(r,i),h((function(t){var e=t[0],n=e[0],r=t[1],i=t[2],o=e[1].findMaxValue(Math.max(e[2],0));if(1===r.length&&r[0].index===o)return r;var s=n.itemAt(o);return i.transpose([s])}))).subscribe(r.next),{stickyItems$:o}}({offsetList$:C,scrollTop$:s,topList$:u,transposer$:a}).stickyItems$,k=c(C,d,p).pipe(h((function(t){var e=t[2];return t[0].total(t[1]-1)+e})));return n||g.pipe(y(C,b,x)).subscribe((function(t){var e=t[0],n=t[1],r=t[2],i=t[3],o=n;i&&(o=H.create(),i=!1);for(var s=0,u=e;s<u.length;s++){var a=u[s],l=a.start,f=a.end,c=a.size;o=o.empty()&&l===f&&r.indexOf(l)>-1?o.insertSpots(r,c):o.insert(l,f,c)}o!==n?(C.next(o),I.next([!0,o])):I.next([!1,o])})),{totalCount$:d,offsetList$:C,totalHeight$:k,footerHeight$:p,initialItemCount$:$,itemHeights$:g,stickyItems$:b,heightsChanged$:I}}({totalCount:i,itemHeight:o,defaultItemHeight:u,initialTopMostItemIndex:s,viewportHeight$:d,scrollTop$:$,transposer$:a,topList$:C}),z=R.stickyItems$,N=R.initialItemCount$,_=R.itemHeights$,O=R.offsetList$,W=R.totalCount$,V=R.footerHeight$,F=R.totalHeight$,P=R.heightsChanged$,j=function(t){var e=t.transposer$,n=t.stickyItems$,r=t.totalCount$,i=l(),o=n.pipe();return i.subscribe((function(t){var i=new k(t);e.next(i),r.next(i.totalCount()),n.next(i.groupIndices())})),{groupCounts$:i,groupIndices$:o}}({totalCount$:W,transposer$:a,stickyItems$:z}),A=j.groupCounts$,D=j.groupIndices$,B=function(t){var e=t.totalHeight$,n=t.viewportHeight$,r=t.scrollTop$,i=l(!1);return c(r,n,e).pipe(h((function(t){var e=t[1];return 0!==e&&t[0]===t[2]-e}))).subscribe((function(t){clearTimeout(void 0),t?i.next(!0):setTimeout((function(){return i.next(!1)}))})),{scrolledToBottom$:i}}({totalHeight$:F,viewportHeight$:d,scrollTop$:$}).scrolledToBottom$,q=function(t){var e=t.offsetList$,n=t.topListHeight$,r=t.stickyItems$,i=t.viewportHeight$,o=t.totalCount$,s=t.totalHeight$,u=t.initialTopMostItemIndex,a=t.itemHeights$,c=t.scrollTop$,p=f(),d=l(!1),v=l(!0),g=f(),m=function(t){var e=t.initialTopMostItemIndex,n=t.scrollToIndex$,r=t.scrollTop$,i=t.scrollTo$,o=t.offsetList$,s=l(!e);return r.pipe(y(i,s)).subscribe((function(t){t[0]!==t[1].top||t[2]||setTimeout((function(){s.next(!0)}))})),o.pipe(y(s)).subscribe((function(t){t[1]||setTimeout((function(){n.next(e)}))})),{scrolledToTopMostItem$:s}}({scrollTo$:g,offsetList$:e,scrollToIndex$:p,scrollTop$:c,initialTopMostItemIndex:u}).scrolledToTopMostItem$;return a.pipe(y(m)).subscribe((function(t){0===t[0].length&&t[1]&&d.next(!1)})),p.pipe(y(e,n,r,i,o,s),h((function(t){var e,n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],u=t[6];"number"==typeof n&&(n={index:n,align:"start",behavior:"auto"});var a=n.index,l=n.align,f=void 0===l?"start":l;a=Math.max(0,a,Math.min(t[5]-1,a));var c=r.offsetOf(a);return"end"===f?c=c-s+r.itemAt(a).size:"center"===f?c=Math.round(c-s/2+r.itemAt(a).size/2):-1===o.indexOf(a)&&(c-=i),v.next(!1),{top:Math.min(c,Math.floor(u-s)),behavior:(e=n.behavior,null!=e?e:"auto")}}))).subscribe(g.next),c.pipe(y(v)).subscribe((function(t){t[1]||(v.next(!0),d.next(!0))})),e.pipe(y(d,p)).subscribe((function(t){t[1]&&p.next(t[2])})),{scrollToIndex$:p,scrollTo$:g,scrolledToTopMostItem$:m}}({initialTopMostItemIndex:s,scrollTop$:$,offsetList$:O,viewportHeight$:d,totalHeight$:F,stickyItems$:z,totalCount$:W,topListHeight$:E,itemHeights$:_}),U=q.scrollToIndex$,G=q.scrollTo$,K=function(t){var e=t.overscan,n=t.viewportHeight$,r=t.scrollTop$,i=t.topListHeight$,o=t.footerHeight$,s=t.minListIndex$,u=t.totalCount$,a=t.offsetList$,p=t.scrolledToTopMostItem$,d=t.transposer$,v=l(0),g=f(),x=c(n,r,i,v,o,s,u,a,p,d).pipe(m((function(t,n){var r=n[0],i=n[1],o=n[2],s=n[3],u=n[4],a=n[5],l=n[6],f=n[7],c=n[8],h=n[9],p=t.length;if(0===l)return[];var d=w(t),v=d-i+s-u-o,g=Math.max(l-1,0);if(v<r||p>0&&(t[0].index<a||t[p-1].index>g)){var m=Math.max(i,0);t=h.transpose(f.range(m,i+r+2*e-1,a,g))}return d>i&&(m=Math.max(i-2*e,0),t=h.transpose(f.range(m,i+r-1,a,g))),t.length>1&&!c?[]:t}),[])),$=c(x,r,i).pipe(h((function(t){return w(t[0])}))),I=0;return x.pipe(h((function(t){return t.length?t[t.length-1].index:0}))).pipe(y(u)).subscribe((function(t){var e=t[0],n=t[1];0!==n&&e===n-1&&I!==e&&(I=e,g.next(e))})),{list$:x,listOffset$:$,listHeight$:v,endReached$:g}}({overscan:n,viewportHeight$:d,scrollTop$:$,topListHeight$:E,footerHeight$:V,minListIndex$:M,totalCount$:W,offsetList$:O,scrolledToTopMostItem$:q.scrolledToTopMostItem$,transposer$:a}),Y=K.listHeight$,J=K.list$,Q=K.listOffset$,X=K.endReached$,Z=function(t){var e=t.offsetList$,n=t.scrollTop$,r=t.scrollTo$,i=f(),o=l(!1);return i.pipe(y(e,n,o)).subscribe((function(t){var n=t[0],i=t[1],s=t[2];t[3]||i.empty()||(o.next(!0),e.next(i.adjustForPrependedItems(n)),setTimeout((function(){r.next({top:n*i.getDefaultSize()+s}),o.next(!1)})))})),{adjustForPrependedItems$:i,adjustmentInProgress$:o}}({offsetList$:O,scrollTop$:$,scrollTo$:G}),tt=Z.adjustForPrependedItems$,et=Z.adjustmentInProgress$,nt=function(t){var e=t.list$,n=t.offsetList$,r=t.scrollTop$,i=t.scrollTo$,o=l(null),s=l(Infinity);return n.pipe(y(s,r,e)).subscribe((function(t){var e=t[2],n=t[3];return t[0].configureMaxRangeSize(t[1],(function(){o.next({index:n[0].index,offset:e-n[0].offset})}))})),n.pipe(y(o)).subscribe((function(t){var e=t[1];if(null!==e){var n=t[0].offsetOf(e.index)+e.offset;i.next({top:n}),o.next(null)}})),{maxRangeSize$:s}}({scrollTo$:G,offsetList$:O,scrollTop$:$,list$:J}).maxRangeSize$,rt=function(t){var e=t.topList$,n=t.transposer$,r=t.viewportHeight$,i=t.totalCount$,o=t.offsetList$,s=l();return c(o,s,i,r).pipe(v((function(t){return t[1]>0&&t[3]>0})),y(n),h((function(t){var e=t[0],n=e[0],r=t[1],i=Math.max(0,Math.min(e[1]-1,e[2]));return r.transpose(n.indexRange(0,i))}))).subscribe(e.next),{topItemCount$:s}}({offsetList$:O,totalCount$:W,transposer$:a,viewportHeight$:d,topList$:C}).topItemCount$,it=function(t){var e=t.scrollToIndex$,n=t.scrolledToBottom$,r=t.totalCount$,i=l(!1);return c(i,r).pipe(y(n)).subscribe((function(t){var n=t[0],r=n[1];n[0]&&t[1]&&setTimeout((function(){e.next({index:r-1,align:"end",behavior:"auto"})}))})),{followOutput$:i}}({totalCount$:W,scrollToIndex$:U,scrolledToBottom$:B}).followOutput$,ot=Q.pipe(h((function(t){return-t}))),st=f();J.pipe(y(et),v((function(t){return 0!==t[0].length&&!t[1]})),h((function(t){var e=t[0];return{startIndex:e[0].index,endIndex:e[e.length-1].index}})),g((function(t,e){return!t||t.startIndex!==e.startIndex||t.endIndex!==e.endIndex}))).subscribe(st.next);var ut=J.pipe(g(),v((function(t){return t.length>0})),m((function(t,e){var n=t[0];return[e,n.length&&n[0].index>e[0].index?"up":"down"]}),[[],"down"]),h((function(t){return t[1]})));P.pipe(y(ut,J,$),v((function(t){return t[0][0]&&"up"===t[1]}))).subscribe((function(t){var e=t[2],n=t[3],r=e[e.length-1].offset,i=t[0][1].offsetOf(e[e.length-1].index);G.next({top:n+(i-r)})}));var at=function(t){var e,n,r=t.isScrolling$,i=t.scrollTop$,o=t.rangeChanged$,s=l(0),u=l(!1),a=l(void 0);return r.pipe(v((function(t){return!t})),p(0)).subscribe(s.next),i.pipe((function(t,r){e=t,n||(n=setTimeout((function(){n=void 0,r(e)}),100))}),m((function(t,e){return[t[1],e]}),[0,0]),h((function(t){return t[1]-t[0]}))).subscribe(s.next),s.pipe(y(a,u,o),v((function(t){return!!t[1]})),h((function(t){var e=t[0],n=t[1],r=t[2],i=t[3],o=n.enter;if(r){if((0,n.exit)(e,i))return!1}else if(o(e,i))return!0;return r})),g()).subscribe(u.next),c(u,s,o).pipe(y(a)).subscribe((function(t){var e=t[0];return e[0]&&t[1].change(e[1],e[2])})),{isSeeking$:u,scrollSeekConfiguration$:a,scrollVelocity$:s}}({scrollTop$:$,isScrolling$:I,rangeChanged$:st}),lt=at.isSeeking$,ft=at.scrollVelocity$,ct=at.scrollSeekConfiguration$;return{groupCounts:L(A),itemHeights:L(_),footerHeight:L(V),listHeight:L(Y),viewportHeight:L(d),scrollTop:L($),topItemCount:L(rt),totalCount:L(W),scrollToIndex:L(U),initialItemCount:L(N),followOutput:L(it),adjustForPrependedItems:L(tt),maxRangeSize:L(nt),scrollSeekConfiguration:L(ct),list:S(J),isSeeking:S(lt),scrollVelocity:S(ft),itemsRendered:S(J),topList:S(C),listOffset:S(Q),totalHeight:S(F),endReached:S(X),atBottomStateChange:S(B),totalListHeightChanged:S(F),rangeChanged:S(st),isScrolling:S(I),stickyItems:S(z),groupIndices:S(D),stickyItemsOffset:S(ot),scrollTo:S(G)}},R=function(t,e,r){var o=n.useRef(null),s=n.useRef(0),u=new i((function(e){var n=Math.round(e[0].contentRect.height);r&&(s.current=window.requestAnimationFrame((function(){return r(e[0].target)}))),t(n)}));return n.useEffect((function(){return function(){return window.cancelAnimationFrame(s.current)}}),[]),function(t){t?(u.observe(t),e&&e(t),o.current=t):(u.unobserve(o.current),o.current=null)}};function z(t,e){var r=n.useState(function(t,e){return function(){var n=e;return t((function(t){n=t})),n}}(t,e)),i=r[0],o=r[1];return n.useLayoutEffect((function(){return t(o),function(){return t(void 0)}}),[t]),i}var N={height:"40rem",overflowY:"auto",WebkitOverflowScrolling:"touch",position:"relative",outline:"none"},_=function(t){var e=t.className,i=t.style,o=t.reportScrollTop,s=t.scrollTo,u=t.children,a=n.useRef(null),l=n.useRef(null),f=n.useRef(),c=n.useCallback((function(t){var e=t.target.scrollTop;f.current=e,null!==l.current?l.current===e&&(l.current=null,o(e)):o(e)}),[o]),h=n.useCallback((function(t){t?(t.addEventListener("scroll",c,{passive:!0}),a.current=t):a.current.removeEventListener("scroll",c)}),[c]);return s((function(t){f.current!==t.top&&("smooth"===t.behavior&&(l.current=t.top),a.current&&a.current.scrollTo(t))})),r.createElement("div",{ref:h,style:i,tabIndex:0,className:e},u)},O=function(t){var n=t.children,i=t.style,o=t.className,s=t.ScrollContainer,u=t.scrollTop,a=t.scrollTo;return r.createElement(void 0===s?_:s,{style:e.__assign(e.__assign({},N),i),reportScrollTop:u,scrollTo:a,className:o},n)},W=function(t){var e=t.render,i=t.stickyClassName,s=n.useContext(o),u=s.isSeeking,a=s.topList,l=z(s.list,[]),f=z(a,[]),c=z(u,!1),h=[],p=0,d=[],v=f.reduce((function(t,e){return t+e.size}),0);return f.forEach((function(t,n){var r=t.index;d.push(r),h.push(e(t,{key:r,"data-index":r,"data-known-size":t.size,className:i,renderPlaceholder:c,style:{top:p+"px",marginTop:0===n?-v+"px":void 0}})),p+=t.size})),l.forEach((function(t){d.indexOf(t.index)>-1||h.push(e(t,{key:t.index,"data-index":t.index,"data-known-size":t.size,renderPlaceholder:c}))})),r.createElement(r.Fragment,null," ",h," ")},V=function(t){var e=t.stickyClassName,r=n.useRef(null);return n.useLayoutEffect((function(){var t=document.createElement("style");return document.head.appendChild(t),t.sheet.insertRule("."+e+" {\n position: sticky;\n position: -webkit-sticky;\n z-index: 2;\n } ",0),r.current=t,function(){document.head.removeChild(r.current),r.current=null}}),[e]),null},F=function(){return String.fromCharCode(Math.round(25*Math.random()+97))},P=function(){return new Array(12).fill(0).map(F).join("")},j={top:0,position:"absolute",height:"100%",width:"100%",overflow:"absolute"},A=function(t){return r.createElement("div",{style:{height:t.height+"px",position:"absolute",top:0}}," ")},D=function(t){return r.createElement("footer",{ref:t.footerRef},t.children)},B=function(t){return r.createElement("div",{ref:t.listRef,style:t.style},t.children)},q=function(t){var e=t.footer,i=t.FooterContainer,s=void 0===i?D:i,u=R(n.useContext(o).footerHeight);return r.createElement(s,{footerRef:u},e())},U=function(t){var e=t.fixedItemHeight,i=t.children,s=t.ListContainer,u=n.useContext(o),a=u.listHeight,l=u.itemHeights,f={marginTop:z(u.listOffset,0)+"px"},c=R(a,(function(){}),(function(t){if(!e){var n=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t.item(n);if(i&&void 0!==i.dataset.index){var o=parseInt(i.dataset.index),s=parseInt(i.dataset.knownSize),u=i.offsetHeight;if(u!==s){var a=e[e.length-1];0===e.length||a.size!==u||a.end!==o-1?e.push({start:o,end:o,size:u}):e[e.length-1].end++}}}return e}(t.children);l(n)}}));return r.createElement(s,{listRef:c,style:f},i)},G=function(t){var i=t.style,s=t.footer,u=t.item,a=t.fixedItemHeight,l=t.ScrollContainer,f=t.ListContainer,c=t.FooterContainer,h=t.className,p=n.useContext(o),d=p.scrollTo,v=p.scrollTop,g=p.viewportHeight,m=z(p.totalHeight,0),y=n.useMemo(P,[]),x=R(g);return r.createElement(O,{style:i,ScrollContainer:l,className:h,scrollTo:d,scrollTop:v},r.createElement("div",{ref:x,style:j},r.createElement(U,{fixedItemHeight:a,ListContainer:f},r.createElement(W,{render:u,stickyClassName:y}),s&&r.createElement(q,{footer:s,FooterContainer:c}))),r.createElement(A,{height:m}),r.createElement(V,e.__assign({},{stickyClassName:y})))},K=function(t){return r.createElement(o.Provider,{value:t.contextValue},r.createElement(G,{style:t.style||{},className:t.className,item:t.item,footer:t.footer,fixedItemHeight:void 0!==t.itemHeight,ScrollContainer:t.ScrollContainer,FooterContainer:t.FooterContainer,ListContainer:t.ListContainer||B}))},Y=function(t){function n(n){var i=t.call(this,n)||this;return i.itemRender=function(t,n){var o,s=n.key,u=n.renderPlaceholder,a=e.__rest(n,["key","renderPlaceholder"]),l=i.props,f=l.scrollSeek,c=l.computeItemKey,h=l.item,p=l.ItemContainer,d=void 0===p?"div":p;return c&&(s=c(t.index)),o=f&&u?r.createElement(f.placeholder,{height:a["data-known-size"],index:t.index}):h(t.index),r.createElement(d,e.__assign(e.__assign({},a),{key:s}),o)},i.state=E(n),i}return e.__extends(n,t),n.getDerivedStateFromProps=function(t,e){return e.isScrolling(t.scrollingStateChange),e.atBottomStateChange(t.atBottomStateChange),e.endReached(t.endReached),e.topItemCount(t.topItems||0),e.totalCount(t.totalCount),t.initialItemCount&&e.initialItemCount(t.initialItemCount),e.itemsRendered(t.itemsRendered),e.totalListHeightChanged(t.totalListHeightChanged),e.followOutput(!!t.followOutput),e.maxRangeSize(t.maxHeightCacheSize||Infinity),e.rangeChanged(t.rangeChanged),e.scrollSeekConfiguration(t.scrollSeek),null},n.prototype.scrollToIndex=function(t){this.state.scrollToIndex(t)},n.prototype.adjustForPrependedItems=function(t){this.state.adjustForPrependedItems(t)},n.prototype.componentWillUnmount=function(){this.state.itemsRendered(void 0),this.state.totalListHeightChanged(void 0)},n.prototype.render=function(){return r.createElement(K,{contextValue:this.state,style:this.props.style,className:this.props.className,item:this.itemRender,footer:this.props.footer,itemHeight:this.props.itemHeight,ScrollContainer:this.props.ScrollContainer,FooterContainer:this.props.FooterContainer,ListContainer:this.props.ListContainer})},n}(n.PureComponent),J=function(t){function n(n){var i=t.call(this,n)||this;return i.itemRender=function(t,n){var o=i.props.ItemContainer,s=i.props.GroupContainer||o;if("group"===t.type){var u=i.props.group(t.groupIndex);return s?r.createElement(s,e.__assign({key:n.key},n),u):r.createElement("div",e.__assign({},n),u)}return u=i.props.item(t.transposedIndex,t.groupIndex),o?r.createElement(o,e.__assign({key:n.key},n),u):r.createElement("div",e.__assign({},n),u)},i.state=E(n),i}return e.__extends(n,t),n.getDerivedStateFromProps=function(t,e){return e.endReached(t.endReached),e.isScrolling(t.scrollingStateChange),e.groupCounts(t.groupCounts),e.groupIndices(t.groupIndices),e.itemsRendered(t.itemsRendered),e.totalListHeightChanged(t.totalListHeightChanged),null},n.prototype.scrollToIndex=function(t){this.state.scrollToIndex(t)},n.prototype.componentWillUnmount=function(){this.state.itemsRendered(void 0),this.state.totalListHeightChanged(void 0)},n.prototype.render=function(){return r.createElement(K,{contextValue:this.state,style:this.props.style,className:this.props.className,item:this.itemRender,footer:this.props.footer,itemHeight:this.props.itemHeight,ScrollContainer:this.props.ScrollContainer,FooterContainer:this.props.FooterContainer,ListContainer:this.props.ListContainer})},n}(n.PureComponent),Q=Math.ceil,X=Math.floor,Z=Math.min,tt=Math.max,et=function(t){return Q(t)-t<.03?Q(t):X(t)},nt=function(){var t=l([0,0,void 0,void 0]),e=l(0),n=l(0),r=l(0),i=l([0,0]),o=l(0),s=l(0),u=f();c(t,n,r,e).pipe(y(i)).subscribe((function(t){var e=t[0],n=e[0],r=n[0],u=n[1],a=n[2],l=n[3],f=e[1],c=e[2],h=e[3],p=t[1];if(void 0!==a&&void 0!==l){if(0===h)return i.next([0,-1]),void s.next(0);var d=p[0],v=p[1],g=et(r/a),m=function(t,e){return void 0===e&&(e=X),e(t/g)},y=function(t){var e=t?[0,c]:[c,0],n=e[1],r=g*X((f-e[0])/l),o=g*Q((f+u+n)/l)-1;o=Z(h-1,o),r=Z(o,tt(0,r)),i.next([r,o]),s.next(m(r)*l)},x=l*m(d),$=l*m(v)+l;h<v-1?y(!0):x>f?y(!1):$<f+u&&y(!0),o.next(l*m(h,Q))}}));var a=u.pipe(y(t,e),h((function(t){var e=t[0],n=t[1],r=n[0],i=n[1],o=n[2],s=n[3];if(void 0===o||void 0===s)return{top:0,behavior:"auto"};"number"==typeof e&&(e={index:e,align:"start"});var u=e.index,a=e.align,l=void 0===a?"start":a;u=Math.max(0,u,Math.min(t[2]-1,u));var f=et(r/o),c=X(u/f)*s;return"end"===l?c=c-i+s:"center"===l&&(c=Math.round(c-i/2+s/2)),{top:c,behavior:"auto"}}))),p=x(n),d=f(),v=0;return i.pipe(y(e)).subscribe((function(t){var e=t[0][1],n=t[1];0!==n&&e===n-1&&v!==e&&(v=e,d.next(e))})),{gridDimensions:L(t),totalCount:L(e),scrollTop:L(n),overscan:L(r),scrollToIndex:L(u),itemRange:S(i),totalHeight:S(o),listOffset:S(s),scrollTo:S(a),isScrolling:S(p),endReached:S(d)}},rt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.state=nt(),e}return e.__extends(n,t),n.getDerivedStateFromProps=function(t,e){return e.overscan(t.overscan||0),e.totalCount(t.totalCount),e.isScrolling(t.scrollingStateChange),e.endReached(t.endReached),null},n.prototype.scrollToIndex=function(t){this.state.scrollToIndex(t)},n.prototype.render=function(){return r.createElement(it,e.__assign({},this.props,{engine:this.state}))},n}(r.PureComponent),it=function(t){var e,o,s,u,a=t.ScrollContainer,l=t.ItemContainer,f=void 0===l?"div":l,c=t.ListContainer,h=void 0===c?"div":c,p=t.className,d=t.item,v=t.itemClassName,g=void 0===v?"virtuoso-grid-item":v,m=t.listClassName,y=void 0===m?"virtuoso-grid-list":m,x=t.engine,$=t.style,I=void 0===$?{height:"40rem"}:$,T=x.itemRange,C=x.listOffset,b=x.gridDimensions,k=x.scrollTo,w=x.scrollTop,H=z(x.totalHeight,0),M={marginTop:z(C,0)+"px"},S=z(T,[0,0]),L=(e=function(t){var e=t.element.firstChild.firstChild;b([t.width,t.height,e.offsetWidth,e.offsetHeight])},o=n.useRef(null),s=n.useRef([0,0]),u=new i((function(t){var n=t[0].contentRect,r=n.width,i=n.height;s.current[0]===r&&s.current[1]===i||(s.current=[r,i],e({element:t[0].target,width:Math.round(r),height:Math.round(i)}))})),function(t){t?(u.observe(t),o.current=t):(u.unobserve(o.current),o.current=null)});return r.createElement(O,{style:I,ScrollContainer:a,className:p,scrollTo:k,scrollTop:w},r.createElement("div",{ref:L,style:j},r.createElement(h,{style:M,className:y},function(t,e,n,i){for(var o=t[1],s=[],u=t[0];u<=o;u++)s.push(r.createElement(i,{key:u,className:n},e(u)));return s}(S,d,g,f))),r.createElement(A,{height:H}))};exports.GroupedVirtuoso=J,exports.Virtuoso=Y,exports.VirtuosoGrid=rt,exports.VirtuosoPresentation=K; | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react"),r=t(n),i=t(require("resize-observer-polyfill")),o=n.createContext(void 0);function s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?function(t,e){return e(t)}:1===t.length?t[0]:function(e,n){var r=function(t){return n(t)};t.slice().reverse().forEach((function(t){var e=r;r=function(n){return t(n,e)}})),r(e)}}function u(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=s.apply(void 0,e);return a(t,r)}}function a(t,e){var n=function(n){return t((function(t){return e(t,n)}))};return{subscribe:n,pipe:u(n)}}function l(t,e){void 0===e&&(e=!0);var n=[],r=t,i=function(t){return n.push(t),void 0!==r&&t(r),function(){n=n.filter((function(e){return e!==t}))}};return{next:function(t){e&&t===r||(r=t,n.forEach((function(e){return e(t)})))},subscribe:i,pipe:u(i),subscribers:n}}function f(){var t=[],e=function(e){return t.push(e),function(){t=t.filter((function(t){return t!==e}))}};return{next:function(e){t.forEach((function(t){return t(e)}))},subscribe:e,pipe:u(e),subscribers:t}}function c(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Array(t.length).fill(!1),r=Array(t.length),i=[],o=function(t){n.every((function(t){return t}))&&t.forEach((function(t){return t(r)}))};t.forEach((function(t,e){t.subscribe((function(t){n[e]=!0,r[e]=t,o(i)}))}));var s=function(t){return i.push(t),o([t]),function(){i=i.filter((function(e){return e!==t}))}};return{subscribe:s,pipe:u(s)}}function h(t){return function(e,n){n(t(e))}}function p(t){return function(e,n){return n(t)}}function d(t){return function(e,n){t>0?t--:n(e)}}function v(t){return function(e,n){t(e)&&n(e)}}function g(t){var e;return void 0===t&&(t=function(t,e){return t!==e}),function(n,r){t(e,n)&&(e=n,r(n))}}function m(t,e){var n=e;return function(e,r){r(n=t(n,e))}}function y(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Array(t.length).fill(!1),i=Array(t.length);return t.forEach((function(t,e){t.subscribe((function(t){i[e]=t,r[e]=!0}))})),function(t,n){r.every((function(t){return t}))&&n(e.__spreadArrays([t],i))}}var x=function(t){var e,n,r=l(!1);return t.pipe(d(1),p(!0)).subscribe(r.next),t.pipe(d(1),p(!1),(function(t,r){e=t,n&&clearTimeout(n),n=setTimeout((function(){r(e)}),200)})).subscribe(r.next),r},$=new(function(){function t(){this.level=0}return t.prototype.rebalance=function(){return this},t.prototype.adjust=function(){return this},t.prototype.shift=function(){return this},t.prototype.remove=function(){return this},t.prototype.find=function(){},t.prototype.findWith=function(){},t.prototype.findMax=function(){return-Infinity},t.prototype.findMaxValue=function(){},t.prototype.insert=function(t,e){return new T({key:t,value:e,level:1})},t.prototype.walkWithin=function(){return[]},t.prototype.walk=function(){return[]},t.prototype.ranges=function(){return[]},t.prototype.rangesWithin=function(){return[]},t.prototype.empty=function(){return!0},t.prototype.isSingle=function(){return!0},t.prototype.isInvariant=function(){return!0},t.prototype.keys=function(){return[]},t}());Object.freeze($);var I=function(t){function n(e){return t.call(this,"Unreachable case: "+e)||this}return e.__extends(n,t),n}(Error),T=function(){function t(t){var e=t.value,n=t.level,r=t.left,i=void 0===r?$:r,o=t.right,s=void 0===o?$:o;this.key=t.key,this.value=e,this.level=n,this.left=i,this.right=s}return t.prototype.shift=function(t){return this.clone({key:this.key+t,left:this.left.shift(t),right:this.right.shift(t)})},t.prototype.remove=function(t){var e=this.left,n=this.right;if(t===this.key){if(e.empty())return n;if(n.empty())return e;var r=e.last();return this.clone({key:r[0],value:r[1],left:e.deleteLast()}).adjust()}return t<this.key?this.clone({left:e.remove(t)}).adjust():this.clone({right:n.remove(t)}).adjust()},t.prototype.empty=function(){return!1},t.prototype.find=function(t){return t===this.key?this.value:t<this.key?this.left.find(t):this.right.find(t)},t.prototype.findWith=function(t){var e=t(this.value);switch(e){case-1:return this.left.findWith(t);case 0:return[this.key,this.value];case 1:return this.right.findWith(t);default:throw new I(e)}},t.prototype.findMax=function(t){if(this.key===t)return t;if(this.key<t){var e=this.right.findMax(t);return-Infinity===e?this.key:e}return this.left.findMax(t)},t.prototype.findMaxValue=function(t){if(this.key===t)return this.value;if(this.key<t){var e=this.right.findMaxValue(t);return void 0===e?this.value:e}return this.left.findMaxValue(t)},t.prototype.insert=function(t,e){return t===this.key?this.clone({key:t,value:e}):t<this.key?this.clone({left:this.left.insert(t,e)}).rebalance():this.clone({right:this.right.insert(t,e)}).rebalance()},t.prototype.walkWithin=function(t,e){var n=this.key,r=this.value,i=[];return n>t&&(i=i.concat(this.left.walkWithin(t,e))),n>=t&&n<=e&&i.push({key:n,value:r}),n<=e&&(i=i.concat(this.right.walkWithin(t,e))),i},t.prototype.walk=function(){return e.__spreadArrays(this.left.walk(),[{key:this.key,value:this.value}],this.right.walk())},t.prototype.last=function(){return this.right.empty()?[this.key,this.value]:this.right.last()},t.prototype.deleteLast=function(){return this.right.empty()?this.left:this.clone({right:this.right.deleteLast()}).adjust()},t.prototype.clone=function(e){return new t({key:void 0!==e.key?e.key:this.key,value:void 0!==e.value?e.value:this.value,level:void 0!==e.level?e.level:this.level,left:void 0!==e.left?e.left:this.left,right:void 0!==e.right?e.right:this.right})},t.prototype.isSingle=function(){return this.level>this.right.level},t.prototype.rebalance=function(){return this.skew().split()},t.prototype.adjust=function(){var t=this.left,e=this.right,n=this.level;if(e.level>=n-1&&t.level>=n-1)return this;if(n>e.level+1){if(t.isSingle())return this.clone({level:n-1}).skew();if(t.empty()||t.right.empty())throw new Error("Unexpected empty nodes");return t.right.clone({left:t.clone({right:t.right.left}),right:this.clone({left:t.right.right,level:n-1}),level:n})}if(this.isSingle())return this.clone({level:n-1}).split();if(e.empty()||e.left.empty())throw new Error("Unexpected empty nodes");var r=e.left,i=r.isSingle()?e.level-1:e.level;return r.clone({left:this.clone({right:r.left,level:n-1}),right:e.clone({left:r.right,level:i}).split(),level:r.level+1})},t.prototype.isInvariant=function(){var t=this.left,e=this.right,n=this.level;return n===t.level+1&&(n===e.level||n===e.level+1)&&!(!e.empty()&&n<=e.right.level)&&t.isInvariant()&&e.isInvariant()},t.prototype.keys=function(){return e.__spreadArrays(this.left.keys(),[this.key],this.right.keys())},t.prototype.ranges=function(){return this.toRanges(this.walk())},t.prototype.rangesWithin=function(t,e){return this.toRanges(this.walkWithin(t,e))},t.prototype.toRanges=function(t){if(0===t.length)return[];for(var e=t[0],n=e.key,r=e.value,i=[],o=1;o<=t.length;o++){var s=t[o];i.push({start:n,end:s?s.key-1:Infinity,value:r}),s&&(n=s.key,r=s.value)}return i},t.prototype.split=function(){var t=this.right,e=this.level;return t.empty()||t.right.empty()||t.level!==e||t.right.level!==e?this:t.clone({left:this.clone({right:t.left}),level:e+1})},t.prototype.skew=function(){var t=this.left;return t.empty()||t.level!==this.level?this:t.clone({right:this.clone({left:t.right})})},t}(),C=function(){function t(t){this.root=t}return t.empty=function(){return new t($)},t.prototype.find=function(t){return this.root.find(t)},t.prototype.findMax=function(t){return this.root.findMax(t)},t.prototype.findMaxValue=function(t){if(this.empty())throw new Error("Searching for max value in an empty tree");return this.root.findMaxValue(t)},t.prototype.findWith=function(t){return this.root.findWith(t)},t.prototype.insert=function(e,n){return new t(this.root.insert(e,n))},t.prototype.remove=function(e){return new t(this.root.remove(e))},t.prototype.shift=function(e){if(this.empty())return this;var n=this.root.findMaxValue(Infinity);return new t(this.root.shift(e).insert(0,n))},t.prototype.empty=function(){return this.root.empty()},t.prototype.keys=function(){return this.root.keys()},t.prototype.walk=function(){return this.root.walk()},t.prototype.walkWithin=function(t,e){var n=this.root.findMax(t);return this.root.walkWithin(n,e)},t.prototype.ranges=function(){return this.root.ranges()},t.prototype.rangesWithin=function(t,e){var n=this.root.findMax(t);return this.root.rangesWithin(n,e)},t.prototype.isInvariant=function(){return this.root.isInvariant()},t}(),b=function(){function t(){}return t.prototype.transpose=function(t){return t.map((function(t){return{groupIndex:0,index:t.index,offset:t.offset,size:t.size,transposedIndex:t.index,type:"item"}}))},t}(),k=function(){function t(t){this.count=t.reduce((function(t,e){return t+e+1}),0);for(var e=C.empty(),n=0,r=0,i=0,o=t;i<o.length;i++){var s=o[i];e=e.insert(r,[n,r]),n++,r+=s+1}this.tree=e}return t.prototype.totalCount=function(){return this.count},t.prototype.transpose=function(t){var e=this;return t.map((function(t){var n=e.tree.find(t.index);if(n)return{groupIndex:n[0],index:t.index,offset:t.offset,size:t.size,type:"group"};var r=e.tree.findMaxValue(t.index)[0];return{groupIndex:r,index:t.index,offset:t.offset,size:t.size,transposedIndex:t.index-r-1,type:"item"}}))},t.prototype.groupIndices=function(){return this.tree.keys()},t}(),w=function(t){return t.length>0?t[0].offset:0},H=function(){function t(t,e,n,r){if(void 0===e&&(e=C.empty()),void 0===n&&(n=[]),void 0===r&&(r=0),this.initialTopMostItemIndex=0,this.rangeSize=0,this.maxRangeSize=Infinity,this.rangeSizeExceededCallback=function(){},this.rangeTree=t,this.nanIndices=n,this.initialTopMostItemIndex=r,e.empty())for(var i=0,o=!1,s=0,u=t.ranges();s<u.length;s++){var a=u[s],l=a.start,f=a.end,c=a.value;this.rangeSize++,isNaN(c)?(this.nanIndices.push(l),o||(e=e.insert(i,{startIndex:l,endIndex:Infinity,size:c})),o=!0):o||(e=e.insert(i,{startIndex:l,endIndex:f,size:c}),i+=(f-l+1)*c)}this.offsetTree=e}return t.create=function(){return new t(C.empty())},t.prototype.empty=function(){return this.rangeTree.empty()},t.prototype.fromTree=function(e){return new t(e,void 0,void 0,this.initialTopMostItemIndex)},t.prototype.insert=function(t,e,n){var r=this.rangeTree;if(r.empty())return this.fromTree(r.insert(0,n));if(this.rangeSize>this.maxRangeSize)return this.rangeSizeExceededCallback(),this.fromTree(C.empty().insert(0,this.getDefaultSize()));if(this.nanIndices.length&&this.nanIndices.indexOf(e)>-1){if(r.find(this.nanIndices[0]-1)===n)return this.fromTree(C.empty().insert(0,n));for(var i=0,o=this.nanIndices;i<o.length;i++)r=r.insert(o[i],n);return this.fromTree(r)}var s=r.rangesWithin(t-1,e+1);if(s.some((function(r){return r.start===t&&(r.end===e||Infinity===r.end)&&r.value===n})))return this;for(var u=!1,a=!1,l=0,f=s;l<f.length;l++){var c=f[l],h=c.start,p=c.end,d=c.value;u?(e>=h||n===d)&&(r=r.remove(h)):(a=d!==n,u=!0),p>e&&e>=h&&(d===n||isNaN(d)||(r=r.insert(e+1,d)))}return a&&(r=r.insert(t,n)),r===this.rangeTree?this:this.fromTree(r)},t.prototype.insertSpots=function(e,n){if(this.empty()){for(var r=this.rangeTree,i=0,o=e;i<o.length;i++){var s=o[i];r=r.insert(s,n).insert(s+1,NaN)}return new t(r)}throw new Error("attempting to overwrite non-empty tree")},t.prototype.offsetOf=function(t){if(this.offsetTree.empty())return 0;var e=this.offsetTree.findWith((function(e){return e.startIndex>t?-1:e.endIndex<t?1:0}));if(e){var n=e[1];return e[0]+(t-n.startIndex)*n.size}throw new Error("Requested offset outside of the known ones, index: "+t)},t.prototype.itemAt=function(t){return{index:t,size:this.rangeTree.findMaxValue(t),offset:NaN}},t.prototype.indexRange=function(t,e){if(this.rangeTree.empty())return[{index:this.initialTopMostItemIndex,size:0,offset:NaN}];for(var n=[],r=0,i=this.rangeTree.rangesWithin(t,e);r<i.length;r++)for(var o=i[r],s=Math.max(t,o.start),u=Math.min(e,void 0===o.end?Infinity:o.end),a=s;a<=u;a++)n.push({index:a,size:o.value,offset:NaN});return n},t.prototype.range=function(t,e,n,r){if(void 0===n&&(n=0),void 0===r&&(r=Infinity),this.offsetTree.empty())return[{index:this.initialTopMostItemIndex,size:0,offset:0}];for(var i=[],o=0,s=this.offsetTree.rangesWithin(t,e);o<s.length;o++){var u=s[o],a=u.start,l=u.value,f=l.startIndex,c=l.endIndex,h=l.size,p=a,d=f;if(a<t&&(p+=((d+=Math.floor((t-a)/h))-f)*h),d<n&&(p+=(n-d)*h,d=n),isNaN(h))return i.push({index:d,size:0,offset:p}),i;c=Math.min(c,r);for(var v=d;v<=c&&!(p>e);v++)i.push({index:v,size:h,offset:p}),p+=h}return i},t.prototype.total=function(t){for(var e=0,n=0,r=this.rangeTree.rangesWithin(0,t);n<r.length;n++){var i=r[n],o=i.start,s=i.end,u=i.value;e+=((s=Math.min(s,t))-o+1)*(isNaN(u)?0:u)}return e},t.prototype.getOffsets=function(t){var e=this,n=C.empty();return t.forEach((function(t){var r=e.offsetOf(t);n=n.insert(r,t)})),new M(n)},t.prototype.setInitialIndex=function(e){return new t(this.rangeTree,this.offsetTree,this.nanIndices,e)},t.prototype.getDefaultSize=function(){return this.rangeTree.findMaxValue(Infinity)},t.prototype.adjustForPrependedItems=function(t){return this.fromTree(this.rangeTree.shift(t))},t.prototype.configureMaxRangeSize=function(t,e){this.maxRangeSize=t,this.rangeSizeExceededCallback=e},t}(),M=function(){function t(t){this.tree=t}return t.prototype.findMaxValue=function(t){return this.tree.findMaxValue(t)},t.prototype.empty=function(){return this.tree.empty()},t}();function S(t){var e;return function(n){e&&e(),n&&(e=t.subscribe(n))}}function L(t){return t.next}var E=function(t){var e=t.overscan,n=void 0===e?0:e,r=t.totalCount,i=void 0===r?0:r,o=t.itemHeight,s=t.initialTopMostItemIndex,u=t.defaultItemHeight,a=l(new b),d=l(0),$=l(0),I=x($),T=function(){var t=l([]),e=t.pipe(h((function(t){return t.reduce((function(t,e){return t+e.size}),0)}))),n=t.pipe(h((function(t){return t.length&&t[t.length-1].index+1})));return{topList$:t,topListHeight$:e,minListIndex$:n}}(),C=T.topList$,M=T.minListIndex$,E=T.topListHeight$,R=function(t){var e=t.totalCount,n=t.itemHeight,r=t.defaultItemHeight,i=t.initialTopMostItemIndex,o=t.viewportHeight$,s=t.scrollTop$,u=t.topList$,a=t.transposer$,p=l(0),d=l(e),g=l(),m=function(t){var e=t.itemHeights$,n=t.viewportHeight$,r=l(),i=l(!1),o=r.subscribe((function(t){e.next([{start:0,end:0,size:30}]),n.next(30*t),i.next(!0),o()}));return{initialItemCount$:r,pendingRenderAfterInitial$:i}}({itemHeights$:g,viewportHeight$:o}),x=m.pendingRenderAfterInitial$,$=m.initialItemCount$,I=f(),T=H.create();n&&(T=T.insert(0,0,n)),r&&(T=T.insert(0,0,r)),i&&(T=T.setInitialIndex(i));var C=l(T),b=function(t){var e=t.offsetList$,n=t.scrollTop$,r=t.topList$,i=t.transposer$,o=l([]),s=c(e,o).pipe(h((function(t){return t[0].getOffsets(t[1])})));return c(e,s,n).pipe(v((function(t){return!t[1].empty()&&!t[0].empty()})),y(r,i),h((function(t){var e=t[0],n=e[0],r=t[1],i=t[2],o=e[1].findMaxValue(Math.max(e[2],0));if(1===r.length&&r[0].index===o)return r;var s=n.itemAt(o);return i.transpose([s])}))).subscribe(r.next),{stickyItems$:o}}({offsetList$:C,scrollTop$:s,topList$:u,transposer$:a}).stickyItems$,k=c(C,d,p).pipe(h((function(t){var e=t[2];return t[0].total(t[1]-1)+e})));return n||g.pipe(y(C,b,x)).subscribe((function(t){var e=t[0],n=t[1],r=t[2],i=t[3],o=n;i&&(o=H.create(),i=!1);for(var s=0,u=e;s<u.length;s++){var a=u[s],l=a.start,f=a.end,c=a.size;o=o.empty()&&l===f&&r.indexOf(l)>-1?o.insertSpots(r,c):o.insert(l,f,c)}o!==n?(C.next(o),I.next([!0,o])):I.next([!1,o])})),{totalCount$:d,offsetList$:C,totalHeight$:k,footerHeight$:p,initialItemCount$:$,itemHeights$:g,stickyItems$:b,heightsChanged$:I}}({totalCount:i,itemHeight:o,defaultItemHeight:u,initialTopMostItemIndex:s,viewportHeight$:d,scrollTop$:$,transposer$:a,topList$:C}),z=R.stickyItems$,N=R.initialItemCount$,_=R.itemHeights$,O=R.offsetList$,W=R.totalCount$,V=R.footerHeight$,F=R.totalHeight$,P=R.heightsChanged$,j=function(t){var e=t.transposer$,n=t.stickyItems$,r=t.totalCount$,i=l(),o=n.pipe();return i.subscribe((function(t){var i=new k(t);e.next(i),r.next(i.totalCount()),n.next(i.groupIndices())})),{groupCounts$:i,groupIndices$:o}}({totalCount$:W,transposer$:a,stickyItems$:z}),A=j.groupCounts$,D=j.groupIndices$,B=function(t){var e=t.totalHeight$,n=t.viewportHeight$,r=t.scrollTop$,i=l(!1);return c(r,n,e).pipe(h((function(t){var e=t[1];return 0!==e&&t[0]===t[2]-e}))).subscribe((function(t){clearTimeout(void 0),t?i.next(!0):setTimeout((function(){return i.next(!1)}))})),{scrolledToBottom$:i}}({totalHeight$:F,viewportHeight$:d,scrollTop$:$}).scrolledToBottom$,q=function(t){var e=t.offsetList$,n=t.topListHeight$,r=t.stickyItems$,i=t.viewportHeight$,o=t.totalCount$,s=t.totalHeight$,u=t.initialTopMostItemIndex,a=t.itemHeights$,c=t.scrollTop$,p=f(),d=l(!1),v=l(!0),g=f(),m=function(t){var e=t.initialTopMostItemIndex,n=t.scrollToIndex$,r=t.scrollTop$,i=t.scrollTo$,o=t.offsetList$,s=l(!e);return r.pipe(y(i,s)).subscribe((function(t){t[0]!==t[1].top||t[2]||setTimeout((function(){s.next(!0)}))})),o.pipe(y(s)).subscribe((function(t){t[1]||setTimeout((function(){n.next(e)}))})),{scrolledToTopMostItem$:s}}({scrollTo$:g,offsetList$:e,scrollToIndex$:p,scrollTop$:c,initialTopMostItemIndex:u}).scrolledToTopMostItem$;return a.pipe(y(m)).subscribe((function(t){0===t[0].length&&t[1]&&d.next(!1)})),p.pipe(y(e,n,r,i,o,s),h((function(t){var e,n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],u=t[6];"number"==typeof n&&(n={index:n,align:"start",behavior:"auto"});var a=n.index,l=n.align,f=void 0===l?"start":l;a=Math.max(0,a,Math.min(t[5]-1,a));var c=r.offsetOf(a);return"end"===f?c=c-s+r.itemAt(a).size:"center"===f?c=Math.round(c-s/2+r.itemAt(a).size/2):-1===o.indexOf(a)&&(c-=i),v.next(!1),{top:Math.min(c,Math.floor(u-s)),behavior:(e=n.behavior,null!=e?e:"auto")}}))).subscribe(g.next),c.pipe(y(v)).subscribe((function(t){t[1]||(v.next(!0),d.next(!0))})),e.pipe(y(d,p)).subscribe((function(t){t[1]&&p.next(t[2])})),{scrollToIndex$:p,scrollTo$:g,scrolledToTopMostItem$:m}}({initialTopMostItemIndex:s,scrollTop$:$,offsetList$:O,viewportHeight$:d,totalHeight$:F,stickyItems$:z,totalCount$:W,topListHeight$:E,itemHeights$:_}),U=q.scrollToIndex$,G=q.scrollTo$,K=function(t){var e=t.overscan,n=t.viewportHeight$,r=t.scrollTop$,i=t.topListHeight$,o=t.footerHeight$,s=t.minListIndex$,u=t.totalCount$,a=t.offsetList$,p=t.scrolledToTopMostItem$,d=t.transposer$,v=l(0),g=f(),x=c(n,r,i,v,o,s,u,a,p,d).pipe(m((function(t,n){var r=n[0],i=n[1],o=n[2],s=n[3],u=n[4],a=n[5],l=n[6],f=n[7],c=n[8],h=n[9],p=t.length;if(0===l)return[];var d=w(t),v=d-i+s-u-o,g=Math.max(l-1,0);if(v<r||p>0&&(t[0].index<a||t[p-1].index>g)){var m=Math.max(i,0);t=h.transpose(f.range(m,i+r+2*e-1,a,g))}return d>i&&(m=Math.max(i-2*e,0),t=h.transpose(f.range(m,i+r-1,a,g))),t.length>1&&!c?[]:t}),[])),$=c(x,r,i).pipe(h((function(t){return w(t[0])}))),I=0;return x.pipe(h((function(t){return t.length?t[t.length-1].index:0}))).pipe(y(u)).subscribe((function(t){var e=t[0],n=t[1];0!==n&&e===n-1&&I!==e&&(I=e,g.next(e))})),{list$:x,listOffset$:$,listHeight$:v,endReached$:g}}({overscan:n,viewportHeight$:d,scrollTop$:$,topListHeight$:E,footerHeight$:V,minListIndex$:M,totalCount$:W,offsetList$:O,scrolledToTopMostItem$:q.scrolledToTopMostItem$,transposer$:a}),Y=K.listHeight$,J=K.list$,Q=K.listOffset$,X=K.endReached$,Z=function(t){var e=t.offsetList$,n=t.scrollTop$,r=t.scrollTo$,i=f(),o=l(!1);return i.pipe(y(e,n,o)).subscribe((function(t){var n=t[0],i=t[1],s=t[2];t[3]||i.empty()||(o.next(!0),e.next(i.adjustForPrependedItems(n)),setTimeout((function(){r.next({top:n*i.getDefaultSize()+s}),o.next(!1)})))})),{adjustForPrependedItems$:i,adjustmentInProgress$:o}}({offsetList$:O,scrollTop$:$,scrollTo$:G}),tt=Z.adjustForPrependedItems$,et=Z.adjustmentInProgress$,nt=function(t){var e=t.list$,n=t.offsetList$,r=t.scrollTop$,i=t.scrollTo$,o=l(null),s=l(Infinity);return n.pipe(y(s,r,e)).subscribe((function(t){var e=t[2],n=t[3];return t[0].configureMaxRangeSize(t[1],(function(){o.next({index:n[0].index,offset:e-n[0].offset})}))})),n.pipe(y(o)).subscribe((function(t){var e=t[1];if(null!==e){var n=t[0].offsetOf(e.index)+e.offset;i.next({top:n}),o.next(null)}})),{maxRangeSize$:s}}({scrollTo$:G,offsetList$:O,scrollTop$:$,list$:J}).maxRangeSize$,rt=function(t){var e=t.topList$,n=t.transposer$,r=t.viewportHeight$,i=t.totalCount$,o=t.offsetList$,s=l();return c(o,s,i,r).pipe(v((function(t){return t[1]>0&&t[3]>0})),y(n),h((function(t){var e=t[0],n=e[0],r=t[1],i=Math.max(0,Math.min(e[1]-1,e[2]));return r.transpose(n.indexRange(0,i))}))).subscribe(e.next),{topItemCount$:s}}({offsetList$:O,totalCount$:W,transposer$:a,viewportHeight$:d,topList$:C}).topItemCount$,it=function(t){var e=t.scrollToIndex$,n=t.scrolledToBottom$,r=t.totalCount$,i=l(!1);return c(i,r).pipe(y(n)).subscribe((function(t){var n=t[0],r=n[1];n[0]&&t[1]&&setTimeout((function(){e.next({index:r-1,align:"end",behavior:"auto"})}))})),{followOutput$:i}}({totalCount$:W,scrollToIndex$:U,scrolledToBottom$:B}).followOutput$,ot=Q.pipe(h((function(t){return-t}))),st=f();J.pipe(y(et),v((function(t){return 0!==t[0].length&&!t[1]})),h((function(t){var e=t[0];return{startIndex:e[0].index,endIndex:e[e.length-1].index}})),g((function(t,e){return!t||t.startIndex!==e.startIndex||t.endIndex!==e.endIndex}))).subscribe(st.next);var ut=J.pipe(g(),v((function(t){return t.length>0})),m((function(t,e){var n=t[0];return[e,n.length&&n[0].index>e[0].index?"up":"down"]}),[[],"down"]),h((function(t){return t[1]})));P.pipe(y(ut,J,$),v((function(t){return t[0][0]&&"up"===t[1]}))).subscribe((function(t){var e=t[2],n=t[3],r=e[e.length-1].offset,i=t[0][1].offsetOf(e[e.length-1].index);G.next({top:n+(i-r)})}));var at=function(t){var e,n,r=t.isScrolling$,i=t.scrollTop$,o=t.rangeChanged$,s=l(0),u=l(!1),a=l(void 0);return r.pipe(v((function(t){return!t})),p(0)).subscribe(s.next),i.pipe((function(t,r){e=t,n||(n=setTimeout((function(){n=void 0,r(e)}),100))}),m((function(t,e){return[t[1],e]}),[0,0]),h((function(t){return t[1]-t[0]}))).subscribe(s.next),s.pipe(y(a,u,o),v((function(t){return!!t[1]})),h((function(t){var e=t[0],n=t[1],r=t[2],i=t[3],o=n.enter;if(r){if((0,n.exit)(e,i))return!1}else if(o(e,i))return!0;return r})),g()).subscribe(u.next),c(u,s,o).pipe(y(a)).subscribe((function(t){var e=t[0];return e[0]&&t[1].change(e[1],e[2])})),{isSeeking$:u,scrollSeekConfiguration$:a,scrollVelocity$:s}}({scrollTop$:$,isScrolling$:I,rangeChanged$:st}),lt=at.isSeeking$,ft=at.scrollVelocity$,ct=at.scrollSeekConfiguration$;return{groupCounts:L(A),itemHeights:L(_),footerHeight:L(V),listHeight:L(Y),viewportHeight:L(d),scrollTop:L($),topItemCount:L(rt),totalCount:L(W),scrollToIndex:L(U),initialItemCount:L(N),followOutput:L(it),adjustForPrependedItems:L(tt),maxRangeSize:L(nt),scrollSeekConfiguration:L(ct),list:S(J),isSeeking:S(lt),scrollVelocity:S(ft),itemsRendered:S(J),topList:S(C),listOffset:S(Q),totalHeight:S(F),endReached:S(X),atBottomStateChange:S(B),totalListHeightChanged:S(F),rangeChanged:S(st),isScrolling:S(I),stickyItems:S(z),groupIndices:S(D),stickyItemsOffset:S(ot),scrollTo:S(G)}},R=function(t,e,r){var o=n.useRef(null),s=n.useRef(0),u=new i((function(e){var n=Math.round(e[0].contentRect.height);r&&(s.current=window.requestAnimationFrame((function(){return r(e[0].target)}))),t(n)}));return n.useEffect((function(){return function(){return window.cancelAnimationFrame(s.current)}}),[]),function(t){t?(u.observe(t),e&&e(t),o.current=t):(u.unobserve(o.current),o.current=null)}};function z(t,e){var r=n.useState(function(t,e){return function(){var n=e;return t((function(t){n=t})),n}}(t,e)),i=r[0],o=r[1];return n.useLayoutEffect((function(){return t(o),function(){return t(void 0)}}),[t]),i}var N={height:"40rem",overflowY:"auto",WebkitOverflowScrolling:"touch",position:"relative",outline:"none"},_=function(t){var e=t.className,i=t.style,o=t.reportScrollTop,s=t.scrollTo,u=t.children,a=n.useRef(null),l=n.useRef(null),f=n.useRef(),c=n.useCallback((function(t){var e=t.target.scrollTop;f.current=e,null!==l.current?l.current===e&&(l.current=null,o(e)):o(e)}),[o]),h=n.useCallback((function(t){t?(t.addEventListener("scroll",c,{passive:!0}),a.current=t):a.current.removeEventListener("scroll",c)}),[c]);return s((function(t){f.current!==t.top&&("smooth"===t.behavior&&(l.current=t.top),a.current&&a.current.scrollTo(t))})),r.createElement("div",{ref:h,style:i,tabIndex:0,className:e},u)},O=function(t){var n=t.children,i=t.style,o=t.className,s=t.ScrollContainer,u=t.scrollTop,a=t.scrollTo;return r.createElement(void 0===s?_:s,{style:e.__assign(e.__assign({},N),i),reportScrollTop:u,scrollTo:a,className:o},n)},W=function(t){var e=t.render,i=t.stickyClassName,s=n.useContext(o),u=s.isSeeking,a=s.topList,l=z(s.list,[]),f=z(a,[]),c=z(u,!1),h=[],p=0,d=[],v=f.reduce((function(t,e){return t+e.size}),0);return f.forEach((function(t,n){var r=t.index;d.push(r),h.push(e(t,{key:r,"data-index":r,"data-known-size":t.size,className:i,renderPlaceholder:c,style:{top:p+"px",marginTop:0===n?-v+"px":void 0}})),p+=t.size})),l.forEach((function(t){d.indexOf(t.index)>-1||h.push(e(t,{key:t.index,"data-index":t.index,"data-known-size":t.size,renderPlaceholder:c}))})),r.createElement(r.Fragment,null," ",h," ")},V=function(t){var e=t.stickyClassName,r=n.useRef(null);return n.useLayoutEffect((function(){var t=document.createElement("style");return document.head.appendChild(t),t.sheet.insertRule("."+e+" {\n position: sticky;\n position: -webkit-sticky;\n z-index: 2;\n } ",0),r.current=t,function(){document.head.removeChild(r.current),r.current=null}}),[e]),null},F=function(){return String.fromCharCode(Math.round(25*Math.random()+97))},P=function(){return new Array(12).fill(0).map(F).join("")},j={top:0,position:"absolute",height:"100%",width:"100%",overflow:"absolute"},A=function(t){return r.createElement("div",{style:{height:t.height+"px",position:"absolute",top:0}}," ")},D=function(t){return r.createElement("footer",{ref:t.footerRef},t.children)},B=function(t){return r.createElement("div",{ref:t.listRef,style:t.style},t.children)},q=function(t){var e=t.footer,i=t.FooterContainer,s=void 0===i?D:i,u=R(n.useContext(o).footerHeight);return r.createElement(s,{footerRef:u},e())},U=function(t){var e=t.fixedItemHeight,i=t.children,s=t.ListContainer,u=n.useContext(o),a=u.listHeight,l=u.itemHeights,f={marginTop:z(u.listOffset,0)+"px"},c=R(a,(function(){}),(function(t){if(!e){var n=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t.item(n);if(i&&void 0!==i.dataset.index){var o=parseInt(i.dataset.index),s=parseInt(i.dataset.knownSize),u=i.offsetHeight;if(u!==s){var a=e[e.length-1];0===e.length||a.size!==u||a.end!==o-1?e.push({start:o,end:o,size:u}):e[e.length-1].end++}}}return e}(t.children);l(n)}}));return r.createElement(s,{listRef:c,style:f},i)},G=function(t){var i=t.style,s=t.footer,u=t.item,a=t.fixedItemHeight,l=t.ScrollContainer,f=t.ListContainer,c=t.FooterContainer,h=t.className,p=n.useContext(o),d=p.scrollTo,v=p.scrollTop,g=p.viewportHeight,m=z(p.totalHeight,0),y=n.useMemo(P,[]),x=R(g);return r.createElement(O,{style:i,ScrollContainer:l,className:h,scrollTo:d,scrollTop:function(t){v(Math.max(t,0))}},r.createElement("div",{ref:x,style:j},r.createElement(U,{fixedItemHeight:a,ListContainer:f},r.createElement(W,{render:u,stickyClassName:y}),s&&r.createElement(q,{footer:s,FooterContainer:c}))),r.createElement(A,{height:m}),r.createElement(V,e.__assign({},{stickyClassName:y})))},K=function(t){return r.createElement(o.Provider,{value:t.contextValue},r.createElement(G,{style:t.style||{},className:t.className,item:t.item,footer:t.footer,fixedItemHeight:void 0!==t.itemHeight,ScrollContainer:t.ScrollContainer,FooterContainer:t.FooterContainer,ListContainer:t.ListContainer||B}))},Y=function(t){function n(n){var i=t.call(this,n)||this;return i.itemRender=function(t,n){var o,s=n.key,u=n.renderPlaceholder,a=e.__rest(n,["key","renderPlaceholder"]),l=i.props,f=l.scrollSeek,c=l.computeItemKey,h=l.item,p=l.ItemContainer,d=void 0===p?"div":p;return c&&(s=c(t.index)),o=f&&u?r.createElement(f.placeholder,{height:a["data-known-size"],index:t.index}):h(t.index),r.createElement(d,e.__assign(e.__assign({},a),{key:s}),o)},i.state=E(n),i}return e.__extends(n,t),n.getDerivedStateFromProps=function(t,e){return e.isScrolling(t.scrollingStateChange),e.atBottomStateChange(t.atBottomStateChange),e.endReached(t.endReached),e.topItemCount(t.topItems||0),e.totalCount(t.totalCount),t.initialItemCount&&e.initialItemCount(t.initialItemCount),e.itemsRendered(t.itemsRendered),e.totalListHeightChanged(t.totalListHeightChanged),e.followOutput(!!t.followOutput),e.maxRangeSize(t.maxHeightCacheSize||Infinity),e.rangeChanged(t.rangeChanged),e.scrollSeekConfiguration(t.scrollSeek),null},n.prototype.scrollToIndex=function(t){this.state.scrollToIndex(t)},n.prototype.adjustForPrependedItems=function(t){this.state.adjustForPrependedItems(t)},n.prototype.componentWillUnmount=function(){this.state.itemsRendered(void 0),this.state.totalListHeightChanged(void 0)},n.prototype.render=function(){return r.createElement(K,{contextValue:this.state,style:this.props.style,className:this.props.className,item:this.itemRender,footer:this.props.footer,itemHeight:this.props.itemHeight,ScrollContainer:this.props.ScrollContainer,FooterContainer:this.props.FooterContainer,ListContainer:this.props.ListContainer})},n}(n.PureComponent),J=function(t){function n(n){var i=t.call(this,n)||this;return i.itemRender=function(t,n){var o=i.props.ItemContainer,s=i.props.GroupContainer||o;if("group"===t.type){var u=i.props.group(t.groupIndex);return s?r.createElement(s,e.__assign({key:n.key},n),u):r.createElement("div",e.__assign({},n),u)}return u=i.props.item(t.transposedIndex,t.groupIndex),o?r.createElement(o,e.__assign({key:n.key},n),u):r.createElement("div",e.__assign({},n),u)},i.state=E(n),i}return e.__extends(n,t),n.getDerivedStateFromProps=function(t,e){return e.endReached(t.endReached),e.isScrolling(t.scrollingStateChange),e.groupCounts(t.groupCounts),e.groupIndices(t.groupIndices),e.itemsRendered(t.itemsRendered),e.totalListHeightChanged(t.totalListHeightChanged),null},n.prototype.scrollToIndex=function(t){this.state.scrollToIndex(t)},n.prototype.componentWillUnmount=function(){this.state.itemsRendered(void 0),this.state.totalListHeightChanged(void 0)},n.prototype.render=function(){return r.createElement(K,{contextValue:this.state,style:this.props.style,className:this.props.className,item:this.itemRender,footer:this.props.footer,itemHeight:this.props.itemHeight,ScrollContainer:this.props.ScrollContainer,FooterContainer:this.props.FooterContainer,ListContainer:this.props.ListContainer})},n}(n.PureComponent),Q=Math.ceil,X=Math.floor,Z=Math.min,tt=Math.max,et=function(t){return Q(t)-t<.03?Q(t):X(t)},nt=function(){var t=l([0,0,void 0,void 0]),e=l(0),n=l(0),r=l(0),i=l([0,0]),o=l(0),s=l(0),u=f();c(t,n,r,e).pipe(y(i)).subscribe((function(t){var e=t[0],n=e[0],r=n[0],u=n[1],a=n[2],l=n[3],f=e[1],c=e[2],h=e[3],p=t[1];if(void 0!==a&&void 0!==l){if(0===h)return i.next([0,-1]),void s.next(0);var d=p[0],v=p[1],g=et(r/a),m=function(t,e){return void 0===e&&(e=X),e(t/g)},y=function(t){var e=t?[0,c]:[c,0],n=e[1],r=g*X((f-e[0])/l),o=g*Q((f+u+n)/l)-1;o=Z(h-1,o),r=Z(o,tt(0,r)),i.next([r,o]),s.next(m(r)*l)},x=l*m(d),$=l*m(v)+l;h<v-1?y(!0):x>f?y(!1):$<f+u&&y(!0),o.next(l*m(h,Q))}}));var a=u.pipe(y(t,e),h((function(t){var e=t[0],n=t[1],r=n[0],i=n[1],o=n[2],s=n[3];if(void 0===o||void 0===s)return{top:0,behavior:"auto"};"number"==typeof e&&(e={index:e,align:"start"});var u=e.index,a=e.align,l=void 0===a?"start":a;u=Math.max(0,u,Math.min(t[2]-1,u));var f=et(r/o),c=X(u/f)*s;return"end"===l?c=c-i+s:"center"===l&&(c=Math.round(c-i/2+s/2)),{top:c,behavior:"auto"}}))),p=x(n),d=f(),v=0;return i.pipe(y(e)).subscribe((function(t){var e=t[0][1],n=t[1];0!==n&&e===n-1&&v!==e&&(v=e,d.next(e))})),{gridDimensions:L(t),totalCount:L(e),scrollTop:L(n),overscan:L(r),scrollToIndex:L(u),itemRange:S(i),totalHeight:S(o),listOffset:S(s),scrollTo:S(a),isScrolling:S(p),endReached:S(d)}},rt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.state=nt(),e}return e.__extends(n,t),n.getDerivedStateFromProps=function(t,e){return e.overscan(t.overscan||0),e.totalCount(t.totalCount),e.isScrolling(t.scrollingStateChange),e.endReached(t.endReached),null},n.prototype.scrollToIndex=function(t){this.state.scrollToIndex(t)},n.prototype.render=function(){return r.createElement(it,e.__assign({},this.props,{engine:this.state}))},n}(r.PureComponent),it=function(t){var e,o,s,u,a=t.ScrollContainer,l=t.ItemContainer,f=void 0===l?"div":l,c=t.ListContainer,h=void 0===c?"div":c,p=t.className,d=t.item,v=t.itemClassName,g=void 0===v?"virtuoso-grid-item":v,m=t.listClassName,y=void 0===m?"virtuoso-grid-list":m,x=t.engine,$=t.style,I=void 0===$?{height:"40rem"}:$,T=x.itemRange,C=x.listOffset,b=x.gridDimensions,k=x.scrollTo,w=x.scrollTop,H=z(x.totalHeight,0),M={marginTop:z(C,0)+"px"},S=z(T,[0,0]),L=(e=function(t){var e=t.element.firstChild.firstChild;b([t.width,t.height,e.offsetWidth,e.offsetHeight])},o=n.useRef(null),s=n.useRef([0,0]),u=new i((function(t){var n=t[0].contentRect,r=n.width,i=n.height;s.current[0]===r&&s.current[1]===i||(s.current=[r,i],e({element:t[0].target,width:Math.round(r),height:Math.round(i)}))})),function(t){t?(u.observe(t),o.current=t):(u.unobserve(o.current),o.current=null)});return r.createElement(O,{style:I,ScrollContainer:a,className:p,scrollTo:k,scrollTop:w},r.createElement("div",{ref:L,style:j},r.createElement(h,{style:M,className:y},function(t,e,n,i){for(var o=t[1],s=[],u=t[0];u<=o;u++)s.push(r.createElement(i,{key:u,className:n},e(u)));return s}(S,d,g,f))),r.createElement(A,{height:H}))};exports.GroupedVirtuoso=J,exports.Virtuoso=Y,exports.VirtuosoGrid=rt,exports.VirtuosoPresentation=K; | ||
//# sourceMappingURL=react-virtuoso.cjs.production.min.js.map |
@@ -16,4 +16,6 @@ /// <reference types="react" /> | ||
maxRangeSize: import("./rxio").TInput<number>; | ||
scrollSeekConfiguration: import("./rxio").TInput<import("./engines/scrollSeekEngine").ScrollSeekConfiguration>; | ||
scrollSeekConfiguration: import("./rxio").TInput<import("./engines/scrollSeekEngine").ScrollSeekConfiguration | undefined>; | ||
list: import("./rxio").TOutput<import("./GroupIndexTransposer").ListItem[]>; | ||
isSeeking: import("./rxio").TOutput<boolean>; | ||
scrollVelocity: import("./rxio").TOutput<number>; | ||
itemsRendered: import("./rxio").TOutput<import("./GroupIndexTransposer").ListItem[]>; | ||
@@ -26,6 +28,3 @@ topList: import("./rxio").TOutput<import("./GroupIndexTransposer").ListItem[]>; | ||
totalListHeightChanged: import("./rxio").TOutput<number>; | ||
rangeChanged: import("./rxio").TOutput<{ | ||
startIndex: number; | ||
endIndex: number; | ||
}>; | ||
rangeChanged: import("./rxio").TOutput<import("./engines/scrollSeekEngine").ListRange>; | ||
isScrolling: import("./rxio").TOutput<boolean>; | ||
@@ -32,0 +31,0 @@ stickyItems: import("./rxio").TOutput<number[]>; |
{ | ||
"name": "react-virtuoso", | ||
"sideEffects": false, | ||
"version": "0.13.1", | ||
"version": "0.13.2", | ||
"homepage": "https://virtuoso.dev", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5942094
44
5947