import{s as e}from"./chunk-Bj-mKKzh.js";import{n as t}from"./jsx-runtime-CiQ1k8xo.js";import{lt as n}from"./vscode-api-DjORcpSo.js";import{a as r,i,t as a}from"./electron-menu-shortcuts-RgqJ2PfO.js";import{t as o}from"./keyboard-layout-map-CtWtIpu3.js";var s=n(),c=e(t(),1);function l(e,t){let n=e.split(`+`).filter(Boolean),r=null,i=!1,a=!1,o=!1,s=!1;for(let e of n)switch(e){case`CmdOrCtrl`:t?a=!0:i=!0;break;case`Command`:case`Cmd`:a=!0;break;case`Control`:case`Ctrl`:i=!0;break;case`Alt`:case`Option`:o=!0;break;case`Shift`:s=!0;break;default:r=e.toLowerCase();break}return{key:u(r??``),requireCtrl:i,requireMeta:a,requireAlt:o,requireShift:s}}function u(e){switch(e){case`esc`:case`escape`:return`escape`;case`space`:return` `;case`plus`:return`+`;default:return e}}function d(e,t){return e.target instanceof Element&&e.target.closest(t)!=null}var f=`[data-codex-shortcut-capture]`,p=`input,textarea,select,[contenteditable='true'],[data-codex-composer],[data-codex-terminal]`;function m(e,t){return o(e).toLowerCase()===t.key||t.key===`=`&&t.requireShift&&e.key===`+`}function h(e,t){return!(!t.key||!m(e,t)||e.ctrlKey!==t.requireCtrl||e.metaKey!==t.requireMeta||e.altKey!==t.requireAlt||e.shiftKey!==t.requireShift)}function g(e){return e.requireCtrl||e.requireMeta||e.requireAlt}function _(e){let t=(0,s.c)(27),{accelerator:n,allowRepeat:o,enabled:u,onKeyDown:_,onKeyUp:v,capture:y,ignoreWithin:b,keyboardEventTarget:x}=e,S=o===void 0?!1:o,C=u===void 0?!0:u,w=y===void 0?!0:y,T;if(t[0]!==n){let e=a();T=r(n).map(t=>l(t,e)),t[0]=n,t[1]=T}else T=t[1];let E=T,D=E.length>1,O=(0,c.useRef)(!1),k=(0,c.useRef)(null),A=(0,c.useRef)(0),j=(0,c.useRef)(null),M=v!=null,N;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>{A.current=0,j.current!=null&&(clearTimeout(j.current),j.current=null)},t[2]=N):N=t[2];let P=N,F;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{O.current=!1,k.current=null,P()},t[3]=F):F=t[3];let I=F,L;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{j.current!=null&&clearTimeout(j.current),j.current=setTimeout(P,i)},t[4]=L):L=t[4];let R=L,z;t[5]!==S||t[6]!==C||t[7]!==b||t[8]!==D||t[9]!==_||t[10]!==E?(z=e=>{if(!C||!S&&e.repeat||d(e,f)||b&&d(e,b))return;let t=E[A.current];if(t!=null&&!(d(e,p)&&(D||!g(t)))){if(!h(e,t)){if(!D)return;P();let t=E[0];if(t==null||!h(e,t))return}if(!D){O.current=!0,k.current=t,_(e);return}if(e.preventDefault(),A.current+=1,A.current<E.length){R();return}O.current=!0,k.current=E[E.length-1]??null,P(),_(e)}},t[5]=S,t[6]=C,t[7]=b,t[8]=D,t[9]=_,t[10]=E,t[11]=z):z=t[11];let B=(0,c.useEffectEvent)(z),V;t[12]===v?V=t[13]:(V=e=>{if(!O.current)return;let t=k.current;t!=null&&m(e,t)&&(O.current=!1,k.current=null,v?.(e))},t[12]=v,t[13]=V);let H=(0,c.useEffectEvent)(V),U;t[14]!==w||t[15]!==C||t[16]!==B||t[17]!==H||t[18]!==M||t[19]!==x?(U=()=>{if(!C){I();return}let e=x??(typeof window>`u`?null:window);if(e==null){I();return}return e.addEventListener(`keydown`,B,{capture:w}),M&&e.addEventListener(`keyup`,H,{capture:w}),()=>{e.removeEventListener(`keydown`,B,{capture:w}),M&&e.removeEventListener(`keyup`,H,{capture:w}),I()}},t[14]=w,t[15]=C,t[16]=B,t[17]=H,t[18]=M,t[19]=x,t[20]=U):U=t[20];let W;t[21]!==n||t[22]!==w||t[23]!==C||t[24]!==M||t[25]!==x?(W=[n,w,C,M,x],t[21]=n,t[22]=w,t[23]=C,t[24]=M,t[25]=x,t[26]=W):W=t[26],(0,c.useEffect)(U,W)}export{_ as t};
//# sourceMappingURL=use-hotkey-pv8kDDPO.js.map