import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./jsx-runtime-DE3RlOCf.js";import{l as n,u as r}from"./chunk-62JRHF6Z-aabggn4k.js";import"./useReportMutations-CERlvIP6.js";import"./useLayoutTemplateMutations-C0Ajw4IY.js";var i=e(t(),1);function a(e={}){let{enabled:t=!0,handlers:a={}}=e,o=r(),s=n(),c=typeof navigator<`u`&&navigator.platform.toUpperCase().indexOf(`MAC`)>=0?`metaKey`:`ctrlKey`,l=(0,i.useCallback)(e=>{if(!t)return;let n=e.target,r=n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable;if(e[c]&&e.key===`s`){e.preventDefault(),a.onSave?.();return}if(e[c]&&e.key===`e`){e.preventDefault(),a.onExecute?.();return}if(e[c]&&e.key===`k`&&!r){e.preventDefault(),a.onQuickSearch?.();return}if(e[c]&&e.key===`d`&&!r){s.pathname.includes(`/reports/reports`)&&!s.pathname.includes(`/edit`)&&(e.preventDefault(),a.onDuplicate?.());return}if(e[c]&&e.key===`n`&&!r){e.preventDefault(),a.onNew?a.onNew():o(`/admin/reports/reports/new`);return}if(e.key===`Escape`){a.onEscape?.();return}},[t,a,o,s,c]);(0,i.useEffect)(()=>{if(t)return window.addEventListener(`keydown`,l),()=>window.removeEventListener(`keydown`,l)},[t,l])}function o(e){let t=typeof navigator<`u`&&navigator.platform.toUpperCase().indexOf(`MAC`)>=0?`⌘`:`Ctrl`;return{save:`${t}+S`,execute:`${t}+E`,search:`${t}+K`,duplicate:`${t}+D`,new:`${t}+N`,escape:`Esc`}[e]||e}export{a as n,o as t};