react-virtuoso
Advanced tools
Comparing version 0.16.4 to 0.16.5
@@ -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("react"),n=t(e),r=t(require("resize-observer-polyfill")),i=e.createContext(void 0);function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function s(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function f(t,e,n){return(f=l()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&u(i,n.prototype),i}).apply(null,arguments)}function c(t){var e="function"==typeof Map?new Map:void 0;return(c=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return f(t,arguments,a(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,t)})(t)}function h(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return 0===e.length?function(t,e){return e(t)}:1===e.length?e[0]:function(t,n){var r=function(t){return n(t)};e.slice().reverse().forEach((function(t){var e=r;r=function(n){return t(n,e)}})),r(t)}}function d(t){return function(){var e=h.apply(void 0,arguments);return p(t,e)}}function p(t,e){var n=function(n){return t((function(t){return e(t,n)}))};return{subscribe:n,pipe:d(n)}}function v(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:d(i),subscribers:n}}function g(){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:d(e),subscribers:t}}function m(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=Array(e.length).fill(!1),i=Array(e.length),o=[],s=function(t){r.every((function(t){return t}))&&t.forEach((function(t){return t(i)}))};e.forEach((function(t,e){t.subscribe((function(t){r[e]=!0,i[e]=t,s(o)}))}));var a=function(t){return o.push(t),s([t]),function(){o=o.filter((function(e){return e!==t}))}};return{subscribe:a,pipe:d(a)}}function x(t){return function(e,n){n(t(e))}}function y(t){return function(e,n){return n(t)}}function $(t){return function(e,n){t>0?t--:n(e)}}function I(t){return function(e,n){t(e)&&n(e)}}function b(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 C(t,e){var n=e;return function(e,r){r(n=t(n,e))}}function T(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=Array(e.length).fill(!1),i=Array(e.length);return e.forEach((function(t,e){t.subscribe((function(t){i[e]=t,r[e]=!0}))})),function(t,e){r.every((function(t){return t}))&&e([t].concat(i))}}var k=function(t){var e,n,r=v(!1);return t.pipe($(1),y(!0)).subscribe(r.next),t.pipe($(1),y(!1),(function(t,r){e=t,n&&clearTimeout(n),n=setTimeout((function(){r(e)}),200)})).subscribe(r.next),r},w=new(function(){function t(){this.level=0}var e=t.prototype;return e.rebalance=function(){return this},e.adjust=function(){return this},e.shift=function(){return this},e.remove=function(){return this},e.find=function(){},e.findWith=function(){},e.findMax=function(){return-Infinity},e.findMaxValue=function(){},e.insert=function(t,e){return new H({key:t,value:e,level:1})},e.walkWithin=function(){return[]},e.walk=function(){return[]},e.ranges=function(){return[]},e.rangesWithin=function(){return[]},e.empty=function(){return!0},e.isSingle=function(){return!0},e.isInvariant=function(){return!0},e.keys=function(){return[]},t}());Object.freeze(w);var S=function(t){function e(e){return t.call(this,"Unreachable case: "+e)||this}return s(e,t),e}(c(Error)),H=function(){function t(t){var e=t.value,n=t.level,r=t.left,i=void 0===r?w:r,o=t.right,s=void 0===o?w:o;this.key=t.key,this.value=e,this.level=n,this.left=i,this.right=s}var e=t.prototype;return e.shift=function(t){return this.clone({key:this.key+t,left:this.left.shift(t),right:this.right.shift(t)})},e.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()},e.empty=function(){return!1},e.find=function(t){return t===this.key?this.value:t<this.key?this.left.find(t):this.right.find(t)},e.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 S(e)}},e.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)},e.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)},e.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()},e.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},e.walk=function(){return[].concat(this.left.walk(),[{key:this.key,value:this.value}],this.right.walk())},e.last=function(){return this.right.empty()?[this.key,this.value]:this.right.last()},e.deleteLast=function(){return this.right.empty()?this.left:this.clone({right:this.right.deleteLast()}).adjust()},e.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})},e.isSingle=function(){return this.level>this.right.level},e.rebalance=function(){return this.skew().split()},e.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})},e.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()},e.keys=function(){return[].concat(this.left.keys(),[this.key],this.right.keys())},e.ranges=function(){return this.toRanges(this.walk())},e.rangesWithin=function(t,e){return this.toRanges(this.walkWithin(t,e))},e.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},e.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})},e.skew=function(){var t=this.left;return t.empty()||t.level!==this.level?this:t.clone({right:this.clone({left:t.right})})},t}(),M=function(){function t(t){this.root=t}t.empty=function(){return new t(w)};var e=t.prototype;return e.find=function(t){return this.root.find(t)},e.findMax=function(t){return this.root.findMax(t)},e.findMaxValue=function(t){if(this.empty())throw new Error("Searching for max value in an empty tree");return this.root.findMaxValue(t)},e.findWith=function(t){return this.root.findWith(t)},e.insert=function(e,n){return new t(this.root.insert(e,n))},e.remove=function(e){return new t(this.root.remove(e))},e.shift=function(e){if(this.empty())return this;var n=this.root.findMaxValue(Infinity);return new t(this.root.shift(e).insert(0,n))},e.empty=function(){return this.root.empty()},e.keys=function(){return this.root.keys()},e.walk=function(){return this.root.walk()},e.walkWithin=function(t,e){var n=this.root.findMax(t);return this.root.walkWithin(n,e)},e.ranges=function(){return this.root.ranges()},e.rangesWithin=function(t,e){var n=this.root.findMax(t);return this.root.rangesWithin(n,e)},e.isInvariant=function(){return this.root.isInvariant()},t}(),R=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}(),L=function(){function t(t){this.count=t.reduce((function(t,e){return t+e+1}),0);var e=M.empty(),n=0,r=0,i=t,o=Array.isArray(i),s=0;for(i=o?i:i[Symbol.iterator]();;){var a;if(o){if(s>=i.length)break;a=i[s++]}else{if((s=i.next()).done)break;a=s.value}var u=a;e=e.insert(r,[n,r]),n++,r+=u+1}this.tree=e}var e=t.prototype;return e.totalCount=function(){return this.count},e.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"}}))},e.groupIndices=function(){return this.tree.keys()},t}(),z=function(t){return t.length>0?t[0].offset:0},E=function(){function t(t,e,n,r){if(void 0===e&&(e=M.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()){var i=0,o=!1,s=t.ranges(),a=Array.isArray(s),u=0;for(s=a?s:s[Symbol.iterator]();;){var l;if(a){if(u>=s.length)break;l=s[u++]}else{if((u=s.next()).done)break;l=u.value}var f=l.start,c=l.end,h=l.value;this.rangeSize++,isNaN(h)?(this.nanIndices.push(f),o||(e=e.insert(i,{startIndex:f,endIndex:Infinity,size:h})),o=!0):o||(e=e.insert(i,{startIndex:f,endIndex:c,size:h}),i+=(c-f+1)*h)}}this.offsetTree=e}t.create=function(){return new t(M.empty())};var e=t.prototype;return e.empty=function(){return this.rangeTree.empty()},e.fromTree=function(e){return new t(e,void 0,void 0,this.initialTopMostItemIndex)},e.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(M.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(M.empty().insert(0,n));var i=this.nanIndices,o=Array.isArray(i),s=0;for(i=o?i:i[Symbol.iterator]();;){var a;if(o){if(s>=i.length)break;a=i[s++]}else{if((s=i.next()).done)break;a=s.value}r=r.insert(a,n)}return this.fromTree(r)}var u=r.rangesWithin(t-1,e+1);if(u.some((function(r){return r.start===t&&(r.end===e||Infinity===r.end)&&r.value===n})))return this;var l=!1,f=!1,c=u,h=Array.isArray(c),d=0;for(c=h?c:c[Symbol.iterator]();;){var p;if(h){if(d>=c.length)break;p=c[d++]}else{if((d=c.next()).done)break;p=d.value}var v=p.start,g=p.end,m=p.value;l?(e>=v||n===m)&&(r=r.remove(v)):(f=m!==n,l=!0),g>e&&e>=v&&(m===n||isNaN(m)||(r=r.insert(e+1,m)))}return f&&(r=r.insert(t,n)),r===this.rangeTree?this:this.fromTree(r)},e.insertSpots=function(e,n){if(this.empty()){var r=this.rangeTree,i=e,o=Array.isArray(i),s=0;for(i=o?i:i[Symbol.iterator]();;){var a;if(o){if(s>=i.length)break;a=i[s++]}else{if((s=i.next()).done)break;a=s.value}var u=a;r=r.insert(u,n).insert(u+1,NaN)}return new t(r)}throw new Error("attempting to overwrite non-empty tree")},e.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)},e.itemAt=function(t){return{index:t,size:this.rangeTree.findMaxValue(t),offset:NaN}},e.indexRange=function(t,e){if(this.rangeTree.empty())return[{index:this.initialTopMostItemIndex,size:0,offset:NaN}];var n=[],r=this.rangeTree.rangesWithin(t,e),i=Array.isArray(r),o=0;for(r=i?r:r[Symbol.iterator]();;){var s;if(i){if(o>=r.length)break;s=r[o++]}else{if((o=r.next()).done)break;s=o.value}for(var a=s,u=Math.max(t,a.start),l=Math.min(e,void 0===a.end?Infinity:a.end),f=u;f<=l;f++)n.push({index:f,size:a.value,offset:NaN})}return n},e.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}];var i=[],o=this.offsetTree.rangesWithin(t,e),s=Array.isArray(o),a=0;for(o=s?o:o[Symbol.iterator]();;){var u;if(s){if(a>=o.length)break;u=o[a++]}else{if((a=o.next()).done)break;u=a.value}var l=u.start,f=u.value,c=f.startIndex,h=f.endIndex,d=f.size,p=l,v=c;if(l<t&&(p+=((v+=Math.floor((t-l)/d))-c)*d),v<n&&(p+=(n-v)*d,v=n),isNaN(d))return i.push({index:v,size:0,offset:p}),i;h=Math.min(h,r);for(var g=v;g<=h&&!(p>e);g++)i.push({index:g,size:d,offset:p}),p+=d}return i},e.total=function(t){var e=0,n=this.rangeTree.rangesWithin(0,t),r=Array.isArray(n),i=0;for(n=r?n:n[Symbol.iterator]();;){var o;if(r){if(i>=n.length)break;o=n[i++]}else{if((i=n.next()).done)break;o=i.value}var s=o.start,a=o.end,u=o.value;e+=((a=Math.min(a,t))-s+1)*(isNaN(u)?0:u)}return e},e.getOffsets=function(t){var e=this,n=M.empty();return t.forEach((function(t){var r=e.offsetOf(t);n=n.insert(r,t)})),new O(n)},e.setInitialIndex=function(e){return new t(this.rangeTree,this.offsetTree,this.nanIndices,e)},e.getDefaultSize=function(){return this.rangeTree.findMaxValue(Infinity)},e.adjustForPrependedItems=function(t){return this.fromTree(this.rangeTree.shift(t))},e.configureMaxRangeSize=function(t,e){this.maxRangeSize=t,this.rangeSizeExceededCallback=e},t}(),O=function(){function t(t){this.tree=t}var e=t.prototype;return e.findMaxValue=function(t){return this.tree.findMaxValue(t)},e.empty=function(){return this.tree.empty()},t}();function N(t){var e;return function(n){e&&e(),n&&(e=t.subscribe(n))}}function A(t){return t.next}var P=function(t){var e=t.overscan,r=void 0===e?0:e,i=t.totalCount,s=void 0===i?0:i,a=t.itemHeight,u=t.initialTopMostItemIndex,l=t.defaultItemHeight,f=v(new R),c=v(0),h=v(0,!1),d=k(h),p=function(){var t=v([]),e=t.pipe(x((function(t){return t.reduce((function(t,e){return t+e.size}),0)}))),n=t.pipe(x((function(t){return t.length&&t[t.length-1].index+1})));return{topList$:t,topListHeight$:e,minListIndex$:n}}(),$=p.topList$,w=p.minListIndex$,S=p.topListHeight$,H=function(t){var e=t.totalCount,n=t.itemHeight,r=t.defaultItemHeight,i=t.initialTopMostItemIndex,o=t.viewportHeight$,s=t.scrollTop$,a=t.topList$,u=t.transposer$,l=v(0),f=v(e),c=v(),h=function(t){var e=t.itemHeights$,n=t.viewportHeight$,r=v(),i=v(!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$:c,viewportHeight$:o}),d=h.pendingRenderAfterInitial$,p=h.initialItemCount$,y=g(),$=E.create();n&&($=$.insert(0,0,n)),r&&($=$.insert(0,0,r)),i&&($=$.setInitialIndex(i));var b=v($),C=function(t){var e=t.offsetList$,n=t.scrollTop$,r=t.topList$,i=t.transposer$,o=v([]),s=m(e,o).pipe(x((function(t){return t[0].getOffsets(t[1])})));return m(e,s,n).pipe(I((function(t){return!t[1].empty()&&!t[0].empty()})),T(r,i),x((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$:b,scrollTop$:s,topList$:a,transposer$:u}).stickyItems$,k=m(b,f,l).pipe(x((function(t){var e=t[2];return t[0].total(t[1]-1)+e})));return n||c.pipe(T(b,C,d)).subscribe((function(t){var e=t[0],n=t[1],r=t[2],i=t[3],o=n;i&&(o=E.create(),i=!1);var s=e,a=Array.isArray(s),u=0;for(s=a?s:s[Symbol.iterator]();;){var l;if(a){if(u>=s.length)break;l=s[u++]}else{if((u=s.next()).done)break;l=u.value}var f=l.start,c=l.end,h=l.size;o=o.empty()&&f===c&&r.indexOf(f)>-1?o.insertSpots(r,h):o.insert(f,c,h)}o!==n?(b.next(o),y.next([!0,o])):y.next([!1,o])})),{totalCount$:f,offsetList$:b,totalHeight$:k,footerHeight$:l,initialItemCount$:p,itemHeights$:c,stickyItems$:C,heightsChanged$:y}}({totalCount:s,itemHeight:a,defaultItemHeight:l,initialTopMostItemIndex:u,viewportHeight$:c,scrollTop$:h,transposer$:f,topList$:$}),M=H.stickyItems$,O=H.initialItemCount$,P=H.itemHeights$,j=H.offsetList$,V=H.totalCount$,W=H.footerHeight$,F=H.totalHeight$,_=H.heightsChanged$,B=function(t){var e=t.transposer$,n=t.stickyItems$,r=t.totalCount$,i=v(),o=n.pipe();return i.subscribe((function(t){var i=new L(t);e.next(i),r.next(i.totalCount()),n.next(i.groupIndices())})),{groupCounts$:i,groupIndices$:o}}({totalCount$:V,transposer$:f,stickyItems$:M}),D=B.groupCounts$,K=B.groupIndices$,G=function(t){var e,n=t.totalHeight$,r=t.viewportHeight$,i=t.scrollTop$,o=v(!1);return m(i,r,n).pipe(x((function(t){var e=t[1];return 0!==e&&t[0]===t[2]-e}))).subscribe((function(t){clearTimeout(e),t?o.next(!0):e=setTimeout((function(){return o.next(!1)}))})),{scrolledToBottom$:o}}({totalHeight$:F,viewportHeight$:c,scrollTop$:h}).scrolledToBottom$,q=function(t){var e=t.offsetList$,n=t.topListHeight$,r=t.stickyItems$,i=t.viewportHeight$,o=t.totalCount$,s=t.totalHeight$,a=t.initialTopMostItemIndex,u=t.heightsChanged$,l=t.scrollTop$,f=g(),c=v(!1),h=v(!0),d=g(),p=function(t){var e=t.initialTopMostItemIndex,n=t.scrollToIndex$,r=t.scrollTop$,i=t.scrollTo$,o=t.offsetList$,s=v(!e);return r.pipe(T(i,s)).subscribe((function(t){t[0]!==t[1].top||t[2]||setTimeout((function(){s.next(!0)}))})),o.pipe(T(s)).subscribe((function(t){t[1]||setTimeout((function(){n.next(e)}))})),{scrolledToTopMostItem$:s}}({scrollTo$:d,offsetList$:e,scrollToIndex$:f,scrollTop$:l,initialTopMostItemIndex:a}).scrolledToTopMostItem$;return u.pipe(T(p)).subscribe((function(t){!t[0][0]&&t[1]&&(c.next(!1),h.next(!0))})),f.pipe(T(e,n,r,i,o,s),x((function(t){var e,n=t[0],r=t[1],i=t[2],o=t[3],s=t[4],a=t[6];"number"==typeof n&&(n={index:n,align:"start",behavior:"auto"});var u=n.index,l=n.align,f=void 0===l?"start":l;u=Math.max(0,u,Math.min(t[5]-1,u));var c=r.offsetOf(u);return"end"===f?c=c-s+r.itemAt(u).size:"center"===f?c=Math.round(c-s/2+r.itemAt(u).size/2):-1===o.indexOf(u)&&(c-=i),h.next(!1),{top:Math.min(c,Math.floor(a-s)),behavior:null!==(e=n.behavior)&&void 0!==e?e:"auto"}}))).subscribe(d.next),l.pipe(T(h)).subscribe((function(t){t[1]||(h.next(!0),c.next(!0))})),e.pipe(T(c,f)).subscribe((function(t){t[1]&&f.next(t[2])})),{scrollToIndex$:f,scrollTo$:d,scrolledToTopMostItem$:p}}({initialTopMostItemIndex:u,scrollTop$:h,offsetList$:j,viewportHeight$:c,totalHeight$:F,stickyItems$:M,totalCount$:V,topListHeight$:S,heightsChanged$:_}),U=q.scrollToIndex$,Y=q.scrollTo$,J=function(t){var e=t.overscan,n=t.viewportHeight$,r=t.scrollTop$,i=t.topListHeight$,o=t.footerHeight$,s=t.minListIndex$,a=t.totalCount$,u=t.offsetList$,l=t.scrolledToTopMostItem$,f=t.transposer$,c=t.totalHeight$,h=v(0),d=g(),p=v([]),y=v(0);m(r,c,n).pipe(x((function(t){return Math.max(0,Math.min(t[0],t[1]-t[2]))}))).subscribe(y.next),m(n,y,i,h,o,s,a,u,l,f).pipe(C((function(t,n){var r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],u=n[5],l=n[6],f=n[7],c=n[8],h=n[9],d=t.length;if(0===l)return[];var p=z(t),v=p-i+s-a-o,g=Math.max(l-1,0);if((v<r||d>0&&(t[0].index<u||t[d-1].index>g))&&(t=h.transpose(f.range(i,i+r+2*e-1,u,g))),p>i){var m=Math.max(i-2*e,0);t=h.transpose(f.range(m,i+r-1,u,g))}return t.length>1&&!c?[]:t}),[]),b()).subscribe(p.next);var $=m(p,r,i).pipe(x((function(t){return z(t[0])}))),I=0;return p.pipe(x((function(t){return t.length?t[t.length-1].index:0}))).pipe(T(a)).subscribe((function(t){var e=t[0],n=t[1];0!==n&&e===n-1&&I!==e&&(I=e,d.next(e))})),{list$:p,listOffset$:$,listHeight$:h,endReached$:d}}({overscan:r,viewportHeight$:c,scrollTop$:h,totalHeight$:F,topListHeight$:S,footerHeight$:W,minListIndex$:w,totalCount$:V,offsetList$:j,scrolledToTopMostItem$:q.scrolledToTopMostItem$,transposer$:f}),Q=J.listHeight$,X=J.list$,Z=J.listOffset$,tt=J.endReached$,et=function(t){var e=t.offsetList$,n=t.scrollTop$,r=t.scrollTo$,i=g(),o=v(!1);return i.pipe(T(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$:j,scrollTop$:h,scrollTo$:Y}),nt=et.adjustForPrependedItems$,rt=et.adjustmentInProgress$,it=function(t){var e=t.list$,n=t.offsetList$,r=t.scrollTop$,i=t.scrollTo$,o=v(null),s=v(Infinity);return n.pipe(T(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(T(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$:Y,offsetList$:j,scrollTop$:h,list$:X}).maxRangeSize$,ot=function(t){var e=t.topList$,n=t.transposer$,r=t.viewportHeight$,i=t.totalCount$,o=t.offsetList$,s=v();return m(o,s,i,r).pipe(I((function(t){return t[1]>0&&t[3]>0})),T(n),x((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$:j,totalCount$:V,transposer$:f,viewportHeight$:c,topList$:$}).topItemCount$,st=function(t){var e=t.scrollToIndex$,n=t.scrolledToBottom$,r=t.totalCount$,i=v(!1);return m(i,r).pipe(T(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$:V,scrollToIndex$:U,scrolledToBottom$:G}).followOutput$,at=Z.pipe(x((function(t){return-t}))),ut=g();X.pipe(T(rt),I((function(t){return 0!==t[0].length&&!t[1]})),x((function(t){var e=t[0];return{startIndex:e[0].index,endIndex:e[e.length-1].index}})),b((function(t,e){return!t||t.startIndex!==e.startIndex||t.endIndex!==e.endIndex}))).subscribe(ut.next);var lt=function(t){var e,n,r=t.isScrolling$,i=t.scrollTop$,o=t.rangeChanged$,s=v(0),a=v(!1),u=v(!1);return r.pipe(I((function(t){return!t})),y(0)).subscribe(s.next),i.pipe((function(t,r){e=t,n||(n=setTimeout((function(){n=void 0,r(e)}),100))}),C((function(t,e){return[t[1],e]}),[0,0]),x((function(t){return t[1]-t[0]}))).subscribe(s.next),s.pipe(T(u,a,o),I((function(t){return!!t[1]})),x((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})),b()).subscribe(a.next),m(a,s,o).pipe(T(u)).subscribe((function(t){var e=t[0],n=t[1];return e[0]&&n&&n.change(e[1],e[2])})),{isSeeking$:a,scrollSeekConfiguration$:u,scrollVelocity$:s}}({scrollTop$:h,isScrolling$:d,rangeChanged$:ut}),ft=lt.isSeeking$,ct=lt.scrollVelocity$,ht=lt.scrollSeekConfiguration$,dt=F.pipe(x((function(t){return Math.min(t,15e6)}))),pt=m(F,dt,c).pipe(x((function(t){var e=t[2];return(t[0]-e)/(t[1]-e)}))),vt=v(0,!1),gt=m(Z,pt).pipe(x((function(t){return t[0]/t[1]})));m(vt,pt).pipe(x((function(t){return t[0]*t[1]}))).subscribe(h.next);var mt=v((function(t){return t})),xt=v((function(t,e){return t})),yt=v((function(t){return t})),$t=v("div"),It=v("div"),bt=v(!1),Ct=v(Symbol("data-key"));return m(xt,yt,ht,mt,$t,It,Ct).pipe(x((function(t){var e=t[0],r=t[1],i=t[2],s=t[3],a=t[4],u=t[5];return{render:function(t,l){var f,c=l.key,h=l.renderPlaceholder,d=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)e.indexOf(n=o[r])>=0||(i[n]=t[n]);return i}(l,["key","renderPlaceholder"]);return s&&(c=s(t.index)),"group"===t.type?n.createElement(u,o({key:c},d),r(t.groupIndex)):(f=i&&h?n.createElement(i.placeholder,{height:d["data-known-size"],index:t.index}):e(t.transposedIndex),n.createElement(a,o({},d,{key:c}),f))}}}))).subscribe(bt.next),{groupCounts:A(D),itemHeights:A(P),footerHeight:A(W),listHeight:A(Q),viewportHeight:A(c),scrollTop:A(vt),topItemCount:A(ot),totalCount:A(V),scrollToIndex:A(U),initialItemCount:A(O),followOutput:A(st),adjustForPrependedItems:A(nt),maxRangeSize:A(it),scrollSeekConfiguration:A(ht),renderProp:A(xt),groupRenderProp:A(yt),computeItemKey:A(mt),itemContainer:A($t),groupContainer:A(It),dataKey:A(Ct),itemRender:N(bt),list:N(X),isSeeking:N(ft),scrollVelocity:N(ct),itemsRendered:N(X),topList:N($),listOffset:N(gt),totalHeight:N(dt),endReached:N(tt),atBottomStateChange:N(G),totalListHeightChanged:N(F),rangeChanged:N(ut),isScrolling:N(d),stickyItems:N(M),groupIndices:N(K),stickyItemsOffset:N(at),scrollTo:N(Y)}},j={top:0,position:"absolute",height:"100%",width:"100%"},V=function(t,n,i){var o=e.useRef(null),s=e.useRef(0),a=new r((function(e){var n=Math.round(e[0].contentRect.height);i&&(s.current=window.requestAnimationFrame((function(){var t=e[0].target;document.body.contains(t)&&i(t)}))),t(n)}));return e.useEffect((function(){return function(){return window.cancelAnimationFrame(s.current)}}),[]),function(t){t?(a.observe(t),n&&n(t),o.current=t):(a.unobserve(o.current),o.current=null)}};function W(t,n){var r=e.useState(function(t,e){return function(){var n=e;return t((function(t){n=t})),n}}(t,n)),i=r[0],o=r[1];return e.useEffect((function(){return t(o),function(){return t(void 0)}}),[t]),i}function F(t){var e,n=!1;return function(){return n||(n=!0,e=t()),e}}var _=F((function(){var t=document.createElement("div");return t.style.position="-webkit-sticky","-webkit-sticky"===t.style.position?"-webkit-sticky":"sticky"})),B=function(t){return n.createElement("div",{style:{height:t.height+"px",position:"absolute",top:0}}," ")},D=n.memo((function(){var t=e.useContext(i),r=t.isSeeking,o=t.topList,s=t.itemRender,a=W(t.list,[]),u=W(o,[]),l=W(s,!1),f=W(r,!1),c=[],h=0,d=[],p=u.reduce((function(t,e){return t+e.size}),0);return u.forEach((function(t,e){var n=t.index;d.push(n);var r={top:h+"px",marginTop:0===e?-p+"px":void 0,zIndex:2,position:_()};l&&c.push(l.render(t,{key:n,"data-index":n,"data-known-size":t.size,renderPlaceholder:f,style:r})),h+=t.size})),a.forEach((function(t){d.indexOf(t.index)>-1||l&&c.push(l.render(t,{key:t.index,"data-index":t.index,"data-known-size":t.size,renderPlaceholder:f}))})),n.createElement(n.Fragment,null,c)})),K={height:"40rem",overflowY:"auto",WebkitOverflowScrolling:"touch",position:"relative",outline:"none"},G=function(t){var r=t.className,i=t.style,o=t.reportScrollTop,s=t.scrollTo,a=t.children,u=e.useRef(null),l=e.useRef(null),f=e.useRef(),c=e.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=e.useCallback((function(t){t?(t.addEventListener("scroll",c,{passive:!0}),u.current=t):u.current&&u.current.removeEventListener("scroll",c)}),[c]);return s((function(t){f.current!==t.top&&("smooth"===t.behavior&&(l.current=t.top),u.current&&u.current.scrollTo(t))})),n.createElement("div",{ref:h,style:i,tabIndex:0,className:r},a)},q=function(t){var e=t.children,r=t.className,i=t.ScrollContainer,s=t.scrollTop,a=t.scrollTo;return n.createElement(void 0===i?G:i,{style:o({},K,{},t.style),reportScrollTop:s,scrollTo:a,className:r},e)},U=function(t){return n.createElement("footer",{ref:t.footerRef},t.children)},Y=function(t){return n.createElement("div",{ref:t.listRef,style:t.style},t.children)},J=function(t){var r=t.footer,o=t.FooterContainer,s=void 0===o?U:o,a=V(e.useContext(i).footerHeight);return n.createElement(s,{footerRef:a},r())},Q=function(t){var r=t.fixedItemHeight,o=t.children,s=t.ListContainer,a=e.useContext(i),u=a.listHeight,l=a.itemHeights,f={marginTop:W(a.listOffset,0)+"px"},c=V(u,(function(){}),(function(t){if(!r){var e=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),a=i.offsetHeight;if(a!==s){var u=e[e.length-1];0===e.length||u.size!==a||u.end!==o-1?e.push({start:o,end:o,size:a}):e[e.length-1].end++}}}return e}(t.children);l(e)}}));return n.createElement(s,{listRef:c,style:f},o)},X=function(t){var r=t.style,o=t.footer,s=t.fixedItemHeight,a=t.ScrollContainer,u=t.ListContainer,l=t.FooterContainer,f=t.className,c=e.useContext(i),h=c.scrollTo,d=c.scrollTop,p=c.viewportHeight,v=W(c.totalHeight,0),g=V(p);return n.createElement(q,{style:r,ScrollContainer:a,className:f,scrollTo:h,scrollTop:function(t){d(Math.max(t,0))}},n.createElement("div",{ref:g,style:j},n.createElement(Q,{fixedItemHeight:s,ListContainer:u},n.createElement(D,null),o&&n.createElement(J,{footer:o,FooterContainer:l}))),n.createElement(B,{height:v}))},Z={},tt=n.memo((function(t){return n.createElement(i.Provider,{value:t.contextValue},n.createElement(X,{style:t.style||Z,className:t.className,footer:t.footer,fixedItemHeight:void 0!==t.itemHeight,ScrollContainer:t.ScrollContainer,FooterContainer:t.FooterContainer,ListContainer:t.ListContainer||Y}))})),et=e.forwardRef((function(t,r){var i=e.useState((function(){return P(t)}))[0];return e.useImperativeHandle(r,(function(){return{scrollToIndex:function(t){i.scrollToIndex(t)},adjustForPrependedItems:function(t){i.adjustForPrependedItems(t)}}}),[i]),e.useEffect((function(){return i.isScrolling(t.scrollingStateChange),i.atBottomStateChange(t.atBottomStateChange),i.endReached(t.endReached),i.topItemCount(t.topItems||0),i.totalCount(t.totalCount),t.initialItemCount&&i.initialItemCount(t.initialItemCount),i.itemsRendered(t.itemsRendered),i.totalListHeightChanged(t.totalListHeightChanged),i.followOutput(!!t.followOutput),i.maxRangeSize(t.maxHeightCacheSize||Infinity),i.rangeChanged(t.rangeChanged),i.scrollSeekConfiguration(t.scrollSeek),i.computeItemKey(t.computeItemKey||function(t){return t}),i.itemContainer(t.ItemContainer||"div"),i.renderProp(t.item),i.dataKey(t.dataKey),function(){i.itemsRendered(void 0),i.totalListHeightChanged(void 0)}}),[i,t.scrollingStateChange,t.atBottomStateChange,t.endReached,t.topItems,t.totalCount,t.initialItemCount,t.itemsRendered,t.totalListHeightChanged,t.followOutput,t.maxHeightCacheSize,t.rangeChanged,t.scrollSeek,t.item,t.ItemContainer,t.computeItemKey,t.dataKey]),n.createElement(tt,{contextValue:i,style:t.style,className:t.className,footer:t.footer,itemHeight:t.itemHeight,ScrollContainer:t.ScrollContainer,FooterContainer:t.FooterContainer,ListContainer:t.ListContainer})}));et.displayName="Virtuoso";var nt=e.forwardRef((function(t,r){var i=e.useState(P(t))[0];return e.useImperativeHandle(r,(function(){return{scrollToIndex:function(t){i.scrollToIndex(t)}}}),[i]),e.useEffect((function(){return i.endReached(t.endReached),i.rangeChanged(t.rangeChanged),i.atBottomStateChange(t.atBottomStateChange),i.isScrolling(t.scrollingStateChange),i.groupCounts(t.groupCounts),i.groupIndices(t.groupIndices),i.itemsRendered(t.itemsRendered),i.totalListHeightChanged(t.totalListHeightChanged),i.renderProp(t.item),i.groupRenderProp(t.group),i.itemContainer(t.ItemContainer||"div"),i.groupContainer(t.GroupContainer||"div"),i.scrollSeekConfiguration(t.scrollSeek),function(){i.itemsRendered(void 0),i.totalListHeightChanged(void 0)}}),[i,t.endReached,t.rangeChanged,t.atBottomStateChange,t.scrollingStateChange,t.groupCounts,t.groupIndices,t.itemsRendered,t.totalListHeightChanged,t.item,t.group,t.GroupContainer,t.ItemContainer]),n.createElement(tt,{contextValue:i,style:t.style,className:t.className,footer:t.footer,itemHeight:t.itemHeight,ScrollContainer:t.ScrollContainer,FooterContainer:t.FooterContainer,ListContainer:t.ListContainer})}));nt.displayName="GroupedVirtuoso";var rt=Math.ceil,it=Math.floor,ot=Math.min,st=Math.max,at=function(t){return rt(t)-t<.03?rt(t):it(t)},ut=function(){var t=v([0,0,void 0,void 0]),e=v(0),n=v(0),r=v(0),i=v([0,0]),o=v(0),s=v(0),a=g();m(t,n,r,e).pipe(T(i)).subscribe((function(t){var e=t[0],n=e[0],r=n[0],a=n[1],u=n[2],l=n[3],f=e[1],c=e[2],h=e[3],d=t[1];if(void 0!==u&&void 0!==l){if(0===h)return i.next([0,-1]),void s.next(0);var p=d[0],v=d[1],g=at(r/u),m=function(t,e){return void 0===e&&(e=it),e(t/g)},x=function(t){var e=t?[0,c]:[c,0],n=e[1],r=g*it((f-e[0])/l),o=g*rt((f+a+n)/l)-1;o=ot(h-1,o),r=ot(o,st(0,r)),i.next([r,o]),s.next(m(r)*l)},y=l*m(p),$=l*m(v)+l;h<v-1?x(!0):y>f?x(!1):$<f+a&&x(!0),o.next(l*m(h,rt))}}));var u=a.pipe(T(t,e),x((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 a=e.index,u=e.align,l=void 0===u?"start":u;a=Math.max(0,a,Math.min(t[2]-1,a));var f=at(r/o),c=it(a/f)*s;return"end"===l?c=c-i+s:"center"===l&&(c=Math.round(c-i/2+s/2)),{top:c,behavior:"auto"}}))),l=k(n),f=g(),c=0;return i.pipe(T(e)).subscribe((function(t){var e=t[0][1],n=t[1];0!==n&&e===n-1&&c!==e&&(c=e,f.next(e))})),{gridDimensions:A(t),totalCount:A(e),scrollTop:A(n),overscan:A(r),scrollToIndex:A(a),itemRange:N(i),totalHeight:N(o),listOffset:N(s),scrollTo:N(u),isScrolling:N(l),endReached:N(f)}},lt=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).state=ut(),e}s(e,t),e.getDerivedStateFromProps=function(t,e){return e.overscan(t.overscan||0),e.totalCount(t.totalCount),e.isScrolling(t.scrollingStateChange),e.endReached(t.endReached),null};var r=e.prototype;return r.scrollToIndex=function(t){this.state.scrollToIndex(t)},r.render=function(){return n.createElement(ft,Object.assign({},this.props,{engine:this.state}))},e}(n.PureComponent),ft=function(t){var i,o,s,a,u=t.ScrollContainer,l=t.ItemContainer,f=void 0===l?"div":l,c=t.ListContainer,h=void 0===c?"div":c,d=t.className,p=t.item,v=t.itemClassName,g=void 0===v?"virtuoso-grid-item":v,m=t.listClassName,x=void 0===m?"virtuoso-grid-list":m,y=t.engine,$=t.style,I=void 0===$?{height:"40rem"}:$,b=y.itemRange,C=y.listOffset,T=y.gridDimensions,k=y.scrollTo,w=y.scrollTop,S=W(y.totalHeight,0),H={marginTop:W(C,0)+"px"},M=W(b,[0,0]),R=(i=function(t){var e=t.element.firstChild.firstChild;T([t.width,t.height,e.offsetWidth,e.offsetHeight])},o=e.useRef(null),s=e.useRef([0,0]),a=new r((function(t){var e=t[0].contentRect,n=e.width,r=e.height;s.current[0]===n&&s.current[1]===r||(s.current=[n,r],i({element:t[0].target,width:Math.round(n),height:Math.round(r)}))})),function(t){t?(a.observe(t),o.current=t):(a.unobserve(o.current),o.current=null)});return n.createElement(q,{style:I,ScrollContainer:u,className:d,scrollTo:k,scrollTop:w},n.createElement("div",{ref:R,style:j},n.createElement(h,{style:H,className:x},function(t,e,r,i){for(var o=t[1],s=[],a=t[0];a<=o;a++)s.push(n.createElement(i,{key:a,className:r},e(a)));return s}(M,p,g,f))),n.createElement(B,{height:S}))};exports.GroupedVirtuoso=nt,exports.Virtuoso=et,exports.VirtuosoGrid=lt,exports.VirtuosoPresentation=tt; | ||
"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("react"),n=t(e),r=require("tslib"),i=t(require("resize-observer-polyfill")),o=e.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 g(t){return function(e,n){t(e)&&n(e)}}function v(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=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Array(t.length).fill(!1),i=Array(t.length);return t.forEach((function(t,e){t.subscribe((function(t){i[e]=t,n[e]=!0}))})),function(t,e){n.every((function(t){return t}))&&e(r.__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 C({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 e(e){return t.call(this,"Unreachable case: "+e)||this}return r.__extends(e,t),e}(Error),C=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 r.__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 r.__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}(),T=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=T.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},S=function(){function t(t,e,n,r){if(void 0===e&&(e=T.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(T.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(T.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(T.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 g=d;g<=c&&!(p>e);g++)i.push({index:g,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=T.empty();return t.forEach((function(t){var r=e.offsetOf(t);n=n.insert(r,t)})),new H(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}(),H=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 M(t){var e;return function(n){e&&e(),n&&(e=t.subscribe(n))}}function L(t){return t.next}var R=function(t){var e=t.overscan,i=void 0===e?0:e,o=t.totalCount,s=void 0===o?0:o,u=t.itemHeight,a=t.initialTopMostItemIndex,d=t.defaultItemHeight,$=l(new b),I=l(0),C=l(0,!1),T=x(C),H=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}}(),R=H.topList$,z=H.minListIndex$,E=H.topListHeight$,N=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),v=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$:v,viewportHeight$:o}),x=m.pendingRenderAfterInitial$,$=m.initialItemCount$,I=f(),C=S.create();n&&(C=C.insert(0,0,n)),r&&(C=C.insert(0,0,r)),i&&(C=C.setInitialIndex(i));var T=l(C),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(g((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$:T,scrollTop$:s,topList$:u,transposer$:a}).stickyItems$,k=c(T,d,p).pipe(h((function(t){var e=t[2];return t[0].total(t[1]-1)+e})));return n||v.pipe(y(T,b,x)).subscribe((function(t){var e=t[0],n=t[1],r=t[2],i=t[3],o=n;i&&(o=S.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?(T.next(o),I.next([!0,o])):I.next([!1,o])})),{totalCount$:d,offsetList$:T,totalHeight$:k,footerHeight$:p,initialItemCount$:$,itemHeights$:v,stickyItems$:b,heightsChanged$:I}}({totalCount:s,itemHeight:u,defaultItemHeight:d,initialTopMostItemIndex:a,viewportHeight$:I,scrollTop$:C,transposer$:$,topList$:R}),O=N.stickyItems$,_=N.initialItemCount$,V=N.itemHeights$,W=N.offsetList$,P=N.totalCount$,F=N.footerHeight$,j=N.totalHeight$,A=N.heightsChanged$,B=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$:P,transposer$:$,stickyItems$:O}),K=B.groupCounts$,D=B.groupIndices$,q=function(t){var e,n=t.totalHeight$,r=t.viewportHeight$,i=t.scrollTop$,o=l(!1);return c(i,r,n).pipe(h((function(t){var e=t[1];return 0!==e&&t[0]===t[2]-e}))).subscribe((function(t){clearTimeout(e),t?o.next(!0):e=setTimeout((function(){return o.next(!1)}))})),{scrolledToBottom$:o}}({totalHeight$:j,viewportHeight$:I,scrollTop$:C}).scrolledToBottom$,G=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.heightsChanged$,c=t.scrollTop$,p=f(),d=l(!1),g=l(!0),v=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$:v,offsetList$:e,scrollToIndex$:p,scrollTop$:c,initialTopMostItemIndex:u}).scrolledToTopMostItem$;return a.pipe(y(m)).subscribe((function(t){!t[0][0]&&t[1]&&(d.next(!1),g.next(!0))})),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),g.next(!1),{top:Math.max(0,Math.min(c,Math.floor(u-s))),behavior:(e=n.behavior,null!=e?e:"auto")}}))).subscribe(v.next),c.pipe(y(g)).subscribe((function(t){t[1]||(g.next(!0),d.next(!0))})),e.pipe(y(d,p)).subscribe((function(t){t[1]&&p.next(t[2])})),{scrollToIndex$:p,scrollTo$:v,scrolledToTopMostItem$:m}}({initialTopMostItemIndex:a,scrollTop$:C,offsetList$:W,viewportHeight$:I,totalHeight$:j,stickyItems$:O,totalCount$:P,topListHeight$:E,heightsChanged$:A}),U=G.scrollToIndex$,Y=G.scrollTo$,J=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$,g=t.totalHeight$,x=l(0),$=f(),I=l([]),C=l(0);c(r,g,n).pipe(h((function(t){return Math.max(0,Math.min(t[0],t[1]-t[2]))}))).subscribe(C.next),c(n,C,i,x,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),g=d-i+s-u-o,v=Math.max(l-1,0);if((g<r||p>0&&(t[0].index<a||t[p-1].index>v))&&(t=h.transpose(f.range(i,i+r+2*e-1,a,v))),d>i){var m=Math.max(i-2*e,0);t=h.transpose(f.range(m,i+r-1,a,v))}return t.length>1&&!c?[]:t}),[]),v()).subscribe(I.next);var T=c(I,r,i).pipe(h((function(t){return w(t[0])}))),b=0;return I.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&&b!==e&&(b=e,$.next(e))})),{list$:I,listOffset$:T,listHeight$:x,endReached$:$}}({overscan:i,viewportHeight$:I,scrollTop$:C,totalHeight$:j,topListHeight$:E,footerHeight$:F,minListIndex$:z,totalCount$:P,offsetList$:W,scrolledToTopMostItem$:G.scrolledToTopMostItem$,transposer$:$}),Q=J.listHeight$,X=J.list$,Z=J.listOffset$,tt=J.endReached$,et=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$:W,scrollTop$:C,scrollTo$:Y}),nt=et.adjustForPrependedItems$,rt=et.adjustmentInProgress$,it=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$:Y,offsetList$:W,scrollTop$:C,list$:X}).maxRangeSize$,ot=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(g((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$:W,totalCount$:P,transposer$:$,viewportHeight$:I,topList$:R}).topItemCount$,st=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$:P,scrollToIndex$:U,scrolledToBottom$:q}).followOutput$,ut=Z.pipe(h((function(t){return-t}))),at=f();X.pipe(y(rt),g((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}})),v((function(t,e){return!t||t.startIndex!==e.startIndex||t.endIndex!==e.endIndex}))).subscribe(at.next);var lt=function(t){var e,n,r=t.isScrolling$,i=t.scrollTop$,o=t.rangeChanged$,s=l(0),u=l(!1),a=l(!1);return r.pipe(g((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),g((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})),v()).subscribe(u.next),c(u,s,o).pipe(y(a)).subscribe((function(t){var e=t[0],n=t[1];return e[0]&&n&&n.change(e[1],e[2])})),{isSeeking$:u,scrollSeekConfiguration$:a,scrollVelocity$:s}}({scrollTop$:C,isScrolling$:T,rangeChanged$:at}),ft=lt.isSeeking$,ct=lt.scrollVelocity$,ht=lt.scrollSeekConfiguration$,pt=j.pipe(h((function(t){return Math.min(t,15e6)}))),dt=c(j,pt,I).pipe(h((function(t){var e=t[2];return(t[0]-e)/(t[1]-e)}))),gt=l(0,!1),vt=c(Z,dt).pipe(h((function(t){return t[0]/t[1]})));c(gt,dt).pipe(h((function(t){return t[0]*t[1]}))).subscribe(C.next);var mt=l((function(t){return t})),yt=l((function(t,e){return t})),xt=l((function(t){return t})),$t=l("div"),It=l("div"),Ct=l(!1),Tt=l(Symbol("data-key"));return c(yt,xt,ht,mt,$t,It,Tt).pipe(h((function(t){var e=t[0],i=t[1],o=t[2],s=t[3],u=t[4],a=t[5];return{render:function(t,l){var f,c=l.key,h=l.renderPlaceholder,p=r.__rest(l,["key","renderPlaceholder"]);return s&&(c=s(t.index)),"group"===t.type?n.createElement(a,r.__assign({key:c},p),i(t.groupIndex)):(f=o&&h?n.createElement(o.placeholder,{height:p["data-known-size"],index:t.index}):e(t.transposedIndex),n.createElement(u,r.__assign(r.__assign({},p),{key:c}),f))}}}))).subscribe(Ct.next),{groupCounts:L(K),itemHeights:L(V),footerHeight:L(F),listHeight:L(Q),viewportHeight:L(I),scrollTop:L(gt),topItemCount:L(ot),totalCount:L(P),scrollToIndex:L(U),initialItemCount:L(_),followOutput:L(st),adjustForPrependedItems:L(nt),maxRangeSize:L(it),scrollSeekConfiguration:L(ht),renderProp:L(yt),groupRenderProp:L(xt),computeItemKey:L(mt),itemContainer:L($t),groupContainer:L(It),dataKey:L(Tt),itemRender:M(Ct),list:M(X),isSeeking:M(ft),scrollVelocity:M(ct),itemsRendered:M(X),topList:M(R),listOffset:M(vt),totalHeight:M(pt),endReached:M(tt),atBottomStateChange:M(q),totalListHeightChanged:M(j),rangeChanged:M(at),isScrolling:M(T),stickyItems:M(O),groupIndices:M(D),stickyItemsOffset:M(ut),scrollTo:M(Y)}},z={top:0,position:"absolute",height:"100%",width:"100%"},E=function(t,n,r){var o=e.useRef(null),s=e.useRef(0),u=new i((function(e){var n=Math.round(e[0].contentRect.height);r&&(s.current=window.requestAnimationFrame((function(){var t=e[0].target;document.body.contains(t)&&r(t)}))),t(n)}));return e.useEffect((function(){return function(){return window.cancelAnimationFrame(s.current)}}),[]),function(t){t?(u.observe(t),n&&n(t),o.current=t):(u.unobserve(o.current),o.current=null)}};function N(t,n){var r=e.useState(function(t,e){return function(){var n=e;return t((function(t){n=t})),n}}(t,n)),i=r[0],o=r[1];return e.useEffect((function(){return t(o),function(){return t(void 0)}}),[t]),i}function O(t){var e,n=!1;return function(){return n||(n=!0,e=t()),e}}var _=O((function(){var t=document.createElement("div");return t.style.position="-webkit-sticky","-webkit-sticky"===t.style.position?"-webkit-sticky":"sticky"})),V=function(t){return n.createElement("div",{style:{height:t.height+"px",position:"absolute",top:0}}," ")},W=n.memo((function(){var t=e.useContext(o),r=t.isSeeking,i=t.topList,s=t.itemRender,u=N(t.list,[]),a=N(i,[]),l=N(s,!1),f=N(r,!1),c=[],h=0,p=[],d=a.reduce((function(t,e){return t+e.size}),0);return a.forEach((function(t,e){var n=t.index;p.push(n);var r={top:h+"px",marginTop:0===e?-d+"px":void 0,zIndex:2,position:_()};l&&c.push(l.render(t,{key:n,"data-index":n,"data-known-size":t.size,renderPlaceholder:f,style:r})),h+=t.size})),u.forEach((function(t){p.indexOf(t.index)>-1||l&&c.push(l.render(t,{key:t.index,"data-index":t.index,"data-known-size":t.size,renderPlaceholder:f}))})),n.createElement(n.Fragment,null,c)})),P={height:"40rem",overflowY:"auto",WebkitOverflowScrolling:"touch",position:"relative",outline:"none"},F=function(t){var r=t.className,i=t.style,o=t.reportScrollTop,s=t.scrollTo,u=t.children,a=e.useRef(null),l=e.useRef(null),f=e.useRef(),c=e.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=e.useCallback((function(t){t?(t.addEventListener("scroll",c,{passive:!0}),a.current=t):a.current&&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))})),n.createElement("div",{ref:h,style:i,tabIndex:0,className:r},u)},j=function(t){var e=t.children,i=t.style,o=t.className,s=t.ScrollContainer,u=t.scrollTop,a=t.scrollTo;return n.createElement(void 0===s?F:s,{style:r.__assign(r.__assign({},P),i),reportScrollTop:u,scrollTo:a,className:o},e)},A=function(t){return n.createElement("footer",{ref:t.footerRef},t.children)},B=function(t){return n.createElement("div",{ref:t.listRef,style:t.style},t.children)},K=function(t){var r=t.footer,i=t.FooterContainer,s=void 0===i?A:i,u=E(e.useContext(o).footerHeight);return n.createElement(s,{footerRef:u},r())},D=function(t){var r=t.fixedItemHeight,i=t.children,s=t.ListContainer,u=e.useContext(o),a=u.listHeight,l=u.itemHeights,f={marginTop:N(u.listOffset,0)+"px"},c=E(a,(function(){}),(function(t){if(!r){var e=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(e)}}));return n.createElement(s,{listRef:c,style:f},i)},q=function(t){var r=t.style,i=t.footer,s=t.fixedItemHeight,u=t.ScrollContainer,a=t.ListContainer,l=t.FooterContainer,f=t.className,c=e.useContext(o),h=c.scrollTo,p=c.scrollTop,d=c.viewportHeight,g=N(c.totalHeight,0),v=E(d);return n.createElement(j,{style:r,ScrollContainer:u,className:f,scrollTo:h,scrollTop:function(t){p(Math.max(t,0))}},n.createElement("div",{ref:v,style:z},n.createElement(D,{fixedItemHeight:s,ListContainer:a},n.createElement(W,null),i&&n.createElement(K,{footer:i,FooterContainer:l}))),n.createElement(V,{height:g}))},G={},U=n.memo((function(t){return n.createElement(o.Provider,{value:t.contextValue},n.createElement(q,{style:t.style||G,className:t.className,footer:t.footer,fixedItemHeight:void 0!==t.itemHeight,ScrollContainer:t.ScrollContainer,FooterContainer:t.FooterContainer,ListContainer:t.ListContainer||B}))})),Y=e.forwardRef((function(t,r){var i=e.useState((function(){return R(t)}))[0];return e.useImperativeHandle(r,(function(){return{scrollToIndex:function(t){i.scrollToIndex(t)},adjustForPrependedItems:function(t){i.adjustForPrependedItems(t)}}}),[i]),e.useEffect((function(){return i.isScrolling(t.scrollingStateChange),i.atBottomStateChange(t.atBottomStateChange),i.endReached(t.endReached),i.topItemCount(t.topItems||0),i.totalCount(t.totalCount),t.initialItemCount&&i.initialItemCount(t.initialItemCount),i.itemsRendered(t.itemsRendered),i.totalListHeightChanged(t.totalListHeightChanged),i.followOutput(!!t.followOutput),i.maxRangeSize(t.maxHeightCacheSize||Infinity),i.rangeChanged(t.rangeChanged),i.scrollSeekConfiguration(t.scrollSeek),i.computeItemKey(t.computeItemKey||function(t){return t}),i.itemContainer(t.ItemContainer||"div"),i.renderProp(t.item),i.dataKey(t.dataKey),function(){i.itemsRendered(void 0),i.totalListHeightChanged(void 0)}}),[i,t.scrollingStateChange,t.atBottomStateChange,t.endReached,t.topItems,t.totalCount,t.initialItemCount,t.itemsRendered,t.totalListHeightChanged,t.followOutput,t.maxHeightCacheSize,t.rangeChanged,t.scrollSeek,t.item,t.ItemContainer,t.computeItemKey,t.dataKey]),n.createElement(U,{contextValue:i,style:t.style,className:t.className,footer:t.footer,itemHeight:t.itemHeight,ScrollContainer:t.ScrollContainer,FooterContainer:t.FooterContainer,ListContainer:t.ListContainer})}));Y.displayName="Virtuoso";var J=e.forwardRef((function(t,r){var i=e.useState(R(t))[0];return e.useImperativeHandle(r,(function(){return{scrollToIndex:function(t){i.scrollToIndex(t)}}}),[i]),e.useEffect((function(){return i.endReached(t.endReached),i.rangeChanged(t.rangeChanged),i.atBottomStateChange(t.atBottomStateChange),i.isScrolling(t.scrollingStateChange),i.groupCounts(t.groupCounts),i.groupIndices(t.groupIndices),i.itemsRendered(t.itemsRendered),i.totalListHeightChanged(t.totalListHeightChanged),i.renderProp(t.item),i.groupRenderProp(t.group),i.itemContainer(t.ItemContainer||"div"),i.groupContainer(t.GroupContainer||"div"),i.scrollSeekConfiguration(t.scrollSeek),function(){i.itemsRendered(void 0),i.totalListHeightChanged(void 0)}}),[i,t.endReached,t.rangeChanged,t.atBottomStateChange,t.scrollingStateChange,t.groupCounts,t.groupIndices,t.itemsRendered,t.totalListHeightChanged,t.item,t.group,t.GroupContainer,t.ItemContainer]),n.createElement(U,{contextValue:i,style:t.style,className:t.className,footer:t.footer,itemHeight:t.itemHeight,ScrollContainer:t.ScrollContainer,FooterContainer:t.FooterContainer,ListContainer:t.ListContainer})}));J.displayName="GroupedVirtuoso";var 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(t){void 0===t&&(t=0);var e=l([0,0,void 0,void 0]),n=l(0),r=l(0),i=l(0),o=l([0,tt(t-1,0)]),s=l(0),u=l(0),a=f();c(e,r,i,n).pipe(y(o)).subscribe((function(t){var e=t[0],n=e[0],r=n[0],i=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 o.next([0,-1]),void u.next(0);var d=p[0],g=p[1],v=et(r/a),m=function(t,e){return void 0===e&&(e=X),e(t/v)},y=function(t){var e=t?[0,c]:[c,0],n=e[1],r=v*X((f-e[0])/l),s=v*Q((f+i+n)/l)-1;s=Z(h-1,s),r=Z(s,tt(0,r)),o.next([r,s]),u.next(m(r)*l)},x=l*m(d),$=l*m(g)+l;h<g-1?y(!0):x>f?y(!1):$<f+i&&y(!0),s.next(l*m(h,Q))}}));var p=a.pipe(y(e,n),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"}}))),d=x(r),g=f(),v=0;return o.pipe(y(n)).subscribe((function(t){var e=t[0][1],n=t[1];0!==n&&e===n-1&&v!==e&&(v=e,g.next(e))})),{gridDimensions:L(e),totalCount:L(n),scrollTop:L(r),overscan:L(i),scrollToIndex:L(a),itemRange:M(o),totalHeight:M(s),listOffset:M(u),scrollTo:M(p),isScrolling:M(d),endReached:M(g)}},rt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.state=nt(e.props.initialItemCount),e}return r.__extends(e,t),e.getDerivedStateFromProps=function(t,e){return e.overscan(t.overscan||0),e.totalCount(t.totalCount),e.isScrolling(t.scrollingStateChange),e.endReached(t.endReached),null},e.prototype.scrollToIndex=function(t){this.state.scrollToIndex(t)},e.prototype.render=function(){return n.createElement(it,r.__assign({},this.props,{engine:this.state}))},e}(n.PureComponent),it=function(t){var r,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,g=t.itemClassName,v=void 0===g?"virtuoso-grid-item":g,m=t.listClassName,y=void 0===m?"virtuoso-grid-list":m,x=t.engine,$=t.style,I=void 0===$?{height:"40rem"}:$,C=x.itemRange,T=x.listOffset,b=x.gridDimensions,k=x.scrollTo,w=x.scrollTop,S=N(x.totalHeight,0),H={marginTop:N(T,0)+"px"},M=N(C,[0,0]),L=(r=function(t){var e=t.element.firstChild.firstChild;b([t.width,t.height,e.offsetWidth,e.offsetHeight])},o=e.useRef(null),s=e.useRef([0,0]),u=new i((function(t){var e=t[0].contentRect,n=e.width,i=e.height;s.current[0]===n&&s.current[1]===i||(s.current=[n,i],r({element:t[0].target,width:Math.round(n),height:Math.round(i)}))})),function(t){t?(u.observe(t),o.current=t):(u.unobserve(o.current),o.current=null)});return n.createElement(j,{style:I,ScrollContainer:a,className:p,scrollTo:k,scrollTop:w},n.createElement("div",{ref:L,style:z},n.createElement(h,{style:H,className:y},function(t,e,r,i){for(var o=t[1],s=[],u=t[0];u<=o;u++)s.push(n.createElement(i,{key:u,className:r},e(u)));return s}(M,d,v,f))),n.createElement(V,{height:S}))};exports.GroupedVirtuoso=J,exports.Virtuoso=Y,exports.VirtuosoGrid=rt,exports.VirtuosoPresentation=U; | ||
//# sourceMappingURL=react-virtuoso.cjs.production.min.js.map |
@@ -23,2 +23,3 @@ import React, { CSSProperties, ReactElement } from 'react'; | ||
endReached?: (index: number) => void; | ||
initialItemCount?: number; | ||
} | ||
@@ -25,0 +26,0 @@ declare type VirtuosoGridState = ReturnType<typeof VirtuosoGridEngine>; |
@@ -10,3 +10,3 @@ import { TScrollLocation } from './EngineCommons'; | ||
number]; | ||
export declare const VirtuosoGridEngine: () => { | ||
export declare const VirtuosoGridEngine: (initialItemCount?: number) => { | ||
gridDimensions: import("./rxio").TInput<GridDimensions>; | ||
@@ -13,0 +13,0 @@ totalCount: import("./rxio").TInput<number>; |
{ | ||
"name": "react-virtuoso", | ||
"sideEffects": false, | ||
"version": "0.16.4", | ||
"version": "0.16.5", | ||
"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
727055
5978