import{r as R,fL as O,cy as q,ft as W,fM as K,h1 as A,ij as I,cx as j,gw as N,dt as P,cc as S}from"./index-CCv_8omK.js";import{d as V}from"./depsEqual-BNz3Z5UN.js";var z=function(r,a,n){var e=R.useRef(void 0),t=R.useRef(0);V(a,e.current)||(t.current+=1),e.current=a,O(r,[t.current],n)},J=/(mac|iphone|ipod|ipad)/i.test(typeof navigator<"u"?navigator?.platform:""),M={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:J?[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},E={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"?M.meta.includes(r.keyCode):r.metaKey}};function B(r){return I(r)||j(r)}function Q(r){var a=Object.keys(E).reduce(function(n,e){return E[e](r)?n+1:n},0);return[16,17,18,91,92].includes(r.keyCode)?a:a+1}function T(r,a,n){var e,t;if(!r.key)return!1;if(j(a))return r.keyCode===a?a:!1;var u=a.split("."),o=0;try{for(var l=K(u),d=l.next();!d.done;d=l.next()){var p=d.value,y=E[p],m=M[p.toLowerCase()];(y&&y(r)||m&&m===r.keyCode)&&o++}}catch(b){e={error:b}}finally{try{d&&!d.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}return n?o===u.length&&Q(r)===u.length?a:!1:o===u.length?a:!1}function U(r,a){return A(r)?r:B(r)?function(n){return T(n,r,a)}:Array.isArray(r)?function(n){return r.find(function(e){return T(n,e,a)})}:function(){return!!r}}var X=["keydown"];function _(r,a,n){var e=n||{},t=e.events,u=t===void 0?X:t,o=e.target,l=e.exactMatch,d=l===void 0?!1:l,p=e.useCapture,y=p===void 0?!1:p,m=q(a),b=q(r);z(function(){var k,C,x,i=W(o,window);if(i){var L=function(f){var v,h=U(b.current,d),c=h(f),s=B(c)?c:f.key;if(c)return(v=m.current)===null||v===void 0?void 0:v.call(m,f,s)};try{for(var w=K(u),g=w.next();!g.done;g=w.next()){var D=g.value;(x=i?.addEventListener)===null||x===void 0||x.call(i,D,L,y)}}catch(f){k={error:f}}finally{try{g&&!g.done&&(C=w.return)&&C.call(w)}finally{if(k)throw k.error}}return function(){var f,v,h;try{for(var c=K(u),s=c.next();!s.done;s=c.next()){var G=s.value;(h=i?.removeEventListener)===null||h===void 0||h.call(i,G,L,y)}}catch(H){f={error:H}}finally{try{s&&!s.done&&(v=c.return)&&v.call(c)}finally{if(f)throw f.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 N(r,function(t,u,o){a(e,t,n(t),o)}),e}function rr(r,a){return function(n,e){var t=S(n)?Y:Z,u=a?a():{};return t(n,r,P(e),u)}}export{rr as c,_ as u};
