@aiquants/virtualscroll 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1010 -544
- package/dist/index.js.map +1 -1
- package/dist/src/ScrollBar.d.ts +30 -1
- package/dist/src/ScrollBar.d.ts.map +1 -1
- package/dist/src/ScrollPane.d.ts +19 -0
- package/dist/src/ScrollPane.d.ts.map +1 -1
- package/dist/src/TapScrollCircle.d.ts +45 -0
- package/dist/src/TapScrollCircle.d.ts.map +1 -0
- package/dist/src/VirtualScroll.d.ts +3 -1
- package/dist/src/VirtualScroll.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/virtualscroll.css +1 -0
- package/dist/vite.config.d.ts.map +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -11,7 +11,8 @@ High-performance virtual scrolling component for React with variable item height
|
|
|
11
11
|
<!-- - 🔄 **LRU Caching**: Built-in cache for optimal memory usage -->
|
|
12
12
|
- 📱 **Touch Support**: Full support for touch devices
|
|
13
13
|
- 🎨 **Customizable**: Flexible styling and theming options
|
|
14
|
-
-
|
|
14
|
+
- � **Ultrafast Tap Scroll**: Adaptive tap scroll circle that scales speed up to 120× for massive datasets
|
|
15
|
+
- �🔧 **TypeScript**: Full TypeScript support with comprehensive type definitions
|
|
15
16
|
|
|
16
17
|
## Installation
|
|
17
18
|
|
|
@@ -93,6 +94,8 @@ function App() {
|
|
|
93
94
|
| `background` | `ReactNode` | ❌ | Background element |
|
|
94
95
|
| `initialScrollIndex` | `number` | ❌ | Initial scroll index |
|
|
95
96
|
| `initialScrollOffset` | `number` | ❌ | Initial scroll offset |
|
|
97
|
+
| `tapScrollCircleOptions` | `ScrollBarTapCircleOptions` | ❌ | Customization for the auxiliary tap scroll circle |
|
|
98
|
+
| `inertiaOptions` | `ScrollPaneInertiaOptions` | ❌ | Physics tuning for drag inertia |
|
|
96
99
|
|
|
97
100
|
### VirtualScrollHandle Methods
|
|
98
101
|
|
|
@@ -173,6 +176,43 @@ function AdvancedExample() {
|
|
|
173
176
|
</style>
|
|
174
177
|
```
|
|
175
178
|
|
|
179
|
+
### Tap Scroll Circle Configuration
|
|
180
|
+
|
|
181
|
+
The auxiliary tap scroll circle can replace the native scrollbar for large datasets while remaining easy to control:
|
|
182
|
+
|
|
183
|
+
- **Adaptive speed scaling** automatically ramps up to a `120×` multiplier as `itemCount` grows (trillions supported).
|
|
184
|
+
- **Manual overrides** let you clamp or extend speed via `maxSpeedMultiplier` when you need deterministic behavior.
|
|
185
|
+
- **Full layout control** (`size`, `offsetX`, `offsetY`) keeps the circle accessible on both desktop and touch devices.
|
|
186
|
+
- **Visibility tuning** exposes an `opacity` knob so you can match subdued or high-contrast UI themes.
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
import { VirtualScroll } from "@aiquants/virtualscroll"
|
|
190
|
+
|
|
191
|
+
const items = Array.from({ length: 1_000_000_000_000 }, (_, index) => ({
|
|
192
|
+
id: index,
|
|
193
|
+
text: `Record ${index}`,
|
|
194
|
+
height: 42,
|
|
195
|
+
}))
|
|
196
|
+
|
|
197
|
+
export function UltraFastExample() {
|
|
198
|
+
return (
|
|
199
|
+
<VirtualScroll
|
|
200
|
+
itemCount={items.length}
|
|
201
|
+
getItem={(index) => items[index]}
|
|
202
|
+
getItemHeight={() => 42}
|
|
203
|
+
viewportSize={480}
|
|
204
|
+
tapScrollCircleOptions={{
|
|
205
|
+
maxSpeedMultiplier: 80, // Optional: override adaptive speed when needed
|
|
206
|
+
offsetX: -96,
|
|
207
|
+
opacity: 0.85,
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
210
|
+
{(item) => <div style={{ height: item.height }}>{item.text}</div>}
|
|
211
|
+
</VirtualScroll>
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
176
216
|
## Performance Tips
|
|
177
217
|
|
|
178
218
|
1. **Memoize callback functions**: Use `useCallback` for `getItem` and `getItemHeight`
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),fe=require("tailwind-merge");var pe={exports:{}},le={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var ye;function Ye(){if(ye)return le;ye=1;var u=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,o,i){var l=null;if(i!==void 0&&(l=""+i),o.key!==void 0&&(l=""+o.key),"key"in o){i={};for(var m in o)m!=="key"&&(i[m]=o[m])}else i=o;return o=i.ref,{$$typeof:u,type:r,key:l,ref:o!==void 0?o:null,props:i}}return le.Fragment=e,le.jsx=n,le.jsxs=n,le}var ce={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var Re;function ze(){return Re||(Re=1,process.env.NODE_ENV!=="production"&&(function(){function u(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===c?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case N:return"Fragment";case F:return"Profiler";case G:return"StrictMode";case C:return"Suspense";case j:return"SuspenseList";case re:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case se:return"Portal";case J:return(t.displayName||"Context")+".Provider";case h:return(t._context.displayName||"Context")+".Consumer";case k:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case B:return a=t.displayName||null,a!==null?a:u(t.type)||"Memo";case U:a=t._payload,t=t._init;try{return u(t(a))}catch{}}return null}function e(t){return""+t}function n(t){try{e(t);var a=!1}catch{a=!0}if(a){a=console;var T=a.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return T.call(a,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),e(t)}}function r(t){if(t===N)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===U)return"<...>";try{var a=u(t);return a?"<"+a+">":"<...>"}catch{return"<...>"}}function o(){var t=z.A;return t===null?null:t.getOwner()}function i(){return Error("react-stack-top-frame")}function l(t){if(Y.call(t,"key")){var a=Object.getOwnPropertyDescriptor(t,"key").get;if(a&&a.isReactWarning)return!1}return t.key!==void 0}function m(t,a){function T(){w||(w=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",a))}T.isReactWarning=!0,Object.defineProperty(t,"key",{get:T,configurable:!0})}function g(){var t=u(this.type);return A[t]||(A[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function b(t,a,T,R,S,V,D,M){return T=V.ref,t={$$typeof:te,type:t,key:a,props:V,_owner:S},(T!==void 0?T:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:g}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:D}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function x(t,a,T,R,S,V,D,M){var P=a.children;if(P!==void 0)if(R)if(L(P)){for(R=0;R<P.length;R++)_(P[R]);Object.freeze&&Object.freeze(P)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else _(P);if(Y.call(a,"key")){P=u(t);var X=Object.keys(a).filter(function(f){return f!=="key"});R=0<X.length?"{key: someKey, "+X.join(": ..., ")+": ...}":"{key: someKey}",I[P+R]||(X=0<X.length?"{"+X.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,p,F,N,F),V[F+p]=!0)}if(F=null,m!==void 0&&(s(m),F=""+m),a(i)&&(s(i.key),F=""+i.key),"key"in i){m={};for(var G in i)G!=="key"&&(m[G]=i[G])}else m=i;return F&&h(m,typeof r=="function"?r.displayName||r.name||"Unknown":r),c(r,F,E,R,n(),m,k,Y)}function x(r){typeof r=="object"&&r!==null&&r.$$typeof===T&&r._store&&(r._store.validated=1)}var _=f,T=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),d=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),q=Symbol.for("react.activity"),H=Symbol.for("react.client.reference"),U=_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=Object.prototype.hasOwnProperty,L=Array.isArray,D=console.createTask?console.createTask:function(){return null};_={react_stack_bottom_frame:function(r){return r()}};var W,X={},Q=_.react_stack_bottom_frame.bind(_,o)(),b=D(t(o)),V={};Z.Fragment=A,Z.jsx=function(r,i,m,p,R){var E=1e4>U.recentlyCreatedOwnerStacks++;return g(r,i,m,!1,p,R,E?Error("react-stack-top-frame"):Q,E?D(t(r)):b)},Z.jsxs=function(r,i,m,p,R){var E=1e4>U.recentlyCreatedOwnerStacks++;return g(r,i,m,!0,p,R,E?Error("react-stack-top-frame"):Q,E?D(t(r)):b)}})()),Z}var ne;function be(){return ne||(ne=1,process.env.NODE_ENV==="production"?K.exports=me():K.exports=ge()),K.exports}var z=be();const j={debug(u,...e){typeof window<"u"&&window.localStorage?.getItem("debug")==="true"&&console.debug(`[VirtualScroll] ${u}`,...e)},warn(u,...e){console.warn(`[VirtualScroll] ${u}`,...e)},error(u,...e){console.error(`[VirtualScroll] ${u}`,...e)}},M=(u,e,s)=>Math.min(s,Math.max(e,u)),ae=(u,e,s)=>{const t="touches"in u.nativeEvent,n=t?u.nativeEvent.touches[0]:u.nativeEvent,o=h=>{t&&h.cancelable&&h.preventDefault();const l="touches"in h?h.touches[0]:h;e({deltaX:l.clientX-n.clientX,deltaY:l.clientY-n.clientY})},a=()=>{t?(document.removeEventListener("touchmove",o),document.removeEventListener("touchend",a)):(document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a)),s?.()};t?(document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("touchend",a)):(document.addEventListener("mousemove",o),document.addEventListener("mouseup",a))},ve=20,ie=({contentSize:u,viewportSize:e,scrollPosition:s,onScroll:t,horizontal:n=!1,scrollBarWidth:o=12,className:a,ariaControls:h})=>{const[l,c]=f.useState(!1),g=f.useRef(null),x=e/u,_=Math.max(ve,x*e),T=u-e,w=s/T*(e-_),A=u>e;f.useEffect(()=>{g.current&&(l?g.current.style.backgroundColor="#4F4F4F":g.current.style.backgroundColor="#7F7F7F")},[l]);const v=d=>M(d/(e-_)*T,0,T),S=d=>{if(!A||"button"in d&&d.button!==0||d.ctrlKey)return;d.stopPropagation();const P=w;c(!0),ae(d,({deltaX:O,deltaY:C})=>{t?.(v(P+(n?O:C)),w)},()=>{c(!1)})},I=d=>{if(!A||"button"in d&&d.button!==0||d.ctrlKey)return;const O="touches"in d.nativeEvent?d.nativeEvent.touches[0]:d.nativeEvent,C=n?O.clientX:O.clientY,$=d.currentTarget.getBoundingClientRect(),q=(n?C-$.left:C-$.top)-_/2;t?.(v(q),w),ae(d,({deltaX:H,deltaY:U})=>{t?.(v(q+(n?H:U)),w)})};return z.jsx("div",{className:te.twMerge("group relative cursor-default select-none",a),style:{[n?"width":"height"]:e,[n?"height":"width"]:o,backgroundColor:"white",userSelect:"none"},onMouseDown:I,onTouchStart:I,role:"scrollbar",tabIndex:-1,"aria-controls":h,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":T,"aria-orientation":n?"horizontal":"vertical",children:u>e&&z.jsx("div",{className:"group absolute",style:{[n?"width":"height"]:_,[n?"left":"top"]:w,...n?{top:0,bottom:0}:{left:0,right:0}},onMouseDown:S,onTouchStart:S,role:"slider","aria-orientation":n?"horizontal":"vertical","aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":T,tabIndex:0,children:z.jsx("div",{ref:g,className:te.twMerge("absolute",n?`inset-x-0 inset-y-[1.5px] group-hover:inset-y-[-0.5px] ${l?"inset-y-[-2px]":"group-active:inset-y-[-2px]"}`:`inset-x-[1.5px] inset-y-0 group-hover:inset-x-[-0.5px] ${l?"inset-x-[-2px]":"group-active:inset-x-[-2px]"}`),style:{backgroundColor:"#7F7F7F",borderRadius:o-1,...n?{left:0,right:0,top:l?-2:1.5,bottom:l?-2:1.5}:{top:0,bottom:0,left:l?-2:1.5,right:l?-2:1.5}},onMouseEnter:d=>{n?(d.currentTarget.style.top="-0.5px",d.currentTarget.style.bottom="-0.5px"):(d.currentTarget.style.left="-0.5px",d.currentTarget.style.right="-0.5px"),l||(d.currentTarget.style.backgroundColor="#5F5F5F")},onMouseLeave:d=>{n?(d.currentTarget.style.top=l?"-2px":"1.5px",d.currentTarget.style.bottom=l?"-2px":"1.5px"):(d.currentTarget.style.left=l?"-2px":"1.5px",d.currentTarget.style.right=l?"-2px":"1.5px"),l||(d.currentTarget.style.backgroundColor="#7F7F7F")}})})})},le=f.forwardRef(({children:u,contentSize:e,viewportSize:s,scrollBarWidth:t=12,onScroll:n,className:o,style:a,background:h},l)=>{const c=f.useRef(0),[g,x]=f.useReducer(S=>S+1,0),_=f.useRef(null);j.debug("[ScrollPane] ScrollPane rendered",{contentSize:e,viewportSize:s,scrollBarWidth:t,className:o,style:a});const T=f.useMemo(()=>e>s,[e,s]),w=f.useCallback(S=>{const I=e>s,d=c.current;if(j.debug("[ScrollPane] scrollTo called",{newPosition:S,contentSize:e,viewportSize:s,currentIsScrollable:I,prevPosition:d}),!I){c.current!==0&&(c.current=0,n?.(0,d));return}const P=typeof S=="function"?S(c.current):S,O=M(P,0,e-s);c.current!==O&&(c.current=O,n?.(O,d))},[n,e,s]);f.useLayoutEffect(()=>{if(T){j.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change",{contentSize:e,viewportSize:s,scrollPosition:c.current});const S=M(e-s,0,e);c.current>S&&w(S)}else w(0)},[T,w,e,s]),f.useEffect(()=>{const S=d=>{if(!T)return;d.preventDefault();let P=d.deltaY;d.deltaMode===1?P*=16:d.deltaMode===2&&(P*=s),j.debug("[ScrollPane] wheel event",{deltaY:P,scrollPosition:c.current}),w(O=>O+P)},I=_.current;return I&&I.addEventListener("wheel",S,{passive:!1}),()=>{I&&I.removeEventListener("wheel",S)}},[T,w,s]),f.useImperativeHandle(l,()=>({scrollTo:w,getScrollPosition:()=>c.current,getContentSize:()=>e,getViewportSize:()=>s}),[w,e,s]);const A=f.useId();return f.useMemo(()=>z.jsxs("div",{ref:_,className:te.twMerge("flex",o),style:a,children:[z.jsxs("div",{className:"relative h-full flex-1 overflow-hidden",style:{height:s},id:A,children:[h,u(c.current)]}),T&&z.jsx(ie,{contentSize:e,viewportSize:s,scrollPosition:c.current,onScroll:w,scrollBarWidth:t,ariaControls:A})]}),[u,e,s,t,o,a,T,w,A,h])});class ue{tree;deltas;size;baseValue;valueFn;total;constructor(e,s,t){this.reset(e,s,t)}reset(e,s,t){if(this.size=e,this.tree=new Map,this.deltas=new Map,this.total=void 0,typeof s=="function"){if(this.valueFn=s,this.size>0){const o=t?.sampleRange??{from:0,to:Math.min(99,this.size-1)},{mode:a,materializedValues:h}=this._calculateMode(o.from,o.to);if(this.baseValue=a,t?.materialize)for(let l=0;l<h.length;l++){const c=h[l],g=o.from+l;if(g>=this.size)break;const x=c-this.baseValue;this.deltas.set(g,x),this._updateTree(g,x)}}else this.baseValue=0;this.total=this.getTotal()}else this.valueFn=void 0,this.baseValue=s,this.total=this.baseValue*this.size}setValueFn(e){typeof e=="function"?this.valueFn=e:(this.valueFn=void 0,this.baseValue=e)}_calculateMode(e,s){if(!this.valueFn)return{mode:0,materializedValues:[]};const t=[];for(let c=e;c<=s&&!(c>=this.size);c++)t.push(this.valueFn(c));const n=[...t];if(t.length===0)return{mode:0,materializedValues:[]};t.sort((c,g)=>c-g);const o=Math.floor(t.length/2);let a;t.length%2===0?a=Math.floor((t[o-1]+t[o])/2):a=t[o];const h=new Map;let l=0;for(const c of t){const g=(h.get(c)??0)+1;h.set(c,g),g>l&&(l=g)}if(l>1){const c=[];for(const[x,_]of h.entries())_===l&&c.push(x);const g=c.reduce((x,_)=>x+_,0);a=Math.floor(g/c.length)}return{mode:a,materializedValues:n}}update(e,s){return this.updates([{index:e,value:s}])}updates(e){const s=e.map(({index:t,value:n})=>{if(t<0||t>=this.size)throw new Error(`Index ${t} out of bounds`);if(n<0)throw new Error("Value cannot be negative.");const o=this.deltas.has(t)?(this.deltas.get(t)??0)+this.baseValue:this.baseValue,a=n-o;return{index:t,change:a}}).filter(t=>t.change!==0);return s.length>0?this.updateDeltas(s):this.total}updateDelta(e,s){return this.updateDeltas([{index:e,change:s}])}updateDeltas(e){for(const{index:s,change:t}of e){if(s<0||s>=this.size)throw new Error(`Index ${s} out of bounds`);const n=this.deltas.get(s)??0;this.deltas.set(s,n+t),this._updateTree(s,t)}return this.total}_updateTree(e,s){if(s===0)return;let t=e+1;for(;t<=this.size;)this.tree.set(t,(this.tree.get(t)??0)+s),t+=t&-t;this.total!==void 0&&(this.total+=s)}_materialize(e,s=!0){if(this.valueFn){const t=this.deltas.get(e)??0,o=this.valueFn(e)-this.baseValue;if(o!==t&&(this.deltas.set(e,o),s)){const a=o-t;this._updateTree(e,a)}}}prefixSum(e,s){if(e<0)return{cumulative:0,total:this.total,currentValue:0,safeIndex:0};const t=M(e,0,this.size-1),n=s?.materializeOption;if(n?.materialize&&this.valueFn){if(n.ranges)for(const l of n.ranges){const c=l.from,g=Math.min(l.to,this.size-1);for(let x=c;x<=g;x++)this._materialize(x)}this._materialize(t)}let o=0,a=t+1;for(;a>0;){const l=this.tree.get(a)??0;o+=l,a-=a&-a}const h=n?.materialize?this.get(t):(this.deltas.get(t)||0)+this.baseValue;return{cumulative:o+this.baseValue*(t+1),total:this.total,currentValue:h,safeIndex:t}}get(e,s){if(e<0||e>=this.size)throw new Error("Index out of bounds");const t=s?.materializeOption;if(t?.materialize&&this.valueFn)if(t.ranges){for(const n of t.ranges){const o=n.from,a=Math.min(n.to,this.size-1);for(let h=o;h<=a;h++)this._materialize(h)}e>=t.ranges[0].from&&e<=t.ranges[t.ranges.length-1].to&&this._materialize(e)}else this._materialize(e);return(this.deltas.get(e)??0)+this.baseValue}getTotal(e){const s=e?.materializeOption;if(s?.materialize&&this.valueFn&&s.ranges)for(const t of s.ranges){const n=t.from,o=Math.min(t.to,this.size-1);for(let a=n;a<=o;a++)this._materialize(a)}if(this.total===void 0)if(this.size===0)this.total=0;else{let t=this.baseValue*this.size;for(const n of this.deltas.values())t+=n;this.total=t,console.assert(this.prefixSum(this.getSize()-1).cumulative===this.prefixSum(this.getSize()-1).total,"Inconsistent Fenwick Tree state")}return this.total}rebuildTree(e){if(e?.materialize&&this.valueFn){const n=this.valueFn;this.reset(this.size,o=>n(o),{materialize:!0});return}const s=new Map;let t=this.baseValue*this.size;for(const[n,o]of this.deltas.entries()){if(t+=o,o===0)continue;let a=n+1;for(;a<=this.size;)s.set(a,(s.get(a)??0)+o),a+=a&-a}this.tree=s,this.total=t}calculateAccumulatedError(){if(this.total===void 0)return 0;let e=this.baseValue*this.size;for(const s of this.deltas.values())e+=s;return this.total-e}changeSize(e){const s=this.size;if(e!==s){if(e<s)for(const t of this.deltas.keys())t>=e&&this.deltas.delete(t);this.size=e,this.rebuildTree(),console.assert(this.prefixSum(this.getSize()-1).cumulative===this.prefixSum(this.getSize()-1).total,"Inconsistent Fenwick Tree state")}}getSize(){return this.size}findIndexAtOrAfter(e,s){if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};let t=0,n=this.size-1,o=-1,a,h=this.total;for(;t<=n;){const l=Math.floor((t+n)/2);a=this.prefixSum(l,s),h=a.total,a.cumulative>=e?(o=l,n=l-1):t=l+1}return{index:o,total:h,cumulative:a?.cumulative,currentValue:a?.currentValue,safeIndex:a?.safeIndex}}findIndexAtOrBefore(e,s){if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};let t=0,n=this.size-1,o=-1,a,h=this.total;for(;t<=n;){const l=Math.floor((t+n)/2);a=this.prefixSum(l,s),h=a.total,a.cumulative<=e?(o=l,t=l+1):n=l-1}return{index:o,total:h,cumulative:a?.cumulative,currentValue:a?.currentValue,safeIndex:a?.safeIndex}}}const ce=(u,e,s)=>{const t=Math.max(0,u),n=f.useRef(null),o=f.useMemo(()=>new ue(t,e,s),[t,e,s]);return Object.is(n.current,o)||console.warn("[useFenwickMapTree] instance changed"),n.current=o,o};function pe({itemCount:u,getItem:e,getItemHeight:s,viewportSize:t,overscanCount:n=5,className:o,onScroll:a,onRangeChange:h,children:l,background:c,initialScrollIndex:g,initialScrollOffset:x},_){const T=f.useRef(null),w=f.useRef(!1);f.useEffect(()=>(w.current=!0,()=>{w.current=!1}),[]);const A=f.useRef({size:u,valueOrFn:s,options:{sampleRange:{from:0,to:100}}}),v=ce(A.current.size,A.current.valueOrFn,A.current.options),[S]=f.useState(()=>{let b=0,V=0;if(typeof g=="number"){const r=M(g,0,u-1),i=M(r-n*2,0,u-1),m=M(r+n*2,0,u-1),p=g>0?{materializeOption:{materialize:!0,ranges:[{from:i,to:m}]}}:void 0,{cumulative:R,total:E,currentValue:k}=v.prefixSum(g,p);b=R-k,V=E??v.getTotal()}else typeof x=="number"&&(b=x),V=v.getTotal();return{position:b,total:V}}),[I,d]=f.useState(S.position),[P,O]=f.useState(S.total),[C,$]=f.useState(S.position),[y,q]=f.useState(u);f.useLayoutEffect(()=>{v.setValueFn(s),y!==u&&(v.changeSize(u),q(u));const b=v.getTotal();P!==b&&O(b)},[v,y,u,P,s]),f.useLayoutEffect(()=>{C!==null&&T.current&&(j.debug("[VirtualScroll] Scrolling to position:",C),T.current.scrollTo(C),$(null))},[C]);const H=f.useCallback(b=>{if(T.current){j.debug("[VirtualScroll] Scrolling to index:",b);const V=M(b,0,y-1),r=M(V-n*2,0,y-1),i=M(V+n*2,0,y-1),{cumulative:m,total:p,currentValue:R}=v.prefixSum(V,{materializeOption:{materialize:!0,ranges:[{from:r,to:i}]}});j.debug("[VirtualScroll] Scrolling to index:",b,"Offset:",m,"Total height:",p,"Current value:",R,"safeIndex:",V,"safeIndexFrom:",r,"safeIndexTo:",i),p&&(O(p),$(m-R)),j.debug("[VirtualScroll] Setting scroll position to:",m-R)}},[v,n,y]),U=f.useCallback(b=>{if(T.current){const V=v.getTotal(),r=M(Math.floor(b),0,V),i=v.findIndexAtOrAfter(r,{materializeOption:{materialize:!1}}).index;H(i)}},[v,H]),J=f.useCallback((b,V)=>{j.debug("[VirtualScroll] Scroll position changed:",b),d(b);const r=v.getTotal();a?.(b,r)},[v,a]),{renderingStartIndex:L,renderingEndIndex:D,visibleStartIndex:W,visibleEndIndex:X}=f.useMemo(()=>{if(y===0)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const{index:b,cumulative:V,currentValue:r}=v.findIndexAtOrAfter(I,{materializeOption:{materialize:!1}});let i=0;b===-1?i=0:(V??0)<I+(r??0)?i=1:i=0;const m=b===-1?0:b+i,p=M(m-n,0,y-1);let R=0,E=b===-1?0:b+i;for(;E<y&&R<t;){const Y=s(E);R+=Y,E++}E-=1;const k=M(E+n,0,y-1);return j.debug("[VirtualScroll] Calculated rendering range:",{renderingStartIndex:p,renderingEndIndex:k,visibleStartIndex:m,visibleEndIndex:E,scrollPosition:I,renderingContentSize:v.getTotal(),overscanCount:n,viewportSize:t}),{renderingStartIndex:p,renderingEndIndex:k,visibleStartIndex:m,visibleEndIndex:E}},[I,n,t,s,v,y]);f.useEffect(()=>{const b=T.current?.getScrollPosition()??0;j.debug("[VirtualScroll] Range change effect triggered",{renderingStartIndex:L,renderingEndIndex:D,visibleStartIndex:W,visibleEndIndex:X,scrollPosition:I,contentSize:P,scrollPaneScrollPosition:b}),h?.(L,D,W,X,I,P)},[L,D,W,X,h,I,P]);const Q=f.useCallback(b=>{if(j.debug("[VirtualScroll] Rendering visible items",{currentScrollPosition:b,renderingStartIndex:L,renderingEndIndex:D,fenwickSize:y,viewportSize:t}),y===0)return z.jsx("div",{className:"absolute w-full",style:{top:0},children:z.jsx("div",{className:"text-center text-gray-500",children:"No items"})});const V=M(L,0,y-1),{cumulative:r,currentValue:i}=v.prefixSum(V,{materializeOption:{materialize:!1}}),m=r-i,p=[],R=[];for(let k=L;k<=D;k++){const Y=s(k);p.push({item:e(k),height:Y}),v.get(k)!==Y&&R.push({index:k,value:Y})}R.length>0&&Promise.resolve().then(()=>{const k=v.updates(R);k&&(O(k),j.debug("[VirtualScroll] Updated heights for items",R,"New total height:",k))});const E=P<t?0:m-b;return j.debug("[VirtualScroll] Rendering items",{visibleItems:p,containerTop:E}),z.jsx("div",{className:"absolute w-full",style:{top:E},children:p.map(({item:k,height:Y},F)=>{const N=L+F,G=M(N,0,y-1),{cumulative:ee,currentValue:de}=v.prefixSum(G,{materializeOption:{materialize:!1}}),he=ee-de;return z.jsx("div",{"data-index":N,style:{position:"absolute",top:he-m,width:"100%"},children:l(k,N)},N)})})},[e,l,P,t,L,D,v,y,s]);return f.useImperativeHandle(_,()=>({getScrollPosition:()=>T.current?.getScrollPosition()??-1,getContentSize:()=>T.current?.getContentSize()??-1,getViewportSize:()=>T.current?.getViewportSize()??-1,scrollTo:b=>U(b),scrollToIndex:b=>H(b),getFenwickTreeTotalHeight:()=>v.getTotal(),getFenwickSize:()=>v.getSize()}),[H,v,U]),z.jsx(le,{ref:T,contentSize:P,viewportSize:t,className:o,onScroll:J,background:c,children:Q})}const xe=f.forwardRef(pe);class Te{key;value;prev=null;next=null;constructor(e,s){this.key=e,this.value=s}}class oe{head=null;tail=null;addToTail(e){this.tail?(this.tail.next=e,e.prev=this.tail,this.tail=e):this.head=this.tail=e}remove(e){e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,e.prev=null,e.next=null}removeHead(){const e=this.head;return e&&this.remove(e),e}moveToTail(e){this.remove(e),this.addToTail(e)}}function fe(u){const e=f.useRef(new Map),s=f.useRef(new oe);f.useEffect(()=>{for(;e.current.size>u;){const c=s.current.removeHead();if(c)e.current.delete(c.key);else break}},[u]);const t=f.useCallback(c=>{const g=e.current.get(c);if(g)return s.current.moveToTail(g),g.value},[]),n=f.useCallback((c,g)=>{if(u<=0)return;let x=e.current.get(c);if(x)x.value=g,s.current.moveToTail(x);else{if(e.current.size>=u){const _=s.current.removeHead();_&&e.current.delete(_.key)}x=new Te(c,g),e.current.set(c,x),s.current.addToTail(x)}},[u]),o=f.useCallback(c=>e.current.has(c),[]),a=f.useCallback(()=>{e.current.clear(),s.current=new oe},[]),[h,l]=f.useState(()=>({get:t,set:n,has:o,clear:a}));return f.useEffect(()=>l({get:t,set:n,has:o,clear:a}),[t,n,o,a]),h}const Ee=1e4,Re=()=>{const{get:u,set:e,has:s,clear:t}=fe(Ee);return{get:u,set:e,has:s,clear:t}};exports.FenwickMapTree=ue;exports.ScrollBar=ie;exports.ScrollPane=le;exports.VirtualScroll=xe;exports.minmax=M;exports.useFenwickMapTree=ce;exports.useHeightCache=Re;exports.useLruCache=fe;
|
|
22
|
+
<%s key={someKey} {...props} />`,R,P,X,P),I[P+R]=!0)}if(P=null,T!==void 0&&(n(T),P=""+T),l(a)&&(n(a.key),P=""+a.key),"key"in a){T={};for(var W in a)W!=="key"&&(T[W]=a[W])}else T=a;return P&&m(T,typeof t=="function"?t.displayName||t.name||"Unknown":t),b(t,P,V,S,o(),T,D,M)}function _(t){typeof t=="object"&&t!==null&&t.$$typeof===te&&t._store&&(t._store.validated=1)}var y=s,te=Symbol.for("react.transitional.element"),se=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),F=Symbol.for("react.profiler"),h=Symbol.for("react.consumer"),J=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),c=Symbol.for("react.client.reference"),z=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=Object.prototype.hasOwnProperty,L=Array.isArray,E=console.createTask?console.createTask:function(){return null};y={react_stack_bottom_frame:function(t){return t()}};var w,A={},p=y.react_stack_bottom_frame.bind(y,i)(),v=E(r(i)),I={};ce.Fragment=N,ce.jsx=function(t,a,T,R,S){var V=1e4>z.recentlyCreatedOwnerStacks++;return x(t,a,T,!1,R,S,V?Error("react-stack-top-frame"):p,V?E(r(t)):v)},ce.jsxs=function(t,a,T,R,S){var V=1e4>z.recentlyCreatedOwnerStacks++;return x(t,a,T,!0,R,S,V?Error("react-stack-top-frame"):p,V?E(r(t)):v)}})()),ce}var Ie;function He(){return Ie||(Ie=1,process.env.NODE_ENV==="production"?pe.exports=Ye():pe.exports=ze()),pe.exports}var $=He();const ee={debug(u,...e){typeof window<"u"&&window.localStorage?.getItem("debug")==="true"&&console.debug(`[VirtualScroll] ${u}`,...e)},warn(u,...e){console.warn(`[VirtualScroll] ${u}`,...e)},error(u,...e){console.error(`[VirtualScroll] ${u}`,...e)}},H=(u,e,n)=>Math.min(n,Math.max(e,u)),Te={active:!1,offsetY:0,distance:0,direction:0},Me=6,Ve=s.forwardRef(({onDragChange:u,className:e,maxVisualDistance:n=160,size:r=64,style:o,opacity:i=1},l)=>{const[m,g]=s.useState(Te),b=s.useRef(null),x=s.useRef({x:0,y:0}),_=s.useRef(null),y=s.useCallback((E,w=!1)=>{const{y:A}=x.current,p=E-A,v=Math.abs(p),I=v<Me?0:p<0?-1:1,t={active:w||v>=Me,offsetY:p,distance:v,direction:I};g(t),u(t)},[u]),te=s.useCallback((E=!1)=>{if(E&&b.current!==null){const w=_.current;w?.hasPointerCapture(b.current)&&w.releasePointerCapture(b.current)}b.current=null,g(Te),u(Te)},[u]),se=s.useCallback(E=>{E.preventDefault(),E.stopPropagation();const w=_.current??E.currentTarget,A=w.getBoundingClientRect();x.current={x:A.left+A.width/2,y:A.top+A.height/2},b.current=E.pointerId,w.setPointerCapture(E.pointerId),y(E.clientY,!0)},[y]),N=s.useCallback(E=>{b.current===E.pointerId&&(E.preventDefault(),y(E.clientY))},[y]),G=s.useCallback(E=>{b.current===E.pointerId&&(E.preventDefault(),E.stopPropagation(),te(!0))},[te]);s.useImperativeHandle(l,()=>({reset:()=>{te(!0)},getElement:()=>_.current}),[te]);const F=s.useMemo(()=>Math.min(m.distance,n)/n,[m.distance,n]),h=s.useMemo(()=>r/64,[r]),J=s.useMemo(()=>1+F*.4,[F]),k=s.useMemo(()=>m.direction*F*10*h,[m.direction,F,h]),C=s.useMemo(()=>m.direction*F*26*h,[m.direction,F,h]),j=s.useMemo(()=>22*h,[h]),B=s.useMemo(()=>Math.max(2.5,3*h),[h]),U=s.useMemo(()=>6*h,[h]),re=s.useMemo(()=>3*h,[h]),c=s.useMemo(()=>Math.min(Math.max(i,0),1),[i]),z=s.useMemo(()=>{const E={...o,width:r,height:r,transform:`translateY(${k}px)`};return E.opacity=c,E},[c,k,r,o]),Y=s.useMemo(()=>Math.abs(C)+U,[U,C]),L=s.useMemo(()=>C>0?re:-Math.abs(C)-re,[re,C]);return $.jsxs("div",{ref:_,className:fe.twMerge("relative flex items-center justify-center touch-none select-none","transition-transform duration-100 ease-out",e),style:z,onPointerDown:se,onPointerMove:N,onPointerUp:G,onPointerCancel:G,role:"presentation",children:[$.jsx("div",{className:"absolute inset-0 rounded-full border border-white/40 bg-gradient-to-br from-[#1d4ed8]/60 via-[#60a5fa]/55 to-[#bfdbfe]/40 shadow-md",style:{transform:`scaleY(${J})`,transition:m.active?"transform 40ms ease-out":"transform 200ms ease"}}),$.jsx("div",{className:"absolute left-1/2 top-1/2 h-6 w-6 -translate-x-1/2 -translate-y-1/2 rounded-full border border-white/50 bg-white/85",style:{width:j,height:j,transform:`translate(-50%, calc(-50% + ${C*.3}px)) scale(${1+F*.2})`,transition:m.active?"transform 40ms ease-out":"transform 200ms ease"}}),$.jsx("div",{className:"absolute left-1/2 top-1/2 w-1 rounded-full bg-white/50",style:{width:B,height:Y,transform:`translate(-50%, ${L}px)`,opacity:F,transition:m.active?"height 40ms ease-out, opacity 60ms":"height 200ms ease, opacity 120ms"}})]})});Ve.displayName="TapScrollCircle";const _e=(u,e,n)=>{const r="touches"in u.nativeEvent,o=r?u.nativeEvent.touches[0]:u.nativeEvent,i=m=>{r&&m.cancelable&&m.preventDefault();const g="touches"in m?m.touches[0]:m;e({deltaX:g.clientX-o.clientX,deltaY:g.clientY-o.clientY})},l=()=>{r?(document.removeEventListener("touchmove",i),document.removeEventListener("touchend",l)):(document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",l)),n?.()};r?(document.addEventListener("touchmove",i,{passive:!1}),document.addEventListener("touchend",l)):(document.addEventListener("mousemove",i),document.addEventListener("mouseup",l))},we="virtualscroll:tap-scroll-cancel",Pe=20,$e=250,Ue=60,qe=20,Xe=20,We=220,ke={active:!1,offsetY:0,distance:0,direction:0},Ee=2.2,Be=8,Ge=120,oe={enabled:!0,size:64,offsetX:-80,offsetY:0,className:void 0,maxVisualDistance:We,opacity:1},Je=u=>{if(!u||u<=0)return Ee;const e=Math.max(1,u),n=Math.log10(e),r=Ee+n*Be;return H(r,Ee,Ge)},Ce=({contentSize:u,viewportSize:e,scrollPosition:n,onScroll:r,horizontal:o=!1,scrollBarWidth:i=12,className:l,ariaControls:m,tapScrollCircleOptions:g,itemCount:b})=>{const[x,_]=s.useState(!1),[y,te]=s.useState(!1),se=s.useRef(null),N=s.useRef(n),G=s.useRef(null),F=s.useRef(null),h=s.useRef(ke),J=s.useRef(null),k=s.useRef(null),C=s.useRef(null),j=s.useMemo(()=>{const d=g?.maxSpeedMultiplier,O=typeof d=="number"?d:Je(b);return{enabled:g?.enabled??oe.enabled,size:g?.size??oe.size,offsetX:g?.offsetX??oe.offsetX,offsetY:g?.offsetY??oe.offsetY,className:g?.className??oe.className,maxVisualDistance:g?.maxVisualDistance??oe.maxVisualDistance,maxSpeedMultiplier:O,opacity:H(g?.opacity??oe.opacity,0,1)}},[b,g]),{enabled:B,size:U,offsetX:re,offsetY:c,className:z,maxVisualDistance:Y,maxSpeedMultiplier:L,opacity:E}=j,w=Math.max(Y,1),A=e/u,p=i,v=Math.max(e-p*2,0),I=A*v,t=Math.min(Math.max(Pe,I||0),v||Pe),a=u-e,T=Math.max(v-t,0),R=a<=0||T<=0?0:n/a*T,S=u>e;s.useEffect(()=>{N.current=n},[n]),s.useEffect(()=>{se.current&&(x?se.current.style.backgroundColor="#4F4F4F":se.current.style.backgroundColor="#7F7F7F")},[x]);const V=s.useCallback(()=>{G.current!==null&&(window.clearInterval(G.current),G.current=null),F.current!==null&&(window.clearTimeout(F.current),F.current=null)},[]),D=s.useCallback(()=>{k.current!==null&&(window.cancelAnimationFrame(k.current),k.current=null),C.current=null},[]),M=s.useCallback(()=>{h.current={...ke},te(!1),J.current?.reset(),D()},[D]),P=s.useCallback(d=>{const O=h.current;if(!O.active||O.direction===0){D();return}if(!S||a<=0){D();return}const Q=C.current??d,K=Math.max((d-Q)/1e3,0);if(C.current=d,K<=0){k.current=window.requestAnimationFrame(P);return}const ge=(Math.min(O.distance,w)/w)**1.1,ie=Math.max(e*.2,40),be=Math.max(e*L,1200),ve=ie+(be-ie)*ge,he=N.current,xe=H(he+O.direction*ve*K,0,a);if(xe===he){D();return}N.current=xe,r?.(xe,he),k.current=window.requestAnimationFrame(P)},[w,a,r,S,D,L,e]),X=s.useCallback(()=>{k.current===null&&(C.current=null,k.current=window.requestAnimationFrame(P))},[P]);s.useEffect(()=>()=>{V(),D()},[V,D]);const W=s.useCallback(d=>{h.current=d,te(d.active),d.active&&d.direction!==0?X():D()},[X,D]);s.useEffect(()=>{B||M()},[M,B]),s.useEffect(()=>{const d=O=>{const K=O.detail?.paneId;K&&m&&K!==m||M()};return window.addEventListener(we,d),()=>{window.removeEventListener(we,d)}},[m,M]),s.useEffect(()=>{if(!B)return;const d=O=>{if(!h.current.active)return;const Q=O.target;if(!(Q instanceof Node)){M();return}J.current?.getElement()?.contains(Q)||M()};return document.addEventListener("pointerdown",d,!0),()=>{document.removeEventListener("pointerdown",d,!0)}},[M,B]);const f=d=>{if(!S||T<=0||a<=0)return 0;const O=H(d,0,T);return H(O/T*a,0,a)},Z=d=>{if(!S||a<=0)return;const O=Math.max(Math.round(e/Xe),qe),Q=N.current,K=H(Q+d*O,0,a);K!==Q&&(N.current=K,r?.(K,Q))},q=()=>{V()},ne=d=>O=>{S&&(O.preventDefault(),O.stopPropagation(),M(),V(),Z(d),F.current=window.setTimeout(()=>{G.current=window.setInterval(()=>{Z(d)},Ue)},$e))},ae=d=>O=>{(O.key==="Enter"||O.key===" "||O.key==="Spacebar")&&(O.preventDefault(),Z(d))},de=d=>{if(!S||"button"in d&&d.button!==0||d.ctrlKey)return;d.stopPropagation(),M();const O=R;_(!0),_e(d,({deltaX:Q,deltaY:K})=>{r?.(f(O+(o?Q:K)),R)},()=>{_(!1)})},Se=d=>{if(!S||"button"in d&&d.button!==0||d.ctrlKey)return;const Q="touches"in d.nativeEvent?d.nativeEvent.touches[0]:d.nativeEvent,K=o?Q.clientX:Q.clientY,me=d.currentTarget.getBoundingClientRect(),ge=o?K-me.left:K-me.top;M();const ie=ge-t/2;r?.(f(ie),R),_e(d,({deltaX:be,deltaY:ve})=>{r?.(f(ie+(o?be:ve)),R)})},Ne=s.useMemo(()=>H((y?1:.8)*E,0,1),[y,E]),je=s.useMemo(()=>{const O=`calc(50% - ${U/2}px + ${c}px)`;return{left:re,top:O}},[re,c,U]);return $.jsxs("div",{className:fe.twMerge("group relative cursor-default select-none",o?"flex flex-row items-stretch":"flex flex-col items-stretch",l),style:{[o?"width":"height"]:e,[o?"height":"width"]:i,backgroundColor:"white",userSelect:"none",position:"relative"},role:"scrollbar",tabIndex:-1,"aria-controls":m,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":a,"aria-orientation":o?"horizontal":"vertical",children:[!o&&S&&B&&$.jsx(Ve,{ref:J,className:fe.twMerge("pointer-events-auto absolute transition-opacity duration-150",z),size:U,maxVisualDistance:w,style:je,opacity:Ne,onDragChange:W}),$.jsx("button",{type:"button",className:"flex items-center justify-center text-xs text-[#313131] transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[#60a5fa] focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50",style:{[o?"width":"height"]:p,[o?"height":"width"]:i,backgroundColor:"#E0E0E0"},"aria-label":o?"Scroll left":"Scroll up",onMouseDown:ne(-1),onTouchStart:ne(-1),onMouseUp:q,onMouseLeave:q,onTouchEnd:q,onTouchCancel:q,onKeyDown:ae(-1),disabled:!S,children:$.jsx("span",{"aria-hidden":"true",children:o?"◀":"▲"})}),$.jsx("div",{className:"relative flex-1",style:{backgroundColor:"#F5F5F5",borderRadius:i/2},onMouseDown:Se,onTouchStart:Se,children:u>e&&$.jsx("div",{className:"group absolute",style:{[o?"width":"height"]:t,[o?"left":"top"]:R,...o?{top:0,bottom:0}:{left:0,right:0}},onMouseDown:de,onTouchStart:de,role:"slider","aria-orientation":o?"horizontal":"vertical","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":a,tabIndex:0,children:$.jsx("div",{ref:se,className:fe.twMerge("absolute",o?`inset-x-0 inset-y-[1.5px] group-hover:inset-y-[-0.5px] ${x?"inset-y-[-2px]":"group-active:inset-y-[-2px]"}`:`inset-x-[1.5px] inset-y-0 group-hover:inset-x-[-0.5px] ${x?"inset-x-[-2px]":"group-active:inset-x-[-2px]"}`),style:{backgroundColor:"#7F7F7F",borderRadius:i-1,...o?{left:0,right:0,top:x?-2:1.5,bottom:x?-2:1.5}:{top:0,bottom:0,left:x?-2:1.5,right:x?-2:1.5}},onMouseEnter:d=>{o?(d.currentTarget.style.top="-0.5px",d.currentTarget.style.bottom="-0.5px"):(d.currentTarget.style.left="-0.5px",d.currentTarget.style.right="-0.5px"),x||(d.currentTarget.style.backgroundColor="#5F5F5F")},onMouseLeave:d=>{o?(d.currentTarget.style.top=x?"-2px":"1.5px",d.currentTarget.style.bottom=x?"-2px":"1.5px"):(d.currentTarget.style.left=x?"-2px":"1.5px",d.currentTarget.style.right=x?"-2px":"1.5px"),x||(d.currentTarget.style.backgroundColor="#7F7F7F")}})})}),$.jsx("button",{type:"button",className:"flex items-center justify-center text-xs text-[#313131] transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[#60a5fa] focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50",style:{[o?"width":"height"]:p,[o?"height":"width"]:i,backgroundColor:"#E0E0E0"},"aria-label":o?"Scroll right":"Scroll down",onMouseDown:ne(1),onTouchStart:ne(1),onMouseUp:q,onMouseLeave:q,onTouchEnd:q,onTouchCancel:q,onKeyDown:ae(1),disabled:!S,children:$.jsx("span",{"aria-hidden":"true",children:o?"▶":"▼"})})]})},ue={maxVelocity:6,minVelocity:.02,deceleration:.0025,velocitySampleWindow:90,startVelocityThreshold:.04},Le=s.forwardRef(({children:u,contentSize:e,viewportSize:n,scrollBarWidth:r=12,onScroll:o,className:i,style:l,background:m,tapScrollCircleOptions:g,inertiaOptions:b,itemCount:x},_)=>{const y=s.useRef(0),[te,se]=s.useReducer(c=>c+1,0),N=s.useRef(null),G=s.useRef(null),F=s.useRef({frame:null,velocity:0,lastTimestamp:null}),h=s.useMemo(()=>({maxVelocity:b?.maxVelocity??ue.maxVelocity,minVelocity:b?.minVelocity??ue.minVelocity,deceleration:b?.deceleration??ue.deceleration,velocitySampleWindow:b?.velocitySampleWindow??ue.velocitySampleWindow,startVelocityThreshold:b?.startVelocityThreshold??ue.startVelocityThreshold}),[b]);ee.debug("[ScrollPane] ScrollPane rendered",{contentSize:e,viewportSize:n,scrollBarWidth:r,className:i,style:l,tapScrollCircleOptions:g,inertiaOptions:b});const J=s.useRef({contentSize:e,viewportSize:n}),k=s.useMemo(()=>e>n,[e,n]),C=s.useCallback(c=>{const{contentSize:z,viewportSize:Y}=J.current,L=z>Y,E=y.current;if(ee.debug("[ScrollPane] scrollTo called",{newPosition:c,contentSize:z,viewportSize:Y,currentIsScrollable:L,prevPosition:E}),!L){y.current!==0&&(y.current=0,o?.(0,E));return}const w=typeof c=="function"?c(y.current):c,A=H(w,0,z-Y);y.current!==A&&(y.current=A,o?.(A,E))},[o]),j=s.useCallback(()=>{const c=F.current;c.frame!==null&&cancelAnimationFrame(c.frame),c.frame=null,c.velocity=0,c.lastTimestamp=null},[]),B=s.useCallback(c=>{if(!k)return;const{maxVelocity:z,minVelocity:Y,deceleration:L,startVelocityThreshold:E}=h,w=H(c,-z,z);if(Math.abs(w)<E)return;j(),F.current.velocity=w,F.current.lastTimestamp=null;const A=p=>{const v=F.current;if(v.lastTimestamp===null){v.lastTimestamp=p,v.frame=requestAnimationFrame(A);return}const I=p-v.lastTimestamp;if(v.lastTimestamp=p,I<=0){v.frame=requestAnimationFrame(A);return}const t=v.velocity;let a=t;const T=L*I;t>0?a=Math.max(0,t-T):t<0&&(a=Math.min(0,t+T));const S=(t+a)/2*I,V=y.current;S!==0&&C(f=>f+S);const D=y.current,{contentSize:M,viewportSize:P}=J.current,X=Math.max(M-P,0);v.velocity=a;const W=D===V||D<=0&&a<=0||D>=X&&a>=0;if(Math.abs(a)<Y||W){j();return}v.frame=requestAnimationFrame(A)};F.current.frame=requestAnimationFrame(A)},[k,h,C,j]);s.useLayoutEffect(()=>{J.current={contentSize:e,viewportSize:n}},[e,n]),s.useLayoutEffect(()=>{if(k){ee.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change",{contentSize:e,viewportSize:n,scrollPosition:y.current});const c=H(e-n,0,e);y.current>c&&C(c)}else C(0)},[k,C,e,n]),s.useEffect(()=>{const c=Y=>{if(!k)return;Y.preventDefault(),j();let L=Y.deltaY;Y.deltaMode===1?L*=16:Y.deltaMode===2&&(L*=n),ee.debug("[ScrollPane] wheel event",{deltaY:L,scrollPosition:y.current}),C(E=>E+L)},z=N.current;return z&&z.addEventListener("wheel",c,{passive:!1}),()=>{z&&z.removeEventListener("wheel",c)}},[k,C,j,n]),s.useImperativeHandle(_,()=>({scrollTo:C,getScrollPosition:()=>y.current,getContentSize:()=>e,getViewportSize:()=>n}),[C,e,n]);const U=s.useId(),re=s.useMemo(()=>$.jsxs("div",{ref:N,className:fe.twMerge("flex",i),style:l,children:[$.jsxs("div",{ref:G,className:"relative h-full flex-1 overflow-hidden",style:{height:n,touchAction:"none"},id:U,children:[m,u(y.current)]}),k&&$.jsx(Ce,{contentSize:e,viewportSize:n,scrollPosition:y.current,onScroll:C,scrollBarWidth:r,ariaControls:U,tapScrollCircleOptions:g,itemCount:x})]}),[u,e,n,r,i,l,k,C,U,m,g,x]);return s.useEffect(()=>{const c=G.current;if(!c)return;const z=6,Y="input, textarea, select, button, a[href], [role='button']";let L=null,E=0,w=0,A=!1,p=!1,v=!1,I=null,t=[];const a=()=>{L=null,E=0,w=0,A=!1,p=!1,t=[]},T=f=>{const Z=performance.now();t.push({clientY:f,time:Z}),t=t.filter(q=>Z-q.time<=h.velocitySampleWindow)},R=f=>f instanceof HTMLElement?f.closest("[data-scrollpane-ignore-drag='true']")!==null:!1,S=f=>f instanceof HTMLElement?f.closest(Y)!==null:!1,V=f=>{v&&(f.preventDefault(),f.stopPropagation(),v=!1)},D=f=>{A||(A=!0,p=!1,v=!0,c.hasPointerCapture(f.pointerId)||c.setPointerCapture(f.pointerId),T(f.clientY))},M=f=>{if(L!==f.pointerId)return;if(!A){const ne=Math.abs(f.clientY-E);if(p&&ne<z)return;D(f)}if(!A)return;T(f.clientY);const Z=f.clientY-E,q=w-Z;C(q),f.cancelable&&f.preventDefault()},P=f=>{if(L!==f.pointerId)return;A&&v&&f.cancelable&&(f.preventDefault(),f.stopPropagation()),c.hasPointerCapture(f.pointerId)&&c.releasePointerCapture(f.pointerId);let Z=0;if(A&&t.length>=2){const q=t[t.length-1],ne=t.find(ae=>q.time-ae.time<=h.velocitySampleWindow)??t[0];if(q&&ne&&q.time!==ne.time){const ae=q.clientY-ne.clientY,de=q.time-ne.time;Z=-(ae/de)}}a(),I!==null&&window.clearTimeout(I),v&&(I=window.setTimeout(()=>{v=!1,I=null},0)),Math.abs(Z)>=h.startVelocityThreshold&&B(Z)},X=f=>{k&&(f.button!==0&&f.pointerType==="mouse"||f.ctrlKey||f.metaKey||f.altKey||R(f.target)||(window.dispatchEvent(new CustomEvent(we,{detail:{paneId:U}})),j(),L=f.pointerId,E=f.clientY,w=y.current,p=S(f.target),A=!1,v=!1,t=[],p||(v=!0,D(f),T(f.clientY),f.cancelable&&f.preventDefault())))},W=f=>{L===f.pointerId&&(v=!1,c.hasPointerCapture(f.pointerId)&&c.releasePointerCapture(f.pointerId),I!==null&&(window.clearTimeout(I),I=null),a())};return c.addEventListener("click",V,!0),c.addEventListener("pointerdown",X,{passive:!1}),c.addEventListener("pointermove",M,{passive:!1}),c.addEventListener("pointerup",P),c.addEventListener("pointercancel",W),window.addEventListener("pointermove",M,{passive:!1}),window.addEventListener("pointerup",P),window.addEventListener("pointercancel",W),()=>{c.removeEventListener("click",V,!0),c.removeEventListener("pointerdown",X),c.removeEventListener("pointermove",M),c.removeEventListener("pointerup",P),c.removeEventListener("pointercancel",W),window.removeEventListener("pointermove",M),window.removeEventListener("pointerup",P),window.removeEventListener("pointercancel",W),L!==null&&c.hasPointerCapture(L)&&c.releasePointerCapture(L),I!==null&&window.clearTimeout(I),j()}},[U,k,h,C,B,j]),re});class Oe{tree;deltas;size;baseValue;valueFn;total;constructor(e,n,r){this.reset(e,n,r)}reset(e,n,r){if(this.size=e,this.tree=new Map,this.deltas=new Map,this.total=void 0,typeof n=="function"){if(this.valueFn=n,this.size>0){const i=r?.sampleRange??{from:0,to:Math.min(99,this.size-1)},{mode:l,materializedValues:m}=this._calculateMode(i.from,i.to);if(this.baseValue=l,r?.materialize)for(let g=0;g<m.length;g++){const b=m[g],x=i.from+g;if(x>=this.size)break;const _=b-this.baseValue;this.deltas.set(x,_),this._updateTree(x,_)}}else this.baseValue=0;this.total=this.getTotal()}else this.valueFn=void 0,this.baseValue=n,this.total=this.baseValue*this.size}setValueFn(e){typeof e=="function"?this.valueFn=e:(this.valueFn=void 0,this.baseValue=e)}_calculateMode(e,n){if(!this.valueFn)return{mode:0,materializedValues:[]};const r=[];for(let b=e;b<=n&&!(b>=this.size);b++)r.push(this.valueFn(b));const o=[...r];if(r.length===0)return{mode:0,materializedValues:[]};r.sort((b,x)=>b-x);const i=Math.floor(r.length/2);let l;r.length%2===0?l=Math.floor((r[i-1]+r[i])/2):l=r[i];const m=new Map;let g=0;for(const b of r){const x=(m.get(b)??0)+1;m.set(b,x),x>g&&(g=x)}if(g>1){const b=[];for(const[_,y]of m.entries())y===g&&b.push(_);const x=b.reduce((_,y)=>_+y,0);l=Math.floor(x/b.length)}return{mode:l,materializedValues:o}}update(e,n){return this.updates([{index:e,value:n}])}updates(e){const n=e.map(({index:r,value:o})=>{if(r<0||r>=this.size)throw new Error(`Index ${r} out of bounds`);if(o<0)throw new Error("Value cannot be negative.");const i=this.deltas.has(r)?(this.deltas.get(r)??0)+this.baseValue:this.baseValue,l=o-i;return{index:r,change:l}}).filter(r=>r.change!==0);return n.length>0?this.updateDeltas(n):this.total}updateDelta(e,n){return this.updateDeltas([{index:e,change:n}])}updateDeltas(e){for(const{index:n,change:r}of e){if(n<0||n>=this.size)throw new Error(`Index ${n} out of bounds`);const o=this.deltas.get(n)??0;this.deltas.set(n,o+r),this._updateTree(n,r)}return this.total}_updateTree(e,n){if(n===0)return;let r=e+1;for(;r<=this.size;)this.tree.set(r,(this.tree.get(r)??0)+n),r+=r&-r;this.total!==void 0&&(this.total+=n)}_materialize(e,n=!0){if(this.valueFn){const r=this.deltas.get(e)??0,i=this.valueFn(e)-this.baseValue;if(i!==r&&(this.deltas.set(e,i),n)){const l=i-r;this._updateTree(e,l)}}}prefixSum(e,n){if(e<0)return{cumulative:0,total:this.total,currentValue:0,safeIndex:0};const r=H(e,0,this.size-1),o=n?.materializeOption;if(o?.materialize&&this.valueFn){if(o.ranges)for(const g of o.ranges){const b=g.from,x=Math.min(g.to,this.size-1);for(let _=b;_<=x;_++)this._materialize(_)}this._materialize(r)}let i=0,l=r+1;for(;l>0;){const g=this.tree.get(l)??0;i+=g,l-=l&-l}const m=o?.materialize?this.get(r):(this.deltas.get(r)||0)+this.baseValue;return{cumulative:i+this.baseValue*(r+1),total:this.total,currentValue:m,safeIndex:r}}get(e,n){if(e<0||e>=this.size)throw new Error("Index out of bounds");const r=n?.materializeOption;if(r?.materialize&&this.valueFn)if(r.ranges){for(const o of r.ranges){const i=o.from,l=Math.min(o.to,this.size-1);for(let m=i;m<=l;m++)this._materialize(m)}e>=r.ranges[0].from&&e<=r.ranges[r.ranges.length-1].to&&this._materialize(e)}else this._materialize(e);return(this.deltas.get(e)??0)+this.baseValue}getTotal(e){const n=e?.materializeOption;if(n?.materialize&&this.valueFn&&n.ranges)for(const r of n.ranges){const o=r.from,i=Math.min(r.to,this.size-1);for(let l=o;l<=i;l++)this._materialize(l)}if(this.total===void 0)if(this.size===0)this.total=0;else{let r=this.baseValue*this.size;for(const o of this.deltas.values())r+=o;this.total=r,console.assert(this.prefixSum(this.getSize()-1).cumulative===this.prefixSum(this.getSize()-1).total,"Inconsistent Fenwick Tree state")}return this.total}rebuildTree(e){if(e?.materialize&&this.valueFn){const o=this.valueFn;this.reset(this.size,i=>o(i),{materialize:!0});return}const n=new Map;let r=this.baseValue*this.size;for(const[o,i]of this.deltas.entries()){if(r+=i,i===0)continue;let l=o+1;for(;l<=this.size;)n.set(l,(n.get(l)??0)+i),l+=l&-l}this.tree=n,this.total=r}calculateAccumulatedError(){if(this.total===void 0)return 0;let e=this.baseValue*this.size;for(const n of this.deltas.values())e+=n;return this.total-e}changeSize(e){const n=this.size;if(e!==n){if(e<n)for(const r of this.deltas.keys())r>=e&&this.deltas.delete(r);this.size=e,this.rebuildTree(),console.assert(this.prefixSum(this.getSize()-1).cumulative===this.prefixSum(this.getSize()-1).total,"Inconsistent Fenwick Tree state")}}getSize(){return this.size}findIndexAtOrAfter(e,n){if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};let r=0,o=this.size-1,i=-1,l,m=this.total;for(;r<=o;){const g=Math.floor((r+o)/2);l=this.prefixSum(g,n),m=l.total,l.cumulative>=e?(i=g,o=g-1):r=g+1}return{index:i,total:m,cumulative:l?.cumulative,currentValue:l?.currentValue,safeIndex:l?.safeIndex}}findIndexAtOrBefore(e,n){if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};let r=0,o=this.size-1,i=-1,l,m=this.total;for(;r<=o;){const g=Math.floor((r+o)/2);l=this.prefixSum(g,n),m=l.total,l.cumulative<=e?(i=g,r=g+1):o=g-1}return{index:i,total:m,cumulative:l?.cumulative,currentValue:l?.currentValue,safeIndex:l?.safeIndex}}}const De=(u,e,n)=>{const r=Math.max(0,u),o=s.useRef(null),i=s.useMemo(()=>new Oe(r,e,n),[r,e,n]);return Object.is(o.current,i)||console.warn("[useFenwickMapTree] instance changed"),o.current=i,i};function Ke({itemCount:u,getItem:e,getItemHeight:n,viewportSize:r,overscanCount:o=5,className:i,onScroll:l,onRangeChange:m,children:g,background:b,initialScrollIndex:x,initialScrollOffset:_,tapScrollCircleOptions:y,inertiaOptions:te},se){const N=s.useRef(null),G=s.useRef(!1);s.useEffect(()=>(G.current=!0,()=>{G.current=!1}),[]);const F=s.useRef({size:u,valueOrFn:n,options:{sampleRange:{from:0,to:100}}}),h=De(F.current.size,F.current.valueOrFn,F.current.options),[J]=s.useState(()=>{let p=0,v=0;if(typeof x=="number"){const I=H(x,0,u-1),t=H(I-o*2,0,u-1),a=H(I+o*2,0,u-1),T=x>0?{materializeOption:{materialize:!0,ranges:[{from:t,to:a}]}}:void 0,{cumulative:R,total:S,currentValue:V}=h.prefixSum(x,T);p=R-V,v=S??h.getTotal()}else typeof _=="number"&&(p=_),v=h.getTotal();return{position:p,total:v}}),[k,C]=s.useState(J.position),[j,B]=s.useState(J.total),[U,re]=s.useState(J.position),[c,z]=s.useState(u);s.useLayoutEffect(()=>{h.setValueFn(n),c!==u&&(h.changeSize(u),z(u));const p=h.getTotal();j!==p&&B(p)},[h,c,u,j,n]),s.useLayoutEffect(()=>{U!==null&&N.current&&(ee.debug("[VirtualScroll] Scrolling to position:",U),N.current.scrollTo(U),re(null))},[U]);const Y=s.useCallback(p=>{if(N.current){ee.debug("[VirtualScroll] Scrolling to index:",p);const v=H(p,0,c-1),I=H(v-o*2,0,c-1),t=H(v+o*2,0,c-1),{cumulative:a,total:T,currentValue:R}=h.prefixSum(v,{materializeOption:{materialize:!0,ranges:[{from:I,to:t}]}});ee.debug("[VirtualScroll] Scrolling to index:",p,"Offset:",a,"Total height:",T,"Current value:",R,"safeIndex:",v,"safeIndexFrom:",I,"safeIndexTo:",t),T&&(B(T),re(a-R)),ee.debug("[VirtualScroll] Setting scroll position to:",a-R)}},[h,o,c]),L=s.useCallback(p=>{if(N.current){const v=h.getTotal(),I=H(Math.floor(p),0,v),t=h.findIndexAtOrAfter(I,{materializeOption:{materialize:!1}}).index;Y(t)}},[h,Y]),E=s.useCallback((p,v)=>{ee.debug("[VirtualScroll] Scroll position changed:",p),C(p);const I=h.getTotal();l?.(p,I)},[h,l]),w=s.useMemo(()=>{if(c===0)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const{index:p,cumulative:v,currentValue:I}=h.findIndexAtOrAfter(k,{materializeOption:{materialize:!1}});let t=0;p===-1?t=0:(v??0)<k+(I??0)?t=1:t=0;const a=p===-1?0:p+t,T=H(a-o,0,c-1);let R=0,S=p===-1?0:p+t;for(;S<c&&R<r;){const D=n(S);R+=D,S++}S-=1;const V=H(S+o,0,c-1);return ee.debug("[VirtualScroll] Calculated rendering range:",{renderingStartIndex:T,renderingEndIndex:V,visibleStartIndex:a,visibleEndIndex:S,scrollPosition:k,renderingContentSize:h.getTotal(),overscanCount:o,viewportSize:r}),{renderingStartIndex:T,renderingEndIndex:V,visibleStartIndex:a,visibleEndIndex:S}},[k,o,r,n,h,c]);s.useEffect(()=>{const p=N.current?.getScrollPosition()??0;ee.debug("[VirtualScroll] Range change effect triggered",{renderingStartIndex:w.renderingStartIndex,renderingEndIndex:w.renderingEndIndex,visibleStartIndex:w.visibleStartIndex,visibleEndIndex:w.visibleEndIndex,scrollPosition:k,contentSize:j,scrollPaneScrollPosition:p}),m?.(w.renderingStartIndex,w.renderingEndIndex,w.visibleStartIndex,w.visibleEndIndex,k,j)},[w.renderingStartIndex,w.renderingEndIndex,w.visibleStartIndex,w.visibleEndIndex,m,k,j]);const A=s.useCallback(p=>{const{renderingStartIndex:v,renderingEndIndex:I}=w;if(ee.debug("[VirtualScroll] Rendering visible items",{currentScrollPosition:p,renderingStartIndex:v,renderingEndIndex:I,fenwickSize:c,viewportSize:r}),c===0)return $.jsx("div",{className:"absolute w-full",style:{top:0},children:$.jsx("div",{className:"text-center text-gray-500",children:"No items"})});const t=H(v,0,c-1),{cumulative:a,currentValue:T}=h.prefixSum(t,{materializeOption:{materialize:!1}}),R=a-T,S=[],V=[];for(let M=v;M<=I;M++){const P=n(M);S.push({item:e(M),height:P}),h.get(M)!==P&&V.push({index:M,value:P})}V.length>0&&Promise.resolve().then(()=>{const M=h.updates(V);M&&(B(M),ee.debug("[VirtualScroll] Updated heights for items",V,"New total height:",M))});const D=j<r?0:R-p;return ee.debug("[VirtualScroll] Rendering items",{visibleItems:S,containerTop:D}),$.jsx("div",{className:"absolute w-full",style:{top:D},children:S.map(({item:M,height:P},X)=>{const W=v+X,f=H(W,0,c-1),{cumulative:Z,currentValue:q}=h.prefixSum(f,{materializeOption:{materialize:!1}}),ne=Z-q;return $.jsx("div",{"data-index":W,style:{position:"absolute",top:ne-R,width:"100%"},children:g(M,W)},W)})})},[e,g,j,r,w,h,c,n]);return s.useImperativeHandle(se,()=>({getScrollPosition:()=>N.current?.getScrollPosition()??-1,getContentSize:()=>N.current?.getContentSize()??-1,getViewportSize:()=>N.current?.getViewportSize()??-1,scrollTo:p=>L(p),scrollToIndex:p=>Y(p),getFenwickTreeTotalHeight:()=>h.getTotal(),getFenwickSize:()=>h.getSize()}),[Y,h,L]),$.jsx(Le,{ref:N,contentSize:j,viewportSize:r,className:i,onScroll:E,background:b,tapScrollCircleOptions:y,inertiaOptions:te,itemCount:u,children:A})}const Ze=s.forwardRef(Ke);class Qe{key;value;prev=null;next=null;constructor(e,n){this.key=e,this.value=n}}class Ae{head=null;tail=null;addToTail(e){this.tail?(this.tail.next=e,e.prev=this.tail,this.tail=e):this.head=this.tail=e}remove(e){e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,e.prev=null,e.next=null}removeHead(){const e=this.head;return e&&this.remove(e),e}moveToTail(e){this.remove(e),this.addToTail(e)}}function Fe(u){const e=s.useRef(new Map),n=s.useRef(new Ae);s.useEffect(()=>{for(;e.current.size>u;){const b=n.current.removeHead();if(b)e.current.delete(b.key);else break}},[u]);const r=s.useCallback(b=>{const x=e.current.get(b);if(x)return n.current.moveToTail(x),x.value},[]),o=s.useCallback((b,x)=>{if(u<=0)return;let _=e.current.get(b);if(_)_.value=x,n.current.moveToTail(_);else{if(e.current.size>=u){const y=n.current.removeHead();y&&e.current.delete(y.key)}_=new Qe(b,x),e.current.set(b,_),n.current.addToTail(_)}},[u]),i=s.useCallback(b=>e.current.has(b),[]),l=s.useCallback(()=>{e.current.clear(),n.current=new Ae},[]),[m,g]=s.useState(()=>({get:r,set:o,has:i,clear:l}));return s.useEffect(()=>g({get:r,set:o,has:i,clear:l}),[r,o,i,l]),m}const et=1e4,tt=()=>{const{get:u,set:e,has:n,clear:r}=Fe(et);return{get:u,set:e,has:n,clear:r}};exports.FenwickMapTree=Oe;exports.ScrollBar=Ce;exports.ScrollPane=Le;exports.VirtualScroll=Ze;exports.minmax=H;exports.useFenwickMapTree=De;exports.useHeightCache=tt;exports.useLruCache=Fe;
|
|
23
23
|
//# sourceMappingURL=index.cjs.map
|