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