import{r as registerInstance,h,g as getElement}from"./index-ecdfb761.js";var dvnListViewTableCss=":host{-ms-flex:1 1 1px;flex:1 1 1px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:hidden}.table-progress-container{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;min-height:calc(14 * var(--spacing-unit))}.error-container{padding:calc(4 * var(--spacing-unit))}";function findStartNode(e,t,r){var n=0;var o=r-1;while(o!==n){var i=Math.floor((o-n)/2+n);if(t[i]<=e&&t[i+1]>e){return i}if(i===n){return o}else{if(t[i]<=e){n=i}else{o=i}}}return r}function findEndNode(e,t,r,n){var o;for(o=t;o<r;o++){if(e[o]>e[t]+n){return o}}return o}var VirtualScroll=function(){function e(e){registerInstance(this,e);this.itemCount=500;this.rowHeight=50;this.renderAhead=0;this.scrollTop=0}e.prototype.componentDidRender=function(){var e=this;setTimeout((function(){e.height=e.el?e.el.offsetHeight:0}),100)};e.prototype.render=function(){var e=this;var t=this,r=t.height,n=t.itemCount,o=t.renderAhead,i=t.rowHeight,l=t.scrollTop;var a=function(e){return i};var s=function(){var e=[0];for(var t=1;t<n;t++){e.push(e[t-1]+a())}return e};var c=s()[n-1]+a();console.log("scrollTop",l);var f=function(){return findStartNode(l,s(),n)};console.log("firstVisibleNode()",f());var u=Math.max(0,f()-o);console.log("startNode",u);var d=function(){return findEndNode(s(),f(),n,r)};var v=Math.min(n-1,d()+o);var p=v-u+1;var g=s()[u];console.log("visibleNodeCount",p);var m=function(){return new Array(p).fill(null).map((function(t,r){return e.renderRow(r+u)}))};console.log("viewportHeight",r);console.log("totalHeight",c);return h("div",{style:{height:"".concat(800,"px"),overflow:"auto",flex:"1",display:"block"},onScroll:function(t){console.log(t.target.scrollTop);e.scrollTop=t.target.scrollTop}},h("div",{style:{height:"".concat(c,"px"),overflow:"hidden",willChange:"transform",position:"relative"}},h("div",{style:{transform:"translateY(".concat(g,"px)")}},m())))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();VirtualScroll.style=dvnListViewTableCss;export{VirtualScroll as dvn_virtual_scroll};