import{r as h,aC as p,aD as l}from"./Dih1Xbo1.js";function w(v){const{isFocused:u,items:a,onSelect:o,onSubmit:n,onEscape:t}=v,e=h(-1),{arrowup:s,arrowdown:i,enter:r,escape:c}=p();l(s,()=>{u.value&&a.value.length>0&&(e.value=e.value<=0?a.value.length-1:e.value-1)}),l(i,()=>{u.value&&a.value.length>0&&(e.value=e.value>=a.value.length-1?0:e.value+1)}),l(r,()=>{u.value&&(e.value>=0&&a.value[e.value]?o(a.value[e.value],e.value):n&&n())}),l(c,()=>{u.value&&t&&t()});function f(){e.value=-1}function g(d){e.value=d}return{selectedIndex:e,resetSelection:f,setSelection:g}}export{w as u};
