import{I as e,N as t,P as n,Q as r,b as i,g as a,j as o,m as s,x as c,yt as l,z as u}from"./vue.runtime.esm-bundler-DS0mm12S.js";import{_ as d}from"./Teleport-CHY6zPT-.js";import{i as f}from"./button-DQxx5HZh.js";import{o as p}from"./PopperContent-uFA7BIqu.js";import{a as m,i as h,n as g,r as _}from"./RovingFocusGroup-CKCavvZ9.js";var v=c({__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(c){let v=c,y=g(),b=d(),x=s(()=>v.tabStopId||b),S=s(()=>y.currentTabStopId.value===x.value),{getItems:C,CollectionItem:w}=p();t(()=>{v.focusable&&y.onFocusableItemAdd()}),n(()=>{v.focusable&&y.onFocusableItemRemove()});function T(e){if(e.key===`Tab`&&e.shiftKey){y.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=h(e,y.orientation.value,y.dir.value);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||!v.allowShiftKey&&e.shiftKey)return;e.preventDefault();let n=[...C().map(e=>e.ref).filter(e=>e.dataset.disabled!==``)];if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=y.loop.value?m(n,r+1):n.slice(r+1)}o(()=>_(n))}}return(t,n)=>(e(),a(l(w),null,{default:r(()=>[i(l(f),{tabindex:S.value?0:-1,"data-orientation":l(y).orientation.value,"data-active":t.active?``:void 0,"data-disabled":t.focusable?void 0:``,as:t.as,"as-child":t.asChild,onMousedown:n[0]||=e=>{t.focusable?l(y).onItemFocus(x.value):e.preventDefault()},onFocus:n[1]||=e=>l(y).onItemFocus(x.value),onKeydown:T},{default:r(()=>[u(t.$slots,`default`)]),_:3},8,[`tabindex`,`data-orientation`,`data-active`,`data-disabled`,`as`,`as-child`])]),_:3}))}});export{v as t};