import{h as m}from"./on-fonts-ready-d897575d.js";import{o as r,a as c}from"./Scrollbar-35d51129.js";import{q as y,bg as h,b3 as b,E as w,O as v}from"./index-f4658ae7.js";function O(p={},n){const t=y({ctrl:!1,command:!1,win:!1,shift:!1,tab:!1}),{keydown:i,keyup:u}=p,s=e=>{switch(e.key){case"Control":t.ctrl=!0;break;case"Meta":t.command=!0,t.win=!0;break;case"Shift":t.shift=!0;break;case"Tab":t.tab=!0;break}i!==void 0&&Object.keys(i).forEach(o=>{if(o!==e.key)return;const a=i[o];if(typeof a=="function")a(e);else{const{stop:d=!1,prevent:l=!1}=a;d&&e.stopPropagation(),l&&e.preventDefault(),a.handler(e)}})},f=e=>{switch(e.key){case"Control":t.ctrl=!1;break;case"Meta":t.command=!1,t.win=!1;break;case"Shift":t.shift=!1;break;case"Tab":t.tab=!1;break}u!==void 0&&Object.keys(u).forEach(o=>{if(o!==e.key)return;const a=u[o];if(typeof a=="function")a(e);else{const{stop:d=!1,prevent:l=!1}=a;d&&e.stopPropagation(),l&&e.preventDefault(),a.handler(e)}})},k=()=>{(n===void 0||n.value)&&(c("keydown",document,s),c("keyup",document,f)),n!==void 0&&v(n,e=>{e?(c("keydown",document,s),c("keyup",document,f)):(r("keydown",document,s),r("keyup",document,f))})};return m()?(h(k),b(()=>{(n===void 0||n.value)&&(r("keydown",document,s),r("keyup",document,f))})):k(),w(t)}export{O as u};