var p=Object.defineProperty;var n=(a,d)=>p(a,"name",{value:d,configurable:!0});import{aN as k,c as I,j as C,ay as K,c1 as S,e as h,c2 as i}from"./index-CbOy3pBh.js";const E=[{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:"q"},commandId:"Workspace.ToggleSidebarTab.queue"},{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"}],N=n(()=>{const a=k(),d=I(),c=C(),y=K(),l=n(e=>e.ctrlKey||e.altKey||e.metaKey?!1:["Delete","Backspace"].includes(e.key),"shouldForwardToCanvas"),g=n(async function(e){const t=S.fromEvent(e);if(t.isModifier)return;const o=e.composedPath()[0];if(t.isReservedByTextInput&&(o.tagName==="TEXTAREA"||o.tagName==="INPUT"||o.contentEditable==="true"||o.tagName==="SPAN"&&o.classList.contains("property_value")))return;const m=a.getKeybinding(t);if(m&&m.targetElementId!=="graph-canvas"){if(e.key==="Escape"&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&y.dialogStack.length>0)return;e.preventDefault(),await d.execute(m.commandId);return}if(!m&&l(e)){const r=h.canvas;if(r&&r.processKey&&typeof r.processKey=="function"){r.processKey(e);return}}if(!(e.ctrlKey||e.altKey||e.metaKey)&&e.key==="Escape"){const r=document.querySelectorAll(".comfy-modal");for(const s of r)if(window.getComputedStyle(s).getPropertyValue("display")!=="none"){s.style.display="none";break}for(const s of document.querySelectorAll("dialog"))s.close()}},"keybindHandler"),u=n(()=>{for(const e of E)a.addDefaultKeybinding(new i(e))},"registerCoreKeybindings");function b(){const e=c.get("Comfy.Keybinding.UnsetBindings");for(const o of e)a.unsetKeybinding(new i(o));const t=c.get("Comfy.Keybinding.NewBindings");for(const o of t)a.addUserKeybinding(new i(o))}n(b,"registerUserKeybindings");async function f(){await c.set("Comfy.Keybinding.NewBindings",Object.values(a.getUserKeybindings())),await c.set("Comfy.Keybinding.UnsetBindings",Object.values(a.getUserUnsetKeybindings()))}return n(f,"persistUserKeybindings"),{keybindHandler:g,registerCoreKeybindings:u,registerUserKeybindings:b,persistUserKeybindings:f}},"useKeybindingService");export{N as u};
//# sourceMappingURL=keybindingService-D1-A8QyS.js.map
