const e=require(`./chunk-BcutgqC9.cjs`),t=require(`./dist-B9QvvA-B.cjs`),n=require(`./dist-C1zbYA0G.cjs`),r=require(`./dist-DgPcEpUT.cjs`),i=require(`./dist-CkjbCwvg.cjs`),a=require(`./dist-DY0ggDuW.cjs`),o=require(`./dist-Cq9XeNB7.cjs`);let s=require(`react`);s=e.n(s,1);let c=require(`react/jsx-runtime`);var l=`rovingFocusGroup.onEntryFocus`,u={bubbles:!1,cancelable:!0},d=`RovingFocusGroup`,[f,p,m]=r.t(d),[h,g]=t.a(d,[m]),[_,v]=h(d),y=s.forwardRef((e,t)=>(0,c.jsx)(f.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,c.jsx)(f.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,c.jsx)(b,{...e,ref:t})})}));y.displayName=d;var b=s.forwardRef((e,r)=>{let{__scopeRovingFocusGroup:i,orientation:f,loop:m=!1,dir:h,currentTabStopId:g,defaultCurrentTabStopId:v,onCurrentTabStopIdChange:y,onEntryFocus:b,preventScrollOnEntryFocus:x=!1,...S}=e,C=s.useRef(null),w=n.o(r,C),T=a.t(h),[D,O]=t.t({prop:g,defaultProp:v??null,onChange:y,caller:d}),[k,A]=s.useState(!1),j=o.t(b),M=p(i),N=s.useRef(!1),[P,F]=s.useState(0);return s.useEffect(()=>{let e=C.current;if(e)return e.addEventListener(l,j),()=>e.removeEventListener(l,j)},[j]),(0,c.jsx)(_,{scope:i,orientation:f,dir:T,loop:m,currentTabStopId:D,onItemFocus:s.useCallback(e=>O(e),[O]),onItemShiftTab:s.useCallback(()=>A(!0),[]),onFocusableItemAdd:s.useCallback(()=>F(e=>e+1),[]),onFocusableItemRemove:s.useCallback(()=>F(e=>e-1),[]),children:(0,c.jsx)(n.t.div,{tabIndex:k||P===0?-1:0,"data-orientation":f,...S,ref:w,style:{outline:`none`,...e.style},onMouseDown:t.r(e.onMouseDown,()=>{N.current=!0}),onFocus:t.r(e.onFocus,e=>{let t=!N.current;if(e.target===e.currentTarget&&t&&!k){let t=new CustomEvent(l,u);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=M().filter(e=>e.focusable);E([e.find(e=>e.active),e.find(e=>e.id===D),...e].filter(Boolean).map(e=>e.ref.current),x)}}N.current=!1}),onBlur:t.r(e.onBlur,()=>A(!1))})})}),x=`RovingFocusGroupItem`,S=s.forwardRef((e,r)=>{let{__scopeRovingFocusGroup:a,focusable:o=!0,active:l=!1,tabStopId:u,children:d,...m}=e,h=i.t(),g=u||h,_=v(x,a),y=_.currentTabStopId===g,b=p(a),{onFocusableItemAdd:S,onFocusableItemRemove:C,currentTabStopId:w}=_;return s.useEffect(()=>{if(o)return S(),()=>C()},[o,S,C]),(0,c.jsx)(f.ItemSlot,{scope:a,id:g,focusable:o,active:l,children:(0,c.jsx)(n.t.span,{tabIndex:y?0:-1,"data-orientation":_.orientation,...m,ref:r,onMouseDown:t.r(e.onMouseDown,e=>{o?_.onItemFocus(g):e.preventDefault()}),onFocus:t.r(e.onFocus,()=>_.onItemFocus(g)),onKeyDown:t.r(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){_.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=T(e,_.orientation,_.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=b().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=_.loop?D(n,r+1):n.slice(r+1)}setTimeout(()=>E(n))}}),children:typeof d==`function`?d({isCurrentTabStop:y,hasTabStop:w!=null}):d})})});S.displayName=x;var C={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function w(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function T(e,t,n){let r=w(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return C[r]}function E(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function D(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var O=y,k=S;Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return k}});
//# sourceMappingURL=dist-CMa749p1.cjs.map