@aiquants/virtualscroll 3.4.0 → 3.6.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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("react/jsx-runtime"),t=require("react"),xt=require("tailwind-merge"),_r=r=>{const{quantum:e,resetOnDirectionChange:n=!0}=r;if(!(Number.isFinite(e)&&e>0))throw new TypeError(`[createResidualQuantizer] quantum must be a finite positive number, received ${e}`);let i=0;return{push:a=>{if(!Number.isFinite(a)||Math.abs(a)>Number.MAX_SAFE_INTEGER)return 0;n&&i!==0&&a!==0&&Math.sign(a)!==Math.sign(i)&&(i=0),i+=a;const o=Math.trunc(i/e)*e+0;return i-=o,o},peekResidue:()=>i,reset:()=>{i=0}}};class z{level;prefix;impl;constructor(e=2,n="[virtualscroll]",i=console){this.level=e,this.prefix=n,this.impl=i}static instance=new z(2,"[virtualscroll]");static setLevel(e){z.instance.setLevel(e)}setLevel(e){this.level=e}static setImplementation(e){z.instance.setImplementation(e)}setImplementation(e){this.impl=e}static setPrefix(e){z.instance.setPrefix(e)}setPrefix(e){this.prefix=e}static isEnabled(e){return z.instance.isEnabled(e)}isEnabled(e){return this.level<=e}static resolveLazy(e){if(typeof e!="function")return e;try{return e()}catch{return e}}formatMessage(e){return typeof e=="string"?[`${this.prefix} ${e}`]:[this.prefix,e]}static debug(e,...n){z.instance.debug(e,...n)}debug(e,...n){this.level<=0&&this.impl.debug(...this.formatMessage(z.resolveLazy(e)),...n.map(z.resolveLazy))}static info(e,...n){z.instance.info(e,...n)}info(e,...n){this.level<=1&&this.impl.info(...this.formatMessage(z.resolveLazy(e)),...n.map(z.resolveLazy))}static warn(e,...n){z.instance.warn(e,...n)}warn(e,...n){this.level<=2&&this.impl.warn(...this.formatMessage(z.resolveLazy(e)),...n.map(z.resolveLazy))}static error(e,...n){z.instance.error(e,...n)}error(e,...n){this.level<=3&&this.impl.error(...this.formatMessage(z.resolveLazy(e)),...n.map(z.resolveLazy))}}const br={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},sr=6,Or=8,Fr=({dragState:r,normalizedDistance:e})=>{const n=1+e*.18,i=.16+e*.24,a=.38+e*.28,o=r.active?"80ms ease-out":"220ms ease";return H.jsxs(H.Fragment,{children:[H.jsx("div",{className:"aqvs-tap-scroll-circle-visual-outer",style:{background:"linear-gradient(140deg, rgba(255,255,255,0.62), rgba(72,72,72,0.48))",boxShadow:`0 0 0 1px rgba(255,255,255,0.28), 0 10px 22px rgba(0,0,0,${i})`,transform:`scale(${n})`,transition:`${o}, ${r.active?"80ms":"260ms"} box-shadow ease`}}),H.jsx("div",{className:"aqvs-tap-scroll-circle-inner",style:{background:"linear-gradient(140deg, rgba(255,255,255,0.72), rgba(28,28,28,0.58))",boxShadow:"inset 0 4px 10px rgba(0,0,0,0.24), inset 0 0 2px rgba(255,255,255,0.55)",opacity:a,transition:r.active?"120ms opacity ease-out":"220ms opacity ease"}})]})},Er=t.memo(t.forwardRef(({onDragChange:r,className:e,maxVisualDistance:n=160,size:i=40,style:a,opacity:o=1,renderVisual:l,axis:m="y"},h)=>{const[x,S]=t.useState(br),M=t.useRef(null),T=t.useRef(null),v=t.useRef({x:0,y:0}),V=t.useRef(null),J=t.useRef(0),$=t.useCallback(C=>{S(C),r(C)},[r]),oe=t.useCallback((C,j,ce=!1)=>{const{x:Xe,y:qe}=v.current,D=C-Xe,Ze=j-qe,it=m==="x"?D:Ze,Ye=Math.abs(it),xe=Ye<sr?0:it<0?-1:1,ve=J.current;let Re=xe;const Qe=sr+Or;xe===0?ve!==0&&Ye<Qe?Re=ve:(Re=0,ce||(J.current=0)):xe!==ve&&ve!==0&&Ye<Qe?Re=ve:J.current=xe,$({active:ce||Ye>=sr,offsetX:D,offsetY:Ze,distance:Ye,direction:Re,pointerId:M.current})},[$,m]),be=t.useCallback(C=>{if(C===null)return;const j=V.current;j?.hasPointerCapture(C)&&j.releasePointerCapture(C)},[]),ue=t.useCallback((C=!1)=>{C&&be(M.current),M.current=null,T.current=null,J.current=0,$(br)},[$,be]),le=t.useCallback(C=>{if(M.current!==null&&M.current!==C.pointerId){T.current={pointerId:C.pointerId,clientX:C.clientX,clientY:C.clientY},C.preventDefault(),C.stopPropagation();return}C.preventDefault(),C.stopPropagation();const j=V.current??C.currentTarget,{left:ce,top:Xe,width:qe,height:D}=j.getBoundingClientRect();v.current={x:ce+qe/2,y:Xe+D/2},M.current=C.pointerId;try{j.setPointerCapture(C.pointerId)}catch{}oe(C.clientX,C.clientY,!0)},[oe]),ne=t.useCallback(C=>{if(M.current!==C.pointerId){T.current!==null&&T.current.pointerId===C.pointerId&&(T.current={pointerId:C.pointerId,clientX:C.clientX,clientY:C.clientY});return}C.preventDefault(),oe(C.clientX,C.clientY)},[oe]),_=t.useCallback(C=>{if(M.current!==C.pointerId){T.current!==null&&T.current.pointerId===C.pointerId&&(T.current=null);return}C.preventDefault(),C.stopPropagation();const j=T.current;if(T.current=null,j!==null){be(C.pointerId);const ce=V.current;let Xe=!0;if(ce!==null&&typeof ce.setPointerCapture=="function")try{ce.setPointerCapture(j.pointerId)}catch(qe){(typeof qe=="object"&&qe!==null&&"name"in qe?qe.name:void 0)==="NotFoundError"&&(Xe=!1)}if(Xe){M.current=j.pointerId,oe(j.clientX,j.clientY,!0);return}}ue(!0)},[ue,be,oe]),O=t.useCallback(C=>{C.target===C.currentTarget&&M.current===C.pointerId&&ue(!1)},[ue]);t.useImperativeHandle(h,()=>({reset:()=>{ue(!0)},getElement:()=>V.current}),[ue]);const N=Math.min(Math.max(o,0),1),K=i/64,Q=Math.min(x.distance,n)/n,re=x.direction*Q*10*K,se=l??Fr,ye={dragState:x,normalizedDistance:Q,sizeScale:K,size:i,opacity:N},A={...a,width:i,height:i,transform:`translateY(${re}px)`};return A.opacity=N,H.jsx("div",{ref:V,"data-testid":"virtual-scroll-tap-circle",className:xt.twMerge("aqvs-tap-scroll-circle",e),style:A,tabIndex:-1,onPointerDown:le,onPointerMove:ne,onPointerUp:_,onPointerCancel:_,onLostPointerCapture:O,role:"presentation",children:se(ye)})}));Er.displayName="TapScrollCircle";const G=(r,e,n)=>Math.max(e,Math.min(n,r)),cr=(r,e)=>{const n=e==="x",i=r.getBoundingClientRect(),a=n?i.width:i.height,o=S=>{const M=Number.parseFloat(S);return Number.isFinite(M)?M:0},l=window.getComputedStyle(r),m=o(n?l.width:l.height),h=m>0?m+o(n?l.paddingLeft:l.paddingTop)+o(n?l.paddingRight:l.paddingBottom)+o(n?l.borderLeftWidth:l.borderTopWidth)+o(n?l.borderRightWidth:l.borderBottomWidth):0,x=h>0?h:n?r.offsetWidth:r.offsetHeight;return x<=0||a<=0?1:a/x},ur="virtualscroll:tap-scroll-cancel",xr=20,Hr=250,Xr=60,qr=20,Yr=20,hr={maxDistance:240,minSpeedMultiplier:.2},Br=hr.maxDistance,vr={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},ir=2.2,Wr=8,$r=120,jr=1/10,It={enabled:!0,size:40,offsetX:-80,offsetY:0,className:void 0,maxVisualDistance:Br,minSpeedMultiplier:hr.minSpeedMultiplier,opacity:.9,renderVisual:void 0,maxSpeedCurve:void 0},Ur=r=>r?{mainSizeKey:"width",crossSizeKey:"height",positionKey:"left",selectDelta:(e,n)=>e,getPointerCoordinate:({clientX:e})=>e,arrowLabels:["Scroll left","Scroll right"],arrowIcons:["◀","▶"],directionClass:"aqvs-scrollbar-horizontal",orientation:"horizontal"}:{mainSizeKey:"height",crossSizeKey:"width",positionKey:"top",selectDelta:(e,n)=>n,getPointerCoordinate:({clientY:e})=>e,arrowLabels:["Scroll up","Scroll down"],arrowIcons:["▲","▼"],directionClass:"aqvs-scrollbar-vertical",orientation:"vertical"},Gr=(r,e)=>{const n=r?.maxSpeedMultiplier,i=typeof n=="number"?n:Pr(e);return{enabled:r?.enabled??It.enabled,size:r?.size??It.size,offsetX:r?.offsetX??It.offsetX,offsetY:r?.offsetY??It.offsetY,className:r?.className??It.className,maxVisualDistance:r?.maxVisualDistance??It.maxVisualDistance,maxSpeedMultiplier:i,minSpeedMultiplier:Math.max(r?.minSpeedMultiplier??It.minSpeedMultiplier,0),opacity:G(r?.opacity??It.opacity,0,1),renderVisual:r?.renderVisual??It.renderVisual,maxSpeedCurve:r?.maxSpeedCurve??It.maxSpeedCurve}},Kr=({isDragging:r,isThumbHovered:e,enableThumbDrag:n})=>t.useMemo(()=>n?r?"dragging":e?"hover":"idle":"disabled",[n,r,e]),Zr=({canUseArrowButtons:r,enableArrowButtons:e,resetTapScroll:n,scrollByStep:i})=>{const a=t.useRef(null),o=t.useRef(null),l=t.useRef(null),m=t.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null),o.current!==null&&(window.clearTimeout(o.current),o.current=null),l.current!==null&&(window.removeEventListener("pointerup",l.current),window.removeEventListener("pointercancel",l.current),window.removeEventListener("blur",l.current),l.current=null)},[]),h=t.useCallback(()=>{m()},[m]),x=t.useCallback(M=>T=>{if(!r)return;T.cancelable&&T.preventDefault(),T.stopPropagation(),n(),m(),i(M),o.current=window.setTimeout(()=>{a.current=window.setInterval(()=>{i(M)},Xr)},Hr);const v=()=>m();l.current=v,window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),window.addEventListener("blur",v)},[r,m,n,i]),S=t.useCallback(M=>T=>{e&&(T.key==="Enter"||T.key===" "||T.key==="Spacebar")&&(T.preventDefault(),i(M))},[e,i]);return t.useEffect(()=>{r||m()},[r,m]),t.useEffect(()=>()=>{m()},[m]),{handleArrowPointerDown:x,handleArrowPointerUp:h,handleArrowKeyDown:S}},Qr=700,zt=(r,e)=>typeof r=="number"&&Number.isFinite(r)?r:e,Cr=({distance:r,maxDistance:e,viewportSize:n,minSpeedMultiplier:i,maxSpeedMultiplier:a,hasCustomMaxSpeedMultiplier:o,curve:l})=>{const m=Math.max(zt(r,0),0),h=zt(e,0),x=h>0?Math.min(m,h)/h:1,S=Math.max(zt(n,0),0),M=Math.max(zt(i,0),0),T=Math.max(zt(a,0),0),v=Math.max(S*M,40),V=o?v:1200,J=Math.max(S*T,V),$=l?Math.max(zt(l.exponentialScale,T),0):0,oe=l?Math.min(J,Math.max(S*$,v)):J,be=Math.max(oe,v);let ue=x**1.1;if(l){const ne=Math.min(Math.max(zt(l.exponentialSteepness,0),0),Qr);if(ne===0)ue=x;else{const _=Math.expm1(ne)||1;ue=Math.min(Math.max(Math.expm1(ne*x)/_,0),1)}}const le=Math.min(Math.max(zt(l?.easedOffset,0),0),1);return v+(be-v)*(le+(1-le)*ue)},Pr=r=>{if(!r||r<=0)return ir;const e=Math.max(1,r),n=Math.log10(e),i=ir+n*Wr;return G(i,ir,$r)},pr=({contentSize:r,viewportSize:e,scrollPosition:n,onScroll:i,enableThumbDrag:a=!0,enableTrackClick:o=!0,enableArrowButtons:l=!0,horizontal:m=!1,enableHorizontalTapCircle:h=!1,scrollBarWidth:x=12,className:S,ariaControls:M,tapScrollCircleOptions:T,itemCount:v,renderThumbOverlay:V,visibleStartIndex:J,visibleEndIndex:$})=>{const[oe,be]=t.useState(!1),[ue,le]=t.useState(!1),[ne,_]=t.useState(!1),O=t.useRef(null),N=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null}),K=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}),Q=t.useRef(n),re=t.useRef(i),se=t.useRef(vr),ye=t.useRef(null),A=t.useRef(null),C=t.useRef(null),j=t.useRef(0),ce=t.useRef(0),Xe=t.useMemo(()=>Gr(T,v),[v,T]),qe=t.useMemo(()=>Ur(m),[m]),{enabled:D,size:Ze,offsetX:it,offsetY:Ye,className:xe,maxVisualDistance:ve,maxSpeedMultiplier:Re,minSpeedMultiplier:Qe,opacity:ee,renderVisual:te,maxSpeedCurve:mt}=Xe,P=t.useRef({viewportSize:e,maxScrollPosition:Math.max(r-e,0),scrollBarVisible:r>e,effectiveTapMaxDistance:Math.max(ve,1),tapCircleMaxSpeedMultiplier:Re,tapCircleMinSpeedMultiplier:Qe,tapCircleMaxSpeedCurve:mt,tapScrollCircleOptions:T,effectiveTrackLength:0,onScroll:i,scrollPosition:n}),{mainSizeKey:Me,crossSizeKey:F,positionKey:We,selectDelta:ut,getPointerCoordinate:k,arrowLabels:ht,arrowIcons:yt,directionClass:I,orientation:Oe}=qe,$e=Math.max(ve,1),pt=e/r,Ce=Math.max(e-x*2,0),vt=pt*Ce,d=Math.min(Math.max(xr,vt||0),Ce||xr),q=Math.max(r-e,0),Z=Math.max(Ce-d,0),U=q<=0||Z<=0?0:G(n/q*Z,0,Z),me=U+d/2,B=r>e||oe,ie=B&&l;t.useLayoutEffect(()=>{P.current={viewportSize:e,maxScrollPosition:q,scrollBarVisible:B,effectiveTapMaxDistance:$e,tapCircleMaxSpeedMultiplier:Re,tapCircleMinSpeedMultiplier:Qe,tapCircleMaxSpeedCurve:mt,tapScrollCircleOptions:T,effectiveTrackLength:Z,onScroll:i,scrollPosition:n}}),t.useLayoutEffect(()=>{Q.current=n},[n]),t.useLayoutEffect(()=>{re.current=i},[i]),t.useEffect(()=>{a||le(!1)},[a]);const ge=Kr({isDragging:oe,isThumbHovered:ue,enableThumbDrag:a}),W=t.useCallback((u,E)=>{const L=P.current,Y=E??Q.current;if(re.current){const De=re.current(u,Y);if(typeof De=="number"&&Number.isFinite(De))return Q.current=De,De}const de=typeof u=="function"?u(Y):u,Ve=Math.max(L.maxScrollPosition,0),Ne=L.scrollBarVisible?G(de,0,Ve):0;return Q.current=Ne,Ne},[]),he=t.useCallback(u=>{const E=P.current,L=Q.current;if(!E.scrollBarVisible||E.maxScrollPosition<=0){const He=W(0,L),nt=He-L;return{nextPosition:He,actualDelta:nt,reachedBoundary:!0}}if(u===0)return{nextPosition:L,actualDelta:0,reachedBoundary:!1};const de=W(He=>G(He+u,0,E.maxScrollPosition),L),Ve=de-L,Ne=u<0&&L+u<=0,De=u>0&&L+u>=E.maxScrollPosition,Ge=u<0&&(de<=0||Ne&&Ve===0)||u>0&&(de>=E.maxScrollPosition||De&&Ve===0);return{nextPosition:de,actualDelta:Ve,reachedBoundary:Ge}},[W]),Pe=t.useCallback((u,E)=>{u.current+=E;const L=Math.max(P.current.maxScrollPosition,0);L>0&&(u.current=G(u.current,-L,L));const Y=he(u.current);return u.current-=Y.actualDelta,Y.reachedBoundary&&(u.current=0),Y},[he]),Ie=t.useCallback(()=>{A.current!==null&&(window.cancelAnimationFrame(A.current),A.current=null),C.current=null,j.current=0,ce.current=0},[]),fe=t.useCallback(()=>{se.current={...vr},_(!1),ye.current?.reset(),Ie()},[Ie]),je=t.useCallback(u=>{const E=se.current,L=P.current;if(!E.active||E.direction===0){Ie();return}if(!L.scrollBarVisible||L.maxScrollPosition<=0){Ie();return}const Y=C.current??u,de=Math.max((u-Y)/1e3,0),Ve=Math.min(de,jr);if(C.current=u,Ve<=0){A.current=window.requestAnimationFrame(je);return}const Ne=Cr({distance:E.distance,maxDistance:L.effectiveTapMaxDistance,viewportSize:L.viewportSize,minSpeedMultiplier:L.tapCircleMinSpeedMultiplier,maxSpeedMultiplier:L.tapCircleMaxSpeedMultiplier,hasCustomMaxSpeedMultiplier:typeof L.tapScrollCircleOptions?.maxSpeedMultiplier=="number",curve:L.tapCircleMaxSpeedCurve});ce.current!==E.direction&&(ce.current=E.direction,j.current=0);const{reachedBoundary:De}=Pe(j,E.direction*Ne*Ve);if(De){Ie();return}A.current=window.requestAnimationFrame(je)},[Pe,Ie]),ze=t.useCallback(()=>{A.current===null&&(C.current=null,j.current=0,A.current=window.requestAnimationFrame(je))},[je]);t.useEffect(()=>{const u=se.current;!u.active||u.direction===0||ze()},[r,e,ze]),t.useEffect(()=>()=>{Ie()},[Ie]);const Le=t.useCallback(u=>{se.current=u,_(u.active),u.active&&u.direction!==0?ze():Ie()},[ze,Ie]);t.useEffect(()=>{D||fe()},[fe,D]),t.useEffect(()=>{const u=E=>{const Y=E.detail?.paneId;Y&&M&&Y!==M||fe()};return window.addEventListener(ur,u),()=>{window.removeEventListener(ur,u)}},[M,fe]),t.useEffect(()=>{if(!D)return;const u=E=>{if(!se.current.active||se.current.pointerId===E.pointerId)return;const L=E.target;if(!(L instanceof Node)){fe();return}ye.current?.getElement()?.contains(L)||fe()};return document.addEventListener("pointerdown",u,!0),()=>{document.removeEventListener("pointerdown",u,!0)}},[fe,D]);const we=u=>{if(!B||Z<=0||q<=0)return 0;const E=G(u,0,Z);return G(E/Z*q,0,q)},Be=t.useCallback(u=>{const{scrollBarVisible:E,effectiveTrackLength:L,maxScrollPosition:Y}=P.current;if(z.debug("[ScrollBar] calculateScrollPositionFromThumb",()=>({thumbPos:u,trackLen:L,maxScroll:Y})),L<=0||Y<=0)return null;const de=G(u,0,L);return G(de/L*Y,0,Y)},[]),at=t.useCallback(u=>cr(u,m?"x":"y"),[m]),b=t.useCallback(u=>{const E=N.current;if(E.pointerId!==u.pointerId)return;const L=u.clientX-E.startClientX,Y=u.clientY-E.startClientY,de=ut(L,Y)/(E.scale||1);z.debug("[ScrollBar] handleThumbPointerMove",()=>({delta:de,startThumbPosition:E.startThumbPosition,clientY:u.clientY,startClientY:E.startClientY,metrics:P.current}));const Ve=Be(E.startThumbPosition+de);Ve!==null&&W(Ve),u.cancelable&&u.preventDefault()},[ut,Be,W]),w=t.useCallback(u=>{const E=N.current;if(E.pointerId!==u.pointerId)return;document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",w),document.removeEventListener("pointercancel",w);const L=E.captureTarget;if(L?.hasPointerCapture?.(u.pointerId)&&L.releasePointerCapture(u.pointerId),N.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null},be(!1),O.current){const Y=O.current.getBoundingClientRect();u.clientX>=Y.left&&u.clientX<=Y.right&&u.clientY>=Y.top&&u.clientY<=Y.bottom||le(!1)}else le(!1)},[b]);t.useEffect(()=>()=>{document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",w),document.removeEventListener("pointercancel",w)},[b,w]);const ke=t.useRef(0),Fe=t.useRef(0),_e=t.useCallback(u=>{const E=Math.max(Math.round(P.current.viewportSize/Yr),qr);Fe.current!==u&&(Fe.current=u,ke.current=0),Pe(ke,u*E)},[Pe]),{handleArrowPointerDown:Ue,handleArrowPointerUp:Ee,handleArrowKeyDown:gt}=Zr({canUseArrowButtons:ie,enableArrowButtons:l,resetTapScroll:fe,scrollByStep:_e}),wt=u=>{if(!B)return;if(!a){u.preventDefault(),u.stopPropagation();return}if(u.pointerType==="mouse"&&u.button!==0||u.ctrlKey)return;fe();const E=u.currentTarget,L=at(E);let Y=null;if(E.setPointerCapture)try{E.setPointerCapture(u.pointerId),Y=E}catch{Y=null}N.current={pointerId:u.pointerId,startThumbPosition:U,startClientX:u.clientX,startClientY:u.clientY,scale:L,captureTarget:Y},document.addEventListener("pointermove",b),document.addEventListener("pointerup",w),document.addEventListener("pointercancel",w),be(!0),le(!0),u.preventDefault(),u.stopPropagation()},ft=u=>{if(!B)return;if(!o){u.preventDefault(),u.stopPropagation();return}if(u.pointerType==="mouse"&&u.button!==0||u.ctrlKey)return;const E=u.currentTarget,L=E.getBoundingClientRect(),Y=k(u),de=at(E),Ve=(Y-(m?L.left:L.top))/de;fe();const Ne=Ve-d/2,De=we(Ne);if(W(De),E.setPointerCapture)try{E.setPointerCapture(u.pointerId)}catch{}K.current={pointerId:u.pointerId,startThumbPosition:Ne,startClientX:u.clientX,startClientY:u.clientY,scale:de},u.preventDefault(),u.stopPropagation()},ot=()=>{K.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}},St=u=>{const E=K.current;if(E.pointerId!==u.pointerId)return;if(u.pointerType==="mouse"&&u.buttons===0){ot();return}const L=u.clientX-E.startClientX,Y=u.clientY-E.startClientY,de=ut(L,Y)/(E.scale||1),Ve=we(E.startThumbPosition+de);W(Ve),u.cancelable&&u.preventDefault()},kt=u=>{if(K.current.pointerId!==u.pointerId)return;const E=u.currentTarget;E.hasPointerCapture?.(u.pointerId)&&E.releasePointerCapture(u.pointerId),ot(),u.preventDefault(),u.stopPropagation()},Et=u=>{if(K.current.pointerId!==u.pointerId)return;const E=u.currentTarget;E.hasPointerCapture?.(u.pointerId)&&E.releasePointerCapture(u.pointerId),ot()},Rt=u=>{u.target===u.currentTarget&&K.current.pointerId===u.pointerId&&ot()},Te=t.useMemo(()=>G((ne?1:.8)*ee,0,1),[ne,ee]),bt=t.useMemo(()=>{const E=`calc(50% - ${Ze/2}px + ${Ye}px)`;return{left:it,top:E}},[it,Ye,Ze]),Nt=(u,E,L,Y)=>H.jsx("button",{type:"button",tabIndex:0,className:"aqvs-scrollbar-arrow-button",style:{[Me]:x,[F]:x},"aria-label":E,onPointerDown:Ue(u),onPointerUp:Ee,onPointerLeave:Ee,onPointerCancel:Ee,onKeyDown:gt(u),"aria-disabled":!l,disabled:!ie,children:H.jsx("span",{"aria-hidden":"true",children:L})},Y),Vt=V&&B?{orientation:Oe,scrollPosition:n,maxScrollPosition:q,contentSize:r,viewportSize:e,thumbSize:d,thumbPosition:U,thumbCenter:me,trackSize:Ce,isDragging:oe,isTapScrollActive:ne,visibleStartIndex:J,visibleEndIndex:$}:null;return H.jsxs("div",{className:xt.twMerge("aqvs-scrollbar",I,S),style:{[Me]:e,[F]:x},"data-visible":B?"true":"false",role:"scrollbar",tabIndex:-1,"aria-controls":M,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":q,"aria-orientation":m?"horizontal":"vertical",children:[(!m||h)&&B&&D&&H.jsx(Er,{axis:m?"x":"y",ref:ye,className:xt.twMerge("aqvs-scrollbar-tap-circle-wrapper",xe),size:Ze,maxVisualDistance:$e,style:bt,opacity:Te,renderVisual:te,onDragChange:Le},"tap-circle"),Nt(-1,ht[0],yt[0],"arrow-start"),H.jsxs("div",{className:"aqvs-scrollbar-track",style:{borderRadius:x/2},onPointerDown:ft,onPointerMove:St,onPointerUp:kt,onPointerCancel:Et,onLostPointerCapture:Rt,"aria-disabled":!o,children:[Vt&&H.jsx("div",{className:"aqvs-scrollbar-overlay","aria-hidden":!0,children:V?.(Vt)},"overlay"),H.jsx("div",{className:"aqvs-scrollbar-thumb-wrapper",style:{[Me]:d,[We]:U,...m?{top:0,bottom:0}:{left:0,right:0}},"data-visible":B||oe?"true":"false",onPointerDown:wt,role:"slider","aria-orientation":m?"horizontal":"vertical","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":q,"aria-disabled":!a,tabIndex:-1,children:H.jsx("div",{ref:O,className:xt.twMerge("aqvs-scrollbar-thumb",m?"aqvs-scrollbar-thumb-horizontal":"aqvs-scrollbar-thumb-vertical"),"data-testid":"aqvs-scrollbar-thumb","data-thumb-state":ge,style:{borderRadius:x-1,cursor:a?"pointer":"default"},onMouseEnter:()=>{a&&le(!0)},onMouseLeave:()=>{a&&le(!1)}},"thumb")},"thumb-wrapper")]},"track"),Nt(1,ht[1],yt[1],"arrow-end")]})},Jr=16,wr=(r,e,n)=>e===1?r*Jr:e===2?r*n:r,en=(r,e)=>{const n=r.shiftKey&&r.deltaX===0,i=n?r.deltaY:r.deltaX,a=n?0:r.deltaY,o=i!==0&&Math.abs(i)>=Math.abs(a);return{isZoomGesture:r.ctrlKey,isHorizontalDominant:o,horizontalDelta:wr(i,r.deltaMode,e),verticalDelta:wr(a,r.deltaMode,e)}},zr=new WeakSet,Sr=r=>{zr.add(r)},tn=r=>zr.has(r),rn=["mouse","pen","touch"],ar=(r,e)=>!(r==="mouse"||r==="pen"||r==="touch")||e.includes(r),nn=r=>r==="mouse"||r==="pen",Wt={maxVelocity:6,minVelocity:.02,deceleration:.0025,velocitySampleWindow:90,startVelocityThreshold:.04},tr=(r,e,n)=>{for(const[i,a,o]of e)n==="add"?r.addEventListener(i,a,o):r.removeEventListener(i,a,o)},kr=t.forwardRef(({children:r,contentSize:e,viewportSize:n,onViewportSizeChange:i,scrollBarWidth:a=12,enableThumbDrag:o=!0,enableTrackClick:l=!0,enableArrowButtons:m=!0,enablePointerDrag:h=!0,pointerDragInputs:x=rn,onScroll:S,className:M,testId:T,style:v,background:V,tapScrollCircleOptions:J,inertiaOptions:$,itemCount:oe,renderThumbOverlay:be,wheelSpeedMultiplier:ue=1,overscrollBehavior:le="auto",onWheelHorizontal:ne,onPanHorizontal:_,contentInsets:O,visibleStartIndex:N,visibleEndIndex:K,renderOverlay:Q,initialScrollPosition:re=0,contentProps:se},ye)=>{const A=t.useRef(Number.isFinite(re)?Math.max(0,re):0),C=t.useRef(null),j=t.useRef(null),ce=n===void 0,[Xe,qe]=t.useState(0),D=n??Xe,Ze=t.useRef(null);t.useLayoutEffect(()=>{if(!ce)return;const d=j.current;if(!d)return;const q=()=>{const U=d.offsetHeight;if(U>0){qe(me=>me===U?me:U);return}d.offsetParent!==null&&e>0&&Ze.current!=="zero"&&(Ze.current="zero",z.warn("[ScrollPane] The self-measured viewport is 0px. Give the scroll pane's host element a definite height (e.g. h-full, flex-1 + min-h-0, an explicit px height), or pass viewportSize explicitly."))};if(q(),typeof ResizeObserver!="function")return;const Z=new ResizeObserver(q);return Z.observe(d),()=>{Z.disconnect()}},[e,ce]),t.useLayoutEffect(()=>{ce&&i?.(Xe)},[ce,Xe,i]),t.useLayoutEffect(()=>{if(ce)return;const d=C.current;if(!d)return;const q=()=>{const U=d.clientHeight;if(U<=0||Math.abs(U-D)<=1)return;const me=`${D}/${U}`;Ze.current!==me&&(Ze.current=me,z.warn(`[ScrollPane] viewportSize=${D} but the host band is ${U}px. The clip window, max scroll position, thumb mapping, rendered row count and scrollability all derive from viewportSize, so they are now wrong. Omit viewportSize to let the pane measure itself.`))};if(q(),typeof ResizeObserver!="function")return;const Z=new ResizeObserver(q);return Z.observe(d),()=>{Z.disconnect()}},[ce,D]);const it=t.useRef(ne);t.useEffect(()=>{it.current=ne},[ne]);const Ye=t.useRef(_);t.useEffect(()=>{Ye.current=_},[_]);const xe=t.useRef({frame:null,velocity:0,lastTimestamp:null,generation:0}),ve=t.useMemo(()=>({maxVelocity:$?.maxVelocity??Wt.maxVelocity,minVelocity:$?.minVelocity??Wt.minVelocity,deceleration:$?.deceleration??Wt.deceleration,velocitySampleWindow:$?.velocitySampleWindow??Wt.velocitySampleWindow,startVelocityThreshold:$?.startVelocityThreshold??Wt.startVelocityThreshold}),[$]),Re=t.useMemo(()=>({top:Math.max(0,O?.top??0),bottom:Math.max(0,O?.bottom??0)}),[O]);z.debug("[ScrollPane] ScrollPane rendered",()=>({contentSize:e,viewportSize:D,scrollBarWidth:a,className:M,style:v,tapScrollCircleOptions:J,inertiaOptions:$,enablePointerDrag:h,contentInsets:Re}));const Qe=t.useRef({contentSize:e,viewportSize:D}),ee=t.useMemo(()=>e>D,[e,D]),te=t.useCallback((d,q)=>{let Z=q??Qe.current;q&&!(Number.isFinite(q.contentSize)&&Number.isFinite(q.viewportSize))&&(z.warn("[ScrollPane] scrollTo received non-finite dimsOverride; falling back to the committed dims",{dimsOverride:q}),Z=Qe.current);const{contentSize:U,viewportSize:me}=Z,B=U>me,ie=A.current;if(z.debug("[ScrollPane] scrollTo called",()=>({newPosition:d,contentSize:U,viewportSize:me,currentIsScrollable:B,prevPosition:ie})),!B)return A.current!==0&&(A.current=0,S?.(0,ie)),A.current;const ge=typeof d=="function"?d(A.current):d;if(!Number.isFinite(ge))return z.warn("[ScrollPane] scrollTo received a non-finite position; keeping the current position",{nextPosition:ge}),A.current;const W=Math.max(U-me,0),he=G(ge,0,W);return A.current!==he&&(A.current=he,S?.(he,ie)),A.current},[S]),mt=t.useRef(te);t.useEffect(()=>{mt.current=te},[te]);const P=t.useCallback(()=>{const d=xe.current;d.generation+=1,d.frame!==null&&cancelAnimationFrame(d.frame),d.frame=null,d.velocity=0,d.lastTimestamp=null},[]),Me=t.useRef(P);t.useEffect(()=>{Me.current=P},[P]),t.useEffect(()=>()=>{Me.current()},[]);const F=t.useCallback(d=>{if(!ee)return;const{maxVelocity:q,minVelocity:Z,deceleration:U,startVelocityThreshold:me}=ve,B=G(d,-q,q);if(Math.abs(B)<me)return;P(),xe.current.velocity=B,xe.current.lastTimestamp=null;const ie=xe.current.generation,ge=W=>{const he=xe.current;if(he.generation!==ie)return;if(he.lastTimestamp===null){he.lastTimestamp=W,he.frame=requestAnimationFrame(ge);return}const Pe=W-he.lastTimestamp;if(he.lastTimestamp=W,Pe<=0){he.frame=requestAnimationFrame(ge);return}const Ie=he.velocity;let fe=Ie;const je=U*Pe;Ie>0?fe=Math.max(0,Ie-je):Ie<0&&(fe=Math.min(0,Ie+je));const Le=(Ie+fe)/2*Pe,we=A.current;if(Le!==0&&mt.current(Fe=>Fe+Le),xe.current.generation!==ie)return;const Be=A.current,{contentSize:at,viewportSize:b}=Qe.current,w=Math.max(at-b,0);he.velocity=fe;const ke=Be===we||Be<=0&&fe<=0||Be>=w&&fe>=0;if(Math.abs(fe)<Z||ke){P();return}he.frame=requestAnimationFrame(ge)};xe.current.frame=requestAnimationFrame(ge)},[ee,ve,P]),We=t.useRef(F);t.useEffect(()=>{We.current=F},[F]),t.useLayoutEffect(()=>{Qe.current={contentSize:e,viewportSize:D}},[e,D]),t.useLayoutEffect(()=>{const d=j.current;if(!d)return;const q=()=>{d.scrollTop!==0&&(z.debug("[ScrollPane] Native scroll detected, resetting to 0",()=>({scrollTop:d.scrollTop})),d.scrollTop=0),d.scrollLeft!==0&&(d.scrollLeft=0)};return d.addEventListener("scroll",q),()=>d.removeEventListener("scroll",q)},[]),t.useLayoutEffect(()=>{if(ee){z.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change",()=>({contentSize:e,viewportSize:D,scrollPosition:A.current}));const d=G(e-D,0,e);A.current>d&&te(d)}else te(0)},[ee,te,e,D]);const ut=t.useRef({isScrollable:ee,viewportSize:D,wheelSpeedMultiplier:ue,overscrollBehavior:le});t.useLayoutEffect(()=>{ut.current={isScrollable:ee,viewportSize:D,wheelSpeedMultiplier:ue,overscrollBehavior:le}},[ee,D,ue,le]);const k=t.useCallback(d=>{if(tn(d))return!1;const{isScrollable:q,viewportSize:Z,wheelSpeedMultiplier:U,overscrollBehavior:me}=ut.current,B=en(d,Z);if(B.isZoomGesture)return!1;if(B.isHorizontalDominant)return it.current?(Sr(d),d.preventDefault(),P(),it.current(B.horizontalDelta),!0):!1;if(!q||B.verticalDelta===0)return!1;let ie=B.verticalDelta;if(U!==1&&(ie*=U),me!=="contain"){const ge=A.current,W=Math.max(Qe.current.contentSize-Z,0);if(ie>0&&ge>=W||ie<0&&ge<=0)return!1}return Sr(d),d.preventDefault(),P(),z.debug("[ScrollPane] wheel event",()=>({deltaY:ie,scrollPosition:A.current,wheelSpeedMultiplier:U,deltaMode:d.deltaMode,scrollTop:j.current?.scrollTop})),te(ge=>ge+ie),!0},[te,P]);t.useEffect(()=>{const d=U=>{k(U)},q=()=>{P()},Z=C.current;return Z&&(Z.addEventListener("wheel",d,{passive:!1}),Z.addEventListener("pointerdown",q,{capture:!0,passive:!0})),()=>{Z&&(Z.removeEventListener("wheel",d),Z.removeEventListener("pointerdown",q,{capture:!0}))}},[k,P]),t.useImperativeHandle(ye,()=>({scrollTo:(d,q)=>(P(),te(d,q)),getScrollPosition:()=>A.current,getContentSize:()=>e,getViewportSize:()=>D,applyWheel:k}),[te,e,D,P,k]);const ht=t.useId(),yt=se?.id??ht,I=t.useRef({pointerType:"",pointerId:null,startClientY:0,startClientX:0,lastPanClientX:0,startScroll:0,isDragging:!1,shouldCancelNextClick:!1,clickResetTimer:null,velocitySamples:[],scale:1,scaleX:1}),Oe=t.useRef(h),$e=t.useRef(x);t.useEffect(()=>{Oe.current=h},[h]),t.useEffect(()=>{$e.current=x},[x]);const pt=t.useRef(ee);t.useEffect(()=>{pt.current=ee},[ee]);const Ce=t.useRef(ve);t.useEffect(()=>{Ce.current=ve},[ve]),t.useEffect(()=>{const d=I.current;if(h&&ee&&(d.pointerId===null||ar(d.pointerType,x))||d.pointerId===null)return;const q=j.current;d.clickResetTimer!==null&&(window.clearTimeout(d.clickResetTimer),d.clickResetTimer=null);const Z=d.isDragging&&d.shouldCancelNextClick,U=d.pointerId;d.pointerId=null,d.pointerType="",d.startClientY=0,d.startScroll=0,d.isDragging=!1,d.shouldCancelNextClick=Z,d.velocitySamples=[],d.scale=1,q?.hasPointerCapture(U)&&q.releasePointerCapture(U)},[h,x,ee]),t.useEffect(()=>{const d=j.current;if(!d)return;const q=6,Z=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),U=()=>{const b=I.current;b.pointerId=null,b.pointerType="",b.startClientY=0,b.startScroll=0,b.isDragging=!1,b.velocitySamples=[],b.scale=1},me=()=>{const b=I.current;b.clickResetTimer!==null&&(window.clearTimeout(b.clickResetTimer),b.clickResetTimer=null)},B=b=>{const w=I.current,ke=Z();w.velocitySamples.push({clientY:b,time:ke});const Fe=Ce.current.velocitySampleWindow;w.velocitySamples=w.velocitySamples.filter(_e=>ke-_e.time<=Fe)},ie=b=>b instanceof HTMLElement&&b.closest("[data-scrollpane-ignore-drag='true']")!==null,ge=b=>{const w=I.current;w.shouldCancelNextClick&&(b.preventDefault(),b.stopPropagation(),w.shouldCancelNextClick=!1)},W=b=>{const w=I.current;if(!w.isDragging){if(w.isDragging=!0,w.shouldCancelNextClick=!0,!d.hasPointerCapture(b.pointerId))try{d.setPointerCapture(b.pointerId)}catch{}B(b.clientY)}},he=b=>b.isTrusted||b.target===d,Pe=b=>{const w=I.current;d.hasPointerCapture(b)&&d.releasePointerCapture(b),w.shouldCancelNextClick=!1,me(),U()},Ie=b=>{const w=I.current;if(w.pointerId!==b.pointerId)return;if(b.buttons===0&&nn(b.pointerType)){Pe(b.pointerId);return}if(!(Oe.current&&pt.current)||!ar(b.pointerType,$e.current))return;if(!w.isDragging){const Ue=Math.abs(b.clientY-w.startClientY),Ee=Ye.current?Math.abs(b.clientX-w.startClientX):0;if(Math.max(Ue,Ee)<q||(W(b),!w.isDragging))return}B(b.clientY);const ke=(b.clientY-w.startClientY)/(w.scale||1),Fe=w.startScroll-ke;mt.current(Fe);const _e=Ye.current;if(_e){const Ue=b.clientX-w.lastPanClientX;w.lastPanClientX=b.clientX,Ue!==0&&_e(-Ue/(w.scaleX||1))}b.cancelable&&b.preventDefault()},fe=()=>{const b=I.current;return b.pointerId!==null||!b.shouldCancelNextClick?!1:(me(),b.clickResetTimer=window.setTimeout(()=>{const w=I.current;w.shouldCancelNextClick=!1,w.clickResetTimer=null},0),!0)},je=b=>{const w=I.current;if(w.pointerId!==b.pointerId){fe();return}w.isDragging&&w.shouldCancelNextClick&&b.cancelable&&(b.preventDefault(),b.stopPropagation()),w.isDragging&&B(b.clientY);let ke=0;if(w.isDragging&&w.velocitySamples.length>=2){const _e=w.velocitySamples,Ue=Ce.current.velocitySampleWindow,Ee=_e[_e.length-1],gt=_e.find(wt=>Ee.time-wt.time<=Ue)??_e[0];if(Ee&&gt&&Ee.time!==gt.time){const wt=Ee.clientY-gt.clientY,ft=Ee.time-gt.time;ke=-(wt/ft)/(w.scale||1)}}me(),w.shouldCancelNextClick&&(w.clickResetTimer=window.setTimeout(()=>{const _e=I.current;_e.shouldCancelNextClick=!1,_e.clickResetTimer=null},0));const Fe=Ce.current.startVelocityThreshold;U(),d.hasPointerCapture(b.pointerId)&&d.releasePointerCapture(b.pointerId),Math.abs(ke)>=Fe&&We.current?.(ke)},ze=b=>{if(I.current.pointerId!==null){if(!b.isPrimary||b.pointerType!==I.current.pointerType)return;Pe(I.current.pointerId)}if(I.current.shouldCancelNextClick&&(me(),I.current.shouldCancelNextClick=!1),!(Oe.current&&pt.current)||!ar(b.pointerType,$e.current)||b.button!==0&&b.pointerType==="mouse"||b.ctrlKey||b.metaKey||b.altKey||ie(b.target))return;window.dispatchEvent(new CustomEvent(ur,{detail:{paneId:ht}})),Me.current?.();const w=I.current;me(),w.pointerId=b.pointerId,w.pointerType=b.pointerType,w.startClientY=b.clientY,w.startClientX=b.clientX,w.lastPanClientX=b.clientX,w.startScroll=A.current,w.scale=cr(d,"y"),w.scaleX=Ye.current?cr(d,"x"):1,w.isDragging=!1,w.shouldCancelNextClick=!1,w.velocitySamples=[]},Le=b=>{if(I.current.pointerId!==b.pointerId){fe();return}he(b)&&Pe(b.pointerId)},Be=[["click",ge,!0],["pointerdown",ze,{passive:!1}],["lostpointercapture",b=>{b.target!==d||I.current.pointerId!==b.pointerId||Pe(b.pointerId)},void 0]],at=[["pointermove",Ie,{passive:!1}],["pointerup",je,void 0],["pointercancel",Le,void 0]];return tr(d,Be,"add"),tr(window,at,"add"),()=>{tr(d,Be,"remove"),tr(window,at,"remove");const b=I.current;b.pointerId!==null&&d.hasPointerCapture(b.pointerId)&&d.releasePointerCapture(b.pointerId),me(),U()}},[ht]);const vt=t.useCallback(d=>(P(),te(d)),[te,P]);return H.jsxs("div",{ref:C,"data-testid":T,"data-self-measured":ce?"true":void 0,className:xt.twMerge("aqvs-scroll-pane",M),style:v,children:[H.jsxs("div",{ref:j,className:xt.twMerge("aqvs-scroll-pane-content"),"data-testid":"aqvs-scroll-pane-content",style:{height:ce?void 0:D,paddingTop:Re.top,paddingBottom:Re.bottom,...h&&ee&&x.some(d=>d==="touch"||d==="pen")?{touchAction:"none"}:{}},...se,id:yt,children:[V,r(A.current)]}),H.jsx(pr,{contentSize:e,viewportSize:D,scrollPosition:A.current,onScroll:vt,enableThumbDrag:o,enableTrackClick:l,enableArrowButtons:m,scrollBarWidth:a,ariaControls:yt,tapScrollCircleOptions:J,itemCount:oe,renderThumbOverlay:be,visibleStartIndex:N,visibleEndIndex:K},"scrollbar"),Q?.()]})}),Rr=(r,e,n)=>Math.min(Math.max(r,e),n),sn=({dragState:r,normalizedDistance:e,sizeScale:n,size:i})=>{const a=Math.max(i/2,1),o=1+e*.65,l=Math.max(.65,1-e*.25),m=r.direction*e*26*n,h=.8+e*.18,x=3*n,S=6*n,M=22*n,T=Math.abs(m)+S,v=m>0?x:-Math.abs(m)-x,V=Math.max(2.5,3*n),J=Rr(r.offsetX,-a,a),$=Rr(r.offsetY,-a,a),oe=a*.35,be=J/a*oe,ue=$/a*oe,le=be*.45,ne=ue*.45,_=Math.max(M*.38,6),O=.65+e*.2,N=r.active;return H.jsxs(H.Fragment,{children:[H.jsx("div",{className:"aqvs-tap-scroll-circle-gradient",style:{transform:`scale(${l}, ${o})`,transition:N?"40ms transform ease-out":"200ms ease transform"}}),H.jsx("div",{className:"aqvs-sample-visual-pupil",style:{width:M,height:M,transform:`translate(calc(-50% + ${be}px), calc(-50% + ${ue}px)) scale(${l}, ${h*o})`,transition:N?"70ms transform ease-out":"200ms ease transform"}}),H.jsx("div",{className:"aqvs-sample-visual-highlight",style:{width:_,height:_,transform:`translate(calc(-50% + ${le}px), calc(-50% + ${ne}px)) scale(${l}, ${o})`,opacity:O,boxShadow:"0 0 8px rgba(255,255,255,0.45)",transition:N?"120ms opacity 150ms, 120ms transform ease-out ease-out":"220ms ease transform, 240ms opacity ease"}}),H.jsx("div",{className:"aqvs-sample-visual-rod",style:{width:V,height:T,transform:`translate(-50%, ${v}px)`,opacity:e,transition:N?"40ms height, 60ms opacity ease-out ease-out":"200ms ease height, 120ms ease opacity"}})]})},Ot=100,an=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},or=(r,e)=>{if(!Number.isFinite(r))throw new Error(`valueFn returned a non-finite value at index ${e}: ${r}`);return r},Ft=r=>{if(r<=0||!Number.isFinite(r))return 0;const e=Math.trunc(r);if(e<=2147483647)return e&-e;const n=BigInt(e)&-BigInt(e);return Number(n)};class Tt{tree;deltas;size;baseValue;valueFn;total;constructor(e,n,i){this.reset(e,n,i)}reset(e,n,i){const a=Number.isFinite(e)&&e>0?Math.trunc(e):0;if(typeof n!="function"){this.size=a,this.tree=new Map,this.deltas=new Map,this.valueFn=void 0,this.baseValue=n,this.total=this.baseValue*this.size;return}let o=0,l;const m=i?.baseValue;if(m!==void 0&&!(Number.isFinite(m)&&m>=0))throw new RangeError(`[FenwickMapTree] options.baseValue must be a finite number >= 0, received ${m}.`);if(a>0&&m!==void 0){if(o=m,i?.materialize){const h=i?.sampleRange??{from:0,to:Math.min(Ot-1,a-1)};let x=Math.max(0,Math.trunc(h.from)),S=Math.min(Math.trunc(h.to),a-1);x>S&&(x=0,S=Math.min(Ot-1,a-1)),l={from:x,values:Tt._collectValidatedValues(n,x,S)}}}else if(a>0){const h=i?.sampleRange??{from:0,to:Math.min(Ot-1,a-1)};let x=Math.max(0,Math.trunc(h.from)),S=Math.min(Math.trunc(h.to),a-1);if(x>S&&(x=0,S=Math.min(Ot-1,a-1)),a>Ot)o=Tt._sampleBaseValueStrided(n,a,Ot),i?.materialize&&(l={from:x,values:Tt._collectValidatedValues(n,x,S)});else{const M=Tt._collectValidatedValues(n,x,S);o=Tt._modeOrMedian([...M]),i?.materialize&&(l={from:x,values:M})}}if(this.size=a,this.tree=new Map,this.deltas=new Map,this.total=void 0,this.valueFn=n,this.baseValue=o,l)for(let h=0;h<l.values.length;h++){const x=l.from+h;if(x>=this.size)break;const S=l.values[h]-this.baseValue;S!==0&&(this.deltas.set(x,S),this._updateTree(x,S))}this.total=this.getTotal()}setValueFn(e,n){if(n?.reset){this.reset(this.size,e);return}typeof e=="function"?this.valueFn=e:(this.valueFn=void 0,this.baseValue=e,this.total=this._computeTreeTotal())}static _collectValidatedValues(e,n,i){const a=[];for(let o=n;o<=i;o++)a.push(or(e(o),o));return a}static _modeOrMedian(e){if(e.length===0)return 0;e.sort((l,m)=>l-m);const n=Math.floor(e.length/2);let i;e.length%2===0?i=Math.floor((e[n-1]+e[n])/2):i=e[n];const a=new Map;let o=0;for(const l of e){const m=(a.get(l)??0)+1;a.set(l,m),m>o&&(o=m)}if(o>e.length*.2){const l=[];for(const[h,x]of a.entries())x===o&&l.push(h);const m=l.reduce((h,x)=>h+x,0);i=Math.floor(m/l.length)}return i}static _sampleBaseValueStrided(e,n,i){if(n<=0)return 0;let a=Math.max(1,Math.ceil(n/i));a%2===0&&(a+=1);const o=[];for(let l=0;l<n&&o.length<i;l+=a)o.push(or(e(l),l));return Tt._modeOrMedian(o)}update(e,n){return this.updates([{index:e,value:n}])}updates(e){const n=this._buildDeltaUpdates(e);return n.length>0?this.updateDeltas(n):this.total}updateDelta(e,n){return this.updateDeltas([{index:e,change:n}])}updateDeltas(e){const n=new Map;for(const{index:i,change:a}of e){if(i<0||i>=this.size)throw new Error(`Index ${i} out of bounds`);if(!Number.isInteger(i))throw new Error(`Index must be an integer: ${i}`);if(!Number.isFinite(a))throw new Error(`Change must be a finite number: ${a}`);const l=(n.get(i)??this.deltas.get(i)??0)+a;if(l+this.baseValue<-1e-9)throw new Error(`Change would make the value at index ${i} negative: ${l+this.baseValue}`);n.set(i,l)}for(const{index:i,change:a}of e){const l=(this.deltas.get(i)??0)+a;l===0?this.deltas.delete(i):this.deltas.set(i,l),this._updateTree(i,a)}return this.total}_updateTree(e,n){if(n===0)return;let i=e+1;for(;i<=this.size;){this.tree.set(i,(this.tree.get(i)??0)+n);const a=Ft(i);if(a===0)break;i+=a}this.total!==void 0&&(this.total+=n)}_buildDeltaUpdates(e){const n=[],i=new Map;for(const{index:a,value:o}of e){if(a<0||a>=this.size)throw new Error(`Index ${a} out of bounds`);if(!Number.isInteger(a))throw new Error(`Index must be an integer: ${a}`);if(!Number.isFinite(o))throw new Error(`Value must be a finite number: ${o}`);if(o<0)throw new Error("Value cannot be negative.");const l=i.has(a)?i.get(a)??0:this.deltas.get(a)??0,m=l+this.baseValue,h=o-m;h!==0&&n.push({index:a,change:h}),i.set(a,l+h)}return n}_computeTreeTotal(){if(this.size<=0)return 0;let e=0,n=this.size;for(;n>0;){e+=this.tree.get(n)??0;const i=Ft(n);if(i===0)break;n-=i}return e+this.baseValue*this.size}_materialize(e,n=!0){if(this.valueFn){const i=this.deltas.get(e)??0,o=or(this.valueFn(e),e)-this.baseValue;if(o!==i&&(o===0?this.deltas.delete(e):this.deltas.set(e,o),n)){const l=o-i;this._updateTree(e,l)}}}_materializeRanges(e,n,i=!1){if(!(e?.materialize&&this.valueFn))return;const a=e.ranges;if(a&&a.length>0){for(const m of a){const h=Math.max(0,Math.trunc(m.from)),x=Math.min(Math.trunc(m.to),this.size-1);for(let S=h;S<=x;S++)this._materialize(S)}if(n===void 0)return;if(i){this._materialize(n);return}const o=a[0].from,l=a[a.length-1].to;n>=o&&n<=l&&this._materialize(n);return}n!==void 0&&this._materialize(n)}_findIndex(e,n={},i){if(this.size>=1073741824)return this._findIndexLarge(e,n,i);if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};this._materializeRanges(n.materializeOption);const a=n.materializeOption?.materialize===!0;let o;for(;;){if(o=this._descend(e,i),o<0||o>=this.size)return{index:-1,total:this.total??this.getTotal(),cumulative:void 0,currentValue:void 0,safeIndex:void 0};if(!a)break;const m=this.deltas.get(o)??0;if(this._materialize(o),(this.deltas.get(o)??0)===m)break}const l=this.prefixSum(o);return{index:o,total:this.total??l.total,cumulative:l.cumulative,currentValue:l.currentValue,safeIndex:l.safeIndex}}_descend(e,n){let i=0,a=0,o=1;for(;o<<1<=this.size;)o<<=1;for(;o>0;o>>=1){const l=i+o;if(l<=this.size){const h=(this.tree.get(l)??0)+this.baseValue*o;(n?a+h<e:a+h<=e)&&(i=l,a+=h)}}return n?i:i-1}_findIndexLarge(e,n,i){if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};const a=an(this.size);if(a===0n)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};this._materializeRanges(n.materializeOption);const o=n.materializeOption?.materialize===!0;for(;;){let l=0n,m=a-1n,h,x,S=this.total;for(;l<=m;){const v=l+m>>1n,V=Number(v),J=this.prefixSum(V);if(S=J.total,i?J.cumulative>=e:J.cumulative<=e)if(h=v,x=J,i){if(v===0n)break;m=v-1n}else l=v+1n;else if(i)l=v+1n;else{if(v===0n)break;m=v-1n}}const M=x,T=h!==void 0?Number(h):-1;if(o&&T>=0){const v=this.deltas.get(T)??0;if(this._materialize(T),(this.deltas.get(T)??0)!==v)continue}return{index:T,total:S,cumulative:M?.cumulative,currentValue:M?.currentValue,safeIndex:M?.safeIndex}}}prefixSum(e,n){if(e<0||Number.isNaN(e))return{cumulative:0,total:this.total,currentValue:0,safeIndex:0};if(this.size===0)return{cumulative:0,total:this.total??0,currentValue:0,safeIndex:0};const i=G(Math.trunc(e),0,this.size-1),a=n?.materializeOption;this._materializeRanges(a,i,!0);let o=0,l=i+1;for(;l>0;){const h=this.tree.get(l)??0;o+=h;const x=Ft(l);if(x===0)break;l-=x}const m=a?.materialize?this.get(i):(this.deltas.get(i)||0)+this.baseValue;return{cumulative:o+this.baseValue*(i+1),total:this.total,currentValue:m,safeIndex:i}}get(e,n){if(this.size===0)return 0;if(!Number.isInteger(e)||e<0||e>=this.size)throw new Error("Index out of bounds");const i=n?.materializeOption;return this._materializeRanges(i,e),(this.deltas.get(e)??0)+this.baseValue}getTotal(e){const n=e?.materializeOption;if(this._materializeRanges(n),this.total===void 0)if(this.size===0)this.total=0;else{this.total=this._computeTreeTotal();const i=this.prefixSum(this.getSize()-1);i.cumulative!==i.total&&z.error("Inconsistent Fenwick Tree state")}return this.total}rebuildTree(e){if(e?.materialize&&this.valueFn){const i=this.valueFn;this.reset(this.size,a=>i(a),{materialize:!0});return}const n=new Map;for(const[i,a]of this.deltas.entries()){if(a===0)continue;let o=i+1;for(;o<=this.size;){n.set(o,(n.get(o)??0)+a);const l=Ft(o);if(l===0)break;o+=l}}this.tree=n,this.total=this._computeTreeTotal()}calculateAccumulatedError(){if(this.total===void 0)return 0;let e=this.baseValue*this.size;for(const[n,i]of this.deltas)n<this.size&&(e+=i);return this.total-e}changeSize(e){if(!Number.isFinite(e))throw new Error(`Size must be a finite number: ${e}`);const n=Math.max(0,Math.trunc(e)),i=this.size;if(n===i)return;if(n>i)if(i===0&&this.deltas.size>0){for(const o of this.deltas.keys())o>=n&&this.deltas.delete(o);this.size=n,this.rebuildTree()}else this._growSize(i,n);else{if(n>0)for(const o of this.deltas.keys())o>=n&&this.deltas.delete(o);this.size=n,this.rebuildTree()}const a=this.prefixSum(this.getSize()-1);a.cumulative!==a.total&&z.error("Inconsistent Fenwick Tree state")}static _minCoveredLowBound(e,n){let i=1;for(;;){const a=i*2;if(Math.floor(n/a)*a<=e)break;i=a}return i*Math.floor(e/i)}_propagateDeltaToGrownNodes(e,n,i,a){let o=e+1;for(;o<=i;){const l=Ft(o);if(l===0)break;o+=l}for(;o<=a;){this.tree.set(o,(this.tree.get(o)??0)+n);const l=Ft(o);if(l===0)break;o+=l}}_growSize(e,n){if(this.size=n,this.deltas.size>0){const i=Tt._minCoveredLowBound(e,n);if(e-i<this.deltas.size)for(let o=i;o<e;o++){const l=this.deltas.get(o);l===void 0||l===0||this._propagateDeltaToGrownNodes(o,l,e,n)}else for(const[o,l]of this.deltas.entries())l===0||o<i||this._propagateDeltaToGrownNodes(o,l,e,n)}this.total=this._computeTreeTotal()}getSize(){return this.size}get base(){return this.baseValue}findIndexAtOrAfter(e,n){return this._findIndex(e,n??{},!0)}findIndexAtOrBefore(e,n){return this._findIndex(e,n??{},!1)}}const on=(r,e)=>{const n=r?.sampleRange,i=e?.sampleRange;return n===i?!1:n&&i?n.from!==i.from||n.to!==i.to:!0},gr=(r,e,n)=>{const i=Number.isFinite(r)&&r>0?Math.trunc(r):0,a=t.useRef(null),o=t.useRef({size:i,valueOrFn:e,options:n});a.current===null&&(a.current=new Tt(i,e,n));const l=a.current,m=o.current,h=m.size!==i,x=m.valueOrFn!==e,S=on(m.options,n)||m.options?.baseValue!==n?.baseValue,M=m.size===0&&i>0&&(!a.current||a.current.base===0);if(x||S){const T=n?.resetOnValueFnChange??!0;S||x&&T||M?(n?.debug&&z.debug("[useFenwickMapTree] reset",{valueOrFnChanged:x,optionsChanged:S}),l.reset(i,e,n)):(h&&(n?.debug&&z.debug("[useFenwickMapTree] resize (with valueFn change)",{from:m.size,to:i}),l.changeSize(i)),n?.debug&&z.debug("[useFenwickMapTree] setValueFn (no reset)",{valueOrFnChanged:x}),l.setValueFn(e,{reset:!1})),o.current={size:i,valueOrFn:e,options:n}}else h&&(n?.debug&&z.debug("[useFenwickMapTree] resize",{from:m.size,to:i}),M?l.reset(i,e,n):l.changeSize(i),o.current={size:i,valueOrFn:e,options:n});return l};class ln{key;value;prev=null;next=null;constructor(e,n){this.key=e,this.value=n}}class lr{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 Nr(r){const e=t.useRef(new Map),n=t.useRef(new lr),i=Math.floor(r),a=t.useRef(i);t.useEffect(()=>{if(a.current=i,Number.isNaN(i)||i<0){z.warn(`useLruCache: invalid capacity ${r}; the cache will not store any entries.`),e.current.clear(),n.current=new lr;return}if(Number.isFinite(i))for(;e.current.size>i;){const S=n.current.removeHead();if(S)e.current.delete(S.key);else break}},[r,i]);const o=t.useCallback(S=>{const M=e.current.get(S);if(M)return n.current.moveToTail(M),M.value},[]),l=t.useCallback((S,M)=>{const T=a.current;if(Number.isNaN(T)||T<=0)return;let v=e.current.get(S);if(v)v.value=M,n.current.moveToTail(v);else{if(e.current.size>=T){const V=n.current.removeHead();V&&e.current.delete(V.key)}v=new ln(S,M),e.current.set(S,v),n.current.addToTail(v)}},[]),m=t.useCallback(S=>e.current.has(S),[]),h=t.useCallback(S=>{const M=e.current.get(S);M&&(n.current.remove(M),e.current.delete(S))},[]),x=t.useCallback(()=>{e.current.clear(),n.current=new lr},[]);return t.useMemo(()=>({get:o,set:l,has:m,remove:h,clear:x}),[o,l,m,h,x])}const cn=1e4,un=()=>{const{get:r,set:e,has:n,clear:i}=Nr(cn);return t.useMemo(()=>({get:r,set:e,has:n,clear:i}),[r,e,n,i])},fn=(r,e)=>{const n=t.useRef(e),i=t.useRef(r);t.useLayoutEffect(()=>{n.current=e,i.current=r},[e,r]);const a=t.useRef(new WeakMap);return t.useCallback(o=>{if(!o||a.current.has(o))return;const l=m=>{n.current?.enableBridge!==!1&&i.current.current?.applyWheel(m)};return o.addEventListener("wheel",l,{passive:!1}),a.current.set(o,l),()=>{a.current.get(o)===l&&(o.removeEventListener("wheel",l),a.current.delete(o))}},[])},Ae=(r,e)=>e<=0?0:G(r,0,e-1),Mr=r=>({top:Math.max(0,r?.top??0),bottom:Math.max(0,r?.bottom??0)}),st=(r,e)=>r<=e?0:r-e,Lt=(r,e)=>r<=0?0:r+e,jt=1e3,fr=2e3,Vr=1048576,dn=40,$t=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},mn=(r,e,n,i,a,o,l,m)=>{const h=$t(i);if(h===0n)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const x=_=>_<0n?0n:_>=h?h-1n:_,S={materializeOption:{materialize:!1}},{index:M,cumulative:T}=o.findIndexAtOrAfter(r,S);let v;M===-1?v=h-1n:(T===r?v=$t(M+1):v=$t(M),v>=h&&(v=h-1n)),r<=0&&(v=0n),m&&r>=l&&(v=h-1n);const V=_=>{const O=Number(_);if(!Number.isSafeInteger(O))return null;const{cumulative:N}=o.prefixSum(O,{materializeOption:{materialize:!1}});if(!Number.isFinite(N))return null;const{index:K}=o.findIndexAtOrAfter(N+.5,{materializeOption:{materialize:!1}});if(K===-1)return null;const Q=$t(K);return Q>_?Q:null},J=_=>{let O=0,N=_,K=_,Q=0n,re=0;for(;N<h&&O<e;){const se=Number(N),ye=a(se);if(O+=ye,K=N,N+=1n,Q+=1n,!Number.isFinite(ye)||ye<0)break;if(ye===0){if(re+=1,re>jt){const A=V(K);if(A!==null&&A>N)N=A,re=0;else if(A!==null&&A===N&&a(Number(N))>0)re=0;else break}}else re=0}return Q===0n&&(K=_),{height:O,end:K}};let{height:$,end:oe}=J(v);if($<e&&v>0n){let _=v,O=$,N=0;for(;_>0n&&O<e;){_-=1n;const Q=Number(_),re=a(Q);if(O+=re,!Number.isFinite(re)||re<0)break;if(re===0){if(N+=1,N>jt){const se=Number(_);if(!Number.isSafeInteger(se))break;const{cumulative:ye}=o.prefixSum(se,{materializeOption:{materialize:!1}});if(!Number.isFinite(ye))break;const{index:A}=o.findIndexAtOrAfter(ye-.5,{materializeOption:{materialize:!1}}),C=A===-1?-1n:$t(A);if(C>=0n&&C<_)_=C+1n,N=0;else if(C===_&&_>=1n&&a(Number(_-1n))>0)N=0;else break}}else N=0}v=x(_);const K=J(v);$=K.height,oe=K.end}const be=x(v),ue=x(oe),le=x(be-BigInt(Math.max(0,n))),ne=x(ue+BigInt(Math.max(0,n)));return{renderingStartIndex:Ae(Number(le),i),renderingEndIndex:Ae(Number(ne),i),visibleStartIndex:Ae(Number(be),i),visibleEndIndex:Ae(Number(ue),i)}},Ar=(r,e,n,i,a,o,l)=>{if(i===0)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const m=Number.isFinite(l),h=m?Math.min(Math.max(0,r),l):Math.max(0,r);if(i>=Number.MAX_SAFE_INTEGER)return mn(h,e,n,i,a,o,l,m);const{index:x,cumulative:S,currentValue:M}=o.findIndexAtOrAfter(h,{materializeOption:{materialize:!1}}),T=x===-1?e<=0||(S??0)<h+(M??0)?i-1:0:x;let v=Ae(T,i),V=0;if(x!==-1&&S===h)v=Ae(x+1,i),V=0;else if(v===x&&S!==void 0&&M!==void 0)V=S-M-h;else{const{cumulative:_,currentValue:O}=o.prefixSum(v,{materializeOption:{materialize:!1}});V=(_??0)-(O??0)-h}const J=V,$=(_,O)=>{let N=_,K=O,Q=0;for(;N<i&&K<e;){const re=a(N);if(K+=re,N++,!Number.isFinite(re)||re<0)break;if(re===0){if(Q++,Q>jt){const{cumulative:se}=o.prefixSum(N-1,{materializeOption:{materialize:!1}}),{index:ye}=Number.isFinite(se)?o.findIndexAtOrAfter(se+.5,{materializeOption:{materialize:!1}}):{index:-1};if(ye>N)N=ye,Q=0;else if(ye===N&&a(N)>0)Q=0;else break}}else Q=0}return{cursor:N,height:K}},oe=$(v,V);let be=oe.cursor;if(V=oe.height,V<e&&v>0){let _=V+Math.abs(Math.min(0,J)),O=v-1,N=0;for(;O>=0&&_<e;){const Q=a(O);if(_+=Q,!Number.isFinite(Q)||Q<0){O--;break}if(Q===0){if(N++,N>jt){const{cumulative:re}=o.prefixSum(O,{materializeOption:{materialize:!1}}),{index:se}=Number.isFinite(re)?o.findIndexAtOrAfter(re-.5,{materializeOption:{materialize:!1}}):{index:-1};if(se!==-1&&se<O){O=se,N=0;continue}if(se===O&&O>=1&&a(O-1)>0)N=0;else{O--;break}}}else N=0;O--}v=Ae(O+1,i);const K=$(v,0);be=K.cursor,V=K.height}const ue=Ae(v-n,i),le=Ae(Math.max(be-1,v),i),ne=Ae(le+n,i);return{renderingStartIndex:ue,renderingEndIndex:ne,visibleStartIndex:v,visibleEndIndex:le}},Ir=(r,e,n)=>{const i=Math.max(0,e??0),a=t.useRef({last:0,id:null,arg:null}).current;return t.useEffect(()=>()=>{if(a.id!==null&&(cancelAnimationFrame(a.id),a.id=null),a.arg!==null&&r.current){try{n(r.current,a.arg)}catch(o){console.error("[useThrottledInvoker] Error flushing pending callback on unmount",o)}a.arg=null}},[a,r,n]),t.useCallback(o=>{if(a.arg=o,a.id!==null)return;const l=m=>{if(a.id=null,a.arg===null)return;const h=m-a.last;if(i===0||a.last===0||h>=i){if(r.current)try{n(r.current,a.arg)}catch(x){console.error("[useThrottledInvoker] Error invoking callback",x)}a.arg=null,a.last=m}a.arg!==null&&(a.id=requestAnimationFrame(l))};a.id=requestAnimationFrame(l)},[i,n,r,a])},hn=t.memo(({index:r,top:e,height:n,item:i,children:a,clipItemHeight:o,enableKeyboardNavigation:l,onKeyDown:m,onEscapeKeyDown:h,onFocus:x,registerItemRef:S})=>{const M=t.useCallback($=>S(r,$),[r,S]),T=t.useCallback($=>m($,r),[r,m]),v=t.useCallback($=>h?.($,r),[r,h]),V=t.useCallback(()=>x(r),[r,x]),J=t.useCallback($=>{$.currentTarget.focus({preventScroll:!0})},[]);return H.jsx("div",{ref:M,"data-index":r,"data-virtualscroll-item":"true",className:"aqvs-item-container",style:{top:e,height:n,overflow:o?"hidden":void 0},tabIndex:l?-1:void 0,onPointerDown:l?J:void 0,onKeyDownCapture:l?T:void 0,onKeyDown:l&&h?v:void 0,onFocusCapture:l?V:void 0,children:a(i,r)})}),pn=({itemCount:r,getItem:e,getItemKey:n,getItemHeight:i,viewportSize:a,overscanCount:o=15,className:l,testId:m,onScroll:h,onRangeChange:x,children:S,background:M,initialScrollIndex:T,initialScrollOffset:v,initialScrollAnchor:V,callbackThrottleMs:J=5,contentInsets:$,onItemFocus:oe,scrollBarOptions:be,behaviorOptions:ue,onWheelHorizontal:le,onPanHorizontal:ne,horizontalKeyInputs:_,horizontalKeyStep:O=dn,contentProps:N,liveRegion:K},Q)=>{const{width:re,enableThumbDrag:se,enableTrackClick:ye,enableArrowButtons:A,enableScrollToTopBottomButtons:C,renderThumbOverlay:j,tapScrollCircleOptions:ce}=be??{},{enablePointerDrag:Xe,pointerDragInputs:qe,enableKeyboardNavigation:D=!0,enableEscapeRowReturn:Ze=!1,wheelSpeedMultiplier:it,inertiaOptions:Ye,overscrollBehavior:xe,clipItemHeight:ve=!1,resetOnGetItemHeightChange:Re=!1}=ue??{},[Qe,ee]=t.useState(0),te=a??Qe,mt=t.useCallback(c=>{ee(g=>g===c?g:c)},[]),P=t.useRef(null),Me=t.useRef({renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0,scrollPosition:0,totalHeight:0}),F=t.useRef(V&&r>0?{index:G(Math.trunc(V.index),0,r-1),align:"top",offset:-Math.max(0,V.offsetPx??0)}:null),We=t.useRef(!1),ut=t.useRef(!0);t.useEffect(()=>{if(ut.current){ut.current=!1;return}Re&&(F.current=null)},[Re,i]);const k=t.useMemo(()=>Mr($),[$]),[ht]=t.useState(()=>{const g=V?.index??T,s=typeof g=="number"&&Number.isFinite(g)?Math.max(0,Math.trunc(g)):0;return{from:Math.max(0,s-50),to:s+50}}),yt=t.useMemo(()=>({sampleRange:ht,resetOnValueFnChange:Re,materialize:!0}),[Re,ht]),I=gr(r,i,yt),[Oe]=t.useState(()=>{let c=0,g=0;if(V&&r>0){const s=G(Math.trunc(V.index),0,r-1),f=Math.max(0,V.offsetPx??0),p=G(s-o*2,0,r-1),R=G(s+o*2,0,r-1),y=s>0||f>0?{materializeOption:{materialize:!0,ranges:[{from:p,to:R}]}}:void 0,{cumulative:X,total:Se,currentValue:ae}=I.prefixSum(s,y),pe=Math.max(X-ae+f,0);c=Lt(pe,k.top),g=Se??I.getTotal()}else if(typeof T=="number"){const s=G(T,0,r-1),f=G(s-o*2,0,r-1),p=G(s+o*2,0,r-1),R=T>0?{materializeOption:{materialize:!0,ranges:[{from:f,to:p}]}}:void 0,{cumulative:y,total:X,currentValue:Se}=I.prefixSum(T,R),ae=Math.max(y-Se,0);c=Lt(ae,k.top),g=X??I.getTotal()}else typeof v=="number"&&(c=Lt(Math.max(v,0),k.top)),g=I.getTotal();return{position:c,total:g}}),[$e,pt]=t.useState(Oe.position),[Ce,vt]=t.useState(Oe.total),d=t.useRef(Oe.position),q=t.useRef(k.top),Z=t.useRef(h??void 0),U=t.useRef(x??void 0),me=t.useRef(le),B=(_?.length??0)>0,ie=!!le;t.useEffect(()=>{B&&(D||z.warn("[VirtualScroll] horizontalKeyInputs is set but behaviorOptions.enableKeyboardNavigation is false; horizontal keyboard scrolling is disabled because the row key handler is not mounted."),ie||z.warn("[VirtualScroll] horizontalKeyInputs is set but onWheelHorizontal is missing; horizontal keyboard scrolling is disabled because the package does not own the horizontal axis."),Number.isFinite(O)&&O>0||z.warn(`[VirtualScroll] horizontalKeyStep must be a finite positive number, received ${O}. Horizontal arrow keys are left untouched.`))},[B,ie,D,O]);const ge=t.useRef(new Map),W=t.useRef(null),he=t.useRef(null),[Pe,Ie]=t.useState(null),[fe,je]=t.useState(!1),ze=t.useRef(null),Le=t.useRef(!1),we=t.useRef(0),Be=t.useRef(!1),at=t.useRef(!1),b=t.useRef(r);b.current!==r&&(b.current=r,at.current=!0),t.useLayoutEffect(()=>{Z.current=h??void 0,U.current=x??void 0,me.current=le},[x,h,le]);const w=t.useCallback(c=>{if(D&&c&&typeof c.focus=="function")try{c.focus({preventScroll:!0})}catch{c.focus()}},[D]),ke=t.useCallback((c,{position:g,totalHeight:s})=>{c(g,s)},[]),Fe=Ir(Z,J,ke),_e=t.useCallback((c,g)=>{c(g)},[]),Ue=Ir(U,J,_e),Ee=t.useRef(k.top);Ee.current=k.top;const gt=t.useRef(Fe);gt.current=Fe,t.useEffect(()=>(We.current=!1,()=>{We.current=!0,ze.current&&(clearTimeout(ze.current),ze.current=null)}),[]),t.useEffect(()=>{D||(ge.current.clear(),W.current=null,he.current=null)},[D]);const wt=t.useCallback((c,g)=>{if(!g){ge.current.delete(c);return}D&&(ge.current.set(c,g),W.current===c&&(W.current=null,he.current=c,w(g)))},[D,w]),ft=.01,ot=t.useRef({rafId:null,loopActive:!1,idleFrames:0,lastRenderedPosition:Oe.position}),St=t.useCallback(()=>{const c=ot.current;c.rafId!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(c.rafId),c.rafId=null,c.loopActive=!1,c.idleFrames=0},[]);t.useEffect(()=>()=>{St()},[St]);const kt=t.useRef(()=>{}),Et=t.useCallback(()=>{const c=ot.current;c.rafId=null;const g=d.current,s=st(g,Ee.current),f=I.getTotal();if(pt(R=>Math.abs(R-g)<ft?R:g),Math.abs(c.lastRenderedPosition-g)>=ft?(gt.current({position:s,totalHeight:f}),c.lastRenderedPosition=g,c.idleFrames=0):c.idleFrames+=1,c.idleFrames>=2){St();return}if(typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(R=>kt.current(R));return}c.loopActive=!1},[I,St]);kt.current=Et;const Rt=t.useCallback(()=>{const c=ot.current;if(c.idleFrames=0,!c.loopActive){if(c.loopActive=!0,typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(Et);return}c.loopActive=!1}},[Et]),Te=t.useCallback((c,g)=>{const s=g?.immediate??!1,f=st(c,k.top);if(d.current=c,s){ot.current.lastRenderedPosition=c,ot.current.idleFrames=0,pt(c),Fe({position:f,totalHeight:I.getTotal()});return}Rt()},[Rt,I,k.top,Fe]),bt=t.useCallback((c,g=0)=>{const s=P.current;if(!s)return c;const f=s.getScrollPosition();we.current+=1;const p=s.getContentSize()+g,R=s.getViewportSize(),y=s.scrollTo(c,{contentSize:p,viewportSize:R});return y===f&&(we.current=Math.max(0,we.current-1)),Math.abs(y-c)>.5&&(Be.current=!0),y},[]),Nt=t.useRef(!1);t.useEffect(()=>{if(!Nt.current)if(Nt.current=!0,V==null&&typeof T!="number"&&typeof v=="number"){const c=Lt(Math.max(v,0),k.top),g=Math.abs(c-d.current)>.5;Te(c,{immediate:!0}),g&&P.current?.scrollTo(c)}else Te(d.current,{immediate:!0})},[V,T,v,k.top,Te]),t.useEffect(()=>{const c=I.getTotal();if(Ce!==c){vt(c);return}if(Be.current){Be.current=!1;const g=P.current;if(g&&Math.abs(g.getScrollPosition()-d.current)>.5){const s=bt(d.current);Be.current=!1,Te(s,{immediate:!0})}}},[I,Ce,r,bt,Te]),t.useEffect(()=>{if(F.current!==null){const{index:c,align:g,offset:s}=F.current,f=Ae(c,r),{cumulative:p,currentValue:R}=I.prefixSum(f,{materializeOption:{materialize:!1}});if(p!==void 0&&R!==void 0){const y=Math.max(p-R,0);let X=y;g==="bottom"?X=p-te:g==="center"&&(X=y+R/2-te/2),s&&(X-=s),X=Math.max(0,X);const Se=Math.max(0,Ce+k.top+k.bottom-te),ae=Math.min(Lt(X,k.top),Se);Math.abs(ae-d.current)>1&&(z.debug("[VirtualScroll] Drift correction",{from:d.current,to:ae,targetIndex:f}),we.current===0&&(we.current+=1),P.current?.scrollTo(ae),Te(ae,{immediate:!0}))}}at.current=!1},[Ce,I,r,k.top,Te,te,k.bottom]),t.useEffect(()=>{const c=q.current;if(c===k.top||(q.current=k.top,F.current))return;const g=st(d.current,c),s=Lt(g,k.top);d.current=s,P.current?.scrollTo(s),Te(s,{immediate:!0})},[k.top,Te]);const Vt=t.useCallback((c,g)=>{if(r===0)return;const s=Ae(c,r),f=I.get(s),p=g-f,R=I.update(s,g);R!==void 0&&vt(R),z.debug("[VirtualScroll] Updated item size manually",{index:s,size:g,total:R});let y=F.current?F.current.index:null;if(y===null){const X=d.current,Se=Mr($).top,ae=st(X,Se),{index:pe,cumulative:tt}=I.findIndexAtOrAfter(ae,{materializeOption:{materialize:!1}});y=tt!==void 0&&tt===ae?pe+1:pe}if(y!==-1&&s<y&&p!==0){const X=d.current,Se=X+p;bt(Se,p),Te(Se,{immediate:!0}),z.debug("[VirtualScroll] Adjusted scroll for layout shift (manual update)",{from:X,to:Se,causedByIndex:s,delta:p,activeVisibleStartIndex:y})}},[I,r,bt,Te,$]),u=t.useCallback((c,g)=>{if(!P.current||r===0)return;const s=Ae(c,r),f=Ae(s-o*2,r),p=Ae(s+o*2,r),{cumulative:R,total:y,currentValue:X}=I.prefixSum(s,{materializeOption:{materialize:!0,ranges:[{from:f,to:p}]}});if(z.debug("[VirtualScroll] Scrolling to index:",s,"ItemBottom:",R,"Total height:",y,"ItemHeight:",X,"safeIndexFrom:",f,"safeIndexTo:",p),!y)return;const Se=Math.max(R-X,0);let ae=Se;g?.align==="bottom"?ae=R-te:g?.align==="center"&&(ae=Se+X/2-te/2),g?.offset&&(ae-=g.offset),ae=Math.max(0,ae);const pe=Lt(ae,k.top),tt=P.current?.getContentSize()??y+k.top+k.bottom,Ke=Math.max(0,tt-te),rt=Math.min(pe,Ke);F.current={index:s,align:g?.align,offset:g?.offset};const Bt=P.current?.getScrollPosition()??-1,nr=Math.abs(Bt-rt)>.5;Le.current=!1,we.current=0,nr&&(Le.current=!0,we.current+=1,P.current?.scrollTo(rt)),vt(y),Te(rt,{immediate:!0}),z.debug("[VirtualScroll] Setting scroll position to:",rt,{original:pe,max:Ke})},[I,o,r,k.top,k.bottom,te,Te]),E=t.useRef(V&&r===0?V:null);t.useEffect(()=>{const c=E.current;!c||r===0||(E.current=null,u(G(Math.trunc(c.index),0,r-1),{align:"top",offset:-Math.max(0,c.offsetPx??0)}))},[r,u]);const L=t.useCallback(c=>{if(!P.current||r===0)return;const g=I.getTotal(),s=G(Math.floor(c),0,g),{index:f,cumulative:p,currentValue:R}=I.findIndexAtOrAfter(s,{materializeOption:{materialize:!1}}),X=(p??0)-(R??0)-s;u(f,{offset:X})},[I,r,u]),Y=t.useCallback(()=>{if(r===0)return null;const c=st(d.current,k.top),{index:g,cumulative:s,currentValue:f}=I.findIndexAtOrAfter(c,{materializeOption:{materialize:!1}});if(g===-1)return{index:r-1,offsetPx:0};if(s===c)return{index:G(g+1,0,r-1),offsetPx:0};const p=(s??0)-(f??0);return{index:g,offsetPx:Math.max(0,c-p)}},[I,r,k.top]),de=t.useCallback(c=>{const g=st(d.current,k.top),s=typeof c=="function"?c(g):c;L(s);const f=P.current?.getScrollPosition(),p=typeof f=="number"?f:d.current;return Te(p),st(p,Ee.current)},[k.top,L,Te]),Ve=t.useCallback(c=>{const g=P.current;if(!g)return st(d.current,Ee.current);const s=g.scrollTo(f=>f+c);return st(s,Ee.current)},[]),Ne=t.useCallback(c=>P.current?.applyWheel(c)??!1,[]),De=t.useCallback((c,g)=>{z.debug("[VirtualScroll] Scroll position changed:",c);const s=Le.current;s&&(Le.current=!1);const f=we.current>0;f&&(we.current=0);const p=at.current&&b.current===r;if(s||f||p||(F.current=null),Te(c),C){if(s||f)return;const R=c-g;if(z.debug("[VirtualScroll] Scroll diff:",R,"New:",c,"Prev:",g),Math.abs(R)>1){const y=R>0?"down":"up";Ie(y),je(!0),z.debug("[VirtualScroll] Showing scroll buttons. Direction:",y),ze.current&&clearTimeout(ze.current),ze.current=setTimeout(()=>{je(!1),z.debug("[VirtualScroll] Hiding scroll buttons")},2e3)}}},[Te,C,r]),Ge=t.useMemo(()=>st($e,k.top),[k.top,$e]),He=t.useMemo(()=>{const c=I.getTotal(),g=Ar(Ge,te,o,r,i,I,c);return z.debug("[VirtualScroll] Calculated rendering range:",()=>({...g,scrollPosition:Ge,renderingContentSize:c,overscanCount:o,viewportSize:te})),g},[Ge,te,o,r,i,I]),{renderingStartIndex:nt,renderingEndIndex:lt,visibleStartIndex:Je,visibleEndIndex:et}=He,dt=t.useCallback((c,g)=>{if(!D||r===0)return;const s=Ae(c,r);if(!(g?.ensureVisible??!0)){const Ke=ge.current.get(s);Ke&&(W.current=null,he.current=s,w(Ke));return}const p=I.prefixSum(s,{materializeOption:{materialize:!1}}),R=p.currentValue,y=Math.max(p.cumulative-R,0),X=y+R,Se=st(d.current,k.top),ae=Se+te;if(y<Se||X>ae){u(s);const Ke=ge.current.get(s);Ke?(W.current=null,he.current=s,w(Ke)):W.current=s;return}const tt=ge.current.get(s);if(tt){W.current=null,he.current=s,w(tt);return}W.current=s},[D,r,I,k.top,u,w,te]),Gt=t.useCallback((c,g)=>{if(!(!D||c.defaultPrevented)&&!(c.altKey||c.metaKey||c.ctrlKey)&&c.target===c.currentTarget&&!c.currentTarget.isContentEditable){if(c.key==="ArrowLeft"||c.key==="ArrowRight"){const s=me.current;if(!s||c.shiftKey||!_?.includes("arrow")||!(Number.isFinite(O)&&O>0))return;c.preventDefault(),s(c.key==="ArrowLeft"?-O:O);return}if(c.key==="ArrowDown"){g<r-1&&(c.preventDefault(),dt(g+1));return}if(c.key==="ArrowUp"){g>0&&(c.preventDefault(),dt(g-1));return}if(c.key==="PageDown"){if(g<r-1){c.preventDefault();const{visibleStartIndex:s,visibleEndIndex:f}=Me.current,p=Math.max(f-s+1,1),R=Math.max(p,1),y=Ae(Math.min(g+R,r-1),r);dt(y)}return}if(c.key==="PageUp"&&g>0){c.preventDefault();const{visibleStartIndex:s,visibleEndIndex:f}=Me.current,p=Math.max(f-s+1,1),R=Math.max(p,1),y=Ae(g-R,r);dt(y)}}},[D,r,dt,_,O]),Ht=t.useCallback((c,g)=>{if(c.key!=="Escape"||c.defaultPrevented||c.nativeEvent.isComposing||c.target===c.currentTarget)return;const s=c.target;s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement||s.isContentEditable||(c.preventDefault(),dt(g))},[dt]),Xt=t.useCallback(c=>{if(!D)return;const g=Ae(c,r);W.current=null,he.current=g,oe?.(g)},[D,r,oe]);t.useEffect(()=>{const c=P.current?.getScrollPosition()??0,g=d.current,s=st(g,k.top);z.debug("[VirtualScroll] Range change effect triggered",()=>({renderingStartIndex:nt,renderingEndIndex:lt,visibleStartIndex:Je,visibleEndIndex:et,scrollPositionState:$e,paneScrollPosition:g,logicalScrollPosition:s,contentSize:Ce,scrollPaneScrollPosition:c})),Ue({renderingStartIndex:nt,renderingEndIndex:lt,visibleStartIndex:Je,visibleEndIndex:et,scrollPosition:s,totalHeight:Ce})},[Ce,lt,nt,k.top,Ue,$e,et,Je]);const Kt=t.useCallback(()=>{if(!C)return null;const c=fe&&Pe!==null,g=Pe==="up";return H.jsx("div",{className:"aqvs-scroll-to-edge-overlay","data-visible":c,inert:!c,children:g?H.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-top",children:H.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:s=>{s.stopPropagation(),Le.current=!0,u(0),je(!1)},children:"Top"})}):H.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-bottom",children:H.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:s=>{s.stopPropagation(),Le.current=!0,u(r-1),je(!1)},children:"Bottom"})})})},[C,fe,Pe,u,r]),At=t.useRef(0),{visibleItems:Ct,renderAnchor:Pt}=t.useMemo(()=>{if(r===0)return{visibleItems:H.jsx("div",{className:"aqvs-no-items-container",children:H.jsx("div",{className:"aqvs-no-items-text",children:"No items"})}),renderAnchor:0};const c=Ae(nt,r),g=Ae(lt,r),{cumulative:s,currentValue:f}=I.prefixSum(c,{materializeOption:{materialize:!1}}),p=s-f;Number.isFinite(p)&&Math.abs(p-At.current)>Vr&&(At.current=p);const R=At.current,y=[],X=[];let Se=0,ae=p;for(let pe=c;pe<=g;pe++){if(X.length>=fr){z.warn("[VirtualScroll] Rendered item count reached the safety cap; truncating render window.",{cap:fr,safeRenderingStartIndex:c,safeRenderingEndIndex:g});break}const tt=i(pe),Ke=I.get(pe),rt=tt-Ke;rt!==0&&y.push({index:pe,value:tt});const Bt=ae+Se,nr=n?n(pe):pe;X.push(H.jsx(hn,{index:pe,top:Bt-R,height:tt,item:e(pe),clipItemHeight:ve,enableKeyboardNavigation:D,onKeyDown:Gt,onEscapeKeyDown:Ze?Ht:void 0,onFocus:Xt,registerItemRef:wt,children:S},nr)),Se+=rt,ae+=Ke}return y.length>0&&Promise.resolve().then(()=>{if(We.current)return;let pe=0;for(const rt of y)if(rt.index<Je){const Bt=I.get(rt.index);pe+=rt.value-Bt}const tt=I.updates(y);if(We.current||typeof tt!="number")return;vt(tt),z.debug("[VirtualScroll] Updated heights for items",y,"New total height:",tt);const Ke=P.current?.getScrollPosition()??d.current;if(pe!==0){const rt=Ke+pe;bt(rt,pe),Te(rt,{immediate:!0}),z.debug("[VirtualScroll] Adjusted scroll for layout shift (auto update)",{from:Ke,to:rt,shiftAmount:pe})}else Ke!==d.current&&Te(Ke)}),{visibleItems:X,renderAnchor:R}},[S,ve,Ce,D,r,I,e,n,i,Xt,Gt,Ze,Ht,bt,wt,lt,nt,Te,Je]),Zt=t.useCallback(c=>{const g=(J??0)>0,s=Math.abs(c-$e),f=g&&s>.5?$e:c,p=st(f,k.top);if(z.debug("[VirtualScroll] Rendering visible items",()=>({currentScrollPosition:c,effectiveScrollPosition:p,renderingStartIndex:nt,renderingEndIndex:lt,itemCount:r,viewportSize:te,callbackThrottleMs:J,diff:s,rawEffectiveScrollPosition:f})),r===0)return Ct;const R=k.top+Pt-f,y=k.bottom>0?H.jsx("div",{className:"aqvs-bottom-inset",style:{top:I.getTotal()-Pt,height:k.bottom}},"virtualscroll-bottom-inset"):null;return z.debug("[VirtualScroll] Rendering items",()=>({containerTop:R,logicalScrollPosition:Ge,resolvedInsets:k,effectiveScrollPosition:p})),H.jsxs("div",{className:"aqvs-items-wrapper",style:{top:0,transform:`translateY(${R}px)`,willChange:"transform"},children:[Ct,y]})},[J,r,I,Ge,Pt,lt,nt,k,$e,te,Ct]),qt=t.useMemo(()=>({renderingStartIndex:He.renderingStartIndex,renderingEndIndex:He.renderingEndIndex,visibleStartIndex:He.visibleStartIndex,visibleEndIndex:He.visibleEndIndex,scrollPosition:Ge,totalHeight:I.getTotal()}),[He,Ge,I,Ce]);t.useEffect(()=>{Me.current=qt},[qt]);const[Qt,Jt]=t.useState(""),er=t.useRef(K);t.useLayoutEffect(()=>{er.current=K},[K]);const ct=K?.debounceMs??400,Dt=Number.isFinite(ct)&&ct>=0,Mt=K!==void 0;t.useEffect(()=>{Mt&&!Dt&&z.warn(`[VirtualScroll] liveRegion.debounceMs must be a finite number >= 0, received ${ct}. Announcements are disabled.`)},[Mt,Dt,ct]),t.useEffect(()=>{if(!(Mt&&Dt)){Jt("");return}const c=setTimeout(()=>{const g=er.current?.format;if(!g)return;const s=g({visibleStartIndex:Je,visibleEndIndex:et,itemCount:r});Jt(s)},ct);return()=>clearTimeout(c)},[Mt,Dt,ct,Je,et,r]),t.useImperativeHandle(Q,()=>({getScrollPosition:()=>{const c=P.current?.getScrollPosition();return typeof c=="number"?st(c,Ee.current):-1},getContentSize:()=>P.current?.getContentSize()??-1,getViewportSize:()=>P.current?.getViewportSize()??-1,scrollTo:de,scrollBy:Ve,applyWheel:Ne,scrollToIndex:u,getFenwickTreeTotalHeight:()=>I.getTotal(),getFenwickSize:()=>I.getSize(),focusItemAtIndex:dt,getRange:()=>Me.current,getScrollAnchor:Y,updateItemSize:Vt}),[de,Ve,Ne,u,I,dt,Y,Vt]);const _t=I.getTotal()+k.top+k.bottom,Yt=H.jsx(kr,{ref:P,contentSize:_t,viewportSize:a,onViewportSizeChange:mt,className:l,testId:m,onScroll:De,background:M,tapScrollCircleOptions:ce,inertiaOptions:Ye,overscrollBehavior:xe,itemCount:r,scrollBarWidth:re,enableThumbDrag:se,enableTrackClick:ye,enableArrowButtons:A,enablePointerDrag:Xe,pointerDragInputs:qe,renderThumbOverlay:j,wheelSpeedMultiplier:it,onWheelHorizontal:le,onPanHorizontal:ne,contentInsets:k,contentProps:N,visibleStartIndex:Je,visibleEndIndex:et,renderOverlay:Kt,initialScrollPosition:Oe.position,children:Zt});return Mt?H.jsxs(H.Fragment,{children:[Yt,H.jsx("div",{className:"aqvs-live-region",role:"status","aria-live":"polite","aria-atomic":"true","data-aqvs-live-region":"",children:Qt})]}):Yt},Dr=t.forwardRef(pn),Ut=262144,Tr=3,Lr=32768,dr=128,mr=128,yr=10,gn=(r,e)=>Math.max(1,Math.floor((r??Lr)/Math.max(1,e))),bn=(r,e,n,i,a)=>{let o=0,l=0,m=Math.max(0,Math.min(i,n-1));for(;m<n&&o<r&&l<fr;)o+=e(m),l+=1,m+=1;return Math.max(1,l+2*a+2)},rr=(r,e,n)=>{if(!(Number.isInteger(r)&&r>=0&&r<=Ut))throw new RangeError(`[VirtualGrid] ${e==="row"?"getRowHeight":"getColWidth"}(${n}) returned ${r} — must be an integer in [0, ${Ut}] (0 = hidden). Oversized tracks would pierce the browser layout-coordinate wall (see the design plan §3.1/§6).`);return r},xn=(r,e,n,i,a,o,l,m)=>{const h=Ar(r,e,n,i,a,o,l);if(i===0)return{renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0};const x=G(h.renderingStartIndex,0,i-1),{cumulative:S,currentValue:M}=o.prefixSum(x,{materializeOption:{materialize:!1}}),T=S-M,v=Number.isFinite(T)&&Math.abs(T-m)>Vr?T:m;return{renderingColStart:h.renderingStartIndex,renderingColEnd:h.renderingEndIndex,visibleColStart:h.visibleStartIndex,visibleColEnd:h.visibleEndIndex,colAnchor:v}},vn=[],wn=(r,e,n,i,a)=>{const o=[],l=[];if(e<r)return{columns:o,widthUpdates:l,truncated:0};const m=i.prefixSum(r,{materializeOption:{materialize:!1}});let h=m.cumulative-m.currentValue,x=0,S=r;for(;S<=e;){if(o.length>=a)return{columns:o,widthUpdates:l,truncated:e-S+1};const M=n(S),T=i.get(S);if(M!==T&&l.push({index:S,value:M}),M>0){o.push({col:S,left:h,width:M}),h+=T,x=0,S+=1;continue}if(h+=T,x+=1,S+=1,x>jt){const v=i.findIndexAtOrAfter(h+.5,{materializeOption:{materialize:!1}});if(v.index===-1||v.index<=S||!Number.isSafeInteger(v.index))break;const V=i.prefixSum(v.index,{materializeOption:{materialize:!1}});h=V.cumulative-V.currentValue,S=v.index,x=0}}return{columns:o,widthUpdates:l,truncated:0}},Sn=(r,e,n)=>{const i=[],a=[];let o=0;for(let l=0;l<r;l+=1){const m=e(l),h=n.get(l);m!==h&&a.push({index:l,value:m}),m>0&&i.push({col:l,left:o,width:m}),o+=h}return{columns:i,widthUpdates:a,width:o}},Rn={renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0,key:"0:0:0"},Mn=({rowCount:r,colCount:e,getRowHeight:n,getColWidth:i,getCell:a,getCellKey:o,children:l,getCellProps:m,getRowProps:h,contentProps:x,background:S,contentInsets:M,onRowFocus:T,frozenLeadingCols:v=0,frozenLeadingRows:V=0,horizontalKeyInputs:J,horizontalKeyStep:$,onScroll:oe,onRangeChange:be,onRenderTruncated:ue,callbackThrottleMs:le,initialScrollAnchor:ne,overscanRows:_=Tr,overscanCols:O=Tr,viewportSize:N,__maxRenderedCells:K,behaviorOptions:Q,scrollBarOptions:re,liveRegion:se,className:ye,testId:A},C)=>{const j=t.useRef(null),ce=t.useRef(null),Xe=t.useRef(n);Xe.current=n;const qe=t.useRef(i);qe.current=i;const D=Q?.resetOnGetColWidthChange===!0,it=Q?.resetOnGetItemHeightChange===!0?n:null,Ye=D?i:null,xe=t.useCallback(s=>rr(Xe.current(s),"row",s),[it]),ve=t.useCallback(s=>rr(qe.current(s),"col",s),[Ye]),Re=Q?.defaultColWidth,Qe=t.useMemo(()=>{if(Re!==void 0&&!(Number.isInteger(Re)&&Re>=0&&Re<=Ut))throw new RangeError(`[VirtualGrid] behaviorOptions.defaultColWidth must be an integer in [0, ${Ut}], received ${Re}.`);return{resetOnValueFnChange:D,baseValue:Re}},[D,Re]),ee=gr(e,ve,Qe),[te,mt]=t.useState(0);if(!(Number.isInteger(v)&&v>=0&&v<=dr))throw new RangeError(`[VirtualGrid] frozenLeadingCols must be an integer in [0, ${dr}], received ${v}.`);const P=Math.min(v,e),Me=t.useRef(0);if(!(Number.isInteger(V)&&V>=0&&V<=mr))throw new RangeError(`[VirtualGrid] frozenLeadingRows must be an integer in [0, ${mr}], received ${V}.`);const F=Math.min(V,r),We=Math.max(0,r-F),ut=t.useRef(!1),k=t.useRef(0),[ht,yt]=t.useState(0),{frozenRows:I,frozenHeight:Oe}=t.useMemo(()=>{if(F===0)return{frozenRows:[],frozenHeight:0};const s=[];let f=0;for(let p=0;p<F;p+=1){const R=xe(p);R>0&&s.push({row:p,top:f,height:R}),f+=R}return{frozenRows:s,frozenHeight:f}},[F,ht,xe]);k.current=Oe;const $e=t.useCallback(s=>xe(s+F),[xe,F]),pt=t.useRef(T);pt.current=T;const Ce=T!==void 0,vt=t.useMemo(()=>Ce?s=>pt.current?.(s+F):void 0,[F,Ce]),d=Oe,[q,Z]=t.useState(F),U=t.useRef(null),me=t.useRef(!1);if(q!==F){Z(F),me.current=!0;const s=j.current?.getScrollAnchor()??null;U.current=s===null?null:{row:s.index+q,offsetPx:s.offsetPx}}const B=t.useRef(0),ie=t.useRef(0),ge=t.useRef(!1),[W,he]=t.useState(Rn),Pe=t.useRef(W);Pe.current=W;const Ie=t.useRef(0),[fe,je]=t.useState(()=>ee.getTotal()??0),ze=t.useRef(fe);ze.current=fe;const Le=t.useCallback(s=>{typeof s=="number"&&Number.isFinite(s)&&(ze.current=s,je(s))},[]);t.useLayoutEffect(()=>{const s=ee.getTotal();typeof s=="number"&&Number.isFinite(s)&&s!==ze.current&&Le(s)});const we=re?.width??12,Be=N===void 0?null:{width:Math.max(0,Math.round(N.width)-we),height:Math.max(0,Math.round(N.height)-we)},[at,b]=t.useState({width:0,height:0}),w=Be??at,ke=t.useRef(w);ke.current=w;const Fe=w.height>0&&w.height-Oe<=0;ut.current=Fe;const _e=Be!==null;t.useLayoutEffect(()=>{if(_e)return;const s=ce.current;if(s===null)return;const f=()=>{const R=Math.max(0,Math.round(s.clientWidth)-we),y=Math.max(0,Math.round(s.clientHeight)-we);b(X=>X.width===R&&X.height===y?X:{width:R,height:y})};f();const p=new ResizeObserver(f);return p.observe(s),()=>p.disconnect()},[we,_e]);const Ue=t.useCallback(()=>{const s=ce.current;s!==null&&s.style.setProperty("--aqvs-grid-hx-residual",`${Ie.current-B.current}px`)},[]),Ee=t.useCallback(()=>{const s=Math.max(0,ke.current.width-Me.current),f=xn(Me.current+B.current,s,O,e,ve,ee,ze.current,Pe.current.colAnchor);P>0&&(f.renderingColStart=Math.max(f.renderingColStart,P),f.visibleColStart=Math.max(f.visibleColStart,P),s<=0&&(f.renderingColStart=e,f.renderingColEnd=e-1,f.visibleColStart=e,f.visibleColEnd=e-1));const p=`${f.renderingColStart}:${f.renderingColEnd}:${f.colAnchor}`;p!==Pe.current.key&&he({...f,key:p})},[O,e,ve,ee,P]),[gt,wt]=t.useState(0),ft=t.useRef(null),ot=t.useCallback(()=>{ft.current===null&&(ft.current=requestAnimationFrame(()=>{ft.current=null,wt(B.current)}))},[]);t.useEffect(()=>()=>{ft.current!==null&&cancelAnimationFrame(ft.current)},[]);const St=t.useRef(oe);St.current=oe;const kt=t.useRef(be);kt.current=be;const Et=t.useRef(ue);Et.current=ue;const Rt=t.useRef(null),[Te,bt]=t.useState(null),[Nt,Vt]=t.useState(w.height);Nt!==w.height&&(Vt(w.height),bt(null));const u=ne===void 0||r===0?0:G(Math.trunc(ne.row),0,r-1),E=t.useMemo(()=>{const s=Rt.current?.renderingStartIndex??u;return bn(Math.max(0,w.height-k.current),xe,r,s,_)},[w.height,xe,r,u,_,d]),L=Te??E,Y=t.useCallback(()=>{const s=Rt.current;if(s===null)return null;const f=Pe.current;return{renderingRowStart:s.renderingStartIndex,renderingRowEnd:s.renderingEndIndex,visibleRowStart:s.visibleStartIndex,visibleRowEnd:s.visibleEndIndex,renderingColStart:f.renderingColStart,renderingColEnd:f.renderingColEnd,visibleColStart:f.visibleColStart,visibleColEnd:f.visibleColEnd,scrollX:B.current,scrollY:ie.current,totalWidth:ze.current,totalHeight:s.totalHeight+k.current}},[]),de=t.useCallback(()=>{const s=Y();s!==null&&kt.current?.(s)},[Y]),Ve=t.useCallback(s=>{const f=Math.max(0,ke.current.width-Me.current),p=Math.max(0,ze.current-Me.current-f),R=G(s,0,p);return R!==B.current&&(B.current=R,Ue(),Ee(),ot(),St.current?.({x:R,y:ie.current})),R},[Ue,Ee,ot]),Ne=t.useRef(Ve);Ne.current=Ve,t.useLayoutEffect(()=>{Ie.current=W.colAnchor,Ue(),de()},[W,Ue,de]),t.useLayoutEffect(()=>{Rt.current!==null&&de()},[Oe,de]);const De=t.useRef(null),Ge=t.useCallback(s=>{const f=G(s.col,0,Math.max(0,e-1)),p=ee.prefixSum(f,{materializeOption:{materialize:!1}}),R=p.cumulative-p.currentValue,y=p.currentValue,X=Math.max(0,ke.current.width-Me.current);return(s.alignX==="end"?R+y-Me.current-X:s.alignX==="center"?R+y/2-Me.current-X/2:R-Me.current)+s.offsetX},[ee,e]),He=t.useRef(null),nt=t.useCallback(()=>{const s=He.current;He.current=null,!(s===null||s.length===0)&&(Le(ee.updates(s)),mt(f=>f+1))},[ee,Le]),lt=t.useRef({count:0,warned:!1}),{frozenColumns:Je,frozenWidth:et}=t.useMemo(()=>{if(P===0)return lt.current.count=0,lt.current.warned=!1,{frozenColumns:vn,frozenWidth:0};const{columns:s,widthUpdates:f,width:p}=Sn(P,ve,ee);if(f.length>0){const R=lt.current;R.count>=yr?R.warned||(R.warned=!0,z.warn("[VirtualGrid] getColWidth keeps disagreeing with its own previous values inside the frozen band; width self-heal is suspended until a converged pass re-arms it (unstable accessor).",{frozenCols:P,pendingUpdates:f.length})):(R.count+=1,He.current=[...He.current??[],...f],Promise.resolve().then(nt))}else lt.current.count=0,lt.current.warned=!1;return{frozenColumns:s,frozenWidth:p}},[P,te,ve,ee,nt]);Me.current=et,t.useLayoutEffect(()=>{P>0?ce.current?.style.setProperty("--aqvs-grid-frozen-width",`${et}px`):ce.current?.style.removeProperty("--aqvs-grid-frozen-width")},[et,P]),t.useLayoutEffect(()=>{const s=De.current;s===null?Ne.current(B.current):Ne.current(Ge(s)),Ee()},[w.width,fe,te,et,Ee,Ge]);const dt=t.useRef(!1);t.useLayoutEffect(()=>{if(dt.current||ne===void 0||e===0)return;dt.current=!0;const s=G(Math.trunc(ne.col),0,e-1);if(s<P)return;const f={col:s,alignX:"start",offsetX:Math.max(0,ne.offsetX)};De.current=f,Ne.current(Ge(f))},[ne,e,Ge,P]);const Gt=t.useCallback(s=>{ie.current=s,ge.current=!0,St.current?.({x:B.current,y:s})},[]),Ht=t.useCallback(s=>{if(We===0||ut.current)Rt.current={renderingStartIndex:r,renderingEndIndex:r-1,visibleStartIndex:r,visibleEndIndex:r-1,scrollPosition:0,totalHeight:We===0?0:s.totalHeight},ie.current=0;else{const f=F;Rt.current={renderingStartIndex:s.renderingStartIndex+f,renderingEndIndex:s.renderingEndIndex+f,visibleStartIndex:s.visibleStartIndex+f,visibleEndIndex:s.visibleEndIndex+f,scrollPosition:s.scrollPosition,totalHeight:s.totalHeight},ie.current=s.scrollPosition}bt(f=>{const p=Math.max(1,s.renderingEndIndex-s.renderingStartIndex+1);return p===f?f:p}),de()},[de,F,We,r]),Xt=t.useCallback(s=>{De.current=null,Ne.current(B.current+s)},[]),Kt=gn(K,L+I.length),At=t.useRef({count:0,warned:!1}),{placedColumns:Ct,truncatedCols:Pt}=t.useMemo(()=>{const s=Math.max(0,w.width-et);if(e===0||s<=0)return{placedColumns:[],truncatedCols:0};if(W.renderingColStart>W.renderingColEnd)return{placedColumns:[],truncatedCols:0};const f=Math.max(1,Kt-Je.length),{columns:p,widthUpdates:R,truncated:y}=wn(G(W.renderingColStart,0,e-1),G(W.renderingColEnd,0,e-1),ve,ee,f);if(R.length>0){const X=At.current;X.count>=yr?X.warned||(X.warned=!0,z.warn("[VirtualGrid] getColWidth keeps disagreeing with its own previous values; width self-heal is suspended until a converged (zero-deviation) pass re-arms it (unstable accessor — the accessor must be index-stable while the ordering is unchanged).",{window:W.key,pendingUpdates:R.length})):(X.count+=1,He.current=[...He.current??[],...R],Promise.resolve().then(nt))}else At.current.count=0,At.current.warned=!1;return{placedColumns:p,truncatedCols:y}},[W,e,w.width,et,Je.length,te,ve,ee,Kt,nt]),Zt=t.useRef("");t.useEffect(()=>{if(Pt>0){const s=`${W.key}:${Pt}`;s!==Zt.current&&(Zt.current=s,Et.current?.({renderedCells:(Ct.length+Je.length)*(L+I.length),droppedCols:Pt}))}},[Pt,W.key,Ct.length,Je.length,L,I.length]);const qt=W.colAnchor,Qt=t.useCallback(s=>{const f=h?.(s),p=xe(s)===0,R=p?null:Ct.map(({col:y,left:X,width:Se})=>{const ae=m?.(s,y),pe={...ae?.style,left:X-qt,width:Se};return t.createElement("div",{...ae,key:o?o(s,y):y,className:xt.twMerge("aqvs-grid-cell",ae?.className),style:pe},l(a(s,y),s,y))});return P===0?H.jsx("div",{...f,className:xt.twMerge("aqvs-grid-row",f?.className),style:f?.style,children:R}):H.jsxs("div",{...f,"data-aqvs-frozen-row":"",className:xt.twMerge("aqvs-grid-row aqvs-grid-row-frozen-host",f?.className),style:f?.style,children:[p?null:Je.map(({col:y,left:X,width:Se})=>{const ae=m?.(s,y),pe={...ae?.style,left:X,width:Se};return t.createElement("div",{...ae,"data-aqvs-frozen-cell":"",key:o?o(s,y):y,className:xt.twMerge("aqvs-grid-cell",ae?.className),style:pe},l(a(s,y),s,y))}),p?null:H.jsx("div",{className:"aqvs-grid-row-scroll",children:H.jsx("div",{className:"aqvs-grid-row-scroll-inner",children:R})})]})},[Ct,Je,P,qt,h,m,o,a,l,xe]),[Jt,er]=t.useState(""),ct=t.useRef(null),Dt=t.useRef(se);Dt.current=se;const Mt=t.useCallback(()=>{const s=Dt.current;if(s===void 0)return;const f=s.debounceMs??400;Number.isFinite(f)&&f>=0&&(ct.current!==null&&window.clearTimeout(ct.current),ct.current=window.setTimeout(()=>{ct.current=null;const p=Y();p!==null&&er(R=>{const y=s.buildMessage(p);return y===R?R:y})},f))},[Y]),_t=se?.debounceMs??400,Yt=Number.isFinite(_t)&&_t>=0,c=se!==void 0;t.useEffect(()=>{c&&!Yt&&z.warn(`[VirtualGrid] liveRegion.debounceMs must be a finite number >= 0, received ${_t}. Announcements are disabled.`)},[c,Yt,_t]),t.useEffect(()=>()=>{ct.current!==null&&window.clearTimeout(ct.current)},[]),t.useEffect(()=>{Mt()},[W,Mt]);const g=t.useCallback(s=>{Ht(s),Mt()},[Ht,Mt]);return t.useImperativeHandle(C,()=>({scrollTo:s=>{const f=j.current;let p=ie.current;s.y!==void 0&&f!==null&&(f.scrollTo(s.y),p=f.getScrollPosition(),ie.current=p);let R=B.current;return s.x!==void 0&&(De.current=null,R=Ne.current(s.x)),{x:R,y:p}},scrollBy:s=>{const f=j.current;let p=ie.current;s.y!==void 0&&s.y!==0&&f!==null&&(p=f.scrollBy(s.y),ie.current=p);let R=B.current;return s.x!==void 0&&s.x!==0&&(De.current=null,R=Ne.current(B.current+s.x)),{x:R,y:p}},scrollToCell:(s,f,p)=>{const R=j.current;if(R!==null&&r>0){const y=G(Math.trunc(s),0,r-1);y>=F&&R.scrollToIndex(y-F,{align:p?.alignY??"top",offset:p?.offsetY})}if(e>0){const y=G(Math.trunc(f),0,e-1);if(y>=P){const X={col:y,alignX:p?.alignX??"start",offsetX:p?.offsetX??0};De.current=X,Ne.current(Ge(X))}}},getScrollPosition:()=>ge.current||j.current!==null?{x:B.current,y:j.current?.getScrollPosition()??ie.current}:{x:-1,y:-1},getScrollAnchor:()=>{if(r===0||e===0)return null;const s=j.current?.getScrollAnchor()??null;if(s===null)return null;const f=Me.current+B.current,p=ee.findIndexAtOrAfter(f,{materializeOption:{materialize:!1}});if(p.index===-1)return{row:s.index+F,col:e-1,offsetX:0,offsetY:s.offsetPx};if(p.cumulative===f)return{row:s.index+F,col:G(p.index+1,0,e-1),offsetX:0,offsetY:s.offsetPx};const R=(p.cumulative??0)-(p.currentValue??0);return{row:s.index+F,col:p.index,offsetX:Math.max(0,f-R),offsetY:s.offsetPx}},getViewportSize:()=>({width:ke.current.width,height:ke.current.height}),getContentSize:()=>({width:ze.current,height:j.current===null?0:k.current+Math.max(0,j.current.getContentSize())}),getRange:Y,updateRowSize:(s,f)=>{rr(f,"row",s),Math.trunc(s)<F?yt(p=>p+1):j.current?.updateItemSize(Math.trunc(s)-F,f)},updateColSize:(s,f)=>{rr(f,"col",s),Le(ee.update(G(Math.trunc(s),0,Math.max(0,e-1)),f)),mt(p=>p+1)},getFrozenSize:()=>({cols:P,width:Me.current,rows:F,height:k.current}),applyWheel:s=>j.current?.applyWheel(s)??!1,focusRowAtIndex:(s,f)=>{const p=Math.trunc(s);p<F?ce.current?.querySelector(`[data-aqvs-frozen-band-row="${p}"]`)?.focus():j.current?.focusItemAtIndex(p-F,f)}}),[r,e,ee,Y,Le,Ge,P,F]),H.jsxs("div",{ref:ce,className:xt.twMerge("aqvs-grid",F>0?"aqvs-grid-has-frozen-rows":"",ye),"data-testid":A,children:[F>0?H.jsx("div",{className:"aqvs-grid-frozen-rows",style:{height:Oe},"data-testid":A?`${A}-frozen-rows`:void 0,children:I.map(({row:s,top:f,height:p})=>H.jsx("div",{"data-aqvs-frozen-band-row":s,className:"aqvs-grid-frozen-band-row",style:{top:f,height:p,right:we},tabIndex:-1,onFocus:()=>T?.(s),children:Qt(s)},s))}):null,H.jsx("div",{className:"aqvs-grid-main","data-testid":A?`${A}-main`:void 0,children:H.jsx(Dr,{ref:j,itemCount:Fe?0:We,getItem:s=>s+F,getItemKey:s=>s+F,getItemHeight:$e,overscanCount:_,viewportSize:w.height>0?Math.max(0,w.height-Oe):void 0,callbackThrottleMs:le,behaviorOptions:Q,scrollBarOptions:re,contentProps:x,background:S,contentInsets:M,onItemFocus:vt,horizontalKeyInputs:J,horizontalKeyStep:$,initialScrollAnchor:me.current?U.current!==null&&U.current.row>=F&&We>0?{index:U.current.row-F,offsetPx:U.current.offsetPx}:void 0:ne!==void 0&&We>0&&Math.trunc(ne.row)>=F?{index:Math.trunc(ne.row)-F,offsetPx:ne.offsetY}:void 0,onScroll:Gt,onRangeChange:g,onWheelHorizontal:Xt,onPanHorizontal:Xt,testId:A?`${A}-rows`:void 0,children:Qt},F)}),H.jsx("div",{className:"aqvs-grid-hbar-strip",style:{height:we,paddingRight:we},"data-testid":A?`${A}-hbar`:void 0,children:H.jsx(pr,{horizontal:!0,enableHorizontalTapCircle:!0,contentSize:Math.max(0,fe-et),viewportSize:Math.max(0,w.width-et),scrollPosition:gt,itemCount:Math.max(0,e-P),tapScrollCircleOptions:re?.tapScrollCircleOptions,onScroll:(s,f)=>(De.current=null,Ne.current(typeof s=="function"?s(f??B.current):s)),scrollBarWidth:we})}),se!==void 0?H.jsx("div",{className:"aqvs-grid-live-region","aria-live":"polite","data-testid":A?`${A}-live`:void 0,children:Jt}):null]})},In=t.forwardRef(Mn);exports.FenwickMapTree=Tt;exports.MAX_FROZEN_LEADING_COLS=dr;exports.MAX_FROZEN_LEADING_ROWS=mr;exports.MAX_RENDERED_CELLS=Lr;exports.MAX_TRACK_SIZE=Ut;exports.ScrollBar=pr;exports.ScrollPane=kr;exports.TAP_SCROLL_SPEED_DEFAULTS=hr;exports.VirtualGrid=In;exports.VirtualScroll=Dr;exports.computeAutoTapScrollMaxSpeedMultiplier=Pr;exports.computeTapScrollSpeed=Cr;exports.createResidualQuantizer=_r;exports.minmax=G;exports.tapScrollCircleSampleVisual=sn;exports.useFenwickMapTree=gr;exports.useHeightCache=un;exports.useLruCache=Nr;exports.useWheelBridge=fn;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("react/jsx-runtime"),t=require("react"),Mt=require("tailwind-merge");class z{level;prefix;impl;constructor(e=2,n="[virtualscroll]",s=console){this.level=e,this.prefix=n,this.impl=s}static instance=new z(2,"[virtualscroll]");static setLevel(e){z.instance.setLevel(e)}setLevel(e){this.level=e}static setImplementation(e){z.instance.setImplementation(e)}setImplementation(e){this.impl=e}static setPrefix(e){z.instance.setPrefix(e)}setPrefix(e){this.prefix=e}static isEnabled(e){return z.instance.isEnabled(e)}isEnabled(e){return this.level<=e}static resolveLazy(e){if(typeof e!="function")return e;try{return e()}catch{return e}}formatMessage(e){return typeof e=="string"?[`${this.prefix} ${e}`]:[this.prefix,e]}static debug(e,...n){z.instance.debug(e,...n)}debug(e,...n){this.level<=0&&this.impl.debug(...this.formatMessage(z.resolveLazy(e)),...n.map(z.resolveLazy))}static info(e,...n){z.instance.info(e,...n)}info(e,...n){this.level<=1&&this.impl.info(...this.formatMessage(z.resolveLazy(e)),...n.map(z.resolveLazy))}static warn(e,...n){z.instance.warn(e,...n)}warn(e,...n){this.level<=2&&this.impl.warn(...this.formatMessage(z.resolveLazy(e)),...n.map(z.resolveLazy))}static error(e,...n){z.instance.error(e,...n)}error(e,...n){this.level<=3&&this.impl.error(...this.formatMessage(z.resolveLazy(e)),...n.map(z.resolveLazy))}}const Gr={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},gr=6,yn=8,En=({dragState:r,normalizedDistance:e})=>{const n=1+e*.18,s=.16+e*.24,i=.38+e*.28,a=r.active?"80ms ease-out":"220ms ease";return D.jsxs(D.Fragment,{children:[D.jsx("div",{className:"aqvs-tap-scroll-circle-visual-outer",style:{background:"linear-gradient(140deg, rgba(255,255,255,0.62), rgba(72,72,72,0.48))",boxShadow:`0 0 0 1px rgba(255,255,255,0.28), 0 10px 22px rgba(0,0,0,${s})`,transform:`scale(${n})`,transition:`${a}, ${r.active?"80ms":"260ms"} box-shadow ease`}}),D.jsx("div",{className:"aqvs-tap-scroll-circle-inner",style:{background:"linear-gradient(140deg, rgba(255,255,255,0.72), rgba(28,28,28,0.58))",boxShadow:"inset 0 4px 10px rgba(0,0,0,0.24), inset 0 0 2px rgba(255,255,255,0.55)",opacity:i,transition:r.active?"120ms opacity ease-out":"220ms opacity ease"}})]})},Lr=t.memo(t.forwardRef(({onDragChange:r,className:e,maxVisualDistance:n=160,size:s=40,style:i,opacity:a=1,renderVisual:o,axis:u="y"},f)=>{const[g,v]=t.useState(Gr),y=t.useRef(null),I=t.useRef(null),S=t.useRef({x:0,y:0}),P=t.useRef(null),Q=t.useRef(0),O=t.useCallback(R=>{v(R),r(R)},[r]),ve=t.useCallback((R,oe,le=!1)=>{const{x:He,y:_}=S.current,_e=R-He,it=oe-_;let Qe,Ye;if(u==="xy")Qe=Math.hypot(_e,it),Ye=Qe<gr?0:1;else{const ge=u==="x"?_e:it;Qe=Math.abs(ge),Ye=Qe<gr?0:ge<0?-1:1}const rt=Q.current;let Ie=Ye;const Oe=gr+yn;Ye===0?rt!==0&&Qe<Oe?Ie=rt:(Ie=0,le||(Q.current=0)):Ye!==rt&&rt!==0&&Qe<Oe?Ie=rt:Q.current=Ye,O({active:le||Qe>=gr,offsetX:_e,offsetY:it,distance:Qe,direction:Ie,pointerId:y.current})},[O,u]),Se=t.useCallback(R=>{if(R===null)return;const oe=P.current;oe?.hasPointerCapture(R)&&oe.releasePointerCapture(R)},[]),k=t.useCallback((R=!1)=>{R&&Se(y.current),y.current=null,I.current=null,Q.current=0,O(Gr)},[O,Se]),q=t.useCallback(R=>{if(y.current!==null&&y.current!==R.pointerId){I.current={pointerId:R.pointerId,clientX:R.clientX,clientY:R.clientY},R.preventDefault(),R.stopPropagation();return}R.preventDefault(),R.stopPropagation();const oe=P.current??R.currentTarget,{left:le,top:He,width:_,height:_e}=oe.getBoundingClientRect();S.current={x:le+_/2,y:He+_e/2},y.current=R.pointerId;try{oe.setPointerCapture(R.pointerId)}catch{}ve(R.clientX,R.clientY,!0)},[ve]),ne=t.useCallback(R=>{if(y.current!==R.pointerId){I.current!==null&&I.current.pointerId===R.pointerId&&(I.current={pointerId:R.pointerId,clientX:R.clientX,clientY:R.clientY});return}R.preventDefault(),ve(R.clientX,R.clientY)},[ve]),A=t.useCallback(R=>{if(y.current!==R.pointerId){I.current!==null&&I.current.pointerId===R.pointerId&&(I.current=null);return}R.preventDefault(),R.stopPropagation();const oe=I.current;if(I.current=null,oe!==null){Se(R.pointerId);const le=P.current;let He=!0;if(le!==null&&typeof le.setPointerCapture=="function")try{le.setPointerCapture(oe.pointerId)}catch(_){(typeof _=="object"&&_!==null&&"name"in _?_.name:void 0)==="NotFoundError"&&(He=!1)}if(He){y.current=oe.pointerId,ve(oe.clientX,oe.clientY,!0);return}}k(!0)},[k,Se,ve]),C=t.useCallback(R=>{R.target===R.currentTarget&&y.current===R.pointerId&&k(!1)},[k]);t.useImperativeHandle(f,()=>({reset:()=>{k(!0)},getElement:()=>P.current}),[k]);const N=Math.min(Math.max(a,0),1),U=s/64,W=Math.min(g.distance,n)/n,$=g.direction*W*10*U;let ie;if(u==="xy"){const R=g.distance,oe=R===0?0:$*g.offsetX/R,le=R===0?0:$*g.offsetY/R;ie=`translate(${oe}px, ${le}px)`}else u==="x"?ie=`translateX(${$}px)`:ie=`translateY(${$}px)`;const ae=o??En,F={dragState:g,normalizedDistance:W,sizeScale:U,size:s,opacity:N},we={...i,width:s,height:s,transform:ie};return we.opacity=N,D.jsx("div",{ref:P,"data-testid":"virtual-scroll-tap-circle",className:Mt.twMerge("aqvs-tap-scroll-circle",e),style:we,tabIndex:-1,onPointerDown:q,onPointerMove:ne,onPointerUp:A,onPointerCancel:A,onLostPointerCapture:C,role:"presentation",children:ae(F)})}));Lr.displayName="TapScrollCircle";const re=(r,e,n)=>Math.max(e,Math.min(n,r)),Pr=(r,e)=>{const n=e==="x",s=r.getBoundingClientRect(),i=n?s.width:s.height,a=v=>{const y=Number.parseFloat(v);return Number.isFinite(y)?y:0},o=window.getComputedStyle(r),u=a(n?o.width:o.height),f=u>0?u+a(n?o.paddingLeft:o.paddingTop)+a(n?o.paddingRight:o.paddingBottom)+a(n?o.borderLeftWidth:o.borderTopWidth)+a(n?o.borderRightWidth:o.borderBottomWidth):0,g=f>0?f:n?r.offsetWidth:r.offsetHeight;return g<=0||i<=0?1:i/g},lr="virtualscroll:tap-scroll-cancel",Zr=20,Tn=250,Cn=60,Pn=20,Nn=20,_r={maxDistance:240,minSpeedMultiplier:.2},zn=_r.maxDistance,Kr={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},Ir=2.2,kn=8,Vn=120,ln=1/10,Ft={enabled:!0,size:40,offsetX:-80,offsetY:0,className:void 0,maxVisualDistance:zn,minSpeedMultiplier:_r.minSpeedMultiplier,opacity:.9,renderVisual:void 0,maxSpeedCurve:void 0},An=r=>r?{mainSizeKey:"width",crossSizeKey:"height",positionKey:"left",selectDelta:(e,n)=>e,getPointerCoordinate:({clientX:e})=>e,arrowLabels:["Scroll left","Scroll right"],arrowIcons:["◀","▶"],directionClass:"aqvs-scrollbar-horizontal",orientation:"horizontal"}:{mainSizeKey:"height",crossSizeKey:"width",positionKey:"top",selectDelta:(e,n)=>n,getPointerCoordinate:({clientY:e})=>e,arrowLabels:["Scroll up","Scroll down"],arrowIcons:["▲","▼"],directionClass:"aqvs-scrollbar-vertical",orientation:"vertical"},Nr=(r,e)=>{const n=r?.maxSpeedMultiplier,s=typeof n=="number"?n:cn(e);return{enabled:r?.enabled??Ft.enabled,size:r?.size??Ft.size,offsetX:r?.offsetX??Ft.offsetX,offsetY:r?.offsetY??Ft.offsetY,className:r?.className??Ft.className,maxVisualDistance:r?.maxVisualDistance??Ft.maxVisualDistance,maxSpeedMultiplier:s,minSpeedMultiplier:Math.max(r?.minSpeedMultiplier??Ft.minSpeedMultiplier,0),opacity:re(r?.opacity??Ft.opacity,0,1),renderVisual:r?.renderVisual??Ft.renderVisual,maxSpeedCurve:r?.maxSpeedCurve??Ft.maxSpeedCurve}},Dn=({isDragging:r,isThumbHovered:e,enableThumbDrag:n})=>t.useMemo(()=>n?r?"dragging":e?"hover":"idle":"disabled",[n,r,e]),Ln=({canUseArrowButtons:r,enableArrowButtons:e,resetTapScroll:n,scrollByStep:s})=>{const i=t.useRef(null),a=t.useRef(null),o=t.useRef(null),u=t.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null),a.current!==null&&(window.clearTimeout(a.current),a.current=null),o.current!==null&&(window.removeEventListener("pointerup",o.current),window.removeEventListener("pointercancel",o.current),window.removeEventListener("blur",o.current),o.current=null)},[]),f=t.useCallback(()=>{u()},[u]),g=t.useCallback(y=>I=>{if(!r)return;I.cancelable&&I.preventDefault(),I.stopPropagation(),n(),u(),s(y),a.current=window.setTimeout(()=>{i.current=window.setInterval(()=>{s(y)},Cn)},Tn);const S=()=>u();o.current=S,window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S),window.addEventListener("blur",S)},[r,u,n,s]),v=t.useCallback(y=>I=>{e&&(I.key==="Enter"||I.key===" "||I.key==="Spacebar")&&(I.preventDefault(),s(y))},[e,s]);return t.useEffect(()=>{r||u()},[r,u]),t.useEffect(()=>()=>{u()},[u]),{handleArrowPointerDown:g,handleArrowPointerUp:f,handleArrowKeyDown:v}},_n=700,Ut=(r,e)=>typeof r=="number"&&Number.isFinite(r)?r:e,Sr=({distance:r,maxDistance:e,viewportSize:n,minSpeedMultiplier:s,maxSpeedMultiplier:i,hasCustomMaxSpeedMultiplier:a,curve:o})=>{const u=Math.max(Ut(r,0),0),f=Ut(e,0),g=f>0?Math.min(u,f)/f:1,v=Math.max(Ut(n,0),0),y=Math.max(Ut(s,0),0),I=Math.max(Ut(i,0),0),S=Math.max(v*y,40),P=a?S:1200,Q=Math.max(v*I,P),O=o?Math.max(Ut(o.exponentialScale,I),0):0,ve=o?Math.min(Q,Math.max(v*O,S)):Q,Se=Math.max(ve,S);let k=g**1.1;if(o){const ne=Math.min(Math.max(Ut(o.exponentialSteepness,0),0),_n);if(ne===0)k=g;else{const A=Math.expm1(ne)||1;k=Math.min(Math.max(Math.expm1(ne*g)/A,0),1)}}const q=Math.min(Math.max(Ut(o?.easedOffset,0),0),1);return S+(Se-S)*(q+(1-q)*k)},cn=r=>{if(!r||r<=0)return Ir;const e=Math.max(1,r),n=Math.log10(e),s=Ir+n*kn;return re(s,Ir,Vn)},Or=({contentSize:r,viewportSize:e,scrollPosition:n,onScroll:s,enableThumbDrag:i=!0,enableTrackClick:a=!0,enableArrowButtons:o=!0,horizontal:u=!1,enableHorizontalTapCircle:f=!1,stretchMainSize:g=!1,scrollBarWidth:v=12,className:y,ariaControls:I,tapScrollCircleOptions:S,itemCount:P,renderThumbOverlay:Q,visibleStartIndex:O,visibleEndIndex:ve})=>{const[Se,k]=t.useState(!1),[q,ne]=t.useState(!1),[A,C]=t.useState(!1),N=t.useRef(null),U=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null}),W=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}),$=t.useRef(n),ie=t.useRef(s),ae=t.useRef(Kr),F=t.useRef(null),we=t.useRef(null),R=t.useRef(null),oe=t.useRef(0),le=t.useRef(0),He=t.useMemo(()=>Nr(S,P),[P,S]),_=t.useMemo(()=>An(u),[u]),{enabled:_e,size:it,offsetX:Qe,offsetY:Ye,className:rt,maxVisualDistance:Ie,maxSpeedMultiplier:Oe,minSpeedMultiplier:ge,opacity:ue,renderVisual:Pe,maxSpeedCurve:G}=He,Ue=t.useRef({viewportSize:e,maxScrollPosition:Math.max(r-e,0),scrollBarVisible:r>e,effectiveTapMaxDistance:Math.max(Ie,1),tapCircleMaxSpeedMultiplier:Oe,tapCircleMinSpeedMultiplier:ge,tapCircleMaxSpeedCurve:G,tapScrollCircleOptions:S,effectiveTrackLength:0,onScroll:s,scrollPosition:n}),{mainSizeKey:ee,crossSizeKey:We,positionKey:he,selectDelta:V,getPointerCoordinate:Z,arrowLabels:Xe,arrowIcons:M,directionClass:ht,orientation:Ge}=_,ft=Math.max(Ie,1),nt=e/r,St=Math.max(e-v*2,0),m=nt*St,H=Math.min(Math.max(Zr,m||0),St||Zr),se=Math.max(r-e,0),te=Math.max(St-H,0),de=se<=0||te<=0?0:re(n/se*te,0,te),pe=de+H/2,be=r>e||Se,Re=be&&o;t.useLayoutEffect(()=>{Ue.current={viewportSize:e,maxScrollPosition:se,scrollBarVisible:be,effectiveTapMaxDistance:ft,tapCircleMaxSpeedMultiplier:Oe,tapCircleMinSpeedMultiplier:ge,tapCircleMaxSpeedCurve:G,tapScrollCircleOptions:S,effectiveTrackLength:te,onScroll:s,scrollPosition:n}}),t.useLayoutEffect(()=>{$.current=n},[n]),t.useLayoutEffect(()=>{ie.current=s},[s]),t.useEffect(()=>{i||ne(!1)},[i]);const Ve=Dn({isDragging:Se,isThumbHovered:q,enableThumbDrag:i}),fe=t.useCallback((d,T)=>{const L=Ue.current,J=T??$.current;if(ie.current){const Le=ie.current(d,J);if(typeof Le=="number"&&Number.isFinite(Le))return $.current=Le,Le}const Ce=typeof d=="function"?d(J):d,Be=Math.max(L.maxScrollPosition,0),gt=L.scrollBarVisible?re(Ce,0,Be):0;return $.current=gt,gt},[]),at=t.useCallback(d=>{const T=Ue.current,L=$.current;if(!T.scrollBarVisible||T.maxScrollPosition<=0){const mt=fe(0,L),Nt=mt-L;return{nextPosition:mt,actualDelta:Nt,reachedBoundary:!0}}if(d===0)return{nextPosition:L,actualDelta:0,reachedBoundary:!1};const Ce=fe(mt=>re(mt+d,0,T.maxScrollPosition),L),Be=Ce-L,gt=d<0&&L+d<=0,Le=d>0&&L+d>=T.maxScrollPosition,Pt=d<0&&(Ce<=0||gt&&Be===0)||d>0&&(Ce>=T.maxScrollPosition||Le&&Be===0);return{nextPosition:Ce,actualDelta:Be,reachedBoundary:Pt}},[fe]),ot=t.useCallback((d,T)=>{d.current+=T;const L=Math.max(Ue.current.maxScrollPosition,0);L>0&&(d.current=re(d.current,-L,L));const J=at(d.current);return d.current-=J.actualDelta,J.reachedBoundary&&(d.current=0),J},[at]),ye=t.useCallback(()=>{we.current!==null&&(window.cancelAnimationFrame(we.current),we.current=null),R.current=null,oe.current=0,le.current=0},[]),qe=t.useCallback(()=>{ae.current={...Kr},C(!1),F.current?.reset(),ye()},[ye]),Ze=t.useCallback(d=>{const T=ae.current,L=Ue.current;if(!T.active||T.direction===0){ye();return}if(!L.scrollBarVisible||L.maxScrollPosition<=0){ye();return}const J=R.current??d,Ce=Math.max((d-J)/1e3,0),Be=Math.min(Ce,ln);if(R.current=d,Be<=0){we.current=window.requestAnimationFrame(Ze);return}const gt=Sr({distance:T.distance,maxDistance:L.effectiveTapMaxDistance,viewportSize:L.viewportSize,minSpeedMultiplier:L.tapCircleMinSpeedMultiplier,maxSpeedMultiplier:L.tapCircleMaxSpeedMultiplier,hasCustomMaxSpeedMultiplier:typeof L.tapScrollCircleOptions?.maxSpeedMultiplier=="number",curve:L.tapCircleMaxSpeedCurve});le.current!==T.direction&&(le.current=T.direction,oe.current=0);const{reachedBoundary:Le}=ot(oe,T.direction*gt*Be);if(Le){ye();return}we.current=window.requestAnimationFrame(Ze)},[ot,ye]),Je=t.useCallback(()=>{we.current===null&&(R.current=null,oe.current=0,we.current=window.requestAnimationFrame(Ze))},[Ze]);t.useEffect(()=>{const d=ae.current;!d.active||d.direction===0||Je()},[r,e,Je]),t.useEffect(()=>()=>{ye()},[ye]);const me=t.useCallback(d=>{ae.current=d,C(d.active),d.active&&d.direction!==0?Je():ye()},[Je,ye]);t.useEffect(()=>{_e||qe()},[qe,_e]),t.useEffect(()=>{const d=T=>{const J=T.detail?.paneId;J&&I&&J!==I||qe()};return window.addEventListener(lr,d),()=>{window.removeEventListener(lr,d)}},[I,qe]),t.useEffect(()=>{if(!_e)return;const d=T=>{if(!ae.current.active||ae.current.pointerId===T.pointerId)return;const L=T.target;if(!(L instanceof Node)){qe();return}F.current?.getElement()?.contains(L)||qe()};return document.addEventListener("pointerdown",d,!0),()=>{document.removeEventListener("pointerdown",d,!0)}},[qe,_e]);const Me=d=>{if(!be||te<=0||se<=0)return 0;const T=re(d,0,te);return re(T/te*se,0,se)},pt=t.useCallback(d=>{const{scrollBarVisible:T,effectiveTrackLength:L,maxScrollPosition:J}=Ue.current;if(z.debug("[ScrollBar] calculateScrollPositionFromThumb",()=>({thumbPos:d,trackLen:L,maxScroll:J})),L<=0||J<=0)return null;const Ce=re(d,0,L);return re(Ce/L*J,0,J)},[]),p=t.useCallback(d=>Pr(d,u?"x":"y"),[u]),E=t.useCallback(d=>{const T=U.current;if(T.pointerId!==d.pointerId)return;const L=d.clientX-T.startClientX,J=d.clientY-T.startClientY,Ce=V(L,J)/(T.scale||1);z.debug("[ScrollBar] handleThumbPointerMove",()=>({delta:Ce,startThumbPosition:T.startThumbPosition,clientY:d.clientY,startClientY:T.startClientY,metrics:Ue.current}));const Be=pt(T.startThumbPosition+Ce);Be!==null&&fe(Be),d.cancelable&&d.preventDefault()},[V,pt,fe]),Ne=t.useCallback(d=>{const T=U.current;if(T.pointerId!==d.pointerId)return;document.removeEventListener("pointermove",E),document.removeEventListener("pointerup",Ne),document.removeEventListener("pointercancel",Ne);const L=T.captureTarget;if(L?.hasPointerCapture?.(d.pointerId)&&L.releasePointerCapture(d.pointerId),U.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null},k(!1),N.current){const J=N.current.getBoundingClientRect();d.clientX>=J.left&&d.clientX<=J.right&&d.clientY>=J.top&&d.clientY<=J.bottom||ne(!1)}else ne(!1)},[E]);t.useEffect(()=>()=>{document.removeEventListener("pointermove",E),document.removeEventListener("pointerup",Ne),document.removeEventListener("pointercancel",Ne)},[E,Ne]);const st=t.useRef(0),Fe=t.useRef(0),wt=t.useCallback(d=>{const T=Math.max(Math.round(Ue.current.viewportSize/Nn),Pn);Fe.current!==d&&(Fe.current=d,st.current=0),ot(st,d*T)},[ot]),{handleArrowPointerDown:Ae,handleArrowPointerUp:lt,handleArrowKeyDown:De}=Ln({canUseArrowButtons:Re,enableArrowButtons:o,resetTapScroll:qe,scrollByStep:wt}),Xt=d=>{if(!be)return;if(!i){d.preventDefault(),d.stopPropagation();return}if(d.pointerType==="mouse"&&d.button!==0||d.ctrlKey)return;qe();const T=d.currentTarget,L=p(T);let J=null;if(T.setPointerCapture)try{T.setPointerCapture(d.pointerId),J=T}catch{J=null}U.current={pointerId:d.pointerId,startThumbPosition:de,startClientX:d.clientX,startClientY:d.clientY,scale:L,captureTarget:J},document.addEventListener("pointermove",E),document.addEventListener("pointerup",Ne),document.addEventListener("pointercancel",Ne),k(!0),ne(!0),d.preventDefault(),d.stopPropagation()},qt=d=>{if(!be)return;if(!a){d.preventDefault(),d.stopPropagation();return}if(d.pointerType==="mouse"&&d.button!==0||d.ctrlKey)return;const T=d.currentTarget,L=T.getBoundingClientRect(),J=Z(d),Ce=p(T),Be=(J-(u?L.left:L.top))/Ce;qe();const gt=Be-H/2,Le=Me(gt);if(fe(Le),T.setPointerCapture)try{T.setPointerCapture(d.pointerId)}catch{}W.current={pointerId:d.pointerId,startThumbPosition:gt,startClientX:d.clientX,startClientY:d.clientY,scale:Ce},d.preventDefault(),d.stopPropagation()},Tt=()=>{W.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}},Te=d=>{const T=W.current;if(T.pointerId!==d.pointerId)return;if(d.pointerType==="mouse"&&d.buttons===0){Tt();return}const L=d.clientX-T.startClientX,J=d.clientY-T.startClientY,Ce=V(L,J)/(T.scale||1),Be=Me(T.startThumbPosition+Ce);fe(Be),d.cancelable&&d.preventDefault()},It=d=>{if(W.current.pointerId!==d.pointerId)return;const T=d.currentTarget;T.hasPointerCapture?.(d.pointerId)&&T.releasePointerCapture(d.pointerId),Tt(),d.preventDefault(),d.stopPropagation()},Gt=d=>{if(W.current.pointerId!==d.pointerId)return;const T=d.currentTarget;T.hasPointerCapture?.(d.pointerId)&&T.releasePointerCapture(d.pointerId),Tt()},ze=d=>{d.target===d.currentTarget&&W.current.pointerId===d.pointerId&&Tt()},Rt=t.useMemo(()=>re((A?1:.8)*ue,0,1),[A,ue]),Ct=t.useMemo(()=>{const T=`calc(50% - ${it/2}px + ${Ye}px)`;return{left:Qe,top:T}},[Qe,Ye,it]),At=(d,T,L,J)=>D.jsx("button",{type:"button",tabIndex:0,className:"aqvs-scrollbar-arrow-button",style:{[ee]:v,[We]:v},"aria-label":T,onPointerDown:Ae(d),onPointerUp:lt,onPointerLeave:lt,onPointerCancel:lt,onKeyDown:De(d),"aria-disabled":!o,disabled:!Re,children:D.jsx("span",{"aria-hidden":"true",children:L})},J),et=Q&&be?{orientation:Ge,scrollPosition:n,maxScrollPosition:se,contentSize:r,viewportSize:e,thumbSize:H,thumbPosition:de,thumbCenter:pe,trackSize:St,isDragging:Se,isTapScrollActive:A,visibleStartIndex:O,visibleEndIndex:ve}:null;return D.jsxs("div",{className:Mt.twMerge("aqvs-scrollbar",ht,y),style:{...g&&!u?{}:{[ee]:e},[We]:v},"data-visible":be?"true":"false",role:"scrollbar",tabIndex:-1,"aria-controls":I,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":se,"aria-orientation":u?"horizontal":"vertical",children:[(!u||f)&&be&&_e&&D.jsx(Lr,{axis:u?"x":"y",ref:F,className:Mt.twMerge("aqvs-scrollbar-tap-circle-wrapper",rt),size:it,maxVisualDistance:ft,style:Ct,opacity:Rt,renderVisual:Pe,onDragChange:me},"tap-circle"),At(-1,Xe[0],M[0],"arrow-start"),D.jsxs("div",{className:"aqvs-scrollbar-track",style:{borderRadius:v/2},onPointerDown:qt,onPointerMove:Te,onPointerUp:It,onPointerCancel:Gt,onLostPointerCapture:ze,"aria-disabled":!a,children:[et&&D.jsx("div",{className:"aqvs-scrollbar-overlay","aria-hidden":!0,children:Q?.(et)},"overlay"),D.jsx("div",{className:"aqvs-scrollbar-thumb-wrapper",style:{[ee]:H,[he]:de,...u?{top:0,bottom:0}:{left:0,right:0}},"data-visible":be||Se?"true":"false",onPointerDown:Xt,role:"slider","aria-orientation":u?"horizontal":"vertical","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":se,"aria-disabled":!i,tabIndex:-1,children:D.jsx("div",{ref:N,className:Mt.twMerge("aqvs-scrollbar-thumb",u?"aqvs-scrollbar-thumb-horizontal":"aqvs-scrollbar-thumb-vertical"),"data-testid":"aqvs-scrollbar-thumb","data-thumb-state":Ve,style:{borderRadius:v-1,cursor:i?"pointer":"default"},onMouseEnter:()=>{i&&ne(!0)},onMouseLeave:()=>{i&&ne(!1)}},"thumb")},"thumb-wrapper")]},"track"),At(1,Xe[1],M[1],"arrow-end")]})},un=({offsetX:r,offsetY:e,maxDistance:n,x:s,y:i})=>{const a=Number.isFinite(r)?r:0,o=Number.isFinite(e)?e:0,u=Math.hypot(a,o);if(u===0)return{x:0,y:0};const f=Sr({distance:u,maxDistance:n,viewportSize:s.viewportSize,minSpeedMultiplier:s.minSpeedMultiplier,maxSpeedMultiplier:s.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:s.hasCustomMaxSpeedMultiplier,curve:s.curve}),g=Sr({distance:u,maxDistance:n,viewportSize:i.viewportSize,minSpeedMultiplier:i.minSpeedMultiplier,maxSpeedMultiplier:i.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:i.hasCustomMaxSpeedMultiplier,curve:i.curve});return{x:f*a/u,y:g*o/u}},On=r=>{const{quantum:e,resetOnDirectionChange:n=!0}=r;if(!(Number.isFinite(e)&&e>0))throw new TypeError(`[createResidualQuantizer] quantum must be a finite positive number, received ${e}`);let s=0;return{push:i=>{if(!Number.isFinite(i)||Math.abs(i)>Number.MAX_SAFE_INTEGER)return 0;n&&s!==0&&i!==0&&Math.sign(i)!==Math.sign(s)&&(s=0),s+=i;const a=Math.trunc(s/e)*e+0;return s-=a,a},peekResidue:()=>s,reset:()=>{s=0}}},Fn=16,Qr=(r,e,n)=>e===1?r*Fn:e===2?r*n:r,Hn=(r,e)=>{const n=r.shiftKey&&r.deltaX===0,s=n?r.deltaY:r.deltaX,i=n?0:r.deltaY,a=s!==0&&Math.abs(s)>=Math.abs(i);return{isZoomGesture:r.ctrlKey,isHorizontalDominant:a,horizontalDelta:Qr(s,r.deltaMode,e),verticalDelta:Qr(i,r.deltaMode,e)}},dn=new WeakSet,Jr=r=>{dn.add(r)},Xn=r=>dn.has(r),qn=["mouse","pen","touch"],yr=(r,e)=>!(r==="mouse"||r==="pen"||r==="touch")||e.includes(r),$n=r=>r==="mouse"||r==="pen",ar={maxVelocity:6,minVelocity:.02,deceleration:.0025,velocitySampleWindow:90,startVelocityThreshold:.04},br=(r,e,n)=>{for(const[s,i,a]of e)n==="add"?r.addEventListener(s,i,a):r.removeEventListener(s,i,a)},fn=t.forwardRef(({children:r,contentSize:e,viewportSize:n,onViewportSizeChange:s,scrollBarWidth:i=12,enableThumbDrag:a=!0,enableTrackClick:o=!0,enableArrowButtons:u=!0,enablePointerDrag:f=!0,pointerDragInputs:g=qn,onScroll:v,className:y,testId:I,style:S,background:P,tapScrollCircleOptions:Q,inertiaOptions:O,itemCount:ve,renderThumbOverlay:Se,wheelSpeedMultiplier:k=1,overscrollBehavior:q="auto",onWheelHorizontal:ne,onPanHorizontal:A,contentInsets:C,visibleStartIndex:N,visibleEndIndex:U,renderOverlay:W,initialScrollPosition:$=0,contentProps:ie},ae)=>{const F=t.useRef(Number.isFinite($)?Math.max(0,$):0),we=t.useRef(null),R=t.useRef(null),oe=n===void 0,[le,He]=t.useState(0),_=n??le,_e=t.useRef(null);t.useLayoutEffect(()=>{if(!oe)return;const m=R.current;if(!m)return;const H=()=>{const te=m.offsetHeight;if(te>0){He(de=>de===te?de:te);return}m.offsetParent!==null&&e>0&&_e.current!=="zero"&&(_e.current="zero",z.warn("[ScrollPane] The self-measured viewport is 0px. Give the scroll pane's host element a definite height (e.g. h-full, flex-1 + min-h-0, an explicit px height), or pass viewportSize explicitly."))};if(H(),typeof ResizeObserver!="function")return;const se=new ResizeObserver(H);return se.observe(m),()=>{se.disconnect()}},[e,oe]),t.useLayoutEffect(()=>{oe&&s?.(le)},[oe,le,s]),t.useLayoutEffect(()=>{if(oe)return;const m=we.current;if(!m)return;const H=()=>{const te=m.clientHeight;if(te<=0||Math.abs(te-_)<=1)return;const de=`${_}/${te}`;_e.current!==de&&(_e.current=de,z.warn(`[ScrollPane] viewportSize=${_} but the host band is ${te}px. The clip window, max scroll position, thumb mapping, rendered row count and scrollability all derive from viewportSize, so they are now wrong. Omit viewportSize to let the pane measure itself.`))};if(H(),typeof ResizeObserver!="function")return;const se=new ResizeObserver(H);return se.observe(m),()=>{se.disconnect()}},[oe,_]);const it=t.useRef(ne);t.useEffect(()=>{it.current=ne},[ne]);const Qe=t.useRef(A);t.useEffect(()=>{Qe.current=A},[A]);const Ye=t.useRef({frame:null,velocity:0,lastTimestamp:null,generation:0}),rt=t.useMemo(()=>({maxVelocity:O?.maxVelocity??ar.maxVelocity,minVelocity:O?.minVelocity??ar.minVelocity,deceleration:O?.deceleration??ar.deceleration,velocitySampleWindow:O?.velocitySampleWindow??ar.velocitySampleWindow,startVelocityThreshold:O?.startVelocityThreshold??ar.startVelocityThreshold}),[O]),Ie=t.useMemo(()=>({top:Math.max(0,C?.top??0),bottom:Math.max(0,C?.bottom??0)}),[C]);z.debug("[ScrollPane] ScrollPane rendered",()=>({contentSize:e,viewportSize:_,scrollBarWidth:i,className:y,style:S,tapScrollCircleOptions:Q,inertiaOptions:O,enablePointerDrag:f,contentInsets:Ie}));const Oe=t.useRef({contentSize:e,viewportSize:_}),ge=t.useMemo(()=>e>_,[e,_]),ue=t.useCallback((m,H)=>{let se=H??Oe.current;H&&!(Number.isFinite(H.contentSize)&&Number.isFinite(H.viewportSize))&&(z.warn("[ScrollPane] scrollTo received non-finite dimsOverride; falling back to the committed dims",{dimsOverride:H}),se=Oe.current);const{contentSize:te,viewportSize:de}=se,pe=te>de,be=F.current;if(z.debug("[ScrollPane] scrollTo called",()=>({newPosition:m,contentSize:te,viewportSize:de,currentIsScrollable:pe,prevPosition:be})),!pe)return F.current!==0&&(F.current=0,v?.(0,be)),F.current;const Re=typeof m=="function"?m(F.current):m;if(!Number.isFinite(Re))return z.warn("[ScrollPane] scrollTo received a non-finite position; keeping the current position",{nextPosition:Re}),F.current;const Ve=Math.max(te-de,0),fe=re(Re,0,Ve);return F.current!==fe&&(F.current=fe,v?.(fe,be)),F.current},[v]),Pe=t.useRef(ue);t.useEffect(()=>{Pe.current=ue},[ue]);const G=t.useCallback(()=>{const m=Ye.current;m.generation+=1,m.frame!==null&&cancelAnimationFrame(m.frame),m.frame=null,m.velocity=0,m.lastTimestamp=null},[]),Ue=t.useRef(G);t.useEffect(()=>{Ue.current=G},[G]),t.useEffect(()=>()=>{Ue.current()},[]);const ee=t.useCallback(m=>{if(!ge)return;const{maxVelocity:H,minVelocity:se,deceleration:te,startVelocityThreshold:de}=rt,pe=re(m,-H,H);if(Math.abs(pe)<de)return;G(),Ye.current.velocity=pe,Ye.current.lastTimestamp=null;const be=Ye.current.generation,Re=Ve=>{const fe=Ye.current;if(fe.generation!==be)return;if(fe.lastTimestamp===null){fe.lastTimestamp=Ve,fe.frame=requestAnimationFrame(Re);return}const at=Ve-fe.lastTimestamp;if(fe.lastTimestamp=Ve,at<=0){fe.frame=requestAnimationFrame(Re);return}const ot=fe.velocity;let ye=ot;const qe=te*at;ot>0?ye=Math.max(0,ot-qe):ot<0&&(ye=Math.min(0,ot+qe));const Je=(ot+ye)/2*at,me=F.current;if(Je!==0&&Pe.current(st=>st+Je),Ye.current.generation!==be)return;const Me=F.current,{contentSize:pt,viewportSize:p}=Oe.current,E=Math.max(pt-p,0);fe.velocity=ye;const Ne=Me===me||Me<=0&&ye<=0||Me>=E&&ye>=0;if(Math.abs(ye)<se||Ne){G();return}fe.frame=requestAnimationFrame(Re)};Ye.current.frame=requestAnimationFrame(Re)},[ge,rt,G]),We=t.useRef(ee);t.useEffect(()=>{We.current=ee},[ee]),t.useLayoutEffect(()=>{Oe.current={contentSize:e,viewportSize:_}},[e,_]),t.useLayoutEffect(()=>{const m=R.current;if(!m)return;const H=()=>{m.scrollTop!==0&&(z.debug("[ScrollPane] Native scroll detected, resetting to 0",()=>({scrollTop:m.scrollTop})),m.scrollTop=0),m.scrollLeft!==0&&(m.scrollLeft=0)};return m.addEventListener("scroll",H),()=>m.removeEventListener("scroll",H)},[]),t.useLayoutEffect(()=>{if(ge){z.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change",()=>({contentSize:e,viewportSize:_,scrollPosition:F.current}));const m=re(e-_,0,e);F.current>m&&ue(m)}else ue(0)},[ge,ue,e,_]);const he=t.useRef({isScrollable:ge,viewportSize:_,wheelSpeedMultiplier:k,overscrollBehavior:q});t.useLayoutEffect(()=>{he.current={isScrollable:ge,viewportSize:_,wheelSpeedMultiplier:k,overscrollBehavior:q}},[ge,_,k,q]);const V=t.useCallback(m=>{if(Xn(m))return!1;const{isScrollable:H,viewportSize:se,wheelSpeedMultiplier:te,overscrollBehavior:de}=he.current,pe=Hn(m,se);if(pe.isZoomGesture)return!1;if(pe.isHorizontalDominant)return it.current?(Jr(m),m.preventDefault(),G(),it.current(pe.horizontalDelta),!0):!1;if(!H||pe.verticalDelta===0)return!1;let be=pe.verticalDelta;if(te!==1&&(be*=te),de!=="contain"){const Re=F.current,Ve=Math.max(Oe.current.contentSize-se,0);if(be>0&&Re>=Ve||be<0&&Re<=0)return!1}return Jr(m),m.preventDefault(),G(),z.debug("[ScrollPane] wheel event",()=>({deltaY:be,scrollPosition:F.current,wheelSpeedMultiplier:te,deltaMode:m.deltaMode,scrollTop:R.current?.scrollTop})),ue(Re=>Re+be),!0},[ue,G]);t.useEffect(()=>{const m=te=>{V(te)},H=()=>{G()},se=we.current;return se&&(se.addEventListener("wheel",m,{passive:!1}),se.addEventListener("pointerdown",H,{capture:!0,passive:!0})),()=>{se&&(se.removeEventListener("wheel",m),se.removeEventListener("pointerdown",H,{capture:!0}))}},[V,G]),t.useImperativeHandle(ae,()=>({scrollTo:(m,H)=>(G(),ue(m,H)),getScrollPosition:()=>F.current,getContentSize:()=>e,getViewportSize:()=>_,applyWheel:V}),[ue,e,_,G,V]);const Z=t.useId(),Xe=ie?.id??Z,M=t.useRef({pointerType:"",pointerId:null,startClientY:0,startClientX:0,lastPanClientX:0,startScroll:0,isDragging:!1,shouldCancelNextClick:!1,clickResetTimer:null,velocitySamples:[],scale:1,scaleX:1}),ht=t.useRef(f),Ge=t.useRef(g);t.useEffect(()=>{ht.current=f},[f]),t.useEffect(()=>{Ge.current=g},[g]);const ft=t.useRef(ge);t.useEffect(()=>{ft.current=ge},[ge]);const nt=t.useRef(rt);t.useEffect(()=>{nt.current=rt},[rt]),t.useEffect(()=>{const m=M.current;if(f&&ge&&(m.pointerId===null||yr(m.pointerType,g))||m.pointerId===null)return;const H=R.current;m.clickResetTimer!==null&&(window.clearTimeout(m.clickResetTimer),m.clickResetTimer=null);const se=m.isDragging&&m.shouldCancelNextClick,te=m.pointerId;m.pointerId=null,m.pointerType="",m.startClientY=0,m.startScroll=0,m.isDragging=!1,m.shouldCancelNextClick=se,m.velocitySamples=[],m.scale=1,H?.hasPointerCapture(te)&&H.releasePointerCapture(te)},[f,g,ge]),t.useEffect(()=>{const m=R.current;if(!m)return;const H=6,se=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),te=()=>{const p=M.current;p.pointerId=null,p.pointerType="",p.startClientY=0,p.startScroll=0,p.isDragging=!1,p.velocitySamples=[],p.scale=1},de=()=>{const p=M.current;p.clickResetTimer!==null&&(window.clearTimeout(p.clickResetTimer),p.clickResetTimer=null)},pe=p=>{const E=M.current,Ne=se();E.velocitySamples.push({clientY:p,time:Ne});const st=nt.current.velocitySampleWindow;E.velocitySamples=E.velocitySamples.filter(Fe=>Ne-Fe.time<=st)},be=p=>p instanceof HTMLElement&&p.closest("[data-scrollpane-ignore-drag='true']")!==null,Re=p=>{const E=M.current;E.shouldCancelNextClick&&(p.preventDefault(),p.stopPropagation(),E.shouldCancelNextClick=!1)},Ve=p=>{const E=M.current;if(!E.isDragging){if(E.isDragging=!0,E.shouldCancelNextClick=!0,!m.hasPointerCapture(p.pointerId))try{m.setPointerCapture(p.pointerId)}catch{}pe(p.clientY)}},fe=p=>p.isTrusted||p.target===m,at=p=>{const E=M.current;m.hasPointerCapture(p)&&m.releasePointerCapture(p),E.shouldCancelNextClick=!1,de(),te()},ot=p=>{const E=M.current;if(E.pointerId!==p.pointerId)return;if(p.buttons===0&&$n(p.pointerType)){at(p.pointerId);return}if(!(ht.current&&ft.current)||!yr(p.pointerType,Ge.current))return;if(!E.isDragging){const wt=Math.abs(p.clientY-E.startClientY),Ae=Qe.current?Math.abs(p.clientX-E.startClientX):0;if(Math.max(wt,Ae)<H||(Ve(p),!E.isDragging))return}pe(p.clientY);const Ne=(p.clientY-E.startClientY)/(E.scale||1),st=E.startScroll-Ne;Pe.current(st);const Fe=Qe.current;if(Fe){const wt=p.clientX-E.lastPanClientX;E.lastPanClientX=p.clientX,wt!==0&&Fe(-wt/(E.scaleX||1))}p.cancelable&&p.preventDefault()},ye=()=>{const p=M.current;return p.pointerId!==null||!p.shouldCancelNextClick?!1:(de(),p.clickResetTimer=window.setTimeout(()=>{const E=M.current;E.shouldCancelNextClick=!1,E.clickResetTimer=null},0),!0)},qe=p=>{const E=M.current;if(E.pointerId!==p.pointerId){ye();return}E.isDragging&&E.shouldCancelNextClick&&p.cancelable&&(p.preventDefault(),p.stopPropagation()),E.isDragging&&pe(p.clientY);let Ne=0;if(E.isDragging&&E.velocitySamples.length>=2){const Fe=E.velocitySamples,wt=nt.current.velocitySampleWindow,Ae=Fe[Fe.length-1],lt=Fe.find(De=>Ae.time-De.time<=wt)??Fe[0];if(Ae&&lt&&Ae.time!==lt.time){const De=Ae.clientY-lt.clientY,Xt=Ae.time-lt.time;Ne=-(De/Xt)/(E.scale||1)}}de(),E.shouldCancelNextClick&&(E.clickResetTimer=window.setTimeout(()=>{const Fe=M.current;Fe.shouldCancelNextClick=!1,Fe.clickResetTimer=null},0));const st=nt.current.startVelocityThreshold;te(),m.hasPointerCapture(p.pointerId)&&m.releasePointerCapture(p.pointerId),Math.abs(Ne)>=st&&We.current?.(Ne)},Ze=p=>{if(M.current.pointerId!==null){if(!p.isPrimary||p.pointerType!==M.current.pointerType)return;at(M.current.pointerId)}if(M.current.shouldCancelNextClick&&(de(),M.current.shouldCancelNextClick=!1),!(ht.current&&ft.current)||!yr(p.pointerType,Ge.current)||p.button!==0&&p.pointerType==="mouse"||p.ctrlKey||p.metaKey||p.altKey||be(p.target))return;window.dispatchEvent(new CustomEvent(lr,{detail:{paneId:Z}})),Ue.current?.();const E=M.current;de(),E.pointerId=p.pointerId,E.pointerType=p.pointerType,E.startClientY=p.clientY,E.startClientX=p.clientX,E.lastPanClientX=p.clientX,E.startScroll=F.current,E.scale=Pr(m,"y"),E.scaleX=Qe.current?Pr(m,"x"):1,E.isDragging=!1,E.shouldCancelNextClick=!1,E.velocitySamples=[]},Je=p=>{if(M.current.pointerId!==p.pointerId){ye();return}fe(p)&&at(p.pointerId)},Me=[["click",Re,!0],["pointerdown",Ze,{passive:!1}],["lostpointercapture",p=>{p.target!==m||M.current.pointerId!==p.pointerId||at(p.pointerId)},void 0]],pt=[["pointermove",ot,{passive:!1}],["pointerup",qe,void 0],["pointercancel",Je,void 0]];return br(m,Me,"add"),br(window,pt,"add"),()=>{br(m,Me,"remove"),br(window,pt,"remove");const p=M.current;p.pointerId!==null&&m.hasPointerCapture(p.pointerId)&&m.releasePointerCapture(p.pointerId),de(),te()}},[Z]);const St=t.useCallback(m=>(G(),ue(m)),[ue,G]);return D.jsxs("div",{ref:we,"data-testid":I,"data-self-measured":oe?"true":void 0,className:Mt.twMerge("aqvs-scroll-pane",y),style:S,children:[D.jsxs("div",{ref:R,className:Mt.twMerge("aqvs-scroll-pane-content"),"data-testid":"aqvs-scroll-pane-content",style:{height:oe?void 0:_,paddingTop:Ie.top,paddingBottom:Ie.bottom,...f&&ge&&g.some(m=>m==="touch"||m==="pen")?{touchAction:"none"}:{}},...ie,id:Xe,children:[P,r(F.current)]}),D.jsx(Or,{contentSize:e,viewportSize:_,stretchMainSize:oe,scrollPosition:F.current,onScroll:St,enableThumbDrag:a,enableTrackClick:o,enableArrowButtons:u,scrollBarWidth:i,ariaControls:Xe,tapScrollCircleOptions:Q,itemCount:ve,renderThumbOverlay:Se,visibleStartIndex:N,visibleEndIndex:U},"scrollbar"),W?.()]})}),en=(r,e,n)=>Math.min(Math.max(r,e),n),Yn=({dragState:r,normalizedDistance:e,sizeScale:n,size:s})=>{const i=Math.max(s/2,1),a=1+e*.65,o=Math.max(.65,1-e*.25),u=r.direction*e*26*n,f=.8+e*.18,g=3*n,v=6*n,y=22*n,I=Math.abs(u)+v,S=u>0?g:-Math.abs(u)-g,P=Math.max(2.5,3*n),Q=en(r.offsetX,-i,i),O=en(r.offsetY,-i,i),ve=i*.35,Se=Q/i*ve,k=O/i*ve,q=Se*.45,ne=k*.45,A=Math.max(y*.38,6),C=.65+e*.2,N=r.active;return D.jsxs(D.Fragment,{children:[D.jsx("div",{className:"aqvs-tap-scroll-circle-gradient",style:{transform:`scale(${o}, ${a})`,transition:N?"40ms transform ease-out":"200ms ease transform"}}),D.jsx("div",{className:"aqvs-sample-visual-pupil",style:{width:y,height:y,transform:`translate(calc(-50% + ${Se}px), calc(-50% + ${k}px)) scale(${o}, ${f*a})`,transition:N?"70ms transform ease-out":"200ms ease transform"}}),D.jsx("div",{className:"aqvs-sample-visual-highlight",style:{width:A,height:A,transform:`translate(calc(-50% + ${q}px), calc(-50% + ${ne}px)) scale(${o}, ${a})`,opacity:C,boxShadow:"0 0 8px rgba(255,255,255,0.45)",transition:N?"120ms opacity 150ms, 120ms transform ease-out ease-out":"220ms ease transform, 240ms opacity ease"}}),D.jsx("div",{className:"aqvs-sample-visual-rod",style:{width:P,height:I,transform:`translate(-50%, ${S}px)`,opacity:e,transition:N?"40ms height, 60ms opacity ease-out ease-out":"200ms ease height, 120ms ease opacity"}})]})},nr=100,Wn=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},Er=(r,e)=>{if(!Number.isFinite(r))throw new Error(`valueFn returned a non-finite value at index ${e}: ${r}`);return r},sr=r=>{if(r<=0||!Number.isFinite(r))return 0;const e=Math.trunc(r);if(e<=2147483647)return e&-e;const n=BigInt(e)&-BigInt(e);return Number(n)};class Ht{tree;deltas;size;baseValue;valueFn;total;constructor(e,n,s){this.reset(e,n,s)}reset(e,n,s){const i=Number.isFinite(e)&&e>0?Math.trunc(e):0;if(typeof n!="function"){this.size=i,this.tree=new Map,this.deltas=new Map,this.valueFn=void 0,this.baseValue=n,this.total=this.baseValue*this.size;return}let a=0,o;const u=s?.baseValue;if(u!==void 0&&!(Number.isFinite(u)&&u>=0))throw new RangeError(`[FenwickMapTree] options.baseValue must be a finite number >= 0, received ${u}.`);if(i>0&&u!==void 0){if(a=u,s?.materialize){const f=s?.sampleRange??{from:0,to:Math.min(nr-1,i-1)};let g=Math.max(0,Math.trunc(f.from)),v=Math.min(Math.trunc(f.to),i-1);g>v&&(g=0,v=Math.min(nr-1,i-1)),o={from:g,values:Ht._collectValidatedValues(n,g,v)}}}else if(i>0){const f=s?.sampleRange??{from:0,to:Math.min(nr-1,i-1)};let g=Math.max(0,Math.trunc(f.from)),v=Math.min(Math.trunc(f.to),i-1);if(g>v&&(g=0,v=Math.min(nr-1,i-1)),i>nr)a=Ht._sampleBaseValueStrided(n,i,nr),s?.materialize&&(o={from:g,values:Ht._collectValidatedValues(n,g,v)});else{const y=Ht._collectValidatedValues(n,g,v);a=Ht._modeOrMedian([...y]),s?.materialize&&(o={from:g,values:y})}}if(this.size=i,this.tree=new Map,this.deltas=new Map,this.total=void 0,this.valueFn=n,this.baseValue=a,o)for(let f=0;f<o.values.length;f++){const g=o.from+f;if(g>=this.size)break;const v=o.values[f]-this.baseValue;v!==0&&(this.deltas.set(g,v),this._updateTree(g,v))}this.total=this.getTotal()}setValueFn(e,n){if(n?.reset){this.reset(this.size,e);return}typeof e=="function"?this.valueFn=e:(this.valueFn=void 0,this.baseValue=e,this.total=this._computeTreeTotal())}static _collectValidatedValues(e,n,s){const i=[];for(let a=n;a<=s;a++)i.push(Er(e(a),a));return i}static _modeOrMedian(e){if(e.length===0)return 0;e.sort((o,u)=>o-u);const n=Math.floor(e.length/2);let s;e.length%2===0?s=Math.floor((e[n-1]+e[n])/2):s=e[n];const i=new Map;let a=0;for(const o of e){const u=(i.get(o)??0)+1;i.set(o,u),u>a&&(a=u)}if(a>e.length*.2){const o=[];for(const[f,g]of i.entries())g===a&&o.push(f);const u=o.reduce((f,g)=>f+g,0);s=Math.floor(u/o.length)}return s}static _sampleBaseValueStrided(e,n,s){if(n<=0)return 0;let i=Math.max(1,Math.ceil(n/s));i%2===0&&(i+=1);const a=[];for(let o=0;o<n&&a.length<s;o+=i)a.push(Er(e(o),o));return Ht._modeOrMedian(a)}update(e,n){return this.updates([{index:e,value:n}])}updates(e){const n=this._buildDeltaUpdates(e);return n.length>0?this.updateDeltas(n):this.total}updateDelta(e,n){return this.updateDeltas([{index:e,change:n}])}updateDeltas(e){const n=new Map;for(const{index:s,change:i}of e){if(s<0||s>=this.size)throw new Error(`Index ${s} out of bounds`);if(!Number.isInteger(s))throw new Error(`Index must be an integer: ${s}`);if(!Number.isFinite(i))throw new Error(`Change must be a finite number: ${i}`);const o=(n.get(s)??this.deltas.get(s)??0)+i;if(o+this.baseValue<-1e-9)throw new Error(`Change would make the value at index ${s} negative: ${o+this.baseValue}`);n.set(s,o)}for(const{index:s,change:i}of e){const o=(this.deltas.get(s)??0)+i;o===0?this.deltas.delete(s):this.deltas.set(s,o),this._updateTree(s,i)}return this.total}_updateTree(e,n){if(n===0)return;let s=e+1;for(;s<=this.size;){this.tree.set(s,(this.tree.get(s)??0)+n);const i=sr(s);if(i===0)break;s+=i}this.total!==void 0&&(this.total+=n)}_buildDeltaUpdates(e){const n=[],s=new Map;for(const{index:i,value:a}of e){if(i<0||i>=this.size)throw new Error(`Index ${i} out of bounds`);if(!Number.isInteger(i))throw new Error(`Index must be an integer: ${i}`);if(!Number.isFinite(a))throw new Error(`Value must be a finite number: ${a}`);if(a<0)throw new Error("Value cannot be negative.");const o=s.has(i)?s.get(i)??0:this.deltas.get(i)??0,u=o+this.baseValue,f=a-u;f!==0&&n.push({index:i,change:f}),s.set(i,o+f)}return n}_computeTreeTotal(){if(this.size<=0)return 0;let e=0,n=this.size;for(;n>0;){e+=this.tree.get(n)??0;const s=sr(n);if(s===0)break;n-=s}return e+this.baseValue*this.size}_materialize(e,n=!0){if(this.valueFn){const s=this.deltas.get(e)??0,a=Er(this.valueFn(e),e)-this.baseValue;if(a!==s&&(a===0?this.deltas.delete(e):this.deltas.set(e,a),n)){const o=a-s;this._updateTree(e,o)}}}_materializeRanges(e,n,s=!1){if(!(e?.materialize&&this.valueFn))return;const i=e.ranges;if(i&&i.length>0){for(const u of i){const f=Math.max(0,Math.trunc(u.from)),g=Math.min(Math.trunc(u.to),this.size-1);for(let v=f;v<=g;v++)this._materialize(v)}if(n===void 0)return;if(s){this._materialize(n);return}const a=i[0].from,o=i[i.length-1].to;n>=a&&n<=o&&this._materialize(n);return}n!==void 0&&this._materialize(n)}_findIndex(e,n={},s){if(this.size>=1073741824)return this._findIndexLarge(e,n,s);if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};this._materializeRanges(n.materializeOption);const i=n.materializeOption?.materialize===!0;let a;for(;;){if(a=this._descend(e,s),a<0||a>=this.size)return{index:-1,total:this.total??this.getTotal(),cumulative:void 0,currentValue:void 0,safeIndex:void 0};if(!i)break;const u=this.deltas.get(a)??0;if(this._materialize(a),(this.deltas.get(a)??0)===u)break}const o=this.prefixSum(a);return{index:a,total:this.total??o.total,cumulative:o.cumulative,currentValue:o.currentValue,safeIndex:o.safeIndex}}_descend(e,n){let s=0,i=0,a=1;for(;a<<1<=this.size;)a<<=1;for(;a>0;a>>=1){const o=s+a;if(o<=this.size){const f=(this.tree.get(o)??0)+this.baseValue*a;(n?i+f<e:i+f<=e)&&(s=o,i+=f)}}return n?s:s-1}_findIndexLarge(e,n,s){if(this.size===0)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};const i=Wn(this.size);if(i===0n)return{index:-1,total:this.total??0,cumulative:void 0,currentValue:void 0,safeIndex:void 0};this._materializeRanges(n.materializeOption);const a=n.materializeOption?.materialize===!0;for(;;){let o=0n,u=i-1n,f,g,v=this.total;for(;o<=u;){const S=o+u>>1n,P=Number(S),Q=this.prefixSum(P);if(v=Q.total,s?Q.cumulative>=e:Q.cumulative<=e)if(f=S,g=Q,s){if(S===0n)break;u=S-1n}else o=S+1n;else if(s)o=S+1n;else{if(S===0n)break;u=S-1n}}const y=g,I=f!==void 0?Number(f):-1;if(a&&I>=0){const S=this.deltas.get(I)??0;if(this._materialize(I),(this.deltas.get(I)??0)!==S)continue}return{index:I,total:v,cumulative:y?.cumulative,currentValue:y?.currentValue,safeIndex:y?.safeIndex}}}prefixSum(e,n){if(e<0||Number.isNaN(e))return{cumulative:0,total:this.total,currentValue:0,safeIndex:0};if(this.size===0)return{cumulative:0,total:this.total??0,currentValue:0,safeIndex:0};const s=re(Math.trunc(e),0,this.size-1),i=n?.materializeOption;this._materializeRanges(i,s,!0);let a=0,o=s+1;for(;o>0;){const f=this.tree.get(o)??0;a+=f;const g=sr(o);if(g===0)break;o-=g}const u=i?.materialize?this.get(s):(this.deltas.get(s)||0)+this.baseValue;return{cumulative:a+this.baseValue*(s+1),total:this.total,currentValue:u,safeIndex:s}}get(e,n){if(this.size===0)return 0;if(!Number.isInteger(e)||e<0||e>=this.size)throw new Error("Index out of bounds");const s=n?.materializeOption;return this._materializeRanges(s,e),(this.deltas.get(e)??0)+this.baseValue}getTotal(e){const n=e?.materializeOption;if(this._materializeRanges(n),this.total===void 0)if(this.size===0)this.total=0;else{this.total=this._computeTreeTotal();const s=this.prefixSum(this.getSize()-1);s.cumulative!==s.total&&z.error("Inconsistent Fenwick Tree state")}return this.total}rebuildTree(e){if(e?.materialize&&this.valueFn){const s=this.valueFn;this.reset(this.size,i=>s(i),{materialize:!0});return}const n=new Map;for(const[s,i]of this.deltas.entries()){if(i===0)continue;let a=s+1;for(;a<=this.size;){n.set(a,(n.get(a)??0)+i);const o=sr(a);if(o===0)break;a+=o}}this.tree=n,this.total=this._computeTreeTotal()}calculateAccumulatedError(){if(this.total===void 0)return 0;let e=this.baseValue*this.size;for(const[n,s]of this.deltas)n<this.size&&(e+=s);return this.total-e}changeSize(e){if(!Number.isFinite(e))throw new Error(`Size must be a finite number: ${e}`);const n=Math.max(0,Math.trunc(e)),s=this.size;if(n===s)return;if(n>s)if(s===0&&this.deltas.size>0){for(const a of this.deltas.keys())a>=n&&this.deltas.delete(a);this.size=n,this.rebuildTree()}else this._growSize(s,n);else{if(n>0)for(const a of this.deltas.keys())a>=n&&this.deltas.delete(a);this.size=n,this.rebuildTree()}const i=this.prefixSum(this.getSize()-1);i.cumulative!==i.total&&z.error("Inconsistent Fenwick Tree state")}static _minCoveredLowBound(e,n){let s=1;for(;;){const i=s*2;if(Math.floor(n/i)*i<=e)break;s=i}return s*Math.floor(e/s)}_propagateDeltaToGrownNodes(e,n,s,i){let a=e+1;for(;a<=s;){const o=sr(a);if(o===0)break;a+=o}for(;a<=i;){this.tree.set(a,(this.tree.get(a)??0)+n);const o=sr(a);if(o===0)break;a+=o}}_growSize(e,n){if(this.size=n,this.deltas.size>0){const s=Ht._minCoveredLowBound(e,n);if(e-s<this.deltas.size)for(let a=s;a<e;a++){const o=this.deltas.get(a);o===void 0||o===0||this._propagateDeltaToGrownNodes(a,o,e,n)}else for(const[a,o]of this.deltas.entries())o===0||a<s||this._propagateDeltaToGrownNodes(a,o,e,n)}this.total=this._computeTreeTotal()}getSize(){return this.size}get base(){return this.baseValue}findIndexAtOrAfter(e,n){return this._findIndex(e,n??{},!0)}findIndexAtOrBefore(e,n){return this._findIndex(e,n??{},!1)}}const Bn=(r,e)=>{const n=r?.sampleRange,s=e?.sampleRange;return n===s?!1:n&&s?n.from!==s.from||n.to!==s.to:!0},Fr=(r,e,n)=>{const s=Number.isFinite(r)&&r>0?Math.trunc(r):0,i=t.useRef(null),a=t.useRef({size:s,valueOrFn:e,options:n});i.current===null&&(i.current=new Ht(s,e,n));const o=i.current,u=a.current,f=u.size!==s,g=u.valueOrFn!==e,v=Bn(u.options,n)||u.options?.baseValue!==n?.baseValue,y=u.size===0&&s>0&&(!i.current||i.current.base===0);if(g||v){const I=n?.resetOnValueFnChange??!0;v||g&&I||y?(n?.debug&&z.debug("[useFenwickMapTree] reset",{valueOrFnChanged:g,optionsChanged:v}),o.reset(s,e,n)):(f&&(n?.debug&&z.debug("[useFenwickMapTree] resize (with valueFn change)",{from:u.size,to:s}),o.changeSize(s)),n?.debug&&z.debug("[useFenwickMapTree] setValueFn (no reset)",{valueOrFnChanged:g}),o.setValueFn(e,{reset:!1})),a.current={size:s,valueOrFn:e,options:n}}else f&&(n?.debug&&z.debug("[useFenwickMapTree] resize",{from:u.size,to:s}),y?o.reset(s,e,n):o.changeSize(s),a.current={size:s,valueOrFn:e,options:n});return o};class jn{key;value;prev=null;next=null;constructor(e,n){this.key=e,this.value=n}}class Tr{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 mn(r){const e=t.useRef(new Map),n=t.useRef(new Tr),s=Math.floor(r),i=t.useRef(s);t.useEffect(()=>{if(i.current=s,Number.isNaN(s)||s<0){z.warn(`useLruCache: invalid capacity ${r}; the cache will not store any entries.`),e.current.clear(),n.current=new Tr;return}if(Number.isFinite(s))for(;e.current.size>s;){const v=n.current.removeHead();if(v)e.current.delete(v.key);else break}},[r,s]);const a=t.useCallback(v=>{const y=e.current.get(v);if(y)return n.current.moveToTail(y),y.value},[]),o=t.useCallback((v,y)=>{const I=i.current;if(Number.isNaN(I)||I<=0)return;let S=e.current.get(v);if(S)S.value=y,n.current.moveToTail(S);else{if(e.current.size>=I){const P=n.current.removeHead();P&&e.current.delete(P.key)}S=new jn(v,y),e.current.set(v,S),n.current.addToTail(S)}},[]),u=t.useCallback(v=>e.current.has(v),[]),f=t.useCallback(v=>{const y=e.current.get(v);y&&(n.current.remove(y),e.current.delete(v))},[]),g=t.useCallback(()=>{e.current.clear(),n.current=new Tr},[]);return t.useMemo(()=>({get:a,set:o,has:u,remove:f,clear:g}),[a,o,u,f,g])}const Un=1e4,Gn=()=>{const{get:r,set:e,has:n,clear:s}=mn(Un);return t.useMemo(()=>({get:r,set:e,has:n,clear:s}),[r,e,n,s])},Zn=(r,e)=>{const n=t.useRef(e),s=t.useRef(r);t.useLayoutEffect(()=>{n.current=e,s.current=r},[e,r]);const i=t.useRef(new WeakMap);return t.useCallback(a=>{if(!a||i.current.has(a))return;const o=u=>{n.current?.enableBridge!==!1&&s.current.current?.applyWheel(u)};return a.addEventListener("wheel",o,{passive:!1}),i.current.set(a,o),()=>{i.current.get(a)===o&&(a.removeEventListener("wheel",o),i.current.delete(a))}},[])},tn=-200,rn={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},Kn=r=>{const e=t.useRef(r);e.current=r;const n=t.useRef(rn),s=t.useRef(null),[i,a]=t.useState(!1),o=t.useRef(null),u=t.useRef(null),f=t.useRef({residual:0,direction:0}),g=t.useRef({residual:0,direction:0}),v=t.useCallback(()=>{o.current!==null&&(window.cancelAnimationFrame(o.current),o.current=null),u.current=null,f.current={residual:0,direction:0},g.current={residual:0,direction:0}},[]),y=t.useCallback((k,q,ne,A,C,N)=>{const U=q>0?1:q<0?-1:0;U!==0&&U!==k.direction&&(k.direction=U,k.residual=0),k.residual+=q*ne;const W=Math.max(C(),0);W>0&&(k.residual=re(k.residual,-W,W));const $=k.residual;if($===0)return{actualDelta:0,atBoundary:!1};const ie=A(),ae=N($),F=ae-ie;k.residual-=F;const we=$<0&&ie+$<=0,R=$>0&&ie+$>=W,oe=$<0&&(ae<=0||we&&F===0)||$>0&&(ae>=W||R&&F===0);return oe&&(k.residual=0),{actualDelta:F,atBoundary:oe}},[]),I=t.useCallback(k=>{const q=e.current,ne=n.current;if(!ne.active||ne.direction===0){v();return}const A=u.current??k,C=Math.max((k-A)/1e3,0),N=Math.min(C,ln);if(u.current=k,N<=0){o.current=window.requestAnimationFrame(I);return}const U=un({offsetX:ne.offsetX,offsetY:ne.offsetY,maxDistance:q.maxDistance,x:q.xSpeedParams,y:q.ySpeedParams}),W=y(f.current,U.x,N,q.getHx,q.getMaxHx,F=>q.applyHxRef.current(q.getHx()+F));W.actualDelta!==0&&(q.pendingColAnchorRef.current=null);const $=y(g.current,U.y,N,q.getVy,q.getMaxVy,q.applyVy),ie=q.getMaxHx()<=0||W.atBoundary||ne.offsetX===0,ae=q.getMaxVy()<=0||$.atBoundary||ne.offsetY===0;if(ie&&ae){v();return}o.current=window.requestAnimationFrame(I)},[v,y]),S=t.useCallback(()=>{o.current===null&&(u.current=null,f.current={residual:0,direction:0},g.current={residual:0,direction:0},o.current=window.requestAnimationFrame(I))},[I]),P=t.useCallback(()=>{n.current={...rn},a(!1),s.current?.reset(),v()},[v]),Q=t.useCallback(k=>{n.current=k,a(k.active),k.active&&k.direction!==0?S():v()},[S,v]),{enabled:O,xExtentFreshness:ve,yExtentFreshness:Se}=r;return t.useEffect(()=>{const k=n.current;!k.active||k.direction===0||S()},[ve,Se,S]),t.useEffect(()=>{const k=()=>{P()};return window.addEventListener(lr,k),()=>{window.removeEventListener(lr,k)}},[P]),t.useEffect(()=>{if(!O)return;const k=q=>{if(!n.current.active||n.current.pointerId===q.pointerId)return;const ne=q.target;if(!(ne instanceof Node)){P();return}s.current?.getElement()?.contains(ne)||P()};return document.addEventListener("pointerdown",k,!0),()=>{document.removeEventListener("pointerdown",k,!0)}},[O,P]),t.useEffect(()=>{O||P()},[O,P]),t.useEffect(()=>()=>{v()},[v]),{isTapActive:i,handleTapCircleDragChange:Q,tapCircleHandleRef:s}},je=(r,e)=>e<=0?0:re(r,0,e-1),nn=r=>({top:Math.max(0,r?.top??0),bottom:Math.max(0,r?.bottom??0)}),vt=(r,e)=>r<=e?0:r-e,Qt=(r,e)=>r<=0?0:r+e,cr=1e3,zr=2e3,hn=1048576,Qn=40,or=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},Jn=(r,e,n,s,i,a,o,u)=>{const f=or(s);if(f===0n)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const g=A=>A<0n?0n:A>=f?f-1n:A,v={materializeOption:{materialize:!1}},{index:y,cumulative:I}=a.findIndexAtOrAfter(r,v);let S;y===-1?S=f-1n:(I===r?S=or(y+1):S=or(y),S>=f&&(S=f-1n)),r<=0&&(S=0n),u&&r>=o&&(S=f-1n);const P=A=>{const C=Number(A);if(!Number.isSafeInteger(C))return null;const{cumulative:N}=a.prefixSum(C,{materializeOption:{materialize:!1}});if(!Number.isFinite(N))return null;const{index:U}=a.findIndexAtOrAfter(N+.5,{materializeOption:{materialize:!1}});if(U===-1)return null;const W=or(U);return W>A?W:null},Q=A=>{let C=0,N=A,U=A,W=0n,$=0;for(;N<f&&C<e;){const ie=Number(N),ae=i(ie);if(C+=ae,U=N,N+=1n,W+=1n,!Number.isFinite(ae)||ae<0)break;if(ae===0){if($+=1,$>cr){const F=P(U);if(F!==null&&F>N)N=F,$=0;else if(F!==null&&F===N&&i(Number(N))>0)$=0;else break}}else $=0}return W===0n&&(U=A),{height:C,end:U}};let{height:O,end:ve}=Q(S);if(O<e&&S>0n){let A=S,C=O,N=0;for(;A>0n&&C<e;){A-=1n;const W=Number(A),$=i(W);if(C+=$,!Number.isFinite($)||$<0)break;if($===0){if(N+=1,N>cr){const ie=Number(A);if(!Number.isSafeInteger(ie))break;const{cumulative:ae}=a.prefixSum(ie,{materializeOption:{materialize:!1}});if(!Number.isFinite(ae))break;const{index:F}=a.findIndexAtOrAfter(ae-.5,{materializeOption:{materialize:!1}}),we=F===-1?-1n:or(F);if(we>=0n&&we<A)A=we+1n,N=0;else if(we===A&&A>=1n&&i(Number(A-1n))>0)N=0;else break}}else N=0}S=g(A);const U=Q(S);O=U.height,ve=U.end}const Se=g(S),k=g(ve),q=g(Se-BigInt(Math.max(0,n))),ne=g(k+BigInt(Math.max(0,n)));return{renderingStartIndex:je(Number(q),s),renderingEndIndex:je(Number(ne),s),visibleStartIndex:je(Number(Se),s),visibleEndIndex:je(Number(k),s)}},pn=(r,e,n,s,i,a,o)=>{if(s===0)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const u=Number.isFinite(o),f=u?Math.min(Math.max(0,r),o):Math.max(0,r);if(s>=Number.MAX_SAFE_INTEGER)return Jn(f,e,n,s,i,a,o,u);const{index:g,cumulative:v,currentValue:y}=a.findIndexAtOrAfter(f,{materializeOption:{materialize:!1}}),I=g===-1?e<=0||(v??0)<f+(y??0)?s-1:0:g;let S=je(I,s),P=0;if(g!==-1&&v===f)S=je(g+1,s),P=0;else if(S===g&&v!==void 0&&y!==void 0)P=v-y-f;else{const{cumulative:A,currentValue:C}=a.prefixSum(S,{materializeOption:{materialize:!1}});P=(A??0)-(C??0)-f}const Q=P,O=(A,C)=>{let N=A,U=C,W=0;for(;N<s&&U<e;){const $=i(N);if(U+=$,N++,!Number.isFinite($)||$<0)break;if($===0){if(W++,W>cr){const{cumulative:ie}=a.prefixSum(N-1,{materializeOption:{materialize:!1}}),{index:ae}=Number.isFinite(ie)?a.findIndexAtOrAfter(ie+.5,{materializeOption:{materialize:!1}}):{index:-1};if(ae>N)N=ae,W=0;else if(ae===N&&i(N)>0)W=0;else break}}else W=0}return{cursor:N,height:U}},ve=O(S,P);let Se=ve.cursor;if(P=ve.height,P<e&&S>0){let A=P+Math.abs(Math.min(0,Q)),C=S-1,N=0;for(;C>=0&&A<e;){const W=i(C);if(A+=W,!Number.isFinite(W)||W<0){C--;break}if(W===0){if(N++,N>cr){const{cumulative:$}=a.prefixSum(C,{materializeOption:{materialize:!1}}),{index:ie}=Number.isFinite($)?a.findIndexAtOrAfter($-.5,{materializeOption:{materialize:!1}}):{index:-1};if(ie!==-1&&ie<C){C=ie,N=0;continue}if(ie===C&&C>=1&&i(C-1)>0)N=0;else{C--;break}}}else N=0;C--}S=je(C+1,s);const U=O(S,0);Se=U.cursor,P=U.height}const k=je(S-n,s),q=je(Math.max(Se-1,S),s),ne=je(q+n,s);return{renderingStartIndex:k,renderingEndIndex:ne,visibleStartIndex:S,visibleEndIndex:q}},sn=(r,e,n)=>{const s=Math.max(0,e??0),i=t.useRef({last:0,id:null,arg:null}).current;return t.useEffect(()=>()=>{if(i.id!==null&&(cancelAnimationFrame(i.id),i.id=null),i.arg!==null&&r.current){try{n(r.current,i.arg)}catch(a){console.error("[useThrottledInvoker] Error flushing pending callback on unmount",a)}i.arg=null}},[i,r,n]),t.useCallback(a=>{if(i.arg=a,i.id!==null)return;const o=u=>{if(i.id=null,i.arg===null)return;const f=u-i.last;if(s===0||i.last===0||f>=s){if(r.current)try{n(r.current,i.arg)}catch(g){console.error("[useThrottledInvoker] Error invoking callback",g)}i.arg=null,i.last=u}i.arg!==null&&(i.id=requestAnimationFrame(o))};i.id=requestAnimationFrame(o)},[s,n,r,i])},es=t.memo(({index:r,top:e,height:n,item:s,children:i,clipItemHeight:a,enableKeyboardNavigation:o,onKeyDown:u,onEscapeKeyDown:f,onFocus:g,registerItemRef:v})=>{const y=t.useCallback(O=>v(r,O),[r,v]),I=t.useCallback(O=>u(O,r),[r,u]),S=t.useCallback(O=>f?.(O,r),[r,f]),P=t.useCallback(()=>g(r),[r,g]),Q=t.useCallback(O=>{O.currentTarget.focus({preventScroll:!0})},[]);return D.jsx("div",{ref:y,"data-index":r,"data-virtualscroll-item":"true",className:"aqvs-item-container",style:{top:e,height:n,overflow:a?"hidden":void 0},tabIndex:o?-1:void 0,onPointerDown:o?Q:void 0,onKeyDownCapture:o?I:void 0,onKeyDown:o&&f?S:void 0,onFocusCapture:o?P:void 0,children:i(s,r)})}),ts=({itemCount:r,getItem:e,getItemKey:n,getItemHeight:s,viewportSize:i,overscanCount:a=15,className:o,testId:u,onScroll:f,onRangeChange:g,children:v,background:y,initialScrollIndex:I,initialScrollOffset:S,initialScrollAnchor:P,callbackThrottleMs:Q=5,contentInsets:O,onItemFocus:ve,scrollBarOptions:Se,behaviorOptions:k,onWheelHorizontal:q,onPanHorizontal:ne,horizontalKeyInputs:A,horizontalKeyStep:C=Qn,contentProps:N,liveRegion:U},W)=>{const{width:$,enableThumbDrag:ie,enableTrackClick:ae,enableArrowButtons:F,enableScrollToTopBottomButtons:we,renderThumbOverlay:R,tapScrollCircleOptions:oe}=Se??{},{enablePointerDrag:le,pointerDragInputs:He,enableKeyboardNavigation:_=!0,enableEscapeRowReturn:_e=!1,wheelSpeedMultiplier:it,inertiaOptions:Qe,overscrollBehavior:Ye,clipItemHeight:rt=!1,resetOnGetItemHeightChange:Ie=!1}=k??{},[Oe,ge]=t.useState(0),ue=i??Oe,Pe=t.useCallback(c=>{ge(b=>b===c?b:c)},[]),G=t.useRef(null),Ue=t.useRef({renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0,scrollPosition:0,totalHeight:0}),ee=t.useRef(P&&r>0?{index:re(Math.trunc(P.index),0,r-1),align:"top",offset:-Math.max(0,P.offsetPx??0)}:null),We=t.useRef(!1),he=t.useRef(!0);t.useEffect(()=>{if(he.current){he.current=!1;return}Ie&&(ee.current=null)},[Ie,s]);const V=t.useMemo(()=>nn(O),[O]),[Z]=t.useState(()=>{const b=P?.index??I,h=typeof b=="number"&&Number.isFinite(b)?Math.max(0,Math.trunc(b)):0;return{from:Math.max(0,h-50),to:h+50}}),Xe=t.useMemo(()=>({sampleRange:Z,resetOnValueFnChange:Ie,materialize:!0}),[Ie,Z]),M=Fr(r,s,Xe),[ht]=t.useState(()=>{let c=0,b=0;if(P&&r>0){const h=re(Math.trunc(P.index),0,r-1),Y=Math.max(0,P.offsetPx??0),B=re(h-a*2,0,r-1),j=re(h+a*2,0,r-1),K=h>0||Y>0?{materializeOption:{materialize:!0,ranges:[{from:B,to:j}]}}:void 0,{cumulative:xe,total:$e,currentValue:ke}=M.prefixSum(h,K),Ee=Math.max(xe-ke+Y,0);c=Qt(Ee,V.top),b=$e??M.getTotal()}else if(typeof I=="number"){const h=re(I,0,r-1),Y=re(h-a*2,0,r-1),B=re(h+a*2,0,r-1),j=I>0?{materializeOption:{materialize:!0,ranges:[{from:Y,to:B}]}}:void 0,{cumulative:K,total:xe,currentValue:$e}=M.prefixSum(I,j),ke=Math.max(K-$e,0);c=Qt(ke,V.top),b=xe??M.getTotal()}else typeof S=="number"&&(c=Qt(Math.max(S,0),V.top)),b=M.getTotal();return{position:c,total:b}}),[Ge,ft]=t.useState(ht.position),[nt,St]=t.useState(ht.total),m=t.useRef(ht.position),H=t.useRef(V.top),se=t.useRef(f??void 0),te=t.useRef(g??void 0),de=t.useRef(q),pe=(A?.length??0)>0,be=!!q;t.useEffect(()=>{pe&&(_||z.warn("[VirtualScroll] horizontalKeyInputs is set but behaviorOptions.enableKeyboardNavigation is false; horizontal keyboard scrolling is disabled because the row key handler is not mounted."),be||z.warn("[VirtualScroll] horizontalKeyInputs is set but onWheelHorizontal is missing; horizontal keyboard scrolling is disabled because the package does not own the horizontal axis."),Number.isFinite(C)&&C>0||z.warn(`[VirtualScroll] horizontalKeyStep must be a finite positive number, received ${C}. Horizontal arrow keys are left untouched.`))},[pe,be,_,C]);const Re=t.useRef(new Map),Ve=t.useRef(null),fe=t.useRef(null),[at,ot]=t.useState(null),[ye,qe]=t.useState(!1),Ze=t.useRef(null),Je=t.useRef(!1),me=t.useRef(0),Me=t.useRef(!1),pt=t.useRef(!1),p=t.useRef(r);p.current!==r&&(p.current=r,pt.current=!0),t.useLayoutEffect(()=>{se.current=f??void 0,te.current=g??void 0,de.current=q},[g,f,q]);const E=t.useCallback(c=>{if(_&&c&&typeof c.focus=="function")try{c.focus({preventScroll:!0})}catch{c.focus()}},[_]),Ne=t.useCallback((c,{position:b,totalHeight:h})=>{c(b,h)},[]),st=sn(se,Q,Ne),Fe=t.useCallback((c,b)=>{c(b)},[]),wt=sn(te,Q,Fe),Ae=t.useRef(V.top);Ae.current=V.top;const lt=t.useRef(st);lt.current=st,t.useEffect(()=>(We.current=!1,()=>{We.current=!0,Ze.current&&(clearTimeout(Ze.current),Ze.current=null)}),[]),t.useEffect(()=>{_||(Re.current.clear(),Ve.current=null,fe.current=null)},[_]);const De=t.useCallback((c,b)=>{if(!b){Re.current.delete(c);return}_&&(Re.current.set(c,b),Ve.current===c&&(Ve.current=null,fe.current=c,E(b)))},[_,E]),Xt=.01,qt=t.useRef({rafId:null,loopActive:!1,idleFrames:0,lastRenderedPosition:ht.position}),Tt=t.useCallback(()=>{const c=qt.current;c.rafId!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(c.rafId),c.rafId=null,c.loopActive=!1,c.idleFrames=0},[]);t.useEffect(()=>()=>{Tt()},[Tt]);const Te=t.useRef(()=>{}),It=t.useCallback(()=>{const c=qt.current;c.rafId=null;const b=m.current,h=vt(b,Ae.current),Y=M.getTotal();if(ft(j=>Math.abs(j-b)<Xt?j:b),Math.abs(c.lastRenderedPosition-b)>=Xt?(lt.current({position:h,totalHeight:Y}),c.lastRenderedPosition=b,c.idleFrames=0):c.idleFrames+=1,c.idleFrames>=2){Tt();return}if(typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(j=>Te.current(j));return}c.loopActive=!1},[M,Tt]);Te.current=It;const Gt=t.useCallback(()=>{const c=qt.current;if(c.idleFrames=0,!c.loopActive){if(c.loopActive=!0,typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(It);return}c.loopActive=!1}},[It]),ze=t.useCallback((c,b)=>{const h=b?.immediate??!1,Y=vt(c,V.top);if(m.current=c,h){qt.current.lastRenderedPosition=c,qt.current.idleFrames=0,ft(c),st({position:Y,totalHeight:M.getTotal()});return}Gt()},[Gt,M,V.top,st]),Rt=t.useCallback((c,b=0)=>{const h=G.current;if(!h)return c;const Y=h.getScrollPosition();me.current+=1;const B=h.getContentSize()+b,j=h.getViewportSize(),K=h.scrollTo(c,{contentSize:B,viewportSize:j});return K===Y&&(me.current=Math.max(0,me.current-1)),Math.abs(K-c)>.5&&(Me.current=!0),K},[]),Ct=t.useRef(!1);t.useEffect(()=>{if(!Ct.current)if(Ct.current=!0,P==null&&typeof I!="number"&&typeof S=="number"){const c=Qt(Math.max(S,0),V.top),b=Math.abs(c-m.current)>.5;ze(c,{immediate:!0}),b&&G.current?.scrollTo(c)}else ze(m.current,{immediate:!0})},[P,I,S,V.top,ze]),t.useEffect(()=>{const c=M.getTotal();if(nt!==c){St(c);return}if(Me.current){Me.current=!1;const b=G.current;if(b&&Math.abs(b.getScrollPosition()-m.current)>.5){const h=Rt(m.current);Me.current=!1,ze(h,{immediate:!0})}}},[M,nt,r,Rt,ze]),t.useEffect(()=>{if(ee.current!==null){const{index:c,align:b,offset:h}=ee.current,Y=je(c,r),{cumulative:B,currentValue:j}=M.prefixSum(Y,{materializeOption:{materialize:!1}});if(B!==void 0&&j!==void 0){const K=Math.max(B-j,0);let xe=K;b==="bottom"?xe=B-ue:b==="center"&&(xe=K+j/2-ue/2),h&&(xe-=h),xe=Math.max(0,xe);const $e=Math.max(0,nt+V.top+V.bottom-ue),ke=Math.min(Qt(xe,V.top),$e);Math.abs(ke-m.current)>1&&(z.debug("[VirtualScroll] Drift correction",{from:m.current,to:ke,targetIndex:Y}),me.current===0&&(me.current+=1),G.current?.scrollTo(ke),ze(ke,{immediate:!0}))}}pt.current=!1},[nt,M,r,V.top,ze,ue,V.bottom]),t.useEffect(()=>{const c=H.current;if(c===V.top||(H.current=V.top,ee.current))return;const b=vt(m.current,c),h=Qt(b,V.top);m.current=h,G.current?.scrollTo(h),ze(h,{immediate:!0})},[V.top,ze]);const At=t.useCallback((c,b)=>{if(r===0)return;const h=je(c,r),Y=M.get(h),B=b-Y,j=M.update(h,b);j!==void 0&&St(j),z.debug("[VirtualScroll] Updated item size manually",{index:h,size:b,total:j});let K=ee.current?ee.current.index:null;if(K===null){const xe=m.current,$e=nn(O).top,ke=vt(xe,$e),{index:Ee,cumulative:ut}=M.findIndexAtOrAfter(ke,{materializeOption:{materialize:!1}});K=ut!==void 0&&ut===ke?Ee+1:Ee}if(K!==-1&&h<K&&B!==0){const xe=m.current,$e=xe+B;Rt($e,B),ze($e,{immediate:!0}),z.debug("[VirtualScroll] Adjusted scroll for layout shift (manual update)",{from:xe,to:$e,causedByIndex:h,delta:B,activeVisibleStartIndex:K})}},[M,r,Rt,ze,O]),et=t.useCallback((c,b)=>{if(!G.current||r===0)return;const h=je(c,r),Y=je(h-a*2,r),B=je(h+a*2,r),{cumulative:j,total:K,currentValue:xe}=M.prefixSum(h,{materializeOption:{materialize:!0,ranges:[{from:Y,to:B}]}});if(z.debug("[VirtualScroll] Scrolling to index:",h,"ItemBottom:",j,"Total height:",K,"ItemHeight:",xe,"safeIndexFrom:",Y,"safeIndexTo:",B),!K)return;const $e=Math.max(j-xe,0);let ke=$e;b?.align==="bottom"?ke=j-ue:b?.align==="center"&&(ke=$e+xe/2-ue/2),b?.offset&&(ke-=b.offset),ke=Math.max(0,ke);const Ee=Qt(ke,V.top),ut=G.current?.getContentSize()??K+V.top+V.bottom,tt=Math.max(0,ut-ue),dt=Math.min(Ee,tt);ee.current={index:h,align:b?.align,offset:b?.offset};const Kt=G.current?.getScrollPosition()??-1,er=Math.abs(Kt-dt)>.5;Je.current=!1,me.current=0,er&&(Je.current=!0,me.current+=1,G.current?.scrollTo(dt)),St(K),ze(dt,{immediate:!0}),z.debug("[VirtualScroll] Setting scroll position to:",dt,{original:Ee,max:tt})},[M,a,r,V.top,V.bottom,ue,ze]),d=t.useRef(P&&r===0?P:null);t.useEffect(()=>{const c=d.current;!c||r===0||(d.current=null,et(re(Math.trunc(c.index),0,r-1),{align:"top",offset:-Math.max(0,c.offsetPx??0)}))},[r,et]);const T=t.useCallback(c=>{if(!G.current||r===0)return;const b=M.getTotal(),h=re(Math.floor(c),0,b),{index:Y,cumulative:B,currentValue:j}=M.findIndexAtOrAfter(h,{materializeOption:{materialize:!1}}),xe=(B??0)-(j??0)-h;et(Y,{offset:xe})},[M,r,et]),L=t.useCallback(()=>{if(r===0)return null;const c=vt(m.current,V.top),{index:b,cumulative:h,currentValue:Y}=M.findIndexAtOrAfter(c,{materializeOption:{materialize:!1}});if(b===-1)return{index:r-1,offsetPx:0};if(h===c)return{index:re(b+1,0,r-1),offsetPx:0};const B=(h??0)-(Y??0);return{index:b,offsetPx:Math.max(0,c-B)}},[M,r,V.top]),J=t.useCallback(c=>{const b=vt(m.current,V.top),h=typeof c=="function"?c(b):c;T(h);const Y=G.current?.getScrollPosition(),B=typeof Y=="number"?Y:m.current;return ze(B),vt(B,Ae.current)},[V.top,T,ze]),Ce=t.useCallback(c=>{const b=G.current;if(!b)return vt(m.current,Ae.current);const h=b.scrollTo(Y=>Y+c);return vt(h,Ae.current)},[]),Be=t.useCallback(c=>G.current?.applyWheel(c)??!1,[]),gt=t.useCallback((c,b)=>{z.debug("[VirtualScroll] Scroll position changed:",c);const h=Je.current;h&&(Je.current=!1);const Y=me.current>0;Y&&(me.current=0);const B=pt.current&&p.current===r;if(h||Y||B||(ee.current=null),ze(c),we){if(h||Y)return;const j=c-b;if(z.debug("[VirtualScroll] Scroll diff:",j,"New:",c,"Prev:",b),Math.abs(j)>1){const K=j>0?"down":"up";ot(K),qe(!0),z.debug("[VirtualScroll] Showing scroll buttons. Direction:",K),Ze.current&&clearTimeout(Ze.current),Ze.current=setTimeout(()=>{qe(!1),z.debug("[VirtualScroll] Hiding scroll buttons")},2e3)}}},[ze,we,r]),Le=t.useMemo(()=>vt(Ge,V.top),[V.top,Ge]),Pt=t.useMemo(()=>{const c=M.getTotal(),b=pn(Le,ue,a,r,s,M,c);return z.debug("[VirtualScroll] Calculated rendering range:",()=>({...b,scrollPosition:Le,renderingContentSize:c,overscanCount:a,viewportSize:ue})),b},[Le,ue,a,r,s,M]),{renderingStartIndex:mt,renderingEndIndex:Nt,visibleStartIndex:Dt,visibleEndIndex:$t}=Pt,zt=t.useCallback((c,b)=>{if(!_||r===0)return;const h=je(c,r);if(!(b?.ensureVisible??!0)){const tt=Re.current.get(h);tt&&(Ve.current=null,fe.current=h,E(tt));return}const B=M.prefixSum(h,{materializeOption:{materialize:!1}}),j=B.currentValue,K=Math.max(B.cumulative-j,0),xe=K+j,$e=vt(m.current,V.top),ke=$e+ue;if(K<$e||xe>ke){et(h);const tt=Re.current.get(h);tt?(Ve.current=null,fe.current=h,E(tt)):Ve.current=h;return}const ut=Re.current.get(h);if(ut){Ve.current=null,fe.current=h,E(ut);return}Ve.current=h},[_,r,M,V.top,et,E,ue]),Jt=t.useCallback((c,b)=>{if(!(!_||c.defaultPrevented)&&!(c.altKey||c.metaKey||c.ctrlKey)&&c.target===c.currentTarget&&!c.currentTarget.isContentEditable){if(c.key==="ArrowLeft"||c.key==="ArrowRight"){const h=de.current;if(!h||c.shiftKey||!A?.includes("arrow")||!(Number.isFinite(C)&&C>0))return;c.preventDefault(),h(c.key==="ArrowLeft"?-C:C);return}if(c.key==="ArrowDown"){b<r-1&&(c.preventDefault(),zt(b+1));return}if(c.key==="ArrowUp"){b>0&&(c.preventDefault(),zt(b-1));return}if(c.key==="PageDown"){if(b<r-1){c.preventDefault();const{visibleStartIndex:h,visibleEndIndex:Y}=Ue.current,B=Math.max(Y-h+1,1),j=Math.max(B,1),K=je(Math.min(b+j,r-1),r);zt(K)}return}if(c.key==="PageUp"&&b>0){c.preventDefault();const{visibleStartIndex:h,visibleEndIndex:Y}=Ue.current,B=Math.max(Y-h+1,1),j=Math.max(B,1),K=je(b-j,r);zt(K)}}},[_,r,zt,A,C]),Yt=t.useCallback((c,b)=>{if(c.key!=="Escape"||c.defaultPrevented||c.nativeEvent.isComposing||c.target===c.currentTarget)return;const h=c.target;h instanceof HTMLInputElement||h instanceof HTMLTextAreaElement||h instanceof HTMLSelectElement||h.isContentEditable||(c.preventDefault(),zt(b))},[zt]),Wt=t.useCallback(c=>{if(!_)return;const b=je(c,r);Ve.current=null,fe.current=b,ve?.(b)},[_,r,ve]);t.useEffect(()=>{const c=G.current?.getScrollPosition()??0,b=m.current,h=vt(b,V.top);z.debug("[VirtualScroll] Range change effect triggered",()=>({renderingStartIndex:mt,renderingEndIndex:Nt,visibleStartIndex:Dt,visibleEndIndex:$t,scrollPositionState:Ge,paneScrollPosition:b,logicalScrollPosition:h,contentSize:nt,scrollPaneScrollPosition:c})),wt({renderingStartIndex:mt,renderingEndIndex:Nt,visibleStartIndex:Dt,visibleEndIndex:$t,scrollPosition:h,totalHeight:nt})},[nt,Nt,mt,V.top,wt,Ge,$t,Dt]);const dr=t.useCallback(()=>{if(!we)return null;const c=ye&&at!==null,b=at==="up";return D.jsx("div",{className:"aqvs-scroll-to-edge-overlay","data-visible":c,inert:!c,children:b?D.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-top",children:D.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:h=>{h.stopPropagation(),Je.current=!0,et(0),qe(!1)},children:"Top"})}):D.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-bottom",children:D.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:h=>{h.stopPropagation(),Je.current=!0,et(r-1),qe(!1)},children:"Bottom"})})})},[we,ye,at,et,r]),bt=t.useRef(0),{visibleItems:yt,renderAnchor:Lt}=t.useMemo(()=>{if(r===0)return{visibleItems:D.jsx("div",{className:"aqvs-no-items-container",children:D.jsx("div",{className:"aqvs-no-items-text",children:"No items"})}),renderAnchor:0};const c=je(mt,r),b=je(Nt,r),{cumulative:h,currentValue:Y}=M.prefixSum(c,{materializeOption:{materialize:!1}}),B=h-Y;Number.isFinite(B)&&Math.abs(B-bt.current)>hn&&(bt.current=B);const j=bt.current,K=[],xe=[];let $e=0,ke=B;for(let Ee=c;Ee<=b;Ee++){if(xe.length>=zr){z.warn("[VirtualScroll] Rendered item count reached the safety cap; truncating render window.",{cap:zr,safeRenderingStartIndex:c,safeRenderingEndIndex:b});break}const ut=s(Ee),tt=M.get(Ee),dt=ut-tt;dt!==0&&K.push({index:Ee,value:ut});const Kt=ke+$e,er=n?n(Ee):Ee;xe.push(D.jsx(es,{index:Ee,top:Kt-j,height:ut,item:e(Ee),clipItemHeight:rt,enableKeyboardNavigation:_,onKeyDown:Jt,onEscapeKeyDown:_e?Yt:void 0,onFocus:Wt,registerItemRef:De,children:v},er)),$e+=dt,ke+=tt}return K.length>0&&Promise.resolve().then(()=>{if(We.current)return;let Ee=0;for(const dt of K)if(dt.index<Dt){const Kt=M.get(dt.index);Ee+=dt.value-Kt}const ut=M.updates(K);if(We.current||typeof ut!="number")return;St(ut),z.debug("[VirtualScroll] Updated heights for items",K,"New total height:",ut);const tt=G.current?.getScrollPosition()??m.current;if(Ee!==0){const dt=tt+Ee;Rt(dt,Ee),ze(dt,{immediate:!0}),z.debug("[VirtualScroll] Adjusted scroll for layout shift (auto update)",{from:tt,to:dt,shiftAmount:Ee})}else tt!==m.current&&ze(tt)}),{visibleItems:xe,renderAnchor:j}},[v,rt,nt,_,r,M,e,n,s,Wt,Jt,_e,Yt,Rt,De,Nt,mt,ze,Dt]),_t=t.useCallback(c=>{const b=(Q??0)>0,h=Math.abs(c-Ge),Y=b&&h>.5?Ge:c,B=vt(Y,V.top);if(z.debug("[VirtualScroll] Rendering visible items",()=>({currentScrollPosition:c,effectiveScrollPosition:B,renderingStartIndex:mt,renderingEndIndex:Nt,itemCount:r,viewportSize:ue,callbackThrottleMs:Q,diff:h,rawEffectiveScrollPosition:Y})),r===0)return yt;const j=V.top+Lt-Y,K=V.bottom>0?D.jsx("div",{className:"aqvs-bottom-inset",style:{top:M.getTotal()-Lt,height:V.bottom}},"virtualscroll-bottom-inset"):null;return z.debug("[VirtualScroll] Rendering items",()=>({containerTop:j,logicalScrollPosition:Le,resolvedInsets:V,effectiveScrollPosition:B})),D.jsxs("div",{className:"aqvs-items-wrapper",style:{top:0,transform:`translateY(${j}px)`,willChange:"transform"},children:[yt,K]})},[Q,r,M,Le,Lt,Nt,mt,V,Ge,ue,yt]),Bt=t.useMemo(()=>({renderingStartIndex:Pt.renderingStartIndex,renderingEndIndex:Pt.renderingEndIndex,visibleStartIndex:Pt.visibleStartIndex,visibleEndIndex:Pt.visibleEndIndex,scrollPosition:Le,totalHeight:M.getTotal()}),[Pt,Le,M,nt]);t.useEffect(()=>{Ue.current=Bt},[Bt]);const[Zt,jt]=t.useState(""),xt=t.useRef(U);t.useLayoutEffect(()=>{xt.current=U},[U]);const Et=U?.debounceMs??400,kt=Number.isFinite(Et)&&Et>=0,ct=U!==void 0;t.useEffect(()=>{ct&&!kt&&z.warn(`[VirtualScroll] liveRegion.debounceMs must be a finite number >= 0, received ${Et}. Announcements are disabled.`)},[ct,kt,Et]),t.useEffect(()=>{if(!(ct&&kt)){jt("");return}const c=setTimeout(()=>{const b=xt.current?.format;if(!b)return;const h=b({visibleStartIndex:Dt,visibleEndIndex:$t,itemCount:r});jt(h)},Et);return()=>clearTimeout(c)},[ct,kt,Et,Dt,$t,r]),t.useImperativeHandle(W,()=>({getScrollPosition:()=>{const c=G.current?.getScrollPosition();return typeof c=="number"?vt(c,Ae.current):-1},getContentSize:()=>G.current?.getContentSize()??-1,getViewportSize:()=>G.current?.getViewportSize()??-1,scrollTo:J,scrollBy:Ce,applyWheel:Be,scrollToIndex:et,getFenwickTreeTotalHeight:()=>M.getTotal(),getFenwickSize:()=>M.getSize(),focusItemAtIndex:zt,getRange:()=>Ue.current,getScrollAnchor:L,updateItemSize:At}),[J,Ce,Be,et,M,zt,L,At]);const wr=M.getTotal()+V.top+V.bottom,Ot=D.jsx(fn,{ref:G,contentSize:wr,viewportSize:i,onViewportSizeChange:Pe,className:o,testId:u,onScroll:gt,background:y,tapScrollCircleOptions:oe,inertiaOptions:Qe,overscrollBehavior:Ye,itemCount:r,scrollBarWidth:$,enableThumbDrag:ie,enableTrackClick:ae,enableArrowButtons:F,enablePointerDrag:le,pointerDragInputs:He,renderThumbOverlay:R,wheelSpeedMultiplier:it,onWheelHorizontal:q,onPanHorizontal:ne,contentInsets:V,contentProps:N,visibleStartIndex:Dt,visibleEndIndex:$t,renderOverlay:dr,initialScrollPosition:ht.position,children:_t});return ct?D.jsxs(D.Fragment,{children:[Ot,D.jsx("div",{className:"aqvs-live-region",role:"status","aria-live":"polite","aria-atomic":"true","data-aqvs-live-region":"",children:Zt})]}):Ot},gn=t.forwardRef(ts),ur=262144,an=3,bn=32768,kr=128,Vr=128,Ar=128,Dr=128,Cr=10,rs=(r,e)=>Math.max(1,Math.floor((r??bn)/Math.max(1,e))),ns=(r,e,n,s,i)=>{let a=0,o=0,u=Math.max(0,Math.min(s,n-1));for(;u<n&&a<r&&o<zr;)a+=e(u),o+=1,u+=1;return Math.max(1,o+2*i+2)},xr=(r,e,n)=>{if(!(Number.isInteger(r)&&r>=0&&r<=ur))throw new RangeError(`[VirtualGrid] ${e==="row"?"getRowHeight":"getColWidth"}(${n}) returned ${r} — must be an integer in [0, ${ur}] (0 = hidden). Oversized tracks would pierce the browser layout-coordinate wall (see the design plan §3.1/§6).`);return r},ss=(r,e,n,s,i,a,o,u)=>{const f=pn(r,e,n,s,i,a,o);if(s===0)return{renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0};const g=re(f.renderingStartIndex,0,s-1),{cumulative:v,currentValue:y}=a.prefixSum(g,{materializeOption:{materialize:!1}}),I=v-y,S=Number.isFinite(I)&&Math.abs(I-u)>hn?I:u;return{renderingColStart:f.renderingStartIndex,renderingColEnd:f.renderingEndIndex,visibleColStart:f.visibleStartIndex,visibleColEnd:f.visibleEndIndex,colAnchor:S}},on=[],is=(r,e,n,s,i)=>{const a=[],o=[];if(e<r)return{columns:a,widthUpdates:o,truncated:0};const u=s.prefixSum(r,{materializeOption:{materialize:!1}});let f=u.cumulative-u.currentValue,g=0,v=r;for(;v<=e;){if(a.length>=i)return{columns:a,widthUpdates:o,truncated:e-v+1};const y=n(v),I=s.get(v);if(y!==I&&o.push({index:v,value:y}),y>0){a.push({col:v,left:f,width:y}),f+=I,g=0,v+=1;continue}if(f+=I,g+=1,v+=1,g>cr){const S=s.findIndexAtOrAfter(f+.5,{materializeOption:{materialize:!1}});if(S.index===-1||S.index<=v||!Number.isSafeInteger(S.index))break;const P=s.prefixSum(S.index,{materializeOption:{materialize:!1}});f=P.cumulative-P.currentValue,v=S.index,g=0}}return{columns:a,widthUpdates:o,truncated:0}},as=(r,e,n)=>{const s=[],i=[];let a=0;for(let o=0;o<r;o+=1){const u=e(o),f=n.get(o);u!==f&&i.push({index:o,value:u}),u>0&&s.push({col:o,left:a,width:u}),a+=f}return{columns:s,widthUpdates:i,width:a}},os=(r,e,n,s)=>{const i=[],a=[];let o=0;for(let u=r-e;u<r;u+=1){const f=n(u),g=s.get(u);f!==g&&a.push({index:u,value:f}),f>0&&i.push({col:u,left:o,width:f}),o+=g}return{columns:i,widthUpdates:a,width:o}},vr=(r,e,n)=>Math.min(r,Math.max(0,n-e)),ls={renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0,key:"0:0:0"},cs=({rowCount:r,colCount:e,getRowHeight:n,getColWidth:s,getCell:i,getCellKey:a,children:o,getCellProps:u,getRowProps:f,contentProps:g,background:v,contentInsets:y,onRowFocus:I,frozenLeadingCols:S=0,frozenLeadingRows:P=0,frozenTrailingCols:Q=0,frozenTrailingRows:O=0,horizontalKeyInputs:ve,horizontalKeyStep:Se,onScroll:k,onRangeChange:q,onRenderTruncated:ne,callbackThrottleMs:A,initialScrollAnchor:C,overscanRows:N=an,overscanCols:U=an,viewportSize:W,__maxRenderedCells:$,behaviorOptions:ie,scrollBarOptions:ae,liveRegion:F,className:we,testId:R},oe)=>{const le=t.useRef(null),He=t.useRef(null),_=t.useRef(n);_.current=n;const _e=t.useRef(s);_e.current=s;const it=ie?.resetOnGetColWidthChange===!0,Ye=ie?.resetOnGetItemHeightChange===!0?n:null,rt=it?s:null,Ie=t.useCallback(l=>xr(_.current(l),"row",l),[Ye]),Oe=t.useCallback(l=>xr(_e.current(l),"col",l),[rt]),ge=ie?.defaultColWidth,ue=t.useMemo(()=>{if(ge!==void 0&&!(Number.isInteger(ge)&&ge>=0&&ge<=ur))throw new RangeError(`[VirtualGrid] behaviorOptions.defaultColWidth must be an integer in [0, ${ur}], received ${ge}.`);return{resetOnValueFnChange:it,baseValue:ge}},[it,ge]),Pe=Fr(e,Oe,ue),[G,Ue]=t.useState(0);if(!(Number.isInteger(S)&&S>=0&&S<=kr))throw new RangeError(`[VirtualGrid] frozenLeadingCols must be an integer in [0, ${kr}], received ${S}.`);const ee=Math.min(S,e),We=t.useRef(0);if(!(Number.isInteger(Q)&&Q>=0&&Q<=Ar))throw new RangeError(`[VirtualGrid] frozenTrailingCols must be an integer in [0, ${Ar}], received ${Q}.`);const he=Math.min(Q,e-ee),V=t.useRef(0);if(!(Number.isInteger(P)&&P>=0&&P<=Vr))throw new RangeError(`[VirtualGrid] frozenLeadingRows must be an integer in [0, ${Vr}], received ${P}.`);const Z=Math.min(P,r);if(!(Number.isInteger(O)&&O>=0&&O<=Dr))throw new RangeError(`[VirtualGrid] frozenTrailingRows must be an integer in [0, ${Dr}], received ${O}.`);const Xe=Math.min(O,r-Z),M=Math.max(0,r-Z-Xe),ht=t.useRef(!1),Ge=t.useRef(0),ft=t.useRef(0),[nt,St]=t.useState(0),{frozenRows:m,frozenHeight:H}=t.useMemo(()=>{if(Z===0)return{frozenRows:[],frozenHeight:0};const l=[];let x=0;for(let w=0;w<Z;w+=1){const X=Ie(w);X>0&&l.push({row:w,top:x,height:X}),x+=X}return{frozenRows:l,frozenHeight:x}},[Z,nt,Ie]);Ge.current=H;const[se,te]=t.useState(0),{trailingRows:de,trailingHeight:pe}=t.useMemo(()=>{if(Xe===0)return{trailingRows:[],trailingHeight:0};const l=[];let x=0;for(let w=r-Xe;w<r;w+=1){const X=Ie(w);X>0&&l.push({row:w,top:x,height:X}),x+=X}return{trailingRows:l,trailingHeight:x}},[Xe,r,se,Ie]);ft.current=pe;const be=t.useCallback(l=>Ie(l+Z),[Ie,Z]),Re=t.useRef(I);Re.current=I;const Ve=I!==void 0,fe=t.useMemo(()=>Ve?l=>Re.current?.(l+Z):void 0,[Z,Ve]),at=H,ot=pe,[ye,qe]=t.useState(Z),Ze=t.useRef(null),Je=t.useRef(!1);if(ye!==Z){qe(Z),Je.current=!0;const l=le.current?.getScrollAnchor()??null;Ze.current=l===null?null:{row:l.index+ye,offsetPx:l.offsetPx}}const me=t.useRef(0),Me=t.useRef(0),pt=t.useRef(!1),[p,E]=t.useState(ls),Ne=t.useRef(p);Ne.current=p;const st=t.useRef(0),[Fe,wt]=t.useState(()=>Pe.getTotal()??0),Ae=t.useRef(Fe);Ae.current=Fe;const lt=t.useCallback(l=>{typeof l=="number"&&Number.isFinite(l)&&(Ae.current=l,wt(l))},[]);t.useLayoutEffect(()=>{const l=Pe.getTotal();typeof l=="number"&&Number.isFinite(l)&&l!==Ae.current&&lt(l)});const De=ae?.width??12,Xt=W===void 0?null:{width:Math.max(0,Math.round(W.width)-De),height:Math.max(0,Math.round(W.height)-De)},[qt,Tt]=t.useState({width:0,height:0}),Te=Xt??qt,It=t.useRef(Te);It.current=Te;const Gt=Te.height>0&&Te.height-H-pe<=0;ht.current=Gt;const ze=Xt!==null;t.useLayoutEffect(()=>{if(ze)return;const l=He.current;if(l===null)return;const x=()=>{const X=Math.max(0,Math.round(l.clientWidth)-De),ce=Math.max(0,Math.round(l.clientHeight)-De);Tt(Ke=>Ke.width===X&&Ke.height===ce?Ke:{width:X,height:ce})};x();const w=new ResizeObserver(x);return w.observe(l),()=>w.disconnect()},[De,ze]);const Rt=t.useCallback(()=>{const l=He.current;l!==null&&l.style.setProperty("--aqvs-grid-hx-residual",`${st.current-me.current}px`)},[]),Ct=t.useCallback(()=>Math.max(0,It.current.width-We.current-V.current),[]),At=t.useCallback(()=>Math.max(0,Ae.current-We.current-V.current-Ct()),[Ct]),et=t.useCallback(()=>{const l=Ct(),x=ss(We.current+me.current,l,U,e,Oe,Pe,Ae.current,Ne.current.colAnchor);if(ee>0&&(x.renderingColStart=Math.max(x.renderingColStart,ee),x.visibleColStart=Math.max(x.visibleColStart,ee)),he>0){const X=e-he-1;x.renderingColEnd=Math.min(x.renderingColEnd,X),x.visibleColEnd=Math.min(x.visibleColEnd,X)}(ee>0||he>0)&&(l<=0||x.renderingColStart>x.renderingColEnd)&&(x.renderingColStart=e,x.renderingColEnd=e-1,x.visibleColStart=e,x.visibleColEnd=e-1);const w=`${x.renderingColStart}:${x.renderingColEnd}:${x.colAnchor}`;w!==Ne.current.key&&E({...x,key:w})},[U,e,Oe,Pe,ee,he,Ct]),[d,T]=t.useState(0),L=t.useRef(null),J=t.useCallback(()=>{L.current===null&&(L.current=requestAnimationFrame(()=>{L.current=null,T(me.current)}))},[]);t.useEffect(()=>()=>{L.current!==null&&cancelAnimationFrame(L.current)},[]);const Ce=t.useRef(k);Ce.current=k;const Be=t.useRef(q);Be.current=q;const gt=t.useRef(ne);gt.current=ne;const Le=t.useRef(null),[Pt,mt]=t.useState(null),[Nt,Dt]=t.useState(Te.height);Nt!==Te.height&&(Dt(Te.height),mt(null));const $t=C===void 0||r===0?0:re(Math.trunc(C.row),0,r-1),zt=t.useMemo(()=>{const l=Le.current?.renderingStartIndex??$t;return ns(Math.max(0,Te.height-Ge.current-ft.current),Ie,r,l,N)},[Te.height,Ie,r,$t,N,at,ot]),Jt=Pt??zt,Yt=t.useCallback(()=>{const l=Le.current;if(l===null)return null;const x=Ne.current;return{renderingRowStart:l.renderingStartIndex,renderingRowEnd:l.renderingEndIndex,visibleRowStart:l.visibleStartIndex,visibleRowEnd:l.visibleEndIndex,renderingColStart:x.renderingColStart,renderingColEnd:x.renderingColEnd,visibleColStart:x.visibleColStart,visibleColEnd:x.visibleColEnd,scrollX:me.current,scrollY:Me.current,totalWidth:Ae.current,totalHeight:l.totalHeight+Ge.current+ft.current}},[]),Wt=t.useCallback(()=>{const l=Yt();l!==null&&Be.current?.(l)},[Yt]),dr=t.useCallback(l=>{const x=At(),w=re(l,0,x);return w!==me.current&&(me.current=w,Rt(),et(),J(),Ce.current?.({x:w,y:Me.current})),w},[Rt,et,J,At]),bt=t.useRef(dr);bt.current=dr,t.useLayoutEffect(()=>{st.current=p.colAnchor,Rt(),Wt()},[p,Rt,Wt]),t.useLayoutEffect(()=>{Le.current!==null&&Wt()},[H,pe,Wt]);const yt=t.useRef(null),Lt=t.useCallback(l=>{const x=re(l.col,0,Math.max(0,e-1)),w=Pe.prefixSum(x,{materializeOption:{materialize:!1}}),X=w.cumulative-w.currentValue,ce=w.currentValue,Ke=Ct();return(l.alignX==="end"?X+ce-We.current-Ke:l.alignX==="center"?X+ce/2-We.current-Ke/2:X-We.current)+l.offsetX},[Pe,e,Ct]),_t=t.useRef(null),Bt=t.useCallback(()=>{const l=_t.current;_t.current=null,!(l===null||l.length===0)&&(lt(Pe.updates(l)),Ue(x=>x+1))},[Pe,lt]),Zt=t.useRef({count:0,warned:!1}),{frozenColumns:jt,frozenWidth:xt}=t.useMemo(()=>{if(ee===0)return Zt.current.count=0,Zt.current.warned=!1,{frozenColumns:on,frozenWidth:0};const{columns:l,widthUpdates:x,width:w}=as(ee,Oe,Pe);if(x.length>0){const X=Zt.current;X.count>=Cr?X.warned||(X.warned=!0,z.warn("[VirtualGrid] getColWidth keeps disagreeing with its own previous values inside the frozen band; width self-heal is suspended until a converged pass re-arms it (unstable accessor).",{frozenCols:ee,pendingUpdates:x.length})):(X.count+=1,_t.current=[..._t.current??[],...x],Promise.resolve().then(Bt))}else Zt.current.count=0,Zt.current.warned=!1;return{frozenColumns:l,frozenWidth:w}},[ee,G,Oe,Pe,Bt]);We.current=xt,t.useLayoutEffect(()=>{ee>0?He.current?.style.setProperty("--aqvs-grid-frozen-width",`${xt}px`):He.current?.style.removeProperty("--aqvs-grid-frozen-width")},[xt,ee]);const Et=t.useRef({count:0,warned:!1}),{trailingColumns:kt,trailingWidth:ct}=t.useMemo(()=>{if(he===0)return Et.current.count=0,Et.current.warned=!1,{trailingColumns:on,trailingWidth:0};const{columns:l,widthUpdates:x,width:w}=os(e,he,Oe,Pe);if(x.length>0){const X=Et.current;X.count>=Cr?X.warned||(X.warned=!0,z.warn("[VirtualGrid] getColWidth keeps disagreeing with its own previous values inside the trailing band; width self-heal is suspended until a converged pass re-arms it (unstable accessor).",{trailingCols:he,pendingUpdates:x.length})):(X.count+=1,_t.current=[..._t.current??[],...x],Promise.resolve().then(Bt))}else Et.current.count=0,Et.current.warned=!1;return{trailingColumns:l,trailingWidth:w}},[he,e,G,Oe,Pe,Bt]);V.current=ct,t.useLayoutEffect(()=>{he>0?He.current?.style.setProperty("--aqvs-grid-trailing-width",`${ct}px`):He.current?.style.removeProperty("--aqvs-grid-trailing-width")},[ct,he]);const wr=t.useMemo(()=>({...ae,tapScrollCircleOptions:{...ae?.tapScrollCircleOptions,enabled:!1}}),[ae]),Ot=ae?.tapScrollCircleOptions,c=typeof Ot?.maxSpeedMultiplier=="number",b=t.useMemo(()=>({...Ot,offsetX:Ot?.offsetX===void 0?tn:Ot.offsetX,offsetY:Ot?.offsetY===void 0?tn:Ot.offsetY}),[Ot]),h=t.useMemo(()=>Nr(b,Math.max(0,e-ee-he)),[b,e,ee,he]),Y=t.useMemo(()=>Nr(b,M),[b,M]),B=h.enabled,j=Math.max(h.maxVisualDistance,1),K={viewportSize:Math.max(0,Te.width-xt-ct),minSpeedMultiplier:h.minSpeedMultiplier,maxSpeedMultiplier:h.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:c,curve:h.maxSpeedCurve},xe={viewportSize:Math.max(0,Te.height-H-pe),minSpeedMultiplier:Y.minSpeedMultiplier,maxSpeedMultiplier:Y.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:c,curve:Y.maxSpeedCurve},$e=t.useCallback(()=>me.current,[]),ke=t.useCallback(()=>Me.current,[]),Ee=t.useCallback(()=>{const l=le.current;return l===null?0:Math.max(0,Math.max(0,l.getContentSize())-Math.max(0,l.getViewportSize()))},[]),ut=t.useCallback(l=>{const x=le.current;if(x===null)return Me.current;const w=x.scrollBy(l);return Me.current=w,w},[]),tt=At()>0||Ee()>0,dt=`${Fe}:${xt}:${ct}:${Te.width}:${p.key}`,Kt=`${r}:${Pt??-1}:${H}:${pe}:${Te.height}`,{isTapActive:er,handleTapCircleDragChange:xn,tapCircleHandleRef:vn}=Kn({enabled:B&&tt,maxDistance:j,xSpeedParams:K,ySpeedParams:xe,applyHxRef:bt,getHx:$e,getMaxHx:At,applyVy:ut,getVy:ke,getMaxVy:Ee,pendingColAnchorRef:yt,xExtentFreshness:dt,yExtentFreshness:Kt}),Sn=t.useMemo(()=>re((er?1:.8)*h.opacity,0,1),[er,h.opacity]);t.useLayoutEffect(()=>{const l=yt.current;l===null?bt.current(me.current):bt.current(Lt(l)),et()},[Te.width,Fe,G,xt,ct,et,Lt]);const Hr=t.useRef(!1);t.useLayoutEffect(()=>{if(Hr.current||C===void 0||e===0)return;Hr.current=!0;const l=re(Math.trunc(C.col),0,e-1);if(l<ee||l>=e-he)return;const x={col:l,alignX:"start",offsetX:Math.max(0,C.offsetX)};yt.current=x,bt.current(Lt(x))},[C,e,Lt,ee,he]);const wn=t.useCallback(l=>{Me.current=l,pt.current=!0,Ce.current?.({x:me.current,y:l})},[]),Xr=t.useCallback(l=>{if(M===0||ht.current)Le.current={renderingStartIndex:r,renderingEndIndex:r-1,visibleStartIndex:r,visibleEndIndex:r-1,scrollPosition:0,totalHeight:M===0?0:l.totalHeight},Me.current=0;else{const x=Z;Le.current={renderingStartIndex:l.renderingStartIndex+x,renderingEndIndex:l.renderingEndIndex+x,visibleStartIndex:l.visibleStartIndex+x,visibleEndIndex:l.visibleEndIndex+x,scrollPosition:l.scrollPosition,totalHeight:l.totalHeight},Me.current=l.scrollPosition}mt(x=>{const w=Math.max(1,l.renderingEndIndex-l.renderingStartIndex+1);return w===x?x:w}),Wt()},[Wt,Z,M,r]),qr=t.useCallback(l=>{yt.current=null,bt.current(me.current+l)},[]),$r=rs($,Jt+m.length+de.length),Rr=t.useRef({count:0,warned:!1}),{placedColumns:fr,truncatedCols:mr}=t.useMemo(()=>{const l=Math.max(0,Te.width-xt-ct);if(e===0||l<=0)return{placedColumns:[],truncatedCols:0};if(p.renderingColStart>p.renderingColEnd)return{placedColumns:[],truncatedCols:0};const x=Math.max(1,$r-jt.length-kt.length),{columns:w,widthUpdates:X,truncated:ce}=is(re(p.renderingColStart,0,e-1),re(p.renderingColEnd,0,e-1),Oe,Pe,x);if(X.length>0){const Ke=Rr.current;Ke.count>=Cr?Ke.warned||(Ke.warned=!0,z.warn("[VirtualGrid] getColWidth keeps disagreeing with its own previous values; width self-heal is suspended until a converged (zero-deviation) pass re-arms it (unstable accessor — the accessor must be index-stable while the ordering is unchanged).",{window:p.key,pendingUpdates:X.length})):(Ke.count+=1,_t.current=[..._t.current??[],...X],Promise.resolve().then(Bt))}else Rr.current.count=0,Rr.current.warned=!1;return{placedColumns:w,truncatedCols:ce}},[p,e,Te.width,xt,ct,jt.length,kt.length,G,Oe,Pe,$r,Bt]),Yr=t.useRef("");t.useEffect(()=>{if(mr>0){const l=`${p.key}:${mr}`;l!==Yr.current&&(Yr.current=l,gt.current?.({renderedCells:(fr.length+jt.length+kt.length)*(Jt+m.length+de.length),droppedCols:mr}))}},[mr,p.key,fr.length,jt.length,kt.length,Jt,m.length,de.length]);const Wr=p.colAnchor,Mr=t.useCallback(l=>{const x=f?.(l),w=Ie(l)===0,X=w?null:fr.map(({col:ce,left:Ke,width:rr})=>{const Vt=u?.(l,ce),ir={...Vt?.style,left:Ke-Wr,width:rr};return t.createElement("div",{...Vt,key:a?a(l,ce):ce,className:Mt.twMerge("aqvs-grid-cell",Vt?.className),style:ir},o(i(l,ce),l,ce))});return ee===0&&he===0?D.jsx("div",{...x,className:Mt.twMerge("aqvs-grid-row",x?.className),style:x?.style,children:X}):D.jsxs("div",{...x,"data-aqvs-frozen-row":ee>0?"":void 0,className:Mt.twMerge("aqvs-grid-row aqvs-grid-row-frozen-host",x?.className),style:x?.style,children:[w?null:jt.map(({col:ce,left:Ke,width:rr})=>{const Vt=u?.(l,ce),ir={...Vt?.style,left:Ke,width:rr};return t.createElement("div",{...Vt,"data-aqvs-frozen-cell":"",key:a?a(l,ce):ce,className:Mt.twMerge("aqvs-grid-cell",Vt?.className),style:ir},o(i(l,ce),l,ce))}),w?null:D.jsx("div",{className:"aqvs-grid-row-scroll",children:D.jsx("div",{className:"aqvs-grid-row-scroll-inner",children:X})}),w||he===0?null:D.jsx("div",{className:"aqvs-grid-row-trailing",children:D.jsx("div",{className:"aqvs-grid-row-trailing-inner",children:kt.map(({col:ce,left:Ke,width:rr})=>{const Vt=u?.(l,ce),ir={...Vt?.style,left:Ke,width:rr};return t.createElement("div",{...Vt,"data-aqvs-trailing-cell":"",key:a?a(l,ce):ce,className:Mt.twMerge("aqvs-grid-cell",Vt?.className),style:ir},o(i(l,ce),l,ce))})})})]})},[fr,jt,kt,ee,he,Wr,f,u,a,i,o,Ie]),[Rn,Mn]=t.useState(""),tr=t.useRef(null),Br=t.useRef(F);Br.current=F;const hr=t.useCallback(()=>{const l=Br.current;if(l===void 0)return;const x=l.debounceMs??400;Number.isFinite(x)&&x>=0&&(tr.current!==null&&window.clearTimeout(tr.current),tr.current=window.setTimeout(()=>{tr.current=null;const w=Yt();w!==null&&Mn(X=>{const ce=l.buildMessage(w);return ce===X?X:ce})},x))},[Yt]),pr=F?.debounceMs??400,jr=Number.isFinite(pr)&&pr>=0,Ur=F!==void 0;t.useEffect(()=>{Ur&&!jr&&z.warn(`[VirtualGrid] liveRegion.debounceMs must be a finite number >= 0, received ${pr}. Announcements are disabled.`)},[Ur,jr,pr]),t.useEffect(()=>()=>{tr.current!==null&&window.clearTimeout(tr.current)},[]),t.useEffect(()=>{hr()},[p,hr]);const In=t.useCallback(l=>{Xr(l),hr()},[Xr,hr]);return t.useImperativeHandle(oe,()=>({scrollTo:l=>{const x=le.current;let w=Me.current;l.y!==void 0&&x!==null&&(x.scrollTo(l.y),w=x.getScrollPosition(),Me.current=w);let X=me.current;return l.x!==void 0&&(yt.current=null,X=bt.current(l.x)),{x:X,y:w}},scrollBy:l=>{const x=le.current;let w=Me.current;l.y!==void 0&&l.y!==0&&x!==null&&(w=x.scrollBy(l.y),Me.current=w);let X=me.current;return l.x!==void 0&&l.x!==0&&(yt.current=null,X=bt.current(me.current+l.x)),{x:X,y:w}},scrollToCell:(l,x,w)=>{const X=le.current;if(X!==null&&r>0){const ce=re(Math.trunc(l),0,r-1);ce>=Z&&ce<r-Xe&&X.scrollToIndex(ce-Z,{align:w?.alignY??"top",offset:w?.offsetY})}if(e>0){const ce=re(Math.trunc(x),0,e-1);if(ce>=ee&&ce<e-he){const Ke={col:ce,alignX:w?.alignX??"start",offsetX:w?.offsetX??0};yt.current=Ke,bt.current(Lt(Ke))}}},getScrollPosition:()=>pt.current||le.current!==null?{x:me.current,y:le.current?.getScrollPosition()??Me.current}:{x:-1,y:-1},getScrollAnchor:()=>{if(r===0||e===0)return null;const l=le.current?.getScrollAnchor()??null;if(l===null)return null;const x=We.current+me.current,w=Pe.findIndexAtOrAfter(x,{materializeOption:{materialize:!1}});if(w.index===-1)return{row:l.index+Z,col:e-1,offsetX:0,offsetY:l.offsetPx};if(w.cumulative===x)return{row:l.index+Z,col:re(w.index+1,0,e-1),offsetX:0,offsetY:l.offsetPx};const X=(w.cumulative??0)-(w.currentValue??0);return{row:l.index+Z,col:w.index,offsetX:Math.max(0,x-X),offsetY:l.offsetPx}},getViewportSize:()=>({width:It.current.width,height:It.current.height}),getContentSize:()=>({width:Ae.current,height:le.current===null?0:Ge.current+ft.current+Math.max(0,le.current.getContentSize())}),getRange:Yt,updateRowSize:(l,x)=>{xr(x,"row",l),Math.trunc(l)<Z?St(w=>w+1):Xe>0&&Math.trunc(l)>=r-Xe?te(w=>w+1):le.current?.updateItemSize(Math.trunc(l)-Z,x)},updateColSize:(l,x)=>{xr(x,"col",l),lt(Pe.update(re(Math.trunc(l),0,Math.max(0,e-1)),x)),Ue(w=>w+1)},getFrozenSize:()=>({cols:ee,width:We.current,rows:Z,height:Ge.current,trailingCols:he,trailingRows:Xe,trailingWidth:V.current,trailingHeight:ft.current,trailingVisibleWidth:vr(V.current,We.current,It.current.width),trailingVisibleHeight:vr(ft.current,Ge.current,It.current.height)}),applyWheel:l=>le.current?.applyWheel(l)??!1,focusRowAtIndex:(l,x)=>{const w=Math.trunc(l);w<Z?He.current?.querySelector(`[data-aqvs-frozen-band-row="${w}"]`)?.focus():Xe>0&&w>=r-Xe?He.current?.querySelector(`[data-aqvs-trailing-band-row="${w}"]`)?.focus():le.current?.focusItemAtIndex(w-Z,x)}}),[r,e,Pe,Yt,lt,Lt,ee,Z,he,Xe]),D.jsxs("div",{ref:He,className:Mt.twMerge("aqvs-grid",Z>0?"aqvs-grid-has-frozen-rows":"",Xe>0?"aqvs-grid-has-trailing-rows":"",we),"data-testid":R,children:[Z>0?D.jsx("div",{className:"aqvs-grid-frozen-rows",style:{height:H},"data-testid":R?`${R}-frozen-rows`:void 0,children:m.map(({row:l,top:x,height:w})=>D.jsx("div",{"data-aqvs-frozen-band-row":l,className:"aqvs-grid-frozen-band-row",style:{top:x,height:w,right:De},tabIndex:-1,onFocus:()=>I?.(l),children:Mr(l)},l))}):null,D.jsx("div",{className:"aqvs-grid-main","data-testid":R?`${R}-main`:void 0,children:D.jsx(gn,{ref:le,itemCount:Gt?0:M,getItem:l=>l+Z,getItemKey:l=>l+Z,getItemHeight:be,overscanCount:N,viewportSize:Te.height>0?Math.max(0,Te.height-H-pe):void 0,callbackThrottleMs:A,behaviorOptions:ie,scrollBarOptions:wr,contentProps:g,background:v,contentInsets:y,onItemFocus:fe,horizontalKeyInputs:ve,horizontalKeyStep:Se,initialScrollAnchor:Je.current?Ze.current!==null&&Ze.current.row>=Z&&M>0?{index:Ze.current.row-Z,offsetPx:Ze.current.offsetPx}:void 0:C!==void 0&&M>0&&Math.trunc(C.row)>=Z&&Math.trunc(C.row)<r-Xe?{index:Math.trunc(C.row)-Z,offsetPx:C.offsetY}:void 0,onScroll:wn,onRangeChange:In,onWheelHorizontal:qr,onPanHorizontal:qr,testId:R?`${R}-rows`:void 0,children:Mr},Z)}),Xe>0?D.jsx("div",{className:"aqvs-grid-trailing-rows",style:{height:vr(pe,H,Te.height)},"data-testid":R?`${R}-trailing-rows`:void 0,children:D.jsx("div",{className:"aqvs-grid-trailing-rows-inner",style:{height:pe},children:de.map(({row:l,top:x,height:w})=>D.jsx("div",{"data-aqvs-trailing-band-row":l,className:"aqvs-grid-trailing-band-row",style:{top:x,height:w,right:De},tabIndex:-1,onFocus:()=>I?.(l),children:Mr(l)},l))})}):null,D.jsx("div",{className:"aqvs-grid-hbar-strip",style:{height:De,paddingRight:he>0?De+vr(ct,xt,Te.width):De},"data-testid":R?`${R}-hbar`:void 0,children:D.jsx(Or,{horizontal:!0,contentSize:Math.max(0,Fe-xt-ct),viewportSize:Math.max(0,Te.width-xt-ct),scrollPosition:d,itemCount:Math.max(0,e-ee-he),tapScrollCircleOptions:ae?.tapScrollCircleOptions,onScroll:(l,x)=>(yt.current=null,bt.current(typeof l=="function"?l(x??me.current):l)),scrollBarWidth:De})}),B&&tt&&D.jsx("div",{className:"aqvs-grid-tap-circle-wrapper","data-aqvs-grid-tap-circle":"",style:{left:`min(calc(100% - ${De+h.size}px), max(calc(100% - ${De}px + ${h.offsetX}px), calc(75% - ${h.size/2}px)))`,top:`min(calc(100% - ${De+h.size}px), max(calc(100% - ${De}px + ${h.offsetY}px), calc(75% - ${h.size/2}px)))`},children:D.jsx(Lr,{axis:"xy",ref:vn,className:Mt.twMerge("aqvs-grid-tap-circle",h.className),size:h.size,maxVisualDistance:j,opacity:Sn,renderVisual:h.renderVisual,onDragChange:xn})}),F!==void 0?D.jsx("div",{className:"aqvs-grid-live-region","aria-live":"polite","data-testid":R?`${R}-live`:void 0,children:Rn}):null]})},us=t.forwardRef(cs);exports.FenwickMapTree=Ht;exports.MAX_FROZEN_LEADING_COLS=kr;exports.MAX_FROZEN_LEADING_ROWS=Vr;exports.MAX_FROZEN_TRAILING_COLS=Ar;exports.MAX_FROZEN_TRAILING_ROWS=Dr;exports.MAX_RENDERED_CELLS=bn;exports.MAX_TRACK_SIZE=ur;exports.ScrollBar=Or;exports.ScrollPane=fn;exports.TAP_SCROLL_SPEED_DEFAULTS=_r;exports.VirtualGrid=us;exports.VirtualScroll=gn;exports.computeAutoTapScrollMaxSpeedMultiplier=cn;exports.computeTapScrollSpeed=Sr;exports.computeTapScrollVelocity=un;exports.createResidualQuantizer=On;exports.minmax=re;exports.tapScrollCircleSampleVisual=Yn;exports.useFenwickMapTree=Fr;exports.useHeightCache=Gn;exports.useLruCache=mn;exports.useWheelBridge=Zn;
package/dist/index.d.cts CHANGED
@@ -4,6 +4,7 @@
4
4
  * High-performance virtual scrolling component for React with variable item heights.
5
5
  * 可変なアイテム高さに対応したReact用の高性能仮想スクロールコンポーネント。
6
6
  */
7
+ export { computeTapScrollVelocity, type TapScrollAxisSpeedParams, type TapScrollVelocityInput } from './computeTapScrollVelocity.cjs';
7
8
  export { createResidualQuantizer, type ResidualQuantizer, type ResidualQuantizerOptions } from './residualQuantizer.cjs';
8
9
  export { computeAutoTapScrollMaxSpeedMultiplier, computeTapScrollSpeed, ScrollBar, type ScrollBarProps, type ScrollBarTapCircleOptions, type ScrollBarThumbOverlayRenderProps, TAP_SCROLL_SPEED_DEFAULTS, type TapScrollSpeedInput } from './ScrollBar.cjs';
9
10
  export { ScrollPane, type ScrollPaneContentInsets, type ScrollPaneHandle, type ScrollPaneInertiaOptions, type ScrollPaneProps } from './ScrollPane.cjs';
@@ -14,5 +15,5 @@ export { useHeightCache } from './useHeightCache.cjs';
14
15
  export { useLruCache } from './useLruCache.cjs';
15
16
  export { useWheelBridge, type WheelBridgeOptions, type WheelBridgeTarget } from './useWheelBridge.cjs';
16
17
  export { minmax } from './utils.cjs';
17
- export { MAX_FROZEN_LEADING_COLS, MAX_FROZEN_LEADING_ROWS, MAX_RENDERED_CELLS, MAX_TRACK_SIZE, VirtualGrid, type VirtualGridBehaviorOptions, type VirtualGridHandle, type VirtualGridLiveRegionOptions, type VirtualGridProps, type VirtualGridRange } from './VirtualGrid.cjs';
18
+ export { MAX_FROZEN_LEADING_COLS, MAX_FROZEN_LEADING_ROWS, MAX_FROZEN_TRAILING_COLS, MAX_FROZEN_TRAILING_ROWS, MAX_RENDERED_CELLS, MAX_TRACK_SIZE, VirtualGrid, type VirtualGridBehaviorOptions, type VirtualGridHandle, type VirtualGridLiveRegionOptions, type VirtualGridProps, type VirtualGridRange, } from './VirtualGrid.cjs';
18
19
  export { VirtualScroll, type VirtualScrollBehaviorOptions, type VirtualScrollHandle, type VirtualScrollLiveRegionOptions, type VirtualScrollLiveRegionRange, type VirtualScrollProps, type VirtualScrollRange, type VirtualScrollScrollBarOptions, } from './VirtualScroll.cjs';
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  * High-performance virtual scrolling component for React with variable item heights.
5
5
  * 可変なアイテム高さに対応したReact用の高性能仮想スクロールコンポーネント。
6
6
  */
7
+ export { computeTapScrollVelocity, type TapScrollAxisSpeedParams, type TapScrollVelocityInput } from './computeTapScrollVelocity.ts';
7
8
  export { createResidualQuantizer, type ResidualQuantizer, type ResidualQuantizerOptions } from './residualQuantizer.ts';
8
9
  export { computeAutoTapScrollMaxSpeedMultiplier, computeTapScrollSpeed, ScrollBar, type ScrollBarProps, type ScrollBarTapCircleOptions, type ScrollBarThumbOverlayRenderProps, TAP_SCROLL_SPEED_DEFAULTS, type TapScrollSpeedInput } from './ScrollBar.tsx';
9
10
  export { ScrollPane, type ScrollPaneContentInsets, type ScrollPaneHandle, type ScrollPaneInertiaOptions, type ScrollPaneProps } from './ScrollPane.tsx';
@@ -14,6 +15,6 @@ export { useHeightCache } from './useHeightCache.ts';
14
15
  export { useLruCache } from './useLruCache.ts';
15
16
  export { useWheelBridge, type WheelBridgeOptions, type WheelBridgeTarget } from './useWheelBridge.ts';
16
17
  export { minmax } from './utils.ts';
17
- export { MAX_FROZEN_LEADING_COLS, MAX_FROZEN_LEADING_ROWS, MAX_RENDERED_CELLS, MAX_TRACK_SIZE, VirtualGrid, type VirtualGridBehaviorOptions, type VirtualGridHandle, type VirtualGridLiveRegionOptions, type VirtualGridProps, type VirtualGridRange } from './VirtualGrid.tsx';
18
+ export { MAX_FROZEN_LEADING_COLS, MAX_FROZEN_LEADING_ROWS, MAX_FROZEN_TRAILING_COLS, MAX_FROZEN_TRAILING_ROWS, MAX_RENDERED_CELLS, MAX_TRACK_SIZE, VirtualGrid, type VirtualGridBehaviorOptions, type VirtualGridHandle, type VirtualGridLiveRegionOptions, type VirtualGridProps, type VirtualGridRange, } from './VirtualGrid.tsx';
18
19
  export { VirtualScroll, type VirtualScrollBehaviorOptions, type VirtualScrollHandle, type VirtualScrollLiveRegionOptions, type VirtualScrollLiveRegionRange, type VirtualScrollProps, type VirtualScrollRange, type VirtualScrollScrollBarOptions, } from './VirtualScroll.tsx';
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AACvH,OAAO,EAAE,sCAAsC,EAAE,qBAAqB,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,yBAAyB,EAAE,KAAK,gCAAgC,EAAE,yBAAyB,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC3P,OAAO,EAAE,UAAU,EAAE,KAAK,uBAAuB,EAAE,KAAK,gBAAgB,EAAE,KAAK,wBAAwB,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvJ,YAAY,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,0BAA0B,EAAE,KAAK,iBAAiB,EAAE,KAAK,4BAA4B,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAC/Q,OAAO,EACH,aAAa,EACb,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,GACrC,MAAM,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,wBAAwB,EAAE,KAAK,wBAAwB,EAAE,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AACpI,OAAO,EAAE,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AACvH,OAAO,EAAE,sCAAsC,EAAE,qBAAqB,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,yBAAyB,EAAE,KAAK,gCAAgC,EAAE,yBAAyB,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC3P,OAAO,EAAE,UAAU,EAAE,KAAK,uBAAuB,EAAE,KAAK,gBAAgB,EAAE,KAAK,wBAAwB,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvJ,YAAY,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EACH,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EACtB,KAAK,4BAA4B,EACjC,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACxB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACH,aAAa,EACb,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,GACrC,MAAM,qBAAqB,CAAA"}