@aiquants/virtualscroll 3.7.0 → 3.7.1
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/CHANGELOG.md +25 -0
- package/README.md +19 -0
- package/dist/ScrollBar.d.ts.map +1 -1
- package/dist/ScrollPane.d.ts.map +1 -1
- package/dist/TapScrollCircle.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1302 -1332
- package/dist/pointerCapture.d.cts +68 -0
- package/dist/pointerCapture.d.ts +69 -0
- package/dist/pointerCapture.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/ScrollBar.tsx +20 -34
- package/src/ScrollPane.tsx +45 -18
- package/src/TapScrollCircle.tsx +35 -25
- package/src/pointerCapture.ts +89 -0
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react/jsx-runtime"),t=require("react"),It=require("tailwind-merge"),Xr=["en","ja"],yr=["scrollUp","scrollDown","scrollLeft","scrollRight","scrollToTop","scrollToBottom","noItems"],pn=Object.freeze({en:Object.freeze({scrollUp:"Scroll up",scrollDown:"Scroll down",scrollLeft:"Scroll left",scrollRight:"Scroll right",scrollToTop:"Top",scrollToBottom:"Bottom",noItems:"No items"}),ja:Object.freeze({scrollUp:"上へスクロール",scrollDown:"下へスクロール",scrollLeft:"左へスクロール",scrollRight:"右へスクロール",scrollToTop:"先頭へ",scrollToBottom:"末尾へ",noItems:"項目がありません"})}),Vn=r=>Xr.includes(r),Vr=r=>typeof r=="string"?JSON.stringify(r):r===null?"null":typeof r,gn=r=>{if(r===void 0)return"en";if(Vn(r))return r;const e=Xr.map(n=>JSON.stringify(n)).join(", ");throw new RangeError(`[virtualscroll] locale must be one of ${e}; got ${Vr(r)}`)},An=r=>yr.includes(r),$r=(r,e)=>{const n=pn[gn(r)];if(e===void 0)return n;if(e===null||typeof e!="object")throw new RangeError(`[virtualscroll] labels must be an object; got ${Vr(e)}`);const s=Object.getPrototypeOf(e);if(s!==Object.prototype&&s!==null)throw new RangeError(`[virtualscroll] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(e)?"an array":"an object with a non-plain prototype"}`);const i=new Set(Object.keys(e));for(const o of i)if(!An(o))throw new RangeError(`[virtualscroll] labels.${o} is not a known label key; expected one of ${yr.join(", ")}`);const a={...n};for(const o of yr){const u=i.has(o)?e[o]:void 0;if(u!==void 0){if(typeof u!="string"||u.trim()==="")throw new RangeError(`[virtualscroll] labels.${o} must be a non-blank string; got ${Vr(u)}`);a[o]=u}}return Object.freeze(a)};class k{level;prefix;impl;constructor(e=2,n="[virtualscroll]",s=console){this.level=e,this.prefix=n,this.impl=s}static instance=new k(2,"[virtualscroll]");static setLevel(e){k.instance.setLevel(e)}setLevel(e){this.level=e}static setImplementation(e){k.instance.setImplementation(e)}setImplementation(e){this.impl=e}static setPrefix(e){k.instance.setPrefix(e)}setPrefix(e){this.prefix=e}static isEnabled(e){return k.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){k.instance.debug(e,...n)}debug(e,...n){this.level<=0&&this.impl.debug(...this.formatMessage(k.resolveLazy(e)),...n.map(k.resolveLazy))}static info(e,...n){k.instance.info(e,...n)}info(e,...n){this.level<=1&&this.impl.info(...this.formatMessage(k.resolveLazy(e)),...n.map(k.resolveLazy))}static warn(e,...n){k.instance.warn(e,...n)}warn(e,...n){this.level<=2&&this.impl.warn(...this.formatMessage(k.resolveLazy(e)),...n.map(k.resolveLazy))}static error(e,...n){k.instance.error(e,...n)}error(e,...n){this.level<=3&&this.impl.error(...this.formatMessage(k.resolveLazy(e)),...n.map(k.resolveLazy))}}const rn={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},Sr=6,Ln=8,Dn=({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 A.jsxs(A.Fragment,{children:[A.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`}}),A.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"}})]})},qr=t.memo(t.forwardRef(({onDragChange:r,className:e,maxVisualDistance:n=160,size:s=40,style:i,opacity:a=1,renderVisual:o,axis:u="y"},m)=>{const[g,x]=t.useState(rn),I=t.useRef(null),y=t.useRef(null),S=t.useRef({x:0,y:0}),P=t.useRef(null),G=t.useRef(0),_=t.useCallback(M=>{x(M),r(M)},[r]),Re=t.useCallback((M,ne,te=!1)=>{const{x:ke,y:ee}=S.current,He=M-ke,pe=ne-ee;let re,Ue;if(u==="xy")re=Math.hypot(He,pe),Ue=re<Sr?0:1;else{const Fe=u==="x"?He:pe;re=Math.abs(Fe),Ue=re<Sr?0:Fe<0?-1:1}const rt=G.current;let Ge=Ue;const pt=Sr+Ln;Ue===0?rt!==0&&re<pt?Ge=rt:(Ge=0,te||(G.current=0)):Ue!==rt&&rt!==0&&re<pt?Ge=rt:G.current=Ue,_({active:te||re>=Sr,offsetX:He,offsetY:pe,distance:re,direction:Ge,pointerId:I.current})},[_,u]),Te=t.useCallback(M=>{if(M===null)return;const ne=P.current;ne?.hasPointerCapture(M)&&ne.releasePointerCapture(M)},[]),V=t.useCallback((M=!1)=>{M&&Te(I.current),I.current=null,y.current=null,G.current=0,_(rn)},[_,Te]),F=t.useCallback(M=>{if(I.current!==null&&I.current!==M.pointerId){y.current={pointerId:M.pointerId,clientX:M.clientX,clientY:M.clientY},M.preventDefault(),M.stopPropagation();return}M.preventDefault(),M.stopPropagation();const ne=P.current??M.currentTarget,{left:te,top:ke,width:ee,height:He}=ne.getBoundingClientRect();S.current={x:te+ee/2,y:ke+He/2},I.current=M.pointerId;try{ne.setPointerCapture(M.pointerId)}catch{}Re(M.clientX,M.clientY,!0)},[Re]),oe=t.useCallback(M=>{if(I.current!==M.pointerId){y.current!==null&&y.current.pointerId===M.pointerId&&(y.current={pointerId:M.pointerId,clientX:M.clientX,clientY:M.clientY});return}M.preventDefault(),Re(M.clientX,M.clientY)},[Re]),L=t.useCallback(M=>{if(I.current!==M.pointerId){y.current!==null&&y.current.pointerId===M.pointerId&&(y.current=null);return}M.preventDefault(),M.stopPropagation();const ne=y.current;if(y.current=null,ne!==null){Te(M.pointerId);const te=P.current;let ke=!0;if(te!==null&&typeof te.setPointerCapture=="function")try{te.setPointerCapture(ne.pointerId)}catch(ee){(typeof ee=="object"&&ee!==null&&"name"in ee?ee.name:void 0)==="NotFoundError"&&(ke=!1)}if(ke){I.current=ne.pointerId,Re(ne.clientX,ne.clientY,!0);return}}V(!0)},[V,Te,Re]),E=t.useCallback(M=>{M.target===M.currentTarget&&I.current===M.pointerId&&V(!1)},[V]);t.useImperativeHandle(m,()=>({reset:()=>{V(!0)},getElement:()=>P.current}),[V]);const z=Math.min(Math.max(a,0),1),K=s/64,Y=Math.min(g.distance,n)/n,H=g.direction*Y*10*K;let Z;if(u==="xy"){const M=g.distance,ne=M===0?0:H*g.offsetX/M,te=M===0?0:H*g.offsetY/M;Z=`translate(${ne}px, ${te}px)`}else u==="x"?Z=`translateX(${H}px)`:Z=`translateY(${H}px)`;const se=o??Dn,he={dragState:g,normalizedDistance:Y,sizeScale:K,size:s,opacity:z},_e={...i,width:s,height:s,transform:Z};return _e.opacity=z,A.jsx("div",{ref:P,"data-testid":"virtual-scroll-tap-circle",className:It.twMerge("aqvs-tap-scroll-circle",e),style:_e,tabIndex:-1,onPointerDown:F,onPointerMove:oe,onPointerUp:L,onPointerCancel:L,onLostPointerCapture:E,role:"presentation",children:se(he)})}));qr.displayName="TapScrollCircle";const J=(r,e,n)=>Math.max(e,Math.min(n,r)),Ar=(r,e)=>{const n=e==="x",s=r.getBoundingClientRect(),i=n?s.width:s.height,a=x=>{const I=Number.parseFloat(x);return Number.isFinite(I)?I:0},o=window.getComputedStyle(r),u=a(n?o.width:o.height),m=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=m>0?m:n?r.offsetWidth:r.offsetHeight;return g<=0||i<=0?1:i/g},mr="virtualscroll:tap-scroll-cancel",nn=20,On=250,_n=60,Fn=20,Hn=20,Yr={maxDistance:240,minSpeedMultiplier:.2},Xn=Yr.maxDistance,sn={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},Cr=2.2,$n=8,qn=120,bn=1/10,Ot={enabled:!0,size:40,offsetX:-80,offsetY:0,className:void 0,maxVisualDistance:Xn,minSpeedMultiplier:Yr.minSpeedMultiplier,opacity:.9,renderVisual:void 0,maxSpeedCurve:void 0},Yn=r=>r?{mainSizeKey:"width",crossSizeKey:"height",positionKey:"left",selectDelta:(e,n)=>e,getPointerCoordinate:({clientX:e})=>e,arrowIcons:["◀","▶"],directionClass:"aqvs-scrollbar-horizontal",orientation:"horizontal"}:{mainSizeKey:"height",crossSizeKey:"width",positionKey:"top",selectDelta:(e,n)=>n,getPointerCoordinate:({clientY:e})=>e,arrowIcons:["▲","▼"],directionClass:"aqvs-scrollbar-vertical",orientation:"vertical"},Lr=(r,e)=>{const n=r?.maxSpeedMultiplier,s=typeof n=="number"?n:xn(e);return{enabled:r?.enabled??Ot.enabled,size:r?.size??Ot.size,offsetX:r?.offsetX??Ot.offsetX,offsetY:r?.offsetY??Ot.offsetY,className:r?.className??Ot.className,maxVisualDistance:r?.maxVisualDistance??Ot.maxVisualDistance,maxSpeedMultiplier:s,minSpeedMultiplier:Math.max(r?.minSpeedMultiplier??Ot.minSpeedMultiplier,0),opacity:J(r?.opacity??Ot.opacity,0,1),renderVisual:r?.renderVisual??Ot.renderVisual,maxSpeedCurve:r?.maxSpeedCurve??Ot.maxSpeedCurve}},Bn=({isDragging:r,isThumbHovered:e,enableThumbDrag:n})=>t.useMemo(()=>n?r?"dragging":e?"hover":"idle":"disabled",[n,r,e]),jn=({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)},[]),m=t.useCallback(()=>{u()},[u]),g=t.useCallback(I=>y=>{if(!r)return;y.cancelable&&y.preventDefault(),y.stopPropagation(),n(),u(),s(I),a.current=window.setTimeout(()=>{i.current=window.setInterval(()=>{s(I)},_n)},On);const S=()=>u();o.current=S,window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S),window.addEventListener("blur",S)},[r,u,n,s]),x=t.useCallback(I=>y=>{e&&(y.key==="Enter"||y.key===" "||y.key==="Spacebar")&&(y.preventDefault(),s(I))},[e,s]);return t.useEffect(()=>{r||u()},[r,u]),t.useEffect(()=>()=>{u()},[u]),{handleArrowPointerDown:g,handleArrowPointerUp:m,handleArrowKeyDown:x}},Wn=700,Qt=(r,e)=>typeof r=="number"&&Number.isFinite(r)?r:e,Ir=({distance:r,maxDistance:e,viewportSize:n,minSpeedMultiplier:s,maxSpeedMultiplier:i,hasCustomMaxSpeedMultiplier:a,curve:o})=>{const u=Math.max(Qt(r,0),0),m=Qt(e,0),g=m>0?Math.min(u,m)/m:1,x=Math.max(Qt(n,0),0),I=Math.max(Qt(s,0),0),y=Math.max(Qt(i,0),0),S=Math.max(x*I,40),P=a?S:1200,G=Math.max(x*y,P),_=o?Math.max(Qt(o.exponentialScale,y),0):0,Re=o?Math.min(G,Math.max(x*_,S)):G,Te=Math.max(Re,S);let V=g**1.1;if(o){const oe=Math.min(Math.max(Qt(o.exponentialSteepness,0),0),Wn);if(oe===0)V=g;else{const L=Math.expm1(oe)||1;V=Math.min(Math.max(Math.expm1(oe*g)/L,0),1)}}const F=Math.min(Math.max(Qt(o?.easedOffset,0),0),1);return S+(Te-S)*(F+(1-F)*V)},xn=r=>{if(!r||r<=0)return Cr;const e=Math.max(1,r),n=Math.log10(e),s=Cr+n*$n;return J(s,Cr,qn)},Br=({contentSize:r,viewportSize:e,scrollPosition:n,onScroll:s,enableThumbDrag:i=!0,enableTrackClick:a=!0,enableArrowButtons:o=!0,horizontal:u=!1,enableHorizontalTapCircle:m=!1,stretchMainSize:g=!1,scrollBarWidth:x=12,className:I,ariaControls:y,tapScrollCircleOptions:S,itemCount:P,renderThumbOverlay:G,visibleStartIndex:_,visibleEndIndex:Re,locale:Te,labels:V})=>{const[F,oe]=t.useState(!1),[L,E]=t.useState(!1),[z,K]=t.useState(!1),Y=t.useRef(null),H=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null}),Z=t.useRef({pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}),se=t.useRef(n),he=t.useRef(s),_e=t.useRef(sn),M=t.useRef(null),ne=t.useRef(null),te=t.useRef(null),ke=t.useRef(0),ee=t.useRef(0),He=t.useMemo(()=>Lr(S,P),[P,S]),pe=t.useMemo(()=>Yn(u),[u]),re=t.useMemo(()=>$r(Te,V),[Te,V]),Ue=u?[re.scrollLeft,re.scrollRight]:[re.scrollUp,re.scrollDown],{enabled:rt,size:Ge,offsetX:pt,offsetY:Fe,className:Xe,maxVisualDistance:Ee,maxSpeedMultiplier:nt,minSpeedMultiplier:Q,opacity:Ve,renderVisual:Me,maxSpeedCurve:le}=He,ge=t.useRef({viewportSize:e,maxScrollPosition:Math.max(r-e,0),scrollBarVisible:r>e,effectiveTapMaxDistance:Math.max(Ee,1),tapCircleMaxSpeedMultiplier:nt,tapCircleMinSpeedMultiplier:Q,tapCircleMaxSpeedCurve:le,tapScrollCircleOptions:S,effectiveTrackLength:0,onScroll:s,scrollPosition:n}),{mainSizeKey:ue,crossSizeKey:dt,positionKey:w,selectDelta:De,getPointerCoordinate:fe,arrowIcons:D,directionClass:at,orientation:Ke}=pe,Tt=Math.max(Ee,1),gt=e/r,b=Math.max(e-x*2,0),N=gt*b,ce=Math.min(Math.max(nn,N||0),b||nn),j=Math.max(r-e,0),ie=Math.max(b-ce,0),de=j<=0||ie<=0?0:J(n/j*ie,0,ie),Ye=de+ce/2,be=r>e||F,$e=be&&o;t.useLayoutEffect(()=>{ge.current={viewportSize:e,maxScrollPosition:j,scrollBarVisible:be,effectiveTapMaxDistance:Tt,tapCircleMaxSpeedMultiplier:nt,tapCircleMinSpeedMultiplier:Q,tapCircleMaxSpeedCurve:le,tapScrollCircleOptions:S,effectiveTrackLength:ie,onScroll:s,scrollPosition:n}}),t.useLayoutEffect(()=>{se.current=n},[n]),t.useLayoutEffect(()=>{he.current=s},[s]),t.useEffect(()=>{i||E(!1)},[i]);const Se=Bn({isDragging:F,isThumbHovered:L,enableThumbDrag:i}),Ae=t.useCallback((f,T)=>{const O=ge.current,W=T??se.current;if(he.current){const je=he.current(f,W);if(typeof je=="number"&&Number.isFinite(je))return se.current=je,je}const Le=typeof f=="function"?f(W):f,Be=Math.max(O.maxScrollPosition,0),ut=O.scrollBarVisible?J(Le,0,Be):0;return se.current=ut,ut},[]),ct=t.useCallback(f=>{const T=ge.current,O=se.current;if(!T.scrollBarVisible||T.maxScrollPosition<=0){const vt=Ae(0,O),kt=vt-O;return{nextPosition:vt,actualDelta:kt,reachedBoundary:!0}}if(f===0)return{nextPosition:O,actualDelta:0,reachedBoundary:!1};const Le=Ae(vt=>J(vt+f,0,T.maxScrollPosition),O),Be=Le-O,ut=f<0&&O+f<=0,je=f>0&&O+f>=T.maxScrollPosition,zt=f<0&&(Le<=0||ut&&Be===0)||f>0&&(Le>=T.maxScrollPosition||je&&Be===0);return{nextPosition:Le,actualDelta:Be,reachedBoundary:zt}},[Ae]),Ze=t.useCallback((f,T)=>{f.current+=T;const O=Math.max(ge.current.maxScrollPosition,0);O>0&&(f.current=J(f.current,-O,O));const W=ct(f.current);return f.current-=W.actualDelta,W.reachedBoundary&&(f.current=0),W},[ct]),Qe=t.useCallback(()=>{ne.current!==null&&(window.cancelAnimationFrame(ne.current),ne.current=null),te.current=null,ke.current=0,ee.current=0},[]),Oe=t.useCallback(()=>{_e.current={...sn},K(!1),M.current?.reset(),Qe()},[Qe]),st=t.useCallback(f=>{const T=_e.current,O=ge.current;if(!T.active||T.direction===0){Qe();return}if(!O.scrollBarVisible||O.maxScrollPosition<=0){Qe();return}const W=te.current??f,Le=Math.max((f-W)/1e3,0),Be=Math.min(Le,bn);if(te.current=f,Be<=0){ne.current=window.requestAnimationFrame(st);return}const ut=Ir({distance:T.distance,maxDistance:O.effectiveTapMaxDistance,viewportSize:O.viewportSize,minSpeedMultiplier:O.tapCircleMinSpeedMultiplier,maxSpeedMultiplier:O.tapCircleMaxSpeedMultiplier,hasCustomMaxSpeedMultiplier:typeof O.tapScrollCircleOptions?.maxSpeedMultiplier=="number",curve:O.tapCircleMaxSpeedCurve});ee.current!==T.direction&&(ee.current=T.direction,ke.current=0);const{reachedBoundary:je}=Ze(ke,T.direction*ut*Be);if(je){Qe();return}ne.current=window.requestAnimationFrame(st)},[Ze,Qe]),xe=t.useCallback(()=>{ne.current===null&&(te.current=null,ke.current=0,ne.current=window.requestAnimationFrame(st))},[st]);t.useEffect(()=>{const f=_e.current;!f.active||f.direction===0||xe()},[r,e,xe]),t.useEffect(()=>()=>{Qe()},[Qe]);const me=t.useCallback(f=>{_e.current=f,K(f.active),f.active&&f.direction!==0?xe():Qe()},[xe,Qe]);t.useEffect(()=>{rt||Oe()},[Oe,rt]),t.useEffect(()=>{const f=T=>{const W=T.detail?.paneId;W&&y&&W!==y||Oe()};return window.addEventListener(mr,f),()=>{window.removeEventListener(mr,f)}},[y,Oe]),t.useEffect(()=>{if(!rt)return;const f=T=>{if(!_e.current.active||_e.current.pointerId===T.pointerId)return;const O=T.target;if(!(O instanceof Node)){Oe();return}M.current?.getElement()?.contains(O)||Oe()};return document.addEventListener("pointerdown",f,!0),()=>{document.removeEventListener("pointerdown",f,!0)}},[Oe,rt]);const bt=f=>{if(!be||ie<=0||j<=0)return 0;const T=J(f,0,ie);return J(T/ie*j,0,j)},h=t.useCallback(f=>{const{scrollBarVisible:T,effectiveTrackLength:O,maxScrollPosition:W}=ge.current;if(k.debug("[ScrollBar] calculateScrollPositionFromThumb",()=>({thumbPos:f,trackLen:O,maxScroll:W})),O<=0||W<=0)return null;const Le=J(f,0,O);return J(Le/O*W,0,W)},[]),C=t.useCallback(f=>Ar(f,u?"x":"y"),[u]),ye=t.useCallback(f=>{const T=H.current;if(T.pointerId!==f.pointerId)return;const O=f.clientX-T.startClientX,W=f.clientY-T.startClientY,Le=De(O,W)/(T.scale||1);k.debug("[ScrollBar] handleThumbPointerMove",()=>({delta:Le,startThumbPosition:T.startThumbPosition,clientY:f.clientY,startClientY:T.startClientY,metrics:ge.current}));const Be=h(T.startThumbPosition+Le);Be!==null&&Ae(Be),f.cancelable&&f.preventDefault()},[De,h,Ae]),Je=t.useCallback(f=>{const T=H.current;if(T.pointerId!==f.pointerId)return;document.removeEventListener("pointermove",ye),document.removeEventListener("pointerup",Je),document.removeEventListener("pointercancel",Je);const O=T.captureTarget;if(O?.hasPointerCapture?.(f.pointerId)&&O.releasePointerCapture(f.pointerId),H.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null},oe(!1),Y.current){const W=Y.current.getBoundingClientRect();f.clientX>=W.left&&f.clientX<=W.right&&f.clientY>=W.top&&f.clientY<=W.bottom||E(!1)}else E(!1)},[ye]);t.useEffect(()=>()=>{document.removeEventListener("pointermove",ye),document.removeEventListener("pointerup",Je),document.removeEventListener("pointercancel",Je)},[ye,Je]);const Ce=t.useRef(0),Rt=t.useRef(0),et=t.useCallback(f=>{const T=Math.max(Math.round(ge.current.viewportSize/Hn),Fn);Rt.current!==f&&(Rt.current=f,Ce.current=0),Ze(Ce,f*T)},[Ze]),{handleArrowPointerDown:it,handleArrowPointerUp:Pe,handleArrowKeyDown:Ft}=jn({canUseArrowButtons:$e,enableArrowButtons:o,resetTapScroll:Oe,scrollByStep:et}),rr=f=>{if(!be)return;if(!i){f.preventDefault(),f.stopPropagation();return}if(f.pointerType==="mouse"&&f.button!==0||f.ctrlKey)return;Oe();const T=f.currentTarget,O=C(T);let W=null;if(T.setPointerCapture)try{T.setPointerCapture(f.pointerId),W=T}catch{W=null}H.current={pointerId:f.pointerId,startThumbPosition:de,startClientX:f.clientX,startClientY:f.clientY,scale:O,captureTarget:W},document.addEventListener("pointermove",ye),document.addEventListener("pointerup",Je),document.addEventListener("pointercancel",Je),oe(!0),E(!0),f.preventDefault(),f.stopPropagation()},Ht=f=>{if(!be)return;if(!a){f.preventDefault(),f.stopPropagation();return}if(f.pointerType==="mouse"&&f.button!==0||f.ctrlKey)return;const T=f.currentTarget,O=T.getBoundingClientRect(),W=fe(f),Le=C(T),Be=(W-(u?O.left:O.top))/Le;Oe();const ut=Be-ce/2,je=bt(ut);if(Ae(je),T.setPointerCapture)try{T.setPointerCapture(f.pointerId)}catch{}Z.current={pointerId:f.pointerId,startThumbPosition:ut,startClientX:f.clientX,startClientY:f.clientY,scale:Le},f.preventDefault(),f.stopPropagation()},ve=()=>{Z.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}},Nt=f=>{const T=Z.current;if(T.pointerId!==f.pointerId)return;if(f.pointerType==="mouse"&&f.buttons===0){ve();return}const O=f.clientX-T.startClientX,W=f.clientY-T.startClientY,Le=De(O,W)/(T.scale||1),Be=bt(T.startThumbPosition+Le);Ae(Be),f.cancelable&&f.preventDefault()},Bt=f=>{if(Z.current.pointerId!==f.pointerId)return;const T=f.currentTarget;T.hasPointerCapture?.(f.pointerId)&&T.releasePointerCapture(f.pointerId),ve(),f.preventDefault(),f.stopPropagation()},Jt=f=>{if(Z.current.pointerId!==f.pointerId)return;const T=f.currentTarget;T.hasPointerCapture?.(f.pointerId)&&T.releasePointerCapture(f.pointerId),ve()},Ie=f=>{f.target===f.currentTarget&&Z.current.pointerId===f.pointerId&&ve()},xt=t.useMemo(()=>J((z?1:.8)*Ve,0,1),[z,Ve]),Xt=t.useMemo(()=>{const T=`calc(50% - ${Ge/2}px + ${Fe}px)`;return{left:pt,top:T}},[pt,Fe,Ge]),Lt=(f,T,O,W)=>A.jsx("button",{type:"button",tabIndex:0,className:"aqvs-scrollbar-arrow-button",style:{[ue]:x,[dt]:x},"aria-label":T,onPointerDown:it(f),onPointerUp:Pe,onPointerLeave:Pe,onPointerCancel:Pe,onKeyDown:Ft(f),"aria-disabled":!o,disabled:!$e,children:A.jsx("span",{"aria-hidden":"true",children:O})},W),mt=G&&be?{orientation:Ke,scrollPosition:n,maxScrollPosition:j,contentSize:r,viewportSize:e,thumbSize:ce,thumbPosition:de,thumbCenter:Ye,trackSize:b,isDragging:F,isTapScrollActive:z,visibleStartIndex:_,visibleEndIndex:Re}:null;return A.jsxs("div",{className:It.twMerge("aqvs-scrollbar",at,I),style:{...g&&!u?{}:{[ue]:e},[dt]:x},"data-visible":be?"true":"false",role:"scrollbar",tabIndex:-1,"aria-controls":y,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":j,"aria-orientation":u?"horizontal":"vertical",children:[(!u||m)&&be&&rt&&A.jsx(qr,{axis:u?"x":"y",ref:M,className:It.twMerge("aqvs-scrollbar-tap-circle-wrapper",Xe),size:Ge,maxVisualDistance:Tt,style:Xt,opacity:xt,renderVisual:Me,onDragChange:me},"tap-circle"),Lt(-1,Ue[0],D[0],"arrow-start"),A.jsxs("div",{className:"aqvs-scrollbar-track",style:{borderRadius:x/2},onPointerDown:Ht,onPointerMove:Nt,onPointerUp:Bt,onPointerCancel:Jt,onLostPointerCapture:Ie,"aria-disabled":!a,children:[mt&&A.jsx("div",{className:"aqvs-scrollbar-overlay","aria-hidden":!0,children:G?.(mt)},"overlay"),A.jsx("div",{className:"aqvs-scrollbar-thumb-wrapper",style:{[ue]:ce,[w]:de,...u?{top:0,bottom:0}:{left:0,right:0}},"data-visible":be||F?"true":"false",onPointerDown:rr,role:"slider","aria-orientation":u?"horizontal":"vertical","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":j,"aria-disabled":!i,tabIndex:-1,children:A.jsx("div",{ref:Y,className:It.twMerge("aqvs-scrollbar-thumb",u?"aqvs-scrollbar-thumb-horizontal":"aqvs-scrollbar-thumb-vertical"),"data-testid":"aqvs-scrollbar-thumb","data-thumb-state":Se,style:{borderRadius:x-1,cursor:i?"pointer":"default"},onMouseEnter:()=>{i&&E(!0)},onMouseLeave:()=>{i&&E(!1)}},"thumb")},"thumb-wrapper")]},"track"),Lt(1,Ue[1],D[1],"arrow-end")]})},vn=({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 m=Ir({distance:u,maxDistance:n,viewportSize:s.viewportSize,minSpeedMultiplier:s.minSpeedMultiplier,maxSpeedMultiplier:s.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:s.hasCustomMaxSpeedMultiplier,curve:s.curve}),g=Ir({distance:u,maxDistance:n,viewportSize:i.viewportSize,minSpeedMultiplier:i.minSpeedMultiplier,maxSpeedMultiplier:i.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:i.hasCustomMaxSpeedMultiplier,curve:i.curve});return{x:m*a/u,y:g*o/u}},Un=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}}},Gn=16,an=(r,e,n)=>e===1?r*Gn:e===2?r*n:r,Kn=(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:an(s,r.deltaMode,e),verticalDelta:an(i,r.deltaMode,e)}},Sn=new WeakSet,on=r=>{Sn.add(r)},Zn=r=>Sn.has(r),Qn=["mouse","pen","touch"],Pr=(r,e)=>!(r==="mouse"||r==="pen"||r==="touch")||e.includes(r),Jn=r=>r==="mouse"||r==="pen",fr={maxVelocity:6,minVelocity:.02,deceleration:.0025,velocitySampleWindow:90,startVelocityThreshold:.04},wr=(r,e,n)=>{for(const[s,i,a]of e)n==="add"?r.addEventListener(s,i,a):r.removeEventListener(s,i,a)},wn=t.forwardRef(({children:r,contentSize:e,viewportSize:n,onViewportSizeChange:s,scrollBarWidth:i=12,enableThumbDrag:a=!0,enableTrackClick:o=!0,enableArrowButtons:u=!0,enablePointerDrag:m=!0,pointerDragInputs:g=Qn,onScroll:x,className:I,testId:y,style:S,background:P,tapScrollCircleOptions:G,inertiaOptions:_,itemCount:Re,renderThumbOverlay:Te,wheelSpeedMultiplier:V=1,overscrollBehavior:F="auto",onWheelHorizontal:oe,onPanHorizontal:L,contentInsets:E,visibleStartIndex:z,visibleEndIndex:K,renderOverlay:Y,initialScrollPosition:H=0,contentProps:Z,locale:se,labels:he},_e)=>{const M=t.useRef(Number.isFinite(H)?Math.max(0,H):0),ne=t.useRef(null),te=t.useRef(null),ke=n===void 0,[ee,He]=t.useState(0),pe=n??ee,re=t.useRef(null);t.useLayoutEffect(()=>{if(!ke)return;const b=te.current;if(!b)return;const N=()=>{const j=b.offsetHeight;if(j>0){He(ie=>ie===j?ie:j);return}b.offsetParent!==null&&e>0&&re.current!=="zero"&&(re.current="zero",k.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(N(),typeof ResizeObserver!="function")return;const ce=new ResizeObserver(N);return ce.observe(b),()=>{ce.disconnect()}},[e,ke]),t.useLayoutEffect(()=>{ke&&s?.(ee)},[ke,ee,s]),t.useLayoutEffect(()=>{if(ke)return;const b=ne.current;if(!b)return;const N=()=>{const j=b.clientHeight;if(j<=0||Math.abs(j-pe)<=1)return;const ie=`${pe}/${j}`;re.current!==ie&&(re.current=ie,k.warn(`[ScrollPane] viewportSize=${pe} but the host band is ${j}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(N(),typeof ResizeObserver!="function")return;const ce=new ResizeObserver(N);return ce.observe(b),()=>{ce.disconnect()}},[ke,pe]);const Ue=t.useRef(oe);t.useEffect(()=>{Ue.current=oe},[oe]);const rt=t.useRef(L);t.useEffect(()=>{rt.current=L},[L]);const Ge=t.useRef({frame:null,velocity:0,lastTimestamp:null,generation:0}),pt=t.useMemo(()=>({maxVelocity:_?.maxVelocity??fr.maxVelocity,minVelocity:_?.minVelocity??fr.minVelocity,deceleration:_?.deceleration??fr.deceleration,velocitySampleWindow:_?.velocitySampleWindow??fr.velocitySampleWindow,startVelocityThreshold:_?.startVelocityThreshold??fr.startVelocityThreshold}),[_]),Fe=t.useMemo(()=>({top:Math.max(0,E?.top??0),bottom:Math.max(0,E?.bottom??0)}),[E]);k.debug("[ScrollPane] ScrollPane rendered",()=>({contentSize:e,viewportSize:pe,scrollBarWidth:i,className:I,style:S,tapScrollCircleOptions:G,inertiaOptions:_,enablePointerDrag:m,contentInsets:Fe}));const Xe=t.useRef({contentSize:e,viewportSize:pe}),Ee=t.useMemo(()=>e>pe,[e,pe]),nt=t.useCallback((b,N)=>{let ce=N??Xe.current;N&&!(Number.isFinite(N.contentSize)&&Number.isFinite(N.viewportSize))&&(k.warn("[ScrollPane] scrollTo received non-finite dimsOverride; falling back to the committed dims",{dimsOverride:N}),ce=Xe.current);const{contentSize:j,viewportSize:ie}=ce,de=j>ie,Ye=M.current;if(k.debug("[ScrollPane] scrollTo called",()=>({newPosition:b,contentSize:j,viewportSize:ie,currentIsScrollable:de,prevPosition:Ye})),!de)return M.current!==0&&(M.current=0,x?.(0,Ye)),M.current;const be=typeof b=="function"?b(M.current):b;if(!Number.isFinite(be))return k.warn("[ScrollPane] scrollTo received a non-finite position; keeping the current position",{nextPosition:be}),M.current;const $e=Math.max(j-ie,0),Se=J(be,0,$e);return M.current!==Se&&(M.current=Se,x?.(Se,Ye)),M.current},[x]),Q=t.useRef(nt);t.useEffect(()=>{Q.current=nt},[nt]);const Ve=t.useCallback(()=>{const b=Ge.current;b.generation+=1,b.frame!==null&&cancelAnimationFrame(b.frame),b.frame=null,b.velocity=0,b.lastTimestamp=null},[]),Me=t.useRef(Ve);t.useEffect(()=>{Me.current=Ve},[Ve]),t.useEffect(()=>()=>{Me.current()},[]);const le=t.useCallback(b=>{if(!Ee)return;const{maxVelocity:N,minVelocity:ce,deceleration:j,startVelocityThreshold:ie}=pt,de=J(b,-N,N);if(Math.abs(de)<ie)return;Ve(),Ge.current.velocity=de,Ge.current.lastTimestamp=null;const Ye=Ge.current.generation,be=$e=>{const Se=Ge.current;if(Se.generation!==Ye)return;if(Se.lastTimestamp===null){Se.lastTimestamp=$e,Se.frame=requestAnimationFrame(be);return}const Ae=$e-Se.lastTimestamp;if(Se.lastTimestamp=$e,Ae<=0){Se.frame=requestAnimationFrame(be);return}const ct=Se.velocity;let Ze=ct;const Qe=j*Ae;ct>0?Ze=Math.max(0,ct-Qe):ct<0&&(Ze=Math.min(0,ct+Qe));const st=(ct+Ze)/2*Ae,xe=M.current;if(st!==0&&Q.current(Je=>Je+st),Ge.current.generation!==Ye)return;const me=M.current,{contentSize:bt,viewportSize:h}=Xe.current,C=Math.max(bt-h,0);Se.velocity=Ze;const ye=me===xe||me<=0&&Ze<=0||me>=C&&Ze>=0;if(Math.abs(Ze)<ce||ye){Ve();return}Se.frame=requestAnimationFrame(be)};Ge.current.frame=requestAnimationFrame(be)},[Ee,pt,Ve]),ge=t.useRef(le);t.useEffect(()=>{ge.current=le},[le]),t.useLayoutEffect(()=>{Xe.current={contentSize:e,viewportSize:pe}},[e,pe]),t.useLayoutEffect(()=>{const b=te.current;if(!b)return;const N=()=>{b.scrollTop!==0&&(k.debug("[ScrollPane] Native scroll detected, resetting to 0",()=>({scrollTop:b.scrollTop})),b.scrollTop=0),b.scrollLeft!==0&&(b.scrollLeft=0)};return b.addEventListener("scroll",N),()=>b.removeEventListener("scroll",N)},[]),t.useLayoutEffect(()=>{if(Ee){k.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change",()=>({contentSize:e,viewportSize:pe,scrollPosition:M.current}));const b=J(e-pe,0,e);M.current>b&&nt(b)}else nt(0)},[Ee,nt,e,pe]);const ue=t.useRef({isScrollable:Ee,viewportSize:pe,wheelSpeedMultiplier:V,overscrollBehavior:F});t.useLayoutEffect(()=>{ue.current={isScrollable:Ee,viewportSize:pe,wheelSpeedMultiplier:V,overscrollBehavior:F}},[Ee,pe,V,F]);const dt=t.useCallback(b=>{if(Zn(b))return!1;const{isScrollable:N,viewportSize:ce,wheelSpeedMultiplier:j,overscrollBehavior:ie}=ue.current,de=Kn(b,ce);if(de.isZoomGesture)return!1;if(de.isHorizontalDominant)return Ue.current?(on(b),b.preventDefault(),Ve(),Ue.current(de.horizontalDelta),!0):!1;if(!N||de.verticalDelta===0)return!1;let Ye=de.verticalDelta;if(j!==1&&(Ye*=j),ie!=="contain"){const be=M.current,$e=Math.max(Xe.current.contentSize-ce,0);if(Ye>0&&be>=$e||Ye<0&&be<=0)return!1}return on(b),b.preventDefault(),Ve(),k.debug("[ScrollPane] wheel event",()=>({deltaY:Ye,scrollPosition:M.current,wheelSpeedMultiplier:j,deltaMode:b.deltaMode,scrollTop:te.current?.scrollTop})),nt(be=>be+Ye),!0},[nt,Ve]);t.useEffect(()=>{const b=j=>{dt(j)},N=()=>{Ve()},ce=ne.current;return ce&&(ce.addEventListener("wheel",b,{passive:!1}),ce.addEventListener("pointerdown",N,{capture:!0,passive:!0})),()=>{ce&&(ce.removeEventListener("wheel",b),ce.removeEventListener("pointerdown",N,{capture:!0}))}},[dt,Ve]),t.useImperativeHandle(_e,()=>({scrollTo:(b,N)=>(Ve(),nt(b,N)),getScrollPosition:()=>M.current,getContentSize:()=>e,getViewportSize:()=>pe,applyWheel:dt}),[nt,e,pe,Ve,dt]);const w=t.useId(),De=Z?.id??w,fe=t.useRef({pointerType:"",pointerId:null,startClientY:0,startClientX:0,lastPanClientX:0,startScroll:0,isDragging:!1,shouldCancelNextClick:!1,clickResetTimer:null,velocitySamples:[],scale:1,scaleX:1}),D=t.useRef(m),at=t.useRef(g);t.useEffect(()=>{D.current=m},[m]),t.useEffect(()=>{at.current=g},[g]);const Ke=t.useRef(Ee);t.useEffect(()=>{Ke.current=Ee},[Ee]);const Tt=t.useRef(pt);t.useEffect(()=>{Tt.current=pt},[pt]),t.useEffect(()=>{const b=fe.current;if(m&&Ee&&(b.pointerId===null||Pr(b.pointerType,g))||b.pointerId===null)return;const N=te.current;b.clickResetTimer!==null&&(window.clearTimeout(b.clickResetTimer),b.clickResetTimer=null);const ce=b.isDragging&&b.shouldCancelNextClick,j=b.pointerId;b.pointerId=null,b.pointerType="",b.startClientY=0,b.startScroll=0,b.isDragging=!1,b.shouldCancelNextClick=ce,b.velocitySamples=[],b.scale=1,N?.hasPointerCapture(j)&&N.releasePointerCapture(j)},[m,g,Ee]),t.useEffect(()=>{const b=te.current;if(!b)return;const N=6,ce=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),j=()=>{const h=fe.current;h.pointerId=null,h.pointerType="",h.startClientY=0,h.startScroll=0,h.isDragging=!1,h.velocitySamples=[],h.scale=1},ie=()=>{const h=fe.current;h.clickResetTimer!==null&&(window.clearTimeout(h.clickResetTimer),h.clickResetTimer=null)},de=h=>{const C=fe.current,ye=ce();C.velocitySamples.push({clientY:h,time:ye});const Je=Tt.current.velocitySampleWindow;C.velocitySamples=C.velocitySamples.filter(Ce=>ye-Ce.time<=Je)},Ye=h=>h instanceof HTMLElement&&h.closest("[data-scrollpane-ignore-drag='true']")!==null,be=h=>{const C=fe.current;C.shouldCancelNextClick&&(h.preventDefault(),h.stopPropagation(),C.shouldCancelNextClick=!1)},$e=h=>{const C=fe.current;if(!C.isDragging){if(C.isDragging=!0,C.shouldCancelNextClick=!0,!b.hasPointerCapture(h.pointerId))try{b.setPointerCapture(h.pointerId)}catch{}de(h.clientY)}},Se=h=>h.isTrusted||h.target===b,Ae=h=>{const C=fe.current;b.hasPointerCapture(h)&&b.releasePointerCapture(h),C.shouldCancelNextClick=!1,ie(),j()},ct=h=>{const C=fe.current;if(C.pointerId!==h.pointerId)return;if(h.buttons===0&&Jn(h.pointerType)){Ae(h.pointerId);return}if(!(D.current&&Ke.current)||!Pr(h.pointerType,at.current))return;if(!C.isDragging){const Rt=Math.abs(h.clientY-C.startClientY),et=rt.current?Math.abs(h.clientX-C.startClientX):0;if(Math.max(Rt,et)<N||($e(h),!C.isDragging))return}de(h.clientY);const ye=(h.clientY-C.startClientY)/(C.scale||1),Je=C.startScroll-ye;Q.current(Je);const Ce=rt.current;if(Ce){const Rt=h.clientX-C.lastPanClientX;C.lastPanClientX=h.clientX,Rt!==0&&Ce(-Rt/(C.scaleX||1))}h.cancelable&&h.preventDefault()},Ze=()=>{const h=fe.current;return h.pointerId!==null||!h.shouldCancelNextClick?!1:(ie(),h.clickResetTimer=window.setTimeout(()=>{const C=fe.current;C.shouldCancelNextClick=!1,C.clickResetTimer=null},0),!0)},Qe=h=>{const C=fe.current;if(C.pointerId!==h.pointerId){Ze();return}C.isDragging&&C.shouldCancelNextClick&&h.cancelable&&(h.preventDefault(),h.stopPropagation()),C.isDragging&&de(h.clientY);let ye=0;if(C.isDragging&&C.velocitySamples.length>=2){const Ce=C.velocitySamples,Rt=Tt.current.velocitySampleWindow,et=Ce[Ce.length-1],it=Ce.find(Pe=>et.time-Pe.time<=Rt)??Ce[0];if(et&&it&&et.time!==it.time){const Pe=et.clientY-it.clientY,Ft=et.time-it.time;ye=-(Pe/Ft)/(C.scale||1)}}ie(),C.shouldCancelNextClick&&(C.clickResetTimer=window.setTimeout(()=>{const Ce=fe.current;Ce.shouldCancelNextClick=!1,Ce.clickResetTimer=null},0));const Je=Tt.current.startVelocityThreshold;j(),b.hasPointerCapture(h.pointerId)&&b.releasePointerCapture(h.pointerId),Math.abs(ye)>=Je&&ge.current?.(ye)},Oe=h=>{if(fe.current.pointerId!==null){if(!h.isPrimary||h.pointerType!==fe.current.pointerType)return;Ae(fe.current.pointerId)}if(fe.current.shouldCancelNextClick&&(ie(),fe.current.shouldCancelNextClick=!1),!(D.current&&Ke.current)||!Pr(h.pointerType,at.current)||h.button!==0&&h.pointerType==="mouse"||h.ctrlKey||h.metaKey||h.altKey||Ye(h.target))return;window.dispatchEvent(new CustomEvent(mr,{detail:{paneId:w}})),Me.current?.();const C=fe.current;ie(),C.pointerId=h.pointerId,C.pointerType=h.pointerType,C.startClientY=h.clientY,C.startClientX=h.clientX,C.lastPanClientX=h.clientX,C.startScroll=M.current,C.scale=Ar(b,"y"),C.scaleX=rt.current?Ar(b,"x"):1,C.isDragging=!1,C.shouldCancelNextClick=!1,C.velocitySamples=[]},st=h=>{if(fe.current.pointerId!==h.pointerId){Ze();return}Se(h)&&Ae(h.pointerId)},me=[["click",be,!0],["pointerdown",Oe,{passive:!1}],["lostpointercapture",h=>{h.target!==b||fe.current.pointerId!==h.pointerId||Ae(h.pointerId)},void 0]],bt=[["pointermove",ct,{passive:!1}],["pointerup",Qe,void 0],["pointercancel",st,void 0]];return wr(b,me,"add"),wr(window,bt,"add"),()=>{wr(b,me,"remove"),wr(window,bt,"remove");const h=fe.current;h.pointerId!==null&&b.hasPointerCapture(h.pointerId)&&b.releasePointerCapture(h.pointerId),ie(),j()}},[w]);const gt=t.useCallback(b=>(Ve(),nt(b)),[nt,Ve]);return A.jsxs("div",{ref:ne,"data-testid":y,"data-self-measured":ke?"true":void 0,className:It.twMerge("aqvs-scroll-pane",I),style:S,children:[A.jsxs("div",{ref:te,className:It.twMerge("aqvs-scroll-pane-content"),"data-testid":"aqvs-scroll-pane-content",style:{height:ke?void 0:pe,paddingTop:Fe.top,paddingBottom:Fe.bottom,...m&&Ee&&g.some(b=>b==="touch"||b==="pen")?{touchAction:"none"}:{}},...Z,id:De,children:[P,r(M.current)]}),A.jsx(Br,{contentSize:e,viewportSize:pe,stretchMainSize:ke,scrollPosition:M.current,onScroll:gt,enableThumbDrag:a,enableTrackClick:o,enableArrowButtons:u,scrollBarWidth:i,ariaControls:De,tapScrollCircleOptions:G,itemCount:Re,renderThumbOverlay:Te,visibleStartIndex:z,visibleEndIndex:K,locale:se,labels:he},"scrollbar"),Y?.()]})}),ln=(r,e,n)=>Math.min(Math.max(r,e),n),es=({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,m=.8+e*.18,g=3*n,x=6*n,I=22*n,y=Math.abs(u)+x,S=u>0?g:-Math.abs(u)-g,P=Math.max(2.5,3*n),G=ln(r.offsetX,-i,i),_=ln(r.offsetY,-i,i),Re=i*.35,Te=G/i*Re,V=_/i*Re,F=Te*.45,oe=V*.45,L=Math.max(I*.38,6),E=.65+e*.2,z=r.active;return A.jsxs(A.Fragment,{children:[A.jsx("div",{className:"aqvs-tap-scroll-circle-gradient",style:{transform:`scale(${o}, ${a})`,transition:z?"40ms transform ease-out":"200ms ease transform"}}),A.jsx("div",{className:"aqvs-sample-visual-pupil",style:{width:I,height:I,transform:`translate(calc(-50% + ${Te}px), calc(-50% + ${V}px)) scale(${o}, ${m*a})`,transition:z?"70ms transform ease-out":"200ms ease transform"}}),A.jsx("div",{className:"aqvs-sample-visual-highlight",style:{width:L,height:L,transform:`translate(calc(-50% + ${F}px), calc(-50% + ${oe}px)) scale(${o}, ${a})`,opacity:E,boxShadow:"0 0 8px rgba(255,255,255,0.45)",transition:z?"120ms opacity 150ms, 120ms transform ease-out ease-out":"220ms ease transform, 240ms opacity ease"}}),A.jsx("div",{className:"aqvs-sample-visual-rod",style:{width:P,height:y,transform:`translate(-50%, ${S}px)`,opacity:e,transition:z?"40ms height, 60ms opacity ease-out ease-out":"200ms ease height, 120ms ease opacity"}})]})},ir=100,ts=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},Nr=(r,e)=>{if(!Number.isFinite(r))throw new Error(`valueFn returned a non-finite value at index ${e}: ${r}`);return r},ar=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 _t{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 m=s?.sampleRange??{from:0,to:Math.min(ir-1,i-1)};let g=Math.max(0,Math.trunc(m.from)),x=Math.min(Math.trunc(m.to),i-1);g>x&&(g=0,x=Math.min(ir-1,i-1)),o={from:g,values:_t._collectValidatedValues(n,g,x)}}}else if(i>0){const m=s?.sampleRange??{from:0,to:Math.min(ir-1,i-1)};let g=Math.max(0,Math.trunc(m.from)),x=Math.min(Math.trunc(m.to),i-1);if(g>x&&(g=0,x=Math.min(ir-1,i-1)),i>ir)a=_t._sampleBaseValueStrided(n,i,ir),s?.materialize&&(o={from:g,values:_t._collectValidatedValues(n,g,x)});else{const I=_t._collectValidatedValues(n,g,x);a=_t._modeOrMedian([...I]),s?.materialize&&(o={from:g,values:I})}}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 m=0;m<o.values.length;m++){const g=o.from+m;if(g>=this.size)break;const x=o.values[m]-this.baseValue;x!==0&&(this.deltas.set(g,x),this._updateTree(g,x))}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(Nr(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[m,g]of i.entries())g===a&&o.push(m);const u=o.reduce((m,g)=>m+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(Nr(e(o),o));return _t._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=ar(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,m=a-u;m!==0&&n.push({index:i,change:m}),s.set(i,o+m)}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=ar(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=Nr(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 m=Math.max(0,Math.trunc(u.from)),g=Math.min(Math.trunc(u.to),this.size-1);for(let x=m;x<=g;x++)this._materialize(x)}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 m=(this.tree.get(o)??0)+this.baseValue*a;(n?i+m<e:i+m<=e)&&(s=o,i+=m)}}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=ts(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,m,g,x=this.total;for(;o<=u;){const S=o+u>>1n,P=Number(S),G=this.prefixSum(P);if(x=G.total,s?G.cumulative>=e:G.cumulative<=e)if(m=S,g=G,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 I=g,y=m!==void 0?Number(m):-1;if(a&&y>=0){const S=this.deltas.get(y)??0;if(this._materialize(y),(this.deltas.get(y)??0)!==S)continue}return{index:y,total:x,cumulative:I?.cumulative,currentValue:I?.currentValue,safeIndex:I?.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=J(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 m=this.tree.get(o)??0;a+=m;const g=ar(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&&k.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=ar(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&&k.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=ar(a);if(o===0)break;a+=o}for(;a<=i;){this.tree.set(a,(this.tree.get(a)??0)+n);const o=ar(a);if(o===0)break;a+=o}}_growSize(e,n){if(this.size=n,this.deltas.size>0){const s=_t._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 rs=(r,e)=>{const n=r?.sampleRange,s=e?.sampleRange;return n===s?!1:n&&s?n.from!==s.from||n.to!==s.to:!0},jr=(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 _t(s,e,n));const o=i.current,u=a.current,m=u.size!==s,g=u.valueOrFn!==e,x=rs(u.options,n)||u.options?.baseValue!==n?.baseValue,I=u.size===0&&s>0&&(!i.current||i.current.base===0);if(g||x){const y=n?.resetOnValueFnChange??!0;x||g&&y||I?(n?.debug&&k.debug("[useFenwickMapTree] reset",{valueOrFnChanged:g,optionsChanged:x}),o.reset(s,e,n)):(m&&(n?.debug&&k.debug("[useFenwickMapTree] resize (with valueFn change)",{from:u.size,to:s}),o.changeSize(s)),n?.debug&&k.debug("[useFenwickMapTree] setValueFn (no reset)",{valueOrFnChanged:g}),o.setValueFn(e,{reset:!1})),a.current={size:s,valueOrFn:e,options:n}}else m&&(n?.debug&&k.debug("[useFenwickMapTree] resize",{from:u.size,to:s}),I?o.reset(s,e,n):o.changeSize(s),a.current={size:s,valueOrFn:e,options:n});return o};class ns{key;value;prev=null;next=null;constructor(e,n){this.key=e,this.value=n}}class zr{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 Rn(r){const e=t.useRef(new Map),n=t.useRef(new zr),s=Math.floor(r),i=t.useRef(s);t.useEffect(()=>{if(i.current=s,Number.isNaN(s)||s<0){k.warn(`useLruCache: invalid capacity ${r}; the cache will not store any entries.`),e.current.clear(),n.current=new zr;return}if(Number.isFinite(s))for(;e.current.size>s;){const x=n.current.removeHead();if(x)e.current.delete(x.key);else break}},[r,s]);const a=t.useCallback(x=>{const I=e.current.get(x);if(I)return n.current.moveToTail(I),I.value},[]),o=t.useCallback((x,I)=>{const y=i.current;if(Number.isNaN(y)||y<=0)return;let S=e.current.get(x);if(S)S.value=I,n.current.moveToTail(S);else{if(e.current.size>=y){const P=n.current.removeHead();P&&e.current.delete(P.key)}S=new ns(x,I),e.current.set(x,S),n.current.addToTail(S)}},[]),u=t.useCallback(x=>e.current.has(x),[]),m=t.useCallback(x=>{const I=e.current.get(x);I&&(n.current.remove(I),e.current.delete(x))},[]),g=t.useCallback(()=>{e.current.clear(),n.current=new zr},[]);return t.useMemo(()=>({get:a,set:o,has:u,remove:m,clear:g}),[a,o,u,m,g])}const ss=1e4,is=()=>{const{get:r,set:e,has:n,clear:s}=Rn(ss);return t.useMemo(()=>({get:r,set:e,has:n,clear:s}),[r,e,n,s])},as=(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))}},[])},cn=-200,un={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},os=r=>{const e=t.useRef(r);e.current=r;const n=t.useRef(un),s=t.useRef(null),[i,a]=t.useState(!1),o=t.useRef(null),u=t.useRef(null),m=t.useRef({residual:0,direction:0}),g=t.useRef({residual:0,direction:0}),x=t.useCallback(()=>{o.current!==null&&(window.cancelAnimationFrame(o.current),o.current=null),u.current=null,m.current={residual:0,direction:0},g.current={residual:0,direction:0}},[]),I=t.useCallback((V,F,oe,L,E,z)=>{const K=F>0?1:F<0?-1:0;K!==0&&K!==V.direction&&(V.direction=K,V.residual=0),V.residual+=F*oe;const Y=Math.max(E(),0);Y>0&&(V.residual=J(V.residual,-Y,Y));const H=V.residual;if(H===0)return{actualDelta:0,atBoundary:!1};const Z=L(),se=z(H),he=se-Z;V.residual-=he;const _e=H<0&&Z+H<=0,M=H>0&&Z+H>=Y,ne=H<0&&(se<=0||_e&&he===0)||H>0&&(se>=Y||M&&he===0);return ne&&(V.residual=0),{actualDelta:he,atBoundary:ne}},[]),y=t.useCallback(V=>{const F=e.current,oe=n.current;if(!oe.active||oe.direction===0){x();return}const L=u.current??V,E=Math.max((V-L)/1e3,0),z=Math.min(E,bn);if(u.current=V,z<=0){o.current=window.requestAnimationFrame(y);return}const K=vn({offsetX:oe.offsetX,offsetY:oe.offsetY,maxDistance:F.maxDistance,x:F.xSpeedParams,y:F.ySpeedParams}),Y=I(m.current,K.x,z,F.getHx,F.getMaxHx,he=>F.applyHxRef.current(F.getHx()+he));Y.actualDelta!==0&&(F.pendingColAnchorRef.current=null);const H=I(g.current,K.y,z,F.getVy,F.getMaxVy,F.applyVy),Z=F.getMaxHx()<=0||Y.atBoundary||oe.offsetX===0,se=F.getMaxVy()<=0||H.atBoundary||oe.offsetY===0;if(Z&&se){x();return}o.current=window.requestAnimationFrame(y)},[x,I]),S=t.useCallback(()=>{o.current===null&&(u.current=null,m.current={residual:0,direction:0},g.current={residual:0,direction:0},o.current=window.requestAnimationFrame(y))},[y]),P=t.useCallback(()=>{n.current={...un},a(!1),s.current?.reset(),x()},[x]),G=t.useCallback(V=>{n.current=V,a(V.active),V.active&&V.direction!==0?S():x()},[S,x]),{enabled:_,xExtentFreshness:Re,yExtentFreshness:Te}=r;return t.useEffect(()=>{const V=n.current;!V.active||V.direction===0||S()},[Re,Te,S]),t.useEffect(()=>{const V=()=>{P()};return window.addEventListener(mr,V),()=>{window.removeEventListener(mr,V)}},[P]),t.useEffect(()=>{if(!_)return;const V=F=>{if(!n.current.active||n.current.pointerId===F.pointerId)return;const oe=F.target;if(!(oe instanceof Node)){P();return}s.current?.getElement()?.contains(oe)||P()};return document.addEventListener("pointerdown",V,!0),()=>{document.removeEventListener("pointerdown",V,!0)}},[_,P]),t.useEffect(()=>{_||P()},[_,P]),t.useEffect(()=>()=>{x()},[x]),{isTapActive:i,handleTapCircleDragChange:G,tapCircleHandleRef:s}},We=(r,e)=>e<=0?0:J(r,0,e-1),fn=r=>({top:Math.max(0,r?.top??0),bottom:Math.max(0,r?.bottom??0)}),wt=(r,e)=>r<=e?0:r-e,tr=(r,e)=>r<=0?0:r+e,hr=1e3,Dr=2e3,Mn=1048576,ls=40,dr=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},cs=(r,e,n,s,i,a,o,u)=>{const m=dr(s);if(m===0n)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const g=L=>L<0n?0n:L>=m?m-1n:L,x={materializeOption:{materialize:!1}},{index:I,cumulative:y}=a.findIndexAtOrAfter(r,x);let S;I===-1?S=m-1n:(y===r?S=dr(I+1):S=dr(I),S>=m&&(S=m-1n)),r<=0&&(S=0n),u&&r>=o&&(S=m-1n);const P=L=>{const E=Number(L);if(!Number.isSafeInteger(E))return null;const{cumulative:z}=a.prefixSum(E,{materializeOption:{materialize:!1}});if(!Number.isFinite(z))return null;const{index:K}=a.findIndexAtOrAfter(z+.5,{materializeOption:{materialize:!1}});if(K===-1)return null;const Y=dr(K);return Y>L?Y:null},G=L=>{let E=0,z=L,K=L,Y=0n,H=0;for(;z<m&&E<e;){const Z=Number(z),se=i(Z);if(E+=se,K=z,z+=1n,Y+=1n,!Number.isFinite(se)||se<0)break;if(se===0){if(H+=1,H>hr){const he=P(K);if(he!==null&&he>z)z=he,H=0;else if(he!==null&&he===z&&i(Number(z))>0)H=0;else break}}else H=0}return Y===0n&&(K=L),{height:E,end:K}};let{height:_,end:Re}=G(S);if(_<e&&S>0n){let L=S,E=_,z=0;for(;L>0n&&E<e;){L-=1n;const Y=Number(L),H=i(Y);if(E+=H,!Number.isFinite(H)||H<0)break;if(H===0){if(z+=1,z>hr){const Z=Number(L);if(!Number.isSafeInteger(Z))break;const{cumulative:se}=a.prefixSum(Z,{materializeOption:{materialize:!1}});if(!Number.isFinite(se))break;const{index:he}=a.findIndexAtOrAfter(se-.5,{materializeOption:{materialize:!1}}),_e=he===-1?-1n:dr(he);if(_e>=0n&&_e<L)L=_e+1n,z=0;else if(_e===L&&L>=1n&&i(Number(L-1n))>0)z=0;else break}}else z=0}S=g(L);const K=G(S);_=K.height,Re=K.end}const Te=g(S),V=g(Re),F=g(Te-BigInt(Math.max(0,n))),oe=g(V+BigInt(Math.max(0,n)));return{renderingStartIndex:We(Number(F),s),renderingEndIndex:We(Number(oe),s),visibleStartIndex:We(Number(Te),s),visibleEndIndex:We(Number(V),s)}},yn=(r,e,n,s,i,a,o)=>{if(s===0)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const u=Number.isFinite(o),m=u?Math.min(Math.max(0,r),o):Math.max(0,r);if(s>=Number.MAX_SAFE_INTEGER)return cs(m,e,n,s,i,a,o,u);const{index:g,cumulative:x,currentValue:I}=a.findIndexAtOrAfter(m,{materializeOption:{materialize:!1}}),y=g===-1?e<=0||(x??0)<m+(I??0)?s-1:0:g;let S=We(y,s),P=0;if(g!==-1&&x===m)S=We(g+1,s),P=0;else if(S===g&&x!==void 0&&I!==void 0)P=x-I-m;else{const{cumulative:L,currentValue:E}=a.prefixSum(S,{materializeOption:{materialize:!1}});P=(L??0)-(E??0)-m}const G=P,_=(L,E)=>{let z=L,K=E,Y=0;for(;z<s&&K<e;){const H=i(z);if(K+=H,z++,!Number.isFinite(H)||H<0)break;if(H===0){if(Y++,Y>hr){const{cumulative:Z}=a.prefixSum(z-1,{materializeOption:{materialize:!1}}),{index:se}=Number.isFinite(Z)?a.findIndexAtOrAfter(Z+.5,{materializeOption:{materialize:!1}}):{index:-1};if(se>z)z=se,Y=0;else if(se===z&&i(z)>0)Y=0;else break}}else Y=0}return{cursor:z,height:K}},Re=_(S,P);let Te=Re.cursor;if(P=Re.height,P<e&&S>0){let L=P+Math.abs(Math.min(0,G)),E=S-1,z=0;for(;E>=0&&L<e;){const Y=i(E);if(L+=Y,!Number.isFinite(Y)||Y<0){E--;break}if(Y===0){if(z++,z>hr){const{cumulative:H}=a.prefixSum(E,{materializeOption:{materialize:!1}}),{index:Z}=Number.isFinite(H)?a.findIndexAtOrAfter(H-.5,{materializeOption:{materialize:!1}}):{index:-1};if(Z!==-1&&Z<E){E=Z,z=0;continue}if(Z===E&&E>=1&&i(E-1)>0)z=0;else{E--;break}}}else z=0;E--}S=We(E+1,s);const K=_(S,0);Te=K.cursor,P=K.height}const V=We(S-n,s),F=We(Math.max(Te-1,S),s),oe=We(F+n,s);return{renderingStartIndex:V,renderingEndIndex:oe,visibleStartIndex:S,visibleEndIndex:F}},dn=(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 m=u-i.last;if(s===0||i.last===0||m>=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])},us=t.memo(({index:r,top:e,height:n,item:s,children:i,clipItemHeight:a,enableKeyboardNavigation:o,onKeyDown:u,onEscapeKeyDown:m,onFocus:g,registerItemRef:x})=>{const I=t.useCallback(_=>x(r,_),[r,x]),y=t.useCallback(_=>u(_,r),[r,u]),S=t.useCallback(_=>m?.(_,r),[r,m]),P=t.useCallback(()=>g(r),[r,g]),G=t.useCallback(_=>{_.currentTarget.focus({preventScroll:!0})},[]);return A.jsx("div",{ref:I,"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?G:void 0,onKeyDownCapture:o?y:void 0,onKeyDown:o&&m?S:void 0,onFocusCapture:o?P:void 0,children:i(s,r)})}),fs=({itemCount:r,getItem:e,getItemKey:n,getItemHeight:s,viewportSize:i,overscanCount:a=15,className:o,testId:u,onScroll:m,onRangeChange:g,children:x,background:I,initialScrollIndex:y,initialScrollOffset:S,initialScrollAnchor:P,callbackThrottleMs:G=5,contentInsets:_,onItemFocus:Re,scrollBarOptions:Te,behaviorOptions:V,onWheelHorizontal:F,onPanHorizontal:oe,horizontalKeyInputs:L,horizontalKeyStep:E=ls,contentProps:z,liveRegion:K,locale:Y,labels:H},Z)=>{const{width:se,enableThumbDrag:he,enableTrackClick:_e,enableArrowButtons:M,enableScrollToTopBottomButtons:ne,renderThumbOverlay:te,tapScrollCircleOptions:ke}=Te??{},ee=t.useMemo(()=>$r(Y,H),[Y,H]),{enablePointerDrag:He,pointerDragInputs:pe,enableKeyboardNavigation:re=!0,enableEscapeRowReturn:Ue=!1,wheelSpeedMultiplier:rt,inertiaOptions:Ge,overscrollBehavior:pt,clipItemHeight:Fe=!1,resetOnGetItemHeightChange:Xe=!1}=V??{},[Ee,nt]=t.useState(0),Q=i??Ee,Ve=t.useCallback(c=>{nt(d=>d===c?d:c)},[]),Me=t.useRef(null),le=t.useRef({renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0,scrollPosition:0,totalHeight:0}),ge=t.useRef(P&&r>0?{index:J(Math.trunc(P.index),0,r-1),align:"top",offset:-Math.max(0,P.offsetPx??0)}:null),ue=t.useRef(!1),dt=t.useRef(!0);t.useEffect(()=>{if(dt.current){dt.current=!1;return}Xe&&(ge.current=null)},[Xe,s]);const w=t.useMemo(()=>fn(_),[_]),[De]=t.useState(()=>{const d=P?.index??y,v=typeof d=="number"&&Number.isFinite(d)?Math.max(0,Math.trunc(d)):0;return{from:Math.max(0,v-50),to:v+50}}),fe=t.useMemo(()=>({sampleRange:De,resetOnValueFnChange:Xe,materialize:!0}),[Xe,De]),D=jr(r,s,fe),[at]=t.useState(()=>{let c=0,d=0;if(P&&r>0){const v=J(Math.trunc(P.index),0,r-1),$=Math.max(0,P.offsetPx??0),q=J(v-a*2,0,r-1),B=J(v+a*2,0,r-1),U=v>0||$>0?{materializeOption:{materialize:!0,ranges:[{from:q,to:B}]}}:void 0,{cumulative:we,total:qe,currentValue:Ne}=D.prefixSum(v,U),ze=Math.max(we-Ne+$,0);c=tr(ze,w.top),d=qe??D.getTotal()}else if(typeof y=="number"){const v=J(y,0,r-1),$=J(v-a*2,0,r-1),q=J(v+a*2,0,r-1),B=y>0?{materializeOption:{materialize:!0,ranges:[{from:$,to:q}]}}:void 0,{cumulative:U,total:we,currentValue:qe}=D.prefixSum(y,B),Ne=Math.max(U-qe,0);c=tr(Ne,w.top),d=we??D.getTotal()}else typeof S=="number"&&(c=tr(Math.max(S,0),w.top)),d=D.getTotal();return{position:c,total:d}}),[Ke,Tt]=t.useState(at.position),[gt,b]=t.useState(at.total),N=t.useRef(at.position),ce=t.useRef(w.top),j=t.useRef(m??void 0),ie=t.useRef(g??void 0),de=t.useRef(F),Ye=(L?.length??0)>0,be=!!F;t.useEffect(()=>{Ye&&(re||k.warn("[VirtualScroll] horizontalKeyInputs is set but behaviorOptions.enableKeyboardNavigation is false; horizontal keyboard scrolling is disabled because the row key handler is not mounted."),be||k.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(E)&&E>0||k.warn(`[VirtualScroll] horizontalKeyStep must be a finite positive number, received ${E}. Horizontal arrow keys are left untouched.`))},[Ye,be,re,E]);const $e=t.useRef(new Map),Se=t.useRef(null),Ae=t.useRef(null),[ct,Ze]=t.useState(null),[Qe,Oe]=t.useState(!1),st=t.useRef(null),xe=t.useRef(!1),me=t.useRef(0),bt=t.useRef(!1),h=t.useRef(!1),C=t.useRef(r);C.current!==r&&(C.current=r,h.current=!0),t.useLayoutEffect(()=>{j.current=m??void 0,ie.current=g??void 0,de.current=F},[g,m,F]);const ye=t.useCallback(c=>{if(re&&c&&typeof c.focus=="function")try{c.focus({preventScroll:!0})}catch{c.focus()}},[re]),Je=t.useCallback((c,{position:d,totalHeight:v})=>{c(d,v)},[]),Ce=dn(j,G,Je),Rt=t.useCallback((c,d)=>{c(d)},[]),et=dn(ie,G,Rt),it=t.useRef(w.top);it.current=w.top;const Pe=t.useRef(Ce);Pe.current=Ce,t.useEffect(()=>(ue.current=!1,()=>{ue.current=!0,st.current&&(clearTimeout(st.current),st.current=null)}),[]),t.useEffect(()=>{re||($e.current.clear(),Se.current=null,Ae.current=null)},[re]);const Ft=t.useCallback((c,d)=>{if(!d){$e.current.delete(c);return}re&&($e.current.set(c,d),Se.current===c&&(Se.current=null,Ae.current=c,ye(d)))},[re,ye]),rr=.01,Ht=t.useRef({rafId:null,loopActive:!1,idleFrames:0,lastRenderedPosition:at.position}),ve=t.useCallback(()=>{const c=Ht.current;c.rafId!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(c.rafId),c.rafId=null,c.loopActive=!1,c.idleFrames=0},[]);t.useEffect(()=>()=>{ve()},[ve]);const Nt=t.useRef(()=>{}),Bt=t.useCallback(()=>{const c=Ht.current;c.rafId=null;const d=N.current,v=wt(d,it.current),$=D.getTotal();if(Tt(B=>Math.abs(B-d)<rr?B:d),Math.abs(c.lastRenderedPosition-d)>=rr?(Pe.current({position:v,totalHeight:$}),c.lastRenderedPosition=d,c.idleFrames=0):c.idleFrames+=1,c.idleFrames>=2){ve();return}if(typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(B=>Nt.current(B));return}c.loopActive=!1},[D,ve]);Nt.current=Bt;const Jt=t.useCallback(()=>{const c=Ht.current;if(c.idleFrames=0,!c.loopActive){if(c.loopActive=!0,typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(Bt);return}c.loopActive=!1}},[Bt]),Ie=t.useCallback((c,d)=>{const v=d?.immediate??!1,$=wt(c,w.top);if(N.current=c,v){Ht.current.lastRenderedPosition=c,Ht.current.idleFrames=0,Tt(c),Ce({position:$,totalHeight:D.getTotal()});return}Jt()},[Jt,D,w.top,Ce]),xt=t.useCallback((c,d=0)=>{const v=Me.current;if(!v)return c;const $=v.getScrollPosition();me.current+=1;const q=v.getContentSize()+d,B=v.getViewportSize(),U=v.scrollTo(c,{contentSize:q,viewportSize:B});return U===$&&(me.current=Math.max(0,me.current-1)),Math.abs(U-c)>.5&&(bt.current=!0),U},[]),Xt=t.useRef(!1);t.useEffect(()=>{if(!Xt.current)if(Xt.current=!0,P==null&&typeof y!="number"&&typeof S=="number"){const c=tr(Math.max(S,0),w.top),d=Math.abs(c-N.current)>.5;Ie(c,{immediate:!0}),d&&Me.current?.scrollTo(c)}else Ie(N.current,{immediate:!0})},[P,y,S,w.top,Ie]),t.useEffect(()=>{const c=D.getTotal();if(gt!==c){b(c);return}if(bt.current){bt.current=!1;const d=Me.current;if(d&&Math.abs(d.getScrollPosition()-N.current)>.5){const v=xt(N.current);bt.current=!1,Ie(v,{immediate:!0})}}},[D,gt,r,xt,Ie]),t.useEffect(()=>{if(ge.current!==null){const{index:c,align:d,offset:v}=ge.current,$=We(c,r),{cumulative:q,currentValue:B}=D.prefixSum($,{materializeOption:{materialize:!1}});if(q!==void 0&&B!==void 0){const U=Math.max(q-B,0);let we=U;d==="bottom"?we=q-Q:d==="center"&&(we=U+B/2-Q/2),v&&(we-=v),we=Math.max(0,we);const qe=Math.max(0,gt+w.top+w.bottom-Q),Ne=Math.min(tr(we,w.top),qe);Math.abs(Ne-N.current)>1&&(k.debug("[VirtualScroll] Drift correction",{from:N.current,to:Ne,targetIndex:$}),me.current===0&&(me.current+=1),Me.current?.scrollTo(Ne),Ie(Ne,{immediate:!0}))}}h.current=!1},[gt,D,r,w.top,Ie,Q,w.bottom]),t.useEffect(()=>{const c=ce.current;if(c===w.top||(ce.current=w.top,ge.current))return;const d=wt(N.current,c),v=tr(d,w.top);N.current=v,Me.current?.scrollTo(v),Ie(v,{immediate:!0})},[w.top,Ie]);const Lt=t.useCallback((c,d)=>{if(r===0)return;const v=We(c,r),$=D.get(v),q=d-$,B=D.update(v,d);B!==void 0&&b(B),k.debug("[VirtualScroll] Updated item size manually",{index:v,size:d,total:B});let U=ge.current?ge.current.index:null;if(U===null){const we=N.current,qe=fn(_).top,Ne=wt(we,qe),{index:ze,cumulative:ot}=D.findIndexAtOrAfter(Ne,{materializeOption:{materialize:!1}});U=ot!==void 0&&ot===Ne?ze+1:ze}if(U!==-1&&v<U&&q!==0){const we=N.current,qe=we+q;xt(qe,q),Ie(qe,{immediate:!0}),k.debug("[VirtualScroll] Adjusted scroll for layout shift (manual update)",{from:we,to:qe,causedByIndex:v,delta:q,activeVisibleStartIndex:U})}},[D,r,xt,Ie,_]),mt=t.useCallback((c,d)=>{if(!Me.current||r===0)return;const v=We(c,r),$=We(v-a*2,r),q=We(v+a*2,r),{cumulative:B,total:U,currentValue:we}=D.prefixSum(v,{materializeOption:{materialize:!0,ranges:[{from:$,to:q}]}});if(k.debug("[VirtualScroll] Scrolling to index:",v,"ItemBottom:",B,"Total height:",U,"ItemHeight:",we,"safeIndexFrom:",$,"safeIndexTo:",q),!U)return;const qe=Math.max(B-we,0);let Ne=qe;d?.align==="bottom"?Ne=B-Q:d?.align==="center"&&(Ne=qe+we/2-Q/2),d?.offset&&(Ne-=d.offset),Ne=Math.max(0,Ne);const ze=tr(Ne,w.top),ot=Me.current?.getContentSize()??U+w.top+w.bottom,lt=Math.max(0,ot-Q),ft=Math.min(ze,lt);ge.current={index:v,align:d?.align,offset:d?.offset};const Zt=Me.current?.getScrollPosition()??-1,cr=Math.abs(Zt-ft)>.5;xe.current=!1,me.current=0,cr&&(xe.current=!0,me.current+=1,Me.current?.scrollTo(ft)),b(U),Ie(ft,{immediate:!0}),k.debug("[VirtualScroll] Setting scroll position to:",ft,{original:ze,max:lt})},[D,a,r,w.top,w.bottom,Q,Ie]),f=t.useRef(P&&r===0?P:null);t.useEffect(()=>{const c=f.current;!c||r===0||(f.current=null,mt(J(Math.trunc(c.index),0,r-1),{align:"top",offset:-Math.max(0,c.offsetPx??0)}))},[r,mt]);const T=t.useCallback(c=>{if(!Me.current||r===0)return;const d=D.getTotal(),v=J(Math.floor(c),0,d),{index:$,cumulative:q,currentValue:B}=D.findIndexAtOrAfter(v,{materializeOption:{materialize:!1}}),we=(q??0)-(B??0)-v;mt($,{offset:we})},[D,r,mt]),O=t.useCallback(()=>{if(r===0)return null;const c=wt(N.current,w.top),{index:d,cumulative:v,currentValue:$}=D.findIndexAtOrAfter(c,{materializeOption:{materialize:!1}});if(d===-1)return{index:r-1,offsetPx:0};if(v===c)return{index:J(d+1,0,r-1),offsetPx:0};const q=(v??0)-($??0);return{index:d,offsetPx:Math.max(0,c-q)}},[D,r,w.top]),W=t.useCallback(c=>{const d=wt(N.current,w.top),v=typeof c=="function"?c(d):c;T(v);const $=Me.current?.getScrollPosition(),q=typeof $=="number"?$:N.current;return Ie(q),wt(q,it.current)},[w.top,T,Ie]),Le=t.useCallback(c=>{const d=Me.current;if(!d)return wt(N.current,it.current);const v=d.scrollTo($=>$+c);return wt(v,it.current)},[]),Be=t.useCallback(c=>Me.current?.applyWheel(c)??!1,[]),ut=t.useCallback((c,d)=>{k.debug("[VirtualScroll] Scroll position changed:",c);const v=xe.current;v&&(xe.current=!1);const $=me.current>0;$&&(me.current=0);const q=h.current&&C.current===r;if(v||$||q||(ge.current=null),Ie(c),ne){if(v||$)return;const B=c-d;if(k.debug("[VirtualScroll] Scroll diff:",B,"New:",c,"Prev:",d),Math.abs(B)>1){const U=B>0?"down":"up";Ze(U),Oe(!0),k.debug("[VirtualScroll] Showing scroll buttons. Direction:",U),st.current&&clearTimeout(st.current),st.current=setTimeout(()=>{Oe(!1),k.debug("[VirtualScroll] Hiding scroll buttons")},2e3)}}},[Ie,ne,r]),je=t.useMemo(()=>wt(Ke,w.top),[w.top,Ke]),zt=t.useMemo(()=>{const c=D.getTotal(),d=yn(je,Q,a,r,s,D,c);return k.debug("[VirtualScroll] Calculated rendering range:",()=>({...d,scrollPosition:je,renderingContentSize:c,overscanCount:a,viewportSize:Q})),d},[je,Q,a,r,s,D]),{renderingStartIndex:vt,renderingEndIndex:kt,visibleStartIndex:Vt,visibleEndIndex:jt}=zt,Mt=t.useCallback((c,d)=>{if(!re||r===0)return;const v=We(c,r);if(!(d?.ensureVisible??!0)){const lt=$e.current.get(v);lt&&(Se.current=null,Ae.current=v,ye(lt));return}const q=D.prefixSum(v,{materializeOption:{materialize:!1}}),B=q.currentValue,U=Math.max(q.cumulative-B,0),we=U+B,qe=wt(N.current,w.top),Ne=qe+Q;if(U<qe||we>Ne){mt(v);const lt=$e.current.get(v);lt?(Se.current=null,Ae.current=v,ye(lt)):Se.current=v;return}const ot=$e.current.get(v);if(ot){Se.current=null,Ae.current=v,ye(ot);return}Se.current=v},[re,r,D,w.top,mt,ye,Q]),$t=t.useCallback((c,d)=>{if(!(!re||c.defaultPrevented)&&!(c.altKey||c.metaKey||c.ctrlKey)&&c.target===c.currentTarget&&!c.currentTarget.isContentEditable){if(c.key==="ArrowLeft"||c.key==="ArrowRight"){const v=de.current;if(!v||c.shiftKey||!L?.includes("arrow")||!(Number.isFinite(E)&&E>0))return;c.preventDefault(),v(c.key==="ArrowLeft"?-E:E);return}if(c.key==="ArrowDown"){d<r-1&&(c.preventDefault(),Mt(d+1));return}if(c.key==="ArrowUp"){d>0&&(c.preventDefault(),Mt(d-1));return}if(c.key==="PageDown"){if(d<r-1){c.preventDefault();const{visibleStartIndex:v,visibleEndIndex:$}=le.current,q=Math.max($-v+1,1),B=Math.max(q,1),U=We(Math.min(d+B,r-1),r);Mt(U)}return}if(c.key==="PageUp"&&d>0){c.preventDefault();const{visibleStartIndex:v,visibleEndIndex:$}=le.current,q=Math.max($-v+1,1),B=Math.max(q,1),U=We(d-B,r);Mt(U)}}},[re,r,Mt,L,E]),qt=t.useCallback((c,d)=>{if(c.key!=="Escape"||c.defaultPrevented||c.nativeEvent.isComposing||c.target===c.currentTarget)return;const v=c.target;v instanceof HTMLInputElement||v instanceof HTMLTextAreaElement||v instanceof HTMLSelectElement||v.isContentEditable||(c.preventDefault(),Mt(d))},[Mt]),or=t.useCallback(c=>{if(!re)return;const d=We(c,r);Se.current=null,Ae.current=d,Re?.(d)},[re,r,Re]);t.useEffect(()=>{const c=Me.current?.getScrollPosition()??0,d=N.current,v=wt(d,w.top);k.debug("[VirtualScroll] Range change effect triggered",()=>({renderingStartIndex:vt,renderingEndIndex:kt,visibleStartIndex:Vt,visibleEndIndex:jt,scrollPositionState:Ke,paneScrollPosition:d,logicalScrollPosition:v,contentSize:gt,scrollPaneScrollPosition:c})),et({renderingStartIndex:vt,renderingEndIndex:kt,visibleStartIndex:Vt,visibleEndIndex:jt,scrollPosition:v,totalHeight:gt})},[gt,kt,vt,w.top,et,Ke,jt,Vt]);const Et=t.useCallback(()=>{if(!ne)return null;const c=Qe&&ct!==null,d=ct==="up";return A.jsx("div",{className:"aqvs-scroll-to-edge-overlay","data-visible":c,inert:!c,children:d?A.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-top",children:A.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:v=>{v.stopPropagation(),xe.current=!0,mt(0),Oe(!1)},children:ee.scrollToTop})}):A.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-bottom",children:A.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:v=>{v.stopPropagation(),xe.current=!0,mt(r-1),Oe(!1)},children:ee.scrollToBottom})})})},[ne,Qe,ct,mt,r,ee]),Ct=t.useRef(0),{visibleItems:Dt,renderAnchor:Pt}=t.useMemo(()=>{if(r===0)return{visibleItems:A.jsx("div",{className:"aqvs-no-items-container",children:A.jsx("div",{className:"aqvs-no-items-text",children:ee.noItems})}),renderAnchor:0};const c=We(vt,r),d=We(kt,r),{cumulative:v,currentValue:$}=D.prefixSum(c,{materializeOption:{materialize:!1}}),q=v-$;Number.isFinite(q)&&Math.abs(q-Ct.current)>Mn&&(Ct.current=q);const B=Ct.current,U=[],we=[];let qe=0,Ne=q;for(let ze=c;ze<=d;ze++){if(we.length>=Dr){k.warn("[VirtualScroll] Rendered item count reached the safety cap; truncating render window.",{cap:Dr,safeRenderingStartIndex:c,safeRenderingEndIndex:d});break}const ot=s(ze),lt=D.get(ze),ft=ot-lt;ft!==0&&U.push({index:ze,value:ot});const Zt=Ne+qe,cr=n?n(ze):ze;we.push(A.jsx(us,{index:ze,top:Zt-B,height:ot,item:e(ze),clipItemHeight:Fe,enableKeyboardNavigation:re,onKeyDown:$t,onEscapeKeyDown:Ue?qt:void 0,onFocus:or,registerItemRef:Ft,children:x},cr)),qe+=ft,Ne+=lt}return U.length>0&&Promise.resolve().then(()=>{if(ue.current)return;let ze=0;for(const ft of U)if(ft.index<Vt){const Zt=D.get(ft.index);ze+=ft.value-Zt}const ot=D.updates(U);if(ue.current||typeof ot!="number")return;b(ot),k.debug("[VirtualScroll] Updated heights for items",U,"New total height:",ot);const lt=Me.current?.getScrollPosition()??N.current;if(ze!==0){const ft=lt+ze;xt(ft,ze),Ie(ft,{immediate:!0}),k.debug("[VirtualScroll] Adjusted scroll for layout shift (auto update)",{from:lt,to:ft,shiftAmount:ze})}else lt!==N.current&&Ie(lt)}),{visibleItems:we,renderAnchor:B}},[x,Fe,gt,re,r,D,e,n,s,or,$t,Ue,qt,xt,Ft,kt,vt,ee,Ie,Vt]),Wt=t.useCallback(c=>{const d=(G??0)>0,v=Math.abs(c-Ke),$=d&&v>.5?Ke:c,q=wt($,w.top);if(k.debug("[VirtualScroll] Rendering visible items",()=>({currentScrollPosition:c,effectiveScrollPosition:q,renderingStartIndex:vt,renderingEndIndex:kt,itemCount:r,viewportSize:Q,callbackThrottleMs:G,diff:v,rawEffectiveScrollPosition:$})),r===0)return Dt;const B=w.top+Pt-$,U=w.bottom>0?A.jsx("div",{className:"aqvs-bottom-inset",style:{top:D.getTotal()-Pt,height:w.bottom}},"virtualscroll-bottom-inset"):null;return k.debug("[VirtualScroll] Rendering items",()=>({containerTop:B,logicalScrollPosition:je,resolvedInsets:w,effectiveScrollPosition:q})),A.jsxs("div",{className:"aqvs-items-wrapper",style:{top:0,transform:`translateY(${B}px)`,willChange:"transform"},children:[Dt,U]})},[G,r,D,je,Pt,kt,vt,w,Ke,Q,Dt]),Ut=t.useMemo(()=>({renderingStartIndex:zt.renderingStartIndex,renderingEndIndex:zt.renderingEndIndex,visibleStartIndex:zt.visibleStartIndex,visibleEndIndex:zt.visibleEndIndex,scrollPosition:je,totalHeight:D.getTotal()}),[zt,je,D,gt]);t.useEffect(()=>{le.current=Ut},[Ut]);const[Gt,St]=t.useState(""),Kt=t.useRef(K);t.useLayoutEffect(()=>{Kt.current=K},[K]);const yt=K?.debounceMs??400,ht=Number.isFinite(yt)&&yt>=0,er=K!==void 0;t.useEffect(()=>{er&&!ht&&k.warn(`[VirtualScroll] liveRegion.debounceMs must be a finite number >= 0, received ${yt}. Announcements are disabled.`)},[er,ht,yt]),t.useEffect(()=>{if(!(er&&ht)){St("");return}const c=setTimeout(()=>{const d=Kt.current?.format;if(!d)return;const v=d({visibleStartIndex:Vt,visibleEndIndex:jt,itemCount:r});St(v)},yt);return()=>clearTimeout(c)},[er,ht,yt,Vt,jt,r]),t.useImperativeHandle(Z,()=>({getScrollPosition:()=>{const c=Me.current?.getScrollPosition();return typeof c=="number"?wt(c,it.current):-1},getContentSize:()=>Me.current?.getContentSize()??-1,getViewportSize:()=>Me.current?.getViewportSize()??-1,scrollTo:W,scrollBy:Le,applyWheel:Be,scrollToIndex:mt,getFenwickTreeTotalHeight:()=>D.getTotal(),getFenwickSize:()=>D.getSize(),focusItemAtIndex:Mt,getRange:()=>le.current,getScrollAnchor:O,updateItemSize:Lt}),[W,Le,Be,mt,D,Mt,O,Lt]);const Yt=D.getTotal()+w.top+w.bottom,lr=A.jsx(wn,{ref:Me,contentSize:Yt,viewportSize:i,onViewportSizeChange:Ve,className:o,testId:u,onScroll:ut,background:I,tapScrollCircleOptions:ke,inertiaOptions:Ge,overscrollBehavior:pt,itemCount:r,scrollBarWidth:se,enableThumbDrag:he,enableTrackClick:_e,enableArrowButtons:M,enablePointerDrag:He,pointerDragInputs:pe,renderThumbOverlay:te,wheelSpeedMultiplier:rt,onWheelHorizontal:F,onPanHorizontal:oe,contentInsets:w,contentProps:z,visibleStartIndex:Vt,visibleEndIndex:jt,renderOverlay:Et,initialScrollPosition:at.position,locale:Y,labels:H,children:Wt});return er?A.jsxs(A.Fragment,{children:[lr,A.jsx("div",{className:"aqvs-live-region",role:"status","aria-live":"polite","aria-atomic":"true","data-aqvs-live-region":"",children:Gt})]}):lr},In=t.forwardRef(fs),pr=262144,mn=3,Tn=32768,Or=128,_r=128,Fr=128,Hr=128,kr=10,ds=(r,e)=>Math.max(1,Math.floor((r??Tn)/Math.max(1,e))),ms=(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<Dr;)a+=e(u),o+=1,u+=1;return Math.max(1,o+2*i+2)},Rr=(r,e,n)=>{if(!(Number.isInteger(r)&&r>=0&&r<=pr))throw new RangeError(`[VirtualGrid] ${e==="row"?"getRowHeight":"getColWidth"}(${n}) returned ${r} — must be an integer in [0, ${pr}] (0 = hidden). Oversized tracks would pierce the browser layout-coordinate wall (see the design plan §3.1/§6).`);return r},hs=(r,e,n,s,i,a,o,u)=>{const m=yn(r,e,n,s,i,a,o);if(s===0)return{renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0};const g=J(m.renderingStartIndex,0,s-1),{cumulative:x,currentValue:I}=a.prefixSum(g,{materializeOption:{materialize:!1}}),y=x-I,S=Number.isFinite(y)&&Math.abs(y-u)>Mn?y:u;return{renderingColStart:m.renderingStartIndex,renderingColEnd:m.renderingEndIndex,visibleColStart:m.visibleStartIndex,visibleColEnd:m.visibleEndIndex,colAnchor:S}},hn=[],ps=(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 m=u.cumulative-u.currentValue,g=0,x=r;for(;x<=e;){if(a.length>=i)return{columns:a,widthUpdates:o,truncated:e-x+1};const I=n(x),y=s.get(x);if(I!==y&&o.push({index:x,value:I}),I>0){a.push({col:x,left:m,width:I}),m+=y,g=0,x+=1;continue}if(m+=y,g+=1,x+=1,g>hr){const S=s.findIndexAtOrAfter(m+.5,{materializeOption:{materialize:!1}});if(S.index===-1||S.index<=x||!Number.isSafeInteger(S.index))break;const P=s.prefixSum(S.index,{materializeOption:{materialize:!1}});m=P.cumulative-P.currentValue,x=S.index,g=0}}return{columns:a,widthUpdates:o,truncated:0}},gs=(r,e,n)=>{const s=[],i=[];let a=0;for(let o=0;o<r;o+=1){const u=e(o),m=n.get(o);u!==m&&i.push({index:o,value:u}),u>0&&s.push({col:o,left:a,width:u}),a+=m}return{columns:s,widthUpdates:i,width:a}},bs=(r,e,n,s)=>{const i=[],a=[];let o=0;for(let u=r-e;u<r;u+=1){const m=n(u),g=s.get(u);m!==g&&a.push({index:u,value:m}),m>0&&i.push({col:u,left:o,width:m}),o+=g}return{columns:i,widthUpdates:a,width:o}},Mr=(r,e,n)=>Math.min(r,Math.max(0,n-e)),xs={renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0,key:"0:0:0"},vs=({rowCount:r,colCount:e,getRowHeight:n,getColWidth:s,getCell:i,getCellKey:a,children:o,getCellProps:u,getRowProps:m,contentProps:g,background:x,contentInsets:I,onRowFocus:y,frozenLeadingCols:S=0,frozenLeadingRows:P=0,frozenTrailingCols:G=0,frozenTrailingRows:_=0,horizontalKeyInputs:Re,horizontalKeyStep:Te,onScroll:V,onRangeChange:F,onRenderTruncated:oe,callbackThrottleMs:L,initialScrollAnchor:E,overscanRows:z=mn,overscanCols:K=mn,viewportSize:Y,__maxRenderedCells:H,behaviorOptions:Z,scrollBarOptions:se,liveRegion:he,locale:_e,labels:M,className:ne,testId:te},ke)=>{const ee=t.useRef(null),He=t.useRef(null),pe=t.useRef(n);pe.current=n;const re=t.useRef(s);re.current=s;const Ue=Z?.resetOnGetColWidthChange===!0,Ge=Z?.resetOnGetItemHeightChange===!0?n:null,pt=Ue?s:null,Fe=t.useCallback(l=>Rr(pe.current(l),"row",l),[Ge]),Xe=t.useCallback(l=>Rr(re.current(l),"col",l),[pt]),Ee=Z?.defaultColWidth,nt=t.useMemo(()=>{if(Ee!==void 0&&!(Number.isInteger(Ee)&&Ee>=0&&Ee<=pr))throw new RangeError(`[VirtualGrid] behaviorOptions.defaultColWidth must be an integer in [0, ${pr}], received ${Ee}.`);return{resetOnValueFnChange:Ue,baseValue:Ee}},[Ue,Ee]),Q=jr(e,Xe,nt),[Ve,Me]=t.useState(0);if(!(Number.isInteger(S)&&S>=0&&S<=Or))throw new RangeError(`[VirtualGrid] frozenLeadingCols must be an integer in [0, ${Or}], received ${S}.`);const le=Math.min(S,e),ge=t.useRef(0);if(!(Number.isInteger(G)&&G>=0&&G<=Fr))throw new RangeError(`[VirtualGrid] frozenTrailingCols must be an integer in [0, ${Fr}], received ${G}.`);const ue=Math.min(G,e-le),dt=t.useRef(0);if(!(Number.isInteger(P)&&P>=0&&P<=_r))throw new RangeError(`[VirtualGrid] frozenLeadingRows must be an integer in [0, ${_r}], received ${P}.`);const w=Math.min(P,r);if(!(Number.isInteger(_)&&_>=0&&_<=Hr))throw new RangeError(`[VirtualGrid] frozenTrailingRows must be an integer in [0, ${Hr}], received ${_}.`);const De=Math.min(_,r-w),fe=Math.max(0,r-w-De),D=t.useRef(!1),at=t.useRef(0),Ke=t.useRef(0),[Tt,gt]=t.useState(0),{frozenRows:b,frozenHeight:N}=t.useMemo(()=>{if(w===0)return{frozenRows:[],frozenHeight:0};const l=[];let p=0;for(let R=0;R<w;R+=1){const X=Fe(R);X>0&&l.push({row:R,top:p,height:X}),p+=X}return{frozenRows:l,frozenHeight:p}},[w,Tt,Fe]);at.current=N;const[ce,j]=t.useState(0),{trailingRows:ie,trailingHeight:de}=t.useMemo(()=>{if(De===0)return{trailingRows:[],trailingHeight:0};const l=[];let p=0;for(let R=r-De;R<r;R+=1){const X=Fe(R);X>0&&l.push({row:R,top:p,height:X}),p+=X}return{trailingRows:l,trailingHeight:p}},[De,r,ce,Fe]);Ke.current=de;const Ye=t.useCallback(l=>Fe(l+w),[Fe,w]),be=t.useRef(y);be.current=y;const $e=y!==void 0,Se=t.useMemo(()=>$e?l=>be.current?.(l+w):void 0,[w,$e]),Ae=N,ct=de,[Ze,Qe]=t.useState(w),Oe=t.useRef(null),st=t.useRef(!1);if(Ze!==w){Qe(w),st.current=!0;const l=ee.current?.getScrollAnchor()??null;Oe.current=l===null?null:{row:l.index+Ze,offsetPx:l.offsetPx}}const xe=t.useRef(0),me=t.useRef(0),bt=t.useRef(!1),[h,C]=t.useState(xs),ye=t.useRef(h);ye.current=h;const Je=t.useRef(0),[Ce,Rt]=t.useState(()=>Q.getTotal()??0),et=t.useRef(Ce);et.current=Ce;const it=t.useCallback(l=>{typeof l=="number"&&Number.isFinite(l)&&(et.current=l,Rt(l))},[]);t.useLayoutEffect(()=>{const l=Q.getTotal();typeof l=="number"&&Number.isFinite(l)&&l!==et.current&&it(l)});const Pe=se?.width??12,Ft=Y===void 0?null:{width:Math.max(0,Math.round(Y.width)-Pe),height:Math.max(0,Math.round(Y.height)-Pe)},[rr,Ht]=t.useState({width:0,height:0}),ve=Ft??rr,Nt=t.useRef(ve);Nt.current=ve;const Bt=ve.height>0&&ve.height-N-de<=0;D.current=Bt;const Jt=Ft!==null;t.useLayoutEffect(()=>{if(Jt)return;const l=He.current;if(l===null)return;const p=()=>{const X=Math.max(0,Math.round(l.clientWidth)-Pe),ae=Math.max(0,Math.round(l.clientHeight)-Pe);Ht(tt=>tt.width===X&&tt.height===ae?tt:{width:X,height:ae})};p();const R=new ResizeObserver(p);return R.observe(l),()=>R.disconnect()},[Pe,Jt]);const Ie=t.useCallback(()=>{const l=He.current;l!==null&&l.style.setProperty("--aqvs-grid-hx-residual",`${Je.current-xe.current}px`)},[]),xt=t.useCallback(()=>Math.max(0,Nt.current.width-ge.current-dt.current),[]),Xt=t.useCallback(()=>Math.max(0,et.current-ge.current-dt.current-xt()),[xt]),Lt=t.useCallback(()=>{const l=xt(),p=hs(ge.current+xe.current,l,K,e,Xe,Q,et.current,ye.current.colAnchor);if(le>0&&(p.renderingColStart=Math.max(p.renderingColStart,le),p.visibleColStart=Math.max(p.visibleColStart,le)),ue>0){const X=e-ue-1;p.renderingColEnd=Math.min(p.renderingColEnd,X),p.visibleColEnd=Math.min(p.visibleColEnd,X)}(le>0||ue>0)&&(l<=0||p.renderingColStart>p.renderingColEnd)&&(p.renderingColStart=e,p.renderingColEnd=e-1,p.visibleColStart=e,p.visibleColEnd=e-1);const R=`${p.renderingColStart}:${p.renderingColEnd}:${p.colAnchor}`;R!==ye.current.key&&C({...p,key:R})},[K,e,Xe,Q,le,ue,xt]),[mt,f]=t.useState(0),T=t.useRef(null),O=t.useCallback(()=>{T.current===null&&(T.current=requestAnimationFrame(()=>{T.current=null,f(xe.current)}))},[]);t.useEffect(()=>()=>{T.current!==null&&cancelAnimationFrame(T.current)},[]);const W=t.useRef(V);W.current=V;const Le=t.useRef(F);Le.current=F;const Be=t.useRef(oe);Be.current=oe;const ut=t.useRef(null),[je,zt]=t.useState(null),[vt,kt]=t.useState(ve.height);vt!==ve.height&&(kt(ve.height),zt(null));const Vt=E===void 0||r===0?0:J(Math.trunc(E.row),0,r-1),jt=t.useMemo(()=>{const l=ut.current?.renderingStartIndex??Vt;return ms(Math.max(0,ve.height-at.current-Ke.current),Fe,r,l,z)},[ve.height,Fe,r,Vt,z,Ae,ct]),Mt=je??jt,$t=t.useCallback(()=>{const l=ut.current;if(l===null)return null;const p=ye.current;return{renderingRowStart:l.renderingStartIndex,renderingRowEnd:l.renderingEndIndex,visibleRowStart:l.visibleStartIndex,visibleRowEnd:l.visibleEndIndex,renderingColStart:p.renderingColStart,renderingColEnd:p.renderingColEnd,visibleColStart:p.visibleColStart,visibleColEnd:p.visibleColEnd,scrollX:xe.current,scrollY:me.current,totalWidth:et.current,totalHeight:l.totalHeight+at.current+Ke.current}},[]),qt=t.useCallback(()=>{const l=$t();l!==null&&Le.current?.(l)},[$t]),or=t.useCallback(l=>{const p=Xt(),R=J(l,0,p);return R!==xe.current&&(xe.current=R,Ie(),Lt(),O(),W.current?.({x:R,y:me.current})),R},[Ie,Lt,O,Xt]),Et=t.useRef(or);Et.current=or,t.useLayoutEffect(()=>{Je.current=h.colAnchor,Ie(),qt()},[h,Ie,qt]),t.useLayoutEffect(()=>{ut.current!==null&&qt()},[N,de,qt]);const Ct=t.useRef(null),Dt=t.useCallback(l=>{const p=J(l.col,0,Math.max(0,e-1)),R=Q.prefixSum(p,{materializeOption:{materialize:!1}}),X=R.cumulative-R.currentValue,ae=R.currentValue,tt=xt();return(l.alignX==="end"?X+ae-ge.current-tt:l.alignX==="center"?X+ae/2-ge.current-tt/2:X-ge.current)+l.offsetX},[Q,e,xt]),Pt=t.useRef(null),Wt=t.useCallback(()=>{const l=Pt.current;Pt.current=null,!(l===null||l.length===0)&&(it(Q.updates(l)),Me(p=>p+1))},[Q,it]),Ut=t.useRef({count:0,warned:!1}),{frozenColumns:Gt,frozenWidth:St}=t.useMemo(()=>{if(le===0)return Ut.current.count=0,Ut.current.warned=!1,{frozenColumns:hn,frozenWidth:0};const{columns:l,widthUpdates:p,width:R}=gs(le,Xe,Q);if(p.length>0){const X=Ut.current;X.count>=kr?X.warned||(X.warned=!0,k.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:le,pendingUpdates:p.length})):(X.count+=1,Pt.current=[...Pt.current??[],...p],Promise.resolve().then(Wt))}else Ut.current.count=0,Ut.current.warned=!1;return{frozenColumns:l,frozenWidth:R}},[le,Ve,Xe,Q,Wt]);ge.current=St,t.useLayoutEffect(()=>{le>0?He.current?.style.setProperty("--aqvs-grid-frozen-width",`${St}px`):He.current?.style.removeProperty("--aqvs-grid-frozen-width")},[St,le]);const Kt=t.useRef({count:0,warned:!1}),{trailingColumns:yt,trailingWidth:ht}=t.useMemo(()=>{if(ue===0)return Kt.current.count=0,Kt.current.warned=!1,{trailingColumns:hn,trailingWidth:0};const{columns:l,widthUpdates:p,width:R}=bs(e,ue,Xe,Q);if(p.length>0){const X=Kt.current;X.count>=kr?X.warned||(X.warned=!0,k.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:ue,pendingUpdates:p.length})):(X.count+=1,Pt.current=[...Pt.current??[],...p],Promise.resolve().then(Wt))}else Kt.current.count=0,Kt.current.warned=!1;return{trailingColumns:l,trailingWidth:R}},[ue,e,Ve,Xe,Q,Wt]);dt.current=ht,t.useLayoutEffect(()=>{ue>0?He.current?.style.setProperty("--aqvs-grid-trailing-width",`${ht}px`):He.current?.style.removeProperty("--aqvs-grid-trailing-width")},[ht,ue]);const er=t.useMemo(()=>({...se,tapScrollCircleOptions:{...se?.tapScrollCircleOptions,enabled:!1}}),[se]),Yt=se?.tapScrollCircleOptions,lr=typeof Yt?.maxSpeedMultiplier=="number",c=t.useMemo(()=>({...Yt,offsetX:Yt?.offsetX===void 0?cn:Yt.offsetX,offsetY:Yt?.offsetY===void 0?cn:Yt.offsetY}),[Yt]),d=t.useMemo(()=>Lr(c,Math.max(0,e-le-ue)),[c,e,le,ue]),v=t.useMemo(()=>Lr(c,fe),[c,fe]),$=d.enabled,q=Math.max(d.maxVisualDistance,1),B={viewportSize:Math.max(0,ve.width-St-ht),minSpeedMultiplier:d.minSpeedMultiplier,maxSpeedMultiplier:d.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:lr,curve:d.maxSpeedCurve},U={viewportSize:Math.max(0,ve.height-N-de),minSpeedMultiplier:v.minSpeedMultiplier,maxSpeedMultiplier:v.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:lr,curve:v.maxSpeedCurve},we=t.useCallback(()=>xe.current,[]),qe=t.useCallback(()=>{const l=ee.current;if(l===null)return me.current;const p=l.getScrollPosition();return p<0?me.current:p},[]),Ne=t.useCallback(()=>{const l=ee.current;return l===null?0:Math.max(0,Math.max(0,l.getContentSize())-Math.max(0,l.getViewportSize()))},[]),ze=t.useCallback(l=>{const p=ee.current;if(p===null)return me.current;const R=p.scrollBy(l);return me.current=R,R},[]),ot=Xt()>0||Ne()>0,lt=`${Ce}:${St}:${ht}:${ve.width}:${h.key}`,ft=`${r}:${je??-1}:${N}:${de}:${ve.height}`,{isTapActive:Zt,handleTapCircleDragChange:cr,tapCircleHandleRef:En}=os({enabled:$&&ot,maxDistance:q,xSpeedParams:B,ySpeedParams:U,applyHxRef:Et,getHx:we,getMaxHx:Xt,applyVy:ze,getVy:qe,getMaxVy:Ne,pendingColAnchorRef:Ct,xExtentFreshness:lt,yExtentFreshness:ft}),Cn=t.useMemo(()=>J((Zt?1:.8)*d.opacity,0,1),[Zt,d.opacity]);t.useLayoutEffect(()=>{const l=Ct.current;l===null?Et.current(xe.current):Et.current(Dt(l)),Lt()},[ve.width,Ce,Ve,St,ht,Lt,Dt]);const Wr=t.useRef(!1);t.useLayoutEffect(()=>{if(Wr.current||E===void 0||e===0)return;Wr.current=!0;const l=J(Math.trunc(E.col),0,e-1);if(l<le||l>=e-ue)return;const p={col:l,alignX:"start",offsetX:Math.max(0,E.offsetX)};Ct.current=p,Et.current(Dt(p))},[E,e,Dt,le,ue]);const Pn=t.useCallback(l=>{me.current=l,bt.current=!0,W.current?.({x:xe.current,y:l})},[]),Ur=t.useCallback(l=>{if(fe===0||D.current)ut.current={renderingStartIndex:r,renderingEndIndex:r-1,visibleStartIndex:r,visibleEndIndex:r-1,scrollPosition:0,totalHeight:fe===0?0:l.totalHeight},me.current=0;else{const p=w;ut.current={renderingStartIndex:l.renderingStartIndex+p,renderingEndIndex:l.renderingEndIndex+p,visibleStartIndex:l.visibleStartIndex+p,visibleEndIndex:l.visibleEndIndex+p,scrollPosition:l.scrollPosition,totalHeight:l.totalHeight},me.current=l.scrollPosition}zt(p=>{const R=Math.max(1,l.renderingEndIndex-l.renderingStartIndex+1);return R===p?p:R}),qt()},[qt,w,fe,r]),Gr=t.useCallback(l=>{Ct.current=null,Et.current(xe.current+l)},[]),Kr=ds(H,Mt+b.length+ie.length),Tr=t.useRef({count:0,warned:!1}),{placedColumns:gr,truncatedCols:br}=t.useMemo(()=>{const l=Math.max(0,ve.width-St-ht);if(e===0||l<=0)return{placedColumns:[],truncatedCols:0};if(h.renderingColStart>h.renderingColEnd)return{placedColumns:[],truncatedCols:0};const p=Math.max(1,Kr-Gt.length-yt.length),{columns:R,widthUpdates:X,truncated:ae}=ps(J(h.renderingColStart,0,e-1),J(h.renderingColEnd,0,e-1),Xe,Q,p);if(X.length>0){const tt=Tr.current;tt.count>=kr?tt.warned||(tt.warned=!0,k.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:h.key,pendingUpdates:X.length})):(tt.count+=1,Pt.current=[...Pt.current??[],...X],Promise.resolve().then(Wt))}else Tr.current.count=0,Tr.current.warned=!1;return{placedColumns:R,truncatedCols:ae}},[h,e,ve.width,St,ht,Gt.length,yt.length,Ve,Xe,Q,Kr,Wt]),Zr=t.useRef("");t.useEffect(()=>{if(br>0){const l=`${h.key}:${br}`;l!==Zr.current&&(Zr.current=l,Be.current?.({renderedCells:(gr.length+Gt.length+yt.length)*(Mt+b.length+ie.length),droppedCols:br}))}},[br,h.key,gr.length,Gt.length,yt.length,Mt,b.length,ie.length]);const Qr=h.colAnchor,Er=t.useCallback(l=>{const p=m?.(l),R=Fe(l)===0,X=R?null:gr.map(({col:ae,left:tt,width:sr})=>{const At=u?.(l,ae),ur={...At?.style,left:tt-Qr,width:sr};return t.createElement("div",{...At,key:a?a(l,ae):ae,className:It.twMerge("aqvs-grid-cell",At?.className),style:ur},o(i(l,ae),l,ae))});return le===0&&ue===0?A.jsx("div",{...p,className:It.twMerge("aqvs-grid-row",p?.className),style:p?.style,children:X}):A.jsxs("div",{...p,"data-aqvs-frozen-row":le>0?"":void 0,className:It.twMerge("aqvs-grid-row aqvs-grid-row-frozen-host",p?.className),style:p?.style,children:[R?null:Gt.map(({col:ae,left:tt,width:sr})=>{const At=u?.(l,ae),ur={...At?.style,left:tt,width:sr};return t.createElement("div",{...At,"data-aqvs-frozen-cell":"",key:a?a(l,ae):ae,className:It.twMerge("aqvs-grid-cell",At?.className),style:ur},o(i(l,ae),l,ae))}),R?null:A.jsx("div",{className:"aqvs-grid-row-scroll",children:A.jsx("div",{className:"aqvs-grid-row-scroll-inner",children:X})}),R||ue===0?null:A.jsx("div",{className:"aqvs-grid-row-trailing",children:A.jsx("div",{className:"aqvs-grid-row-trailing-inner",children:yt.map(({col:ae,left:tt,width:sr})=>{const At=u?.(l,ae),ur={...At?.style,left:tt,width:sr};return t.createElement("div",{...At,"data-aqvs-trailing-cell":"",key:a?a(l,ae):ae,className:It.twMerge("aqvs-grid-cell",At?.className),style:ur},o(i(l,ae),l,ae))})})})]})},[gr,Gt,yt,le,ue,Qr,m,u,a,i,o,Fe]),[Nn,zn]=t.useState(""),nr=t.useRef(null),Jr=t.useRef(he);Jr.current=he;const xr=t.useCallback(()=>{const l=Jr.current;if(l===void 0)return;const p=l.debounceMs??400;Number.isFinite(p)&&p>=0&&(nr.current!==null&&window.clearTimeout(nr.current),nr.current=window.setTimeout(()=>{nr.current=null;const R=$t();R!==null&&zn(X=>{const ae=l.buildMessage(R);return ae===X?X:ae})},p))},[$t]),vr=he?.debounceMs??400,en=Number.isFinite(vr)&&vr>=0,tn=he!==void 0;t.useEffect(()=>{tn&&!en&&k.warn(`[VirtualGrid] liveRegion.debounceMs must be a finite number >= 0, received ${vr}. Announcements are disabled.`)},[tn,en,vr]),t.useEffect(()=>()=>{nr.current!==null&&window.clearTimeout(nr.current)},[]),t.useEffect(()=>{xr()},[h,xr]);const kn=t.useCallback(l=>{Ur(l),xr()},[Ur,xr]);return t.useImperativeHandle(ke,()=>({scrollTo:l=>{const p=ee.current;let R=me.current;l.y!==void 0&&p!==null&&(p.scrollTo(l.y),R=p.getScrollPosition(),me.current=R);let X=xe.current;return l.x!==void 0&&(Ct.current=null,X=Et.current(l.x)),{x:X,y:R}},scrollBy:l=>{const p=ee.current;let R=me.current;l.y!==void 0&&l.y!==0&&p!==null&&(R=p.scrollBy(l.y),me.current=R);let X=xe.current;return l.x!==void 0&&l.x!==0&&(Ct.current=null,X=Et.current(xe.current+l.x)),{x:X,y:R}},scrollToCell:(l,p,R)=>{const X=ee.current;if(X!==null&&r>0){const ae=J(Math.trunc(l),0,r-1);ae>=w&&ae<r-De&&X.scrollToIndex(ae-w,{align:R?.alignY??"top",offset:R?.offsetY})}if(e>0){const ae=J(Math.trunc(p),0,e-1);if(ae>=le&&ae<e-ue){const tt={col:ae,alignX:R?.alignX??"start",offsetX:R?.offsetX??0};Ct.current=tt,Et.current(Dt(tt))}}},getScrollPosition:()=>bt.current||ee.current!==null?{x:xe.current,y:ee.current?.getScrollPosition()??me.current}:{x:-1,y:-1},getScrollAnchor:()=>{if(r===0||e===0)return null;const l=ee.current?.getScrollAnchor()??null;if(l===null)return null;const p=ge.current+xe.current,R=Q.findIndexAtOrAfter(p,{materializeOption:{materialize:!1}});if(R.index===-1)return{row:l.index+w,col:e-1,offsetX:0,offsetY:l.offsetPx};if(R.cumulative===p)return{row:l.index+w,col:J(R.index+1,0,e-1),offsetX:0,offsetY:l.offsetPx};const X=(R.cumulative??0)-(R.currentValue??0);return{row:l.index+w,col:R.index,offsetX:Math.max(0,p-X),offsetY:l.offsetPx}},getViewportSize:()=>({width:Nt.current.width,height:Nt.current.height}),getContentSize:()=>({width:et.current,height:ee.current===null?0:at.current+Ke.current+Math.max(0,ee.current.getContentSize())}),getRange:$t,updateRowSize:(l,p)=>{Rr(p,"row",l),Math.trunc(l)<w?gt(R=>R+1):De>0&&Math.trunc(l)>=r-De?j(R=>R+1):ee.current?.updateItemSize(Math.trunc(l)-w,p)},updateColSize:(l,p)=>{Rr(p,"col",l),it(Q.update(J(Math.trunc(l),0,Math.max(0,e-1)),p)),Me(R=>R+1)},getFrozenSize:()=>({cols:le,width:ge.current,rows:w,height:at.current,trailingCols:ue,trailingRows:De,trailingWidth:dt.current,trailingHeight:Ke.current,trailingVisibleWidth:Mr(dt.current,ge.current,Nt.current.width),trailingVisibleHeight:Mr(Ke.current,at.current,Nt.current.height)}),applyWheel:l=>ee.current?.applyWheel(l)??!1,focusRowAtIndex:(l,p)=>{const R=Math.trunc(l);R<w?He.current?.querySelector(`[data-aqvs-frozen-band-row="${R}"]`)?.focus():De>0&&R>=r-De?He.current?.querySelector(`[data-aqvs-trailing-band-row="${R}"]`)?.focus():ee.current?.focusItemAtIndex(R-w,p)}}),[r,e,Q,$t,it,Dt,le,w,ue,De]),A.jsxs("div",{ref:He,className:It.twMerge("aqvs-grid",w>0?"aqvs-grid-has-frozen-rows":"",De>0?"aqvs-grid-has-trailing-rows":"",ne),"data-testid":te,children:[w>0?A.jsx("div",{className:"aqvs-grid-frozen-rows",style:{height:N},"data-testid":te?`${te}-frozen-rows`:void 0,children:b.map(({row:l,top:p,height:R})=>A.jsx("div",{"data-aqvs-frozen-band-row":l,className:"aqvs-grid-frozen-band-row",style:{top:p,height:R,right:Pe},tabIndex:-1,onFocus:()=>y?.(l),children:Er(l)},l))}):null,A.jsx("div",{className:"aqvs-grid-main","data-testid":te?`${te}-main`:void 0,children:A.jsx(In,{ref:ee,itemCount:Bt?0:fe,getItem:l=>l+w,getItemKey:l=>l+w,getItemHeight:Ye,overscanCount:z,viewportSize:ve.height>0?Math.max(0,ve.height-N-de):void 0,callbackThrottleMs:L,behaviorOptions:Z,scrollBarOptions:er,contentProps:g,background:x,contentInsets:I,onItemFocus:Se,horizontalKeyInputs:Re,horizontalKeyStep:Te,initialScrollAnchor:st.current?Oe.current!==null&&Oe.current.row>=w&&fe>0?{index:Oe.current.row-w,offsetPx:Oe.current.offsetPx}:void 0:E!==void 0&&fe>0&&Math.trunc(E.row)>=w&&Math.trunc(E.row)<r-De?{index:Math.trunc(E.row)-w,offsetPx:E.offsetY}:void 0,onScroll:Pn,onRangeChange:kn,onWheelHorizontal:Gr,onPanHorizontal:Gr,locale:_e,labels:M,testId:te?`${te}-rows`:void 0,children:Er},w)}),De>0?A.jsx("div",{className:"aqvs-grid-trailing-rows",style:{height:Mr(de,N,ve.height)},"data-testid":te?`${te}-trailing-rows`:void 0,children:A.jsx("div",{className:"aqvs-grid-trailing-rows-inner",style:{height:de},children:ie.map(({row:l,top:p,height:R})=>A.jsx("div",{"data-aqvs-trailing-band-row":l,className:"aqvs-grid-trailing-band-row",style:{top:p,height:R,right:Pe},tabIndex:-1,onFocus:()=>y?.(l),children:Er(l)},l))})}):null,A.jsx("div",{className:"aqvs-grid-hbar-strip",style:{height:Pe,paddingRight:ue>0?Pe+Mr(ht,St,ve.width):Pe},"data-testid":te?`${te}-hbar`:void 0,children:A.jsx(Br,{horizontal:!0,contentSize:Math.max(0,Ce-St-ht),viewportSize:Math.max(0,ve.width-St-ht),scrollPosition:mt,itemCount:Math.max(0,e-le-ue),tapScrollCircleOptions:se?.tapScrollCircleOptions,onScroll:(l,p)=>(Ct.current=null,Et.current(typeof l=="function"?l(p??xe.current):l)),scrollBarWidth:Pe,locale:_e,labels:M})}),$&&ot&&A.jsx("div",{className:"aqvs-grid-tap-circle-wrapper","data-aqvs-grid-tap-circle":"",style:{left:`min(calc(100% - ${Pe+d.size}px), max(calc(100% - ${Pe}px + ${d.offsetX}px), calc(75% - ${d.size/2}px)))`,top:`min(calc(100% - ${Pe+d.size}px), max(calc(100% - ${Pe}px + ${d.offsetY}px), calc(75% - ${d.size/2}px)))`},children:A.jsx(qr,{axis:"xy",ref:En,className:It.twMerge("aqvs-grid-tap-circle",d.className),size:d.size,maxVisualDistance:q,opacity:Cn,renderVisual:d.renderVisual,onDragChange:cr})}),he!==void 0?A.jsx("div",{className:"aqvs-grid-live-region","aria-live":"polite","data-testid":te?`${te}-live`:void 0,children:Nn}):null]})},Ss=t.forwardRef(vs);exports.FenwickMapTree=_t;exports.MAX_FROZEN_LEADING_COLS=Or;exports.MAX_FROZEN_LEADING_ROWS=_r;exports.MAX_FROZEN_TRAILING_COLS=Fr;exports.MAX_FROZEN_TRAILING_ROWS=Hr;exports.MAX_RENDERED_CELLS=Tn;exports.MAX_TRACK_SIZE=pr;exports.ScrollBar=Br;exports.ScrollPane=wn;exports.TAP_SCROLL_SPEED_DEFAULTS=Yr;exports.VIRTUAL_SCROLL_LABEL_CATALOGS=pn;exports.VIRTUAL_SCROLL_LABEL_KEYS=yr;exports.VIRTUAL_SCROLL_LOCALES=Xr;exports.VirtualGrid=Ss;exports.VirtualScroll=In;exports.computeAutoTapScrollMaxSpeedMultiplier=xn;exports.computeTapScrollSpeed=Ir;exports.computeTapScrollVelocity=vn;exports.createResidualQuantizer=Un;exports.minmax=J;exports.resolveVirtualScrollLabels=$r;exports.resolveVirtualScrollLocale=gn;exports.tapScrollCircleSampleVisual=es;exports.useFenwickMapTree=jr;exports.useHeightCache=is;exports.useLruCache=Rn;exports.useWheelBridge=as;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react/jsx-runtime"),t=require("react"),It=require("tailwind-merge"),qr=["en","ja"],Tr=["scrollUp","scrollDown","scrollLeft","scrollRight","scrollToTop","scrollToBottom","noItems"],bn=Object.freeze({en:Object.freeze({scrollUp:"Scroll up",scrollDown:"Scroll down",scrollLeft:"Scroll left",scrollRight:"Scroll right",scrollToTop:"Top",scrollToBottom:"Bottom",noItems:"No items"}),ja:Object.freeze({scrollUp:"上へスクロール",scrollDown:"下へスクロール",scrollLeft:"左へスクロール",scrollRight:"右へスクロール",scrollToTop:"先頭へ",scrollToBottom:"末尾へ",noItems:"項目がありません"})}),On=r=>qr.includes(r),Lr=r=>typeof r=="string"?JSON.stringify(r):r===null?"null":typeof r,xn=r=>{if(r===void 0)return"en";if(On(r))return r;const e=qr.map(n=>JSON.stringify(n)).join(", ");throw new RangeError(`[virtualscroll] locale must be one of ${e}; got ${Lr(r)}`)},_n=r=>Tr.includes(r),Yr=(r,e)=>{const n=bn[xn(r)];if(e===void 0)return n;if(e===null||typeof e!="object")throw new RangeError(`[virtualscroll] labels must be an object; got ${Lr(e)}`);const s=Object.getPrototypeOf(e);if(s!==Object.prototype&&s!==null)throw new RangeError(`[virtualscroll] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(e)?"an array":"an object with a non-plain prototype"}`);const i=new Set(Object.keys(e));for(const o of i)if(!_n(o))throw new RangeError(`[virtualscroll] labels.${o} is not a known label key; expected one of ${Tr.join(", ")}`);const a={...n};for(const o of Tr){const u=i.has(o)?e[o]:void 0;if(u!==void 0){if(typeof u!="string"||u.trim()==="")throw new RangeError(`[virtualscroll] labels.${o} must be a non-blank string; got ${Lr(u)}`);a[o]=u}}return Object.freeze(a)};class k{level;prefix;impl;constructor(e=2,n="[virtualscroll]",s=console){this.level=e,this.prefix=n,this.impl=s}static instance=new k(2,"[virtualscroll]");static setLevel(e){k.instance.setLevel(e)}setLevel(e){this.level=e}static setImplementation(e){k.instance.setImplementation(e)}setImplementation(e){this.impl=e}static setPrefix(e){k.instance.setPrefix(e)}setPrefix(e){this.prefix=e}static isEnabled(e){return k.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){k.instance.debug(e,...n)}debug(e,...n){this.level<=0&&this.impl.debug(...this.formatMessage(k.resolveLazy(e)),...n.map(k.resolveLazy))}static info(e,...n){k.instance.info(e,...n)}info(e,...n){this.level<=1&&this.impl.info(...this.formatMessage(k.resolveLazy(e)),...n.map(k.resolveLazy))}static warn(e,...n){k.instance.warn(e,...n)}warn(e,...n){this.level<=2&&this.impl.warn(...this.formatMessage(k.resolveLazy(e)),...n.map(k.resolveLazy))}static error(e,...n){k.instance.error(e,...n)}error(e,...n){this.level<=3&&this.impl.error(...this.formatMessage(k.resolveLazy(e)),...n.map(k.resolveLazy))}}const vn=r=>typeof r.setPointerCapture=="function"&&typeof r.releasePointerCapture=="function"&&typeof r.hasPointerCapture=="function",Sn=(r,e)=>vn(r)&&r.hasPointerCapture(e),hr=(r,e)=>{if(!vn(r))return"unsupported";try{return r.setPointerCapture(e),"captured"}catch(n){return(typeof n=="object"&&n!==null&&"name"in n?n.name:void 0)==="NotFoundError"?"inactive-pointer":"rejected"}},Jt=(r,e)=>{Sn(r,e)&&r.releasePointerCapture(e)},sn={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},Rr=6,Fn=8,Hn=({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 V.jsxs(V.Fragment,{children:[V.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`}}),V.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"}})]})},Br=t.memo(t.forwardRef(({onDragChange:r,className:e,maxVisualDistance:n=160,size:s=40,style:i,opacity:a=1,renderVisual:o,axis:u="y"},m)=>{const[g,b]=t.useState(sn),I=t.useRef(null),y=t.useRef(null),S=t.useRef({x:0,y:0}),P=t.useRef(null),W=t.useRef(0),_=t.useCallback(M=>{b(M),r(M)},[r]),Re=t.useCallback((M,ee,te=!1)=>{const{x:_e,y:ce}=S.current,qe=M-_e,pe=ee-ce;let J,Ue;if(u==="xy")J=Math.hypot(qe,pe),Ue=J<Rr?0:1;else{const Fe=u==="x"?qe:pe;J=Math.abs(Fe),Ue=J<Rr?0:Fe<0?-1:1}const rt=W.current;let Ge=Ue;const pt=Rr+Fn;Ue===0?rt!==0&&J<pt?Ge=rt:(Ge=0,te||(W.current=0)):Ue!==rt&&rt!==0&&J<pt?Ge=rt:W.current=Ue,_({active:te||J>=Rr,offsetX:qe,offsetY:pe,distance:J,direction:Ge,pointerId:I.current})},[_,u]),Te=t.useCallback(M=>{if(M===null)return;const ee=P.current;ee!==null&&Jt(ee,M)},[]),A=t.useCallback((M=!1)=>{M&&Te(I.current),I.current=null,y.current=null,W.current=0,_(sn)},[_,Te]),F=t.useCallback(M=>{if(I.current!==null&&I.current!==M.pointerId){y.current={pointerId:M.pointerId,clientX:M.clientX,clientY:M.clientY},M.preventDefault(),M.stopPropagation();return}M.preventDefault(),M.stopPropagation();const ee=P.current??M.currentTarget,{left:te,top:_e,width:ce,height:qe}=ee.getBoundingClientRect();S.current={x:te+ce/2,y:_e+qe/2},I.current=M.pointerId,hr(ee,M.pointerId),Re(M.clientX,M.clientY,!0)},[Re]),ae=t.useCallback(M=>{if(I.current!==M.pointerId){y.current!==null&&y.current.pointerId===M.pointerId&&(y.current={pointerId:M.pointerId,clientX:M.clientX,clientY:M.clientY});return}M.preventDefault(),Re(M.clientX,M.clientY)},[Re]),L=t.useCallback(M=>{if(I.current!==M.pointerId){y.current!==null&&y.current.pointerId===M.pointerId&&(y.current=null);return}M.preventDefault(),M.stopPropagation();const ee=y.current;if(y.current=null,ee!==null){Te(M.pointerId);const te=P.current;if(te===null||hr(te,ee.pointerId)!=="inactive-pointer"){I.current=ee.pointerId,Re(ee.clientX,ee.clientY,!0);return}}A(!0)},[A,Te,Re]),T=t.useCallback(M=>{M.target===M.currentTarget&&I.current===M.pointerId&&A(!1)},[A]);t.useImperativeHandle(m,()=>({reset:()=>{A(!0)},getElement:()=>P.current}),[A]);const z=Math.min(Math.max(a,0),1),U=s/64,Y=Math.min(g.distance,n)/n,H=g.direction*Y*10*U;let K;if(u==="xy"){const M=g.distance,ee=M===0?0:H*g.offsetX/M,te=M===0?0:H*g.offsetY/M;K=`translate(${ee}px, ${te}px)`}else u==="x"?K=`translateX(${H}px)`:K=`translateY(${H}px)`;const re=o??Hn,he={dragState:g,normalizedDistance:Y,sizeScale:U,size:s,opacity:z},Oe={...i,width:s,height:s,transform:K};return Oe.opacity=z,V.jsx("div",{ref:P,"data-testid":"virtual-scroll-tap-circle",className:It.twMerge("aqvs-tap-scroll-circle",e),style:Oe,tabIndex:-1,onPointerDown:F,onPointerMove:ae,onPointerUp:L,onPointerCancel:L,onLostPointerCapture:T,role:"presentation",children:re(he)})}));Br.displayName="TapScrollCircle";const Q=(r,e,n)=>Math.max(e,Math.min(n,r)),Dr=(r,e)=>{const n=e==="x",s=r.getBoundingClientRect(),i=n?s.width:s.height,a=b=>{const I=Number.parseFloat(b);return Number.isFinite(I)?I:0},o=window.getComputedStyle(r),u=a(n?o.width:o.height),m=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=m>0?m:n?r.offsetWidth:r.offsetHeight;return g<=0||i<=0?1:i/g},pr="virtualscroll:tap-scroll-cancel",an=20,Xn=250,$n=60,qn=20,Yn=20,jr={maxDistance:240,minSpeedMultiplier:.2},Bn=jr.maxDistance,on={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},Nr=2.2,jn=8,Wn=120,wn=1/10,Ot={enabled:!0,size:40,offsetX:-80,offsetY:0,className:void 0,maxVisualDistance:Bn,minSpeedMultiplier:jr.minSpeedMultiplier,opacity:.9,renderVisual:void 0,maxSpeedCurve:void 0},Un=r=>r?{mainSizeKey:"width",crossSizeKey:"height",positionKey:"left",selectDelta:(e,n)=>e,getPointerCoordinate:({clientX:e})=>e,arrowIcons:["◀","▶"],directionClass:"aqvs-scrollbar-horizontal",orientation:"horizontal"}:{mainSizeKey:"height",crossSizeKey:"width",positionKey:"top",selectDelta:(e,n)=>n,getPointerCoordinate:({clientY:e})=>e,arrowIcons:["▲","▼"],directionClass:"aqvs-scrollbar-vertical",orientation:"vertical"},Or=(r,e)=>{const n=r?.maxSpeedMultiplier,s=typeof n=="number"?n:Rn(e);return{enabled:r?.enabled??Ot.enabled,size:r?.size??Ot.size,offsetX:r?.offsetX??Ot.offsetX,offsetY:r?.offsetY??Ot.offsetY,className:r?.className??Ot.className,maxVisualDistance:r?.maxVisualDistance??Ot.maxVisualDistance,maxSpeedMultiplier:s,minSpeedMultiplier:Math.max(r?.minSpeedMultiplier??Ot.minSpeedMultiplier,0),opacity:Q(r?.opacity??Ot.opacity,0,1),renderVisual:r?.renderVisual??Ot.renderVisual,maxSpeedCurve:r?.maxSpeedCurve??Ot.maxSpeedCurve}},Gn=({isDragging:r,isThumbHovered:e,enableThumbDrag:n})=>t.useMemo(()=>n?r?"dragging":e?"hover":"idle":"disabled",[n,r,e]),Kn=({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)},[]),m=t.useCallback(()=>{u()},[u]),g=t.useCallback(I=>y=>{if(!r)return;y.cancelable&&y.preventDefault(),y.stopPropagation(),n(),u(),s(I),a.current=window.setTimeout(()=>{i.current=window.setInterval(()=>{s(I)},$n)},Xn);const S=()=>u();o.current=S,window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S),window.addEventListener("blur",S)},[r,u,n,s]),b=t.useCallback(I=>y=>{e&&(y.key==="Enter"||y.key===" "||y.key==="Spacebar")&&(y.preventDefault(),s(I))},[e,s]);return t.useEffect(()=>{r||u()},[r,u]),t.useEffect(()=>()=>{u()},[u]),{handleArrowPointerDown:g,handleArrowPointerUp:m,handleArrowKeyDown:b}},Zn=700,Qt=(r,e)=>typeof r=="number"&&Number.isFinite(r)?r:e,Er=({distance:r,maxDistance:e,viewportSize:n,minSpeedMultiplier:s,maxSpeedMultiplier:i,hasCustomMaxSpeedMultiplier:a,curve:o})=>{const u=Math.max(Qt(r,0),0),m=Qt(e,0),g=m>0?Math.min(u,m)/m:1,b=Math.max(Qt(n,0),0),I=Math.max(Qt(s,0),0),y=Math.max(Qt(i,0),0),S=Math.max(b*I,40),P=a?S:1200,W=Math.max(b*y,P),_=o?Math.max(Qt(o.exponentialScale,y),0):0,Re=o?Math.min(W,Math.max(b*_,S)):W,Te=Math.max(Re,S);let A=g**1.1;if(o){const ae=Math.min(Math.max(Qt(o.exponentialSteepness,0),0),Zn);if(ae===0)A=g;else{const L=Math.expm1(ae)||1;A=Math.min(Math.max(Math.expm1(ae*g)/L,0),1)}}const F=Math.min(Math.max(Qt(o?.easedOffset,0),0),1);return S+(Te-S)*(F+(1-F)*A)},Rn=r=>{if(!r||r<=0)return Nr;const e=Math.max(1,r),n=Math.log10(e),s=Nr+n*jn;return Q(s,Nr,Wn)},Wr=({contentSize:r,viewportSize:e,scrollPosition:n,onScroll:s,enableThumbDrag:i=!0,enableTrackClick:a=!0,enableArrowButtons:o=!0,horizontal:u=!1,enableHorizontalTapCircle:m=!1,stretchMainSize:g=!1,scrollBarWidth:b=12,className:I,ariaControls:y,tapScrollCircleOptions:S,itemCount:P,renderThumbOverlay:W,visibleStartIndex:_,visibleEndIndex:Re,locale:Te,labels:A})=>{const[F,ae]=t.useState(!1),[L,T]=t.useState(!1),[z,U]=t.useState(!1),Y=t.useRef(null),H=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}),re=t.useRef(n),he=t.useRef(s),Oe=t.useRef(on),M=t.useRef(null),ee=t.useRef(null),te=t.useRef(null),_e=t.useRef(0),ce=t.useRef(0),qe=t.useMemo(()=>Or(S,P),[P,S]),pe=t.useMemo(()=>Un(u),[u]),J=t.useMemo(()=>Yr(Te,A),[Te,A]),Ue=u?[J.scrollLeft,J.scrollRight]:[J.scrollUp,J.scrollDown],{enabled:rt,size:Ge,offsetX:pt,offsetY:Fe,className:He,maxVisualDistance:Ee,maxSpeedMultiplier:nt,minSpeedMultiplier:Z,opacity:ke,renderVisual:Me,maxSpeedCurve:oe}=qe,ge=t.useRef({viewportSize:e,maxScrollPosition:Math.max(r-e,0),scrollBarVisible:r>e,effectiveTapMaxDistance:Math.max(Ee,1),tapCircleMaxSpeedMultiplier:nt,tapCircleMinSpeedMultiplier:Z,tapCircleMaxSpeedCurve:oe,tapScrollCircleOptions:S,effectiveTrackLength:0,onScroll:s,scrollPosition:n}),{mainSizeKey:ue,crossSizeKey:ft,positionKey:w,selectDelta:Ve,getPointerCoordinate:de,arrowIcons:O,directionClass:at,orientation:Ke}=pe,Tt=Math.max(Ee,1),gt=e/r,x=Math.max(e-b*2,0),N=gt*x,le=Math.min(Math.max(an,N||0),x||an),G=Math.max(r-e,0),ne=Math.max(x-le,0),fe=G<=0||ne<=0?0:Q(n/G*ne,0,ne),Ye=fe+le/2,be=r>e||F,Xe=be&&o;t.useLayoutEffect(()=>{ge.current={viewportSize:e,maxScrollPosition:G,scrollBarVisible:be,effectiveTapMaxDistance:Tt,tapCircleMaxSpeedMultiplier:nt,tapCircleMinSpeedMultiplier:Z,tapCircleMaxSpeedCurve:oe,tapScrollCircleOptions:S,effectiveTrackLength:ne,onScroll:s,scrollPosition:n}}),t.useLayoutEffect(()=>{re.current=n},[n]),t.useLayoutEffect(()=>{he.current=s},[s]),t.useEffect(()=>{i||T(!1)},[i]);const Se=Gn({isDragging:F,isThumbHovered:L,enableThumbDrag:i}),Ae=t.useCallback((d,E)=>{const D=ge.current,se=E??re.current;if(he.current){const je=he.current(d,se);if(typeof je=="number"&&Number.isFinite(je))return re.current=je,je}const De=typeof d=="function"?d(se):d,Be=Math.max(D.maxScrollPosition,0),ut=D.scrollBarVisible?Q(De,0,Be):0;return re.current=ut,ut},[]),ct=t.useCallback(d=>{const E=ge.current,D=re.current;if(!E.scrollBarVisible||E.maxScrollPosition<=0){const vt=Ae(0,D),kt=vt-D;return{nextPosition:vt,actualDelta:kt,reachedBoundary:!0}}if(d===0)return{nextPosition:D,actualDelta:0,reachedBoundary:!1};const De=Ae(vt=>Q(vt+d,0,E.maxScrollPosition),D),Be=De-D,ut=d<0&&D+d<=0,je=d>0&&D+d>=E.maxScrollPosition,zt=d<0&&(De<=0||ut&&Be===0)||d>0&&(De>=E.maxScrollPosition||je&&Be===0);return{nextPosition:De,actualDelta:Be,reachedBoundary:zt}},[Ae]),Ze=t.useCallback((d,E)=>{d.current+=E;const D=Math.max(ge.current.maxScrollPosition,0);D>0&&(d.current=Q(d.current,-D,D));const se=ct(d.current);return d.current-=se.actualDelta,se.reachedBoundary&&(d.current=0),se},[ct]),Qe=t.useCallback(()=>{ee.current!==null&&(window.cancelAnimationFrame(ee.current),ee.current=null),te.current=null,_e.current=0,ce.current=0},[]),Le=t.useCallback(()=>{Oe.current={...on},U(!1),M.current?.reset(),Qe()},[Qe]),st=t.useCallback(d=>{const E=Oe.current,D=ge.current;if(!E.active||E.direction===0){Qe();return}if(!D.scrollBarVisible||D.maxScrollPosition<=0){Qe();return}const se=te.current??d,De=Math.max((d-se)/1e3,0),Be=Math.min(De,wn);if(te.current=d,Be<=0){ee.current=window.requestAnimationFrame(st);return}const ut=Er({distance:E.distance,maxDistance:D.effectiveTapMaxDistance,viewportSize:D.viewportSize,minSpeedMultiplier:D.tapCircleMinSpeedMultiplier,maxSpeedMultiplier:D.tapCircleMaxSpeedMultiplier,hasCustomMaxSpeedMultiplier:typeof D.tapScrollCircleOptions?.maxSpeedMultiplier=="number",curve:D.tapCircleMaxSpeedCurve});ce.current!==E.direction&&(ce.current=E.direction,_e.current=0);const{reachedBoundary:je}=Ze(_e,E.direction*ut*Be);if(je){Qe();return}ee.current=window.requestAnimationFrame(st)},[Ze,Qe]),xe=t.useCallback(()=>{ee.current===null&&(te.current=null,_e.current=0,ee.current=window.requestAnimationFrame(st))},[st]);t.useEffect(()=>{const d=Oe.current;!d.active||d.direction===0||xe()},[r,e,xe]),t.useEffect(()=>()=>{Qe()},[Qe]);const me=t.useCallback(d=>{Oe.current=d,U(d.active),d.active&&d.direction!==0?xe():Qe()},[xe,Qe]);t.useEffect(()=>{rt||Le()},[Le,rt]),t.useEffect(()=>{const d=E=>{const se=E.detail?.paneId;se&&y&&se!==y||Le()};return window.addEventListener(pr,d),()=>{window.removeEventListener(pr,d)}},[y,Le]),t.useEffect(()=>{if(!rt)return;const d=E=>{if(!Oe.current.active||Oe.current.pointerId===E.pointerId)return;const D=E.target;if(!(D instanceof Node)){Le();return}M.current?.getElement()?.contains(D)||Le()};return document.addEventListener("pointerdown",d,!0),()=>{document.removeEventListener("pointerdown",d,!0)}},[Le,rt]);const bt=d=>{if(!be||ne<=0||G<=0)return 0;const E=Q(d,0,ne);return Q(E/ne*G,0,G)},h=t.useCallback(d=>{const{scrollBarVisible:E,effectiveTrackLength:D,maxScrollPosition:se}=ge.current;if(k.debug("[ScrollBar] calculateScrollPositionFromThumb",()=>({thumbPos:d,trackLen:D,maxScroll:se})),D<=0||se<=0)return null;const De=Q(d,0,D);return Q(De/D*se,0,se)},[]),C=t.useCallback(d=>Dr(d,u?"x":"y"),[u]),ye=t.useCallback(d=>{const E=H.current;if(E.pointerId!==d.pointerId)return;const D=d.clientX-E.startClientX,se=d.clientY-E.startClientY,De=Ve(D,se)/(E.scale||1);k.debug("[ScrollBar] handleThumbPointerMove",()=>({delta:De,startThumbPosition:E.startThumbPosition,clientY:d.clientY,startClientY:E.startClientY,metrics:ge.current}));const Be=h(E.startThumbPosition+De);Be!==null&&Ae(Be),d.cancelable&&d.preventDefault()},[Ve,h,Ae]),Je=t.useCallback(d=>{const E=H.current;if(E.pointerId===d.pointerId)if(document.removeEventListener("pointermove",ye),document.removeEventListener("pointerup",Je),document.removeEventListener("pointercancel",Je),E.captureTarget!==null&&Jt(E.captureTarget,d.pointerId),H.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1,captureTarget:null},ae(!1),Y.current){const D=Y.current.getBoundingClientRect();d.clientX>=D.left&&d.clientX<=D.right&&d.clientY>=D.top&&d.clientY<=D.bottom||T(!1)}else T(!1)},[ye]);t.useEffect(()=>()=>{document.removeEventListener("pointermove",ye),document.removeEventListener("pointerup",Je),document.removeEventListener("pointercancel",Je)},[ye,Je]);const Ce=t.useRef(0),Rt=t.useRef(0),et=t.useCallback(d=>{const E=Math.max(Math.round(ge.current.viewportSize/Yn),qn);Rt.current!==d&&(Rt.current=d,Ce.current=0),Ze(Ce,d*E)},[Ze]),{handleArrowPointerDown:it,handleArrowPointerUp:Pe,handleArrowKeyDown:Ft}=Kn({canUseArrowButtons:Xe,enableArrowButtons:o,resetTapScroll:Le,scrollByStep:et}),nr=d=>{if(!be)return;if(!i){d.preventDefault(),d.stopPropagation();return}if(d.pointerType==="mouse"&&d.button!==0||d.ctrlKey)return;Le();const E=d.currentTarget,D=C(E),se=hr(E,d.pointerId)==="captured"?E:null;H.current={pointerId:d.pointerId,startThumbPosition:fe,startClientX:d.clientX,startClientY:d.clientY,scale:D,captureTarget:se},document.addEventListener("pointermove",ye),document.addEventListener("pointerup",Je),document.addEventListener("pointercancel",Je),ae(!0),T(!0),d.preventDefault(),d.stopPropagation()},Ht=d=>{if(!be)return;if(!a){d.preventDefault(),d.stopPropagation();return}if(d.pointerType==="mouse"&&d.button!==0||d.ctrlKey)return;const E=d.currentTarget,D=E.getBoundingClientRect(),se=de(d),De=C(E),Be=(se-(u?D.left:D.top))/De;Le();const ut=Be-le/2,je=bt(ut);Ae(je),hr(E,d.pointerId),K.current={pointerId:d.pointerId,startThumbPosition:ut,startClientX:d.clientX,startClientY:d.clientY,scale:De},d.preventDefault(),d.stopPropagation()},ve=()=>{K.current={pointerId:null,startThumbPosition:0,startClientX:0,startClientY:0,scale:1}},Nt=d=>{const E=K.current;if(E.pointerId!==d.pointerId)return;if(d.pointerType==="mouse"&&d.buttons===0){ve();return}const D=d.clientX-E.startClientX,se=d.clientY-E.startClientY,De=Ve(D,se)/(E.scale||1),Be=bt(E.startThumbPosition+De);Ae(Be),d.cancelable&&d.preventDefault()},Bt=d=>{K.current.pointerId===d.pointerId&&(Jt(d.currentTarget,d.pointerId),ve(),d.preventDefault(),d.stopPropagation())},er=d=>{K.current.pointerId===d.pointerId&&(Jt(d.currentTarget,d.pointerId),ve())},Ie=d=>{d.target===d.currentTarget&&K.current.pointerId===d.pointerId&&ve()},xt=t.useMemo(()=>Q((z?1:.8)*ke,0,1),[z,ke]),Xt=t.useMemo(()=>{const E=`calc(50% - ${Ge/2}px + ${Fe}px)`;return{left:pt,top:E}},[pt,Fe,Ge]),Lt=(d,E,D,se)=>V.jsx("button",{type:"button",tabIndex:0,className:"aqvs-scrollbar-arrow-button",style:{[ue]:b,[ft]:b},"aria-label":E,onPointerDown:it(d),onPointerUp:Pe,onPointerLeave:Pe,onPointerCancel:Pe,onKeyDown:Ft(d),"aria-disabled":!o,disabled:!Xe,children:V.jsx("span",{"aria-hidden":"true",children:D})},se),mt=W&&be?{orientation:Ke,scrollPosition:n,maxScrollPosition:G,contentSize:r,viewportSize:e,thumbSize:le,thumbPosition:fe,thumbCenter:Ye,trackSize:x,isDragging:F,isTapScrollActive:z,visibleStartIndex:_,visibleEndIndex:Re}:null;return V.jsxs("div",{className:It.twMerge("aqvs-scrollbar",at,I),style:{...g&&!u?{}:{[ue]:e},[ft]:b},"data-visible":be?"true":"false",role:"scrollbar",tabIndex:-1,"aria-controls":y,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":G,"aria-orientation":u?"horizontal":"vertical",children:[(!u||m)&&be&&rt&&V.jsx(Br,{axis:u?"x":"y",ref:M,className:It.twMerge("aqvs-scrollbar-tap-circle-wrapper",He),size:Ge,maxVisualDistance:Tt,style:Xt,opacity:xt,renderVisual:Me,onDragChange:me},"tap-circle"),Lt(-1,Ue[0],O[0],"arrow-start"),V.jsxs("div",{className:"aqvs-scrollbar-track",style:{borderRadius:b/2},onPointerDown:Ht,onPointerMove:Nt,onPointerUp:Bt,onPointerCancel:er,onLostPointerCapture:Ie,"aria-disabled":!a,children:[mt&&V.jsx("div",{className:"aqvs-scrollbar-overlay","aria-hidden":!0,children:W?.(mt)},"overlay"),V.jsx("div",{className:"aqvs-scrollbar-thumb-wrapper",style:{[ue]:le,[w]:fe,...u?{top:0,bottom:0}:{left:0,right:0}},"data-visible":be||F?"true":"false",onPointerDown:nr,role:"slider","aria-orientation":u?"horizontal":"vertical","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":G,"aria-disabled":!i,tabIndex:-1,children:V.jsx("div",{ref:Y,className:It.twMerge("aqvs-scrollbar-thumb",u?"aqvs-scrollbar-thumb-horizontal":"aqvs-scrollbar-thumb-vertical"),"data-testid":"aqvs-scrollbar-thumb","data-thumb-state":Se,style:{borderRadius:b-1,cursor:i?"pointer":"default"},onMouseEnter:()=>{i&&T(!0)},onMouseLeave:()=>{i&&T(!1)}},"thumb")},"thumb-wrapper")]},"track"),Lt(1,Ue[1],O[1],"arrow-end")]})},Mn=({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 m=Er({distance:u,maxDistance:n,viewportSize:s.viewportSize,minSpeedMultiplier:s.minSpeedMultiplier,maxSpeedMultiplier:s.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:s.hasCustomMaxSpeedMultiplier,curve:s.curve}),g=Er({distance:u,maxDistance:n,viewportSize:i.viewportSize,minSpeedMultiplier:i.minSpeedMultiplier,maxSpeedMultiplier:i.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:i.hasCustomMaxSpeedMultiplier,curve:i.curve});return{x:m*a/u,y:g*o/u}},Qn=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}}},Jn=16,ln=(r,e,n)=>e===1?r*Jn:e===2?r*n:r,es=(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:ln(s,r.deltaMode,e),verticalDelta:ln(i,r.deltaMode,e)}},yn=new WeakSet,cn=r=>{yn.add(r)},ts=r=>yn.has(r),rs=["mouse","pen","touch"],zr=(r,e)=>!(r==="mouse"||r==="pen"||r==="touch")||e.includes(r),ns=r=>r==="mouse"||r==="pen",fr={maxVelocity:6,minVelocity:.02,deceleration:.0025,velocitySampleWindow:90,startVelocityThreshold:.04},Mr=(r,e,n)=>{for(const[s,i,a]of e)n==="add"?r.addEventListener(s,i,a):r.removeEventListener(s,i,a)},In=t.forwardRef(({children:r,contentSize:e,viewportSize:n,onViewportSizeChange:s,scrollBarWidth:i=12,enableThumbDrag:a=!0,enableTrackClick:o=!0,enableArrowButtons:u=!0,enablePointerDrag:m=!0,pointerDragInputs:g=rs,onScroll:b,className:I,testId:y,style:S,background:P,tapScrollCircleOptions:W,inertiaOptions:_,itemCount:Re,renderThumbOverlay:Te,wheelSpeedMultiplier:A=1,overscrollBehavior:F="auto",onWheelHorizontal:ae,onPanHorizontal:L,contentInsets:T,visibleStartIndex:z,visibleEndIndex:U,renderOverlay:Y,initialScrollPosition:H=0,contentProps:K,locale:re,labels:he},Oe)=>{const M=t.useRef(Number.isFinite(H)?Math.max(0,H):0),ee=t.useRef(null),te=t.useRef(null),_e=n===void 0,[ce,qe]=t.useState(0),pe=n??ce,J=t.useRef(null);t.useLayoutEffect(()=>{if(!_e)return;const x=te.current;if(!x)return;const N=()=>{const G=x.offsetHeight;if(G>0){qe(ne=>ne===G?ne:G);return}x.offsetParent!==null&&e>0&&J.current!=="zero"&&(J.current="zero",k.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(N(),typeof ResizeObserver!="function")return;const le=new ResizeObserver(N);return le.observe(x),()=>{le.disconnect()}},[e,_e]),t.useLayoutEffect(()=>{_e&&s?.(ce)},[_e,ce,s]),t.useLayoutEffect(()=>{if(_e)return;const x=ee.current;if(!x)return;const N=()=>{const G=x.clientHeight;if(G<=0||Math.abs(G-pe)<=1)return;const ne=`${pe}/${G}`;J.current!==ne&&(J.current=ne,k.warn(`[ScrollPane] viewportSize=${pe} but the host band is ${G}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(N(),typeof ResizeObserver!="function")return;const le=new ResizeObserver(N);return le.observe(x),()=>{le.disconnect()}},[_e,pe]);const Ue=t.useRef(ae);t.useEffect(()=>{Ue.current=ae},[ae]);const rt=t.useRef(L);t.useEffect(()=>{rt.current=L},[L]);const Ge=t.useRef({frame:null,velocity:0,lastTimestamp:null,generation:0}),pt=t.useMemo(()=>({maxVelocity:_?.maxVelocity??fr.maxVelocity,minVelocity:_?.minVelocity??fr.minVelocity,deceleration:_?.deceleration??fr.deceleration,velocitySampleWindow:_?.velocitySampleWindow??fr.velocitySampleWindow,startVelocityThreshold:_?.startVelocityThreshold??fr.startVelocityThreshold}),[_]),Fe=t.useMemo(()=>({top:Math.max(0,T?.top??0),bottom:Math.max(0,T?.bottom??0)}),[T]);k.debug("[ScrollPane] ScrollPane rendered",()=>({contentSize:e,viewportSize:pe,scrollBarWidth:i,className:I,style:S,tapScrollCircleOptions:W,inertiaOptions:_,enablePointerDrag:m,contentInsets:Fe}));const He=t.useRef({contentSize:e,viewportSize:pe}),Ee=t.useMemo(()=>e>pe,[e,pe]),nt=t.useCallback((x,N)=>{let le=N??He.current;N&&!(Number.isFinite(N.contentSize)&&Number.isFinite(N.viewportSize))&&(k.warn("[ScrollPane] scrollTo received non-finite dimsOverride; falling back to the committed dims",{dimsOverride:N}),le=He.current);const{contentSize:G,viewportSize:ne}=le,fe=G>ne,Ye=M.current;if(k.debug("[ScrollPane] scrollTo called",()=>({newPosition:x,contentSize:G,viewportSize:ne,currentIsScrollable:fe,prevPosition:Ye})),!fe)return M.current!==0&&(M.current=0,b?.(0,Ye)),M.current;const be=typeof x=="function"?x(M.current):x;if(!Number.isFinite(be))return k.warn("[ScrollPane] scrollTo received a non-finite position; keeping the current position",{nextPosition:be}),M.current;const Xe=Math.max(G-ne,0),Se=Q(be,0,Xe);return M.current!==Se&&(M.current=Se,b?.(Se,Ye)),M.current},[b]),Z=t.useRef(nt);t.useEffect(()=>{Z.current=nt},[nt]);const ke=t.useCallback(()=>{const x=Ge.current;x.generation+=1,x.frame!==null&&cancelAnimationFrame(x.frame),x.frame=null,x.velocity=0,x.lastTimestamp=null},[]),Me=t.useRef(ke);t.useEffect(()=>{Me.current=ke},[ke]),t.useEffect(()=>()=>{Me.current()},[]);const oe=t.useCallback(x=>{if(!Ee)return;const{maxVelocity:N,minVelocity:le,deceleration:G,startVelocityThreshold:ne}=pt,fe=Q(x,-N,N);if(Math.abs(fe)<ne)return;ke(),Ge.current.velocity=fe,Ge.current.lastTimestamp=null;const Ye=Ge.current.generation,be=Xe=>{const Se=Ge.current;if(Se.generation!==Ye)return;if(Se.lastTimestamp===null){Se.lastTimestamp=Xe,Se.frame=requestAnimationFrame(be);return}const Ae=Xe-Se.lastTimestamp;if(Se.lastTimestamp=Xe,Ae<=0){Se.frame=requestAnimationFrame(be);return}const ct=Se.velocity;let Ze=ct;const Qe=G*Ae;ct>0?Ze=Math.max(0,ct-Qe):ct<0&&(Ze=Math.min(0,ct+Qe));const st=(ct+Ze)/2*Ae,xe=M.current;if(st!==0&&Z.current(Je=>Je+st),Ge.current.generation!==Ye)return;const me=M.current,{contentSize:bt,viewportSize:h}=He.current,C=Math.max(bt-h,0);Se.velocity=Ze;const ye=me===xe||me<=0&&Ze<=0||me>=C&&Ze>=0;if(Math.abs(Ze)<le||ye){ke();return}Se.frame=requestAnimationFrame(be)};Ge.current.frame=requestAnimationFrame(be)},[Ee,pt,ke]),ge=t.useRef(oe);t.useEffect(()=>{ge.current=oe},[oe]),t.useLayoutEffect(()=>{He.current={contentSize:e,viewportSize:pe}},[e,pe]),t.useLayoutEffect(()=>{const x=te.current;if(!x)return;const N=()=>{x.scrollTop!==0&&(k.debug("[ScrollPane] Native scroll detected, resetting to 0",()=>({scrollTop:x.scrollTop})),x.scrollTop=0),x.scrollLeft!==0&&(x.scrollLeft=0)};return x.addEventListener("scroll",N),()=>x.removeEventListener("scroll",N)},[]),t.useLayoutEffect(()=>{if(Ee){k.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change",()=>({contentSize:e,viewportSize:pe,scrollPosition:M.current}));const x=Q(e-pe,0,e);M.current>x&&nt(x)}else nt(0)},[Ee,nt,e,pe]);const ue=t.useRef({isScrollable:Ee,viewportSize:pe,wheelSpeedMultiplier:A,overscrollBehavior:F});t.useLayoutEffect(()=>{ue.current={isScrollable:Ee,viewportSize:pe,wheelSpeedMultiplier:A,overscrollBehavior:F}},[Ee,pe,A,F]);const ft=t.useCallback(x=>{if(ts(x))return!1;const{isScrollable:N,viewportSize:le,wheelSpeedMultiplier:G,overscrollBehavior:ne}=ue.current,fe=es(x,le);if(fe.isZoomGesture)return!1;if(fe.isHorizontalDominant)return Ue.current?(cn(x),x.preventDefault(),ke(),Ue.current(fe.horizontalDelta),!0):!1;if(!N||fe.verticalDelta===0)return!1;let Ye=fe.verticalDelta;if(G!==1&&(Ye*=G),ne!=="contain"){const be=M.current,Xe=Math.max(He.current.contentSize-le,0);if(Ye>0&&be>=Xe||Ye<0&&be<=0)return!1}return cn(x),x.preventDefault(),ke(),k.debug("[ScrollPane] wheel event",()=>({deltaY:Ye,scrollPosition:M.current,wheelSpeedMultiplier:G,deltaMode:x.deltaMode,scrollTop:te.current?.scrollTop})),nt(be=>be+Ye),!0},[nt,ke]);t.useEffect(()=>{const x=G=>{ft(G)},N=()=>{ke()},le=ee.current;return le&&(le.addEventListener("wheel",x,{passive:!1}),le.addEventListener("pointerdown",N,{capture:!0,passive:!0})),()=>{le&&(le.removeEventListener("wheel",x),le.removeEventListener("pointerdown",N,{capture:!0}))}},[ft,ke]),t.useImperativeHandle(Oe,()=>({scrollTo:(x,N)=>(ke(),nt(x,N)),getScrollPosition:()=>M.current,getContentSize:()=>e,getViewportSize:()=>pe,applyWheel:ft}),[nt,e,pe,ke,ft]);const w=t.useId(),Ve=K?.id??w,de=t.useRef({pointerType:"",pointerId:null,startClientY:0,startClientX:0,lastPanClientX:0,startScroll:0,isDragging:!1,shouldCancelNextClick:!1,clickResetTimer:null,velocitySamples:[],scale:1,scaleX:1}),O=t.useRef(m),at=t.useRef(g);t.useEffect(()=>{O.current=m},[m]),t.useEffect(()=>{at.current=g},[g]);const Ke=t.useRef(Ee);t.useEffect(()=>{Ke.current=Ee},[Ee]);const Tt=t.useRef(pt);t.useEffect(()=>{Tt.current=pt},[pt]),t.useEffect(()=>{const x=de.current;if(m&&Ee&&(x.pointerId===null||zr(x.pointerType,g))||x.pointerId===null)return;const N=te.current;x.clickResetTimer!==null&&(window.clearTimeout(x.clickResetTimer),x.clickResetTimer=null);const le=x.isDragging&&x.shouldCancelNextClick,G=x.pointerId;x.pointerId=null,x.pointerType="",x.startClientY=0,x.startScroll=0,x.isDragging=!1,x.shouldCancelNextClick=le,x.velocitySamples=[],x.scale=1,N!==null&&Jt(N,G)},[m,g,Ee]),t.useEffect(()=>{const x=te.current;if(!x)return;const N=6,le=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),G=()=>{const h=de.current;h.pointerId=null,h.pointerType="",h.startClientY=0,h.startScroll=0,h.isDragging=!1,h.velocitySamples=[],h.scale=1},ne=()=>{const h=de.current;h.clickResetTimer!==null&&(window.clearTimeout(h.clickResetTimer),h.clickResetTimer=null)},fe=h=>{const C=de.current,ye=le();C.velocitySamples.push({clientY:h,time:ye});const Je=Tt.current.velocitySampleWindow;C.velocitySamples=C.velocitySamples.filter(Ce=>ye-Ce.time<=Je)},Ye=h=>h instanceof HTMLElement&&h.closest("[data-scrollpane-ignore-drag='true']")!==null,be=h=>{const C=de.current;C.shouldCancelNextClick&&(h.preventDefault(),h.stopPropagation(),C.shouldCancelNextClick=!1)},Xe=h=>{const C=de.current;C.isDragging||(C.isDragging=!0,C.shouldCancelNextClick=!0,Sn(x,h.pointerId)||hr(x,h.pointerId),fe(h.clientY))},Se=h=>h.isTrusted||h.target===x,Ae=h=>{const C=de.current;Jt(x,h),C.shouldCancelNextClick=!1,ne(),G()},ct=h=>{const C=de.current;if(C.pointerId!==h.pointerId)return;if(h.buttons===0&&ns(h.pointerType)){Ae(h.pointerId);return}if(!(O.current&&Ke.current)||!zr(h.pointerType,at.current))return;if(!C.isDragging){const Rt=Math.abs(h.clientY-C.startClientY),et=rt.current?Math.abs(h.clientX-C.startClientX):0;if(Math.max(Rt,et)<N||(Xe(h),!C.isDragging))return}fe(h.clientY);const ye=(h.clientY-C.startClientY)/(C.scale||1),Je=C.startScroll-ye;Z.current(Je);const Ce=rt.current;if(Ce){const Rt=h.clientX-C.lastPanClientX;C.lastPanClientX=h.clientX,Rt!==0&&Ce(-Rt/(C.scaleX||1))}h.cancelable&&h.preventDefault()},Ze=()=>{const h=de.current;return h.pointerId!==null||!h.shouldCancelNextClick?!1:(ne(),h.clickResetTimer=window.setTimeout(()=>{const C=de.current;C.shouldCancelNextClick=!1,C.clickResetTimer=null},0),!0)},Qe=h=>{const C=de.current;if(C.pointerId!==h.pointerId){Ze();return}C.isDragging&&C.shouldCancelNextClick&&h.cancelable&&(h.preventDefault(),h.stopPropagation()),C.isDragging&&fe(h.clientY);let ye=0;if(C.isDragging&&C.velocitySamples.length>=2){const Ce=C.velocitySamples,Rt=Tt.current.velocitySampleWindow,et=Ce[Ce.length-1],it=Ce.find(Pe=>et.time-Pe.time<=Rt)??Ce[0];if(et&&it&&et.time!==it.time){const Pe=et.clientY-it.clientY,Ft=et.time-it.time;ye=-(Pe/Ft)/(C.scale||1)}}ne(),C.shouldCancelNextClick&&(C.clickResetTimer=window.setTimeout(()=>{const Ce=de.current;Ce.shouldCancelNextClick=!1,Ce.clickResetTimer=null},0));const Je=Tt.current.startVelocityThreshold;G(),Jt(x,h.pointerId),Math.abs(ye)>=Je&&ge.current?.(ye)},Le=h=>{if(de.current.pointerId!==null){if(!h.isPrimary||h.pointerType!==de.current.pointerType)return;Ae(de.current.pointerId)}if(de.current.shouldCancelNextClick&&(ne(),de.current.shouldCancelNextClick=!1),!(O.current&&Ke.current)||!zr(h.pointerType,at.current)||h.button!==0&&h.pointerType==="mouse"||h.ctrlKey||h.metaKey||h.altKey||Ye(h.target))return;window.dispatchEvent(new CustomEvent(pr,{detail:{paneId:w}})),Me.current?.();const C=de.current;ne(),C.pointerId=h.pointerId,C.pointerType=h.pointerType,C.startClientY=h.clientY,C.startClientX=h.clientX,C.lastPanClientX=h.clientX,C.startScroll=M.current,C.scale=Dr(x,"y"),C.scaleX=rt.current?Dr(x,"x"):1,C.isDragging=!1,C.shouldCancelNextClick=!1,C.velocitySamples=[]},st=h=>{if(de.current.pointerId!==h.pointerId){Ze();return}Se(h)&&Ae(h.pointerId)},me=[["click",be,!0],["pointerdown",Le,{passive:!1}],["lostpointercapture",h=>{h.target!==x||de.current.pointerId!==h.pointerId||Ae(h.pointerId)},void 0]],bt=[["pointermove",ct,{passive:!1}],["pointerup",Qe,void 0],["pointercancel",st,void 0]];return Mr(x,me,"add"),Mr(window,bt,"add"),()=>{Mr(x,me,"remove"),Mr(window,bt,"remove");const h=de.current;h.pointerId!==null&&Jt(x,h.pointerId),ne(),G()}},[w]);const gt=t.useCallback(x=>(ke(),nt(x)),[nt,ke]);return V.jsxs("div",{ref:ee,"data-testid":y,"data-self-measured":_e?"true":void 0,className:It.twMerge("aqvs-scroll-pane",I),style:S,children:[V.jsxs("div",{ref:te,className:It.twMerge("aqvs-scroll-pane-content"),"data-testid":"aqvs-scroll-pane-content",style:{height:_e?void 0:pe,paddingTop:Fe.top,paddingBottom:Fe.bottom,...m&&Ee&&g.some(x=>x==="touch"||x==="pen")?{touchAction:"none"}:{}},...K,id:Ve,children:[P,r(M.current)]}),V.jsx(Wr,{contentSize:e,viewportSize:pe,stretchMainSize:_e,scrollPosition:M.current,onScroll:gt,enableThumbDrag:a,enableTrackClick:o,enableArrowButtons:u,scrollBarWidth:i,ariaControls:Ve,tapScrollCircleOptions:W,itemCount:Re,renderThumbOverlay:Te,visibleStartIndex:z,visibleEndIndex:U,locale:re,labels:he},"scrollbar"),Y?.()]})}),un=(r,e,n)=>Math.min(Math.max(r,e),n),ss=({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,m=.8+e*.18,g=3*n,b=6*n,I=22*n,y=Math.abs(u)+b,S=u>0?g:-Math.abs(u)-g,P=Math.max(2.5,3*n),W=un(r.offsetX,-i,i),_=un(r.offsetY,-i,i),Re=i*.35,Te=W/i*Re,A=_/i*Re,F=Te*.45,ae=A*.45,L=Math.max(I*.38,6),T=.65+e*.2,z=r.active;return V.jsxs(V.Fragment,{children:[V.jsx("div",{className:"aqvs-tap-scroll-circle-gradient",style:{transform:`scale(${o}, ${a})`,transition:z?"40ms transform ease-out":"200ms ease transform"}}),V.jsx("div",{className:"aqvs-sample-visual-pupil",style:{width:I,height:I,transform:`translate(calc(-50% + ${Te}px), calc(-50% + ${A}px)) scale(${o}, ${m*a})`,transition:z?"70ms transform ease-out":"200ms ease transform"}}),V.jsx("div",{className:"aqvs-sample-visual-highlight",style:{width:L,height:L,transform:`translate(calc(-50% + ${F}px), calc(-50% + ${ae}px)) scale(${o}, ${a})`,opacity:T,boxShadow:"0 0 8px rgba(255,255,255,0.45)",transition:z?"120ms opacity 150ms, 120ms transform ease-out ease-out":"220ms ease transform, 240ms opacity ease"}}),V.jsx("div",{className:"aqvs-sample-visual-rod",style:{width:P,height:y,transform:`translate(-50%, ${S}px)`,opacity:e,transition:z?"40ms height, 60ms opacity ease-out ease-out":"200ms ease height, 120ms ease opacity"}})]})},ar=100,is=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},kr=(r,e)=>{if(!Number.isFinite(r))throw new Error(`valueFn returned a non-finite value at index ${e}: ${r}`);return r},or=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 _t{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 m=s?.sampleRange??{from:0,to:Math.min(ar-1,i-1)};let g=Math.max(0,Math.trunc(m.from)),b=Math.min(Math.trunc(m.to),i-1);g>b&&(g=0,b=Math.min(ar-1,i-1)),o={from:g,values:_t._collectValidatedValues(n,g,b)}}}else if(i>0){const m=s?.sampleRange??{from:0,to:Math.min(ar-1,i-1)};let g=Math.max(0,Math.trunc(m.from)),b=Math.min(Math.trunc(m.to),i-1);if(g>b&&(g=0,b=Math.min(ar-1,i-1)),i>ar)a=_t._sampleBaseValueStrided(n,i,ar),s?.materialize&&(o={from:g,values:_t._collectValidatedValues(n,g,b)});else{const I=_t._collectValidatedValues(n,g,b);a=_t._modeOrMedian([...I]),s?.materialize&&(o={from:g,values:I})}}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 m=0;m<o.values.length;m++){const g=o.from+m;if(g>=this.size)break;const b=o.values[m]-this.baseValue;b!==0&&(this.deltas.set(g,b),this._updateTree(g,b))}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(kr(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[m,g]of i.entries())g===a&&o.push(m);const u=o.reduce((m,g)=>m+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(kr(e(o),o));return _t._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=or(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,m=a-u;m!==0&&n.push({index:i,change:m}),s.set(i,o+m)}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=or(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=kr(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 m=Math.max(0,Math.trunc(u.from)),g=Math.min(Math.trunc(u.to),this.size-1);for(let b=m;b<=g;b++)this._materialize(b)}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 m=(this.tree.get(o)??0)+this.baseValue*a;(n?i+m<e:i+m<=e)&&(s=o,i+=m)}}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=is(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,m,g,b=this.total;for(;o<=u;){const S=o+u>>1n,P=Number(S),W=this.prefixSum(P);if(b=W.total,s?W.cumulative>=e:W.cumulative<=e)if(m=S,g=W,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 I=g,y=m!==void 0?Number(m):-1;if(a&&y>=0){const S=this.deltas.get(y)??0;if(this._materialize(y),(this.deltas.get(y)??0)!==S)continue}return{index:y,total:b,cumulative:I?.cumulative,currentValue:I?.currentValue,safeIndex:I?.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=Q(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 m=this.tree.get(o)??0;a+=m;const g=or(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&&k.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=or(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&&k.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=or(a);if(o===0)break;a+=o}for(;a<=i;){this.tree.set(a,(this.tree.get(a)??0)+n);const o=or(a);if(o===0)break;a+=o}}_growSize(e,n){if(this.size=n,this.deltas.size>0){const s=_t._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 as=(r,e)=>{const n=r?.sampleRange,s=e?.sampleRange;return n===s?!1:n&&s?n.from!==s.from||n.to!==s.to:!0},Ur=(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 _t(s,e,n));const o=i.current,u=a.current,m=u.size!==s,g=u.valueOrFn!==e,b=as(u.options,n)||u.options?.baseValue!==n?.baseValue,I=u.size===0&&s>0&&(!i.current||i.current.base===0);if(g||b){const y=n?.resetOnValueFnChange??!0;b||g&&y||I?(n?.debug&&k.debug("[useFenwickMapTree] reset",{valueOrFnChanged:g,optionsChanged:b}),o.reset(s,e,n)):(m&&(n?.debug&&k.debug("[useFenwickMapTree] resize (with valueFn change)",{from:u.size,to:s}),o.changeSize(s)),n?.debug&&k.debug("[useFenwickMapTree] setValueFn (no reset)",{valueOrFnChanged:g}),o.setValueFn(e,{reset:!1})),a.current={size:s,valueOrFn:e,options:n}}else m&&(n?.debug&&k.debug("[useFenwickMapTree] resize",{from:u.size,to:s}),I?o.reset(s,e,n):o.changeSize(s),a.current={size:s,valueOrFn:e,options:n});return o};class os{key;value;prev=null;next=null;constructor(e,n){this.key=e,this.value=n}}class Ar{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 Tn(r){const e=t.useRef(new Map),n=t.useRef(new Ar),s=Math.floor(r),i=t.useRef(s);t.useEffect(()=>{if(i.current=s,Number.isNaN(s)||s<0){k.warn(`useLruCache: invalid capacity ${r}; the cache will not store any entries.`),e.current.clear(),n.current=new Ar;return}if(Number.isFinite(s))for(;e.current.size>s;){const b=n.current.removeHead();if(b)e.current.delete(b.key);else break}},[r,s]);const a=t.useCallback(b=>{const I=e.current.get(b);if(I)return n.current.moveToTail(I),I.value},[]),o=t.useCallback((b,I)=>{const y=i.current;if(Number.isNaN(y)||y<=0)return;let S=e.current.get(b);if(S)S.value=I,n.current.moveToTail(S);else{if(e.current.size>=y){const P=n.current.removeHead();P&&e.current.delete(P.key)}S=new os(b,I),e.current.set(b,S),n.current.addToTail(S)}},[]),u=t.useCallback(b=>e.current.has(b),[]),m=t.useCallback(b=>{const I=e.current.get(b);I&&(n.current.remove(I),e.current.delete(b))},[]),g=t.useCallback(()=>{e.current.clear(),n.current=new Ar},[]);return t.useMemo(()=>({get:a,set:o,has:u,remove:m,clear:g}),[a,o,u,m,g])}const ls=1e4,cs=()=>{const{get:r,set:e,has:n,clear:s}=Tn(ls);return t.useMemo(()=>({get:r,set:e,has:n,clear:s}),[r,e,n,s])},us=(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))}},[])},dn=-200,fn={active:!1,offsetX:0,offsetY:0,distance:0,direction:0,pointerId:null},ds=r=>{const e=t.useRef(r);e.current=r;const n=t.useRef(fn),s=t.useRef(null),[i,a]=t.useState(!1),o=t.useRef(null),u=t.useRef(null),m=t.useRef({residual:0,direction:0}),g=t.useRef({residual:0,direction:0}),b=t.useCallback(()=>{o.current!==null&&(window.cancelAnimationFrame(o.current),o.current=null),u.current=null,m.current={residual:0,direction:0},g.current={residual:0,direction:0}},[]),I=t.useCallback((A,F,ae,L,T,z)=>{const U=F>0?1:F<0?-1:0;U!==0&&U!==A.direction&&(A.direction=U,A.residual=0),A.residual+=F*ae;const Y=Math.max(T(),0);Y>0&&(A.residual=Q(A.residual,-Y,Y));const H=A.residual;if(H===0)return{actualDelta:0,atBoundary:!1};const K=L(),re=z(H),he=re-K;A.residual-=he;const Oe=H<0&&K+H<=0,M=H>0&&K+H>=Y,ee=H<0&&(re<=0||Oe&&he===0)||H>0&&(re>=Y||M&&he===0);return ee&&(A.residual=0),{actualDelta:he,atBoundary:ee}},[]),y=t.useCallback(A=>{const F=e.current,ae=n.current;if(!ae.active||ae.direction===0){b();return}const L=u.current??A,T=Math.max((A-L)/1e3,0),z=Math.min(T,wn);if(u.current=A,z<=0){o.current=window.requestAnimationFrame(y);return}const U=Mn({offsetX:ae.offsetX,offsetY:ae.offsetY,maxDistance:F.maxDistance,x:F.xSpeedParams,y:F.ySpeedParams}),Y=I(m.current,U.x,z,F.getHx,F.getMaxHx,he=>F.applyHxRef.current(F.getHx()+he));Y.actualDelta!==0&&(F.pendingColAnchorRef.current=null);const H=I(g.current,U.y,z,F.getVy,F.getMaxVy,F.applyVy),K=F.getMaxHx()<=0||Y.atBoundary||ae.offsetX===0,re=F.getMaxVy()<=0||H.atBoundary||ae.offsetY===0;if(K&&re){b();return}o.current=window.requestAnimationFrame(y)},[b,I]),S=t.useCallback(()=>{o.current===null&&(u.current=null,m.current={residual:0,direction:0},g.current={residual:0,direction:0},o.current=window.requestAnimationFrame(y))},[y]),P=t.useCallback(()=>{n.current={...fn},a(!1),s.current?.reset(),b()},[b]),W=t.useCallback(A=>{n.current=A,a(A.active),A.active&&A.direction!==0?S():b()},[S,b]),{enabled:_,xExtentFreshness:Re,yExtentFreshness:Te}=r;return t.useEffect(()=>{const A=n.current;!A.active||A.direction===0||S()},[Re,Te,S]),t.useEffect(()=>{const A=()=>{P()};return window.addEventListener(pr,A),()=>{window.removeEventListener(pr,A)}},[P]),t.useEffect(()=>{if(!_)return;const A=F=>{if(!n.current.active||n.current.pointerId===F.pointerId)return;const ae=F.target;if(!(ae instanceof Node)){P();return}s.current?.getElement()?.contains(ae)||P()};return document.addEventListener("pointerdown",A,!0),()=>{document.removeEventListener("pointerdown",A,!0)}},[_,P]),t.useEffect(()=>{_||P()},[_,P]),t.useEffect(()=>()=>{b()},[b]),{isTapActive:i,handleTapCircleDragChange:W,tapCircleHandleRef:s}},We=(r,e)=>e<=0?0:Q(r,0,e-1),mn=r=>({top:Math.max(0,r?.top??0),bottom:Math.max(0,r?.bottom??0)}),wt=(r,e)=>r<=e?0:r-e,rr=(r,e)=>r<=0?0:r+e,gr=1e3,_r=2e3,En=1048576,fs=40,mr=r=>{if(!Number.isFinite(r))return 0n;const e=Math.trunc(r);return e<=0?0n:BigInt(e)},ms=(r,e,n,s,i,a,o,u)=>{const m=mr(s);if(m===0n)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const g=L=>L<0n?0n:L>=m?m-1n:L,b={materializeOption:{materialize:!1}},{index:I,cumulative:y}=a.findIndexAtOrAfter(r,b);let S;I===-1?S=m-1n:(y===r?S=mr(I+1):S=mr(I),S>=m&&(S=m-1n)),r<=0&&(S=0n),u&&r>=o&&(S=m-1n);const P=L=>{const T=Number(L);if(!Number.isSafeInteger(T))return null;const{cumulative:z}=a.prefixSum(T,{materializeOption:{materialize:!1}});if(!Number.isFinite(z))return null;const{index:U}=a.findIndexAtOrAfter(z+.5,{materializeOption:{materialize:!1}});if(U===-1)return null;const Y=mr(U);return Y>L?Y:null},W=L=>{let T=0,z=L,U=L,Y=0n,H=0;for(;z<m&&T<e;){const K=Number(z),re=i(K);if(T+=re,U=z,z+=1n,Y+=1n,!Number.isFinite(re)||re<0)break;if(re===0){if(H+=1,H>gr){const he=P(U);if(he!==null&&he>z)z=he,H=0;else if(he!==null&&he===z&&i(Number(z))>0)H=0;else break}}else H=0}return Y===0n&&(U=L),{height:T,end:U}};let{height:_,end:Re}=W(S);if(_<e&&S>0n){let L=S,T=_,z=0;for(;L>0n&&T<e;){L-=1n;const Y=Number(L),H=i(Y);if(T+=H,!Number.isFinite(H)||H<0)break;if(H===0){if(z+=1,z>gr){const K=Number(L);if(!Number.isSafeInteger(K))break;const{cumulative:re}=a.prefixSum(K,{materializeOption:{materialize:!1}});if(!Number.isFinite(re))break;const{index:he}=a.findIndexAtOrAfter(re-.5,{materializeOption:{materialize:!1}}),Oe=he===-1?-1n:mr(he);if(Oe>=0n&&Oe<L)L=Oe+1n,z=0;else if(Oe===L&&L>=1n&&i(Number(L-1n))>0)z=0;else break}}else z=0}S=g(L);const U=W(S);_=U.height,Re=U.end}const Te=g(S),A=g(Re),F=g(Te-BigInt(Math.max(0,n))),ae=g(A+BigInt(Math.max(0,n)));return{renderingStartIndex:We(Number(F),s),renderingEndIndex:We(Number(ae),s),visibleStartIndex:We(Number(Te),s),visibleEndIndex:We(Number(A),s)}},Cn=(r,e,n,s,i,a,o)=>{if(s===0)return{renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0};const u=Number.isFinite(o),m=u?Math.min(Math.max(0,r),o):Math.max(0,r);if(s>=Number.MAX_SAFE_INTEGER)return ms(m,e,n,s,i,a,o,u);const{index:g,cumulative:b,currentValue:I}=a.findIndexAtOrAfter(m,{materializeOption:{materialize:!1}}),y=g===-1?e<=0||(b??0)<m+(I??0)?s-1:0:g;let S=We(y,s),P=0;if(g!==-1&&b===m)S=We(g+1,s),P=0;else if(S===g&&b!==void 0&&I!==void 0)P=b-I-m;else{const{cumulative:L,currentValue:T}=a.prefixSum(S,{materializeOption:{materialize:!1}});P=(L??0)-(T??0)-m}const W=P,_=(L,T)=>{let z=L,U=T,Y=0;for(;z<s&&U<e;){const H=i(z);if(U+=H,z++,!Number.isFinite(H)||H<0)break;if(H===0){if(Y++,Y>gr){const{cumulative:K}=a.prefixSum(z-1,{materializeOption:{materialize:!1}}),{index:re}=Number.isFinite(K)?a.findIndexAtOrAfter(K+.5,{materializeOption:{materialize:!1}}):{index:-1};if(re>z)z=re,Y=0;else if(re===z&&i(z)>0)Y=0;else break}}else Y=0}return{cursor:z,height:U}},Re=_(S,P);let Te=Re.cursor;if(P=Re.height,P<e&&S>0){let L=P+Math.abs(Math.min(0,W)),T=S-1,z=0;for(;T>=0&&L<e;){const Y=i(T);if(L+=Y,!Number.isFinite(Y)||Y<0){T--;break}if(Y===0){if(z++,z>gr){const{cumulative:H}=a.prefixSum(T,{materializeOption:{materialize:!1}}),{index:K}=Number.isFinite(H)?a.findIndexAtOrAfter(H-.5,{materializeOption:{materialize:!1}}):{index:-1};if(K!==-1&&K<T){T=K,z=0;continue}if(K===T&&T>=1&&i(T-1)>0)z=0;else{T--;break}}}else z=0;T--}S=We(T+1,s);const U=_(S,0);Te=U.cursor,P=U.height}const A=We(S-n,s),F=We(Math.max(Te-1,S),s),ae=We(F+n,s);return{renderingStartIndex:A,renderingEndIndex:ae,visibleStartIndex:S,visibleEndIndex:F}},hn=(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 m=u-i.last;if(s===0||i.last===0||m>=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])},hs=t.memo(({index:r,top:e,height:n,item:s,children:i,clipItemHeight:a,enableKeyboardNavigation:o,onKeyDown:u,onEscapeKeyDown:m,onFocus:g,registerItemRef:b})=>{const I=t.useCallback(_=>b(r,_),[r,b]),y=t.useCallback(_=>u(_,r),[r,u]),S=t.useCallback(_=>m?.(_,r),[r,m]),P=t.useCallback(()=>g(r),[r,g]),W=t.useCallback(_=>{_.currentTarget.focus({preventScroll:!0})},[]);return V.jsx("div",{ref:I,"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?W:void 0,onKeyDownCapture:o?y:void 0,onKeyDown:o&&m?S:void 0,onFocusCapture:o?P:void 0,children:i(s,r)})}),ps=({itemCount:r,getItem:e,getItemKey:n,getItemHeight:s,viewportSize:i,overscanCount:a=15,className:o,testId:u,onScroll:m,onRangeChange:g,children:b,background:I,initialScrollIndex:y,initialScrollOffset:S,initialScrollAnchor:P,callbackThrottleMs:W=5,contentInsets:_,onItemFocus:Re,scrollBarOptions:Te,behaviorOptions:A,onWheelHorizontal:F,onPanHorizontal:ae,horizontalKeyInputs:L,horizontalKeyStep:T=fs,contentProps:z,liveRegion:U,locale:Y,labels:H},K)=>{const{width:re,enableThumbDrag:he,enableTrackClick:Oe,enableArrowButtons:M,enableScrollToTopBottomButtons:ee,renderThumbOverlay:te,tapScrollCircleOptions:_e}=Te??{},ce=t.useMemo(()=>Yr(Y,H),[Y,H]),{enablePointerDrag:qe,pointerDragInputs:pe,enableKeyboardNavigation:J=!0,enableEscapeRowReturn:Ue=!1,wheelSpeedMultiplier:rt,inertiaOptions:Ge,overscrollBehavior:pt,clipItemHeight:Fe=!1,resetOnGetItemHeightChange:He=!1}=A??{},[Ee,nt]=t.useState(0),Z=i??Ee,ke=t.useCallback(c=>{nt(f=>f===c?f:c)},[]),Me=t.useRef(null),oe=t.useRef({renderingStartIndex:0,renderingEndIndex:0,visibleStartIndex:0,visibleEndIndex:0,scrollPosition:0,totalHeight:0}),ge=t.useRef(P&&r>0?{index:Q(Math.trunc(P.index),0,r-1),align:"top",offset:-Math.max(0,P.offsetPx??0)}:null),ue=t.useRef(!1),ft=t.useRef(!0);t.useEffect(()=>{if(ft.current){ft.current=!1;return}He&&(ge.current=null)},[He,s]);const w=t.useMemo(()=>mn(_),[_]),[Ve]=t.useState(()=>{const f=P?.index??y,v=typeof f=="number"&&Number.isFinite(f)?Math.max(0,Math.trunc(f)):0;return{from:Math.max(0,v-50),to:v+50}}),de=t.useMemo(()=>({sampleRange:Ve,resetOnValueFnChange:He,materialize:!0}),[He,Ve]),O=Ur(r,s,de),[at]=t.useState(()=>{let c=0,f=0;if(P&&r>0){const v=Q(Math.trunc(P.index),0,r-1),$=Math.max(0,P.offsetPx??0),q=Q(v-a*2,0,r-1),B=Q(v+a*2,0,r-1),j=v>0||$>0?{materializeOption:{materialize:!0,ranges:[{from:q,to:B}]}}:void 0,{cumulative:we,total:$e,currentValue:Ne}=O.prefixSum(v,j),ze=Math.max(we-Ne+$,0);c=rr(ze,w.top),f=$e??O.getTotal()}else if(typeof y=="number"){const v=Q(y,0,r-1),$=Q(v-a*2,0,r-1),q=Q(v+a*2,0,r-1),B=y>0?{materializeOption:{materialize:!0,ranges:[{from:$,to:q}]}}:void 0,{cumulative:j,total:we,currentValue:$e}=O.prefixSum(y,B),Ne=Math.max(j-$e,0);c=rr(Ne,w.top),f=we??O.getTotal()}else typeof S=="number"&&(c=rr(Math.max(S,0),w.top)),f=O.getTotal();return{position:c,total:f}}),[Ke,Tt]=t.useState(at.position),[gt,x]=t.useState(at.total),N=t.useRef(at.position),le=t.useRef(w.top),G=t.useRef(m??void 0),ne=t.useRef(g??void 0),fe=t.useRef(F),Ye=(L?.length??0)>0,be=!!F;t.useEffect(()=>{Ye&&(J||k.warn("[VirtualScroll] horizontalKeyInputs is set but behaviorOptions.enableKeyboardNavigation is false; horizontal keyboard scrolling is disabled because the row key handler is not mounted."),be||k.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(T)&&T>0||k.warn(`[VirtualScroll] horizontalKeyStep must be a finite positive number, received ${T}. Horizontal arrow keys are left untouched.`))},[Ye,be,J,T]);const Xe=t.useRef(new Map),Se=t.useRef(null),Ae=t.useRef(null),[ct,Ze]=t.useState(null),[Qe,Le]=t.useState(!1),st=t.useRef(null),xe=t.useRef(!1),me=t.useRef(0),bt=t.useRef(!1),h=t.useRef(!1),C=t.useRef(r);C.current!==r&&(C.current=r,h.current=!0),t.useLayoutEffect(()=>{G.current=m??void 0,ne.current=g??void 0,fe.current=F},[g,m,F]);const ye=t.useCallback(c=>{if(J&&c&&typeof c.focus=="function")try{c.focus({preventScroll:!0})}catch{c.focus()}},[J]),Je=t.useCallback((c,{position:f,totalHeight:v})=>{c(f,v)},[]),Ce=hn(G,W,Je),Rt=t.useCallback((c,f)=>{c(f)},[]),et=hn(ne,W,Rt),it=t.useRef(w.top);it.current=w.top;const Pe=t.useRef(Ce);Pe.current=Ce,t.useEffect(()=>(ue.current=!1,()=>{ue.current=!0,st.current&&(clearTimeout(st.current),st.current=null)}),[]),t.useEffect(()=>{J||(Xe.current.clear(),Se.current=null,Ae.current=null)},[J]);const Ft=t.useCallback((c,f)=>{if(!f){Xe.current.delete(c);return}J&&(Xe.current.set(c,f),Se.current===c&&(Se.current=null,Ae.current=c,ye(f)))},[J,ye]),nr=.01,Ht=t.useRef({rafId:null,loopActive:!1,idleFrames:0,lastRenderedPosition:at.position}),ve=t.useCallback(()=>{const c=Ht.current;c.rafId!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(c.rafId),c.rafId=null,c.loopActive=!1,c.idleFrames=0},[]);t.useEffect(()=>()=>{ve()},[ve]);const Nt=t.useRef(()=>{}),Bt=t.useCallback(()=>{const c=Ht.current;c.rafId=null;const f=N.current,v=wt(f,it.current),$=O.getTotal();if(Tt(B=>Math.abs(B-f)<nr?B:f),Math.abs(c.lastRenderedPosition-f)>=nr?(Pe.current({position:v,totalHeight:$}),c.lastRenderedPosition=f,c.idleFrames=0):c.idleFrames+=1,c.idleFrames>=2){ve();return}if(typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(B=>Nt.current(B));return}c.loopActive=!1},[O,ve]);Nt.current=Bt;const er=t.useCallback(()=>{const c=Ht.current;if(c.idleFrames=0,!c.loopActive){if(c.loopActive=!0,typeof requestAnimationFrame=="function"){c.rafId=requestAnimationFrame(Bt);return}c.loopActive=!1}},[Bt]),Ie=t.useCallback((c,f)=>{const v=f?.immediate??!1,$=wt(c,w.top);if(N.current=c,v){Ht.current.lastRenderedPosition=c,Ht.current.idleFrames=0,Tt(c),Ce({position:$,totalHeight:O.getTotal()});return}er()},[er,O,w.top,Ce]),xt=t.useCallback((c,f=0)=>{const v=Me.current;if(!v)return c;const $=v.getScrollPosition();me.current+=1;const q=v.getContentSize()+f,B=v.getViewportSize(),j=v.scrollTo(c,{contentSize:q,viewportSize:B});return j===$&&(me.current=Math.max(0,me.current-1)),Math.abs(j-c)>.5&&(bt.current=!0),j},[]),Xt=t.useRef(!1);t.useEffect(()=>{if(!Xt.current)if(Xt.current=!0,P==null&&typeof y!="number"&&typeof S=="number"){const c=rr(Math.max(S,0),w.top),f=Math.abs(c-N.current)>.5;Ie(c,{immediate:!0}),f&&Me.current?.scrollTo(c)}else Ie(N.current,{immediate:!0})},[P,y,S,w.top,Ie]),t.useEffect(()=>{const c=O.getTotal();if(gt!==c){x(c);return}if(bt.current){bt.current=!1;const f=Me.current;if(f&&Math.abs(f.getScrollPosition()-N.current)>.5){const v=xt(N.current);bt.current=!1,Ie(v,{immediate:!0})}}},[O,gt,r,xt,Ie]),t.useEffect(()=>{if(ge.current!==null){const{index:c,align:f,offset:v}=ge.current,$=We(c,r),{cumulative:q,currentValue:B}=O.prefixSum($,{materializeOption:{materialize:!1}});if(q!==void 0&&B!==void 0){const j=Math.max(q-B,0);let we=j;f==="bottom"?we=q-Z:f==="center"&&(we=j+B/2-Z/2),v&&(we-=v),we=Math.max(0,we);const $e=Math.max(0,gt+w.top+w.bottom-Z),Ne=Math.min(rr(we,w.top),$e);Math.abs(Ne-N.current)>1&&(k.debug("[VirtualScroll] Drift correction",{from:N.current,to:Ne,targetIndex:$}),me.current===0&&(me.current+=1),Me.current?.scrollTo(Ne),Ie(Ne,{immediate:!0}))}}h.current=!1},[gt,O,r,w.top,Ie,Z,w.bottom]),t.useEffect(()=>{const c=le.current;if(c===w.top||(le.current=w.top,ge.current))return;const f=wt(N.current,c),v=rr(f,w.top);N.current=v,Me.current?.scrollTo(v),Ie(v,{immediate:!0})},[w.top,Ie]);const Lt=t.useCallback((c,f)=>{if(r===0)return;const v=We(c,r),$=O.get(v),q=f-$,B=O.update(v,f);B!==void 0&&x(B),k.debug("[VirtualScroll] Updated item size manually",{index:v,size:f,total:B});let j=ge.current?ge.current.index:null;if(j===null){const we=N.current,$e=mn(_).top,Ne=wt(we,$e),{index:ze,cumulative:ot}=O.findIndexAtOrAfter(Ne,{materializeOption:{materialize:!1}});j=ot!==void 0&&ot===Ne?ze+1:ze}if(j!==-1&&v<j&&q!==0){const we=N.current,$e=we+q;xt($e,q),Ie($e,{immediate:!0}),k.debug("[VirtualScroll] Adjusted scroll for layout shift (manual update)",{from:we,to:$e,causedByIndex:v,delta:q,activeVisibleStartIndex:j})}},[O,r,xt,Ie,_]),mt=t.useCallback((c,f)=>{if(!Me.current||r===0)return;const v=We(c,r),$=We(v-a*2,r),q=We(v+a*2,r),{cumulative:B,total:j,currentValue:we}=O.prefixSum(v,{materializeOption:{materialize:!0,ranges:[{from:$,to:q}]}});if(k.debug("[VirtualScroll] Scrolling to index:",v,"ItemBottom:",B,"Total height:",j,"ItemHeight:",we,"safeIndexFrom:",$,"safeIndexTo:",q),!j)return;const $e=Math.max(B-we,0);let Ne=$e;f?.align==="bottom"?Ne=B-Z:f?.align==="center"&&(Ne=$e+we/2-Z/2),f?.offset&&(Ne-=f.offset),Ne=Math.max(0,Ne);const ze=rr(Ne,w.top),ot=Me.current?.getContentSize()??j+w.top+w.bottom,lt=Math.max(0,ot-Z),dt=Math.min(ze,lt);ge.current={index:v,align:f?.align,offset:f?.offset};const Zt=Me.current?.getScrollPosition()??-1,ur=Math.abs(Zt-dt)>.5;xe.current=!1,me.current=0,ur&&(xe.current=!0,me.current+=1,Me.current?.scrollTo(dt)),x(j),Ie(dt,{immediate:!0}),k.debug("[VirtualScroll] Setting scroll position to:",dt,{original:ze,max:lt})},[O,a,r,w.top,w.bottom,Z,Ie]),d=t.useRef(P&&r===0?P:null);t.useEffect(()=>{const c=d.current;!c||r===0||(d.current=null,mt(Q(Math.trunc(c.index),0,r-1),{align:"top",offset:-Math.max(0,c.offsetPx??0)}))},[r,mt]);const E=t.useCallback(c=>{if(!Me.current||r===0)return;const f=O.getTotal(),v=Q(Math.floor(c),0,f),{index:$,cumulative:q,currentValue:B}=O.findIndexAtOrAfter(v,{materializeOption:{materialize:!1}}),we=(q??0)-(B??0)-v;mt($,{offset:we})},[O,r,mt]),D=t.useCallback(()=>{if(r===0)return null;const c=wt(N.current,w.top),{index:f,cumulative:v,currentValue:$}=O.findIndexAtOrAfter(c,{materializeOption:{materialize:!1}});if(f===-1)return{index:r-1,offsetPx:0};if(v===c)return{index:Q(f+1,0,r-1),offsetPx:0};const q=(v??0)-($??0);return{index:f,offsetPx:Math.max(0,c-q)}},[O,r,w.top]),se=t.useCallback(c=>{const f=wt(N.current,w.top),v=typeof c=="function"?c(f):c;E(v);const $=Me.current?.getScrollPosition(),q=typeof $=="number"?$:N.current;return Ie(q),wt(q,it.current)},[w.top,E,Ie]),De=t.useCallback(c=>{const f=Me.current;if(!f)return wt(N.current,it.current);const v=f.scrollTo($=>$+c);return wt(v,it.current)},[]),Be=t.useCallback(c=>Me.current?.applyWheel(c)??!1,[]),ut=t.useCallback((c,f)=>{k.debug("[VirtualScroll] Scroll position changed:",c);const v=xe.current;v&&(xe.current=!1);const $=me.current>0;$&&(me.current=0);const q=h.current&&C.current===r;if(v||$||q||(ge.current=null),Ie(c),ee){if(v||$)return;const B=c-f;if(k.debug("[VirtualScroll] Scroll diff:",B,"New:",c,"Prev:",f),Math.abs(B)>1){const j=B>0?"down":"up";Ze(j),Le(!0),k.debug("[VirtualScroll] Showing scroll buttons. Direction:",j),st.current&&clearTimeout(st.current),st.current=setTimeout(()=>{Le(!1),k.debug("[VirtualScroll] Hiding scroll buttons")},2e3)}}},[Ie,ee,r]),je=t.useMemo(()=>wt(Ke,w.top),[w.top,Ke]),zt=t.useMemo(()=>{const c=O.getTotal(),f=Cn(je,Z,a,r,s,O,c);return k.debug("[VirtualScroll] Calculated rendering range:",()=>({...f,scrollPosition:je,renderingContentSize:c,overscanCount:a,viewportSize:Z})),f},[je,Z,a,r,s,O]),{renderingStartIndex:vt,renderingEndIndex:kt,visibleStartIndex:At,visibleEndIndex:jt}=zt,Mt=t.useCallback((c,f)=>{if(!J||r===0)return;const v=We(c,r);if(!(f?.ensureVisible??!0)){const lt=Xe.current.get(v);lt&&(Se.current=null,Ae.current=v,ye(lt));return}const q=O.prefixSum(v,{materializeOption:{materialize:!1}}),B=q.currentValue,j=Math.max(q.cumulative-B,0),we=j+B,$e=wt(N.current,w.top),Ne=$e+Z;if(j<$e||we>Ne){mt(v);const lt=Xe.current.get(v);lt?(Se.current=null,Ae.current=v,ye(lt)):Se.current=v;return}const ot=Xe.current.get(v);if(ot){Se.current=null,Ae.current=v,ye(ot);return}Se.current=v},[J,r,O,w.top,mt,ye,Z]),$t=t.useCallback((c,f)=>{if(!(!J||c.defaultPrevented)&&!(c.altKey||c.metaKey||c.ctrlKey)&&c.target===c.currentTarget&&!c.currentTarget.isContentEditable){if(c.key==="ArrowLeft"||c.key==="ArrowRight"){const v=fe.current;if(!v||c.shiftKey||!L?.includes("arrow")||!(Number.isFinite(T)&&T>0))return;c.preventDefault(),v(c.key==="ArrowLeft"?-T:T);return}if(c.key==="ArrowDown"){f<r-1&&(c.preventDefault(),Mt(f+1));return}if(c.key==="ArrowUp"){f>0&&(c.preventDefault(),Mt(f-1));return}if(c.key==="PageDown"){if(f<r-1){c.preventDefault();const{visibleStartIndex:v,visibleEndIndex:$}=oe.current,q=Math.max($-v+1,1),B=Math.max(q,1),j=We(Math.min(f+B,r-1),r);Mt(j)}return}if(c.key==="PageUp"&&f>0){c.preventDefault();const{visibleStartIndex:v,visibleEndIndex:$}=oe.current,q=Math.max($-v+1,1),B=Math.max(q,1),j=We(f-B,r);Mt(j)}}},[J,r,Mt,L,T]),qt=t.useCallback((c,f)=>{if(c.key!=="Escape"||c.defaultPrevented||c.nativeEvent.isComposing||c.target===c.currentTarget)return;const v=c.target;v instanceof HTMLInputElement||v instanceof HTMLTextAreaElement||v instanceof HTMLSelectElement||v.isContentEditable||(c.preventDefault(),Mt(f))},[Mt]),lr=t.useCallback(c=>{if(!J)return;const f=We(c,r);Se.current=null,Ae.current=f,Re?.(f)},[J,r,Re]);t.useEffect(()=>{const c=Me.current?.getScrollPosition()??0,f=N.current,v=wt(f,w.top);k.debug("[VirtualScroll] Range change effect triggered",()=>({renderingStartIndex:vt,renderingEndIndex:kt,visibleStartIndex:At,visibleEndIndex:jt,scrollPositionState:Ke,paneScrollPosition:f,logicalScrollPosition:v,contentSize:gt,scrollPaneScrollPosition:c})),et({renderingStartIndex:vt,renderingEndIndex:kt,visibleStartIndex:At,visibleEndIndex:jt,scrollPosition:v,totalHeight:gt})},[gt,kt,vt,w.top,et,Ke,jt,At]);const Et=t.useCallback(()=>{if(!ee)return null;const c=Qe&&ct!==null,f=ct==="up";return V.jsx("div",{className:"aqvs-scroll-to-edge-overlay","data-visible":c,inert:!c,children:f?V.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-top",children:V.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:v=>{v.stopPropagation(),xe.current=!0,mt(0),Le(!1)},children:ce.scrollToTop})}):V.jsx("div",{className:"aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-bottom",children:V.jsx("button",{type:"button",className:"aqvs-scroll-to-edge-button",tabIndex:c?0:-1,onClick:v=>{v.stopPropagation(),xe.current=!0,mt(r-1),Le(!1)},children:ce.scrollToBottom})})})},[ee,Qe,ct,mt,r,ce]),Ct=t.useRef(0),{visibleItems:Dt,renderAnchor:Pt}=t.useMemo(()=>{if(r===0)return{visibleItems:V.jsx("div",{className:"aqvs-no-items-container",children:V.jsx("div",{className:"aqvs-no-items-text",children:ce.noItems})}),renderAnchor:0};const c=We(vt,r),f=We(kt,r),{cumulative:v,currentValue:$}=O.prefixSum(c,{materializeOption:{materialize:!1}}),q=v-$;Number.isFinite(q)&&Math.abs(q-Ct.current)>En&&(Ct.current=q);const B=Ct.current,j=[],we=[];let $e=0,Ne=q;for(let ze=c;ze<=f;ze++){if(we.length>=_r){k.warn("[VirtualScroll] Rendered item count reached the safety cap; truncating render window.",{cap:_r,safeRenderingStartIndex:c,safeRenderingEndIndex:f});break}const ot=s(ze),lt=O.get(ze),dt=ot-lt;dt!==0&&j.push({index:ze,value:ot});const Zt=Ne+$e,ur=n?n(ze):ze;we.push(V.jsx(hs,{index:ze,top:Zt-B,height:ot,item:e(ze),clipItemHeight:Fe,enableKeyboardNavigation:J,onKeyDown:$t,onEscapeKeyDown:Ue?qt:void 0,onFocus:lr,registerItemRef:Ft,children:b},ur)),$e+=dt,Ne+=lt}return j.length>0&&Promise.resolve().then(()=>{if(ue.current)return;let ze=0;for(const dt of j)if(dt.index<At){const Zt=O.get(dt.index);ze+=dt.value-Zt}const ot=O.updates(j);if(ue.current||typeof ot!="number")return;x(ot),k.debug("[VirtualScroll] Updated heights for items",j,"New total height:",ot);const lt=Me.current?.getScrollPosition()??N.current;if(ze!==0){const dt=lt+ze;xt(dt,ze),Ie(dt,{immediate:!0}),k.debug("[VirtualScroll] Adjusted scroll for layout shift (auto update)",{from:lt,to:dt,shiftAmount:ze})}else lt!==N.current&&Ie(lt)}),{visibleItems:we,renderAnchor:B}},[b,Fe,gt,J,r,O,e,n,s,lr,$t,Ue,qt,xt,Ft,kt,vt,ce,Ie,At]),Wt=t.useCallback(c=>{const f=(W??0)>0,v=Math.abs(c-Ke),$=f&&v>.5?Ke:c,q=wt($,w.top);if(k.debug("[VirtualScroll] Rendering visible items",()=>({currentScrollPosition:c,effectiveScrollPosition:q,renderingStartIndex:vt,renderingEndIndex:kt,itemCount:r,viewportSize:Z,callbackThrottleMs:W,diff:v,rawEffectiveScrollPosition:$})),r===0)return Dt;const B=w.top+Pt-$,j=w.bottom>0?V.jsx("div",{className:"aqvs-bottom-inset",style:{top:O.getTotal()-Pt,height:w.bottom}},"virtualscroll-bottom-inset"):null;return k.debug("[VirtualScroll] Rendering items",()=>({containerTop:B,logicalScrollPosition:je,resolvedInsets:w,effectiveScrollPosition:q})),V.jsxs("div",{className:"aqvs-items-wrapper",style:{top:0,transform:`translateY(${B}px)`,willChange:"transform"},children:[Dt,j]})},[W,r,O,je,Pt,kt,vt,w,Ke,Z,Dt]),Ut=t.useMemo(()=>({renderingStartIndex:zt.renderingStartIndex,renderingEndIndex:zt.renderingEndIndex,visibleStartIndex:zt.visibleStartIndex,visibleEndIndex:zt.visibleEndIndex,scrollPosition:je,totalHeight:O.getTotal()}),[zt,je,O,gt]);t.useEffect(()=>{oe.current=Ut},[Ut]);const[Gt,St]=t.useState(""),Kt=t.useRef(U);t.useLayoutEffect(()=>{Kt.current=U},[U]);const yt=U?.debounceMs??400,ht=Number.isFinite(yt)&&yt>=0,tr=U!==void 0;t.useEffect(()=>{tr&&!ht&&k.warn(`[VirtualScroll] liveRegion.debounceMs must be a finite number >= 0, received ${yt}. Announcements are disabled.`)},[tr,ht,yt]),t.useEffect(()=>{if(!(tr&&ht)){St("");return}const c=setTimeout(()=>{const f=Kt.current?.format;if(!f)return;const v=f({visibleStartIndex:At,visibleEndIndex:jt,itemCount:r});St(v)},yt);return()=>clearTimeout(c)},[tr,ht,yt,At,jt,r]),t.useImperativeHandle(K,()=>({getScrollPosition:()=>{const c=Me.current?.getScrollPosition();return typeof c=="number"?wt(c,it.current):-1},getContentSize:()=>Me.current?.getContentSize()??-1,getViewportSize:()=>Me.current?.getViewportSize()??-1,scrollTo:se,scrollBy:De,applyWheel:Be,scrollToIndex:mt,getFenwickTreeTotalHeight:()=>O.getTotal(),getFenwickSize:()=>O.getSize(),focusItemAtIndex:Mt,getRange:()=>oe.current,getScrollAnchor:D,updateItemSize:Lt}),[se,De,Be,mt,O,Mt,D,Lt]);const Yt=O.getTotal()+w.top+w.bottom,cr=V.jsx(In,{ref:Me,contentSize:Yt,viewportSize:i,onViewportSizeChange:ke,className:o,testId:u,onScroll:ut,background:I,tapScrollCircleOptions:_e,inertiaOptions:Ge,overscrollBehavior:pt,itemCount:r,scrollBarWidth:re,enableThumbDrag:he,enableTrackClick:Oe,enableArrowButtons:M,enablePointerDrag:qe,pointerDragInputs:pe,renderThumbOverlay:te,wheelSpeedMultiplier:rt,onWheelHorizontal:F,onPanHorizontal:ae,contentInsets:w,contentProps:z,visibleStartIndex:At,visibleEndIndex:jt,renderOverlay:Et,initialScrollPosition:at.position,locale:Y,labels:H,children:Wt});return tr?V.jsxs(V.Fragment,{children:[cr,V.jsx("div",{className:"aqvs-live-region",role:"status","aria-live":"polite","aria-atomic":"true","data-aqvs-live-region":"",children:Gt})]}):cr},Pn=t.forwardRef(ps),br=262144,pn=3,Nn=32768,Fr=128,Hr=128,Xr=128,$r=128,Vr=10,gs=(r,e)=>Math.max(1,Math.floor((r??Nn)/Math.max(1,e))),bs=(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<_r;)a+=e(u),o+=1,u+=1;return Math.max(1,o+2*i+2)},yr=(r,e,n)=>{if(!(Number.isInteger(r)&&r>=0&&r<=br))throw new RangeError(`[VirtualGrid] ${e==="row"?"getRowHeight":"getColWidth"}(${n}) returned ${r} — must be an integer in [0, ${br}] (0 = hidden). Oversized tracks would pierce the browser layout-coordinate wall (see the design plan §3.1/§6).`);return r},xs=(r,e,n,s,i,a,o,u)=>{const m=Cn(r,e,n,s,i,a,o);if(s===0)return{renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0};const g=Q(m.renderingStartIndex,0,s-1),{cumulative:b,currentValue:I}=a.prefixSum(g,{materializeOption:{materialize:!1}}),y=b-I,S=Number.isFinite(y)&&Math.abs(y-u)>En?y:u;return{renderingColStart:m.renderingStartIndex,renderingColEnd:m.renderingEndIndex,visibleColStart:m.visibleStartIndex,visibleColEnd:m.visibleEndIndex,colAnchor:S}},gn=[],vs=(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 m=u.cumulative-u.currentValue,g=0,b=r;for(;b<=e;){if(a.length>=i)return{columns:a,widthUpdates:o,truncated:e-b+1};const I=n(b),y=s.get(b);if(I!==y&&o.push({index:b,value:I}),I>0){a.push({col:b,left:m,width:I}),m+=y,g=0,b+=1;continue}if(m+=y,g+=1,b+=1,g>gr){const S=s.findIndexAtOrAfter(m+.5,{materializeOption:{materialize:!1}});if(S.index===-1||S.index<=b||!Number.isSafeInteger(S.index))break;const P=s.prefixSum(S.index,{materializeOption:{materialize:!1}});m=P.cumulative-P.currentValue,b=S.index,g=0}}return{columns:a,widthUpdates:o,truncated:0}},Ss=(r,e,n)=>{const s=[],i=[];let a=0;for(let o=0;o<r;o+=1){const u=e(o),m=n.get(o);u!==m&&i.push({index:o,value:u}),u>0&&s.push({col:o,left:a,width:u}),a+=m}return{columns:s,widthUpdates:i,width:a}},ws=(r,e,n,s)=>{const i=[],a=[];let o=0;for(let u=r-e;u<r;u+=1){const m=n(u),g=s.get(u);m!==g&&a.push({index:u,value:m}),m>0&&i.push({col:u,left:o,width:m}),o+=g}return{columns:i,widthUpdates:a,width:o}},Ir=(r,e,n)=>Math.min(r,Math.max(0,n-e)),Rs={renderingColStart:0,renderingColEnd:0,visibleColStart:0,visibleColEnd:0,colAnchor:0,key:"0:0:0"},Ms=({rowCount:r,colCount:e,getRowHeight:n,getColWidth:s,getCell:i,getCellKey:a,children:o,getCellProps:u,getRowProps:m,contentProps:g,background:b,contentInsets:I,onRowFocus:y,frozenLeadingCols:S=0,frozenLeadingRows:P=0,frozenTrailingCols:W=0,frozenTrailingRows:_=0,horizontalKeyInputs:Re,horizontalKeyStep:Te,onScroll:A,onRangeChange:F,onRenderTruncated:ae,callbackThrottleMs:L,initialScrollAnchor:T,overscanRows:z=pn,overscanCols:U=pn,viewportSize:Y,__maxRenderedCells:H,behaviorOptions:K,scrollBarOptions:re,liveRegion:he,locale:Oe,labels:M,className:ee,testId:te},_e)=>{const ce=t.useRef(null),qe=t.useRef(null),pe=t.useRef(n);pe.current=n;const J=t.useRef(s);J.current=s;const Ue=K?.resetOnGetColWidthChange===!0,Ge=K?.resetOnGetItemHeightChange===!0?n:null,pt=Ue?s:null,Fe=t.useCallback(l=>yr(pe.current(l),"row",l),[Ge]),He=t.useCallback(l=>yr(J.current(l),"col",l),[pt]),Ee=K?.defaultColWidth,nt=t.useMemo(()=>{if(Ee!==void 0&&!(Number.isInteger(Ee)&&Ee>=0&&Ee<=br))throw new RangeError(`[VirtualGrid] behaviorOptions.defaultColWidth must be an integer in [0, ${br}], received ${Ee}.`);return{resetOnValueFnChange:Ue,baseValue:Ee}},[Ue,Ee]),Z=Ur(e,He,nt),[ke,Me]=t.useState(0);if(!(Number.isInteger(S)&&S>=0&&S<=Fr))throw new RangeError(`[VirtualGrid] frozenLeadingCols must be an integer in [0, ${Fr}], received ${S}.`);const oe=Math.min(S,e),ge=t.useRef(0);if(!(Number.isInteger(W)&&W>=0&&W<=Xr))throw new RangeError(`[VirtualGrid] frozenTrailingCols must be an integer in [0, ${Xr}], received ${W}.`);const ue=Math.min(W,e-oe),ft=t.useRef(0);if(!(Number.isInteger(P)&&P>=0&&P<=Hr))throw new RangeError(`[VirtualGrid] frozenLeadingRows must be an integer in [0, ${Hr}], received ${P}.`);const w=Math.min(P,r);if(!(Number.isInteger(_)&&_>=0&&_<=$r))throw new RangeError(`[VirtualGrid] frozenTrailingRows must be an integer in [0, ${$r}], received ${_}.`);const Ve=Math.min(_,r-w),de=Math.max(0,r-w-Ve),O=t.useRef(!1),at=t.useRef(0),Ke=t.useRef(0),[Tt,gt]=t.useState(0),{frozenRows:x,frozenHeight:N}=t.useMemo(()=>{if(w===0)return{frozenRows:[],frozenHeight:0};const l=[];let p=0;for(let R=0;R<w;R+=1){const X=Fe(R);X>0&&l.push({row:R,top:p,height:X}),p+=X}return{frozenRows:l,frozenHeight:p}},[w,Tt,Fe]);at.current=N;const[le,G]=t.useState(0),{trailingRows:ne,trailingHeight:fe}=t.useMemo(()=>{if(Ve===0)return{trailingRows:[],trailingHeight:0};const l=[];let p=0;for(let R=r-Ve;R<r;R+=1){const X=Fe(R);X>0&&l.push({row:R,top:p,height:X}),p+=X}return{trailingRows:l,trailingHeight:p}},[Ve,r,le,Fe]);Ke.current=fe;const Ye=t.useCallback(l=>Fe(l+w),[Fe,w]),be=t.useRef(y);be.current=y;const Xe=y!==void 0,Se=t.useMemo(()=>Xe?l=>be.current?.(l+w):void 0,[w,Xe]),Ae=N,ct=fe,[Ze,Qe]=t.useState(w),Le=t.useRef(null),st=t.useRef(!1);if(Ze!==w){Qe(w),st.current=!0;const l=ce.current?.getScrollAnchor()??null;Le.current=l===null?null:{row:l.index+Ze,offsetPx:l.offsetPx}}const xe=t.useRef(0),me=t.useRef(0),bt=t.useRef(!1),[h,C]=t.useState(Rs),ye=t.useRef(h);ye.current=h;const Je=t.useRef(0),[Ce,Rt]=t.useState(()=>Z.getTotal()??0),et=t.useRef(Ce);et.current=Ce;const it=t.useCallback(l=>{typeof l=="number"&&Number.isFinite(l)&&(et.current=l,Rt(l))},[]);t.useLayoutEffect(()=>{const l=Z.getTotal();typeof l=="number"&&Number.isFinite(l)&&l!==et.current&&it(l)});const Pe=re?.width??12,Ft=Y===void 0?null:{width:Math.max(0,Math.round(Y.width)-Pe),height:Math.max(0,Math.round(Y.height)-Pe)},[nr,Ht]=t.useState({width:0,height:0}),ve=Ft??nr,Nt=t.useRef(ve);Nt.current=ve;const Bt=ve.height>0&&ve.height-N-fe<=0;O.current=Bt;const er=Ft!==null;t.useLayoutEffect(()=>{if(er)return;const l=qe.current;if(l===null)return;const p=()=>{const X=Math.max(0,Math.round(l.clientWidth)-Pe),ie=Math.max(0,Math.round(l.clientHeight)-Pe);Ht(tt=>tt.width===X&&tt.height===ie?tt:{width:X,height:ie})};p();const R=new ResizeObserver(p);return R.observe(l),()=>R.disconnect()},[Pe,er]);const Ie=t.useCallback(()=>{const l=qe.current;l!==null&&l.style.setProperty("--aqvs-grid-hx-residual",`${Je.current-xe.current}px`)},[]),xt=t.useCallback(()=>Math.max(0,Nt.current.width-ge.current-ft.current),[]),Xt=t.useCallback(()=>Math.max(0,et.current-ge.current-ft.current-xt()),[xt]),Lt=t.useCallback(()=>{const l=xt(),p=xs(ge.current+xe.current,l,U,e,He,Z,et.current,ye.current.colAnchor);if(oe>0&&(p.renderingColStart=Math.max(p.renderingColStart,oe),p.visibleColStart=Math.max(p.visibleColStart,oe)),ue>0){const X=e-ue-1;p.renderingColEnd=Math.min(p.renderingColEnd,X),p.visibleColEnd=Math.min(p.visibleColEnd,X)}(oe>0||ue>0)&&(l<=0||p.renderingColStart>p.renderingColEnd)&&(p.renderingColStart=e,p.renderingColEnd=e-1,p.visibleColStart=e,p.visibleColEnd=e-1);const R=`${p.renderingColStart}:${p.renderingColEnd}:${p.colAnchor}`;R!==ye.current.key&&C({...p,key:R})},[U,e,He,Z,oe,ue,xt]),[mt,d]=t.useState(0),E=t.useRef(null),D=t.useCallback(()=>{E.current===null&&(E.current=requestAnimationFrame(()=>{E.current=null,d(xe.current)}))},[]);t.useEffect(()=>()=>{E.current!==null&&cancelAnimationFrame(E.current)},[]);const se=t.useRef(A);se.current=A;const De=t.useRef(F);De.current=F;const Be=t.useRef(ae);Be.current=ae;const ut=t.useRef(null),[je,zt]=t.useState(null),[vt,kt]=t.useState(ve.height);vt!==ve.height&&(kt(ve.height),zt(null));const At=T===void 0||r===0?0:Q(Math.trunc(T.row),0,r-1),jt=t.useMemo(()=>{const l=ut.current?.renderingStartIndex??At;return bs(Math.max(0,ve.height-at.current-Ke.current),Fe,r,l,z)},[ve.height,Fe,r,At,z,Ae,ct]),Mt=je??jt,$t=t.useCallback(()=>{const l=ut.current;if(l===null)return null;const p=ye.current;return{renderingRowStart:l.renderingStartIndex,renderingRowEnd:l.renderingEndIndex,visibleRowStart:l.visibleStartIndex,visibleRowEnd:l.visibleEndIndex,renderingColStart:p.renderingColStart,renderingColEnd:p.renderingColEnd,visibleColStart:p.visibleColStart,visibleColEnd:p.visibleColEnd,scrollX:xe.current,scrollY:me.current,totalWidth:et.current,totalHeight:l.totalHeight+at.current+Ke.current}},[]),qt=t.useCallback(()=>{const l=$t();l!==null&&De.current?.(l)},[$t]),lr=t.useCallback(l=>{const p=Xt(),R=Q(l,0,p);return R!==xe.current&&(xe.current=R,Ie(),Lt(),D(),se.current?.({x:R,y:me.current})),R},[Ie,Lt,D,Xt]),Et=t.useRef(lr);Et.current=lr,t.useLayoutEffect(()=>{Je.current=h.colAnchor,Ie(),qt()},[h,Ie,qt]),t.useLayoutEffect(()=>{ut.current!==null&&qt()},[N,fe,qt]);const Ct=t.useRef(null),Dt=t.useCallback(l=>{const p=Q(l.col,0,Math.max(0,e-1)),R=Z.prefixSum(p,{materializeOption:{materialize:!1}}),X=R.cumulative-R.currentValue,ie=R.currentValue,tt=xt();return(l.alignX==="end"?X+ie-ge.current-tt:l.alignX==="center"?X+ie/2-ge.current-tt/2:X-ge.current)+l.offsetX},[Z,e,xt]),Pt=t.useRef(null),Wt=t.useCallback(()=>{const l=Pt.current;Pt.current=null,!(l===null||l.length===0)&&(it(Z.updates(l)),Me(p=>p+1))},[Z,it]),Ut=t.useRef({count:0,warned:!1}),{frozenColumns:Gt,frozenWidth:St}=t.useMemo(()=>{if(oe===0)return Ut.current.count=0,Ut.current.warned=!1,{frozenColumns:gn,frozenWidth:0};const{columns:l,widthUpdates:p,width:R}=Ss(oe,He,Z);if(p.length>0){const X=Ut.current;X.count>=Vr?X.warned||(X.warned=!0,k.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:oe,pendingUpdates:p.length})):(X.count+=1,Pt.current=[...Pt.current??[],...p],Promise.resolve().then(Wt))}else Ut.current.count=0,Ut.current.warned=!1;return{frozenColumns:l,frozenWidth:R}},[oe,ke,He,Z,Wt]);ge.current=St,t.useLayoutEffect(()=>{oe>0?qe.current?.style.setProperty("--aqvs-grid-frozen-width",`${St}px`):qe.current?.style.removeProperty("--aqvs-grid-frozen-width")},[St,oe]);const Kt=t.useRef({count:0,warned:!1}),{trailingColumns:yt,trailingWidth:ht}=t.useMemo(()=>{if(ue===0)return Kt.current.count=0,Kt.current.warned=!1,{trailingColumns:gn,trailingWidth:0};const{columns:l,widthUpdates:p,width:R}=ws(e,ue,He,Z);if(p.length>0){const X=Kt.current;X.count>=Vr?X.warned||(X.warned=!0,k.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:ue,pendingUpdates:p.length})):(X.count+=1,Pt.current=[...Pt.current??[],...p],Promise.resolve().then(Wt))}else Kt.current.count=0,Kt.current.warned=!1;return{trailingColumns:l,trailingWidth:R}},[ue,e,ke,He,Z,Wt]);ft.current=ht,t.useLayoutEffect(()=>{ue>0?qe.current?.style.setProperty("--aqvs-grid-trailing-width",`${ht}px`):qe.current?.style.removeProperty("--aqvs-grid-trailing-width")},[ht,ue]);const tr=t.useMemo(()=>({...re,tapScrollCircleOptions:{...re?.tapScrollCircleOptions,enabled:!1}}),[re]),Yt=re?.tapScrollCircleOptions,cr=typeof Yt?.maxSpeedMultiplier=="number",c=t.useMemo(()=>({...Yt,offsetX:Yt?.offsetX===void 0?dn:Yt.offsetX,offsetY:Yt?.offsetY===void 0?dn:Yt.offsetY}),[Yt]),f=t.useMemo(()=>Or(c,Math.max(0,e-oe-ue)),[c,e,oe,ue]),v=t.useMemo(()=>Or(c,de),[c,de]),$=f.enabled,q=Math.max(f.maxVisualDistance,1),B={viewportSize:Math.max(0,ve.width-St-ht),minSpeedMultiplier:f.minSpeedMultiplier,maxSpeedMultiplier:f.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:cr,curve:f.maxSpeedCurve},j={viewportSize:Math.max(0,ve.height-N-fe),minSpeedMultiplier:v.minSpeedMultiplier,maxSpeedMultiplier:v.maxSpeedMultiplier,hasCustomMaxSpeedMultiplier:cr,curve:v.maxSpeedCurve},we=t.useCallback(()=>xe.current,[]),$e=t.useCallback(()=>{const l=ce.current;if(l===null)return me.current;const p=l.getScrollPosition();return p<0?me.current:p},[]),Ne=t.useCallback(()=>{const l=ce.current;return l===null?0:Math.max(0,Math.max(0,l.getContentSize())-Math.max(0,l.getViewportSize()))},[]),ze=t.useCallback(l=>{const p=ce.current;if(p===null)return me.current;const R=p.scrollBy(l);return me.current=R,R},[]),ot=Xt()>0||Ne()>0,lt=`${Ce}:${St}:${ht}:${ve.width}:${h.key}`,dt=`${r}:${je??-1}:${N}:${fe}:${ve.height}`,{isTapActive:Zt,handleTapCircleDragChange:ur,tapCircleHandleRef:zn}=ds({enabled:$&&ot,maxDistance:q,xSpeedParams:B,ySpeedParams:j,applyHxRef:Et,getHx:we,getMaxHx:Xt,applyVy:ze,getVy:$e,getMaxVy:Ne,pendingColAnchorRef:Ct,xExtentFreshness:lt,yExtentFreshness:dt}),kn=t.useMemo(()=>Q((Zt?1:.8)*f.opacity,0,1),[Zt,f.opacity]);t.useLayoutEffect(()=>{const l=Ct.current;l===null?Et.current(xe.current):Et.current(Dt(l)),Lt()},[ve.width,Ce,ke,St,ht,Lt,Dt]);const Gr=t.useRef(!1);t.useLayoutEffect(()=>{if(Gr.current||T===void 0||e===0)return;Gr.current=!0;const l=Q(Math.trunc(T.col),0,e-1);if(l<oe||l>=e-ue)return;const p={col:l,alignX:"start",offsetX:Math.max(0,T.offsetX)};Ct.current=p,Et.current(Dt(p))},[T,e,Dt,oe,ue]);const An=t.useCallback(l=>{me.current=l,bt.current=!0,se.current?.({x:xe.current,y:l})},[]),Kr=t.useCallback(l=>{if(de===0||O.current)ut.current={renderingStartIndex:r,renderingEndIndex:r-1,visibleStartIndex:r,visibleEndIndex:r-1,scrollPosition:0,totalHeight:de===0?0:l.totalHeight},me.current=0;else{const p=w;ut.current={renderingStartIndex:l.renderingStartIndex+p,renderingEndIndex:l.renderingEndIndex+p,visibleStartIndex:l.visibleStartIndex+p,visibleEndIndex:l.visibleEndIndex+p,scrollPosition:l.scrollPosition,totalHeight:l.totalHeight},me.current=l.scrollPosition}zt(p=>{const R=Math.max(1,l.renderingEndIndex-l.renderingStartIndex+1);return R===p?p:R}),qt()},[qt,w,de,r]),Zr=t.useCallback(l=>{Ct.current=null,Et.current(xe.current+l)},[]),Qr=gs(H,Mt+x.length+ne.length),Cr=t.useRef({count:0,warned:!1}),{placedColumns:xr,truncatedCols:vr}=t.useMemo(()=>{const l=Math.max(0,ve.width-St-ht);if(e===0||l<=0)return{placedColumns:[],truncatedCols:0};if(h.renderingColStart>h.renderingColEnd)return{placedColumns:[],truncatedCols:0};const p=Math.max(1,Qr-Gt.length-yt.length),{columns:R,widthUpdates:X,truncated:ie}=vs(Q(h.renderingColStart,0,e-1),Q(h.renderingColEnd,0,e-1),He,Z,p);if(X.length>0){const tt=Cr.current;tt.count>=Vr?tt.warned||(tt.warned=!0,k.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:h.key,pendingUpdates:X.length})):(tt.count+=1,Pt.current=[...Pt.current??[],...X],Promise.resolve().then(Wt))}else Cr.current.count=0,Cr.current.warned=!1;return{placedColumns:R,truncatedCols:ie}},[h,e,ve.width,St,ht,Gt.length,yt.length,ke,He,Z,Qr,Wt]),Jr=t.useRef("");t.useEffect(()=>{if(vr>0){const l=`${h.key}:${vr}`;l!==Jr.current&&(Jr.current=l,Be.current?.({renderedCells:(xr.length+Gt.length+yt.length)*(Mt+x.length+ne.length),droppedCols:vr}))}},[vr,h.key,xr.length,Gt.length,yt.length,Mt,x.length,ne.length]);const en=h.colAnchor,Pr=t.useCallback(l=>{const p=m?.(l),R=Fe(l)===0,X=R?null:xr.map(({col:ie,left:tt,width:ir})=>{const Vt=u?.(l,ie),dr={...Vt?.style,left:tt-en,width:ir};return t.createElement("div",{...Vt,key:a?a(l,ie):ie,className:It.twMerge("aqvs-grid-cell",Vt?.className),style:dr},o(i(l,ie),l,ie))});return oe===0&&ue===0?V.jsx("div",{...p,className:It.twMerge("aqvs-grid-row",p?.className),style:p?.style,children:X}):V.jsxs("div",{...p,"data-aqvs-frozen-row":oe>0?"":void 0,className:It.twMerge("aqvs-grid-row aqvs-grid-row-frozen-host",p?.className),style:p?.style,children:[R?null:Gt.map(({col:ie,left:tt,width:ir})=>{const Vt=u?.(l,ie),dr={...Vt?.style,left:tt,width:ir};return t.createElement("div",{...Vt,"data-aqvs-frozen-cell":"",key:a?a(l,ie):ie,className:It.twMerge("aqvs-grid-cell",Vt?.className),style:dr},o(i(l,ie),l,ie))}),R?null:V.jsx("div",{className:"aqvs-grid-row-scroll",children:V.jsx("div",{className:"aqvs-grid-row-scroll-inner",children:X})}),R||ue===0?null:V.jsx("div",{className:"aqvs-grid-row-trailing",children:V.jsx("div",{className:"aqvs-grid-row-trailing-inner",children:yt.map(({col:ie,left:tt,width:ir})=>{const Vt=u?.(l,ie),dr={...Vt?.style,left:tt,width:ir};return t.createElement("div",{...Vt,"data-aqvs-trailing-cell":"",key:a?a(l,ie):ie,className:It.twMerge("aqvs-grid-cell",Vt?.className),style:dr},o(i(l,ie),l,ie))})})})]})},[xr,Gt,yt,oe,ue,en,m,u,a,i,o,Fe]),[Vn,Ln]=t.useState(""),sr=t.useRef(null),tn=t.useRef(he);tn.current=he;const Sr=t.useCallback(()=>{const l=tn.current;if(l===void 0)return;const p=l.debounceMs??400;Number.isFinite(p)&&p>=0&&(sr.current!==null&&window.clearTimeout(sr.current),sr.current=window.setTimeout(()=>{sr.current=null;const R=$t();R!==null&&Ln(X=>{const ie=l.buildMessage(R);return ie===X?X:ie})},p))},[$t]),wr=he?.debounceMs??400,rn=Number.isFinite(wr)&&wr>=0,nn=he!==void 0;t.useEffect(()=>{nn&&!rn&&k.warn(`[VirtualGrid] liveRegion.debounceMs must be a finite number >= 0, received ${wr}. Announcements are disabled.`)},[nn,rn,wr]),t.useEffect(()=>()=>{sr.current!==null&&window.clearTimeout(sr.current)},[]),t.useEffect(()=>{Sr()},[h,Sr]);const Dn=t.useCallback(l=>{Kr(l),Sr()},[Kr,Sr]);return t.useImperativeHandle(_e,()=>({scrollTo:l=>{const p=ce.current;let R=me.current;l.y!==void 0&&p!==null&&(p.scrollTo(l.y),R=p.getScrollPosition(),me.current=R);let X=xe.current;return l.x!==void 0&&(Ct.current=null,X=Et.current(l.x)),{x:X,y:R}},scrollBy:l=>{const p=ce.current;let R=me.current;l.y!==void 0&&l.y!==0&&p!==null&&(R=p.scrollBy(l.y),me.current=R);let X=xe.current;return l.x!==void 0&&l.x!==0&&(Ct.current=null,X=Et.current(xe.current+l.x)),{x:X,y:R}},scrollToCell:(l,p,R)=>{const X=ce.current;if(X!==null&&r>0){const ie=Q(Math.trunc(l),0,r-1);ie>=w&&ie<r-Ve&&X.scrollToIndex(ie-w,{align:R?.alignY??"top",offset:R?.offsetY})}if(e>0){const ie=Q(Math.trunc(p),0,e-1);if(ie>=oe&&ie<e-ue){const tt={col:ie,alignX:R?.alignX??"start",offsetX:R?.offsetX??0};Ct.current=tt,Et.current(Dt(tt))}}},getScrollPosition:()=>bt.current||ce.current!==null?{x:xe.current,y:ce.current?.getScrollPosition()??me.current}:{x:-1,y:-1},getScrollAnchor:()=>{if(r===0||e===0)return null;const l=ce.current?.getScrollAnchor()??null;if(l===null)return null;const p=ge.current+xe.current,R=Z.findIndexAtOrAfter(p,{materializeOption:{materialize:!1}});if(R.index===-1)return{row:l.index+w,col:e-1,offsetX:0,offsetY:l.offsetPx};if(R.cumulative===p)return{row:l.index+w,col:Q(R.index+1,0,e-1),offsetX:0,offsetY:l.offsetPx};const X=(R.cumulative??0)-(R.currentValue??0);return{row:l.index+w,col:R.index,offsetX:Math.max(0,p-X),offsetY:l.offsetPx}},getViewportSize:()=>({width:Nt.current.width,height:Nt.current.height}),getContentSize:()=>({width:et.current,height:ce.current===null?0:at.current+Ke.current+Math.max(0,ce.current.getContentSize())}),getRange:$t,updateRowSize:(l,p)=>{yr(p,"row",l),Math.trunc(l)<w?gt(R=>R+1):Ve>0&&Math.trunc(l)>=r-Ve?G(R=>R+1):ce.current?.updateItemSize(Math.trunc(l)-w,p)},updateColSize:(l,p)=>{yr(p,"col",l),it(Z.update(Q(Math.trunc(l),0,Math.max(0,e-1)),p)),Me(R=>R+1)},getFrozenSize:()=>({cols:oe,width:ge.current,rows:w,height:at.current,trailingCols:ue,trailingRows:Ve,trailingWidth:ft.current,trailingHeight:Ke.current,trailingVisibleWidth:Ir(ft.current,ge.current,Nt.current.width),trailingVisibleHeight:Ir(Ke.current,at.current,Nt.current.height)}),applyWheel:l=>ce.current?.applyWheel(l)??!1,focusRowAtIndex:(l,p)=>{const R=Math.trunc(l);R<w?qe.current?.querySelector(`[data-aqvs-frozen-band-row="${R}"]`)?.focus():Ve>0&&R>=r-Ve?qe.current?.querySelector(`[data-aqvs-trailing-band-row="${R}"]`)?.focus():ce.current?.focusItemAtIndex(R-w,p)}}),[r,e,Z,$t,it,Dt,oe,w,ue,Ve]),V.jsxs("div",{ref:qe,className:It.twMerge("aqvs-grid",w>0?"aqvs-grid-has-frozen-rows":"",Ve>0?"aqvs-grid-has-trailing-rows":"",ee),"data-testid":te,children:[w>0?V.jsx("div",{className:"aqvs-grid-frozen-rows",style:{height:N},"data-testid":te?`${te}-frozen-rows`:void 0,children:x.map(({row:l,top:p,height:R})=>V.jsx("div",{"data-aqvs-frozen-band-row":l,className:"aqvs-grid-frozen-band-row",style:{top:p,height:R,right:Pe},tabIndex:-1,onFocus:()=>y?.(l),children:Pr(l)},l))}):null,V.jsx("div",{className:"aqvs-grid-main","data-testid":te?`${te}-main`:void 0,children:V.jsx(Pn,{ref:ce,itemCount:Bt?0:de,getItem:l=>l+w,getItemKey:l=>l+w,getItemHeight:Ye,overscanCount:z,viewportSize:ve.height>0?Math.max(0,ve.height-N-fe):void 0,callbackThrottleMs:L,behaviorOptions:K,scrollBarOptions:tr,contentProps:g,background:b,contentInsets:I,onItemFocus:Se,horizontalKeyInputs:Re,horizontalKeyStep:Te,initialScrollAnchor:st.current?Le.current!==null&&Le.current.row>=w&&de>0?{index:Le.current.row-w,offsetPx:Le.current.offsetPx}:void 0:T!==void 0&&de>0&&Math.trunc(T.row)>=w&&Math.trunc(T.row)<r-Ve?{index:Math.trunc(T.row)-w,offsetPx:T.offsetY}:void 0,onScroll:An,onRangeChange:Dn,onWheelHorizontal:Zr,onPanHorizontal:Zr,locale:Oe,labels:M,testId:te?`${te}-rows`:void 0,children:Pr},w)}),Ve>0?V.jsx("div",{className:"aqvs-grid-trailing-rows",style:{height:Ir(fe,N,ve.height)},"data-testid":te?`${te}-trailing-rows`:void 0,children:V.jsx("div",{className:"aqvs-grid-trailing-rows-inner",style:{height:fe},children:ne.map(({row:l,top:p,height:R})=>V.jsx("div",{"data-aqvs-trailing-band-row":l,className:"aqvs-grid-trailing-band-row",style:{top:p,height:R,right:Pe},tabIndex:-1,onFocus:()=>y?.(l),children:Pr(l)},l))})}):null,V.jsx("div",{className:"aqvs-grid-hbar-strip",style:{height:Pe,paddingRight:ue>0?Pe+Ir(ht,St,ve.width):Pe},"data-testid":te?`${te}-hbar`:void 0,children:V.jsx(Wr,{horizontal:!0,contentSize:Math.max(0,Ce-St-ht),viewportSize:Math.max(0,ve.width-St-ht),scrollPosition:mt,itemCount:Math.max(0,e-oe-ue),tapScrollCircleOptions:re?.tapScrollCircleOptions,onScroll:(l,p)=>(Ct.current=null,Et.current(typeof l=="function"?l(p??xe.current):l)),scrollBarWidth:Pe,locale:Oe,labels:M})}),$&&ot&&V.jsx("div",{className:"aqvs-grid-tap-circle-wrapper","data-aqvs-grid-tap-circle":"",style:{left:`min(calc(100% - ${Pe+f.size}px), max(calc(100% - ${Pe}px + ${f.offsetX}px), calc(75% - ${f.size/2}px)))`,top:`min(calc(100% - ${Pe+f.size}px), max(calc(100% - ${Pe}px + ${f.offsetY}px), calc(75% - ${f.size/2}px)))`},children:V.jsx(Br,{axis:"xy",ref:zn,className:It.twMerge("aqvs-grid-tap-circle",f.className),size:f.size,maxVisualDistance:q,opacity:kn,renderVisual:f.renderVisual,onDragChange:ur})}),he!==void 0?V.jsx("div",{className:"aqvs-grid-live-region","aria-live":"polite","data-testid":te?`${te}-live`:void 0,children:Vn}):null]})},ys=t.forwardRef(Ms);exports.FenwickMapTree=_t;exports.MAX_FROZEN_LEADING_COLS=Fr;exports.MAX_FROZEN_LEADING_ROWS=Hr;exports.MAX_FROZEN_TRAILING_COLS=Xr;exports.MAX_FROZEN_TRAILING_ROWS=$r;exports.MAX_RENDERED_CELLS=Nn;exports.MAX_TRACK_SIZE=br;exports.ScrollBar=Wr;exports.ScrollPane=In;exports.TAP_SCROLL_SPEED_DEFAULTS=jr;exports.VIRTUAL_SCROLL_LABEL_CATALOGS=bn;exports.VIRTUAL_SCROLL_LABEL_KEYS=Tr;exports.VIRTUAL_SCROLL_LOCALES=qr;exports.VirtualGrid=ys;exports.VirtualScroll=Pn;exports.computeAutoTapScrollMaxSpeedMultiplier=Rn;exports.computeTapScrollSpeed=Er;exports.computeTapScrollVelocity=Mn;exports.createResidualQuantizer=Qn;exports.minmax=Q;exports.resolveVirtualScrollLabels=Yr;exports.resolveVirtualScrollLocale=xn;exports.tapScrollCircleSampleVisual=ss;exports.useFenwickMapTree=Ur;exports.useHeightCache=cs;exports.useLruCache=Tn;exports.useWheelBridge=us;
|