1var h=Object.defineProperty;var c=(r,t,e)=>t in r?h(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t,e)=>(c(r,typeof t!="symbol"?t+"":t,e),e);import{LitElement as u,html as d}from"@hh/global.js";var n=class extends u{constructor(){super(),this.focusIn=this.focusIn.bind(this),this.keyDown=this.keyDown.bind(this)}connectedCallback(){super.connectedCallback(),window.addEventListener("focus-trap:refresh",this.refreshTrapFocus.bind(this))}requestUpdate(t,e){let o=this[t];return t==="isActive"&&(o===!0?(this.addTrapFocus(this.renderRoot),this.selectInitialElement()):this.removeTrapFocus()),super.requestUpdate(t,e)}selectInitialElement(){for(let t=0;t<this.elements.length;t++){if(!this.selector){this.elements[t].focus();break}if(this.elements[t].matches(this.selector)){this.elements[t].focus();break}}}isHidden(t){return t.getAttribute("tabindex")==="-1"||t.getAttribute("type")==="hidden"||t.hasAttribute("hidden")||t.hasAttribute("aria-hidden")&&t.getAttribute("aria-hidden")!=="false"||t.style.display==="none"||t.style.opacity==="0"}isFocusable(t){return!t.disabled&&(t.hasAttribute("tabindex")||(t instanceof HTMLAnchorElement||t instanceof HTMLAreaElement)&&t.hasAttribute("href")||t instanceof HTMLButtonElement||t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t instanceof HTMLIFrameElement)}traverseSlot(t,e){let o=t.assignedNodes().filter(s=>s.nodeType===1);if(o.length>0){let s=o[0].parentElement;return this.queryShadowRoot(s,e+1)}return[]}queryShadowRoot(t,e=1,o=20){if(!t)return[];let s=[];for(let i of Array.from(t.children||[]))this.isHidden(i)||(this.isFocusable(i)&&s.push(i),i.shadowRoot!=null?s.push(...this.queryShadowRoot(i.shadowRoot,e+1)):i.tagName==="SLOT"?s.push(...this.traverseSlot(i,e)):s.push(...this.queryShadowRoot(i,e+1)));return s}focusIn(t){t.target!==this.renderRoot&&t.target!==this.last&&t.target!==this.first||t.target.addEventListener("keydown",this.keyDown)}keyDown(t){t.code.toUpperCase()==="TAB"&&(t.target===this.last&&!t.shiftKey&&(t.preventDefault(),this.first.focus()),(t.target===this.renderRoot||t.target===this.first)&&t.shiftKey&&(t.preventDefault(),this.last.focus()))}removeTrapFocus(){(this.elements||[]).forEach(t=>{t.removeEventListener("focusin",this.focusIn),t.removeEventListener("keydown",this.keyDown)})}addTrapFocus(t){this.removeTrapFocus(),this.elements=this.queryShadowRoot(t),this.first=this.elements[0],this.last=this.elements[this.elements.length-1],this.elements.forEach(e=>{e.addEventListener("focusin",this.focusIn)})}refreshTrapFocus(){!this.isActive||this.addTrapFocus(this.renderRoot)}disconnectedCallback(){super.disconnectedCallback(),this.removeTrapFocus()}render(){return d`<slot></slot> `}};a(n,"properties",{isActive:{attribute:"active",converter(t){return t!=="false"}},selector:{type:String}});customElements.define("hh-focus-trap",n);
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.