/*!
 * Built by Revolist OU ❤️
 */
import{a as t}from"./toNumber.js";import{k as n}from"./data.store.js";var e=Math.floor,r=Math.min;function o(o,i){return function(o,i){var s=0,u=null==o?s:o.length;if("number"==typeof i&&i==i&&u<=2147483647){for(;s<u;){var a=s+u>>>1,f=o[a];null!==f&&!t(f)&&f<i?s=a+1:u=a}return u}return function(n,o,i){var s=0,u=null==n?0:n.length;if(0===u)return 0;for(var a=(o=i(o))!=o,f=null===o,c=t(o),d=void 0===o;s<u;){var l=e((s+u)/2),m=i(n[l]),x=void 0!==m,I=null===m,v=m==m,p=t(m);if(a)var b=v;else b=d?v&&x:f?v&&x&&!I:c?v&&x&&!I&&!p:!I&&!p&&m<o;b?s=l+1:u=l}return r(u,4294967294)}(o,i,n)}(o,i)}function i(t,n={}){const e=[],r={},o={},i=Object.keys(n).map(Number).sort(((t,n)=>t-n));let s;for(let u=0;u<i.length;u++){const a=i[u],f={itemIndex:a,start:0,end:0};f.start=s?(a-s.itemIndex-1)*t+s.end:a*t,f.end=f.start+n[a],e.push(f.start),o[a]=r[u]=f,s=f}return{indexes:i,positionIndexes:[...e],positionIndexToItem:Object.assign({},r),indexToItem:o}}const s=({indexes:t,positionIndexes:n,originItemSize:e,positionIndexToItem:r},i)=>{const s={itemIndex:0,start:0,end:0},u=t.length?o(n,i):0;if(!u)return s.itemIndex=Math.floor(i/e),s.start=s.itemIndex*e,s.end=s.start+e,s;const a=r[u-1];if(a.end>i)return a;const f=Math.floor((i-a.end)/e);return s.itemIndex=a.itemIndex+1+f,s.start=a.end+f*e,s.end=s.start+e,s};function u(t,n){let e={itemIndex:n,start:0,end:0};if(t.indexToItem[n])return t.indexToItem[n];const r=t.indexes.length?o(t.indexes,n):0;if(!r)return e.start=e.itemIndex*t.originItemSize,e.end=e.start+t.originItemSize,e;const i=t.indexToItem[t.indexes[r-1]];return e.start=i.end+(n-i.itemIndex-1)*t.originItemSize,e.end=e.start+t.originItemSize,e}export{u as a,i as c,s as g}