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