import{aV as e,aW as t,ax as s}from"./p-BTBbFFOR.js";var i=new class{constructor(){this.listeners=[],this.listenKeyPress()}register(e){e.map((e=>e.eventName||(e.eventName="keyup"))),this.listeners=this.listeners.concat(e)}deregister(e){this.listeners=this.listeners.filter((t=>!e.includes(t)))}listenKeyPress(){document.addEventListener("keydown",(e=>{this.invokeListeners("keydown",e)})),document.addEventListener("keyup",(e=>{this.invokeListeners("keyup",e)}))}invokeListeners(e,t){this.listeners.filter((s=>s.eventName===e&&this.shouldInvokeListener(s,t))).forEach((e=>{e.preventDefault&&t.preventDefault(),e.callback(t)}))}shouldInvokeListener(i,n){let o="";n.code?o=n.code:n.key&&"Unidentified"!==n.key&&(o=n.key);let r=[],c=[];const u=Array.isArray(i.keyCode)?i.keyCode.includes(o):i.keyCode===o;if(!u)return!1;"function"==typeof i.activeElementInScope?r=i.activeElementInScope():"object"==typeof i.activeElementInScope&&(r=i.activeElementInScope),"function"==typeof i.activeElementOutScope?c=i.activeElementOutScope():"object"==typeof i.activeElementOutScope&&(c=i.activeElementOutScope);const a=!i.activeElementInScope||r.some((s=>e(t(document,!0),s)));if(!a)return!1;const d=!i.activeElementOutScope||c.every((s=>!e(t(document,!0),s))),h=!s(i.modifierPressed)||i.modifierPressed===this.isModifierPressed(n),f=!s(i.shiftKey)||i.shiftKey===n.shiftKey;return u&&a&&d&&h&&f}isModifierPressed(e){return/Mac|iPhone|iPad/.test(navigator.userAgent)?e.metaKey:e.ctrlKey}};export{i as K}