(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.tinykeys={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let t=[`Shift`,`Meta`,`Alt`,`Control`],n=typeof navigator==`object`?navigator.platform:``,r=/Mac|iPod|iPhone|iPad/.test(n)?`Meta`:`Control`,i=n===`Win32`?[`Control`,`Alt`]:[`Alt`];function a(e){return!!(e.key&&e.code&&e.getModifierState)}function o(e){let t=e.target;return e.repeat||e.isComposing||t!==e.currentTarget&&t.matches(`[contenteditable],input,select,textarea`)}function s(e,t){return typeof e.getModifierState==`function`?e.getModifierState(t)||i.includes(t)&&e.getModifierState(`AltGraph`):!1}function c(e){return e.trim().split(` `).map(e=>{let t=e.split(/(?<=\w|\])\+/),n=t.pop(),i=n.match(/^\((.+)\)$/),a=i?RegExp(`^(?:${i[1]})$`,`iv`):n,o=[],s=[];for(let e of t){let t=e.match(/^\[(.*)\]$/),n=t?.[1]??e;n=n===`$mod`?r:n,t?s.push(n):o.push(n)}return[o,s,a]})}function l(e,[n,r,a]){let o=n.includes(`AltGraph`);return!((a instanceof RegExp?!(a.test(e.key)||a.test(e.code)):a.toUpperCase()!==e.key.toUpperCase()&&a!==e.code)||n.find(t=>!s(e,t))||t.find(t=>!n.includes(t)&&!r.includes(t)&&a!==t&&s(e,t)&&!(o&&i.includes(t))))}function u(e,t={}){let n=t.timeout??1e3,r=t.ignore??o,i=Object.keys(e).map(t=>[t,c(t),e[t]]),u=new Map,d=null;return e=>{if(!a(e)||r(e))return;let t=[];for(let[n,r,a]of i){let[i,...o]=u.get(n)||r;if(!l(e,i))s(e,e.key)||u.delete(n);else if(o.length>0)u.set(n,o),t.push(n);else if(u.delete(n),t.length)console.warn(`tinykeys: Conflict found, "${n}" did not fire, waiting for:`,t);else{a(e);break}}d&&clearTimeout(d),d=setTimeout(()=>u.clear(),n)}}function d(e,t,n={}){let r=n.event??`keydown`,i=u(t,n);return e.addEventListener(r,i,n.capture),()=>{e.removeEventListener(r,i,n.capture)}}e.createKeybindingsHandler=u,e.defaultKeybindingsHandlerIgnore=o,e.matchKeybindingPress=l,e.parseKeybinding=c,e.tinykeys=d}); //# sourceMappingURL=tinykeys.umd.js.map