import{r as q,da as O,cz as T,c3 as W,db as K,aQ as z,dc as A,cy as B,dd as I,de as N,aX as P}from"./index-DR3HTfO6.js";import{d as Q}from"./depsEqual-CJ8pX2dq.js";var S=function(r,a,n){var e=q.useRef(void 0),t=q.useRef(0);Q(a,e.current)||(t.current+=1),e.current=a,O(r,[t.current],n)},V=/(mac|iphone|ipod|ipad)/i.test(typeof navigator<"u"?navigator?.platform:""),D={0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,pausebreak:19,capslock:20,esc:27,space:32,pageup:33,pagedown:34,end:35,home:36,leftarrow:37,uparrow:38,rightarrow:39,downarrow:40,insert:45,delete:46,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,leftwindowkey:91,rightwindowkey:92,meta:V?[91,93]:[91,92],selectkey:93,numpad0:96,numpad1:97,numpad2:98,numpad3:99,numpad4:100,numpad5:101,numpad6:102,numpad7:103,numpad8:104,numpad9:105,multiply:106,add:107,subtract:109,decimalpoint:110,divide:111,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,numlock:144,scrolllock:145,semicolon:186,equalsign:187,comma:188,dash:189,period:190,forwardslash:191,graveaccent:192,openbracket:219,backslash:220,closebracket:221,singlequote:222},C={ctrl:function(r){return r.ctrlKey},shift:function(r){return r.shiftKey},alt:function(r){return r.altKey},meta:function(r){return r.type==="keyup"?D.meta.includes(r.keyCode):r.metaKey}};function G(r){return A(r)||B(r)}function X(r){var a=Object.keys(C).reduce(function(n,e){return C[e](r)?n+1:n},0);return[16,17,18,91,92].includes(r.keyCode)?a:a+1}function j(r,a,n){var e,t;if(!r.key)return!1;if(B(a))return r.keyCode===a?a:!1;var u=a.split("."),o=0;try{for(var c=K(u),d=c.next();!d.done;d=c.next()){var y=d.value,m=C[y],g=D[y.toLowerCase()];(m&&m(r)||g&&g===r.keyCode)&&o++}}catch(b){e={error:b}}finally{try{d&&!d.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}return n?o===u.length&&X(r)===u.length?a:!1:o===u.length?a:!1}function J(r,a){return z(r)?r:G(r)?function(n){return j(n,r,a)}:Array.isArray(r)?function(n){return r.find(function(e){return j(n,e,a)})}:function(){return!!r}}var U=["keydown"];function _(r,a,n){var e=n||{},t=e.events,u=t===void 0?U:t,o=e.target,c=e.exactMatch,d=c===void 0?!1:c,y=e.useCapture,m=y===void 0?!1:y,g=T(a),b=T(r);S(function(){var k,L,x,i=W(o,window);if(i){var R=function(l){var v,s=l,p=J(b.current,d),f=p(s),E=G(f)?f:s.key;if(f)return(v=g.current)===null||v===void 0?void 0:v.call(g,s,E)};try{for(var w=K(u),h=w.next();!h.done;h=w.next()){var H=h.value;(x=i?.addEventListener)===null||x===void 0||x.call(i,H,R,m)}}catch(l){k={error:l}}finally{try{h&&!h.done&&(L=w.return)&&L.call(w)}finally{if(k)throw k.error}}return function(){var l,v,s;try{for(var p=K(u),f=p.next();!f.done;f=p.next()){var E=f.value;(s=i?.removeEventListener)===null||s===void 0||s.call(i,E,R,m)}}catch(M){l={error:M}}finally{try{f&&!f.done&&(v=p.return)&&v.call(p)}finally{if(l)throw l.error}}}}},[u],o)}function Y(r,a,n,e){for(var t=-1,u=r==null?0:r.length;++t<u;){var o=r[t];a(e,o,n(o),r)}return e}function Z(r,a,n,e){return I(r,function(t,u,o){a(e,t,n(t),o)}),e}function rr(r,a){return function(n,e){var t=P(n)?Y:Z,u=a?a():{};return t(n,r,N(e),u)}}export{rr as c,_ as u};
