import{e as b,ae as y,x as l,l as I,a2 as g,m as F,o as w,w as u,b as K,n,ac as S,X as h,am as C}from"./BoB2h2qv.js";import{i as T,u as q,g as x,w as B,f as R}from"./iebCrZCv.js";var _=b({__name:"RovingFocusItem",props:{tabStopId:{type:String,required:!1},focusable:{type:Boolean,required:!1,default:!0},active:{type:Boolean,required:!1},allowShiftKey:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(d){const r=d,a=T(),f=y(),i=l(()=>r.tabStopId||f),c=l(()=>a.currentTabStopId.value===i.value),{getItems:p,CollectionItem:m}=q();I(()=>{r.focusable&&a.onFocusableItemAdd()}),g(()=>{r.focusable&&a.onFocusableItemRemove()});function v(e){if(e.key==="Tab"&&e.shiftKey){a.onItemShiftTab();return}if(e.target!==e.currentTarget)return;const t=x(e,a.orientation.value,a.dir.value);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||!r.allowShiftKey&&e.shiftKey)return;e.preventDefault();let o=[...p().map(s=>s.ref).filter(s=>s.dataset.disabled!=="")];if(t==="last")o.reverse();else if(t==="prev"||t==="next"){t==="prev"&&o.reverse();const s=o.indexOf(e.currentTarget);o=a.loop.value?B(o,s+1):o.slice(s+1)}C(()=>R(o))}}return(e,t)=>(w(),F(n(m),null,{default:u(()=>[K(n(S),{tabindex:c.value?0:-1,"data-orientation":n(a).orientation.value,"data-active":e.active?"":void 0,"data-disabled":e.focusable?void 0:"",as:e.as,"as-child":e.asChild,onMousedown:t[0]||(t[0]=o=>{e.focusable?n(a).onItemFocus(i.value):o.preventDefault()}),onFocus:t[1]||(t[1]=o=>n(a).onItemFocus(i.value)),onKeydown:v},{default:u(()=>[h(e.$slots,"default")]),_:3},8,["tabindex","data-orientation","data-active","data-disabled","as","as-child"])]),_:3}))}}),D=_;export{D as R};
