import{ak as D,r as O}from"./typeof-CmqLOq-M.js";var E={exports:{}},d={};/** * @license React * react-dom.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var _;function A(){if(_)return d;_=1;var a=D();function h(o){var n="https://react.dev/errors/"+o;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(h){console.error(h)}}return a(),E.exports=A(),E.exports}var P=k();function y(a,h,e){let t=e.initialDeps??[],s;function i(){var r,l,o,n;let c;e.key&&((r=e.debug)!=null&&r.call(e))&&(c=Date.now());const u=a();if(!(u.length!==t.length||u.some((p,g)=>t[g]!==p)))return s;t=u;let m;if(e.key&&((l=e.debug)!=null&&l.call(e))&&(m=Date.now()),s=h(...u),e.key&&((o=e.debug)!=null&&o.call(e))){const p=Math.round((Date.now()-c)*100)/100,g=Math.round((Date.now()-m)*100)/100,b=g/16,S=(v,R)=>{for(v=String(v);v.length{t=r},i}function M(a,h){if(a===void 0)throw new Error("Unexpected undefined");return a}const F=(a,h)=>Math.abs(a-h)<=1,L=(a,h,e)=>{let t;return function(...s){a.clearTimeout(t),t=a.setTimeout(()=>h.apply(this,s),e)}},T=a=>{const{offsetWidth:h,offsetHeight:e}=a;return{width:h,height:e}},N=a=>a,W=a=>{const h=Math.max(a.startIndex-a.overscan,0),e=Math.min(a.endIndex+a.overscan,a.count-1),t=[];for(let s=h;s<=e;s++)t.push(s);return t},j=(a,h)=>{const e=a.scrollElement;if(!e)return;const t=a.targetWindow;if(!t)return;const s=r=>{const{width:l,height:o}=r;h({width:Math.round(l),height:Math.round(o)})};if(s(T(e)),!t.ResizeObserver)return()=>{};const i=new t.ResizeObserver(r=>{const l=()=>{const o=r[0];if(o!=null&&o.borderBoxSize){const n=o.borderBoxSize[0];if(n){s({width:n.inlineSize,height:n.blockSize});return}}s(T(e))};a.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(e,{box:"border-box"}),()=>{i.unobserve(e)}},I={passive:!0},w=typeof window>"u"?!0:"onscrollend"in window,U=(a,h)=>{const e=a.scrollElement;if(!e)return;const t=a.targetWindow;if(!t)return;let s=0;const i=a.options.useScrollendEvent&&w?()=>{}:L(t,()=>{h(s,!1)},a.options.isScrollingResetDelay),r=c=>()=>{const{horizontal:u,isRtl:f}=a.options;s=u?e.scrollLeft*(f&&-1||1):e.scrollTop,i(),h(s,c)},l=r(!0),o=r(!1);o(),e.addEventListener("scroll",l,I);const n=a.options.useScrollendEvent&&w;return n&&e.addEventListener("scrollend",o,I),()=>{e.removeEventListener("scroll",l),n&&e.removeEventListener("scrollend",o)}},B=(a,h,e)=>{if(h!=null&&h.borderBoxSize){const t=h.borderBoxSize[0];if(t)return Math.round(t[e.options.horizontal?"inlineSize":"blockSize"])}return a[e.options.horizontal?"offsetWidth":"offsetHeight"]},H=(a,{adjustments:h=0,behavior:e},t)=>{var s,i;const r=a+h;(i=(s=t.scrollElement)==null?void 0:s.scrollTo)==null||i.call(s,{[t.options.horizontal?"left":"top"]:r,behavior:e})};class V{constructor(h){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let e=null;const t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(s=>{s.forEach(i=>{const r=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()})}));return{disconnect:()=>{var s;(s=t())==null||s.disconnect(),e=null},observe:s=>{var i;return(i=t())==null?void 0:i.observe(s,{box:"border-box"})},unobserve:s=>{var i;return(i=t())==null?void 0:i.unobserve(s)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,s])=>{typeof s>"u"&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:N,rangeExtractor:W,onChange:()=>{},measureElement:B,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,s;(s=(t=this.options).onChange)==null||s.call(t,this,e)},this.maybeNotify=y(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t){this.maybeNotify();return}this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((e=this.scrollElement)==null?void 0:e.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{const s=new Map,i=new Map;for(let r=t-1;r>=0;r--){const l=e[r];if(s.has(l.lane))continue;const o=i.get(l.lane);if(o==null||l.end>o.end?i.set(l.lane,l):l.endr.end===l.end?r.index-l.index:r.end-l.end)[0]:void 0},this.getMeasurementOptions=y(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(e,t,s,i,r)=>(this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:s,getItemKey:i,enabled:r}),{key:!1}),this.getMeasurements=y(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:s,getItemKey:i,enabled:r},l)=>{if(!r)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(c=>{this.itemSizeCache.set(c.key,c.size)}));const o=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const n=this.measurementsCache.slice(0,o);for(let c=o;cthis.options.debug}),this.calculateRange=y(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,s,i)=>this.range=e.length>0&&t>0?q({measurements:e,outerSize:t,scrollOffset:s,lanes:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=y(()=>{let e=null,t=null;const s=this.calculateRange();return s&&(e=s.startIndex,t=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,s,i,r)=>i===null||r===null?[]:e({startIndex:i,endIndex:r,overscan:t,count:s}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{const t=this.options.indexAttribute,s=e.getAttribute(t);return s?parseInt(s,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this._measureElement=(e,t)=>{const s=this.indexFromElement(e),i=this.measurementsCache[s];if(!i)return;const r=i.key,l=this.elementsCache.get(r);l!==e&&(l&&this.observer.unobserve(l),this.observer.observe(e),this.elementsCache.set(r,e)),e.isConnected&&this.resizeItem(s,this.options.measureElement(e,t,this))},this.resizeItem=(e,t)=>{const s=this.measurementsCache[e];if(!s)return;const i=this.itemSizeCache.get(s.key)??s.size,r=t-i;r!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(s,r,this):s.start{if(!e){this.elementsCache.forEach((t,s)=>{t.isConnected||(this.observer.unobserve(t),this.elementsCache.delete(s))});return}this._measureElement(e,void 0)},this.getVirtualItems=y(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{const s=[];for(let i=0,r=e.length;ithis.options.debug}),this.getVirtualItemForOffset=e=>{const t=this.getMeasurements();if(t.length!==0)return M(t[C(0,t.length-1,s=>M(t[s]).start,e)])},this.getOffsetForAlignment=(e,t,s=0)=>{const i=this.getSize(),r=this.getScrollOffset();t==="auto"&&(t=e>=r+i?"end":"start"),t==="center"?e+=(s-i)/2:t==="end"&&(e-=i);const l=this.getTotalSize()-i;return Math.max(Math.min(l,e),0)},this.getOffsetForIndex=(e,t="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const s=this.measurementsCache[e];if(!s)return;const i=this.getSize(),r=this.getScrollOffset();if(t==="auto")if(s.end>=r+i-this.options.scrollPaddingEnd)t="end";else if(s.start<=r+this.options.scrollPaddingStart)t="start";else return[r,t];const l=t==="end"?s.end+this.options.scrollPaddingEnd:s.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,t,s.size),t]},this.isDynamicMode=()=>this.elementsCache.size>0,this.cancelScrollToIndex=()=>{this.scrollToIndexTimeoutId!==null&&this.targetWindow&&(this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId),this.scrollToIndexTimeoutId=null)},this.scrollToOffset=(e,{align:t="start",behavior:s}={})=>{this.cancelScrollToIndex(),s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(e,t),{adjustments:void 0,behavior:s})},this.scrollToIndex=(e,{align:t="auto",behavior:s}={})=>{e=Math.max(0,Math.min(e,this.options.count-1)),this.cancelScrollToIndex(),s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");const i=this.getOffsetForIndex(e,t);if(!i)return;const[r,l]=i;this._scrollToOffset(r,{adjustments:void 0,behavior:s}),s!=="smooth"&&this.isDynamicMode()&&this.targetWindow&&(this.scrollToIndexTimeoutId=this.targetWindow.setTimeout(()=>{if(this.scrollToIndexTimeoutId=null,this.elementsCache.has(this.options.getItemKey(e))){const n=this.getOffsetForIndex(e,l);if(!n)return;const[c]=n,u=this.getScrollOffset();F(c,u)||this.scrollToIndex(e,{align:l,behavior:s})}else this.scrollToIndex(e,{align:l,behavior:s})}))},this.scrollBy=(e,{behavior:t}={})=>{this.cancelScrollToIndex(),t==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+e,{adjustments:void 0,behavior:t})},this.getTotalSize=()=>{var e;const t=this.getMeasurements();let s;if(t.length===0)s=this.options.paddingStart;else if(this.options.lanes===1)s=((e=t[t.length-1])==null?void 0:e.end)??0;else{const i=Array(this.options.lanes).fill(null);let r=t.length-1;for(;r>=0&&i.some(l=>l===null);){const l=t[r];i[l.lane]===null&&(i[l.lane]=l.end),r--}s=Math.max(...i.filter(l=>l!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:s})=>{this.options.scrollToFn(e,{behavior:s,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(h)}}const C=(a,h,e,t)=>{for(;a<=h;){const s=(a+h)/2|0,i=e(s);if(it)h=s-1;else return s}return a>0?a-1:0};function q({measurements:a,outerSize:h,scrollOffset:e,lanes:t}){const s=a.length-1,i=o=>a[o].start;if(a.length<=t)return{startIndex:0,endIndex:s};let r=C(0,s,i,e),l=r;if(t===1)for(;l1){const o=Array(t).fill(0);for(;lc=0&&n.some(c=>c>=e);){const c=a[r];n[c.lane]=c.start,r--}r=Math.max(0,r-r%t),l=Math.min(s,l+(t-1-l%t))}return{startIndex:r,endIndex:l}}const z=typeof document<"u"?O.useLayoutEffect:O.useEffect;function $(a){const h=O.useReducer(()=>({}),{})[1],e={...a,onChange:(s,i)=>{var r;i?P.flushSync(h):h(),(r=a.onChange)==null||r.call(a,s,i)}},[t]=O.useState(()=>new V(e));return t.setOptions(e),z(()=>t._didMount(),[]),z(()=>t._willUpdate()),t}function G(a){return $({observeElementRect:j,observeElementOffset:U,scrollToFn:H,...a})}export{k as a,P as r,G as u};