1import{a2 as y,r as s,w as g,bu as v}from"./entry.IRopAhUk.js";import{i as O}from"./is-element-visible._LEGGY8N.js";const w=y("Focus Controller Store",()=>{const n=s([]),l=s(null),o=s(!1),f=s(0),a=s(""),c=s();function i(){o.value||(n.value.length>0&&(c.value=n.value.pop()),c.value?.focus())}return g(o,u=>{!u&&!l.value&&i()}),{dropdownLayerDepth:f,toggleElements:n,isLoading:o,focusTrapEl:l,contentChangeKey:a,focusLatestToggleElement:i}});function C(){const n=s([]),l=s(void 0),o=s(void 0),f=s(!0);let a,c=!1,i=null;const u=w();let m;function b(){i=document.activeElement}function N(){const e=i;if(i=null,!e)return;if(e.checkVisibility?.()){e.focus();return}let t=e.parentElement;for(;t&&t!==document.body;){if(t.checkVisibility?.()){const r=Array.from(t.querySelectorAll(v)).find(E=>E.checkVisibility?.());if(r){r.focus();return}}t=t.parentElement}document.getElementById("main-content")?.focus()}function F(e,t){if(!e){console.warn("No target element found to set focus trap on.");return}if(!t){console.warn("No options.");return}m=t,t.refreshQuery&&(c=t.refreshQuery),t.disableSearchForFirstVisibleElement&&(f.value=!1),t.childOfCurrentTrap&&u.focusTrapEl?a={focusTrapEl:u.focusTrapEl,firstFocusableElement:l.value,lastFocusableElement:o.value,focusableElements:n.value,parentTrap:a}:u.focusTrapEl?(console.warn('Overwriting current focus trap - "childOfCurrentTrap" option not specified.'),console.warn("Previous trapped element:",u.focusTrapEl),console.warn("New trapped element:",e)):document.addEventListener("keydown",p),u.focusTrapEl=e,d(),!t?.skipFocus&&(t?.focusLatestToggleElement?u.focusLatestToggleElement():setTimeout(()=>{let r=l.value;if(m?.targetForInitialElement){const E=m.targetForInitialElement.querySelector(v);E?r=E:console.warn("No focusable elements found in initial focus element, using first element instead.",m.targetForInitialElement,r)}if(!r){console.warn("No focusable elements found in initial focus element.");return}r.focus()},1))}function d(){const e=u.focusTrapEl;if(!e){console.warn("No focus target.");return}if(n.value=[...e.querySelectorAll(v)],n.value.length===0){console.warn("No focusable elements.",e,v);return}let t=n.value[0];if(f.value){if(n.value=n.value.filter(O),n.value.length===0){console.warn("No visible elements",e);return}t=n.value[0]}l.value=t,o.value=n.value[n.value.length-1]}function h(){a?(u.focusTrapEl=a.focusTrapEl,l.value=a.firstFocusableElement,o.value=a.lastFocusableElement,n.value=a.focusableElements,a=a.parentTrap):(u.focusTrapEl=null,l.value=void 0,o.value=void 0,n.value=[],document?.removeEventListener("keydown",p))}function p(e){e.key==="Tab"&&T(e)}function T(e){if(c&&d(),e?.shiftKey&&o.value&&document.activeElement===l.value){e.preventDefault(),o.value.focus();return}if(!e?.shiftKey&&l.value&&document.activeElement===o.value){e?.preventDefault(),l.value.focus();return}setTimeout(()=>{if(!(!l.value||!o.value||!u.focusTrapEl)){if(!document.activeElement){l.value.focus();return}if(!u.focusTrapEl.contains(document.activeElement))if(e?.shiftKey){if(l.value.compareDocumentPosition(document.activeElement)===Node.DOCUMENT_POSITION_PRECEDING){o.value.focus();return}o.value.compareDocumentPosition(document.activeElement)===Node.DOCUMENT_POSITION_FOLLOWING&&o.value.focus()}else{if(l.value.compareDocumentPosition(document.activeElement)===Node.DOCUMENT_POSITION_PRECEDING){l.value.focus();return}o.value.compareDocumentPosition(document.activeElement)===Node.DOCUMENT_POSITION_FOLLOWING&&l.value.focus()}}},1)}return{handleTab:T,setFocusTrap:F,destroyFocusTrap:h,saveFocusedElement:b,restoreFocus:N}}export{w as a,C as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.