import{c as p,o as h,u as x}from"./DGBS_YNV.js";import{Y as y,e as g,r as L,B as F}from"./CChoqk00.js";function b(e){if(p.isServer)return null;if(e instanceof Node)return e.ownerDocument;if(e!=null&&e.hasOwnProperty("value")){let t=h(e);if(t)return t.ownerDocument}return document}let E=["[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 S=(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))(S||{}),T=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(T||{}),D=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(D||{});function A(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(E)).sort((t,r)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(r.tabIndex||Number.MAX_SAFE_INTEGER)))}var N=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(N||{});function P(e,t=0){var r;return e===((r=b(e))==null?void 0:r.body)?!1:x(t,{0(){return e.matches(E)},1(){let u=e;for(;u!==null;){if(u.matches(E))return!0;u=u.parentElement}return!1}})}function V(e){let t=b(e);y(()=>{t&&!P(t.activeElement,0)&&O(e)})}var M=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(M||{});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 O(e){e==null||e.focus({preventScroll:!0})}let I=["textarea","input"].join(",");function _(e){var t,r;return(r=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,I))!=null?r:!1}function U(e,t=r=>r){return e.slice().sort((r,u)=>{let a=t(r),n=t(u);if(a===null||n===null)return 0;let i=a.compareDocumentPosition(n);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function W(e,t){return $(A(),t,{relativeTo:e})}function $(e,t,{sorted:r=!0,relativeTo:u=null,skipElements:a=[]}={}){var n;let i=(n=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e==null?void 0:e.ownerDocument)!=null?n:document,o=Array.isArray(e)?r?U(e):e:A(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&&_(d)&&d.select(),2}function k(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function H(){return/Android/gi.test(window.navigator.userAgent)}function R(){return k()||H()}function v(e,t,r){p.isServer||g(u=>{document.addEventListener(e,t,r),u(()=>document.removeEventListener(e,t,r))})}function K(e,t,r){p.isServer||g(u=>{window.addEventListener(e,t,r),u(()=>window.removeEventListener(e,t,r))})}function j(e,t,r=F(()=>!0)){function u(n,i){if(!r.value||n.defaultPrevented)return;let o=i(n);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:h(s);if(l!=null&&l.contains(o)||n.composed&&n.composedPath().includes(l))return}return!P(o,N.Loose)&&o.tabIndex!==-1&&n.preventDefault(),t(n,o)}let a=L(null);v("pointerdown",n=>{var i,o;r.value&&(a.value=((o=(i=n.composedPath)==null?void 0:i.call(n))==null?void 0:o[0])||n.target)},!0),v("mousedown",n=>{var i,o;r.value&&(a.value=((o=(i=n.composedPath)==null?void 0:i.call(n))==null?void 0:o[0])||n.target)},!0),v("click",n=>{R()||a.value&&(u(n,()=>a.value),a.value=null)},!0),v("touchend",n=>u(n,()=>n.target instanceof HTMLElement?n.target:null),!0),K("blur",n=>u(n,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}var G=(e=>(e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.Delete="Delete",e.ArrowLeft="ArrowLeft",e.ArrowUp="ArrowUp",e.ArrowRight="ArrowRight",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab",e))(G||{});export{S as N,U as O,$ as P,O as S,T,V as _,P as a,K as b,N as h,b as i,G as o,k as t,W as v,j as w};
