@aiquants/virtualscroll 3.10.0 → 3.11.0

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