import{g as x}from"./COA9s1yS.js";import{e as p}from"./b1l8QPBl.js";function I(t){const e=p("",1e3);return{search:e,handleTypeaheadSearch:(c,i)=>{e.value=e.value+c;{const s=x(),f=i.map(a=>{var h,E;return{...a,textValue:((h=a.value)==null?void 0:h.textValue)??((E=a.ref.textContent)==null?void 0:E.trim())??""}}),r=f.find(a=>a.ref===s),o=f.map(a=>a.textValue),d=T(o,e.value,r==null?void 0:r.textValue),l=f.find(a=>a.textValue===d);return l&&l.ref.focus(),l==null?void 0:l.ref}},resetTypeahead:()=>{e.value=""}}}function m(t,e){return t.map((n,u)=>t[(e+u)%t.length])}function T(t,e,n){const c=e.length>1&&Array.from(e).every(o=>o===e[0])?e[0]:e,i=n?t.indexOf(n):-1;let s=m(t,Math.max(i,0));c.length===1&&(s=s.filter(o=>o!==n));const r=s.find(o=>o.toLowerCase().startsWith(c.toLowerCase()));return r!==n?r:void 0}const _="menu.itemSelect",S=["Enter"," "],A=["ArrowDown","PageUp","Home"],L=["ArrowUp","PageDown","End"],v=[...A,...L];[...S],[...S];function C(t){return t?"open":"closed"}function V(t){const e=x();for(const n of t)if(n===e||(n.focus(),x()!==e))return}function g(t,e){const{x:n,y:u}=t;let c=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){const f=e[i].x,r=e[i].y,o=e[s].x,d=e[s].y;r>u!=d>u&&n<(o-f)*(u-r)/(d-r)+f&&(c=!c)}return c}function P(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return g(n,e)}function R(t){return t.pointerType==="mouse"}export{v as F,_ as I,L,S,R as a,V as f,C as g,P as i,I as u};
