import{S as p}from"./DT-hKSom.js";import{c as T}from"./b1l8QPBl.js";import{r as m,s as v,M as C,d,ah as I,O as E,E as N,Q as O,N as x}from"./m2W8DxR4.js";import{g as A}from"./COA9s1yS.js";function w(){const e=m(),r=v(()=>{var o,t;return["#text","#comment"].includes((o=e.value)==null?void 0:o.$el.nodeName)?(t=e.value)==null?void 0:t.$el.nextElementSibling:T(e)});return{primitiveElement:e,currentElement:r}}const g="data-reka-collection-item";function L(e={}){const{key:r="",isProvider:o=!1}=e,t=`${r}CollectionProvider`;let n;if(o){const s=m(new Map);n={collectionRef:m(),itemMap:s},O(t,n)}else n=C(t);const M=(s=!1)=>{const i=n.collectionRef.value;if(!i)return[];const l=Array.from(i.querySelectorAll(`[${g}]`)),a=Array.from(n.itemMap.value.values()).sort((u,f)=>l.indexOf(u.ref)-l.indexOf(f.ref));return s?a:a.filter(u=>u.ref.dataset.disabled!=="")},R=d({name:"CollectionSlot",setup(s,{slots:i}){const{primitiveElement:l,currentElement:c}=w();return N(c,()=>{n.collectionRef.value=c.value}),()=>E(p,{ref:l},i)}}),S=d({name:"CollectionItem",inheritAttrs:!1,props:{value:{validator:()=>!0}},setup(s,{slots:i,attrs:l}){const{primitiveElement:c,currentElement:a}=w();return I(u=>{if(a.value){const f=x(a.value);n.itemMap.value.set(f,{ref:a.value,value:s.value}),u(()=>n.itemMap.value.delete(f))}}),()=>E(p,{...l,[g]:"",ref:c},i)}}),_=v(()=>Array.from(n.itemMap.value.values())),h=v(()=>n.itemMap.value.size);return{getItems:M,reactiveItems:_,itemMapSize:h,CollectionSlot:R,CollectionItem:S}}const $="rovingFocusGroup.onEntryFocus",k={bubbles:!1,cancelable:!0},P={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function b(e,r){return r!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function z(e,r,o){const t=b(e.key,o);if(!(r==="vertical"&&["ArrowLeft","ArrowRight"].includes(t))&&!(r==="horizontal"&&["ArrowUp","ArrowDown"].includes(t)))return P[t]}function K(e,r=!1){const o=A();for(const t of e)if(t===o||(t.focus({preventScroll:r}),A()!==o))return}function Y(e,r){return e.map((o,t)=>e[(r+t)%e.length])}export{$ as E,L as a,k as b,K as f,z as g,w as u,Y as w};
