import{o as b,u as L}from"./keyboard.APPKPqkQ.js";import{C as P,Y as y,r as S,A}from"./entry.DV6a5_Hb.js";var I=Object.defineProperty,M=(e,t,n)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t,n)=>(M(e,typeof t!="symbol"?t+"":t,n),n);class O{constructor(){p(this,"current",this.detect()),p(this,"currentId",0)}set(t){this.current!==t&&(this.currentId=0,this.current=t)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}}let E=new O;function g(e){if(E.isServer)return null;if(e instanceof Node)return e.ownerDocument;if(e!=null&&e.hasOwnProperty("value")){let t=b(e);if(t)return t.ownerDocument}return document}let h=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var T=(e=>(e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll",e))(T||{}),$=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))($||{}),D=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(D||{});function N(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(h)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}var x=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(x||{});function F(e,t=0){var n;return e===((n=g(e))==null?void 0:n.body)?!1:L(t,{0(){return e.matches(h)},1(){let u=e;for(;u!==null;){if(u.matches(h))return!0;u=u.parentElement}return!1}})}function q(e){let t=g(e);P(()=>{t&&!F(t.activeElement,0)&&k(e)})}var _=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(_||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function k(e){e==null||e.focus({preventScroll:!0})}let C=["textarea","input"].join(",");function K(e){var t,n;return(n=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,C))!=null?n:!1}function G(e,t=n=>n){return e.slice().sort((n,u)=>{let a=t(n),r=t(u);if(a===null||r===null)return 0;let i=a.compareDocumentPosition(r);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function Y(e,t){return H(N(),t,{relativeTo:e})}function H(e,t,{sorted:n=!0,relativeTo:u=null,skipElements:a=[]}={}){var r;let i=(r=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e==null?void 0:e.ownerDocument)!=null?r:document,o=Array.isArray(e)?n?G(e):e:N(e);a.length>0&&o.length>1&&(o=o.filter(c=>!a.includes(c))),u=u??i.activeElement;let w=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),s=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,o.indexOf(u))-1;if(t&4)return Math.max(0,o.indexOf(u))+1;if(t&8)return o.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),l=t&32?{preventScroll:!0}:{},m=0,f=o.length,d;do{if(m>=f||m+f<=0)return 0;let c=s+m;if(t&16)c=(c+f)%f;else{if(c<0)return 3;if(c>=f)return 1}d=o[c],d==null||d.focus(l),m+=w}while(d!==i.activeElement);return t&6&&K(d)&&d.select(),2}function R(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function U(){return/Android/gi.test(window.navigator.userAgent)}function j(){return R()||U()}function v(e,t,n){E.isServer||y(u=>{document.addEventListener(e,t,n),u(()=>document.removeEventListener(e,t,n))})}function V(e,t,n){E.isServer||y(u=>{window.addEventListener(e,t,n),u(()=>window.removeEventListener(e,t,n))})}function z(e,t,n=A(()=>!0)){function u(r,i){if(!n.value||r.defaultPrevented)return;let o=i(r);if(o===null||!o.getRootNode().contains(o))return;let w=function s(l){return typeof l=="function"?s(l()):Array.isArray(l)||l instanceof Set?l:[l]}(e);for(let s of w){if(s===null)continue;let l=s instanceof HTMLElement?s:b(s);if(l!=null&&l.contains(o)||r.composed&&r.composedPath().includes(l))return}return!F(o,x.Loose)&&o.tabIndex!==-1&&r.preventDefault(),t(r,o)}let a=S(null);v("pointerdown",r=>{var i,o;n.value&&(a.value=((o=(i=r.composedPath)==null?void 0:i.call(r))==null?void 0:o[0])||r.target)},!0),v("mousedown",r=>{var i,o;n.value&&(a.value=((o=(i=r.composedPath)==null?void 0:i.call(r))==null?void 0:o[0])||r.target)},!0),v("click",r=>{j()||a.value&&(u(r,()=>a.value),a.value=null)},!0),v("touchend",r=>u(r,()=>r.target instanceof HTMLElement?r.target:null),!0),V("blur",r=>u(r,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}export{T as N,G as O,H as P,k as S,$ as T,q as _,z as a,F as b,E as c,x as h,g as i,R as t,Y as v,V as w};