import{i as e,n as t}from"./rolldown-runtime-BKYq3fBv.js";import{Co as n,Eo as r,So as i,To as a,at as o,co as s,da as c,it as l,lo as u,ua as d,wo as f,xo as p}from"./dialogService-BJDTj7su.js";var m,h=t((()=>{m=[{combo:{ctrl:!0,key:`Enter`},commandId:`Comfy.QueuePrompt`},{combo:{ctrl:!0,shift:!0,key:`Enter`},commandId:`Comfy.QueuePromptFront`},{combo:{ctrl:!0,alt:!0,key:`Enter`},commandId:`Comfy.Interrupt`},{combo:{key:`r`},commandId:`Comfy.RefreshNodeDefinitions`},{combo:{key:`w`},commandId:`Workspace.ToggleSidebarTab.workflows`},{combo:{key:`n`},commandId:`Workspace.ToggleSidebarTab.node-library`},{combo:{key:`m`},commandId:`Workspace.ToggleSidebarTab.model-library`},{combo:{key:`s`,ctrl:!0},commandId:`Comfy.SaveWorkflow`},{combo:{key:`o`,ctrl:!0},commandId:`Comfy.OpenWorkflow`},{combo:{key:`g`,ctrl:!0},commandId:`Comfy.Graph.GroupSelectedNodes`},{combo:{key:`,`,ctrl:!0},commandId:`Comfy.ShowSettingsDialog`},{combo:{key:`=`,alt:!0},commandId:`Comfy.Canvas.ZoomIn`,targetElementId:`graph-canvas`},{combo:{key:`+`,alt:!0,shift:!0},commandId:`Comfy.Canvas.ZoomIn`,targetElementId:`graph-canvas`},{combo:{key:`+`,alt:!0},commandId:`Comfy.Canvas.ZoomIn`,targetElementId:`graph-canvas`},{combo:{key:`-`,alt:!0},commandId:`Comfy.Canvas.ZoomOut`,targetElementId:`graph-canvas`},{combo:{key:`.`},commandId:`Comfy.Canvas.FitView`,targetElementId:`graph-canvas-container`},{combo:{key:`p`},commandId:`Comfy.Canvas.ToggleSelected.Pin`,targetElementId:`graph-canvas-container`},{combo:{key:`c`,alt:!0},commandId:`Comfy.Canvas.ToggleSelectedNodes.Collapse`,targetElementId:`graph-canvas-container`},{combo:{key:`b`,ctrl:!0},commandId:`Comfy.Canvas.ToggleSelectedNodes.Bypass`,targetElementId:`graph-canvas-container`},{combo:{key:`m`,ctrl:!0},commandId:`Comfy.Canvas.ToggleSelectedNodes.Mute`,targetElementId:`graph-canvas-container`},{combo:{key:"`",ctrl:!0},commandId:`Workspace.ToggleBottomPanelTab.logs-terminal`},{combo:{key:`e`,ctrl:!0,shift:!0},commandId:`Comfy.Graph.ConvertToSubgraph`},{combo:{key:`m`,alt:!0},commandId:`Comfy.Canvas.ToggleMinimap`},{combo:{ctrl:!0,shift:!0,key:`k`},commandId:`Workspace.ToggleBottomPanel.Shortcuts`},{combo:{key:`v`},commandId:`Comfy.Canvas.Unlock`},{combo:{key:`h`},commandId:`Comfy.Canvas.Lock`},{combo:{key:`Escape`},commandId:`Comfy.Graph.ExitSubgraph`}]})),useKeybindingService,g=t((()=>{h(),s(),o(),p(),d(),a(),useKeybindingService=()=>{let e=r(),t=i(),a=u(),o=c(),shouldForwardToCanvas=e=>e.ctrlKey||e.altKey||e.metaKey?!1:[`Delete`,`Backspace`].includes(e.key),keybindHandler=async function(r){let i=n.fromEvent(r);if(i.isModifier)return;let a=r.composedPath()[0];if(i.isReservedByTextInput&&(a.tagName===`TEXTAREA`||a.tagName===`INPUT`||a.contentEditable===`true`||a.tagName===`SPAN`&&a.classList.contains(`property_value`)))return;let s=e.getKeybinding(i);if(s&&s.targetElementId!==`graph-canvas`){if(r.key===`Escape`&&!r.ctrlKey&&!r.altKey&&!r.metaKey&&o.dialogStack.length>0)return;r.preventDefault(),new Set([`Comfy.QueuePrompt`,`Comfy.QueuePromptFront`,`Comfy.QueueSelectedOutputNodes`]).has(s.commandId)?await t.execute(s.commandId,{metadata:{trigger_source:`keybinding`}}):await t.execute(s.commandId);return}if(!s&&shouldForwardToCanvas(r)){let e=l.canvas;if(e&&e.processKey&&typeof e.processKey==`function`){e.processKey(r);return}}if(!(r.ctrlKey||r.altKey||r.metaKey)&&r.key===`Escape`){let e=document.querySelectorAll(`.comfy-modal`);for(let t of e)if(window.getComputedStyle(t).getPropertyValue(`display`)!==`none`){t.style.display=`none`;break}for(let e of document.querySelectorAll(`dialog`))e.close()}},registerCoreKeybindings=()=>{for(let t of m)e.addDefaultKeybinding(new f(t))};function registerUserKeybindings(){let t=a.get(`Comfy.Keybinding.UnsetBindings`);for(let n of t)e.unsetKeybinding(new f(n));let n=a.get(`Comfy.Keybinding.NewBindings`);for(let t of n)e.addUserKeybinding(new f(t))}async function persistUserKeybindings(){await a.set(`Comfy.Keybinding.NewBindings`,Object.values(e.getUserKeybindings())),await a.set(`Comfy.Keybinding.UnsetBindings`,Object.values(e.getUserUnsetKeybindings()))}return{keybindHandler,registerCoreKeybindings,registerUserKeybindings,persistUserKeybindings}}}));export{useKeybindingService as n,g as t};
//# sourceMappingURL=keybindingService-azBNra8Y.js.map