import{d as m,bH as I,I as y,h as g,G as F,H as h,o as K,a as S,p as l,B as C,s as n,P as q,q as w,c as u,y as B,bI as T,n as R,bJ as x}from"./B3fabVUf.js";var _=m({__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=I(),f=y(),i=u(()=>r.tabStopId||f),c=u(()=>a.currentTabStopId.value===i.value),{getItems:p,CollectionItem:v}=g();F(()=>{r.focusable&&a.onFocusableItemAdd()}),h(()=>{r.focusable&&a.onFocusableItemRemove()});function b(e){if(e.key==="Tab"&&e.shiftKey){a.onItemShiftTab();return}if(e.target!==e.currentTarget)return;const t=B(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?T(o,s+1):o.slice(s+1)}R(()=>x(o))}}return(e,t)=>(K(),S(n(v),null,{default:l(()=>[C(n(q),{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:b},{default:l(()=>[w(e.$slots,"default")]),_:3},8,["tabindex","data-orientation","data-active","data-disabled","as","as-child"])]),_:3}))}}),A=_;export{A as R};
