vue-virtual-flow 0.0.1 → 0.0.3

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/README.md CHANGED
@@ -629,6 +629,10 @@ five slides are normally mounted in the middle of the collection.
629
629
  | `hasMore` | `boolean` | `false` | Indicates that another page can be loaded. |
630
630
  | `loading` | `boolean` | `false` | Prevents duplicate `load-more` requests. |
631
631
  | `loadMoreThreshold` | `number` | `2` | Remaining slides after the visible group that trigger `load-more`. |
632
+ | `autoplay` | `boolean` | `false` | Enables automatic slide progression. |
633
+ | `autoplayDelay` | `number` | `3000` | Delay in milliseconds between automatic transitions; values below `1` are clamped and non-finite values use the default. |
634
+ | `autoplayLoop` | `boolean` | `true` | Returns to the first slide when reaching the end. |
635
+ | `pauseOnHover` | `boolean` | `true` | Pauses autoplay when the carousel is hovered. |
632
636
 
633
637
  #### Slots and events
634
638
 
@@ -649,10 +653,48 @@ five slides are normally mounted in the middle of the collection.
649
653
  | `next(behavior?)` | Advances by `slidesToScroll`; defaults to smooth scrolling. |
650
654
  | `previous(behavior?)` | Moves back by `slidesToScroll`. |
651
655
  | `scrollToIndex(index, options?)` | Makes the index the first visible slide. |
656
+ | `startAutoplay()` | Starts or restarts automatic slide progression. |
657
+ | `stopAutoplay()` | Stops automatic slide progression. |
652
658
 
653
659
  The viewport supports Arrow Left/Right, Page Up/Down, Home, and End. A
654
660
  long-distance smooth jump becomes immediate so virtualized gaps are not shown.
655
661
 
662
+ #### Autoplay example
663
+
664
+ ```vue
665
+ <script setup lang="ts">
666
+ import { ref } from 'vue'
667
+ import { VirtualCarousel, type VirtualCarouselExpose } from 'vue-virtual-flow'
668
+
669
+ const carousel = ref<VirtualCarouselExpose>()
670
+ const products = ref(loadProducts())
671
+ </script>
672
+
673
+ <template>
674
+ <VirtualCarousel
675
+ ref="carousel"
676
+ :items="products"
677
+ :slides-per-view="3"
678
+ :autoplay="true"
679
+ :autoplay-delay="3000"
680
+ :autoplay-loop="true"
681
+ :pause-on-hover="true"
682
+ >
683
+ <template #default="{ item }">
684
+ <ProductCard :product="item" />
685
+ </template>
686
+ </VirtualCarousel>
687
+
688
+ <button @click="carousel?.stopAutoplay()">Pause</button>
689
+ <button @click="carousel?.startAutoplay()">Resume</button>
690
+ </template>
691
+ ```
692
+
693
+ Autoplay also starts when an initially empty `items` collection receives data.
694
+ `stopAutoplay()` pauses the timer and `startAutoplay()` resumes it while the
695
+ `autoplay` prop remains enabled. Changes to `autoplayDelay`, `autoplayLoop`, and
696
+ `pauseOnHover` take effect at runtime.
697
+
656
698
  ## Shared recipes
657
699
 
658
700
  ### Viewport height
package/README.vi.md CHANGED
@@ -626,6 +626,10 @@ thường tối đa năm slide được mount ở giữa collection.
626
626
  | `hasMore` | `boolean` | `false` | Cho biết vẫn còn trang dữ liệu tiếp theo. |
627
627
  | `loading` | `boolean` | `false` | Ngăn request `load-more` bị lặp. |
628
628
  | `loadMoreThreshold` | `number` | `2` | Số slide còn lại sau vùng nhìn để kích hoạt `load-more`. |
629
+ | `autoplay` | `boolean` | `false` | Bật chế độ tự động chuyển slide. |
630
+ | `autoplayDelay` | `number` | `3000` | Thời gian chờ giữa các lần tự động chuyển, tính bằng mili giây; giá trị dưới `1` được giới hạn và giá trị không hữu hạn dùng mặc định. |
631
+ | `autoplayLoop` | `boolean` | `true` | Quay lại slide đầu tiên khi đến cuối. |
632
+ | `pauseOnHover` | `boolean` | `true` | Tạm dừng autoplay khi con trỏ nằm trên carousel. |
629
633
 
630
634
  #### Slots và events
631
635
 
@@ -646,10 +650,48 @@ thường tối đa năm slide được mount ở giữa collection.
646
650
  | `next(behavior?)` | Tiến thêm `slidesToScroll` slide; mặc định cuộn mượt. |
647
651
  | `previous(behavior?)` | Lùi lại `slidesToScroll` slide. |
648
652
  | `scrollToIndex(index, options?)` | Đưa index thành slide đầu tiên trong vùng nhìn. |
653
+ | `startAutoplay()` | Bắt đầu hoặc khởi động lại quá trình tự động chuyển slide. |
654
+ | `stopAutoplay()` | Dừng quá trình tự động chuyển slide. |
649
655
 
650
656
  Viewport hỗ trợ Arrow Left/Right, Page Up/Down, Home và End. Smooth scroll ở
651
657
  khoảng cách xa tự chuyển thành tức thời để không lộ khoảng trống virtualized.
652
658
 
659
+ #### Ví dụ autoplay
660
+
661
+ ```vue
662
+ <script setup lang="ts">
663
+ import { ref } from 'vue'
664
+ import { VirtualCarousel, type VirtualCarouselExpose } from 'vue-virtual-flow'
665
+
666
+ const carousel = ref<VirtualCarouselExpose>()
667
+ const products = ref(loadProducts())
668
+ </script>
669
+
670
+ <template>
671
+ <VirtualCarousel
672
+ ref="carousel"
673
+ :items="products"
674
+ :slides-per-view="3"
675
+ :autoplay="true"
676
+ :autoplay-delay="3000"
677
+ :autoplay-loop="true"
678
+ :pause-on-hover="true"
679
+ >
680
+ <template #default="{ item }">
681
+ <ProductCard :product="item" />
682
+ </template>
683
+ </VirtualCarousel>
684
+
685
+ <button @click="carousel?.stopAutoplay()">Tạm dừng</button>
686
+ <button @click="carousel?.startAutoplay()">Tiếp tục</button>
687
+ </template>
688
+ ```
689
+
690
+ Autoplay cũng tự bắt đầu khi collection `items` ban đầu rỗng nhận được dữ liệu.
691
+ `stopAutoplay()` tạm dừng timer và `startAutoplay()` tiếp tục chạy khi prop
692
+ `autoplay` vẫn được bật. Các thay đổi của `autoplayDelay`, `autoplayLoop` và
693
+ `pauseOnHover` có hiệu lực ngay trong lúc component đang chạy.
694
+
653
695
  ## Cách dùng chung
654
696
 
655
697
  ### Chiều cao viewport
@@ -1,4 +1,4 @@
1
- import { ItemKey, VirtualCarouselChangeEvent, VirtualCarouselExpose } from '../types.cjs';
1
+ import { ItemKey, ResponsiveBreakpoint, VirtualCarouselChangeEvent, VirtualCarouselExpose } from '../types.cjs';
2
2
  declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
3
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
4
  readonly onLoadMore?: (() => any) | undefined;
@@ -19,6 +19,11 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
19
19
  hasMore?: boolean;
20
20
  loading?: boolean;
21
21
  loadMoreThreshold?: number;
22
+ autoplay?: boolean;
23
+ autoplayDelay?: number;
24
+ autoplayLoop?: boolean;
25
+ pauseOnHover?: boolean;
26
+ responsive?: ResponsiveBreakpoint[];
22
27
  } & Partial<{}>> & import('vue').PublicProps;
23
28
  expose(exposed: import('vue').ShallowUnwrapRef<VirtualCarouselExpose>): void;
24
29
  attrs: any;
@@ -1,4 +1,4 @@
1
- import { ItemKey, VirtualCarouselChangeEvent, VirtualCarouselExpose } from '../types.js';
1
+ import { ItemKey, ResponsiveBreakpoint, VirtualCarouselChangeEvent, VirtualCarouselExpose } from '../types.js';
2
2
  declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
3
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
4
  readonly onLoadMore?: (() => any) | undefined;
@@ -19,6 +19,11 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
19
19
  hasMore?: boolean;
20
20
  loading?: boolean;
21
21
  loadMoreThreshold?: number;
22
+ autoplay?: boolean;
23
+ autoplayDelay?: number;
24
+ autoplayLoop?: boolean;
25
+ pauseOnHover?: boolean;
26
+ responsive?: ResponsiveBreakpoint[];
22
27
  } & Partial<{}>> & import('vue').PublicProps;
23
28
  expose(exposed: import('vue').ShallowUnwrapRef<VirtualCarouselExpose>): void;
24
29
  attrs: any;
package/dist/index.d.cts CHANGED
@@ -18,6 +18,6 @@ declare module 'vue' {
18
18
  }
19
19
  declare const VirtualList: typeof DynamicVirtualScroll;
20
20
  export { ChatVirtualScroll, DynamicVirtualScroll, ShortMediaFeed, VirtualCarousel, VirtualList, VirtualScroll, WindowDynamicVirtualScroll, };
21
- export type { ChatVirtualScrollExpose, ChatVirtualScrollProps, DynamicVirtualScrollProps, ItemKey, ScrollAlignment, ShortMediaFeedChangeEvent, ShortMediaFeedExpose, ShortMediaFeedProps, VirtualCarouselChangeEvent, VirtualCarouselExpose, VirtualCarouselProps, VirtualListExpose, VirtualListProps, VirtualScrollEvent, VirtualScrollExpose, VirtualScrollProps, WindowDynamicVirtualScrollProps, } from './types.cjs';
21
+ export type { ChatVirtualScrollExpose, ChatVirtualScrollProps, DynamicVirtualScrollProps, ItemKey, ResponsiveBreakpoint, ScrollAlignment, ShortMediaFeedChangeEvent, ShortMediaFeedExpose, ShortMediaFeedProps, VirtualCarouselChangeEvent, VirtualCarouselExpose, VirtualCarouselProps, VirtualListExpose, VirtualListProps, VirtualScrollEvent, VirtualScrollExpose, VirtualScrollProps, WindowDynamicVirtualScrollProps, } from './types.cjs';
22
22
  export declare const VueVirtualScroll: Plugin;
23
23
  export default VueVirtualScroll;
package/dist/index.d.ts CHANGED
@@ -18,6 +18,6 @@ declare module 'vue' {
18
18
  }
19
19
  declare const VirtualList: typeof DynamicVirtualScroll;
20
20
  export { ChatVirtualScroll, DynamicVirtualScroll, ShortMediaFeed, VirtualCarousel, VirtualList, VirtualScroll, WindowDynamicVirtualScroll, };
21
- export type { ChatVirtualScrollExpose, ChatVirtualScrollProps, DynamicVirtualScrollProps, ItemKey, ScrollAlignment, ShortMediaFeedChangeEvent, ShortMediaFeedExpose, ShortMediaFeedProps, VirtualCarouselChangeEvent, VirtualCarouselExpose, VirtualCarouselProps, VirtualListExpose, VirtualListProps, VirtualScrollEvent, VirtualScrollExpose, VirtualScrollProps, WindowDynamicVirtualScrollProps, } from './types.js';
21
+ export type { ChatVirtualScrollExpose, ChatVirtualScrollProps, DynamicVirtualScrollProps, ItemKey, ResponsiveBreakpoint, ScrollAlignment, ShortMediaFeedChangeEvent, ShortMediaFeedExpose, ShortMediaFeedProps, VirtualCarouselChangeEvent, VirtualCarouselExpose, VirtualCarouselProps, VirtualListExpose, VirtualListProps, VirtualScrollEvent, VirtualScrollExpose, VirtualScrollProps, WindowDynamicVirtualScrollProps, } from './types.js';
22
22
  export declare const VueVirtualScroll: Plugin;
23
23
  export default VueVirtualScroll;
package/dist/types.d.cts CHANGED
@@ -85,6 +85,17 @@ export interface VirtualCarouselProps<T> {
85
85
  hasMore?: boolean;
86
86
  loading?: boolean;
87
87
  loadMoreThreshold?: number;
88
+ autoplay?: boolean;
89
+ autoplayDelay?: number;
90
+ autoplayLoop?: boolean;
91
+ pauseOnHover?: boolean;
92
+ responsive?: ResponsiveBreakpoint[];
93
+ }
94
+ export interface ResponsiveBreakpoint {
95
+ breakpoint: number;
96
+ slidesPerView?: number;
97
+ slidesToScroll?: number;
98
+ gap?: number;
88
99
  }
89
100
  export interface VirtualCarouselChangeEvent<T> {
90
101
  index: number;
@@ -114,6 +125,8 @@ export interface VirtualCarouselExpose {
114
125
  next: (behavior?: ScrollBehavior) => void;
115
126
  previous: (behavior?: ScrollBehavior) => void;
116
127
  scrollToIndex: (index: number, options?: ScrollToOptions) => void;
128
+ startAutoplay: () => void;
129
+ stopAutoplay: () => void;
117
130
  }
118
131
  export type VirtualListProps<T> = DynamicVirtualScrollProps<T>;
119
132
  export type VirtualListExpose = VirtualScrollExpose;
package/dist/types.d.ts CHANGED
@@ -85,6 +85,17 @@ export interface VirtualCarouselProps<T> {
85
85
  hasMore?: boolean;
86
86
  loading?: boolean;
87
87
  loadMoreThreshold?: number;
88
+ autoplay?: boolean;
89
+ autoplayDelay?: number;
90
+ autoplayLoop?: boolean;
91
+ pauseOnHover?: boolean;
92
+ responsive?: ResponsiveBreakpoint[];
93
+ }
94
+ export interface ResponsiveBreakpoint {
95
+ breakpoint: number;
96
+ slidesPerView?: number;
97
+ slidesToScroll?: number;
98
+ gap?: number;
88
99
  }
89
100
  export interface VirtualCarouselChangeEvent<T> {
90
101
  index: number;
@@ -114,6 +125,8 @@ export interface VirtualCarouselExpose {
114
125
  next: (behavior?: ScrollBehavior) => void;
115
126
  previous: (behavior?: ScrollBehavior) => void;
116
127
  scrollToIndex: (index: number, options?: ScrollToOptions) => void;
128
+ startAutoplay: () => void;
129
+ stopAutoplay: () => void;
117
130
  }
118
131
  export type VirtualListProps<T> = DynamicVirtualScrollProps<T>;
119
132
  export type VirtualListExpose = VirtualScrollExpose;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");function Me(r){return typeof r=="string"||typeof r=="number"||typeof r=="symbol"}function ce(r,R){const S=r[R];return Me(S)?S:void 0}function Te(r){return ce(r,"id")??ce(r,"key")}function ae(r){function R(t,T){const v=r.itemKey();if(typeof v=="function")return v(t,T);if(t!==null&&typeof t=="object"){if(v!==void 0){const u=ce(t,v);if(u!==void 0)return u}const x=Te(t);if(x!==void 0)return x}return T}function S(){}return e.watch(()=>[r.itemKey(),r.items()],S,{immediate:!0}),{getItemKey:R}}function ie(r){return r==="fill"?"100%":typeof r=="number"?`${r}px`:r}function se(r){return(R,S)=>{typeof S=="string"&&(S==="fill"||S.trim().endsWith("%"))}}const ke=["aria-label"],we={key:0,class:"vue-chat-virtual-scroll__loading-older",role:"status","aria-live":"polite"},Se=["aria-posinset","aria-setsize"],fe=e.defineComponent({name:"ChatVirtualScroll",__name:"ChatVirtualScroll",props:{items:{},estimatedItemSize:{default:48},height:{default:400},overscan:{default:5},itemKey:{default:void 0},ariaLabel:{default:"Chat messages"},stickToBottom:{type:Boolean,default:!0},bottomThreshold:{default:80},initialScroll:{default:"bottom"},hasOlder:{type:Boolean,default:!1},loadingOlder:{type:Boolean,default:!1},loadOlderThreshold:{default:120}},emits:["scroll","loadOlder","bottomChange"],setup(r,{expose:R,emit:S}){const t=r,T=S,v=e.ref(),x=e.ref(0),u=e.ref(0),z=e.ref(0),L=e.ref(!0),C=new Map,E=new Map;let K,p,b=-1,M=!1;const B=se(),{getItemKey:D}=ae({componentName:"ChatVirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),k=e.computed(()=>Math.max(1,t.estimatedItemSize)),P=e.computed(()=>Math.max(0,Math.floor(t.overscan))),j=e.computed(()=>u.value>0?u.value:typeof t.height=="number"?Math.max(0,t.height):k.value),$=e.computed(()=>{z.value;const n=new Array(t.items.length+1),f=new Array(t.items.length);n[0]=0;for(let s=0;s<t.items.length;s+=1){const V=D(t.items[s],s),H=C.get(V)??k.value;f[s]=H,n[s+1]=n[s]+H}return{offsets:n,sizes:f,total:n[t.items.length]??0}}),w=e.computed(()=>{const n=new Map;return t.items.forEach((f,s)=>{n.set(D(f,s),s)}),n});function q(n){if(t.items.length===0)return 0;const f=$.value.offsets;let s=0,V=t.items.length;for(;s<V;){const H=Math.floor((s+V)/2);f[H+1]<=n?s=H+1:V=H}return Math.min(s,t.items.length-1)}const W=e.computed(()=>Math.max(0,q(x.value)-P.value)),_=e.computed(()=>{if(t.items.length===0)return 0;const n=q(x.value+j.value)+1;return Math.min(t.items.length,n+P.value)}),A=e.computed(()=>t.items.slice(W.value,_.value).map((n,f)=>{const s=W.value+f;return{item:n,index:s,key:D(n,s),top:$.value.offsets[s]}})),G=e.computed(()=>({height:ie(t.height)}));function N(){const n=v.value;if(!n)return;const s=Math.max(0,$.value.total-n.scrollTop-n.clientHeight)<=Math.max(0,t.bottomThreshold);s!==L.value&&(L.value=s,M&&T("bottomChange",s))}function c(){var n;u.value=((n=v.value)==null?void 0:n.clientHeight)??0,B(v.value,t.height),e.nextTick(()=>{N(),I()})}function h(n){x.value=n.currentTarget.scrollTop,N(),T("scroll",{scrollTop:x.value,startIndex:W.value,endIndex:_.value}),I()}function I(){const n=v.value;!M||!n||!t.hasOlder||t.loadingOlder||b===t.items.length||n.scrollTop<=Math.max(0,t.loadOlderThreshold)&&(b=t.items.length,T("loadOlder"))}function O(n){const f=n.borderBoxSize;if(f){const s=Array.isArray(f)?f[0]:f;if(s!=null&&s.blockSize)return s.blockSize}return n.contentRect.height}function ee(n){const f=$.value,s=L.value&&t.stickToBottom;let V=0,H=!1;for(const F of n){const te=F.target,l=E.get(te),a=O(F);if(l===void 0||a<=0)continue;const o=C.get(l)??k.value;if(Math.abs(o-a)<.5)continue;const y=w.value.get(l);y!==void 0&&f.offsets[y+1]<=x.value&&(V+=a-o),C.set(l,a),H=!0}H&&(z.value+=1,e.nextTick(()=>{const F=v.value;F&&(s?i("auto"):V!==0&&(F.scrollTop+=V,x.value=F.scrollTop,N()))}))}function Q(n,f){n instanceof HTMLElement&&(E.set(n,f),p==null||p.observe(n))}function J(){for(const[n]of E)n.isConnected||(p==null||p.unobserve(n),E.delete(n))}function ne(n,f={}){const s=v.value;if(!s)return;const V=Math.max(0,$.value.total-s.clientHeight),H=Math.min(Math.max(0,Number.isFinite(n)?n:0),V),F=f.behavior??"auto";F==="auto"&&(x.value=H),s.scrollTo({...f,top:H,behavior:F}),e.nextTick(N)}function Z(n,f={}){const s=v.value;if(!s||t.items.length===0)return;const V=Math.min(t.items.length-1,Math.max(0,Math.floor(n))),{align:H="start",...F}=f,te=$.value.sizes[V];let l=$.value.offsets[V];H==="center"?l-=(s.clientHeight-te)/2:H==="end"&&(l-=s.clientHeight-te);const a=Math.max(0,Math.min(l,$.value.total-s.clientHeight)),o=F.behavior??"auto",y=Math.max(s.clientHeight*3,k.value*10),g=o==="smooth"&&Math.abs(a-s.scrollTop)>y?"auto":o;g==="auto"&&(x.value=a),s.scrollTo({...F,top:a,behavior:g}),e.nextTick(N)}function d(n="auto"){const f=v.value;f&&(n==="auto"&&(x.value=0),f.scrollTo({top:0,behavior:n}),e.nextTick(N))}function i(n="auto"){const f=v.value;if(!f)return;const s=Math.max(0,$.value.total-f.clientHeight);n==="auto"?(f.scrollTop=s,x.value=s):f.scrollTo({top:s,behavior:n}),e.nextTick(N)}let m=t.items.map((n,f)=>D(n,f));return e.watch(()=>t.items.map((n,f)=>D(n,f)),async n=>{const f=m;m=n;const s=v.value,V=(s==null?void 0:s.scrollTop)??0,H=L.value&&t.stickToBottom,F=f[0],te=F===void 0?0:n.indexOf(F),l=te>0?n.slice(0,te).reduce((o,y)=>o+(C.get(y)??k.value),0):0,a=new Set(n);for(const o of C.keys())a.has(o)||C.delete(o);z.value+=1,await e.nextTick(),s&&(l>0?(s.scrollTop=V+l,x.value=s.scrollTop):n.length>f.length&&H&&i("auto"),N(),I())}),e.watch(()=>[t.hasOlder,t.loadingOlder],async([n])=>{n||(b=-1),await e.nextTick(),I()}),e.onMounted(()=>{if(c(),typeof ResizeObserver<"u"){K=new ResizeObserver(c),p=new ResizeObserver(ee),v.value&&K.observe(v.value);for(const[n]of E)p.observe(n)}e.nextTick(()=>{t.initialScroll==="bottom"&&i("auto"),M=!0,N(),I()})}),e.onUpdated(J),e.onBeforeUnmount(()=>{K==null||K.disconnect(),p==null||p.disconnect(),E.clear()}),R({isAtBottom:L,scrollTo:ne,scrollToIndex:Z,scrollToTop:d,scrollToBottom:i}),(n,f)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:v,class:"vue-chat-virtual-scroll",style:e.normalizeStyle(G.value),role:"log","aria-label":r.ariaLabel,"aria-live":"polite",tabindex:"0",onScrollPassive:h},[r.loadingOlder?(e.openBlock(),e.createElementBlock("div",we,[e.createElementVNode("div",null,[e.renderSlot(n.$slots,"loadingOlder",{},()=>[f[0]||(f[0]=e.createTextVNode("Loading older messages…",-1))])])])):e.createCommentVNode("",!0),r.items.length?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-chat-virtual-scroll__spacer",style:e.normalizeStyle({height:`${$.value.total}px`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(A.value,({item:s,index:V,key:H,top:F})=>(e.openBlock(),e.createElementBlock("div",{key:H,ref_for:!0,ref:te=>Q(te,H),class:"vue-chat-virtual-scroll__item",style:e.normalizeStyle({transform:`translateY(${F}px)`}),role:"article","aria-posinset":V+1,"aria-setsize":r.items.length},[e.renderSlot(n.$slots,"default",{item:s,index:V})],12,Se))),128))],4)):e.renderSlot(n.$slots,"empty",{},void 0,void 0,2)],44,ke))}});function de(r){const R=e.ref(),S=e.ref(0),t=e.ref(!1),T=e.ref(!1),v=e.computed(()=>Math.max(1,r.threshold())),x=e.computed(()=>r.refreshing()||T.value?v.value:S.value),u=e.computed(()=>Math.min(1,S.value/v.value)),z=e.computed(()=>r.refreshing()||T.value?"Refreshing…":u.value>=1?"Release to refresh":"Pull to refresh");function L(){R.value=void 0,t.value=!1,S.value=0}function C(p){var B;const b=p.currentTarget,M=((B=r.scrollTop)==null?void 0:B.call(r))??b.scrollTop;!r.enabled()||r.refreshing()||M>0||p.touches.length!==1||(R.value=p.touches[0].clientY,t.value=!0)}function E(p){var D;if(R.value===void 0||!t.value)return;const b=p.currentTarget;if((((D=r.scrollTop)==null?void 0:D.call(r))??b.scrollTop)>0||p.touches.length!==1){L();return}const B=p.touches[0].clientY-R.value;if(B<=0){S.value=0;return}p.preventDefault(),S.value=Math.min(B*.5,v.value*2)}function K(){if(R.value===void 0)return;const p=S.value>=v.value&&r.enabled()&&!r.refreshing();if(R.value=void 0,t.value=!1,!p){S.value=0;return}S.value=v.value,T.value=!0,r.onRefresh(),e.nextTick(()=>{r.refreshing()||(T.value=!1,S.value=0)})}return e.watch(()=>r.refreshing(),(p,b)=>{p?(T.value=!1,S.value=v.value):b&&(T.value=!1,S.value=0)}),{pulling:t,pullDistance:S,pullOffset:x,pullProgress:u,refreshMessage:z,refreshThreshold:v,handleTouchStart:C,handleTouchMove:E,handleTouchEnd:K,handleTouchCancel:L}}const be=["aria-label"],Be=["aria-posinset","aria-setsize"],me=e.defineComponent({name:"DynamicVirtualScroll",__name:"DynamicVirtualScroll",props:{items:{},estimatedItemSize:{default:48},height:{default:400},overscan:{default:3},itemKey:{default:void 0},ariaLabel:{default:"Dynamic virtual list"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadingItemSize:{default:void 0},loadMoreThreshold:{default:200},pullToRefresh:{type:Boolean,default:!1},refreshing:{type:Boolean,default:!1},pullRefreshThreshold:{default:64}},emits:["scroll","loadMore","refresh"],setup(r,{expose:R,emit:S}){const t=r,T=S,{pulling:v,pullDistance:x,pullOffset:u,pullProgress:z,refreshMessage:L,refreshThreshold:C,handleTouchStart:E,handleTouchMove:K,handleTouchEnd:p,handleTouchCancel:b}=de({enabled:()=>t.pullToRefresh,refreshing:()=>t.refreshing,threshold:()=>t.pullRefreshThreshold,onRefresh:()=>T("refresh")}),M=e.ref(),B=e.ref(0),D=e.ref(0),k=e.ref(0),P=new Map,j=new Map;let $,w,q=-1;const W=se(),{getItemKey:_}=ae({componentName:"DynamicVirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),A=e.computed(()=>Math.max(1,t.estimatedItemSize)),G=e.computed(()=>Math.max(1,t.loadingItemSize??A.value)),N=e.computed(()=>Math.max(0,Math.floor(t.overscan))),c=e.computed(()=>D.value>0?D.value:typeof t.height=="number"?Math.max(0,t.height):A.value),h=e.computed(()=>{k.value;const l=new Array(t.items.length+1),a=new Array(t.items.length);l[0]=0;for(let o=0;o<t.items.length;o+=1){const y=_(t.items[o],o),g=P.get(y)??A.value;a[o]=g,l[o+1]=l[o]+g}return{offsets:l,sizes:a,total:l[t.items.length]??0}}),I=e.computed(()=>h.value.total+(t.loading?G.value:0)),O=e.computed(()=>{const l=new Map;return t.items.forEach((a,o)=>{l.set(_(a,o),o)}),l});function ee(l){if(t.items.length===0)return 0;const a=h.value.offsets;let o=0,y=t.items.length;for(;o<y;){const g=Math.floor((o+y)/2);a[g+1]<=l?o=g+1:y=g}return Math.min(o,t.items.length-1)}const Q=e.computed(()=>Math.max(0,ee(B.value)-N.value)),J=e.computed(()=>{if(t.items.length===0)return 0;const l=ee(B.value+c.value)+1;return Math.min(t.items.length,l+N.value)}),ne=e.computed(()=>t.items.slice(Q.value,J.value).map((l,a)=>{const o=Q.value+a;return{item:l,index:o,key:_(l,o),top:h.value.offsets[o]}})),Z=e.computed(()=>({height:ie(t.height)}));function d(){var l;D.value=((l=M.value)==null?void 0:l.clientHeight)??0,W(M.value,t.height),e.nextTick(m)}function i(l){B.value=l.currentTarget.scrollTop,T("scroll",{scrollTop:B.value,startIndex:Q.value,endIndex:J.value}),m()}function m(){const l=M.value;if(!l||!t.hasMore||t.loading||q===t.items.length)return;const a=Math.max(0,t.loadMoreThreshold);I.value-l.scrollTop-l.clientHeight<=a&&(q=t.items.length,T("loadMore"))}function n(l){const a=l.borderBoxSize;if(a){const o=Array.isArray(a)?a[0]:a;if(o!=null&&o.blockSize)return o.blockSize}return l.contentRect.height}function f(l){const a=h.value;let o=0,y=!1;for(const g of l){const U=g.target,Y=j.get(U),X=n(g);if(Y===void 0||X<=0)continue;const le=P.get(Y)??A.value;if(Math.abs(le-X)<.5)continue;const oe=O.value.get(Y);oe!==void 0&&a.offsets[oe+1]<=B.value&&(o+=X-le),P.set(Y,X),y=!0}y&&(k.value+=1,e.nextTick(m),o!==0&&e.nextTick(()=>{const g=M.value;g&&(g.scrollTop+=o,B.value=g.scrollTop)}))}function s(l,a){l instanceof HTMLElement&&(j.set(l,a),w==null||w.observe(l))}function V(){for(const[l]of j)l.isConnected||(w==null||w.unobserve(l),j.delete(l))}function H(l,a={}){const o=M.value;if(!o)return;const y=Math.max(0,I.value-o.clientHeight),g=Math.min(Math.max(0,Number.isFinite(l)?l:0),y),U=a.behavior??"auto";U==="auto"&&(B.value=g),o.scrollTo({...a,top:g,behavior:U})}function F(l,a={}){const o=M.value;if(!o||t.items.length===0)return;const y=Math.min(t.items.length-1,Math.max(0,Math.floor(l))),{align:g="start",...U}=a;let Y=h.value.offsets[y];const X=h.value.sizes[y];g==="center"?Y-=(o.clientHeight-X)/2:g==="end"&&(Y-=o.clientHeight-X);const le=Math.max(0,Math.min(Y,I.value-o.clientHeight)),oe=U.behavior??"auto",ue=Math.max(o.clientHeight*3,A.value*10),re=oe==="smooth"&&Math.abs(le-o.scrollTop)>ue?"auto":oe;re==="auto"&&(B.value=le),o.scrollTo({...U,top:le,behavior:re})}function te(l="auto"){var a;(a=M.value)==null||a.scrollTo({top:0,behavior:l})}return e.watch(()=>t.itemKey,()=>{P.clear(),k.value+=1}),e.watch(()=>t.items.length,async()=>{const l=new Set(t.items.map((y,g)=>_(y,g)));for(const y of P.keys())l.has(y)||P.delete(y);k.value+=1,await e.nextTick();const a=M.value;if(!a)return;const o=Math.max(0,I.value-a.clientHeight);a.scrollTop>o&&(a.scrollTop=o,B.value=o),m()}),e.watch(()=>[t.hasMore,t.loading],async([l])=>{l||(q=-1),await e.nextTick(),m()}),e.onMounted(()=>{if(d(),typeof ResizeObserver<"u"){$=new ResizeObserver(d),w=new ResizeObserver(f),M.value&&$.observe(M.value);for(const[l]of j)w.observe(l)}e.nextTick(m)}),e.onUpdated(V),e.onBeforeUnmount(()=>{$==null||$.disconnect(),w==null||w.disconnect(),j.clear()}),R({scrollTo:H,scrollToIndex:F,scrollToTop:te}),(l,a)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:M,class:e.normalizeClass(["vue-dynamic-virtual-scroll",{"vue-dynamic-virtual-scroll--pulling":e.unref(v)}]),style:e.normalizeStyle(Z.value),role:"list","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:i,onTouchstartPassive:a[0]||(a[0]=(...o)=>e.unref(E)&&e.unref(E)(...o)),onTouchmove:a[1]||(a[1]=(...o)=>e.unref(K)&&e.unref(K)(...o)),onTouchend:a[2]||(a[2]=(...o)=>e.unref(p)&&e.unref(p)(...o)),onTouchcancel:a[3]||(a[3]=(...o)=>e.unref(b)&&e.unref(b)(...o))},[r.pullToRefresh||r.refreshing?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-dynamic-virtual-scroll__refresh",style:e.normalizeStyle({height:`${e.unref(C)}px`,transform:`translateY(${e.unref(u)-e.unref(C)}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(l.$slots,"refresh",{pullDistance:e.unref(x),progress:e.unref(z),refreshing:r.refreshing},()=>[e.createTextVNode(e.toDisplayString(e.unref(L)),1)])],4)):e.createCommentVNode("",!0),r.items.length||r.loading?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-dynamic-virtual-scroll__spacer",style:e.normalizeStyle({height:`${I.value}px`,transform:`translateY(${e.unref(u)}px)`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ne.value,({item:o,index:y,key:g,top:U})=>(e.openBlock(),e.createElementBlock("div",{key:g,ref_for:!0,ref:Y=>s(Y,g),class:"vue-dynamic-virtual-scroll__item",style:e.normalizeStyle({transform:`translateY(${U}px)`}),role:"listitem","aria-posinset":y+1,"aria-setsize":r.items.length},[e.renderSlot(l.$slots,"default",{item:o,index:y})],12,Be))),128)),r.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-dynamic-virtual-scroll__loading",style:e.normalizeStyle({height:`${G.value}px`,transform:`translateY(${h.value.total}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(l.$slots,"loading",{},()=>[a[4]||(a[4]=e.createTextVNode("Loading more…",-1))])],4)):e.createCommentVNode("",!0)],4)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"vue-dynamic-virtual-scroll__empty",style:e.normalizeStyle({transform:`translateY(${e.unref(u)}px)`})},[e.renderSlot(l.$slots,"empty")],4))],46,be))}}),Ie=["aria-label"],ze=["aria-current","aria-posinset","aria-setsize"],Ee={key:1,class:"vue-short-media-feed__empty"},he=e.defineComponent({name:"ShortMediaFeed",__name:"ShortMediaFeed",props:{items:{},activeIndex:{default:0},buffer:{default:1},height:{default:"100dvh"},itemKey:{default:void 0},ariaLabel:{default:"Short media feed"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadMoreThreshold:{default:2}},emits:["update:activeIndex","change","reachStart","reachEnd","loadMore"],setup(r,{expose:R,emit:S}){const t=r,T=S,v=e.ref(),x=e.ref(0),u=e.ref($(t.activeIndex));let z,L=-1;const C=se(),{getItemKey:E}=ae({componentName:"ShortMediaFeed",items:()=>t.items,itemKey:()=>t.itemKey}),K=e.computed(()=>Math.max(0,Math.floor(t.buffer))),p=e.computed(()=>Math.max(0,Math.floor(Number.isFinite(t.loadMoreThreshold)?t.loadMoreThreshold:0))),b=e.computed(()=>x.value>0?x.value:typeof t.height=="number"?Math.max(1,t.height):0),M=e.computed(()=>Math.max(0,u.value-K.value)),B=e.computed(()=>Math.min(t.items.length,u.value+K.value+1)),D=e.computed(()=>t.items.slice(M.value,B.value).map((c,h)=>({item:c,index:M.value+h}))),k=e.computed(()=>M.value*b.value),P=e.computed(()=>(t.items.length-B.value)*b.value),j=e.computed(()=>({height:ie(t.height)}));function $(c){return t.items.length===0?0:Math.min(t.items.length-1,Math.max(0,Math.floor(Number.isFinite(c)?c:0)))}function w(){if(!t.hasMore||t.loading||L===t.items.length)return;(t.items.length===0?0:t.items.length-1-u.value)<=p.value&&(L=t.items.length,T("loadMore"))}function q(c){const h=$(c);h===u.value||t.items.length===0||(u.value=h,T("update:activeIndex",h),T("change",{index:h,item:t.items[h]}),h===0&&T("reachStart"),h===t.items.length-1&&T("reachEnd"),w())}function W(c,h={}){const I=v.value;I&&(typeof I.scrollTo=="function"?I.scrollTo({...h,top:c}):I.scrollTop=c)}function _(c,h={}){if(t.items.length===0)return;const I=$(c);q(I),W(I*b.value,h)}function A(c){if(b.value<=0)return;const h=c.currentTarget.scrollTop;q(Math.round(h/b.value))}function G(c){let h;c.key==="ArrowDown"||c.key==="PageDown"?h=u.value+1:c.key==="ArrowUp"||c.key==="PageUp"?h=u.value-1:c.key==="Home"?h=0:c.key==="End"&&(h=t.items.length-1),h!==void 0&&(c.preventDefault(),_(h,{behavior:"smooth"}))}function N(){var h;const c=((h=v.value)==null?void 0:h.clientHeight)??0;C(v.value,t.height),!(c<=0||c===x.value)&&(x.value=c,e.nextTick(()=>{W(u.value*c)}))}return e.watch(()=>t.activeIndex,async c=>{const h=$(c);h!==u.value&&(u.value=h,await e.nextTick(),W(h*b.value),w())}),e.watch(()=>[t.hasMore,t.loading,t.loadMoreThreshold],async([c])=>{c||(L=-1),await e.nextTick(),w()}),e.watch(()=>t.items.length,async()=>{const c=$(u.value);t.items.length===0?u.value!==0&&(u.value=0,T("update:activeIndex",0)):q(c),await e.nextTick(),W(c*b.value),w()}),e.onMounted(async()=>{N(),typeof ResizeObserver<"u"&&v.value&&(z=new ResizeObserver(N),z.observe(v.value)),await e.nextTick(),W(u.value*b.value),w()}),e.onBeforeUnmount(()=>{z==null||z.disconnect()}),R({scrollToIndex:_}),(c,h)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:v,class:"vue-short-media-feed",style:e.normalizeStyle(j.value),role:"list","aria-orientation":"vertical","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:A,onKeydown:G},[r.items.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[k.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-short-media-feed__spacer",style:e.normalizeStyle({height:`${k.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,({item:I,index:O})=>(e.openBlock(),e.createElementBlock("div",{key:e.unref(E)(I,O),class:"vue-short-media-feed__item",style:e.normalizeStyle({height:`${b.value}px`}),role:"listitem","aria-current":O===u.value?"true":void 0,"aria-posinset":O+1,"aria-setsize":r.items.length},[e.renderSlot(c.$slots,"default",{item:I,index:O,active:O===u.value})],12,ze))),128)),P.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-short-media-feed__spacer",style:e.normalizeStyle({height:`${P.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createElementBlock("div",Ee,[e.renderSlot(c.$slots,"empty")]))],44,Ie))}}),$e=["aria-label"],Ve={key:0,class:"vue-virtual-carousel__track",role:"list"},He=["aria-label","aria-current"],Le={key:1,class:"vue-virtual-carousel__empty"},ve=e.defineComponent({name:"VirtualCarousel",__name:"VirtualCarousel",props:{items:{},activeIndex:{default:0},slidesPerView:{default:1},slidesToScroll:{default:1},gap:{default:0},buffer:{default:1},height:{default:"auto"},itemKey:{default:void 0},ariaLabel:{default:"Carousel"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadMoreThreshold:{default:2}},emits:["update:activeIndex","change","reachStart","reachEnd","loadMore"],setup(r,{expose:R,emit:S}){const t=r,T=S,v=e.ref(),x=e.ref(0),u=e.ref(0);let z,L=-1;const{getItemKey:C}=ae({componentName:"VirtualCarousel",items:()=>t.items,itemKey:()=>t.itemKey}),E=e.computed(()=>Math.max(1,Math.floor(Number.isFinite(t.slidesPerView)?t.slidesPerView:1))),K=e.computed(()=>Math.max(1,Math.floor(Number.isFinite(t.slidesToScroll)?t.slidesToScroll:1))),p=e.computed(()=>Math.max(0,Number.isFinite(t.gap)?t.gap:0)),b=e.computed(()=>Math.max(0,Math.floor(Number.isFinite(t.buffer)?t.buffer:0))),M=e.computed(()=>Math.max(0,Math.floor(Number.isFinite(t.loadMoreThreshold)?t.loadMoreThreshold:0))),B=e.computed(()=>Math.max(0,x.value)),D=e.computed(()=>{if(B.value<=0)return 0;const d=(E.value-1)*p.value;return Math.max(1,(B.value-d)/E.value)}),k=e.computed(()=>D.value+p.value),P=e.computed(()=>Math.max(0,t.items.length-E.value)),j=e.computed(()=>Math.max(0,u.value-b.value)),$=e.computed(()=>Math.min(t.items.length,u.value+E.value+b.value)),w=e.computed(()=>t.items.slice(j.value,$.value).map((d,i)=>({item:d,index:j.value+i}))),q=e.computed(()=>t.items.length===0?0:t.items.length*D.value+(t.items.length-1)*p.value),W=e.computed(()=>j.value*k.value),_=e.computed(()=>Math.max(0,q.value-$.value*k.value)),A=e.computed(()=>({height:ie(t.height)}));function G(d){return Math.min(P.value,Math.max(0,Math.floor(Number.isFinite(d)?d:0)))}u.value=G(t.activeIndex);function N(d){return d>=u.value&&d<Math.min(t.items.length,u.value+E.value)}function c(){if(!t.hasMore||t.loading||L===t.items.length)return;const d=t.items.length===0?-1:Math.min(t.items.length-1,u.value+E.value-1);t.items.length-1-d<=M.value&&(L=t.items.length,T("loadMore"))}function h(d){const i=G(d);i===u.value||t.items.length===0||(u.value=i,T("update:activeIndex",i),T("change",{index:i,item:t.items[i]}),i===0&&T("reachStart"),i===P.value&&T("reachEnd"),c())}function I(d,i={}){const m=v.value;m&&(typeof m.scrollTo=="function"?m.scrollTo({...i,left:d}):m.scrollLeft=d)}function O(d,i={}){if(t.items.length===0||k.value<=0)return;const m=G(d),n=Math.abs(m-u.value),f=i.behavior==="smooth"&&n>b.value?"auto":i.behavior;h(m),I(m*k.value,{...i,behavior:f})}function ee(d="smooth"){O(u.value+K.value,{behavior:d})}function Q(d="smooth"){O(u.value-K.value,{behavior:d})}function J(d){if(k.value<=0)return;const i=d.currentTarget.scrollLeft;h(Math.round(i/k.value))}function ne(d){d.key==="ArrowRight"||d.key==="PageDown"?(d.preventDefault(),ee()):d.key==="ArrowLeft"||d.key==="PageUp"?(d.preventDefault(),Q()):d.key==="Home"?(d.preventDefault(),O(0,{behavior:"smooth"})):d.key==="End"&&(d.preventDefault(),O(P.value,{behavior:"auto"}))}function Z(){var i;const d=((i=v.value)==null?void 0:i.clientWidth)??0;d<=0||d===x.value||(x.value=d,e.nextTick(()=>{I(u.value*k.value)}))}return e.watch(()=>t.activeIndex,async d=>{const i=G(d);i!==u.value&&(u.value=i,await e.nextTick(),I(i*k.value),c())}),e.watch(()=>[t.items.length,t.slidesPerView,t.gap],async()=>{const d=G(u.value);t.items.length===0?u.value!==0&&(u.value=0,T("update:activeIndex",0)):h(d),await e.nextTick(),I(d*k.value),c()}),e.watch(()=>[t.hasMore,t.loading,t.loadMoreThreshold],async([d])=>{d||(L=-1),await e.nextTick(),c()}),e.onMounted(async()=>{Z(),typeof ResizeObserver<"u"&&v.value&&(z=new ResizeObserver(Z),z.observe(v.value)),await e.nextTick(),I(u.value*k.value),c()}),e.onBeforeUnmount(()=>{z==null||z.disconnect()}),R({next:ee,previous:Q,scrollToIndex:O}),(d,i)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:v,class:"vue-virtual-carousel",style:e.normalizeStyle(A.value),role:"region","aria-roledescription":"carousel","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:J,onKeydown:ne},[r.items.length?(e.openBlock(),e.createElementBlock("div",Ve,[W.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-virtual-carousel__spacer",style:e.normalizeStyle({flexBasis:`${W.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,({item:m,index:n})=>(e.openBlock(),e.createElementBlock("div",{key:e.unref(C)(m,n),class:"vue-virtual-carousel__item",style:e.normalizeStyle({flexBasis:`${D.value}px`,marginRight:n<r.items.length-1?`${p.value}px`:"0px"}),role:"listitem","aria-roledescription":"slide","aria-label":`${n+1} of ${r.items.length}`,"aria-current":n===u.value?"true":void 0},[e.renderSlot(d.$slots,"default",{item:m,index:n,active:n===u.value,visible:N(n)})],12,He))),128)),_.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-virtual-carousel__spacer",style:e.normalizeStyle({flexBasis:`${_.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",Le,[e.renderSlot(d.$slots,"empty")]))],44,$e))}}),Ce=["aria-label"],Ke=["aria-posinset","aria-setsize"],pe=e.defineComponent({name:"VirtualScroll",__name:"VirtualScroll",props:{items:{},itemSize:{},height:{default:400},overscan:{default:3},itemKey:{default:void 0},ariaLabel:{default:"Virtual list"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadingItemSize:{default:void 0},loadMoreThreshold:{default:200},pullToRefresh:{type:Boolean,default:!1},refreshing:{type:Boolean,default:!1},pullRefreshThreshold:{default:64}},emits:["scroll","loadMore","refresh"],setup(r,{expose:R,emit:S}){const t=r,T=S,{pulling:v,pullDistance:x,pullOffset:u,pullProgress:z,refreshMessage:L,refreshThreshold:C,handleTouchStart:E,handleTouchMove:K,handleTouchEnd:p,handleTouchCancel:b}=de({enabled:()=>t.pullToRefresh,refreshing:()=>t.refreshing,threshold:()=>t.pullRefreshThreshold,onRefresh:()=>T("refresh")}),M=e.ref(),B=e.ref(0),D=e.ref(0);let k,P=-1;const j=se(),{getItemKey:$}=ae({componentName:"VirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),w=e.computed(()=>Math.max(1,t.itemSize)),q=e.computed(()=>Math.max(0,Math.floor(t.overscan))),W=e.computed(()=>t.items.length*w.value),_=e.computed(()=>Math.max(1,t.loadingItemSize??w.value)),A=e.computed(()=>W.value+(t.loading?_.value:0)),G=e.computed(()=>D.value>0?D.value:typeof t.height=="number"?t.height:0),N=e.computed(()=>Math.max(0,Math.floor(B.value/w.value)-q.value)),c=e.computed(()=>{const i=Math.ceil((B.value+G.value)/w.value);return Math.min(t.items.length,i+q.value)}),h=e.computed(()=>t.items.slice(N.value,c.value).map((i,m)=>({item:i,index:N.value+m}))),I=e.computed(()=>({height:ie(t.height)})),O=e.computed(()=>({transform:`translateY(${N.value*w.value}px)`}));function ee(){var i;D.value=((i=M.value)==null?void 0:i.clientHeight)??0,j(M.value,t.height),e.nextTick(J)}function Q(i){B.value=i.currentTarget.scrollTop,T("scroll",{scrollTop:B.value,startIndex:N.value,endIndex:c.value}),J()}function J(){const i=M.value;if(!i||!t.hasMore||t.loading||P===t.items.length)return;const m=Math.max(0,t.loadMoreThreshold);A.value-i.scrollTop-i.clientHeight<=m&&(P=t.items.length,T("loadMore"))}function ne(i,m={}){const n=M.value;if(!n)return;const f=Math.max(0,A.value-n.clientHeight),s=Math.min(Math.max(0,Number.isFinite(i)?i:0),f),V=m.behavior??"auto";V==="auto"&&(B.value=s),n.scrollTo({...m,top:s,behavior:V})}function Z(i,m={}){const n=M.value;if(!n||t.items.length===0)return;const f=Math.min(t.items.length-1,Math.max(0,Math.floor(i))),{align:s="start",...V}=m;let H=f*w.value;s==="center"?H-=(n.clientHeight-w.value)/2:s==="end"&&(H-=n.clientHeight-w.value),n.scrollTo({...V,top:Math.max(0,Math.min(H,A.value-n.clientHeight))})}function d(i="auto"){var m;(m=M.value)==null||m.scrollTo({top:0,behavior:i})}return e.watch(()=>[t.items.length,t.itemSize],async()=>{await e.nextTick();const i=M.value;if(!i)return;const m=Math.max(0,A.value-i.clientHeight);i.scrollTop>m&&(i.scrollTop=m,B.value=m),J()}),e.watch(()=>[t.hasMore,t.loading],async([i])=>{i||(P=-1),await e.nextTick(),J()}),e.onMounted(()=>{ee(),typeof ResizeObserver<"u"&&M.value&&(k=new ResizeObserver(ee),k.observe(M.value)),e.nextTick(J)}),e.onBeforeUnmount(()=>{k==null||k.disconnect()}),R({scrollTo:ne,scrollToIndex:Z,scrollToTop:d}),(i,m)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:M,class:e.normalizeClass(["vue-virtual-scroll",{"vue-virtual-scroll--pulling":e.unref(v)}]),style:e.normalizeStyle(I.value),role:"list","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:Q,onTouchstartPassive:m[0]||(m[0]=(...n)=>e.unref(E)&&e.unref(E)(...n)),onTouchmove:m[1]||(m[1]=(...n)=>e.unref(K)&&e.unref(K)(...n)),onTouchend:m[2]||(m[2]=(...n)=>e.unref(p)&&e.unref(p)(...n)),onTouchcancel:m[3]||(m[3]=(...n)=>e.unref(b)&&e.unref(b)(...n))},[r.pullToRefresh||r.refreshing?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-virtual-scroll__refresh",style:e.normalizeStyle({height:`${e.unref(C)}px`,transform:`translateY(${e.unref(u)-e.unref(C)}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(i.$slots,"refresh",{pullDistance:e.unref(x),progress:e.unref(z),refreshing:r.refreshing},()=>[e.createTextVNode(e.toDisplayString(e.unref(L)),1)])],4)):e.createCommentVNode("",!0),r.items.length||r.loading?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-virtual-scroll__spacer",style:e.normalizeStyle({height:`${A.value}px`,transform:`translateY(${e.unref(u)}px)`})},[e.createElementVNode("div",{class:"vue-virtual-scroll__content",style:e.normalizeStyle(O.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,({item:n,index:f})=>(e.openBlock(),e.createElementBlock("div",{key:e.unref($)(n,f),class:"vue-virtual-scroll__item",style:e.normalizeStyle({height:`${w.value}px`}),role:"listitem","aria-posinset":f+1,"aria-setsize":r.items.length},[e.renderSlot(i.$slots,"default",{item:n,index:f})],12,Ke))),128))],4),r.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-virtual-scroll__loading",style:e.normalizeStyle({height:`${_.value}px`,transform:`translateY(${W.value}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(i.$slots,"loading",{},()=>[m[4]||(m[4]=e.createTextVNode("Loading more…",-1))])],4)):e.createCommentVNode("",!0)],4)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"vue-virtual-scroll__empty",style:e.normalizeStyle({transform:`translateY(${e.unref(u)}px)`})},[e.renderSlot(i.$slots,"empty")],4))],46,Ce))}}),Ne=["aria-label"],De=["aria-posinset","aria-setsize"],ge=e.defineComponent({name:"WindowDynamicVirtualScroll",__name:"WindowDynamicVirtualScroll",props:{items:{},estimatedItemSize:{default:48},overscan:{default:3},itemKey:{default:void 0},ariaLabel:{default:"Window dynamic virtual list"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadingItemSize:{default:void 0},loadMoreThreshold:{default:200},pullToRefresh:{type:Boolean,default:!1},refreshing:{type:Boolean,default:!1},pullRefreshThreshold:{default:64}},emits:["scroll","loadMore","refresh"],setup(r,{expose:R,emit:S}){const t=r,T=S,v=e.ref(),x=e.ref(0),u=e.ref(0),z=e.ref(0),L=e.ref(0),C=new Map,E=new Map;let K,p,b=-1;const{getItemKey:M}=ae({componentName:"WindowDynamicVirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),{pulling:B,pullDistance:D,pullOffset:k,pullProgress:P,refreshMessage:j,refreshThreshold:$,handleTouchStart:w,handleTouchMove:q,handleTouchEnd:W,handleTouchCancel:_}=de({enabled:()=>t.pullToRefresh,refreshing:()=>t.refreshing,threshold:()=>t.pullRefreshThreshold,onRefresh:()=>T("refresh"),scrollTop:()=>typeof window>"u"?0:Math.max(0,window.scrollY)}),A=e.computed(()=>Math.max(1,t.estimatedItemSize)),G=e.computed(()=>Math.max(1,t.loadingItemSize??A.value)),N=e.computed(()=>Math.max(0,Math.floor(t.overscan))),c=e.computed(()=>{L.value;const l=new Array(t.items.length+1),a=new Array(t.items.length);l[0]=0;for(let o=0;o<t.items.length;o+=1){const y=M(t.items[o],o),g=C.get(y)??A.value;a[o]=g,l[o+1]=l[o]+g}return{offsets:l,sizes:a,total:l[t.items.length]??0}}),h=e.computed(()=>c.value.total+(t.loading?G.value:0)),I=e.computed(()=>{const l=new Map;return t.items.forEach((a,o)=>{l.set(M(a,o),o)}),l}),O=e.computed(()=>Math.max(0,x.value-z.value));function ee(l){if(t.items.length===0)return 0;const a=c.value.offsets;let o=0,y=t.items.length;for(;o<y;){const g=Math.floor((o+y)/2);a[g+1]<=l?o=g+1:y=g}return Math.min(o,t.items.length-1)}const Q=e.computed(()=>Math.max(0,ee(O.value)-N.value)),J=e.computed(()=>{if(t.items.length===0)return 0;const l=x.value+u.value-z.value,a=Math.max(A.value,l),o=ee(a)+1;return Math.min(t.items.length,o+N.value)}),ne=e.computed(()=>t.items.slice(Q.value,J.value).map((l,a)=>{const o=Q.value+a;return{item:l,index:o,key:M(l,o),top:c.value.offsets[o]}}));function Z(){typeof window>"u"||(x.value=Math.max(0,window.scrollY),u.value=window.innerHeight,v.value&&(z.value=v.value.getBoundingClientRect().top+x.value))}function d(){T("scroll",{scrollTop:O.value,startIndex:Q.value,endIndex:J.value})}function i(){Z(),d(),m()}function m(){if(typeof window>"u"||!t.hasMore||t.loading||b===t.items.length)return;const l=Math.max(0,t.loadMoreThreshold),a=z.value+h.value,o=x.value+u.value;a-o<=l&&(b=t.items.length,T("loadMore"))}function n(l){const a=l.borderBoxSize;if(a){const o=Array.isArray(a)?a[0]:a;if(o!=null&&o.blockSize)return o.blockSize}return l.contentRect.height}function f(l){const a=c.value;let o=0,y=!1;for(const g of l){const U=g.target,Y=E.get(U),X=n(g);if(Y===void 0||X<=0)continue;const le=C.get(Y)??A.value;if(Math.abs(le-X)<.5)continue;const oe=I.value.get(Y);oe!==void 0&&a.offsets[oe+1]<=O.value&&(o+=X-le),C.set(Y,X),y=!0}y&&(L.value+=1,e.nextTick(()=>{if(o!==0&&typeof window<"u"){const g=Math.max(0,x.value+o);x.value=g,window.scrollTo({top:g,behavior:"auto"})}Z(),m()}))}function s(l,a){l instanceof HTMLElement&&(E.set(l,a),p==null||p.observe(l))}function V(){for(const[l]of E)l.isConnected||(p==null||p.unobserve(l),E.delete(l))}function H(l,a={}){if(typeof window>"u")return;Z();const o=Math.max(0,h.value-u.value),y=Math.min(Math.max(0,Number.isFinite(l)?l:0),o),g=Math.max(0,z.value+y),U=a.behavior??"auto";U==="auto"&&(x.value=g),window.scrollTo({...a,top:g,behavior:U})}function F(l,a={}){if(typeof window>"u"||t.items.length===0)return;Z();const o=Math.min(t.items.length-1,Math.max(0,Math.floor(l))),{align:y="start",...g}=a,U=c.value.sizes[o];let Y=z.value+c.value.offsets[o];y==="center"?Y-=(u.value-U)/2:y==="end"&&(Y-=u.value-U);const X=Math.max(z.value,z.value+h.value-u.value),le=Math.max(0,Math.min(Y,X)),oe=g.behavior??"auto",ue=Math.max(u.value*3,A.value*10),re=oe==="smooth"&&Math.abs(le-x.value)>ue?"auto":oe;re==="auto"&&(x.value=le),window.scrollTo({...g,top:le,behavior:re})}function te(l="auto"){typeof window>"u"||(Z(),window.scrollTo({top:Math.max(0,z.value),behavior:l}))}return e.watch(()=>t.itemKey,()=>{C.clear(),L.value+=1}),e.watch(()=>t.items.length,async()=>{const l=new Set(t.items.map((a,o)=>M(a,o)));for(const a of C.keys())l.has(a)||C.delete(a);L.value+=1,await e.nextTick(),Z(),m()}),e.watch(()=>[t.hasMore,t.loading],async([l])=>{l||(b=-1),await e.nextTick(),Z(),m()}),e.onMounted(()=>{if(Z(),window.addEventListener("scroll",i,{passive:!0}),window.addEventListener("resize",i,{passive:!0}),typeof ResizeObserver<"u"){K=new ResizeObserver(()=>{Z(),m()}),p=new ResizeObserver(f),v.value&&K.observe(v.value);for(const[l]of E)p.observe(l)}e.nextTick(m)}),e.onUpdated(V),e.onBeforeUnmount(()=>{window.removeEventListener("scroll",i),window.removeEventListener("resize",i),K==null||K.disconnect(),p==null||p.disconnect(),E.clear()}),R({scrollTo:H,scrollToIndex:F,scrollToTop:te}),(l,a)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"root",ref:v,class:e.normalizeClass(["vue-window-dynamic-virtual-scroll",{"vue-window-dynamic-virtual-scroll--pulling":e.unref(B)}]),role:"list","aria-label":r.ariaLabel,onTouchstartPassive:a[0]||(a[0]=(...o)=>e.unref(w)&&e.unref(w)(...o)),onTouchmove:a[1]||(a[1]=(...o)=>e.unref(q)&&e.unref(q)(...o)),onTouchend:a[2]||(a[2]=(...o)=>e.unref(W)&&e.unref(W)(...o)),onTouchcancel:a[3]||(a[3]=(...o)=>e.unref(_)&&e.unref(_)(...o))},[r.pullToRefresh||r.refreshing?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-window-dynamic-virtual-scroll__refresh",style:e.normalizeStyle({height:`${e.unref($)}px`,transform:`translateY(${e.unref(k)-e.unref($)}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(l.$slots,"refresh",{pullDistance:e.unref(D),progress:e.unref(P),refreshing:r.refreshing},()=>[e.createTextVNode(e.toDisplayString(e.unref(j)),1)])],4)):e.createCommentVNode("",!0),r.items.length||r.loading?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-window-dynamic-virtual-scroll__spacer",style:e.normalizeStyle({height:`${h.value}px`,transform:`translateY(${e.unref(k)}px)`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ne.value,({item:o,index:y,key:g,top:U})=>(e.openBlock(),e.createElementBlock("div",{key:g,ref_for:!0,ref:Y=>s(Y,g),class:"vue-window-dynamic-virtual-scroll__item",style:e.normalizeStyle({transform:`translateY(${U}px)`}),role:"listitem","aria-posinset":y+1,"aria-setsize":r.items.length},[e.renderSlot(l.$slots,"default",{item:o,index:y})],12,De))),128)),r.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-window-dynamic-virtual-scroll__loading",style:e.normalizeStyle({height:`${G.value}px`,transform:`translateY(${c.value.total}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(l.$slots,"loading",{},()=>[a[4]||(a[4]=e.createTextVNode("Loading more…",-1))])],4)):e.createCommentVNode("",!0)],4)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"vue-window-dynamic-virtual-scroll__empty",style:e.normalizeStyle({transform:`translateY(${e.unref(k)}px)`})},[e.renderSlot(l.$slots,"empty")],4))],42,Ne))}}),ye=me,xe={install(r){r.component("ChatVirtualScroll",fe),r.component("DynamicVirtualScroll",me),r.component("ShortMediaFeed",he),r.component("VirtualCarousel",ve),r.component("VirtualList",ye),r.component("VirtualScroll",pe),r.component("WindowDynamicVirtualScroll",ge)}};exports.ChatVirtualScroll=fe;exports.DynamicVirtualScroll=me;exports.ShortMediaFeed=he;exports.VirtualCarousel=ve;exports.VirtualList=ye;exports.VirtualScroll=pe;exports.VueVirtualScroll=xe;exports.WindowDynamicVirtualScroll=ge;exports.default=xe;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");function ye(r){return typeof r=="string"||typeof r=="number"||typeof r=="symbol"}function se(r,N){const w=r[N];return ye(w)?w:void 0}function xe(r){return se(r,"id")??se(r,"key")}function ae(r){function N(t,x){const h=r.itemKey();if(typeof h=="function")return h(t,x);if(t!==null&&typeof t=="object"){if(h!==void 0){const s=se(t,h);if(s!==void 0)return s}const T=xe(t);if(T!==void 0)return T}return x}function w(){}return e.watch(()=>[r.itemKey(),r.items()],w,{immediate:!0}),{getItemKey:N}}function re(r){return r==="fill"?"100%":typeof r=="number"?`${r}px`:r}function ie(r){return(N,w)=>{typeof w=="string"&&(w==="fill"||w.trim().endsWith("%"))}}const Te=["aria-label"],Me={key:0,class:"vue-chat-virtual-scroll__loading-older",role:"status","aria-live":"polite"},ke=["aria-posinset","aria-setsize"],de=e.defineComponent({name:"ChatVirtualScroll",__name:"ChatVirtualScroll",props:{items:{},estimatedItemSize:{default:48},height:{default:400},overscan:{default:5},itemKey:{default:void 0},ariaLabel:{default:"Chat messages"},stickToBottom:{type:Boolean,default:!0},bottomThreshold:{default:80},initialScroll:{default:"bottom"},hasOlder:{type:Boolean,default:!1},loadingOlder:{type:Boolean,default:!1},loadOlderThreshold:{default:120}},emits:["scroll","loadOlder","bottomChange"],setup(r,{expose:N,emit:w}){const t=r,x=w,h=e.ref(),T=e.ref(0),s=e.ref(0),b=e.ref(0),K=e.ref(!0),H=new Map,E=new Map;let C,f,B=-1,y=!1;const M=ie(),{getItemKey:L}=ae({componentName:"ChatVirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),O=e.computed(()=>Math.max(1,t.estimatedItemSize)),D=e.computed(()=>Math.max(0,Math.floor(t.overscan))),q=e.computed(()=>s.value>0?s.value:typeof t.height=="number"?Math.max(0,t.height):O.value),V=e.computed(()=>{b.value;const a=new Array(t.items.length+1),c=new Array(t.items.length);a[0]=0;for(let u=0;u<t.items.length;u+=1){const I=L(t.items[u],u),S=H.get(I)??O.value;c[u]=S,a[u+1]=a[u]+S}return{offsets:a,sizes:c,total:a[t.items.length]??0}}),k=e.computed(()=>{const a=new Map;return t.items.forEach((c,u)=>{a.set(L(c,u),u)}),a});function _(a){if(t.items.length===0)return 0;const c=V.value.offsets;let u=0,I=t.items.length;for(;u<I;){const S=Math.floor((u+I)/2);c[S+1]<=a?u=S+1:I=S}return Math.min(u,t.items.length-1)}const z=e.computed(()=>Math.max(0,_(T.value)-D.value)),F=e.computed(()=>{if(t.items.length===0)return 0;const a=_(T.value+q.value)+1;return Math.min(t.items.length,a+D.value)}),P=e.computed(()=>t.items.slice(z.value,F.value).map((a,c)=>{const u=z.value+c;return{item:a,index:u,key:L(a,u),top:V.value.offsets[u]}})),X=e.computed(()=>({height:re(t.height)}));function R(){const a=h.value;if(!a)return;const u=Math.max(0,V.value.total-a.scrollTop-a.clientHeight)<=Math.max(0,t.bottomThreshold);u!==K.value&&(K.value=u,y&&x("bottomChange",u))}function m(){var a;s.value=((a=h.value)==null?void 0:a.clientHeight)??0,M(h.value,t.height),e.nextTick(()=>{R(),$()})}function v(a){T.value=a.currentTarget.scrollTop,R(),x("scroll",{scrollTop:T.value,startIndex:z.value,endIndex:F.value}),$()}function $(){const a=h.value;!y||!a||!t.hasOlder||t.loadingOlder||B===t.items.length||a.scrollTop<=Math.max(0,t.loadOlderThreshold)&&(B=t.items.length,x("loadOlder"))}function G(a){const c=a.borderBoxSize;if(c){const u=Array.isArray(c)?c[0]:c;if(u!=null&&u.blockSize)return u.blockSize}return a.contentRect.height}function Z(a){const c=V.value,u=K.value&&t.stickToBottom;let I=0,S=!1;for(const A of a){const Q=A.target,n=E.get(Q),l=G(A);if(n===void 0||l<=0)continue;const o=H.get(n)??O.value;if(Math.abs(o-l)<.5)continue;const i=k.value.get(n);i!==void 0&&c.offsets[i+1]<=T.value&&(I+=l-o),H.set(n,l),S=!0}S&&(b.value+=1,e.nextTick(()=>{const A=h.value;A&&(u?p("auto"):I!==0&&(A.scrollTop+=I,T.value=A.scrollTop,R()))}))}function te(a,c){a instanceof HTMLElement&&(E.set(a,c),f==null||f.observe(a))}function U(){for(const[a]of E)a.isConnected||(f==null||f.unobserve(a),E.delete(a))}function le(a,c={}){const u=h.value;if(!u)return;const I=Math.max(0,V.value.total-u.clientHeight),S=Math.min(Math.max(0,Number.isFinite(a)?a:0),I),A=c.behavior??"auto";A==="auto"&&(T.value=S),u.scrollTo({...c,top:S,behavior:A}),e.nextTick(R)}function Y(a,c={}){const u=h.value;if(!u||t.items.length===0)return;const I=Math.min(t.items.length-1,Math.max(0,Math.floor(a))),{align:S="start",...A}=c,Q=V.value.sizes[I];let n=V.value.offsets[I];S==="center"?n-=(u.clientHeight-Q)/2:S==="end"&&(n-=u.clientHeight-Q);const l=Math.max(0,Math.min(n,V.value.total-u.clientHeight)),o=A.behavior??"auto";o==="auto"&&(T.value=l),u.scrollTo({...A,top:l,behavior:o}),e.nextTick(R)}function J(a="auto"){const c=h.value;c&&(a==="auto"&&(T.value=0),c.scrollTo({top:0,behavior:a}),e.nextTick(R))}function p(a="auto"){const c=h.value;if(!c)return;const u=Math.max(0,V.value.total-c.clientHeight);a==="auto"?(c.scrollTop=u,T.value=u):c.scrollTo({top:u,behavior:a}),e.nextTick(R)}let g=t.items.map((a,c)=>L(a,c));return e.watch(()=>t.items.map((a,c)=>L(a,c)),async a=>{const c=g;g=a;const u=h.value,I=(u==null?void 0:u.scrollTop)??0,S=K.value&&t.stickToBottom,A=c[0],Q=A===void 0?0:a.indexOf(A),n=Q>0?a.slice(0,Q).reduce((o,i)=>o+(H.get(i)??O.value),0):0,l=new Set(a);for(const o of H.keys())l.has(o)||H.delete(o);b.value+=1,await e.nextTick(),u&&(n>0?(u.scrollTop=I+n,T.value=u.scrollTop):a.length>c.length&&S&&p("auto"),R(),$())}),e.watch(()=>[t.hasOlder,t.loadingOlder],async([a])=>{a||(B=-1),await e.nextTick(),$()}),e.onMounted(()=>{if(m(),typeof ResizeObserver<"u"){C=new ResizeObserver(m),f=new ResizeObserver(Z),h.value&&C.observe(h.value);for(const[a]of E)f.observe(a)}e.nextTick(()=>{t.initialScroll==="bottom"&&p("auto"),y=!0,R(),$()})}),e.onUpdated(U),e.onBeforeUnmount(()=>{C&&(C.disconnect(),C=void 0),f&&(f.disconnect(),f=void 0),E.clear()}),N({isAtBottom:K,scrollTo:le,scrollToIndex:Y,scrollToTop:J,scrollToBottom:p}),(a,c)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:h,class:"vue-chat-virtual-scroll",style:e.normalizeStyle(X.value),role:"log","aria-label":r.ariaLabel,"aria-live":"polite",tabindex:"0",onScrollPassive:v},[r.loadingOlder?(e.openBlock(),e.createElementBlock("div",Me,[e.createElementVNode("div",null,[e.renderSlot(a.$slots,"loadingOlder",{},()=>[c[0]||(c[0]=e.createTextVNode("Loading older messages…",-1))])])])):e.createCommentVNode("",!0),r.items.length?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-chat-virtual-scroll__spacer",style:e.normalizeStyle({height:`${V.value.total}px`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(P.value,({item:u,index:I,key:S,top:A})=>(e.openBlock(),e.createElementBlock("div",{key:S,ref_for:!0,ref:Q=>te(Q,S),class:"vue-chat-virtual-scroll__item",style:e.normalizeStyle({transform:`translateY(${A}px)`}),role:"article","aria-posinset":I+1,"aria-setsize":r.items.length},[e.renderSlot(a.$slots,"default",{item:u,index:I})],12,ke))),128))],4)):e.renderSlot(a.$slots,"empty",{},void 0,void 0,2)],44,Te))}});function ue(r){const N=e.ref(),w=e.ref(0),t=e.ref(!1),x=e.ref(!1),h=e.computed(()=>Math.max(1,r.threshold())),T=e.computed(()=>r.refreshing()||x.value?h.value:w.value),s=e.computed(()=>Math.min(1,w.value/h.value)),b=e.computed(()=>r.refreshing()||x.value?"Refreshing…":s.value>=1?"Release to refresh":"Pull to refresh");function K(){N.value=void 0,t.value=!1,w.value=0}function H(f){var M;const B=f.currentTarget,y=((M=r.scrollTop)==null?void 0:M.call(r))??B.scrollTop;!r.enabled()||r.refreshing()||y>0||f.touches.length!==1||(N.value=f.touches[0].clientY,t.value=!0)}function E(f){var L;if(N.value===void 0||!t.value)return;const B=f.currentTarget;if((((L=r.scrollTop)==null?void 0:L.call(r))??B.scrollTop)>0||f.touches.length!==1){K();return}const M=f.touches[0].clientY-N.value;if(M<=0){w.value=0;return}f.preventDefault(),w.value=Math.min(M*.5,h.value*2)}function C(){if(N.value===void 0)return;const f=w.value>=h.value&&r.enabled()&&!r.refreshing();if(N.value=void 0,t.value=!1,!f){w.value=0;return}w.value=h.value,x.value=!0,r.onRefresh(),e.nextTick(()=>{r.refreshing()||(x.value=!1,w.value=0)})}return e.watch(()=>r.refreshing(),(f,B)=>{f?(x.value=!1,w.value=h.value):B&&(x.value=!1,w.value=0)}),{pulling:t,pullDistance:w,pullOffset:T,pullProgress:s,refreshMessage:b,refreshThreshold:h,handleTouchStart:H,handleTouchMove:E,handleTouchEnd:C,handleTouchCancel:K}}const we=["aria-label"],Se=["aria-posinset","aria-setsize"],ce=e.defineComponent({name:"DynamicVirtualScroll",__name:"DynamicVirtualScroll",props:{items:{},estimatedItemSize:{default:48},height:{default:400},overscan:{default:3},itemKey:{default:void 0},ariaLabel:{default:"Dynamic virtual list"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadingItemSize:{default:void 0},loadMoreThreshold:{default:200},pullToRefresh:{type:Boolean,default:!1},refreshing:{type:Boolean,default:!1},pullRefreshThreshold:{default:64}},emits:["scroll","loadMore","refresh"],setup(r,{expose:N,emit:w}){const t=r,x=w,{pulling:h,pullDistance:T,pullOffset:s,pullProgress:b,refreshMessage:K,refreshThreshold:H,handleTouchStart:E,handleTouchMove:C,handleTouchEnd:f,handleTouchCancel:B}=ue({enabled:()=>t.pullToRefresh,refreshing:()=>t.refreshing,threshold:()=>t.pullRefreshThreshold,onRefresh:()=>x("refresh")}),y=e.ref(),M=e.ref(0),L=e.ref(0),O=e.ref(0),D=new Map,q=new Map;let V,k,_=-1;const z=ie(),{getItemKey:F}=ae({componentName:"DynamicVirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),P=e.computed(()=>Math.max(1,t.estimatedItemSize)),X=e.computed(()=>Math.max(1,t.loadingItemSize??P.value)),R=e.computed(()=>Math.max(0,Math.floor(t.overscan))),m=e.computed(()=>L.value>0?L.value:typeof t.height=="number"?Math.max(0,t.height):P.value),v=e.computed(()=>{O.value;const n=new Array(t.items.length+1),l=new Array(t.items.length);n[0]=0;for(let o=0;o<t.items.length;o+=1){const i=F(t.items[o],o),d=D.get(i)??P.value;l[o]=d,n[o+1]=n[o]+d}return{offsets:n,sizes:l,total:n[t.items.length]??0}}),$=e.computed(()=>v.value.total+(t.loading?X.value:0)),G=e.computed(()=>{const n=new Map;return t.items.forEach((l,o)=>{n.set(F(l,o),o)}),n});function Z(n){if(t.items.length===0)return 0;const l=v.value.offsets;let o=0,i=t.items.length;for(;o<i;){const d=Math.floor((o+i)/2);l[d+1]<=n?o=d+1:i=d}return Math.min(o,t.items.length-1)}const te=e.computed(()=>Math.max(0,Z(M.value)-R.value)),U=e.computed(()=>{if(t.items.length===0)return 0;const n=Z(M.value+m.value)+1;return Math.min(t.items.length,n+R.value)}),le=e.computed(()=>t.items.slice(te.value,U.value).map((n,l)=>{const o=te.value+l;return{item:n,index:o,key:F(n,o),top:v.value.offsets[o]}})),Y=e.computed(()=>({height:re(t.height)}));function J(){var n;L.value=((n=y.value)==null?void 0:n.clientHeight)??0,z(y.value,t.height),e.nextTick(g)}function p(n){M.value=n.currentTarget.scrollTop,x("scroll",{scrollTop:M.value,startIndex:te.value,endIndex:U.value}),g()}function g(){const n=y.value;if(!n||!t.hasMore||t.loading||_===t.items.length)return;const l=Math.max(0,t.loadMoreThreshold);$.value-n.scrollTop-n.clientHeight<=l&&(_=t.items.length,x("loadMore"))}function a(n){const l=n.borderBoxSize;if(l){const o=Array.isArray(l)?l[0]:l;if(o!=null&&o.blockSize)return o.blockSize}return n.contentRect.height}function c(n){const l=v.value;let o=0,i=!1;for(const d of n){const j=d.target,W=q.get(j),ee=a(d);if(W===void 0||ee<=0)continue;const oe=D.get(W)??P.value;if(Math.abs(oe-ee)<.5)continue;const ne=G.value.get(W);ne!==void 0&&l.offsets[ne+1]<=M.value&&(o+=ee-oe),D.set(W,ee),i=!0}i&&(O.value+=1,e.nextTick(g),o!==0&&e.nextTick(()=>{const d=y.value;d&&(d.scrollTop+=o,M.value=d.scrollTop)}))}function u(n,l){n instanceof HTMLElement&&(q.set(n,l),k==null||k.observe(n))}function I(){for(const[n]of q)n.isConnected||(k==null||k.unobserve(n),q.delete(n))}function S(n,l={}){const o=y.value;if(!o)return;const i=Math.max(0,$.value-o.clientHeight),d=Math.min(Math.max(0,Number.isFinite(n)?n:0),i),j=l.behavior??"auto";j==="auto"&&(M.value=d),o.scrollTo({...l,top:d,behavior:j})}function A(n,l={}){const o=y.value;if(!o||t.items.length===0)return;const i=Math.min(t.items.length-1,Math.max(0,Math.floor(n))),{align:d="start",...j}=l;let W=v.value.offsets[i];const ee=v.value.sizes[i];d==="center"?W-=(o.clientHeight-ee)/2:d==="end"&&(W-=o.clientHeight-ee);const oe=Math.max(0,Math.min(W,$.value-o.clientHeight)),ne=j.behavior??"auto";ne==="auto"&&(M.value=oe),o.scrollTo({...j,top:oe,behavior:ne})}function Q(n="auto"){var l;(l=y.value)==null||l.scrollTo({top:0,behavior:n})}return e.watch(()=>t.itemKey,()=>{D.clear(),O.value+=1}),e.watch(()=>t.items.length,async()=>{const n=new Set(t.items.map((i,d)=>F(i,d)));for(const i of D.keys())n.has(i)||D.delete(i);O.value+=1,await e.nextTick();const l=y.value;if(!l)return;const o=Math.max(0,$.value-l.clientHeight);l.scrollTop>o&&(l.scrollTop=o,M.value=o),g()}),e.watch(()=>[t.hasMore,t.loading],async([n])=>{n||(_=-1),await e.nextTick(),g()}),e.onMounted(()=>{if(J(),typeof ResizeObserver<"u"){V=new ResizeObserver(J),k=new ResizeObserver(c),y.value&&V.observe(y.value);for(const[n]of q)k.observe(n)}e.nextTick(g)}),e.onUpdated(I),e.onBeforeUnmount(()=>{V&&(V.disconnect(),V=void 0),k&&(k.disconnect(),k=void 0),q.clear()}),N({scrollTo:S,scrollToIndex:A,scrollToTop:Q}),(n,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:y,class:e.normalizeClass(["vue-dynamic-virtual-scroll",{"vue-dynamic-virtual-scroll--pulling":e.unref(h)}]),style:e.normalizeStyle(Y.value),role:"list","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:p,onTouchstartPassive:l[0]||(l[0]=(...o)=>e.unref(E)&&e.unref(E)(...o)),onTouchmove:l[1]||(l[1]=(...o)=>e.unref(C)&&e.unref(C)(...o)),onTouchend:l[2]||(l[2]=(...o)=>e.unref(f)&&e.unref(f)(...o)),onTouchcancel:l[3]||(l[3]=(...o)=>e.unref(B)&&e.unref(B)(...o))},[r.pullToRefresh||r.refreshing?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-dynamic-virtual-scroll__refresh",style:e.normalizeStyle({height:`${e.unref(H)}px`,transform:`translateY(${e.unref(s)-e.unref(H)}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(n.$slots,"refresh",{pullDistance:e.unref(T),progress:e.unref(b),refreshing:r.refreshing},()=>[e.createTextVNode(e.toDisplayString(e.unref(K)),1)])],4)):e.createCommentVNode("",!0),r.items.length||r.loading?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-dynamic-virtual-scroll__spacer",style:e.normalizeStyle({height:`${$.value}px`,transform:`translateY(${e.unref(s)}px)`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(le.value,({item:o,index:i,key:d,top:j})=>(e.openBlock(),e.createElementBlock("div",{key:d,ref_for:!0,ref:W=>u(W,d),class:"vue-dynamic-virtual-scroll__item",style:e.normalizeStyle({transform:`translateY(${j}px)`}),role:"listitem","aria-posinset":i+1,"aria-setsize":r.items.length},[e.renderSlot(n.$slots,"default",{item:o,index:i})],12,Se))),128)),r.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-dynamic-virtual-scroll__loading",style:e.normalizeStyle({height:`${X.value}px`,transform:`translateY(${v.value.total}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(n.$slots,"loading",{},()=>[l[4]||(l[4]=e.createTextVNode("Loading more…",-1))])],4)):e.createCommentVNode("",!0)],4)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"vue-dynamic-virtual-scroll__empty",style:e.normalizeStyle({transform:`translateY(${e.unref(s)}px)`})},[e.renderSlot(n.$slots,"empty")],4))],46,we))}}),be=["aria-label"],Be=["aria-current","aria-posinset","aria-setsize"],ze={key:1,class:"vue-short-media-feed__empty"},me=e.defineComponent({name:"ShortMediaFeed",__name:"ShortMediaFeed",props:{items:{},activeIndex:{default:0},buffer:{default:1},height:{default:"100dvh"},itemKey:{default:void 0},ariaLabel:{default:"Short media feed"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadMoreThreshold:{default:2}},emits:["update:activeIndex","change","reachStart","reachEnd","loadMore"],setup(r,{expose:N,emit:w}){const t=r,x=w,h=e.ref(),T=e.ref(0),s=e.ref(V(t.activeIndex));let b,K=-1;const H=ie(),{getItemKey:E}=ae({componentName:"ShortMediaFeed",items:()=>t.items,itemKey:()=>t.itemKey}),C=e.computed(()=>Math.max(0,Math.floor(t.buffer))),f=e.computed(()=>Math.max(0,Math.floor(Number.isFinite(t.loadMoreThreshold)?t.loadMoreThreshold:0))),B=e.computed(()=>T.value>0?T.value:typeof t.height=="number"?Math.max(1,t.height):0),y=e.computed(()=>Math.max(0,s.value-C.value)),M=e.computed(()=>Math.min(t.items.length,s.value+C.value+1)),L=e.computed(()=>t.items.slice(y.value,M.value).map((m,v)=>({item:m,index:y.value+v}))),O=e.computed(()=>y.value*B.value),D=e.computed(()=>(t.items.length-M.value)*B.value),q=e.computed(()=>({height:re(t.height)}));function V(m){return t.items.length===0?0:Math.min(t.items.length-1,Math.max(0,Math.floor(Number.isFinite(m)?m:0)))}function k(){if(!t.hasMore||t.loading||K===t.items.length)return;(t.items.length===0?0:t.items.length-1-s.value)<=f.value&&(K=t.items.length,x("loadMore"))}function _(m){const v=V(m);v===s.value||t.items.length===0||(s.value=v,x("update:activeIndex",v),x("change",{index:v,item:t.items[v]}),v===0&&x("reachStart"),v===t.items.length-1&&x("reachEnd"),k())}function z(m,v={}){const $=h.value;$&&(typeof $.scrollTo=="function"?$.scrollTo({...v,top:m}):$.scrollTop=m)}function F(m,v={}){if(t.items.length===0)return;const $=V(m);_($),z($*B.value,v)}function P(m){if(B.value<=0)return;const v=m.currentTarget.scrollTop;_(Math.round(v/B.value))}function X(m){let v;m.key==="ArrowDown"||m.key==="PageDown"?v=s.value+1:m.key==="ArrowUp"||m.key==="PageUp"?v=s.value-1:m.key==="Home"?v=0:m.key==="End"&&(v=t.items.length-1),v!==void 0&&(m.preventDefault(),F(v,{behavior:"smooth"}))}function R(){var v;const m=((v=h.value)==null?void 0:v.clientHeight)??0;H(h.value,t.height),!(m<=0||m===T.value)&&(T.value=m,e.nextTick(()=>{z(s.value*m)}))}return e.watch(()=>t.activeIndex,async m=>{const v=V(m);v!==s.value&&(s.value=v,await e.nextTick(),z(v*B.value),k())}),e.watch(()=>[t.hasMore,t.loading,t.loadMoreThreshold],async([m])=>{m||(K=-1),await e.nextTick(),k()}),e.watch(()=>t.items.length,async()=>{const m=V(s.value);t.items.length===0?s.value!==0&&(s.value=0,x("update:activeIndex",0)):_(m),await e.nextTick(),z(m*B.value),k()}),e.onMounted(async()=>{R(),typeof ResizeObserver<"u"&&h.value&&(b=new ResizeObserver(R),b.observe(h.value)),await e.nextTick(),z(s.value*B.value),k()}),e.onBeforeUnmount(()=>{b&&(b.disconnect(),b=void 0)}),N({scrollToIndex:F}),(m,v)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:h,class:"vue-short-media-feed",style:e.normalizeStyle(q.value),role:"list","aria-orientation":"vertical","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:P,onKeydown:X},[r.items.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[O.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-short-media-feed__spacer",style:e.normalizeStyle({height:`${O.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(L.value,({item:$,index:G})=>(e.openBlock(),e.createElementBlock("div",{key:e.unref(E)($,G),class:"vue-short-media-feed__item",style:e.normalizeStyle({height:`${B.value}px`}),role:"listitem","aria-current":G===s.value?"true":void 0,"aria-posinset":G+1,"aria-setsize":r.items.length},[e.renderSlot(m.$slots,"default",{item:$,index:G,active:G===s.value})],12,Be))),128)),D.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-short-media-feed__spacer",style:e.normalizeStyle({height:`${D.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createElementBlock("div",ze,[e.renderSlot(m.$slots,"empty")]))],44,be))}}),Ie=["aria-label"],Ee={key:0,class:"vue-virtual-carousel__track",role:"list"},Ve=["aria-label","aria-current"],$e={key:1,class:"vue-virtual-carousel__empty"},fe=e.defineComponent({name:"VirtualCarousel",__name:"VirtualCarousel",props:{items:{},activeIndex:{default:0},slidesPerView:{default:1},slidesToScroll:{default:1},gap:{default:0},buffer:{default:1},height:{default:"auto"},itemKey:{default:void 0},ariaLabel:{default:"Carousel"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadMoreThreshold:{default:2},autoplay:{type:Boolean,default:!1},autoplayDelay:{default:3e3},autoplayLoop:{type:Boolean,default:!0},pauseOnHover:{type:Boolean,default:!0},responsive:{default:void 0}},emits:["update:activeIndex","change","reachStart","reachEnd","loadMore"],setup(r,{expose:N,emit:w}){const t=r,x=w,h=e.ref(),T=e.ref(0),s=e.ref(0);let b,K=-1,H,E,C=!1;const f=e.ref(!1),{getItemKey:B}=ae({componentName:"VirtualCarousel",items:()=>t.items,itemKey:()=>t.itemKey}),y=e.computed(()=>Math.max(0,T.value)),M=e.computed(()=>{if(!t.responsive||t.responsive.length===0)return{slidesPerView:t.slidesPerView,slidesToScroll:t.slidesToScroll,gap:t.gap};const l=y.value,o=[...t.responsive].sort((i,d)=>d.breakpoint-i.breakpoint);for(const i of o)if(l>=i.breakpoint)return{slidesPerView:i.slidesPerView??t.slidesPerView,slidesToScroll:i.slidesToScroll??t.slidesToScroll,gap:i.gap??t.gap};return{slidesPerView:t.slidesPerView,slidesToScroll:t.slidesToScroll,gap:t.gap}}),L=e.computed(()=>Math.max(1,Math.floor(Number.isFinite(M.value.slidesPerView)?M.value.slidesPerView:1))),O=e.computed(()=>Math.max(1,Math.floor(Number.isFinite(M.value.slidesToScroll)?M.value.slidesToScroll:1))),D=e.computed(()=>Math.max(0,Number.isFinite(M.value.gap)?M.value.gap:0)),q=e.computed(()=>Math.max(0,Math.floor(Number.isFinite(t.buffer)?t.buffer:0))),V=e.computed(()=>Math.max(0,Math.floor(Number.isFinite(t.loadMoreThreshold)?t.loadMoreThreshold:0))),k=e.computed(()=>Number.isFinite(t.autoplayDelay)?Math.max(1,t.autoplayDelay):3e3),_=e.computed(()=>{if(y.value<=0)return 0;const l=(L.value-1)*D.value;return Math.max(1,(y.value-l)/L.value)}),z=e.computed(()=>_.value+D.value),F=e.computed(()=>Math.max(0,t.items.length-L.value)),P=e.computed(()=>Math.max(0,s.value-q.value)),X=e.computed(()=>Math.min(t.items.length,s.value+L.value+q.value)),R=e.computed(()=>t.items.slice(P.value,X.value).map((l,o)=>({item:l,index:P.value+o}))),m=e.computed(()=>t.items.length===0?0:t.items.length*_.value+(t.items.length-1)*D.value),v=e.computed(()=>P.value*z.value),$=e.computed(()=>Math.max(0,m.value-X.value*z.value)),G=e.computed(()=>({height:re(t.height)}));function Z(l){return Math.min(F.value,Math.max(0,Math.floor(Number.isFinite(l)?l:0)))}s.value=Z(t.activeIndex);function te(l){return l>=s.value&&l<Math.min(t.items.length,s.value+L.value)}function U(){if(!t.hasMore||t.loading||K===t.items.length)return;const l=t.items.length===0?-1:Math.min(t.items.length-1,s.value+L.value-1);t.items.length-1-l<=V.value&&(K=t.items.length,x("loadMore"))}function le(l){const o=Z(l);o===s.value||t.items.length===0||(s.value=o,x("update:activeIndex",o),x("change",{index:o,item:t.items[o]}),o===0&&x("reachStart"),o===F.value&&x("reachEnd"),U(),t.autoplay&&!f.value&&a())}function Y(l,o={}){const i=h.value;i&&(typeof i.scrollTo=="function"?i.scrollTo({...o,left:l}):i.scrollLeft=l)}function J(l,o={}){if(t.items.length===0||z.value<=0)return;const i=Z(l);E=o.behavior==="smooth"?i:void 0,le(i),Y(i*z.value,{...o,behavior:o.behavior})}function p(l="smooth"){J(s.value+O.value,{behavior:l})}function g(l="smooth"){J(s.value-O.value,{behavior:l})}function a(){c(),!(!t.autoplay||t.items.length===0)&&(H=setTimeout(()=>{s.value>=F.value?t.autoplayLoop?J(0,{behavior:"smooth"}):c():p("smooth")},k.value))}function c(){H!==void 0&&(clearTimeout(H),H=void 0)}function u(){f.value=!0,t.pauseOnHover&&c()}function I(){f.value=!1,t.autoplay&&a()}function S(){E=void 0}function A(l){if(z.value<=0||C)return;const o=l.currentTarget.scrollLeft;if(E!==void 0){const i=E*z.value;if(Math.abs(o-i)>1)return;E=void 0}le(Math.round(o/z.value))}function Q(l){l.key==="ArrowRight"||l.key==="PageDown"?(l.preventDefault(),p()):l.key==="ArrowLeft"||l.key==="PageUp"?(l.preventDefault(),g()):l.key==="Home"?(l.preventDefault(),J(0,{behavior:"smooth"})):l.key==="End"&&(l.preventDefault(),J(F.value,{behavior:"auto"}))}function n(){var o;const l=((o=h.value)==null?void 0:o.clientWidth)??0;l<=0||l===T.value||(C=!0,T.value=l,e.nextTick(()=>{const i=Z(s.value);Y(i*z.value),C=!1}))}return e.watch(()=>t.activeIndex,async l=>{const o=Z(l);o!==s.value&&(S(),s.value=o,await e.nextTick(),Y(o*z.value),U())}),e.watch(()=>[t.items.length,M.value.slidesPerView,M.value.gap,M.value.slidesToScroll],async()=>{const l=Z(s.value);t.items.length===0?s.value!==0&&(s.value=0,x("update:activeIndex",0)):le(l),await e.nextTick(),Y(l*z.value),U(),t.autoplay&&t.items.length>0&&!f.value&&a()}),e.watch(()=>t.responsive,()=>{e.nextTick(()=>{const l=Z(s.value);Y(l*z.value)})},{deep:!0}),e.watch(()=>[t.hasMore,t.loading,t.loadMoreThreshold],async([l])=>{l||(K=-1),await e.nextTick(),U()}),e.watch(()=>t.autoplay,l=>{l&&!f.value?a():c()}),e.watch(()=>t.autoplayDelay,()=>{t.autoplay&&!f.value&&a()}),e.watch(()=>t.autoplayLoop,l=>{!t.autoplay||f.value||(!l&&s.value>=F.value?c():a())}),e.watch(()=>t.pauseOnHover,l=>{l&&f.value?c():!l&&t.autoplay&&a()}),e.onMounted(async()=>{n(),typeof ResizeObserver<"u"&&h.value&&(b=new ResizeObserver(n),b.observe(h.value)),await e.nextTick(),Y(s.value*z.value),U(),t.autoplay&&a()}),e.onBeforeUnmount(()=>{b&&(b.disconnect(),b=void 0),c()}),N({next:p,previous:g,scrollToIndex:J,startAutoplay:a,stopAutoplay:c}),(l,o)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:h,class:"vue-virtual-carousel",style:e.normalizeStyle(G.value),role:"region","aria-roledescription":"carousel","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:A,onPointerdown:S,onWheelPassive:S,onKeydown:Q,onMouseenter:u,onMouseleave:I},[r.items.length?(e.openBlock(),e.createElementBlock("div",Ee,[v.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-virtual-carousel__spacer",style:e.normalizeStyle({flexBasis:`${v.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(R.value,({item:i,index:d})=>(e.openBlock(),e.createElementBlock("div",{key:e.unref(B)(i,d),class:"vue-virtual-carousel__item",style:e.normalizeStyle({flexBasis:`${_.value}px`,marginRight:d<r.items.length-1?`${D.value}px`:"0px"}),role:"listitem","aria-roledescription":"slide","aria-label":`${d+1} of ${r.items.length}`,"aria-current":d===s.value?"true":void 0},[e.renderSlot(l.$slots,"default",{item:i,index:d,active:d===s.value,visible:te(d)})],12,Ve))),128)),$.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-virtual-carousel__spacer",style:e.normalizeStyle({flexBasis:`${$.value}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",$e,[e.renderSlot(l.$slots,"empty")]))],44,Ie))}}),He=["aria-label"],Le=["aria-posinset","aria-setsize"],ve=e.defineComponent({name:"VirtualScroll",__name:"VirtualScroll",props:{items:{},itemSize:{},height:{default:400},overscan:{default:3},itemKey:{default:void 0},ariaLabel:{default:"Virtual list"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadingItemSize:{default:void 0},loadMoreThreshold:{default:200},pullToRefresh:{type:Boolean,default:!1},refreshing:{type:Boolean,default:!1},pullRefreshThreshold:{default:64}},emits:["scroll","loadMore","refresh"],setup(r,{expose:N,emit:w}){const t=r,x=w,{pulling:h,pullDistance:T,pullOffset:s,pullProgress:b,refreshMessage:K,refreshThreshold:H,handleTouchStart:E,handleTouchMove:C,handleTouchEnd:f,handleTouchCancel:B}=ue({enabled:()=>t.pullToRefresh,refreshing:()=>t.refreshing,threshold:()=>t.pullRefreshThreshold,onRefresh:()=>x("refresh")}),y=e.ref(),M=e.ref(0),L=e.ref(0);let O,D=-1;const q=ie(),{getItemKey:V}=ae({componentName:"VirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),k=e.computed(()=>Math.max(1,t.itemSize)),_=e.computed(()=>Math.max(0,Math.floor(t.overscan))),z=e.computed(()=>t.items.length*k.value),F=e.computed(()=>Math.max(1,t.loadingItemSize??k.value)),P=e.computed(()=>z.value+(t.loading?F.value:0)),X=e.computed(()=>L.value>0?L.value:typeof t.height=="number"?t.height:0),R=e.computed(()=>Math.max(0,Math.floor(M.value/k.value)-_.value)),m=e.computed(()=>{const p=Math.ceil((M.value+X.value)/k.value);return Math.min(t.items.length,p+_.value)}),v=e.computed(()=>t.items.slice(R.value,m.value).map((p,g)=>({item:p,index:R.value+g}))),$=e.computed(()=>({height:re(t.height)})),G=e.computed(()=>({transform:`translateY(${R.value*k.value}px)`}));function Z(){var p;L.value=((p=y.value)==null?void 0:p.clientHeight)??0,q(y.value,t.height),e.nextTick(U)}function te(p){M.value=p.currentTarget.scrollTop,x("scroll",{scrollTop:M.value,startIndex:R.value,endIndex:m.value}),U()}function U(){const p=y.value;if(!p||!t.hasMore||t.loading||D===t.items.length)return;const g=Math.max(0,t.loadMoreThreshold);P.value-p.scrollTop-p.clientHeight<=g&&(D=t.items.length,x("loadMore"))}function le(p,g={}){const a=y.value;if(!a)return;const c=Math.max(0,P.value-a.clientHeight),u=Math.min(Math.max(0,Number.isFinite(p)?p:0),c),I=g.behavior??"auto";I==="auto"&&(M.value=u),a.scrollTo({...g,top:u,behavior:I})}function Y(p,g={}){const a=y.value;if(!a||t.items.length===0)return;const c=Math.min(t.items.length-1,Math.max(0,Math.floor(p))),{align:u="start",...I}=g;let S=c*k.value;u==="center"?S-=(a.clientHeight-k.value)/2:u==="end"&&(S-=a.clientHeight-k.value),a.scrollTo({...I,top:Math.max(0,Math.min(S,P.value-a.clientHeight))})}function J(p="auto"){var g;(g=y.value)==null||g.scrollTo({top:0,behavior:p})}return e.watch(()=>[t.items.length,t.itemSize],async()=>{await e.nextTick();const p=y.value;if(!p)return;const g=Math.max(0,P.value-p.clientHeight);p.scrollTop>g&&(p.scrollTop=g,M.value=g),U()}),e.watch(()=>[t.hasMore,t.loading],async([p])=>{p||(D=-1),await e.nextTick(),U()}),e.onMounted(()=>{Z(),typeof ResizeObserver<"u"&&y.value&&(O=new ResizeObserver(Z),O.observe(y.value)),e.nextTick(U)}),e.onBeforeUnmount(()=>{O&&(O.disconnect(),O=void 0)}),N({scrollTo:le,scrollToIndex:Y,scrollToTop:J}),(p,g)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"viewport",ref:y,class:e.normalizeClass(["vue-virtual-scroll",{"vue-virtual-scroll--pulling":e.unref(h)}]),style:e.normalizeStyle($.value),role:"list","aria-label":r.ariaLabel,tabindex:"0",onScrollPassive:te,onTouchstartPassive:g[0]||(g[0]=(...a)=>e.unref(E)&&e.unref(E)(...a)),onTouchmove:g[1]||(g[1]=(...a)=>e.unref(C)&&e.unref(C)(...a)),onTouchend:g[2]||(g[2]=(...a)=>e.unref(f)&&e.unref(f)(...a)),onTouchcancel:g[3]||(g[3]=(...a)=>e.unref(B)&&e.unref(B)(...a))},[r.pullToRefresh||r.refreshing?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-virtual-scroll__refresh",style:e.normalizeStyle({height:`${e.unref(H)}px`,transform:`translateY(${e.unref(s)-e.unref(H)}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(p.$slots,"refresh",{pullDistance:e.unref(T),progress:e.unref(b),refreshing:r.refreshing},()=>[e.createTextVNode(e.toDisplayString(e.unref(K)),1)])],4)):e.createCommentVNode("",!0),r.items.length||r.loading?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-virtual-scroll__spacer",style:e.normalizeStyle({height:`${P.value}px`,transform:`translateY(${e.unref(s)}px)`})},[e.createElementVNode("div",{class:"vue-virtual-scroll__content",style:e.normalizeStyle(G.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,({item:a,index:c})=>(e.openBlock(),e.createElementBlock("div",{key:e.unref(V)(a,c),class:"vue-virtual-scroll__item",style:e.normalizeStyle({height:`${k.value}px`}),role:"listitem","aria-posinset":c+1,"aria-setsize":r.items.length},[e.renderSlot(p.$slots,"default",{item:a,index:c})],12,Le))),128))],4),r.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-virtual-scroll__loading",style:e.normalizeStyle({height:`${F.value}px`,transform:`translateY(${z.value}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(p.$slots,"loading",{},()=>[g[4]||(g[4]=e.createTextVNode("Loading more…",-1))])],4)):e.createCommentVNode("",!0)],4)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"vue-virtual-scroll__empty",style:e.normalizeStyle({transform:`translateY(${e.unref(s)}px)`})},[e.renderSlot(p.$slots,"empty")],4))],46,He))}}),Ce=["aria-label"],Ke=["aria-posinset","aria-setsize"],he=e.defineComponent({name:"WindowDynamicVirtualScroll",__name:"WindowDynamicVirtualScroll",props:{items:{},estimatedItemSize:{default:48},overscan:{default:3},itemKey:{default:void 0},ariaLabel:{default:"Window dynamic virtual list"},hasMore:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},loadingItemSize:{default:void 0},loadMoreThreshold:{default:200},pullToRefresh:{type:Boolean,default:!1},refreshing:{type:Boolean,default:!1},pullRefreshThreshold:{default:64}},emits:["scroll","loadMore","refresh"],setup(r,{expose:N,emit:w}){const t=r,x=w,h=e.ref(),T=e.ref(0),s=e.ref(0),b=e.ref(0),K=e.ref(0),H=new Map,E=new Map;let C,f,B=-1;const{getItemKey:y}=ae({componentName:"WindowDynamicVirtualScroll",items:()=>t.items,itemKey:()=>t.itemKey}),{pulling:M,pullDistance:L,pullOffset:O,pullProgress:D,refreshMessage:q,refreshThreshold:V,handleTouchStart:k,handleTouchMove:_,handleTouchEnd:z,handleTouchCancel:F}=ue({enabled:()=>t.pullToRefresh,refreshing:()=>t.refreshing,threshold:()=>t.pullRefreshThreshold,onRefresh:()=>x("refresh"),scrollTop:()=>typeof window>"u"?0:Math.max(0,window.scrollY)}),P=e.computed(()=>Math.max(1,t.estimatedItemSize)),X=e.computed(()=>Math.max(1,t.loadingItemSize??P.value)),R=e.computed(()=>Math.max(0,Math.floor(t.overscan))),m=e.computed(()=>{K.value;const n=new Array(t.items.length+1),l=new Array(t.items.length);n[0]=0;for(let o=0;o<t.items.length;o+=1){const i=y(t.items[o],o),d=H.get(i)??P.value;l[o]=d,n[o+1]=n[o]+d}return{offsets:n,sizes:l,total:n[t.items.length]??0}}),v=e.computed(()=>m.value.total+(t.loading?X.value:0)),$=e.computed(()=>{const n=new Map;return t.items.forEach((l,o)=>{n.set(y(l,o),o)}),n}),G=e.computed(()=>Math.max(0,T.value-b.value));function Z(n){if(t.items.length===0)return 0;const l=m.value.offsets;let o=0,i=t.items.length;for(;o<i;){const d=Math.floor((o+i)/2);l[d+1]<=n?o=d+1:i=d}return Math.min(o,t.items.length-1)}const te=e.computed(()=>Math.max(0,Z(G.value)-R.value)),U=e.computed(()=>{if(t.items.length===0)return 0;const n=T.value+s.value-b.value,l=Math.max(P.value,n),o=Z(l)+1;return Math.min(t.items.length,o+R.value)}),le=e.computed(()=>t.items.slice(te.value,U.value).map((n,l)=>{const o=te.value+l;return{item:n,index:o,key:y(n,o),top:m.value.offsets[o]}}));function Y(){typeof window>"u"||(T.value=Math.max(0,window.scrollY),s.value=window.innerHeight,h.value&&(b.value=h.value.getBoundingClientRect().top+T.value))}function J(){x("scroll",{scrollTop:G.value,startIndex:te.value,endIndex:U.value})}function p(){Y(),J(),g()}function g(){if(typeof window>"u"||!t.hasMore||t.loading||B===t.items.length)return;const n=Math.max(0,t.loadMoreThreshold),l=b.value+v.value,o=T.value+s.value;l-o<=n&&(B=t.items.length,x("loadMore"))}function a(n){const l=n.borderBoxSize;if(l){const o=Array.isArray(l)?l[0]:l;if(o!=null&&o.blockSize)return o.blockSize}return n.contentRect.height}function c(n){const l=m.value;let o=0,i=!1;for(const d of n){const j=d.target,W=E.get(j),ee=a(d);if(W===void 0||ee<=0)continue;const oe=H.get(W)??P.value;if(Math.abs(oe-ee)<.5)continue;const ne=$.value.get(W);ne!==void 0&&l.offsets[ne+1]<=G.value&&(o+=ee-oe),H.set(W,ee),i=!0}i&&(K.value+=1,e.nextTick(()=>{if(o!==0&&typeof window<"u"){const d=Math.max(0,T.value+o);T.value=d,window.scrollTo({top:d,behavior:"auto"})}Y(),g()}))}function u(n,l){n instanceof HTMLElement&&(E.set(n,l),f==null||f.observe(n))}function I(){for(const[n]of E)n.isConnected||(f==null||f.unobserve(n),E.delete(n))}function S(n,l={}){if(typeof window>"u")return;Y();const o=Math.max(0,v.value-s.value),i=Math.min(Math.max(0,Number.isFinite(n)?n:0),o),d=Math.max(0,b.value+i),j=l.behavior??"auto";j==="auto"&&(T.value=d),window.scrollTo({...l,top:d,behavior:j})}function A(n,l={}){if(typeof window>"u"||t.items.length===0)return;Y();const o=Math.min(t.items.length-1,Math.max(0,Math.floor(n))),{align:i="start",...d}=l,j=m.value.sizes[o];let W=b.value+m.value.offsets[o];i==="center"?W-=(s.value-j)/2:i==="end"&&(W-=s.value-j);const ee=Math.max(b.value,b.value+v.value-s.value),oe=Math.max(0,Math.min(W,ee)),ne=d.behavior??"auto";ne==="auto"&&(T.value=oe),window.scrollTo({...d,top:oe,behavior:ne})}function Q(n="auto"){typeof window>"u"||(Y(),window.scrollTo({top:Math.max(0,b.value),behavior:n}))}return e.watch(()=>t.itemKey,()=>{H.clear(),K.value+=1}),e.watch(()=>t.items.length,async()=>{const n=new Set(t.items.map((l,o)=>y(l,o)));for(const l of H.keys())n.has(l)||H.delete(l);K.value+=1,await e.nextTick(),Y(),g()}),e.watch(()=>[t.hasMore,t.loading],async([n])=>{n||(B=-1),await e.nextTick(),Y(),g()}),e.onMounted(()=>{if(Y(),window.addEventListener("scroll",p,{passive:!0}),window.addEventListener("resize",p,{passive:!0}),typeof ResizeObserver<"u"){C=new ResizeObserver(()=>{Y(),g()}),f=new ResizeObserver(c),h.value&&C.observe(h.value);for(const[n]of E)f.observe(n)}e.nextTick(g)}),e.onUpdated(I),e.onBeforeUnmount(()=>{window.removeEventListener("scroll",p),window.removeEventListener("resize",p),C&&(C.disconnect(),C=void 0),f&&(f.disconnect(),f=void 0),E.clear()}),N({scrollTo:S,scrollToIndex:A,scrollToTop:Q}),(n,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"root",ref:h,class:e.normalizeClass(["vue-window-dynamic-virtual-scroll",{"vue-window-dynamic-virtual-scroll--pulling":e.unref(M)}]),role:"list","aria-label":r.ariaLabel,onTouchstartPassive:l[0]||(l[0]=(...o)=>e.unref(k)&&e.unref(k)(...o)),onTouchmove:l[1]||(l[1]=(...o)=>e.unref(_)&&e.unref(_)(...o)),onTouchend:l[2]||(l[2]=(...o)=>e.unref(z)&&e.unref(z)(...o)),onTouchcancel:l[3]||(l[3]=(...o)=>e.unref(F)&&e.unref(F)(...o))},[r.pullToRefresh||r.refreshing?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-window-dynamic-virtual-scroll__refresh",style:e.normalizeStyle({height:`${e.unref(V)}px`,transform:`translateY(${e.unref(O)-e.unref(V)}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(n.$slots,"refresh",{pullDistance:e.unref(L),progress:e.unref(D),refreshing:r.refreshing},()=>[e.createTextVNode(e.toDisplayString(e.unref(q)),1)])],4)):e.createCommentVNode("",!0),r.items.length||r.loading?(e.openBlock(),e.createElementBlock("div",{key:1,class:"vue-window-dynamic-virtual-scroll__spacer",style:e.normalizeStyle({height:`${v.value}px`,transform:`translateY(${e.unref(O)}px)`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(le.value,({item:o,index:i,key:d,top:j})=>(e.openBlock(),e.createElementBlock("div",{key:d,ref_for:!0,ref:W=>u(W,d),class:"vue-window-dynamic-virtual-scroll__item",style:e.normalizeStyle({transform:`translateY(${j}px)`}),role:"listitem","aria-posinset":i+1,"aria-setsize":r.items.length},[e.renderSlot(n.$slots,"default",{item:o,index:i})],12,Ke))),128)),r.loading?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vue-window-dynamic-virtual-scroll__loading",style:e.normalizeStyle({height:`${X.value}px`,transform:`translateY(${m.value.total}px)`}),role:"status","aria-live":"polite"},[e.renderSlot(n.$slots,"loading",{},()=>[l[4]||(l[4]=e.createTextVNode("Loading more…",-1))])],4)):e.createCommentVNode("",!0)],4)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"vue-window-dynamic-virtual-scroll__empty",style:e.normalizeStyle({transform:`translateY(${e.unref(O)}px)`})},[e.renderSlot(n.$slots,"empty")],4))],42,Ce))}}),pe=ce,ge={install(r){r.component("ChatVirtualScroll",de),r.component("DynamicVirtualScroll",ce),r.component("ShortMediaFeed",me),r.component("VirtualCarousel",fe),r.component("VirtualList",pe),r.component("VirtualScroll",ve),r.component("WindowDynamicVirtualScroll",he)}};exports.ChatVirtualScroll=de;exports.DynamicVirtualScroll=ce;exports.ShortMediaFeed=me;exports.VirtualCarousel=fe;exports.VirtualList=pe;exports.VirtualScroll=ve;exports.VueVirtualScroll=ge;exports.WindowDynamicVirtualScroll=he;exports.default=ge;