UNPKG

rcx-virtual-list

Version:

Maximum performance for extremely large lists.<br/> Animation of elements is supported.

3 lines 41.5 kB
/*! For license information please see index.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.$=t(require("react")):e.$=t(e.react)}(self,e=>(()=>{"use strict";var t={155:t=>{t.exports=e},698:(e,t)=>{var i=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function n(e,t,s){var n=null;if(void 0!==s&&(n=""+s),void 0!==t.key&&(n=""+t.key),"key"in t)for(var r in s={},t)"key"!==r&&(s[r]=t[r]);else s=t;return t=s.ref,{$$typeof:i,type:e,key:n,ref:void 0!==t?t:null,props:s}}t.Fragment=s,t.jsx=n,t.jsxs=n},848:(e,t,i)=>{e.exports=i(698)}},i={};function s(e){var n=i[e];if(void 0!==n)return n.exports;var r=i[e]={exports:{}};return t[e](r,r.exports,s),r.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var i in t)s.o(t,i)&&!s.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};s.r(n),s.d(n,{VirtualList:()=>te,default:()=>ie});var r,o,a=s(848),l=s(155),h=s.n(l);!function(e){e.NORMAL="normal",e.ADVANCED="advanced"}(r||(r={})),function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(o||(o={}));const c=24,d=2,u=100,p=!1,_=!1,f=!1,m="id",g=o.VERTICAL,v=r.NORMAL,S="instant",z="block",y="none",b="visible",x="hidden",C="100%",O="auto",B="absolute",T="translate3d",k=`${T}(0,0,0)`,E="top",I="left",D="width",R="height",M="px",L="scroll",$="scrollend",A=function(e){let t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const s=()=>{void 0!==t&&clearTimeout(t)};return{execute:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];s(),t=setTimeout(()=>{e(...r)},i)},dispose:s}};class w{constructor(){this._listeners={},this._disposed=!1}dispatch(e){const t=this,i=this._listeners[e];if(Array.isArray(i)){for(var s=arguments.length,n=new Array(s>1?s-1:0),r=1;r<s;r++)n[r-1]=arguments[r];for(let e=0,s=i.length;e<s;e++){const s=i[e];s&&s.apply(t,n)}}}dispatchAsync(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];queueMicrotask(()=>{this._disposed||this.dispatch(e,...i)})}hasEventListener(e,t){const i=e;return!!(this._listeners.hasOwnProperty(i)&&this._listeners[i].findIndex(e=>e===t)>-1)}addEventListener(e,t){const i=e;this._listeners.hasOwnProperty(i)||(this._listeners[i]=[]),this._listeners[i].push(t)}removeEventListener(e,t){const i=e;if(!this._listeners.hasOwnProperty(i))return;const s=this._listeners[i],n=s.findIndex(e=>e===t);n>-1&&(s.splice(n,1),0===s.length&&delete this._listeners[i])}removeAllListeners(){const e=Object.keys(this._listeners);for(;e.length>0;){const t=e.pop();if(t){const e=this._listeners[t];if(Array.isArray(e))for(;e.length>0;){const i=e.pop();i&&this.removeEventListener(t,i)}}}}dispose(){this._disposed=!0,this.removeAllListeners()}}class j{constructor(e){this._dict={},e&&(this._dict=Object.assign({},e._dict))}get(e){const t=String(e);return this._dict[t]}set(e,t){const i=String(e);return this._dict[i]=t,this}has(e){return this._dict.hasOwnProperty(String(e))}delete(e){const t=String(e);delete this._dict[t]}clear(){this._dict={}}}const V="-1",N="0",H="1";class P extends w{get delta(){return this._delta}set deltaDirection(e){this._deltaDirection=e,this._scrollDirection=this.calcScrollDirection(e)}get deltaDirection(){return this._deltaDirection}get scrollDirection(){return this._scrollDirection}get version(){return this._version}constructor(){super(),this._map=new j,this._snapshot=new j,this._version=0,this._previousVersion=this._version,this._delta=0,this._deltaDirection=0,this._scrollDirectionCache=[],this._scrollDirection=0,this._clearScrollDirectionDebounce=A(()=>{for(;this._scrollDirectionCache.length>10;)this._scrollDirectionCache.shift()},10),this.lifeCircle()}changesDetected(){return this._version!==this._previousVersion}stopLifeCircle(){clearTimeout(this._lifeCircleTimeout)}nextTick(e){if(!this._disposed)return this._lifeCircleTimeout=setTimeout(()=>{e()}),this._lifeCircleTimeout}lifeCircle(){this.fireChangeIfNeed(),this.lifeCircleDo()}lifeCircleDo(){this._previousVersion=this._version,this.nextTick(()=>{this.lifeCircle()})}clearScrollDirectionCache(){this._clearScrollDirectionDebounce.execute()}calcScrollDirection(e){for(;this._scrollDirectionCache.length>=50;)this._scrollDirectionCache.shift();this._scrollDirectionCache.push(e);const t={[V]:0,[N]:0,[H]:0};for(let i=0,s=this._scrollDirectionCache.length,n=s-1;i<s;i++)if(t[String(this._scrollDirectionCache[i])]+=1,i===n)for(let i in t)i!==String(e)&&(t[i]-=1);return t[V]>t[0]&&t[V]>t[H]?-1:t[H]>t[V]&&t[H]>t[0]?1:0}bumpVersion(){if(this.changesDetected())return;const e=this._version===Number.MAX_SAFE_INTEGER?0:this._version+1;this._version=e}fireChangeIfNeed(){this.changesDetected()&&this.dispatch("change",this.version)}set(e,t){if(this._map.has(e)){const i=this._map.get(e),s=t;return i.width===s.width&&(i.height,s.height),this._map}const i=this._map.set(e,t);return this.bumpVersion(),i}has(e){return this._map.has(e)}get(e){return this._map.get(e)}snapshot(){this._snapshot=new j(this._map)}dispose(){super.dispose(),this.stopLifeCircle(),this._snapshot.clear(),this._map.clear()}}class W{set displayObjectIndexMapById(e){this._displayObjectIndexMapById!==e&&(this._displayObjectIndexMapById=e)}get displayObjectIndexMapById(){return this._displayObjectIndexMapById}get trackMap(){return this._trackMap}set trackingPropertyName(e){this._trackingPropertyName=e}constructor(e){this._displayObjectIndexMapById={},this._trackMap={},this._trackingPropertyName=e}track(e,t,i,s){var n;if(!e)return;const r=this._trackingPropertyName,o=[...t],a=0===s||1===s;let l=!1;for(let s=a?0:e.length-1,h=a?e.length:0;a?s<h:s>=h;a?s++:s--){const a=e[s],h=a[r];if(this._trackMap&&this._trackMap.hasOwnProperty(h)){const e=this._trackMap[h],s=t[this._displayObjectIndexMapById[e]],r=null===(n=null==s?void 0:s.current)||void 0===n?void 0:n.id;if((null==s?void 0:s.current)&&r===e){const e=o.findIndex(e=>e.current&&e.current.id===r);if(e>-1){(null==i?void 0:i.current)&&(a.config.snapped||a.config.snappedOut)&&(l=!0,i.current.data=a,i.current.show()),s.current.data=a,(null==i?void 0:i.current)&&(a.config.snapped||a.config.snappedOut)?s.current.hide():s.current.show(),o.splice(e,1);continue}}delete this._trackMap[h]}if(o.length>0){const t=o.shift(),n=e[s];(null==t?void 0:t.current)&&((null==i?void 0:i.current)&&(n.config.snapped||n.config.snappedOut)&&(l=!0,i.current.data=n,i.current.show()),t.current.data=n,(null==i?void 0:i.current)&&(n.config.snapped||n.config.snappedOut)?t.current.hide():t.current.show(),this._trackMap&&(this._trackMap[h]=t.current.id))}}if(o.length)for(let e=0,t=o.length;e<t;e++){const t=o[e];(null==t?void 0:t.current)&&t.current.hide()}l||(null==i?void 0:i.current)&&(i.current.data=null,i.current.hide())}untrackComponentByIdProperty(e){if(!e)return;const t=this._trackingPropertyName;this._trackMap&&void 0!==e[t]&&delete this._trackMap[t]}dispose(){this._trackMap=null}}const U={extremumThreshold:2,bufferSize:10},F="change";var q;!function(e){e[e.CREATE=0]="CREATE",e[e.UPDATE=1]="UPDATE",e[e.DELETE=2]="DELETE",e[e.NOT_CHANGED=3]="NOT_CHANGED"}(q||(q={}));class G extends P{set items(e){this._items!==e&&(this._items=e)}set displayComponents(e){this._displayComponents!==e&&(this._displayComponents=e)}set snapedDisplayComponent(e){this._snapedDisplayComponent!==e&&(this._snapedDisplayComponent=e)}set isSnappingMethodAdvanced(e){this._isSnappingMethodAdvanced!==e&&(this._isSnappingMethodAdvanced=e)}set trackingPropertyName(e){this._tracker.trackingPropertyName=e}constructor(e){super(),this._isSnappingMethodAdvanced=!1,this._deletedItemsMap={},this._crudDetected=!1,this._previousTotalSize=0,this._scrollDelta=0,this.isAdaptiveBuffer=!0,this._bufferSequenceExtraThreshold=15,this._maxBufferSequenceLength=30,this._bufferSizeSequence=[],this._bufferSize=0,this._defaultBufferSize=0,this._maxBufferSize=this._defaultBufferSize,this._resetBufferSizeTimeout=1e4,this._previousScrollSize=0,this._tracker=new W(e)}set(e,t){if(this._map.has(e)){const i=this._map.get(e);if((null==i?void 0:i.width)===t.width&&i.height===t.height)return this._map}const i=this._map.set(e,t);return this.bumpVersion(),i}get crudDetected(){return this._crudDetected}fireChangeIfNeed(){this.changesDetected()&&this.dispatch(F,this._version)}get scrollDelta(){return this._scrollDelta}get bufferSize(){return this._bufferSize}lifeCircle(){this.fireChangeIfNeed(),this.lifeCircleDo()}resetCollection(e,t){null==e||e!==this._previousCollection?(this.updateCache(this._previousCollection,e,t),this._previousCollection=e):console.warn("Attention! The collection must be immutable.")}updateCache(e,t,i){let s=!1;if(!t||0===t.length){if(e)for(let t=0,i=e.length;t<i;t++){const i=e[t].id;s=!0,this._map.has(i)&&this._map.delete(i)}return}if(!e||0===e.length){if(t)for(let e=0,n=t.length;e<n;e++){s=!0;const n=t[e].id;this._map.set(n,{width:i,height:i,method:q.CREATE})}return}const n={};for(let e=0,i=t.length;e<i;e++){const i=t[e];i&&(n[i.id]=i)}const r={},o={},a={},l={};for(let t=0,h=e.length;t<h;t++){const h=e[t],c=h.id;if(h){if(n.hasOwnProperty(c)){if(h===n[c]){r[h.id]=h,this._map.set(c,Object.assign(Object.assign({},this._map.get(c)||{width:i,height:i}),{method:q.NOT_CHANGED}));continue}s=!0,l[h.id]=h,this._map.set(c,Object.assign(Object.assign({},this._map.get(c)||{width:i,height:i}),{method:q.UPDATE}));continue}s=!0,o[h.id]=h,a[t]=this._map.get(h.id),this._map.delete(c)}}for(let e=0,n=t.length;e<n;e++){const n=t[e],a=n.id;!n||o.hasOwnProperty(a)||l.hasOwnProperty(a)||r.hasOwnProperty(a)||(s=!0,this._map.set(a,{width:i,height:i,method:q.CREATE}))}this._crudDetected=s,this._deletedItemsMap=a}getItemPosition(e,t,i){const s=Object.assign({fromItemId:e,stickyMap:t},i);this._defaultBufferSize=s.bufferSize,this._maxBufferSize=s.maxBufferSize;const{scrollSize:n,isFromItemIdFound:r}=this.recalculateMetrics(Object.assign(Object.assign({},s),{dynamicSize:this._crudDetected||s.dynamicSize,previousTotalSize:this._previousTotalSize,crudDetected:this._crudDetected,deletedItemsMap:this._deletedItemsMap}));return r?n:-1}updateCollection(e,t,i){const s=Object.assign({stickyMap:t},i),n=this._crudDetected,r=this._deletedItemsMap;s.dynamicSize&&this.cacheElements(),this._defaultBufferSize=s.bufferSize,this._maxBufferSize=s.maxBufferSize;const o=this.recalculateMetrics(Object.assign(Object.assign({},s),{collection:e,previousTotalSize:this._previousTotalSize,crudDetected:this._crudDetected,deletedItemsMap:r}));return this._delta+=o.delta,this.updateAdaptiveBufferParams(o,e.length),this._previousTotalSize=o.totalSize,this._deletedItemsMap={},this._crudDetected=!1,s.dynamicSize&&this.snapshot(),{displayItems:this.generateDisplayCollection(e,t,Object.assign({},o)),totalSize:o.totalSize,delta:o.delta,crudDetected:n}}getNearestItem(e,t,i,s){return this.getElementFromStart(e,t,this._map,i,s)}updateAdaptiveBufferParams(e,t){this.disposeClearBufferSizeTimer();const i=e.scrollSize+this._delta,s=Math.abs(this._previousScrollSize-i);this._previousScrollSize=i;const n=Math.min(5*Math.floor(s/e.typicalItemSize),t),r=n<this._defaultBufferSize?this._defaultBufferSize:n,o=r>this._maxBufferSize?this._maxBufferSize:r;this._bufferSize=((e,t,i,s)=>{const{extremumThreshold:n=U.extremumThreshold,bufferSize:r=U.bufferSize}=null!=s?s:U;if(e<i){let e=0;for(;e<n;)t.push(i),e++}else t.push(i);for(;t.length>=r;)t.shift();const o=t.length;let a=0;for(let e=0;e<o;e++)a+=t[e];return Math.ceil(a/o)})(this._bufferSize,this._bufferSizeSequence,o,{extremumThreshold:this._bufferSequenceExtraThreshold,bufferSize:this._maxBufferSequenceLength}),this.startResetBufferSizeTimer()}startResetBufferSizeTimer(){this._resetBufferSizeTimer=setTimeout(()=>{this._bufferSize=this._defaultBufferSize,this._bufferSizeSequence=[]},this._resetBufferSizeTimeout)}disposeClearBufferSizeTimer(){clearTimeout(this._resetBufferSizeTimer)}getElementFromStart(e,t,i,s,n){const r=n?R:D;let o=0;for(let n=0,a=t.length;n<a;n++){const a=t[n];let l=0;if(i.has(a.id)){const e=i.get(a.id);l=e?e[r]:s}else l=s;if(o>e)return a;o+=l}}getElementNumToEnd(e,t,i,s,n,r){let o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;const a=r?R:D;let l=0,h=0;for(let r=t.length-o-1;r>=e;r--){const e=t[r];let o=0;if(i.has(e.id)){const t=i.get(e.id);o=t?t[a]:s}else o=s;if(l+=o,h++,l>n)return{num:0,offset:l}}return{num:h,offset:l}}recalculateMetrics(e){var t,i,s,n;const{fromItemId:r,bounds:o,collection:a,dynamicSize:l,isVertical:h,itemSize:c,bufferSize:d,scrollSize:u,snap:p,stickyMap:_,enabledBufferOptimization:f,previousTotalSize:m,crudDetected:g,deletedItemsMap:v}=e,S=Math.max(d,this._bufferSize),{width:z,height:y}=o,b=h?R:D,x=h?y:z,C=a.length,O=c,B=h?z:O,T=h?O:y,k=this._map,E=this._snapshot,I=Math.ceil(x/O),M=Math.floor(u),L=[],$=void 0!==r&&"number"==typeof r&&r>-1||"string"==typeof r&&r>"-1";let A=0,w=0;if(f)switch(this.scrollDirection){case 1:A=0,w=S;break;case-1:A=S,w=0;break;default:A=w=S}else A=w=S;let j,V,N=-1,H=0,P=-1,W=0,U=0,F=0,G=0,Q=0,Z=0,X=0,J=0,K=0,Y=0,ee=-1,te=!1,ie=Y,se=0,ne=!1;if(l){let e,s=0,n=0;for(let o=0,l=a.length;o<l;o++){const l=o+1,c=a[o],d=c.id;let p=0,f=0,m=q.NOT_CHANGED;if(k.has(d)){const e=k.get(d)||{width:O,height:O};switch(p=e[b],m=null!==(t=null==e?void 0:e.method)&&void 0!==t?t:q.UPDATE,m){case q.UPDATE:{const t=E.get(d);f=p-(t?t[b]:O),k.set(d,Object.assign(Object.assign({},e),{method:q.NOT_CHANGED}));break}case q.CREATE:f=O,k.set(d,Object.assign(Object.assign({},e),{method:q.NOT_CHANGED}))}}if(v.hasOwnProperty(o)){const e=v[o],t=null!==(i=null==e?void 0:e[b])&&void 0!==i?i:O;s<u-t&&(K+=t)}if(se+=p,$){if(void 0===j)if(d!==r&&_&&1===_[d]&&(n=p,e=c),d===r){if(ne=!0,ee=o,e&&_){const{num:e}=this.getElementNumToEnd(o,a,k,O,x,h);if(e>0)te=!0,s-=x-p;else if(_&&!_[c.id]&&s>=u&&s<u+n){const e=u-n;Q-=e-s,s=e}else s-=n,Q-=n}j=c,Y=s}else L.push(p),Q+=p,N=l}else s<=u-p&&(L.push(p),Q+=p,N=l);if($)(void 0===j||s<Y+x+p)&&(P=l,Z+=p,H=P+w);else if(s<=u+x+p){if(P=l,Z+=p,H=P+w,s<=u-p)switch(m){case q.CREATE:X+=f;break;case q.UPDATE:J+=f;break;case q.DELETE:K+=f}}else o<H&&(G+=p);s+=p}if(te){const{num:e}=this.getElementNumToEnd(a.length-(I<0?0:a.length-I),a,k,O,x,h,a.length-(a.length-(ee+1)));e>0&&(N-=e)}N<=-1&&(N=0),P<=-1&&(P=0),ie=$?Y:u,L.splice(0,L.length-A),L.forEach(e=>{F+=e}),W=Math.min(N,A),U=P+w>C?C-P:w}else{if(g){let e=0;for(let t=0,i=a.length;t<i;t++){const i=a[t].id;let r=O,o=q.NOT_CHANGED;if(k.has(i)){const e=k.get(i);o=null!==(s=null==e?void 0:e.method)&&void 0!==s?s:q.UPDATE,o===q.CREATE&&k.set(i,Object.assign(Object.assign({},e),{method:q.NOT_CHANGED}))}if(v.hasOwnProperty(t)){const i=v[t],s=null!==(n=null==i?void 0:i[b])&&void 0!==n?n:O;e<u-s&&(K+=s)}if(e<u-r)switch(o){case q.CREATE:case q.UPDATE:J+=r;break;case q.DELETE:K+=r}e+=r}}N=Math.floor(u/O),P=Math.ceil((u+x)/O),W=Math.min(N,S),U=P+S>C?C-P:S,F=W*O,G=U*O,Q=N*O,Z=P*O,se=C*O,ie=u*(0!==se?m/se:0)}V=Math.min(N-W,C>0?C-1:0);const re=P-N;return{delta:J+X-K,normalizedItemWidth:B,normalizedItemHeight:T,width:z,height:y,dynamicSize:l,itemSize:c,itemsFromStartToScrollEnd:N,itemsFromStartToDisplayEnd:P,itemsOnDisplayWeight:Z-F,itemsOnDisplayLength:re,isVertical:h,leftHiddenItemsWeight:Q,leftItemLength:W,leftItemsWeight:F,renderItems:re+W+U,rightItemLength:U,rightItemsWeight:G,scrollSize:ie,leftSizeOfAddedItems:X,sizeProperty:b,snap:p,snippedPos:M,startIndex:V,startPosition:Q-F,totalItemsToDisplayEndWeight:Z,totalLength:C,totalSize:se,typicalItemSize:O,isFromItemIdFound:ne}}clearDeltaDirection(){this.clearScrollDirectionCache()}clearDelta(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._delta=0,e&&this.clearScrollDirectionCache()}changes(){this.bumpVersion()}generateDisplayCollection(e,t,i){var s,n,r;const{width:o,height:a,normalizedItemWidth:l,normalizedItemHeight:h,dynamicSize:c,itemsOnDisplayLength:d,itemsFromStartToScrollEnd:u,isVertical:p,renderItems:_,scrollSize:f,sizeProperty:m,snap:g,snippedPos:v,startPosition:S,totalLength:z,startIndex:y,typicalItemSize:b}=i,x=[];if(e.length){const i=v,C=this.isSnappingMethodAdvanced,O=p?a:o,B=O;let T,k,E,I,D=S,R=_,M=-1,L=0,$=-1,A=0;if(g)for(let n=Math.min(u>0?u:0,z-1);n>=0;n--){if(!e[n])continue;const r=e[n].id,o=t[r],a=c&&(null===(s=this.get(r))||void 0===s?void 0:s[m])||b;if(1===o){const t={isVertical:p,sticky:o,snap:g,snapped:!0,snappedOut:!1,dynamic:c,isSnappingMethodAdvanced:C,zIndex:"1"};T={id:r,measures:{x:p?0:i,y:p?i:0,width:p?l:a,height:p?a:h,delta:0},data:e[n],config:t},M=n,L=a,x.push(T);break}}if(g){const i=u+d-1;for(let s=Math.min(i,z>0?z-1:0),r=z;s<r;s++){const i=e[s].id,r=t[i],o=c&&(null===(n=this.get(i))||void 0===n?void 0:n[m])||b;if(2===r){const t=p?l:o,n=p?o:h,a={isVertical:p,sticky:r,snap:g,snapped:!0,snappedOut:!1,dynamic:c,isSnappingMethodAdvanced:C,zIndex:"1"};E={id:i,measures:{x:p?0:B-t,y:p?B-n:0,width:t,height:n,delta:0},data:e[s],config:a},$=s,A=o,x.push(E);break}}}let w=y;for(;R>0&&!(w>=z);){const s=e[w].id,n=c&&(null===(r=this.get(s))||void 0===r?void 0:r[m])||b;if(s!==(null==T?void 0:T.id)&&s!==(null==E?void 0:E.id)){const r=g&&(1===t[s]&&D<=f||2===t[s]&&D>=f+O-n),o={x:p?1===t[s]?0:O-n:D,y:p?D:2===t[s]?O-n:0,width:p?l:n,height:p?n:h,delta:0},a={isVertical:p,sticky:t[s],snap:g,snapped:!1,snappedOut:!1,dynamic:c,isSnappingMethodAdvanced:C,zIndex:"0"};r&&(a.zIndex="2");const d={id:s,measures:o,data:e[w],config:a};!k&&M<w&&1===t[s]&&D<=f+n+L?(d.measures.x=p?0:r?i:D,d.measures.y=p?r?i:D:0,k=d,k.config.snapped=r,k.measures.delta=p?d.measures.y-f:d.measures.x-f,k.config.zIndex="3"):!I&&$>w&&2===t[s]&&D>=f+O-n-A&&(d.measures.x=p?0:r?B-n:D,d.measures.y=p?r?B-n:D:0,I=d,I.config.zIndex="3",I.config.snapped=r,I.measures.delta=p?d.measures.y-f:d.measures.x-f),x.push(d)}R-=1,D+=n,w++}const j=p?"y":"x";k&&T&&k.measures[j]<=f+L&&(k.measures[j]>f?(T.measures[j]=k.measures[j]-L,T.config.snapped=k.config.snapped=!1,T.config.snappedOut=!0,T.config.sticky=1,T.measures.delta=p?T.measures.y-f:T.measures.x-f):(k.config.snapped=!0,k.measures.delta=p?k.measures.y-f:k.measures.x-f)),I&&E&&I.measures[j]>=f+O-A-I.measures[m]&&(I.measures[j]<f+O-A?(E.measures[j]=I.measures[j]+I.measures[m],E.config.snapped=I.config.snapped=!1,E.config.snappedOut=!0,E.config.sticky=2,E.measures.delta=p?E.measures.y-f:E.measures.x-f):(I.config.snapped=!0,I.measures.delta=p?I.measures.y-f:I.measures.x-f))}return x}track(){this._items&&this._displayComponents&&this._tracker.track(this._items,this._displayComponents,this._snapedDisplayComponent,this.scrollDirection)}setDisplayObjectIndexMapById(e){this._tracker.displayObjectIndexMapById=e}untrackComponentByIdProperty(e){this._tracker.untrackComponentByIdProperty(e)}getItemBounds(e){if(this.has(e))return this.get(e)}cacheElements(){if(this._displayComponents)for(let e=0,t=this._displayComponents.length;e<t;e++){const t=this._displayComponents[e];if(t.current){const e=t.current.itemId;if(void 0===e)continue;const i=t.current.getBounds();this.set(e,i)}}}dispose(){super.dispose(),this.disposeClearBufferSizeTimer(),this._tracker&&this._tracker.dispose()}}class Q{get direction(){return this._direction}get scrollSize(){return this._scrollSize}get scrollWeight(){return this._scrollWeight}get isVertical(){return this._isVertical}get listSize(){return this._listSize}get size(){return this._size}get isStart(){return this._isStart}get isEnd(){return this._isEnd}get delta(){return this._delta}get scrollDelta(){return this._scrollDelta}constructor(e){this._direction=1,this._scrollSize=0,this._scrollWeight=0,this._isVertical=!0,this._listSize=0,this._size=0,this._isStart=!0,this._isEnd=!1,this._delta=0,this._scrollDelta=0;const{direction:t,isVertical:i,container:s,list:n,delta:r,scrollDelta:o}=e;this._direction=t,this._isVertical=i,this._scrollSize=i?s.scrollTop:s.scrollLeft,this._scrollWeight=i?s.scrollHeight:s.scrollWidth,this._listSize=i?n.offsetHeight:n.offsetWidth,this._size=i?s.offsetHeight:s.offsetWidth,this._isEnd=this._scrollSize+this._size===this._scrollWeight,this._delta=r,this._scrollDelta=o,this._isStart=0===this._scrollSize}}const Z=[o.HORIZONTAL,"horizontal"],X=[o.VERTICAL,"vertical"],J=()=>(0,a.jsx)(a.Fragment,{});class K extends h().Component{get id(){return this._id}get regular(){return this._regular}get data(){return this._data}set data(e){this._data!==e&&(this._data=e,this.update(),this.setState(e=>Object.assign(Object.assign({},e),{data:this._data})))}set regularLength(e){this._regularLength!==e&&(this._regularLength=e,this.update())}get regularLength(){return this._regularLength}get item(){return this._data}get itemId(){var e;return null===(e=this._data)||void 0===e?void 0:e.id}get element(){var e;return null===(e=this._$elementRef)||void 0===e?void 0:e.current}get renderer(){return this._renderer}set renderer(e){this._renderer!==e&&(this._renderer=e,this.update())}constructor(e){var t,i;super(e),this._$elementRef=(0,l.createRef)(),this._$listItemRef=(0,l.createRef)(),this._regular=!1,this._data=void 0,this._regularLength=C,this._renderer=J,this._id=K.__nextId=K.__nextId===Number.MAX_SAFE_INTEGER?0:K.__nextId+1,this._regular=null!==(t=e.regular)&&void 0!==t&&t,this._renderer=null!==(i=e.renderer)&&void 0!==i?i:J,this.state={data:void 0}}update(){const e=this._data,t=this._regular,i=this._regularLength,s=this._$elementRef.current;if(e&&s){const n=s.style;n.zIndex=e.config.zIndex,e.config.snapped?(n.transform=1===e.config.sticky?k:`${T}(${e.config.isVertical?0:e.measures.x}${M}, ${e.config.isVertical?e.measures.y:0}${M} , 0)`,e.config.isSnappingMethodAdvanced||(n.position="sticky")):(n.position=B,n.transform=t?`${T}(${e.config.isVertical?0:e.measures.delta}${M}, ${e.config.isVertical?e.measures.delta:0}${M} , 0)`:`${T}(${e.config.isVertical?0:e.measures.x}${M}, ${e.config.isVertical?e.measures.y:0}${M} , 0)`),n.height=e.config.isVertical?e.config.dynamic?O:`${e.measures.height}${M}`:t?i:C,n.width=e.config.isVertical?t?i:C:e.config.dynamic?O:`${e.measures.width}${M}`}}getSnapshotBeforeUpdate(e,t){return null}componentDidUpdate(e,t,i){}shouldComponentUpdate(e,t){var i;let s=!1;return this._renderer!==e.renderer&&(this.renderer=null!==(i=e.renderer)&&void 0!==i?i:J,s=!0),this._regular!==e.regular&&(s=!0),this.state!==t&&(s=!0),s}getBounds(){var e;const t=this._$elementRef.current,{width:i,height:s}=null!==(e=null==t?void 0:t.getBoundingClientRect())&&void 0!==e?e:{width:0,height:0};return{width:i,height:s}}show(){var e,t,i;const s=this._$elementRef.current;if(!s)return;const n=this._regular,r=s.style;if(n){if(r.display===z)return;r.display=z}else{if(r.visibility===b)return;r.visibility=b}r.zIndex=r.zIndex=null!==(i=null===(t=null===(e=this._data)||void 0===e?void 0:e.config)||void 0===t?void 0:t.zIndex)&&void 0!==i?i:"0"}hide(){const e=this._$elementRef.current;if(!e)return;const t=this._regular,i=e.style;if(t){if(i.display===y)return;i.display=y}else{if(i.visibility===x)return;i.visibility=x}i.position=B,i.transform=k,i.zIndex="-1"}classNames(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];const n=["rcxvl__item-container",...null!=i?i:[]];return e.config.snapped&&n.push("snapped"),e.config.snappedOut&&n.push("snapped-out"),n.join(" ")}render(){const e=this._renderer,t={renderer:e},i=this._data;return(0,a.jsx)("div",Object.assign({ref:this._$elementRef,className:"rcxvl__item"},{children:this._data&&(0,a.jsx)("li",Object.assign({ref:this._$listItemRef,className:this.classNames(this._data)},{children:(void 0!==e||null!==e)&&(0,a.jsx)(t.renderer,{data:null==i?void 0:i.data,config:null==i?void 0:i.config})}))}))}}K.__nextId=0;const Y=navigator.userAgent.toLowerCase().includes("firefox"),ee=[r.ADVANCED,"advanced"];r.NORMAL;class te extends h().Component{get id(){return this._id}set items(e){this._items!==e&&(this._items=this._itemsTransform(e))}get items(){return this._items}set snap(e){this._snap!==e&&(this._snap=e)}get snap(){return this._snap}set enabledBufferOptimization(e){this._enabledBufferOptimization!==e&&(this._enabledBufferOptimization=e)}get enabledBufferOptimization(){return this._enabledBufferOptimization}set itemRenderer(e){this._itemRenderer!==e&&(this._itemRenderer=e,this._initialized&&this.setState(e=>Object.assign(Object.assign({},e),{itemRenderer:{renderer:this._itemRenderer}})))}get itemRenderer(){return this._itemRenderer}set stickyMap(e){this._stickyMap!==e&&(this._stickyMap=e)}get stickyMap(){return this._stickyMap}set itemSize(e){this._itemSize!==e&&(this._itemSize=this._itemSizeTransform(e))}get itemSize(){return this._itemSize}set dynamicSize(e){this._dynamicSize!==e&&(this._dynamicSize=e,this.listenCacheChangesIfNeed(e))}get dynamicSize(){return this._dynamicSize}set direction(e){this._direction!==e&&(this._direction=e,this._isVertical=this.getIsVertical(e),this._initialized&&this.setState(e=>Object.assign(Object.assign({},e),{isVertical:this._isVertical})))}get direction(){return this._direction}set bufferSize(e){this._bufferSize!==e&&(this._bufferSize=e)}get bufferSize(){return this._bufferSize}set maxBufferSize(e){const t=this.bufferSize;void 0===e||e<=t?this._maxBufferSize=t:this._maxBufferSize!==e&&(this._maxBufferSize=e)}get maxBufferSize(){return this._maxBufferSize}set snappingMethod(e){this._snappingMethod!==e&&(this._snappingMethod=e,this._isSnappingMethodAdvanced=this.getIsSnappingMethodAdvanced(e),this._trackBox.isSnappingMethodAdvanced=this._isSnappingMethodAdvanced)}get snappingMethod(){return this._snappingMethod}set trackBy(e){this._trackBy!==e&&(this._trackBy=e,this._trackBox.trackingPropertyName=e)}get trackBy(){return this._trackBy}set displayComponentsList(e){this._displayComponentsList!==e&&(this._displayComponentsList=e,this._initialized&&this.setState(e=>Object.assign(Object.assign({},e),{displayComponentsList:this._displayComponentsList})))}set bounds(e){this._bounds!==e&&(this._bounds=e,this._initialized&&this.setState(e=>Object.assign(Object.assign({},e),{bounds:this._bounds})))}get bounds(){return this._bounds}set scrollSize(e){this._scrollSize!==e&&(this._scrollSize=e,this._initialized&&this.setState(e=>Object.assign(Object.assign({},e),{scrollSize:this._scrollSize})))}get scrollSize(){return this._scrollSize}set cacheVersion(e){this._cacheVersion!==e&&(this._cacheVersion=e,this._initialized&&this.setState(e=>Object.assign(Object.assign({},e),{cacheVersion:this._cacheVersion})))}get cacheVersion(){return this._cacheVersion}constructor(e){super(e),this._id=te.__nextId,this._$elementRef=(0,l.createRef)(),this._$containerRef=(0,l.createRef)(),this._$snappedRef=(0,l.createRef)(),this._$listRef=(0,l.createRef)(),this._itemsTransform=e=>(this._trackBox.resetCollection(e,this.itemSize),e),this._snap=p,this._enabledBufferOptimization=_,this._stickyMap={},this._itemSizeTransform=e=>{if(void 0===e)return c;const t=Number(e);return Number.isNaN(t)||t<=0?c:t},this._itemSize=c,this._dynamicSize=f,this._direction=g,this._bufferSize=d,this._maxBufferSize=u,this._snappingMethod=v,this._trackBy=m,this._trackBox=new G(this.trackBy),this._displayComponents=[],this._snapedDisplayComponent=(0,l.createRef)(),this._displayComponentsList=[],this._bounds=null,this._scrollSize=0,this._cacheVersion=-1,this._resizeObserver=null,this._isSnappingMethodAdvanced=this.getIsSnappingMethodAdvanced(),this._isVertical=this.getIsVertical(),this._initialized=!1,this._onTrackBoxChangeHandler=e=>{this.cacheVersion=e},this._resizeSnappedComponentHandler=()=>{var e,t,i,s,n,r,o,a,l;const h=this._$listRef,c=this._$containerRef,d=null===(e=this._snapedDisplayComponent)||void 0===e?void 0:e.current;if(h&&h.current&&c&&c.current&&d){const e=this._isVertical,u=h.current.getBoundingClientRect(),p=null==h?void 0:h.current,{width:_,height:f}=null!==(t=null==p?void 0:p.getBoundingClientRect())&&void 0!==t?t:{width:0,height:0},{width:m,height:g}=null!==(s=null===(i=c.current)||void 0===i?void 0:i.getBoundingClientRect())&&void 0!==s?s:{width:0,height:0},v=e?c.current.scrollHeight>0:c.current.scrollWidth>0;let S=e?m-_:g-f,z=!0,y=0;0===S&&v&&(z=!0),z&&Y&&(S=y=12);const b=d.element;if(b){b.style.clipPath=`path("M 0 0 L 0 ${b.offsetHeight} L ${b.offsetWidth-y} ${b.offsetHeight} L ${b.offsetWidth-y} 0 Z")`,d.regularLength=`${e?u.width:u.height}${M}`;const{width:t,height:i}=null!==(n=d.getBounds())&&void 0!==n?n:{width:0,height:0},s=c.current;if(s){let n,h,c,u;if(e){const e=null!==(o=null===(r=d.data)||void 0===r?void 0:r.measures.delta)&&void 0!==o?o:0;n=0,h=m-S,c=i,u=g,s.style.clipPath=`path("M 0 ${c+e} L 0 ${g} L ${m} ${g} L ${m} 0 L ${h} 0 L ${h} ${c+e} Z")`}else{const e=null!==(l=null===(a=d.data)||void 0===a?void 0:a.measures.delta)&&void 0!==l?l:0;n=t,h=m,c=0,u=g-S,s.style.clipPath=`path("M ${n+e} 0 L ${n+e} ${u} L 0 ${u} L 0 ${g} L ${m} ${g} L ${m} 0 Z")`}}}}},this._observeComponentRenderersTimeout=void 0,this._scrollToRepeatExecutionTimeout=void 0,this._resizeSnappedObserver=null,this._componentsResizeObserver=new ResizeObserver(()=>{this._trackBox.changes()}),this._onResizeHandler=()=>{var e;const t=null===(e=this._$containerRef.current)||void 0===e?void 0:e.getBoundingClientRect();this.bounds=t?{width:t.width,height:t.height}:{width:400,height:400},this._isSnappingMethodAdvanced&&this._resizeSnappedComponentHandler()},this._onScrollHandler=e=>{var t;this.disposeScrollToRepeatExecutionTimeout();const i=null===(t=this._$containerRef)||void 0===t?void 0:t.current;if(i){const e=this._isVertical?i.scrollTop:i.scrollLeft;this.scrollSize=e}},this._onScrollEndHandler=e=>{var t;this.disposeScrollToRepeatExecutionTimeout();const i=null===(t=this._$containerRef)||void 0===t?void 0:t.current;i&&i.removeEventListener($,this._onScrollEndHandler)},this._onContainerScrollHandler=e=>{var t,i;const s=null===(t=this._$containerRef)||void 0===t?void 0:t.current,n=null===(i=this._$listRef)||void 0===i?void 0:i.current;if(s&&n){const e=this._isVertical?s.scrollTop:s.scrollLeft;this._trackBox.deltaDirection=this._scrollSize>e?-1:this._scrollSize<e?1:0;const t=new Q({direction:this._trackBox.scrollDirection,container:s,list:n,delta:this._trackBox.delta,scrollDelta:this._trackBox.scrollDelta,isVertical:this._isVertical});void 0!==this._onScroll&&this._onScroll(t)}},this._onContainerScrollEndHandler=e=>{var t,i;const s=null===(t=this._$containerRef)||void 0===t?void 0:t.current,n=null===(i=this._$listRef)||void 0===i?void 0:i.current;if(s&&n){const e=this._isVertical?s.scrollTop:s.scrollLeft;this._trackBox.deltaDirection=this._scrollSize>e?-1:0;const t=new Q({direction:this._trackBox.scrollDirection,container:s,list:n,delta:this._trackBox.delta,scrollDelta:this._trackBox.scrollDelta,isVertical:this._isVertical});void 0!==this._onScrollEnd&&this._onScrollEnd(t)}},this._t=Date.now(),this._debouncedInitialize=A(()=>{this._initialized||(this._trackBox.displayComponents=this._displayComponents,this.initializeComponent(),this.initializeSnappedComponent(),this.resetRenderers(),this.observeComponentRenderers()),this._initialized=!0}),this._resizeObserveQueue=[],this.resetBoundsSize=(e,t)=>{const i=this._$listRef;i&&i.current&&(i.current.style[e?R:D]=`${t}${M}`)};const{direction:t=g,dynamicSize:i=f,enabledBufferOptimization:s=_,bufferSize:n=d,maxBufferSize:r=u,itemRenderer:o,items:a,itemSize:h=c,snap:S=p,snappingMethod:z=v,stickyMap:y={},trackBy:b=m,className:x,onScroll:C,onScrollEnd:O}=e;this.direction=t,this.dynamicSize=i,this.enabledBufferOptimization=s,this.bufferSize=n,this.maxBufferSize=r,this.items=a,this.itemRenderer=o,this.itemSize=h,this.snap=S,this.snappingMethod=z,this.stickyMap=y,this.trackBy=b,this._className=x,this._onScroll=C,this._onScrollEnd=O,this.state={cacheVersion:this._cacheVersion,displayComponentsList:this._displayComponentsList,isVertical:this._isVertical,scrollSize:this._scrollSize,bounds:this._bounds}}getSnapshotBeforeUpdate(e,t){return null}componentDidUpdate(e,t,i){}shouldComponentUpdate(e,t,i){var s,n,r,o,a,l,h,S,z,y,b;let x=!1;return e.direction!==this._direction&&(this.direction=null!==(s=e.direction)&&void 0!==s?s:g,x=!0),e.dynamicSize!==this._dynamicSize&&(this.dynamicSize=null!==(n=e.dynamicSize)&&void 0!==n?n:f,x=!0),e.enabledBufferOptimization!==this._enabledBufferOptimization&&(this.enabledBufferOptimization=null!==(r=e.enabledBufferOptimization)&&void 0!==r?r:_,x=!0),e.itemRenderer!==this._itemRenderer&&(this.itemRenderer=e.itemRenderer,x=!0),e.itemSize!==this._itemSize&&(this.itemSize=null!==(o=e.itemSize)&&void 0!==o?o:c,x=!0),e.items!==this._items&&(this.items=null!==(a=e.items)&&void 0!==a?a:[],x=!0),e.bufferSize!==this._bufferSize&&(this.bufferSize=null!==(l=e.bufferSize)&&void 0!==l?l:d,x=!0),e.maxBufferSize!==this._maxBufferSize&&(this.maxBufferSize=null!==(h=e.maxBufferSize)&&void 0!==h?h:u,x=!0),e.snap!==this._snap&&(this.snap=null!==(S=e.snap)&&void 0!==S?S:p,x=!0),e.snappingMethod!==this._snappingMethod&&(this.snappingMethod=null!==(z=e.snappingMethod)&&void 0!==z?z:v,x=!0),e.stickyMap!==this._stickyMap&&(this.stickyMap=null!==(y=e.stickyMap)&&void 0!==y?y:{},x=!0),e.trackBy!==this._trackBy&&(this.trackBy=null!==(b=e.trackBy)&&void 0!==b?b:m,x=!0),e.onScroll!==this._onScroll&&(this._onScroll=e.onScroll),e.onScrollEnd!==this._onScrollEnd&&(this._onScrollEnd=e.onScrollEnd),this.state.displayComponentsList===t.displayComponentsList&&this.state.isVertical===t.isVertical&&this.state.scrollSize===t.scrollSize&&this.state.bounds===t.bounds||(x=!0),this.update(),x}componentDidMount(){this._debouncedInitialize.execute()}observeComponentRenderers(){this.disposeObserveComponentRenderers(),this._observeComponentRenderersTimeout=setTimeout(()=>{this.executeResizeObserverQueue(),this.observeComponentRenderers()})}initializeComponent(){const e=this._$containerRef.current;e&&(e.addEventListener(L,this._onContainerScrollHandler),e.addEventListener($,this._onContainerScrollEndHandler),e.addEventListener(L,this._onScrollHandler),this._resizeObserver=new ResizeObserver(this._onResizeHandler),this._resizeObserver.observe(e),this._onResizeHandler())}update(){var e,t,i,s,n,r,o;const a=this._items,l=this._bounds;if(this._initialized&&l&&a){const{width:h,height:c}=l,d=this._isVertical,u=this._stickyMap,p=this._itemSize,_=this._dynamicSize,f=this._snap,m=this._bufferSize,g=this._maxBufferSize,v=this._enabledBufferOptimization,z=null!==(r=this._isVertical?null!==(i=null===(t=null===(e=this._$containerRef)||void 0===e?void 0:e.current)||void 0===t?void 0:t.scrollTop)&&void 0!==i?i:0:null===(n=null===(s=this._$containerRef)||void 0===s?void 0:s.current)||void 0===n?void 0:n.scrollLeft)&&void 0!==r?r:0;let y=z;const b={bounds:{width:h,height:c},dynamicSize:_,isVertical:d,itemSize:p,bufferSize:m,maxBufferSize:g,scrollSize:y,snap:f,enabledBufferOptimization:v},{displayItems:x,totalSize:C}=this._trackBox.updateCollection(a,u,b);this.resetBoundsSize(d,C),this.createDisplayComponentsIfNeed(x),this.tracking(),this._isSnappingMethodAdvanced&&this._resizeSnappedComponentHandler();const O=this._$containerRef;if(O&&(y=z+this._trackBox.delta,this._trackBox.clearDelta(),this._scrollSize!==y)){const e={[this._isVertical?E:I]:y,behavior:S};null===(o=O.current)||void 0===o||o.scrollTo(e),this.scrollSize=y}}}initializeSnappedComponent(){this._trackBox.snapedDisplayComponent=this._snapedDisplayComponent}listenCacheChangesIfNeed(e){e?this._trackBox.hasEventListener(F,this._onTrackBoxChangeHandler)||this._trackBox.addEventListener(F,this._onTrackBoxChangeHandler):this._trackBox.hasEventListener(F,this._onTrackBoxChangeHandler)&&this._trackBox.removeEventListener(F,this._onTrackBoxChangeHandler)}getIsSnappingMethodAdvanced(e){return t=e||this._snappingMethod,ee.includes(t);var t}getIsVertical(e){return((e,t)=>Z.includes(t)?Z.includes(e):X.includes(e))(e||this._direction,o.VERTICAL)}getItemBounds(e){return this._trackBox.getItemBounds(e)}scrollToExecutor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];var n,r,o,a,l,h,c,d,u,p,_,f,m,g,v,z;const y=this._items,b=this._bounds,x=this._dynamicSize,C=this._isVertical,O=this._itemSize,B=this._bufferSize,T=this._maxBufferSize,k=this._snap,D=this._trackBox,R=this._enabledBufferOptimization,M=this._stickyMap;if(!b||!y||!y.length)return;const A=this._$containerRef;if(A)if(this.disposeScrollToRepeatExecutionTimeout(),x){null===(n=A.current)||void 0===n||n.removeEventListener($,this._onScrollEndHandler),A&&A.current&&A.current.removeEventListener(L,this._onScrollHandler);const{width:f,height:m}=b,g=D.delta,v={bounds:{width:f,height:m},collection:y,dynamicSize:x,isVertical:C,itemSize:O,bufferSize:B,maxBufferSize:T,scrollSize:(C?null!==(o=null===(r=A.current)||void 0===r?void 0:r.scrollTop)&&void 0!==o?o:0:null!==(l=null===(a=A.current)||void 0===a?void 0:a.scrollLeft)&&void 0!==l?l:0)+g,snap:k,fromItemId:e,enabledBufferOptimization:R},z=D.getItemPosition(e,M,v),w={[C?E:I]:z,behavior:t};if(-1===z)return null===(h=A.current)||void 0===h||h.addEventListener($,this._onScrollEndHandler),void(null===(c=A.current)||void 0===c||c.addEventListener(L,this._onScrollHandler));if(D.clearDelta(),A){const{displayItems:t,totalSize:n}=D.updateCollection(y,M,Object.assign(Object.assign({},v),{scrollSize:z,fromItemId:s?void 0:e})),r=D.delta;D.clearDelta();let o=z+r;this.resetBoundsSize(C,n),this.createDisplayComponentsIfNeed(t),this.tracking();const a=D.getItemPosition(e,M,Object.assign(Object.assign({},v),{scrollSize:o,fromItemId:e})),l=o===a;if(-1===a)return null===(d=A.current)||void 0===d||d.addEventListener($,this._onScrollEndHandler),void(null===(u=A.current)||void 0===u||u.addEventListener(L,this._onScrollHandler));!l||i<5?(this.disposeScrollToRepeatExecutionTimeout(),this._scrollToRepeatExecutionTimeout=setTimeout(()=>{this.scrollToExecutor(e,S,i+1,l)})):(this.scrollSize=o,null===(p=A.current)||void 0===p||p.addEventListener(L,this._onScrollHandler))}null===(_=A.current)||void 0===_||_.scrollTo(w),this.scrollSize=z}else{const i=C?null!==(m=null===(f=A.current)||void 0===f?void 0:f.scrollTop)&&void 0!==m?m:0:null!==(v=null===(g=A.current)||void 0===g?void 0:g.scrollLeft)&&void 0!==v?v:0,s=y.findIndex(t=>t.id===e);if(s>-1){const e=s*O;if(i!==e){const i={[C?E:I]:e,behavior:t};null===(z=A.current)||void 0===z||z.scrollTo(i)}}}}resetRenderers(){const e={},t=this._displayComponents;for(let i=0,s=t.length;i<s;i++){const s=t[i].current;s&&(e[s.id]=i)}this._trackBox.setDisplayObjectIndexMapById(e)}executeResizeObserverQueue(){var e,t;let i=!1;const s=this._resizeObserveQueue,n=[];for(let r=s.length-1;r>=0;r--){const o=s[r],a=null===(e=o.current)||void 0===e?void 0:e.element;a?(i=!0,null===(t=this._componentsResizeObserver)||void 0===t||t.observe(a),this._resizeObserveQueue.slice(r,1)):n.push(o)}i&&(this.displayComponentsList=[...this._displayComponentsList]);const r=this._snapedDisplayComponent.current;if(this._trackBox.snapedDisplayComponent=this._snapedDisplayComponent,r&&!this._resizeSnappedObserver){const e=null==r?void 0:r.element;e&&(this._resizeSnappedObserver=new ResizeObserver(this._resizeSnappedComponentHandler),this._resizeSnappedObserver.observe(e))}this._resizeObserveQueue=n}waitToResizeObserve(e){this._resizeObserveQueue.push(e)}createDisplayComponentsIfNeed(e){if(!e||!this._$listRef)return void this._trackBox.setDisplayObjectIndexMapById({});this._trackBox.items=e;let t=!1;const i=this._$listRef,s=this._displayComponents;for(;s.length<e.length;)if(i){t=!0;const e=(0,l.createRef)();s.push(e),this.waitToResizeObserve(e)}t&&(this.displayComponentsList=[...s]),this.resetRenderers()}tracking(){this._trackBox.track()}scrollTo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"auto";this.scrollToExecutor(e,t)}scrollToEnd(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:S;const t=this._items,i=null==t?void 0:t[t.length>0?t.length-1:0];i&&this.scrollTo(i.id,e)}render(){const{displayComponentsList:e}=this.state,t=this._isVertical;return(0,a.jsxs)("div",Object.assign({ref:this._$elementRef,className:`rcxvl ${this._className} ${t?"vertical":"horizontal"}`},{children:[this._snap&&this._isSnappingMethodAdvanced&&(0,a.jsx)("div",Object.assign({ref:this._$snappedRef,className:"rcxvl__list-snapper snapped-item"},{children:(0,a.jsx)(K,{ref:this._snapedDisplayComponent,regular:!0,renderer:this._itemRenderer})})),(0,a.jsx)("div",Object.assign({ref:this._$containerRef,className:"rcxvl__scroller"},{children:(0,a.jsx)("ul",Object.assign({ref:this._$listRef,className:"rcxvl__list"},{children:e.map((e,t)=>(0,a.jsx)(K,{ref:e,renderer:this._itemRenderer},String(t)))}))}))]}))}disposeScrollToRepeatExecutionTimeout(){clearTimeout(this._scrollToRepeatExecutionTimeout)}disposeObserveComponentRenderers(){clearTimeout(this._observeComponentRenderersTimeout)}componentWillUnmount(){this.disposeScrollToRepeatExecutionTimeout(),this.disposeObserveComponentRenderers(),this._debouncedInitialize&&this._debouncedInitialize.dispose(),this._trackBox&&this._trackBox.dispose(),this._componentsResizeObserver&&this._componentsResizeObserver.disconnect(),this._resizeSnappedObserver&&this._resizeSnappedObserver.disconnect(),this._resizeObserver&&this._resizeObserver.disconnect();const e=this._$containerRef.current;e&&(e.removeEventListener(L,this._onScrollHandler),e.removeEventListener(L,this._onContainerScrollHandler),e.removeEventListener($,this._onContainerScrollEndHandler))}}te.__nextId=0;const ie=te;return n})()); //# sourceMappingURL=index.js.map