@codebolt/litegraph 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +161 -0
  3. package/dist/CanvasPointer.d.ts +120 -0
  4. package/dist/ContextMenu.d.ts +41 -0
  5. package/dist/CurveEditor.d.ts +18 -0
  6. package/dist/DragAndScale.d.ts +67 -0
  7. package/dist/LGraph.d.ts +407 -0
  8. package/dist/LGraphBadge.d.ts +33 -0
  9. package/dist/LGraphButton.d.ts +27 -0
  10. package/dist/LGraphCanvas.d.ts +772 -0
  11. package/dist/LGraphGroup.d.ts +81 -0
  12. package/dist/LGraphIcon.d.ts +22 -0
  13. package/dist/LGraphNode.d.ts +883 -0
  14. package/dist/LLink.d.ts +194 -0
  15. package/dist/LiteGraphGlobal.d.ts +360 -0
  16. package/dist/MapProxyHandler.d.ts +13 -0
  17. package/dist/Reroute.d.ts +185 -0
  18. package/dist/canvas/FloatingRenderLink.d.ts +55 -0
  19. package/dist/canvas/InputIndicators.d.ts +45 -0
  20. package/dist/canvas/LinkConnector.d.ts +165 -0
  21. package/dist/canvas/MovingInputLink.d.ts +34 -0
  22. package/dist/canvas/MovingLinkBase.d.ts +55 -0
  23. package/dist/canvas/MovingOutputLink.d.ts +30 -0
  24. package/dist/canvas/RenderLink.d.ts +39 -0
  25. package/dist/canvas/ToInputFromIoNodeLink.d.ts +37 -0
  26. package/dist/canvas/ToInputRenderLink.d.ts +35 -0
  27. package/dist/canvas/ToOutputFromIoNodeLink.d.ts +33 -0
  28. package/dist/canvas/ToOutputFromRerouteLink.d.ts +15 -0
  29. package/dist/canvas/ToOutputRenderLink.d.ts +32 -0
  30. package/dist/canvas/measureSlots.d.ts +22 -0
  31. package/dist/constants.d.ts +9 -0
  32. package/dist/css/litegraph.css +638 -0
  33. package/dist/draw.d.ts +65 -0
  34. package/dist/infrastructure/ConstrainedSize.d.ts +27 -0
  35. package/dist/infrastructure/CustomEventTarget.d.ts +72 -0
  36. package/dist/infrastructure/InvalidLinkError.d.ts +3 -0
  37. package/dist/infrastructure/LGraphCanvasEventMap.d.ts +41 -0
  38. package/dist/infrastructure/LGraphEventMap.d.ts +43 -0
  39. package/dist/infrastructure/LinkConnectorEventMap.d.ts +47 -0
  40. package/dist/infrastructure/NullGraphError.d.ts +3 -0
  41. package/dist/infrastructure/Rectangle.d.ts +163 -0
  42. package/dist/infrastructure/RecursionError.d.ts +6 -0
  43. package/dist/infrastructure/SlotIndexError.d.ts +3 -0
  44. package/dist/infrastructure/SubgraphEventMap.d.ts +49 -0
  45. package/dist/infrastructure/SubgraphInputEventMap.d.ts +13 -0
  46. package/dist/interfaces.d.ts +388 -0
  47. package/dist/litegraph.d.ts +95 -0
  48. package/dist/litegraph.es.js +17613 -0
  49. package/dist/litegraph.es.js.map +1 -0
  50. package/dist/litegraph.umd.js +3 -0
  51. package/dist/litegraph.umd.js.map +1 -0
  52. package/dist/measure.d.ts +168 -0
  53. package/dist/node/NodeInputSlot.d.ts +20 -0
  54. package/dist/node/NodeOutputSlot.d.ts +18 -0
  55. package/dist/node/NodeSlot.d.ts +35 -0
  56. package/dist/node/SlotBase.d.ts +27 -0
  57. package/dist/node/slotUtils.d.ts +17 -0
  58. package/dist/polyfills.d.ts +1 -0
  59. package/dist/strings.d.ts +22 -0
  60. package/dist/subgraph/EmptySubgraphInput.d.ts +15 -0
  61. package/dist/subgraph/EmptySubgraphOutput.d.ts +15 -0
  62. package/dist/subgraph/ExecutableNodeDTO.d.ts +96 -0
  63. package/dist/subgraph/Subgraph.d.ts +65 -0
  64. package/dist/subgraph/SubgraphIONodeBase.d.ts +80 -0
  65. package/dist/subgraph/SubgraphInput.d.ts +47 -0
  66. package/dist/subgraph/SubgraphInputNode.d.ts +33 -0
  67. package/dist/subgraph/SubgraphNode.d.ts +73 -0
  68. package/dist/subgraph/SubgraphOutput.d.ts +30 -0
  69. package/dist/subgraph/SubgraphOutputNode.d.ts +31 -0
  70. package/dist/subgraph/SubgraphSlotBase.d.ts +61 -0
  71. package/dist/subgraph/subgraphUtils.d.ts +77 -0
  72. package/dist/types/NodeLike.d.ts +7 -0
  73. package/dist/types/events.d.ts +64 -0
  74. package/dist/types/globalEnums.d.ts +130 -0
  75. package/dist/types/serialisation.d.ts +198 -0
  76. package/dist/types/utility.d.ts +11 -0
  77. package/dist/types/widgets.d.ts +209 -0
  78. package/dist/utils/arrange.d.ts +22 -0
  79. package/dist/utils/collections.d.ts +38 -0
  80. package/dist/utils/feedback.d.ts +7 -0
  81. package/dist/utils/object.d.ts +1 -0
  82. package/dist/utils/spaceDistribution.d.ts +11 -0
  83. package/dist/utils/textUtils.d.ts +9 -0
  84. package/dist/utils/type.d.ts +14 -0
  85. package/dist/utils/uuid.d.ts +13 -0
  86. package/dist/utils/widget.d.ts +7 -0
  87. package/dist/widgets/BaseSteppedWidget.d.ts +34 -0
  88. package/dist/widgets/BaseWidget.d.ts +125 -0
  89. package/dist/widgets/BooleanWidget.d.ts +9 -0
  90. package/dist/widgets/ButtonWidget.d.ts +16 -0
  91. package/dist/widgets/ComboWidget.d.ts +17 -0
  92. package/dist/widgets/KnobWidget.d.ts +20 -0
  93. package/dist/widgets/LegacyWidget.d.ts +14 -0
  94. package/dist/widgets/NumberWidget.d.ts +18 -0
  95. package/dist/widgets/SliderWidget.d.ts +20 -0
  96. package/dist/widgets/TextWidget.d.ts +13 -0
  97. package/dist/widgets/widgetMap.d.ts +50 -0
  98. package/package.json +76 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"litegraph.es.js","sources":["../src/infrastructure/CustomEventTarget.ts","../src/constants.ts","../src/utils/uuid.ts","../src/LLink.ts","../src/types/globalEnums.ts","../src/measure.ts","../src/infrastructure/Rectangle.ts","../src/canvas/measureSlots.ts","../src/infrastructure/NullGraphError.ts","../src/LGraphIcon.ts","../src/LGraphBadge.ts","../src/LGraphButton.ts","../src/draw.ts","../src/node/SlotBase.ts","../src/node/NodeSlot.ts","../src/LGraphGroup.ts","../src/Reroute.ts","../src/strings.ts","../src/infrastructure/ConstrainedSize.ts","../src/subgraph/SubgraphSlotBase.ts","../src/subgraph/SubgraphOutput.ts","../src/subgraph/EmptySubgraphOutput.ts","../src/subgraph/SubgraphIONodeBase.ts","../src/subgraph/SubgraphOutputNode.ts","../src/subgraph/subgraphUtils.ts","../src/node/NodeInputSlot.ts","../src/node/NodeOutputSlot.ts","../src/node/slotUtils.ts","../src/utils/feedback.ts","../src/utils/spaceDistribution.ts","../src/utils/textUtils.ts","../src/utils/type.ts","../src/widgets/BaseWidget.ts","../src/widgets/BooleanWidget.ts","../src/widgets/ButtonWidget.ts","../src/widgets/BaseSteppedWidget.ts","../src/widgets/ComboWidget.ts","../src/utils/widget.ts","../src/widgets/KnobWidget.ts","../src/widgets/LegacyWidget.ts","../src/widgets/NumberWidget.ts","../src/widgets/SliderWidget.ts","../src/widgets/TextWidget.ts","../src/widgets/widgetMap.ts","../src/LGraphNode.ts","../src/utils/collections.ts","../src/subgraph/SubgraphInput.ts","../src/subgraph/EmptySubgraphInput.ts","../src/subgraph/SubgraphInputNode.ts","../src/canvas/FloatingRenderLink.ts","../src/canvas/MovingLinkBase.ts","../src/canvas/MovingInputLink.ts","../src/canvas/MovingOutputLink.ts","../src/canvas/ToInputFromIoNodeLink.ts","../src/canvas/ToInputRenderLink.ts","../src/canvas/ToOutputFromIoNodeLink.ts","../src/canvas/ToOutputRenderLink.ts","../src/canvas/ToOutputFromRerouteLink.ts","../src/canvas/LinkConnector.ts","../src/CanvasPointer.ts","../src/DragAndScale.ts","../src/utils/arrange.ts","../src/LGraphCanvas.ts","../src/MapProxyHandler.ts","../src/LGraph.ts","../src/subgraph/Subgraph.ts","../src/canvas/InputIndicators.ts","../src/ContextMenu.ts","../src/CurveEditor.ts","../src/LiteGraphGlobal.ts","../src/polyfills.ts","../src/infrastructure/InvalidLinkError.ts","../src/infrastructure/RecursionError.ts","../src/infrastructure/SlotIndexError.ts","../src/subgraph/ExecutableNodeDTO.ts","../src/subgraph/SubgraphNode.ts","../src/litegraph.ts"],"sourcesContent":["import type { NeverNever, PickNevers } from \"@/types/utility\"\n\ntype EventListeners<T> = {\n readonly [K in keyof T]: ((this: EventTarget, ev: CustomEvent<T[K]>) => any) | EventListenerObject | null\n}\n\n/**\n * Has strongly-typed overrides of {@link EventTarget.addEventListener} and {@link EventTarget.removeEventListener}.\n */\nexport interface ICustomEventTarget<\n EventMap extends Record<Keys, unknown>,\n Keys extends keyof EventMap & string = keyof EventMap & string,\n> {\n addEventListener<K extends Keys>(\n type: K,\n listener: EventListeners<EventMap>[K],\n options?: boolean | AddEventListenerOptions,\n ): void\n\n removeEventListener<K extends Keys>(\n type: K,\n listener: EventListeners<EventMap>[K],\n options?: boolean | EventListenerOptions,\n ): void\n\n /** @deprecated Use {@link dispatch}. */\n dispatchEvent(event: never): boolean\n}\n\n/**\n * Capable of dispatching strongly-typed events via {@link dispatch}.\n * Overloads are used to ensure detail param is correctly optional.\n */\nexport interface CustomEventDispatcher<\n EventMap extends Record<Keys, unknown>,\n Keys extends keyof EventMap & string = keyof EventMap & string,\n> {\n dispatch<T extends keyof NeverNever<EventMap>>(type: T, detail: EventMap[T]): boolean\n dispatch<T extends keyof PickNevers<EventMap>>(type: T): boolean\n}\n\n/**\n * A strongly-typed, custom {@link EventTarget} that can dispatch and listen for events.\n *\n * 1. Define an event map\n * ```ts\n * export interface CustomEventMap {\n * \"my-event\": { message: string }\n * \"simple-event\": never\n * }\n * ```\n *\n * 2. Create an event emitter\n * ```ts\n * // By subclassing\n * class MyClass extends CustomEventTarget<CustomEventMap> {\n * // ...\n * }\n *\n * // Or simply create an instance:\n * const events = new CustomEventTarget<CustomEventMap>()\n * ```\n *\n * 3. Dispatch events\n * ```ts\n * // Extended class\n * const myClass = new MyClass()\n * myClass.dispatch(\"my-event\", { message: \"Hello, world!\" })\n * myClass.dispatch(\"simple-event\")\n *\n * // Instance\n * const events = new CustomEventTarget<CustomEventMap>()\n * events.dispatch(\"my-event\", { message: \"Hello, world!\" })\n * events.dispatch(\"simple-event\")\n * ```\n */\nexport class CustomEventTarget<\n EventMap extends Record<Keys, unknown>,\n Keys extends keyof EventMap & string = keyof EventMap & string,\n>\n extends EventTarget implements ICustomEventTarget<EventMap, Keys> {\n /**\n * Type-safe event dispatching.\n * @see {@link EventTarget.dispatchEvent}\n * @param type Name of the event to dispatch\n * @param detail A custom object to send with the event\n * @returns `true` if the event was dispatched successfully, otherwise `false`.\n */\n dispatch<T extends keyof NeverNever<EventMap>>(type: T, detail: EventMap[T]): boolean\n dispatch<T extends keyof PickNevers<EventMap>>(type: T): boolean\n dispatch<T extends keyof EventMap>(type: T, detail?: EventMap[T]) {\n const event = new CustomEvent(type as string, { detail, cancelable: true })\n return super.dispatchEvent(event)\n }\n\n override addEventListener<K extends Keys>(\n type: K,\n listener: EventListeners<EventMap>[K],\n options?: boolean | AddEventListenerOptions,\n ): void {\n // Assertion: Contravariance on CustomEvent => Event\n super.addEventListener(type as string, listener as EventListener, options)\n }\n\n override removeEventListener<K extends Keys>(\n type: K,\n listener: EventListeners<EventMap>[K],\n options?: boolean | EventListenerOptions,\n ): void {\n // Assertion: Contravariance on CustomEvent => Event\n super.removeEventListener(type as string, listener as EventListener, options)\n }\n\n /** @deprecated Use {@link dispatch}. */\n override dispatchEvent(event: never): boolean {\n return super.dispatchEvent(event)\n }\n}\n","/**\n * Subgraph constants\n *\n * This entire module is exported as `Constants`.\n */\n\n/** ID of the virtual input node of a subgraph. */\nexport const SUBGRAPH_INPUT_ID = -10\n\n/** ID of the virtual output node of a subgraph. */\nexport const SUBGRAPH_OUTPUT_ID = -20\n","// Using a template string for this is resulting in complex type workarounds. No current benefit beyond dev reading.\nexport type UUID = string\n\n/** Special-case zero-UUID, consisting entirely of zeros. Used as a default value. */\nexport const zeroUuid = \"00000000-0000-0000-0000-000000000000\"\n\n/** Pre-allocated storage for uuid random values. */\nconst randomStorage = new Uint32Array(31)\n\n/**\n * Creates a UUIDv4 string.\n * @returns A new UUIDv4 string\n * @remarks\n * Original implementation from https://gist.github.com/jed/982883?permalink_comment_id=852670#gistcomment-852670\n *\n * Prefers the {@link crypto.randomUUID} method if available, falling back to\n * {@link crypto.getRandomValues}, then finally the legacy {@link Math.random} method.\n */\nexport function createUuidv4(): UUID {\n if (typeof crypto?.randomUUID === \"function\") return crypto.randomUUID()\n if (typeof crypto?.getRandomValues === \"function\") {\n const random = crypto.getRandomValues(randomStorage)\n let i = 0\n return \"10000000-1000-4000-8000-100000000000\".replaceAll(/[018]/g, a =>\n (Number(a) ^ ((random[i++] * 3.725_290_298_461_914e-9) >> (Number(a) * 0.25))).toString(16))\n }\n return \"10000000-1000-4000-8000-100000000000\".replaceAll(/[018]/g, a =>\n (Number(a) ^ ((Math.random() * 16) >> (Number(a) * 0.25))).toString(16))\n}\n","import type {\n CanvasColour,\n INodeInputSlot,\n INodeOutputSlot,\n ISlotType,\n LinkNetwork,\n LinkSegment,\n ReadonlyLinkNetwork,\n} from \"./interfaces\"\nimport type { LGraphNode, NodeId } from \"./LGraphNode\"\nimport type { Reroute, RerouteId } from \"./Reroute\"\nimport type { Serialisable, SerialisableLLink, SubgraphIO } from \"./types/serialisation\"\n\nimport { SUBGRAPH_INPUT_ID, SUBGRAPH_OUTPUT_ID } from \"@/constants\"\n\nimport { Subgraph } from \"./litegraph\"\n\nexport type LinkId = number\n\nexport type SerialisedLLinkArray = [\n id: LinkId,\n origin_id: NodeId,\n origin_slot: number,\n target_id: NodeId,\n target_slot: number,\n type: ISlotType,\n]\n\n// Resolved connection union; eliminates subgraph in/out as a possibility\nexport type ResolvedConnection = BaseResolvedConnection &\n (\n (ResolvedSubgraphInput & ResolvedNormalOutput) |\n (ResolvedNormalInput & ResolvedSubgraphOutput) |\n (ResolvedNormalInput & ResolvedNormalOutput)\n )\n\ninterface BaseResolvedConnection {\n link: LLink\n /** The node on the input side of the link (owns {@link input}) */\n inputNode?: LGraphNode\n /** The input the link is connected to (mutually exclusive with {@link subgraphOutput}) */\n input?: INodeInputSlot\n /** The node on the output side of the link (owns {@link output}) */\n outputNode?: LGraphNode\n /** The output the link is connected to (mutually exclusive with {@link subgraphInput}) */\n output?: INodeOutputSlot\n /** The subgraph output the link is connected to (mutually exclusive with {@link input}) */\n subgraphOutput?: SubgraphIO\n /** The subgraph input the link is connected to (mutually exclusive with {@link output}) */\n subgraphInput?: SubgraphIO\n}\n\ninterface ResolvedNormalInput {\n inputNode: LGraphNode | undefined\n input: INodeInputSlot | undefined\n subgraphOutput?: undefined\n}\n\ninterface ResolvedNormalOutput {\n outputNode: LGraphNode | undefined\n output: INodeOutputSlot | undefined\n subgraphInput?: undefined\n}\n\ninterface ResolvedSubgraphInput {\n inputNode?: undefined\n /** The actual input slot the link is connected to (mutually exclusive with {@link subgraphOutput}) */\n input?: undefined\n subgraphOutput: SubgraphIO\n}\n\ninterface ResolvedSubgraphOutput {\n outputNode?: undefined\n output?: undefined\n subgraphInput: SubgraphIO\n}\n\ntype BasicReadonlyNetwork = Pick<ReadonlyLinkNetwork, \"getNodeById\" | \"links\" | \"getLink\" | \"inputNode\" | \"outputNode\">\n\n// this is the class in charge of storing link information\nexport class LLink implements LinkSegment, Serialisable<SerialisableLLink> {\n static _drawDebug = false\n\n /** Link ID */\n id: LinkId\n parentId?: RerouteId\n type: ISlotType\n /** Output node ID */\n origin_id: NodeId\n /** Output slot index */\n origin_slot: number\n /** Input node ID */\n target_id: NodeId\n /** Input slot index */\n target_slot: number\n\n data?: number | string | boolean | { toToolTip?(): string }\n _data?: unknown\n /** Centre point of the link, calculated during render only - can be inaccurate */\n _pos: Float32Array\n /** @todo Clean up - never implemented in comfy. */\n _last_time?: number\n /** The last canvas 2D path that was used to render this link */\n path?: Path2D\n /** @inheritdoc */\n _centreAngle?: number\n\n /** @inheritdoc */\n _dragging?: boolean\n\n #color?: CanvasColour | null\n /** Custom colour for this link only */\n public get color(): CanvasColour | null | undefined {\n return this.#color\n }\n\n public set color(value: CanvasColour) {\n this.#color = value === \"\" ? null : value\n }\n\n public get isFloatingOutput(): boolean {\n return this.origin_id === -1 && this.origin_slot === -1\n }\n\n public get isFloatingInput(): boolean {\n return this.target_id === -1 && this.target_slot === -1\n }\n\n public get isFloating(): boolean {\n return this.isFloatingOutput || this.isFloatingInput\n }\n\n /** `true` if this link is connected to a subgraph input node (the actual origin is in a different graph). */\n get originIsIoNode(): boolean {\n return this.origin_id === SUBGRAPH_INPUT_ID\n }\n\n /** `true` if this link is connected to a subgraph output node (the actual target is in a different graph). */\n get targetIsIoNode(): boolean {\n return this.target_id === SUBGRAPH_OUTPUT_ID\n }\n\n constructor(\n id: LinkId,\n type: ISlotType,\n origin_id: NodeId,\n origin_slot: number,\n target_id: NodeId,\n target_slot: number,\n parentId?: RerouteId,\n ) {\n this.id = id\n this.type = type\n this.origin_id = origin_id\n this.origin_slot = origin_slot\n this.target_id = target_id\n this.target_slot = target_slot\n this.parentId = parentId\n\n this._data = null\n // center\n this._pos = new Float32Array(2)\n }\n\n /** @deprecated Use {@link LLink.create} */\n static createFromArray(data: SerialisedLLinkArray): LLink {\n return new LLink(data[0], data[5], data[1], data[2], data[3], data[4])\n }\n\n /**\n * LLink static factory: creates a new LLink from the provided data.\n * @param data Serialised LLink data to create the link from\n * @returns A new LLink\n */\n static create(data: SerialisableLLink): LLink {\n return new LLink(\n data.id,\n data.type,\n data.origin_id,\n data.origin_slot,\n data.target_id,\n data.target_slot,\n data.parentId,\n )\n }\n\n /**\n * Gets all reroutes from the output slot to this segment. If this segment is a reroute, it will not be included.\n * @returns An ordered array of all reroutes from the node output to\n * this reroute or the reroute before it. Otherwise, an empty array.\n */\n static getReroutes(\n network: Pick<ReadonlyLinkNetwork, \"reroutes\">,\n linkSegment: LinkSegment,\n ): Reroute[] {\n if (!linkSegment.parentId) return []\n return network.reroutes\n .get(linkSegment.parentId)\n ?.getReroutes() ?? []\n }\n\n static getFirstReroute(\n network: Pick<ReadonlyLinkNetwork, \"reroutes\">,\n linkSegment: LinkSegment,\n ): Reroute | undefined {\n return LLink.getReroutes(network, linkSegment).at(0)\n }\n\n /**\n * Finds the reroute in the chain after the provided reroute ID.\n * @param network The network this link belongs to\n * @param linkSegment The starting point of the search (input side).\n * Typically the LLink object itself, but can be any link segment.\n * @param rerouteId The matching reroute will have this set as its {@link parentId}.\n * @returns The reroute that was found, `undefined` if no reroute was found, or `null` if an infinite loop was detected.\n */\n static findNextReroute(\n network: Pick<ReadonlyLinkNetwork, \"reroutes\">,\n linkSegment: LinkSegment,\n rerouteId: RerouteId,\n ): Reroute | null | undefined {\n if (!linkSegment.parentId) return\n return network.reroutes\n .get(linkSegment.parentId)\n ?.findNextReroute(rerouteId)\n }\n\n /**\n * Gets the origin node of a link.\n * @param network The network to search\n * @param linkId The ID of the link to get the origin node of\n * @returns The origin node of the link, or `undefined` if the link is not found or the origin node is not found\n */\n static getOriginNode(network: BasicReadonlyNetwork, linkId: LinkId): LGraphNode | undefined {\n const id = network.links.get(linkId)?.origin_id\n return network.getNodeById(id) ?? undefined\n }\n\n /**\n * Gets the target node of a link.\n * @param network The network to search\n * @param linkId The ID of the link to get the target node of\n * @returns The target node of the link, or `undefined` if the link is not found or the target node is not found\n */\n static getTargetNode(network: BasicReadonlyNetwork, linkId: LinkId): LGraphNode | undefined {\n const id = network.links.get(linkId)?.target_id\n return network.getNodeById(id) ?? undefined\n }\n\n /**\n * Resolves a link ID to the link, node, and slot objects.\n * @param linkId The {@link id} of the link to resolve\n * @param network The link network to search\n * @returns An object containing the input and output nodes, as well as the input and output slots.\n * @remarks This method is heavier than others; it will always resolve all objects.\n * Whilst the performance difference should in most cases be negligible,\n * it is recommended to use simpler methods where appropriate.\n */\n static resolve(linkId: LinkId | null | undefined, network: BasicReadonlyNetwork): ResolvedConnection | undefined {\n return network.getLink(linkId)?.resolve(network)\n }\n\n /**\n * Resolves a list of link IDs to the link, node, and slot objects.\n * Discards invalid link IDs.\n * @param linkIds An iterable of link {@link id}s to resolve\n * @param network The link network to search\n * @returns An array of resolved connections. If a link is not found, it is not included in the array.\n * @see {@link LLink.resolve}\n */\n static resolveMany(linkIds: Iterable<LinkId>, network: BasicReadonlyNetwork): ResolvedConnection[] {\n const resolved: ResolvedConnection[] = []\n for (const id of linkIds) {\n const r = network.getLink(id)?.resolve(network)\n if (r) resolved.push(r)\n }\n return resolved\n }\n\n /**\n * Resolves the primitive ID values stored in the link to the referenced objects.\n * @param network The link network to search\n * @returns An object containing the input and output nodes, as well as the input and output slots.\n * @remarks This method is heavier than others; it will always resolve all objects.\n * Whilst the performance difference should in most cases be negligible,\n * it is recommended to use simpler methods where appropriate.\n */\n resolve(network: BasicReadonlyNetwork): ResolvedConnection {\n const inputNode = this.target_id === -1 ? undefined : network.getNodeById(this.target_id) ?? undefined\n const input = inputNode?.inputs[this.target_slot]\n const subgraphInput = this.originIsIoNode ? network.inputNode?.slots[this.origin_slot] : undefined\n if (subgraphInput) {\n return { inputNode, input, subgraphInput, link: this }\n }\n\n const outputNode = this.origin_id === -1 ? undefined : network.getNodeById(this.origin_id) ?? undefined\n const output = outputNode?.outputs[this.origin_slot]\n const subgraphOutput = this.targetIsIoNode ? network.outputNode?.slots[this.target_slot] : undefined\n if (subgraphOutput) {\n return { outputNode, output, subgraphInput: undefined, subgraphOutput, link: this }\n }\n\n return { inputNode, outputNode, input, output, subgraphInput, subgraphOutput, link: this }\n }\n\n configure(o: LLink | SerialisedLLinkArray) {\n if (Array.isArray(o)) {\n this.id = o[0]\n this.origin_id = o[1]\n this.origin_slot = o[2]\n this.target_id = o[3]\n this.target_slot = o[4]\n this.type = o[5]\n } else {\n this.id = o.id\n this.type = o.type\n this.origin_id = o.origin_id\n this.origin_slot = o.origin_slot\n this.target_id = o.target_id\n this.target_slot = o.target_slot\n this.parentId = o.parentId\n }\n }\n\n /**\n * Checks if the specified node id and output index are this link's origin (output side).\n * @param nodeId ID of the node to check\n * @param outputIndex The array index of the node output\n * @returns `true` if the origin matches, otherwise `false`.\n */\n hasOrigin(nodeId: NodeId, outputIndex: number): boolean {\n return this.origin_id === nodeId && this.origin_slot === outputIndex\n }\n\n /**\n * Checks if the specified node id and input index are this link's target (input side).\n * @param nodeId ID of the node to check\n * @param inputIndex The array index of the node input\n * @returns `true` if the target matches, otherwise `false`.\n */\n hasTarget(nodeId: NodeId, inputIndex: number): boolean {\n return this.target_id === nodeId && this.target_slot === inputIndex\n }\n\n /**\n * Creates a floating link from this link.\n * @param slotType The side of the link that is still connected\n * @param parentId The parent reroute ID of the link\n * @returns A new LLink that is floating\n */\n toFloating(slotType: \"input\" | \"output\", parentId: RerouteId): LLink {\n const exported = this.asSerialisable()\n exported.id = -1\n exported.parentId = parentId\n\n if (slotType === \"input\") {\n exported.origin_id = -1\n exported.origin_slot = -1\n } else {\n exported.target_id = -1\n exported.target_slot = -1\n }\n\n return LLink.create(exported)\n }\n\n /**\n * Disconnects a link and removes it from the graph, cleaning up any reroutes that are no longer used\n * @param network The container (LGraph) where reroutes should be updated\n * @param keepReroutes If `undefined`, reroutes will be automatically removed if no links remain.\n * If `input` or `output`, reroutes will not be automatically removed, and retain a connection to the input or output, respectively.\n */\n disconnect(network: LinkNetwork, keepReroutes?: \"input\" | \"output\"): void {\n const reroutes = LLink.getReroutes(network, this)\n\n const lastReroute = reroutes.at(-1)\n\n // When floating from output, 1-to-1 ratio of floating link to final reroute (tree-like)\n const outputFloating = keepReroutes === \"output\" &&\n lastReroute?.linkIds.size === 1 &&\n lastReroute.floatingLinkIds.size === 0\n\n // When floating from inputs, the final (input side) reroute may have many floating links\n if (outputFloating || (keepReroutes === \"input\" && lastReroute)) {\n const newLink = LLink.create(this)\n newLink.id = -1\n\n if (keepReroutes === \"input\") {\n newLink.origin_id = -1\n newLink.origin_slot = -1\n\n lastReroute.floating = { slotType: \"input\" }\n } else {\n newLink.target_id = -1\n newLink.target_slot = -1\n\n lastReroute.floating = { slotType: \"output\" }\n }\n\n network.addFloatingLink(newLink)\n }\n\n for (const reroute of reroutes) {\n reroute.linkIds.delete(this.id)\n if (!keepReroutes && !reroute.totalLinks) {\n network.reroutes.delete(reroute.id)\n }\n }\n network.links.delete(this.id)\n\n if (this.originIsIoNode && network instanceof Subgraph) {\n const subgraphInput = network.inputs.at(this.origin_slot)\n if (!subgraphInput) throw new Error(\"Invalid link - subgraph input not found\")\n\n subgraphInput.events.dispatch(\"input-disconnected\", { input: subgraphInput })\n }\n }\n\n /**\n * @deprecated Prefer {@link LLink.asSerialisable} (returns an object, not an array)\n * @returns An array representing this LLink\n */\n serialize(): SerialisedLLinkArray {\n return [\n this.id,\n this.origin_id,\n this.origin_slot,\n this.target_id,\n this.target_slot,\n this.type,\n ]\n }\n\n asSerialisable(): SerialisableLLink {\n const copy: SerialisableLLink = {\n id: this.id,\n origin_id: this.origin_id,\n origin_slot: this.origin_slot,\n target_id: this.target_id,\n target_slot: this.target_slot,\n type: this.type,\n }\n if (this.parentId) copy.parentId = this.parentId\n return copy\n }\n}\n","/** Node slot type - input or output */\nexport enum NodeSlotType {\n INPUT = 1,\n OUTPUT = 2,\n}\n\n/** Shape that an object will render as - used by nodes and slots */\nexport enum RenderShape {\n /** Rectangle with square corners */\n BOX = 1,\n /** Rounded rectangle */\n ROUND = 2,\n /** Circle is circle */\n CIRCLE = 3,\n /** Two rounded corners: top left & bottom right */\n CARD = 4,\n /** Slot shape: Arrow */\n ARROW = 5,\n /** Slot shape: Grid */\n GRID = 6,\n /** Slot shape: Hollow circle */\n HollowCircle = 7,\n}\n\n/** Bit flags used to indicate what the pointer is currently hovering over. */\nexport enum CanvasItem {\n /** No items / none */\n Nothing = 0,\n /** At least one node */\n Node = 1,\n /** At least one group */\n Group = 1 << 1,\n /** A reroute (not its path) */\n Reroute = 1 << 2,\n /** The path of a link */\n Link = 1 << 3,\n /** A reroute slot */\n RerouteSlot = 1 << 5,\n /** A subgraph input or output node */\n SubgraphIoNode = 1 << 6,\n /** A subgraph input or output slot */\n SubgraphIoSlot = 1 << 7,\n}\n\n/** The direction that a link point will flow towards - e.g. horizontal outputs are right by default */\nexport enum LinkDirection {\n NONE = 0,\n UP = 1,\n DOWN = 2,\n LEFT = 3,\n RIGHT = 4,\n CENTER = 5,\n}\n\n/** The path calculation that links follow */\nexport enum LinkRenderType {\n HIDDEN_LINK = -1,\n /** Juts out from the input & output a little @see LinkDirection, then a straight line between them */\n STRAIGHT_LINK = 0,\n /** 90° angles, clean and box-like */\n LINEAR_LINK = 1,\n /** Smooth curved links - default */\n SPLINE_LINK = 2,\n}\n\n/** The marker in the middle of a link */\nexport enum LinkMarkerShape {\n /** Do not display markers */\n None = 0,\n /** Circles (default) */\n Circle = 1,\n /** Directional arrows */\n Arrow = 2,\n}\n\nexport enum TitleMode {\n NORMAL_TITLE = 0,\n NO_TITLE = 1,\n TRANSPARENT_TITLE = 2,\n AUTOHIDE_TITLE = 3,\n}\n\nexport enum LGraphEventMode {\n ALWAYS = 0,\n ON_EVENT = 1,\n NEVER = 2,\n ON_TRIGGER = 3,\n BYPASS = 4,\n}\n\nexport enum EaseFunction {\n LINEAR = \"linear\",\n EASE_IN_QUAD = \"easeInQuad\",\n EASE_OUT_QUAD = \"easeOutQuad\",\n EASE_IN_OUT_QUAD = \"easeInOutQuad\",\n}\n\n/** Bit flags used to indicate what the pointer is currently hovering over. */\nexport enum Alignment {\n /** No items / none */\n None = 0,\n /** Top */\n Top = 1,\n /** Bottom */\n Bottom = 1 << 1,\n /** Vertical middle */\n Middle = 1 << 2,\n /** Left */\n Left = 1 << 3,\n /** Right */\n Right = 1 << 4,\n /** Horizontal centre */\n Centre = 1 << 5,\n /** Top left */\n TopLeft = Top | Left,\n /** Top side, horizontally centred */\n TopCentre = Top | Centre,\n /** Top right */\n TopRight = Top | Right,\n /** Left side, vertically centred */\n MidLeft = Left | Middle,\n /** Middle centre */\n MidCentre = Middle | Centre,\n /** Right side, vertically centred */\n MidRight = Right | Middle,\n /** Bottom left */\n BottomLeft = Bottom | Left,\n /** Bottom side, horizontally centred */\n BottomCentre = Bottom | Centre,\n /** Bottom right */\n BottomRight = Bottom | Right,\n}\n\n/**\n * Checks if the bitwise {@link flag} is set in the {@link flagSet}.\n * @param flagSet The unknown set of flags - will be checked for the presence of {@link flag}\n * @param flag The flag to check for\n * @returns `true` if the flag is set, `false` otherwise.\n */\nexport function hasFlag(flagSet: number, flag: number): boolean {\n return (flagSet & flag) === flag\n}\n","import type {\n HasBoundingRect,\n Point,\n ReadOnlyPoint,\n ReadOnlyRect,\n Rect,\n} from \"./interfaces\"\n\nimport { Alignment, hasFlag, LinkDirection } from \"./types/globalEnums\"\n\n/**\n * Calculates the distance between two points (2D vector)\n * @param a Point a as `x, y`\n * @param b Point b as `x, y`\n * @returns Distance between point {@link a} & {@link b}\n */\nexport function distance(a: ReadOnlyPoint, b: ReadOnlyPoint): number {\n return Math.sqrt(\n (b[0] - a[0]) * (b[0] - a[0]) + (b[1] - a[1]) * (b[1] - a[1]),\n )\n}\n\n/**\n * Calculates the distance2 (squared) between two points (2D vector).\n * Much faster when only comparing distances (closest/furthest point).\n * @param x1 Origin point X\n * @param y1 Origin point Y\n * @param x2 Destination point X\n * @param y2 Destination point Y\n * @returns Distance2 (squared) between point [{@link x1}, {@link y1}] & [{@link x2}, {@link y2}]\n */\nexport function dist2(x1: number, y1: number, x2: number, y2: number): number {\n return ((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))\n}\n\n/**\n * Determines whether a point is inside a rectangle.\n *\n * Otherwise identical to {@link isInsideRectangle}, it also returns `true` if `x` equals `left` or `y` equals `top`.\n * @param x Point x\n * @param y Point y\n * @param left Rect x\n * @param top Rect y\n * @param width Rect width\n * @param height Rect height\n * @returns `true` if the point is inside the rect, otherwise `false`\n */\nexport function isInRectangle(\n x: number,\n y: number,\n left: number,\n top: number,\n width: number,\n height: number,\n): boolean {\n return x >= left &&\n x < left + width &&\n y >= top &&\n y < top + height\n}\n\n/**\n * Determines whether a {@link Point} is inside a {@link Rect}.\n * @param point The point to check, as `x, y`\n * @param rect The rectangle, as `x, y, width, height`\n * @returns `true` if the point is inside the rect, otherwise `false`\n */\nexport function isPointInRect(point: ReadOnlyPoint, rect: ReadOnlyRect): boolean {\n return point[0] >= rect[0] &&\n point[0] < rect[0] + rect[2] &&\n point[1] >= rect[1] &&\n point[1] < rect[1] + rect[3]\n}\n\n/**\n * Determines whether the point represented by {@link x}, {@link y} is inside a {@link Rect}.\n * @param x X co-ordinate of the point to check\n * @param y Y co-ordinate of the point to check\n * @param rect The rectangle, as `x, y, width, height`\n * @returns `true` if the point is inside the rect, otherwise `false`\n */\nexport function isInRect(x: number, y: number, rect: ReadOnlyRect): boolean {\n return x >= rect[0] &&\n x < rect[0] + rect[2] &&\n y >= rect[1] &&\n y < rect[1] + rect[3]\n}\n\n/**\n * Determines whether a point (`x, y`) is inside a rectangle.\n *\n * This is the original litegraph implementation. It returns `false` if `x` is equal to `left`, or `y` is equal to `top`.\n * @deprecated\n * Use {@link isInRectangle} to match inclusive of top left.\n * This function returns a false negative when an integer point (e.g. pixel) is on the leftmost or uppermost edge of a rectangle.\n * @param x Point x\n * @param y Point y\n * @param left Rect x\n * @param top Rect y\n * @param width Rect width\n * @param height Rect height\n * @returns `true` if the point is inside the rect, otherwise `false`\n */\nexport function isInsideRectangle(\n x: number,\n y: number,\n left: number,\n top: number,\n width: number,\n height: number,\n): boolean {\n return left < x &&\n left + width > x &&\n top < y &&\n top + height > y\n}\n\n/**\n * Determines if two rectangles have any overlap\n * @param a Rectangle A as `x, y, width, height`\n * @param b Rectangle B as `x, y, width, height`\n * @returns `true` if rectangles overlap, otherwise `false`\n */\nexport function overlapBounding(a: ReadOnlyRect, b: ReadOnlyRect): boolean {\n const aRight = a[0] + a[2]\n const aBottom = a[1] + a[3]\n const bRight = b[0] + b[2]\n const bBottom = b[1] + b[3]\n\n return a[0] > bRight ||\n a[1] > bBottom ||\n aRight < b[0] ||\n aBottom < b[1]\n ? false\n : true\n}\n\n/**\n * Returns the centre of a rectangle.\n * @param rect The rectangle, as `x, y, width, height`\n * @returns The centre of the rectangle, as `x, y`\n */\nexport function getCentre(rect: ReadOnlyRect): Point {\n return [\n rect[0] + (rect[2] * 0.5),\n rect[1] + (rect[3] * 0.5),\n ]\n}\n\n/**\n * Determines if rectangle {@link a} contains the centre point of rectangle {@link b}.\n * @param a Container rectangle A as `x, y, width, height`\n * @param b Sub-rectangle B as `x, y, width, height`\n * @returns `true` if {@link a} contains most of {@link b}, otherwise `false`\n */\nexport function containsCentre(a: ReadOnlyRect, b: ReadOnlyRect): boolean {\n const centreX = b[0] + (b[2] * 0.5)\n const centreY = b[1] + (b[3] * 0.5)\n return isInRect(centreX, centreY, a)\n}\n\n/**\n * Determines if rectangle {@link a} wholly contains rectangle {@link b}.\n * @param a Container rectangle A as `x, y, width, height`\n * @param b Sub-rectangle B as `x, y, width, height`\n * @returns `true` if {@link a} wholly contains {@link b}, otherwise `false`\n */\nexport function containsRect(a: ReadOnlyRect, b: ReadOnlyRect): boolean {\n const aRight = a[0] + a[2]\n const aBottom = a[1] + a[3]\n const bRight = b[0] + b[2]\n const bBottom = b[1] + b[3]\n\n const identical = a[0] === b[0] &&\n a[1] === b[1] &&\n aRight === bRight &&\n aBottom === bBottom\n\n return !identical &&\n a[0] <= b[0] &&\n a[1] <= b[1] &&\n aRight >= bRight &&\n aBottom >= bBottom\n}\n\n/**\n * Adds an offset in the specified direction to {@link out}\n * @param amount Amount of offset to add\n * @param direction Direction to add the offset to\n * @param out The {@link Point} to add the offset to\n */\nexport function addDirectionalOffset(\n amount: number,\n direction: LinkDirection,\n out: Point,\n): void {\n switch (direction) {\n case LinkDirection.LEFT:\n out[0] -= amount\n return\n case LinkDirection.RIGHT:\n out[0] += amount\n return\n case LinkDirection.UP:\n out[1] -= amount\n return\n case LinkDirection.DOWN:\n out[1] += amount\n return\n // LinkDirection.CENTER: Nothing to do.\n }\n}\n\n/**\n * Rotates an offset in 90° increments.\n *\n * Swaps/flips axis values of a 2D vector offset - effectively rotating\n * {@link offset} by 90°\n * @param offset The zero-based offset to rotate\n * @param from Direction to rotate from\n * @param to Direction to rotate to\n */\nexport function rotateLink(\n offset: Point,\n from: LinkDirection,\n to: LinkDirection,\n): void {\n let x: number\n let y: number\n\n // Normalise to left\n switch (from) {\n case to:\n case LinkDirection.CENTER:\n case LinkDirection.NONE:\n default:\n // Nothing to do\n return\n\n case LinkDirection.LEFT:\n x = offset[0]\n y = offset[1]\n break\n case LinkDirection.RIGHT:\n x = -offset[0]\n y = -offset[1]\n break\n case LinkDirection.UP:\n x = -offset[1]\n y = offset[0]\n break\n case LinkDirection.DOWN:\n x = offset[1]\n y = -offset[0]\n break\n }\n\n // Apply new direction\n switch (to) {\n case LinkDirection.CENTER:\n case LinkDirection.NONE:\n // Nothing to do\n return\n\n case LinkDirection.LEFT:\n offset[0] = x\n offset[1] = y\n break\n case LinkDirection.RIGHT:\n offset[0] = -x\n offset[1] = -y\n break\n case LinkDirection.UP:\n offset[0] = y\n offset[1] = -x\n break\n case LinkDirection.DOWN:\n offset[0] = -y\n offset[1] = x\n break\n }\n}\n\n/**\n * Check if a point is to to the left or right of a line.\n * Project a line from lineStart -> lineEnd. Determine if point is to the left\n * or right of that projection.\n * {@link https://www.geeksforgeeks.org/orientation-3-ordered-points/}\n * @param lineStart The start point of the line\n * @param lineEnd The end point of the line\n * @param x X co-ordinate of the point to check\n * @param y Y co-ordinate of the point to check\n * @returns 0 if all three points are in a straight line, a negative value if\n * point is to the left of the projected line, or positive if the point is to\n * the right\n */\nexport function getOrientation(\n lineStart: ReadOnlyPoint,\n lineEnd: ReadOnlyPoint,\n x: number,\n y: number,\n): number {\n return ((lineEnd[1] - lineStart[1]) * (x - lineEnd[0])) -\n ((lineEnd[0] - lineStart[0]) * (y - lineEnd[1]))\n}\n\n/**\n * @param out The array to store the point in\n * @param a Start point\n * @param b End point\n * @param controlA Start curve control point\n * @param controlB End curve control point\n * @param t Time: factor of distance to travel along the curve (e.g 0.25 is 25% along the curve)\n */\nexport function findPointOnCurve(\n out: Point,\n a: ReadOnlyPoint,\n b: ReadOnlyPoint,\n controlA: ReadOnlyPoint,\n controlB: ReadOnlyPoint,\n t: number = 0.5,\n): void {\n const iT = 1 - t\n\n const c1 = iT * iT * iT\n const c2 = 3 * (iT * iT) * t\n const c3 = 3 * iT * (t * t)\n const c4 = t * t * t\n\n out[0] = (c1 * a[0]) + (c2 * controlA[0]) + (c3 * controlB[0]) + (c4 * b[0])\n out[1] = (c1 * a[1]) + (c2 * controlA[1]) + (c3 * controlB[1]) + (c4 * b[1])\n}\n\nexport function createBounds(\n objects: Iterable<HasBoundingRect>,\n padding: number = 10,\n): ReadOnlyRect | null {\n const bounds = new Float32Array([Infinity, Infinity, -Infinity, -Infinity])\n\n for (const obj of objects) {\n const rect = obj.boundingRect\n bounds[0] = Math.min(bounds[0], rect[0])\n bounds[1] = Math.min(bounds[1], rect[1])\n bounds[2] = Math.max(bounds[2], rect[0] + rect[2])\n bounds[3] = Math.max(bounds[3], rect[1] + rect[3])\n }\n if (!bounds.every(x => isFinite(x))) return null\n\n return [\n bounds[0] - padding,\n bounds[1] - padding,\n bounds[2] - bounds[0] + (2 * padding),\n bounds[3] - bounds[1] + (2 * padding),\n ]\n}\n\n/**\n * Snaps the provided {@link Point} or {@link Rect} ({@link pos}) to a grid of size {@link snapTo}.\n * @param pos The point that will be snapped\n * @param snapTo The value to round up/down by (multiples thereof)\n * @returns `true` if snapTo is truthy, otherwise `false`\n * @remarks `NaN` propagates through this function and does not affect return value.\n */\nexport function snapPoint(pos: Point | Rect, snapTo: number): boolean {\n if (!snapTo) return false\n\n pos[0] = snapTo * Math.round(pos[0] / snapTo)\n pos[1] = snapTo * Math.round(pos[1] / snapTo)\n return true\n}\n\n/**\n * Aligns a {@link Rect} relative to the edges or centre of a {@link container} rectangle.\n *\n * With no {@link inset}, the element will be placed on the interior of the {@link container},\n * with their edges lined up on the {@link anchors}. A positive {@link inset} moves the element towards the centre,\n * negative will push it outside the {@link container}.\n * @param rect The bounding rect of the element to align.\n * If using the element's pos/size backing store, this function will move the element.\n * @param anchors The direction(s) to anchor the element to\n * @param container The rectangle inside which to align the element\n * @param inset Relative offset from each {@link anchors} edge, with positive always leading to the centre, as an `[x, y]` point\n * @returns The original {@link rect}, modified in place.\n */\nexport function alignToContainer(\n rect: Rect,\n anchors: Alignment,\n [containerX, containerY, containerWidth, containerHeight]: ReadOnlyRect,\n [insetX, insetY]: ReadOnlyPoint = [0, 0],\n): Rect {\n if (hasFlag(anchors, Alignment.Left)) {\n // Left\n rect[0] = containerX + insetX\n } else if (hasFlag(anchors, Alignment.Right)) {\n // Right\n rect[0] = containerX + containerWidth - insetX - rect[2]\n } else if (hasFlag(anchors, Alignment.Centre)) {\n // Horizontal centre\n rect[0] = containerX + (containerWidth * 0.5) - (rect[2] * 0.5)\n }\n\n if (hasFlag(anchors, Alignment.Top)) {\n // Top\n rect[1] = containerY + insetY\n } else if (hasFlag(anchors, Alignment.Bottom)) {\n // Bottom\n rect[1] = containerY + containerHeight - insetY - rect[3]\n } else if (hasFlag(anchors, Alignment.Middle)) {\n // Vertical middle\n rect[1] = containerY + (containerHeight * 0.5) - (rect[3] * 0.5)\n }\n return rect\n}\n\n/**\n * Aligns a {@link Rect} relative to the edges of {@link other}.\n *\n * With no {@link outset}, the element will be placed on the exterior of the {@link other},\n * with their edges lined up on the {@link anchors}. A positive {@link outset} moves the element away from the {@link other},\n * negative will push it inside the {@link other}.\n * @param rect The bounding rect of the element to align.\n * If using the element's pos/size backing store, this function will move the element.\n * @param anchors The direction(s) to anchor the element to\n * @param other The rectangle to align {@link rect} to\n * @param outset Relative offset from each {@link anchors} edge, with positive always moving away from the centre of the {@link other}, as an `[x, y]` point\n * @returns The original {@link rect}, modified in place.\n */\nexport function alignOutsideContainer(\n rect: Rect,\n anchors: Alignment,\n [otherX, otherY, otherWidth, otherHeight]: ReadOnlyRect,\n [outsetX, outsetY]: ReadOnlyPoint = [0, 0],\n): Rect {\n if (hasFlag(anchors, Alignment.Left)) {\n // Left\n rect[0] = otherX - outsetX - rect[2]\n } else if (hasFlag(anchors, Alignment.Right)) {\n // Right\n rect[0] = otherX + otherWidth + outsetX\n } else if (hasFlag(anchors, Alignment.Centre)) {\n // Horizontal centre\n rect[0] = otherX + (otherWidth * 0.5) - (rect[2] * 0.5)\n }\n\n if (hasFlag(anchors, Alignment.Top)) {\n // Top\n rect[1] = otherY - outsetY - rect[3]\n } else if (hasFlag(anchors, Alignment.Bottom)) {\n // Bottom\n rect[1] = otherY + otherHeight + outsetY\n } else if (hasFlag(anchors, Alignment.Middle)) {\n // Vertical middle\n rect[1] = otherY + (otherHeight * 0.5) - (rect[3] * 0.5)\n }\n return rect\n}\n\nexport function clamp(value: number, min: number, max: number): number {\n return value < min ? min : (value > max ? max : value)\n}\n","import type { CompassCorners, Point, ReadOnlyPoint, ReadOnlyRect, ReadOnlySize, ReadOnlyTypedArray, Size } from \"@/interfaces\"\n\nimport { isInRectangle } from \"@/measure\"\n\n/**\n * A rectangle, represented as a float64 array of 4 numbers: [x, y, width, height].\n *\n * This class is a subclass of Float64Array, and so has all the methods of that class. Notably,\n * {@link Rectangle.from} can be used to convert a {@link ReadOnlyRect}. Typing of this however,\n * is broken due to the base TS lib returning Float64Array rather than `this`.\n *\n * Sub-array properties ({@link Float64Array.subarray}):\n * - {@link pos}: The position of the top-left corner of the rectangle.\n * - {@link size}: The size of the rectangle.\n */\nexport class Rectangle extends Float64Array {\n #pos: Point | undefined\n #size: Size | undefined\n\n constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {\n super(4)\n\n this[0] = x\n this[1] = y\n this[2] = width\n this[3] = height\n }\n\n static override from([x, y, width, height]: ReadOnlyRect): Rectangle {\n return new Rectangle(x, y, width, height)\n }\n\n /**\n * Creates a new rectangle positioned at the given centre, with the given width/height.\n * @param centre The centre of the rectangle, as an `[x, y]` point\n * @param width The width of the rectangle\n * @param height The height of the rectangle. Default: {@link width}\n * @returns A new rectangle whose centre is at {@link x}\n */\n static fromCentre([x, y]: ReadOnlyPoint, width: number, height = width): Rectangle {\n const left = x - width * 0.5\n const top = y - height * 0.5\n return new Rectangle(left, top, width, height)\n }\n\n static ensureRect(rect: ReadOnlyRect): Rectangle {\n return rect instanceof Rectangle\n ? rect\n : new Rectangle(rect[0], rect[1], rect[2], rect[3])\n }\n\n override subarray(begin: number = 0, end?: number): Float64Array<ArrayBuffer> {\n const byteOffset = begin << 3\n const length = end === undefined ? end : end - begin\n return new Float64Array(this.buffer, byteOffset, length)\n }\n\n /**\n * A reference to the position of the top-left corner of this rectangle.\n *\n * Updating the values of the returned object will update this rectangle.\n */\n get pos(): Point {\n this.#pos ??= this.subarray(0, 2)\n return this.#pos\n }\n\n set pos(value: ReadOnlyPoint) {\n this[0] = value[0]\n this[1] = value[1]\n }\n\n /**\n * A reference to the size of this rectangle.\n *\n * Updating the values of the returned object will update this rectangle.\n */\n get size(): Size {\n this.#size ??= this.subarray(2, 4)\n return this.#size\n }\n\n set size(value: ReadOnlySize) {\n this[2] = value[0]\n this[3] = value[1]\n }\n\n // #region Property accessors\n /** The x co-ordinate of the top-left corner of this rectangle. */\n get x() {\n return this[0]\n }\n\n set x(value: number) {\n this[0] = value\n }\n\n /** The y co-ordinate of the top-left corner of this rectangle. */\n get y() {\n return this[1]\n }\n\n set y(value: number) {\n this[1] = value\n }\n\n /** The width of this rectangle. */\n get width() {\n return this[2]\n }\n\n set width(value: number) {\n this[2] = value\n }\n\n /** The height of this rectangle. */\n get height() {\n return this[3]\n }\n\n set height(value: number) {\n this[3] = value\n }\n\n /** The x co-ordinate of the left edge of this rectangle. */\n get left() {\n return this[0]\n }\n\n set left(value: number) {\n this[0] = value\n }\n\n /** The y co-ordinate of the top edge of this rectangle. */\n get top() {\n return this[1]\n }\n\n set top(value: number) {\n this[1] = value\n }\n\n /** The x co-ordinate of the right edge of this rectangle. */\n get right() {\n return this[0] + this[2]\n }\n\n set right(value: number) {\n this[0] = value - this[2]\n }\n\n /** The y co-ordinate of the bottom edge of this rectangle. */\n get bottom() {\n return this[1] + this[3]\n }\n\n set bottom(value: number) {\n this[1] = value - this[3]\n }\n\n /** The x co-ordinate of the centre of this rectangle. */\n get centreX() {\n return this[0] + (this[2] * 0.5)\n }\n\n /** The y co-ordinate of the centre of this rectangle. */\n get centreY() {\n return this[1] + (this[3] * 0.5)\n }\n // #endregion Property accessors\n\n /**\n * Updates the rectangle to the values of {@link rect}.\n * @param rect The rectangle to update to.\n */\n updateTo(rect: ReadOnlyRect) {\n this[0] = rect[0]\n this[1] = rect[1]\n this[2] = rect[2]\n this[3] = rect[3]\n }\n\n /**\n * Checks if the point [{@link x}, {@link y}] is inside this rectangle.\n * @param x The x-coordinate to check\n * @param y The y-coordinate to check\n * @returns `true` if the point is inside this rectangle, otherwise `false`.\n */\n containsXy(x: number, y: number): boolean {\n const [left, top, width, height] = this\n return x >= left &&\n x < left + width &&\n y >= top &&\n y < top + height\n }\n\n /**\n * Checks if {@link point} is inside this rectangle.\n * @param point The point to check\n * @returns `true` if {@link point} is inside this rectangle, otherwise `false`.\n */\n containsPoint([x, y]: ReadOnlyPoint): boolean {\n const [left, top, width, height] = this\n return x >= left &&\n x < left + width &&\n y >= top &&\n y < top + height\n }\n\n /**\n * Checks if {@link other} is a smaller rectangle inside this rectangle.\n * One **must** be larger than the other; identical rectangles are not considered to contain each other.\n * @param other The rectangle to check\n * @returns `true` if {@link other} is inside this rectangle, otherwise `false`.\n */\n containsRect(other: ReadOnlyRect): boolean {\n const { right, bottom } = this\n const otherRight = other[0] + other[2]\n const otherBottom = other[1] + other[3]\n\n const identical = this.x === other[0] &&\n this.y === other[1] &&\n right === otherRight &&\n bottom === otherBottom\n\n return !identical &&\n this.x <= other[0] &&\n this.y <= other[1] &&\n right >= otherRight &&\n bottom >= otherBottom\n }\n\n /**\n * Checks if {@link rect} overlaps with this rectangle.\n * @param rect The rectangle to check\n * @returns `true` if {@link rect} overlaps with this rectangle, otherwise `false`.\n */\n overlaps(rect: ReadOnlyRect): boolean {\n return this.x < rect[0] + rect[2] &&\n this.y < rect[1] + rect[3] &&\n this.x + this.width > rect[0] &&\n this.y + this.height > rect[1]\n }\n\n /**\n * Finds the corner (if any) of this rectangle that contains the point [{@link x}, {@link y}].\n * @param x The x-coordinate to check\n * @param y The y-coordinate to check\n * @param cornerSize Each corner is treated as an inset square with this width and height.\n * @returns The compass direction of the corner that contains the point, or `undefined` if the point is not in any corner.\n */\n findContainingCorner(x: number, y: number, cornerSize: number): CompassCorners | undefined {\n if (this.isInTopLeftCorner(x, y, cornerSize)) return \"NW\"\n if (this.isInTopRightCorner(x, y, cornerSize)) return \"NE\"\n if (this.isInBottomLeftCorner(x, y, cornerSize)) return \"SW\"\n if (this.isInBottomRightCorner(x, y, cornerSize)) return \"SE\"\n }\n\n /** @returns `true` if the point [{@link x}, {@link y}] is in the top-left corner of this rectangle, otherwise `false`. */\n isInTopLeftCorner(x: number, y: number, cornerSize: number): boolean {\n return isInRectangle(x, y, this.x, this.y, cornerSize, cornerSize)\n }\n\n /** @returns `true` if the point [{@link x}, {@link y}] is in the top-right corner of this rectangle, otherwise `false`. */\n isInTopRightCorner(x: number, y: number, cornerSize: number): boolean {\n return isInRectangle(x, y, this.right - cornerSize, this.y, cornerSize, cornerSize)\n }\n\n /** @returns `true` if the point [{@link x}, {@link y}] is in the bottom-left corner of this rectangle, otherwise `false`. */\n isInBottomLeftCorner(x: number, y: number, cornerSize: number): boolean {\n return isInRectangle(x, y, this.x, this.bottom - cornerSize, cornerSize, cornerSize)\n }\n\n /** @returns `true` if the point [{@link x}, {@link y}] is in the bottom-right corner of this rectangle, otherwise `false`. */\n isInBottomRightCorner(x: number, y: number, cornerSize: number): boolean {\n return isInRectangle(x, y, this.right - cornerSize, this.bottom - cornerSize, cornerSize, cornerSize)\n }\n\n /** @returns `true` if the point [{@link x}, {@link y}] is in the top edge of this rectangle, otherwise `false`. */\n isInTopEdge(x: number, y: number, edgeSize: number): boolean {\n return isInRectangle(x, y, this.x, this.y, this.width, edgeSize)\n }\n\n /** @returns `true` if the point [{@link x}, {@link y}] is in the bottom edge of this rectangle, otherwise `false`. */\n isInBottomEdge(x: number, y: number, edgeSize: number): boolean {\n return isInRectangle(x, y, this.x, this.bottom - edgeSize, this.width, edgeSize)\n }\n\n /** @returns `true` if the point [{@link x}, {@link y}] is in the left edge of this rectangle, otherwise `false`. */\n isInLeftEdge(x: number, y: number, edgeSize: number): boolean {\n return isInRectangle(x, y, this.x, this.y, edgeSize, this.height)\n }\n\n /** @returns `true` if the point [{@link x}, {@link y}] is in the right edge of this rectangle, otherwise `false`. */\n isInRightEdge(x: number, y: number, edgeSize: number): boolean {\n return isInRectangle(x, y, this.right - edgeSize, this.y, edgeSize, this.height)\n }\n\n /** @returns The centre point of this rectangle, as a new {@link Point}. */\n getCentre(): Point {\n return [this.centreX, this.centreY]\n }\n\n /** @returns The area of this rectangle. */\n getArea(): number {\n return this.width * this.height\n }\n\n /** @returns The perimeter of this rectangle. */\n getPerimeter(): number {\n return 2 * (this.width + this.height)\n }\n\n /** @returns The top-left corner of this rectangle, as a new {@link Point}. */\n getTopLeft(): Point {\n return [this[0], this[1]]\n }\n\n /** @returns The bottom-right corner of this rectangle, as a new {@link Point}. */\n getBottomRight(): Point {\n return [this.right, this.bottom]\n }\n\n /** @returns The width and height of this rectangle, as a new {@link Size}. */\n getSize(): Size {\n return [this[2], this[3]]\n }\n\n /** @returns The offset from the top-left of this rectangle to the point [{@link x}, {@link y}], as a new {@link Point}. */\n getOffsetTo([x, y]: ReadOnlyPoint): Point {\n return [x - this[0], y - this[1]]\n }\n\n /** @returns The offset from the point [{@link x}, {@link y}] to the top-left of this rectangle, as a new {@link Point}. */\n getOffsetFrom([x, y]: ReadOnlyPoint): Point {\n return [this[0] - x, this[1] - y]\n }\n\n /** Resizes the rectangle without moving it, setting its top-left corner to [{@link x}, {@link y}]. */\n resizeTopLeft(x1: number, y1: number) {\n this[2] += this[0] - x1\n this[3] += this[1] - y1\n\n this[0] = x1\n this[1] = y1\n }\n\n /** Resizes the rectangle without moving it, setting its bottom-left corner to [{@link x}, {@link y}]. */\n resizeBottomLeft(x1: number, y2: number) {\n this[2] += this[0] - x1\n this[3] = y2 - this[1]\n\n this[0] = x1\n }\n\n /** Resizes the rectangle without moving it, setting its top-right corner to [{@link x}, {@link y}]. */\n resizeTopRight(x2: number, y1: number) {\n this[2] = x2 - this[0]\n this[3] += this[1] - y1\n\n this[1] = y1\n }\n\n /** Resizes the rectangle without moving it, setting its bottom-right corner to [{@link x}, {@link y}]. */\n resizeBottomRight(x2: number, y2: number) {\n this[2] = x2 - this[0]\n this[3] = y2 - this[1]\n }\n\n /** Sets the width without moving the right edge (changes position) */\n setWidthRightAnchored(width: number) {\n const currentWidth = this[2]\n this[2] = width\n this[0] += currentWidth - width\n }\n\n /** Sets the height without moving the bottom edge (changes position) */\n setHeightBottomAnchored(height: number) {\n const currentHeight = this[3]\n this[3] = height\n this[1] += currentHeight - height\n }\n\n clone(): Rectangle {\n return new Rectangle(this[0], this[1], this[2], this[3])\n }\n\n /** Alias of {@link export}. */\n toArray() { return this.export() }\n\n /** @returns A new, untyped array (serializable) containing the values of this rectangle. */\n export(): [number, number, number, number] {\n return [this[0], this[1], this[2], this[3]]\n }\n\n /**\n * Draws a debug outline of this rectangle.\n * @internal Convenience debug/development interface; not for production use.\n */\n _drawDebug(ctx: CanvasRenderingContext2D, colour = \"red\") {\n const { strokeStyle, lineWidth } = ctx\n try {\n ctx.strokeStyle = colour\n ctx.lineWidth = 0.5\n ctx.beginPath()\n ctx.strokeRect(this[0], this[1], this[2], this[3])\n } finally {\n ctx.strokeStyle = strokeStyle\n ctx.lineWidth = lineWidth\n }\n }\n}\n\nexport type ReadOnlyRectangle = Omit<\n ReadOnlyTypedArray<Rectangle>,\n | \"setHeightBottomAnchored\"\n | \"setWidthRightAnchored\"\n | \"resizeTopLeft\"\n | \"resizeBottomLeft\"\n | \"resizeTopRight\"\n | \"resizeBottomRight\"\n | \"resizeBottomRight\"\n | \"updateTo\"\n>\n","import type { INodeInputSlot, INodeOutputSlot, Point } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\n\nimport { isInRectangle } from \"@/measure\"\n\nexport function getNodeInputOnPos(node: LGraphNode, x: number, y: number): { index: number, input: INodeInputSlot, pos: Point } | undefined {\n const { inputs } = node\n if (!inputs) return\n\n for (const [index, input] of inputs.entries()) {\n const pos = node.getInputPos(index)\n\n // TODO: Find a cheap way to measure text, and do it on node label change instead of here\n // Input icon width + text approximation\n const nameLength = input.label?.length ?? input.localized_name?.length ?? input.name?.length\n const width = 20 + (nameLength || 3) * 7\n\n if (isInRectangle(\n x,\n y,\n pos[0] - 10,\n pos[1] - 10,\n width,\n 20,\n )) {\n return { index, input, pos }\n }\n }\n}\n\nexport function getNodeOutputOnPos(node: LGraphNode, x: number, y: number): { index: number, output: INodeOutputSlot, pos: Point } | undefined {\n const { outputs } = node\n if (!outputs) return\n\n for (const [index, output] of outputs.entries()) {\n const pos = node.getOutputPos(index)\n\n if (isInRectangle(\n x,\n y,\n pos[0] - 10,\n pos[1] - 10,\n 40,\n 20,\n )) {\n return { index, output, pos }\n }\n }\n}\n\n/**\n * Returns the input slot index if the given position (in graph space) is on top of a node input slot.\n * A helper function - originally on the prototype of LGraphCanvas.\n */\nexport function isOverNodeInput(\n node: LGraphNode,\n canvasx: number,\n canvasy: number,\n slot_pos?: Point,\n): number {\n const result = getNodeInputOnPos(node, canvasx, canvasy)\n if (!result) return -1\n\n if (slot_pos) {\n slot_pos[0] = result.pos[0]\n slot_pos[1] = result.pos[1]\n }\n return result.index\n}\n\n/**\n * Returns the output slot index if the given position (in graph space) is on top of a node output slot.\n * A helper function - originally on the prototype of LGraphCanvas.\n */\nexport function isOverNodeOutput(\n node: LGraphNode,\n canvasx: number,\n canvasy: number,\n slot_pos?: Point,\n): number {\n const result = getNodeOutputOnPos(node, canvasx, canvasy)\n if (!result) return -1\n\n if (slot_pos) {\n slot_pos[0] = result.pos[0]\n slot_pos[1] = result.pos[1]\n }\n return result.index\n}\n","export class NullGraphError extends Error {\n constructor(message: string = \"Attempted to access LGraph reference that was null or undefined.\", cause?: Error) {\n super(message, { cause })\n this.name = \"NullGraphError\"\n }\n}\n","export interface LGraphIconOptions {\n unicode: string\n fontFamily?: string\n color?: string\n bgColor?: string\n fontSize?: number\n circlePadding?: number\n xOffset?: number\n yOffset?: number\n}\n\nexport class LGraphIcon {\n unicode: string\n fontFamily: string\n color: string\n bgColor?: string\n fontSize: number\n circlePadding: number\n xOffset: number\n yOffset: number\n\n constructor({\n unicode,\n fontFamily = \"PrimeIcons\",\n color = \"#e6c200\",\n bgColor,\n fontSize = 16,\n circlePadding = 2,\n xOffset = 0,\n yOffset = 0,\n }: LGraphIconOptions) {\n this.unicode = unicode\n this.fontFamily = fontFamily\n this.color = color\n this.bgColor = bgColor\n this.fontSize = fontSize\n this.circlePadding = circlePadding\n this.xOffset = xOffset\n this.yOffset = yOffset\n }\n\n draw(ctx: CanvasRenderingContext2D, x: number, y: number) {\n x += this.xOffset\n y += this.yOffset\n\n const { font, textBaseline, textAlign, fillStyle } = ctx\n\n ctx.font = `${this.fontSize}px '${this.fontFamily}'`\n ctx.textBaseline = \"middle\"\n ctx.textAlign = \"center\"\n const iconRadius = this.fontSize / 2 + this.circlePadding\n // Draw icon background circle if bgColor is set\n if (this.bgColor) {\n ctx.beginPath()\n ctx.arc(x + iconRadius, y, iconRadius, 0, 2 * Math.PI)\n ctx.fillStyle = this.bgColor\n ctx.fill()\n }\n // Draw icon\n ctx.fillStyle = this.color\n ctx.fillText(this.unicode, x + iconRadius, y)\n\n ctx.font = font\n ctx.textBaseline = textBaseline\n ctx.textAlign = textAlign\n ctx.fillStyle = fillStyle\n }\n}\n","import { LGraphIcon, type LGraphIconOptions } from \"./LGraphIcon\"\n\nexport enum BadgePosition {\n TopLeft = \"top-left\",\n TopRight = \"top-right\",\n}\n\nexport interface LGraphBadgeOptions {\n text: string\n fgColor?: string\n bgColor?: string\n fontSize?: number\n padding?: number\n height?: number\n cornerRadius?: number\n iconOptions?: LGraphIconOptions\n xOffset?: number\n yOffset?: number\n}\n\nexport class LGraphBadge {\n text: string\n fgColor: string\n bgColor: string\n fontSize: number\n padding: number\n height: number\n cornerRadius: number\n icon?: LGraphIcon\n xOffset: number\n yOffset: number\n\n constructor({\n text,\n fgColor = \"white\",\n bgColor = \"#0F1F0F\",\n fontSize = 12,\n padding = 6,\n height = 20,\n cornerRadius = 5,\n iconOptions,\n xOffset = 0,\n yOffset = 0,\n }: LGraphBadgeOptions) {\n this.text = text\n this.fgColor = fgColor\n this.bgColor = bgColor\n this.fontSize = fontSize\n this.padding = padding\n this.height = height\n this.cornerRadius = cornerRadius\n if (iconOptions) {\n this.icon = new LGraphIcon(iconOptions)\n }\n this.xOffset = xOffset\n this.yOffset = yOffset\n }\n\n get visible() {\n return (this.text?.length ?? 0) > 0 || !!this.icon\n }\n\n getWidth(ctx: CanvasRenderingContext2D) {\n if (!this.visible) return 0\n const { font } = ctx\n let iconWidth = 0\n if (this.icon) {\n ctx.font = `${this.icon.fontSize}px '${this.icon.fontFamily}'`\n iconWidth = ctx.measureText(this.icon.unicode).width + this.padding\n }\n ctx.font = `${this.fontSize}px sans-serif`\n const textWidth = this.text ? ctx.measureText(this.text).width : 0\n ctx.font = font\n return iconWidth + textWidth + this.padding * 2\n }\n\n draw(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n ): void {\n if (!this.visible) return\n\n x += this.xOffset\n y += this.yOffset\n\n const { font, fillStyle, textBaseline, textAlign } = ctx\n\n ctx.font = `${this.fontSize}px sans-serif`\n const badgeWidth = this.getWidth(ctx)\n const badgeX = 0\n\n // Draw badge background\n ctx.fillStyle = this.bgColor\n ctx.beginPath()\n if (ctx.roundRect) {\n ctx.roundRect(x + badgeX, y, badgeWidth, this.height, this.cornerRadius)\n } else {\n // Fallback for browsers that don't support roundRect\n ctx.rect(x + badgeX, y, badgeWidth, this.height)\n }\n ctx.fill()\n\n let drawX = x + badgeX + this.padding\n const centerY = y + this.height / 2\n\n // Draw icon if present\n if (this.icon) {\n this.icon.draw(ctx, drawX, centerY)\n drawX += this.icon.fontSize + this.padding / 2 + 4\n }\n\n // Draw badge text\n if (this.text) {\n ctx.fillStyle = this.fgColor\n ctx.textBaseline = \"middle\"\n ctx.textAlign = \"left\"\n ctx.fillText(this.text, drawX, centerY + 1)\n }\n\n ctx.font = font\n ctx.fillStyle = fillStyle\n ctx.textBaseline = textBaseline\n ctx.textAlign = textAlign\n }\n}\n","import { Rectangle } from \"./infrastructure/Rectangle\"\nimport { LGraphBadge, type LGraphBadgeOptions } from \"./LGraphBadge\"\n\nexport interface LGraphButtonOptions extends LGraphBadgeOptions {\n name?: string // To identify the button\n}\n\nexport class LGraphButton extends LGraphBadge {\n name?: string\n _last_area: Rectangle = new Rectangle()\n\n constructor(options: LGraphButtonOptions) {\n super(options)\n this.name = options.name\n }\n\n override getWidth(ctx: CanvasRenderingContext2D): number {\n if (!this.visible) return 0\n\n const { font } = ctx\n ctx.font = `${this.fontSize}px 'PrimeIcons'`\n\n // For icon buttons, just measure the text width without padding\n const textWidth = this.text ? ctx.measureText(this.text).width : 0\n\n ctx.font = font\n return textWidth\n }\n\n /**\n * @internal\n *\n * Draws the button and updates its last rendered area for hit detection.\n * @param ctx The canvas rendering context.\n * @param x The x-coordinate to draw the button at.\n * @param y The y-coordinate to draw the button at.\n */\n override draw(ctx: CanvasRenderingContext2D, x: number, y: number): void {\n if (!this.visible) {\n return\n }\n\n const width = this.getWidth(ctx)\n\n // Update the hit area\n this._last_area[0] = x + this.xOffset\n this._last_area[1] = y + this.yOffset\n this._last_area[2] = width\n this._last_area[3] = this.height\n\n // Custom drawing for buttons - no background, just icon/text\n const adjustedX = x + this.xOffset\n const adjustedY = y + this.yOffset\n\n const { font, fillStyle, textBaseline, textAlign } = ctx\n\n // Use the same color as the title text (usually white)\n const titleTextColor = ctx.fillStyle || \"white\"\n\n // Draw as icon-only without background\n ctx.font = `${this.fontSize}px 'PrimeIcons'`\n ctx.fillStyle = titleTextColor\n ctx.textBaseline = \"middle\"\n ctx.textAlign = \"center\"\n\n const centerX = adjustedX + width / 2\n const centerY = adjustedY + this.height / 2\n\n if (this.text) {\n ctx.fillText(this.text, centerX, centerY)\n }\n\n // Restore context\n ctx.font = font\n ctx.fillStyle = fillStyle\n ctx.textBaseline = textBaseline\n ctx.textAlign = textAlign\n }\n\n /**\n * Checks if a point is inside the button's last rendered area.\n * @param x The x-coordinate of the point.\n * @param y The y-coordinate of the point.\n * @returns `true` if the point is inside the button, otherwise `false`.\n */\n isPointInside(x: number, y: number): boolean {\n return this._last_area.containsPoint([x, y])\n }\n}\n","import type { Rectangle } from \"./infrastructure/Rectangle\"\nimport type { CanvasColour, Rect } from \"./interfaces\"\n\nimport { LiteGraph } from \"./litegraph\"\nimport { LinkDirection, RenderShape, TitleMode } from \"./types/globalEnums\"\n\nconst ELLIPSIS = \"\\u2026\"\nconst TWO_DOT_LEADER = \"\\u2025\"\nconst ONE_DOT_LEADER = \"\\u2024\"\n\nexport enum SlotType {\n Array = \"array\",\n Event = -1,\n}\n\n/** @see RenderShape */\nexport enum SlotShape {\n Box = RenderShape.BOX,\n Arrow = RenderShape.ARROW,\n Grid = RenderShape.GRID,\n Circle = RenderShape.CIRCLE,\n HollowCircle = RenderShape.HollowCircle,\n}\n\n/** @see LinkDirection */\nexport enum SlotDirection {\n Up = LinkDirection.UP,\n Right = LinkDirection.RIGHT,\n Down = LinkDirection.DOWN,\n Left = LinkDirection.LEFT,\n}\n\nexport enum LabelPosition {\n Left = \"left\",\n Right = \"right\",\n}\n\nexport interface IDrawBoundingOptions {\n /** The shape to render */\n shape?: RenderShape\n /** The radius of the rounded corners for {@link RenderShape.ROUND} and {@link RenderShape.CARD} */\n round_radius?: number\n /** Shape will extend above the Y-axis 0 by this amount @deprecated This is node-specific: it should be removed entirely, and behaviour defined by the caller more explicitly */\n title_height?: number\n /** @deprecated This is node-specific: it should be removed entirely, and behaviour defined by the caller more explicitly */\n title_mode?: TitleMode\n /** The color that should be drawn */\n color?: CanvasColour\n /** The distance between the edge of the {@link area} and the middle of the line */\n padding?: number\n /** @deprecated This is node-specific: it should be removed entirely, and behaviour defined by the caller more explicitly */\n collapsed?: boolean\n /** Thickness of the line drawn (`lineWidth`) */\n lineWidth?: number\n}\n\nexport interface IDrawTextInAreaOptions {\n /** The canvas to draw the text on. */\n ctx: CanvasRenderingContext2D\n /** The text to draw. */\n text: string\n /** The area the text will be drawn in. */\n area: Rectangle\n /** The alignment of the text. */\n align?: \"left\" | \"right\" | \"center\"\n}\n\n/**\n * Draws only the path of a shape on the canvas, without filling.\n * Used to draw indicators for node status, e.g. \"selected\".\n * @param ctx The 2D context to draw on\n * @param area The position and size of the shape to render\n */\nexport function strokeShape(\n ctx: CanvasRenderingContext2D,\n area: Rect,\n {\n shape = RenderShape.BOX,\n round_radius,\n title_height,\n title_mode = TitleMode.NORMAL_TITLE,\n color,\n padding = 6,\n collapsed = false,\n lineWidth: thickness = 1,\n }: IDrawBoundingOptions = {},\n): void {\n // These param defaults are not compile-time static, and must be re-evaluated at runtime\n round_radius ??= LiteGraph.ROUND_RADIUS\n color ??= LiteGraph.NODE_BOX_OUTLINE_COLOR\n\n // Adjust area if title is transparent\n if (title_mode === TitleMode.TRANSPARENT_TITLE) {\n const height = title_height ?? LiteGraph.NODE_TITLE_HEIGHT\n area[1] -= height\n area[3] += height\n }\n\n // Set up context\n const { lineWidth, strokeStyle } = ctx\n ctx.lineWidth = thickness\n ctx.globalAlpha = 0.8\n ctx.strokeStyle = color\n ctx.beginPath()\n\n // Draw shape based on type\n const [x, y, width, height] = area\n switch (shape) {\n case RenderShape.BOX: {\n ctx.rect(\n x - padding,\n y - padding,\n width + 2 * padding,\n height + 2 * padding,\n )\n break\n }\n case RenderShape.ROUND:\n case RenderShape.CARD: {\n const radius = round_radius + padding\n const isCollapsed = shape === RenderShape.CARD && collapsed\n const cornerRadii =\n isCollapsed || shape === RenderShape.ROUND\n ? [radius]\n : [radius, 2, radius, 2]\n ctx.roundRect(\n x - padding,\n y - padding,\n width + 2 * padding,\n height + 2 * padding,\n cornerRadii,\n )\n break\n }\n case RenderShape.CIRCLE: {\n const centerX = x + width / 2\n const centerY = y + height / 2\n const radius = Math.max(width, height) / 2 + padding\n ctx.arc(centerX, centerY, radius, 0, Math.PI * 2)\n break\n }\n }\n\n // Stroke the shape\n ctx.stroke()\n\n // Reset context\n ctx.lineWidth = lineWidth\n ctx.strokeStyle = strokeStyle\n\n // TODO: Store and reset value properly. Callers currently expect this behaviour (e.g. muted nodes).\n ctx.globalAlpha = 1\n}\n\n/**\n * Truncates text using binary search to fit within a given width, appending an ellipsis if needed.\n * @param ctx The canvas rendering context.\n * @param text The text to truncate.\n * @param maxWidth The maximum width the text (plus ellipsis) can occupy.\n * @returns The truncated text, or the original text if it fits.\n */\nfunction truncateTextToWidth(ctx: CanvasRenderingContext2D, text: string, maxWidth: number): string {\n if (!(maxWidth > 0)) return \"\"\n\n // Text fits\n const fullWidth = ctx.measureText(text).width\n if (fullWidth <= maxWidth) return text\n\n const ellipsisWidth = ctx.measureText(ELLIPSIS).width * 0.75\n\n // Can't even fit ellipsis\n if (ellipsisWidth > maxWidth) {\n const twoDotsWidth = ctx.measureText(TWO_DOT_LEADER).width * 0.75\n if (twoDotsWidth < maxWidth) return TWO_DOT_LEADER\n\n const oneDotWidth = ctx.measureText(ONE_DOT_LEADER).width * 0.75\n return oneDotWidth < maxWidth ? ONE_DOT_LEADER : \"\"\n }\n\n let min = 0\n let max = text.length\n let bestLen = 0\n\n // Binary search for the longest substring that fits with the ellipsis\n while (min <= max) {\n const mid = Math.floor((min + max) * 0.5)\n\n // Avoid measuring empty string + ellipsis\n if (mid === 0) {\n min = mid + 1\n continue\n }\n\n const sub = text.substring(0, mid)\n const currentWidth = ctx.measureText(sub).width + ellipsisWidth\n\n if (currentWidth <= maxWidth) {\n // This length fits, try potentially longer\n bestLen = mid\n min = mid + 1\n } else {\n // Too long, try shorter\n max = mid - 1\n }\n }\n\n return bestLen === 0\n ? ELLIPSIS\n : text.substring(0, bestLen) + ELLIPSIS\n}\n\n/**\n * Draws text within an area, truncating it and adding an ellipsis if necessary.\n */\nexport function drawTextInArea({ ctx, text, area, align = \"left\" }: IDrawTextInAreaOptions) {\n const { left, right, bottom, width, centreX } = area\n\n // Text already fits\n const fullWidth = ctx.measureText(text).width\n if (fullWidth <= width) {\n ctx.textAlign = align\n const x = align === \"left\" ? left : (align === \"right\" ? right : centreX)\n ctx.fillText(text, x, bottom)\n return\n }\n\n // Need to truncate text\n const truncated = truncateTextToWidth(ctx, text, width)\n if (truncated.length === 0) return\n\n // Draw text - left-aligned to prevent bouncing during resize\n ctx.textAlign = \"left\"\n ctx.fillText(truncated.slice(0, -1), left, bottom)\n ctx.rect(left, bottom, width, 1)\n\n // Draw the ellipsis, right-aligned to the button\n ctx.textAlign = \"right\"\n const ellipsis = truncated.at(-1)!\n ctx.fillText(ellipsis, right, bottom, ctx.measureText(ellipsis).width * 0.75)\n}\n","import type { CanvasColour, DefaultConnectionColors, INodeSlot, ISlotType, IWidgetLocator, Point } from \"@/interfaces\"\nimport type { LLink } from \"@/LLink\"\nimport type { RenderShape } from \"@/types/globalEnums\"\nimport type { LinkDirection } from \"@/types/globalEnums\"\n\nimport { Rectangle } from \"@/infrastructure/Rectangle\"\n\n/** Base class for all input & output slots. */\n\nexport abstract class SlotBase implements INodeSlot {\n name: string\n localized_name?: string\n label?: string\n type: ISlotType\n dir?: LinkDirection\n removable?: boolean\n shape?: RenderShape\n color_off?: CanvasColour\n color_on?: CanvasColour\n locked?: boolean\n nameLocked?: boolean\n widget?: IWidgetLocator\n _floatingLinks?: Set<LLink>\n hasErrors?: boolean\n\n /** The centre point of the slot. */\n abstract pos?: Point\n readonly boundingRect: Rectangle\n\n constructor(name: string, type: ISlotType, boundingRect?: Rectangle) {\n this.name = name\n this.type = type\n this.boundingRect = boundingRect ?? new Rectangle()\n }\n\n abstract get isConnected(): boolean\n\n renderingColor(colorContext: DefaultConnectionColors): CanvasColour {\n return this.isConnected\n ? this.color_on || colorContext.getConnectedColor(this.type)\n : this.color_off || colorContext.getDisconnectedColor(this.type)\n }\n}\n","import type { CanvasColour, DefaultConnectionColors, INodeInputSlot, INodeOutputSlot, INodeSlot, ISubgraphInput, OptionalProps, Point, ReadOnlyPoint } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { SubgraphInput } from \"@/subgraph/SubgraphInput\"\nimport type { SubgraphOutput } from \"@/subgraph/SubgraphOutput\"\n\nimport { LabelPosition, SlotShape, SlotType } from \"@/draw\"\nimport { LiteGraph, Rectangle } from \"@/litegraph\"\nimport { getCentre } from \"@/measure\"\nimport { LinkDirection, RenderShape } from \"@/types/globalEnums\"\n\nimport { NodeInputSlot } from \"./NodeInputSlot\"\nimport { SlotBase } from \"./SlotBase\"\n\nexport interface IDrawOptions {\n colorContext: DefaultConnectionColors\n labelPosition?: LabelPosition\n lowQuality?: boolean\n doStroke?: boolean\n highlight?: boolean\n}\n\n/** Shared base class for {@link LGraphNode} input and output slots. */\nexport abstract class NodeSlot extends SlotBase implements INodeSlot {\n pos?: Point\n\n /** The offset from the parent node to the centre point of this slot. */\n get #centreOffset(): ReadOnlyPoint {\n const nodePos = this.node.pos\n const { boundingRect } = this\n\n // Use height; widget input slots may be thinner.\n const diameter = boundingRect[3]\n\n return getCentre([\n boundingRect[0] - nodePos[0],\n boundingRect[1] - nodePos[1],\n diameter,\n diameter,\n ])\n }\n\n /** The center point of this slot when the node is collapsed. */\n abstract get collapsedPos(): ReadOnlyPoint\n\n #node: LGraphNode\n get node(): LGraphNode {\n return this.#node\n }\n\n get highlightColor(): CanvasColour {\n return LiteGraph.NODE_TEXT_HIGHLIGHT_COLOR ?? LiteGraph.NODE_SELECTED_TITLE_COLOR ?? LiteGraph.NODE_TEXT_COLOR\n }\n\n abstract get isWidgetInputSlot(): boolean\n\n constructor(slot: OptionalProps<INodeSlot, \"boundingRect\">, node: LGraphNode) {\n // Workaround: Ensure internal properties are not copied to the slot (_listenerController\n // https://github.com/Comfy-Org/litegraph.js/issues/1138\n const maybeSubgraphSlot: OptionalProps<ISubgraphInput, \"link\" | \"boundingRect\"> = slot\n const { boundingRect, name, type, _listenerController, ...rest } = maybeSubgraphSlot\n const rectangle = boundingRect ? Rectangle.ensureRect(boundingRect) : new Rectangle()\n\n super(name, type, rectangle)\n\n Object.assign(this, rest)\n this.#node = node\n }\n\n /**\n * Whether this slot is a valid target for a dragging link.\n * @param fromSlot The slot that the link is being connected from.\n */\n abstract isValidTarget(fromSlot: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput): boolean\n\n /**\n * The label to display in the UI.\n */\n get renderingLabel(): string {\n return this.label || this.localized_name || this.name || \"\"\n }\n\n draw(\n ctx: CanvasRenderingContext2D,\n {\n colorContext,\n labelPosition = LabelPosition.Right,\n lowQuality = false,\n highlight = false,\n doStroke = false,\n }: IDrawOptions,\n ) {\n // Save the current fillStyle and strokeStyle\n const originalFillStyle = ctx.fillStyle\n const originalStrokeStyle = ctx.strokeStyle\n const originalLineWidth = ctx.lineWidth\n\n const labelColor = highlight\n ? this.highlightColor\n : LiteGraph.NODE_TEXT_COLOR\n\n const pos = this.#centreOffset\n const slot_type = this.type\n const slot_shape = (\n slot_type === SlotType.Array ? SlotShape.Grid : this.shape\n ) as SlotShape\n\n ctx.beginPath()\n let doFill = true\n\n ctx.fillStyle = this.renderingColor(colorContext)\n ctx.lineWidth = 1\n if (slot_type === SlotType.Event || slot_shape === SlotShape.Box) {\n ctx.rect(pos[0] - 6 + 0.5, pos[1] - 5 + 0.5, 14, 10)\n } else if (slot_shape === SlotShape.Arrow) {\n ctx.moveTo(pos[0] + 8, pos[1] + 0.5)\n ctx.lineTo(pos[0] - 4, pos[1] + 6 + 0.5)\n ctx.lineTo(pos[0] - 4, pos[1] - 6 + 0.5)\n ctx.closePath()\n } else if (slot_shape === SlotShape.Grid) {\n const gridSize = 3\n const cellSize = 2\n const spacing = 3\n\n for (let x = 0; x < gridSize; x++) {\n for (let y = 0; y < gridSize; y++) {\n ctx.rect(\n pos[0] - 4 + x * spacing,\n pos[1] - 4 + y * spacing,\n cellSize,\n cellSize,\n )\n }\n }\n doStroke = false\n } else {\n // Default rendering for circle, hollow circle.\n if (lowQuality) {\n ctx.rect(pos[0] - 4, pos[1] - 4, 8, 8)\n } else {\n let radius: number\n if (slot_shape === SlotShape.HollowCircle) {\n doFill = false\n doStroke = true\n ctx.lineWidth = 3\n ctx.strokeStyle = ctx.fillStyle\n radius = highlight ? 4 : 3\n } else {\n // Normal circle\n radius = highlight ? 5 : 4\n }\n ctx.arc(pos[0], pos[1], radius, 0, Math.PI * 2)\n }\n }\n\n if (doFill) ctx.fill()\n if (!lowQuality && doStroke) ctx.stroke()\n\n // render slot label\n const hideLabel = lowQuality || this.isWidgetInputSlot\n if (!hideLabel) {\n const text = this.renderingLabel\n if (text) {\n // TODO: Finish impl. Highlight text on mouseover unless we're connecting links.\n ctx.fillStyle = labelColor\n\n if (labelPosition === LabelPosition.Right) {\n if (this.dir == LinkDirection.UP) {\n ctx.fillText(text, pos[0], pos[1] - 10)\n } else {\n ctx.fillText(text, pos[0] + 10, pos[1] + 5)\n }\n } else {\n if (this.dir == LinkDirection.DOWN) {\n ctx.fillText(text, pos[0], pos[1] - 8)\n } else {\n ctx.fillText(text, pos[0] - 10, pos[1] + 5)\n }\n }\n }\n }\n\n // Draw a red circle if the slot has errors.\n if (this.hasErrors) {\n ctx.lineWidth = 2\n ctx.strokeStyle = \"red\"\n ctx.beginPath()\n ctx.arc(pos[0], pos[1], 12, 0, Math.PI * 2)\n ctx.stroke()\n }\n\n // Restore the original fillStyle and strokeStyle\n ctx.fillStyle = originalFillStyle\n ctx.strokeStyle = originalStrokeStyle\n ctx.lineWidth = originalLineWidth\n }\n\n drawCollapsed(ctx: CanvasRenderingContext2D) {\n const [x, y] = this.collapsedPos\n\n // Save original styles\n const { fillStyle } = ctx\n\n ctx.fillStyle = \"#686\"\n ctx.beginPath()\n\n if (this.type === SlotType.Event || this.shape === RenderShape.BOX) {\n ctx.rect(x - 7 + 0.5, y - 4, 14, 8)\n } else if (this.shape === RenderShape.ARROW) {\n // Adjust arrow direction based on whether this is an input or output slot\n const isInput = this instanceof NodeInputSlot\n if (isInput) {\n ctx.moveTo(x + 8, y)\n ctx.lineTo(x - 4, y - 4)\n ctx.lineTo(x - 4, y + 4)\n } else {\n ctx.moveTo(x + 6, y)\n ctx.lineTo(x - 6, y - 4)\n ctx.lineTo(x - 6, y + 4)\n }\n ctx.closePath()\n } else {\n ctx.arc(x, y, 4, 0, Math.PI * 2)\n }\n ctx.fill()\n\n // Restore original styles\n ctx.fillStyle = fillStyle\n }\n}\n","import type {\n ColorOption,\n IColorable,\n IContextMenuValue,\n IPinnable,\n Point,\n Positionable,\n Size,\n} from \"./interfaces\"\nimport type { LGraph } from \"./LGraph\"\nimport type { ISerialisedGroup } from \"./types/serialisation\"\n\nimport { NullGraphError } from \"@/infrastructure/NullGraphError\"\n\nimport { strokeShape } from \"./draw\"\nimport { LGraphCanvas } from \"./LGraphCanvas\"\nimport { LGraphNode } from \"./LGraphNode\"\nimport { LiteGraph } from \"./litegraph\"\nimport {\n containsCentre,\n containsRect,\n createBounds,\n isInRectangle,\n isPointInRect,\n snapPoint,\n} from \"./measure\"\n\nexport interface IGraphGroupFlags extends Record<string, unknown> {\n pinned?: true\n}\n\nexport class LGraphGroup implements Positionable, IPinnable, IColorable {\n static minWidth = 140\n static minHeight = 80\n static resizeLength = 10\n static padding = 4\n static defaultColour = \"#335\"\n\n id: number\n color?: string\n title: string\n font?: string\n font_size: number = LiteGraph.DEFAULT_GROUP_FONT || 24\n _bounding: Float32Array = new Float32Array([\n 10,\n 10,\n LGraphGroup.minWidth,\n LGraphGroup.minHeight,\n ])\n\n _pos: Point = this._bounding.subarray(0, 2)\n _size: Size = this._bounding.subarray(2, 4)\n /** @deprecated See {@link _children} */\n _nodes: LGraphNode[] = []\n _children: Set<Positionable> = new Set()\n graph?: LGraph\n flags: IGraphGroupFlags = {}\n selected?: boolean\n\n constructor(title?: string, id?: number) {\n // TODO: Object instantiation pattern requires too much boilerplate and null checking. ID should be passed in via constructor.\n this.id = id ?? -1\n this.title = title || \"Group\"\n\n const { pale_blue } = LGraphCanvas.node_colors\n this.color = pale_blue ? pale_blue.groupcolor : \"#AAA\"\n }\n\n /** @inheritdoc {@link IColorable.setColorOption} */\n setColorOption(colorOption: ColorOption | null): void {\n if (colorOption == null) {\n delete this.color\n } else {\n this.color = colorOption.groupcolor\n }\n }\n\n /** @inheritdoc {@link IColorable.getColorOption} */\n getColorOption(): ColorOption | null {\n return Object.values(LGraphCanvas.node_colors).find(\n colorOption => colorOption.groupcolor === this.color,\n ) ?? null\n }\n\n /** Position of the group, as x,y co-ordinates in graph space */\n get pos() {\n return this._pos\n }\n\n set pos(v) {\n if (!v || v.length < 2) return\n\n this._pos[0] = v[0]\n this._pos[1] = v[1]\n }\n\n /** Size of the group, as width,height in graph units */\n get size() {\n return this._size\n }\n\n set size(v) {\n if (!v || v.length < 2) return\n\n this._size[0] = Math.max(LGraphGroup.minWidth, v[0])\n this._size[1] = Math.max(LGraphGroup.minHeight, v[1])\n }\n\n get boundingRect() {\n return this._bounding\n }\n\n get nodes() {\n return this._nodes\n }\n\n get titleHeight() {\n return this.font_size * 1.4\n }\n\n get children(): ReadonlySet<Positionable> {\n return this._children\n }\n\n get pinned() {\n return !!this.flags.pinned\n }\n\n /**\n * Prevents the group being accidentally moved or resized by mouse interaction.\n * Toggles pinned state if no value is provided.\n */\n pin(value?: boolean): void {\n const newState = value === undefined ? !this.pinned : value\n\n if (newState) this.flags.pinned = true\n else delete this.flags.pinned\n }\n\n unpin(): void {\n this.pin(false)\n }\n\n configure(o: ISerialisedGroup): void {\n this.id = o.id\n this.title = o.title\n this._bounding.set(o.bounding)\n this.color = o.color\n this.flags = o.flags || this.flags\n if (o.font_size) this.font_size = o.font_size\n }\n\n serialize(): ISerialisedGroup {\n const b = this._bounding\n return {\n id: this.id,\n title: this.title,\n bounding: [...b],\n color: this.color,\n font_size: this.font_size,\n flags: this.flags,\n }\n }\n\n /**\n * Draws the group on the canvas\n * @param graphCanvas\n * @param ctx\n */\n draw(graphCanvas: LGraphCanvas, ctx: CanvasRenderingContext2D): void {\n const { padding, resizeLength, defaultColour } = LGraphGroup\n const font_size = this.font_size || LiteGraph.DEFAULT_GROUP_FONT_SIZE\n\n const [x, y] = this._pos\n const [width, height] = this._size\n const color = this.color || defaultColour\n\n // Titlebar\n ctx.globalAlpha = 0.25 * graphCanvas.editor_alpha\n ctx.fillStyle = color\n ctx.strokeStyle = color\n ctx.beginPath()\n ctx.rect(x + 0.5, y + 0.5, width, font_size * 1.4)\n ctx.fill()\n\n // Group background, border\n ctx.fillStyle = color\n ctx.strokeStyle = color\n ctx.beginPath()\n ctx.rect(x + 0.5, y + 0.5, width, height)\n ctx.fill()\n ctx.globalAlpha = graphCanvas.editor_alpha\n ctx.stroke()\n\n // Resize marker\n ctx.beginPath()\n ctx.moveTo(x + width, y + height)\n ctx.lineTo(x + width - resizeLength, y + height)\n ctx.lineTo(x + width, y + height - resizeLength)\n ctx.fill()\n\n // Title\n ctx.font = `${font_size}px ${LiteGraph.GROUP_FONT}`\n ctx.textAlign = \"left\"\n ctx.fillText(this.title + (this.pinned ? \"📌\" : \"\"), x + padding, y + font_size)\n\n if (LiteGraph.highlight_selected_group && this.selected) {\n strokeShape(ctx, this._bounding, {\n title_height: this.titleHeight,\n padding,\n })\n }\n }\n\n resize(width: number, height: number): boolean {\n if (this.pinned) return false\n\n this._size[0] = Math.max(LGraphGroup.minWidth, width)\n this._size[1] = Math.max(LGraphGroup.minHeight, height)\n return true\n }\n\n move(deltaX: number, deltaY: number, skipChildren: boolean = false): void {\n if (this.pinned) return\n\n this._pos[0] += deltaX\n this._pos[1] += deltaY\n if (skipChildren === true) return\n\n for (const item of this._children) {\n item.move(deltaX, deltaY)\n }\n }\n\n /** @inheritdoc */\n snapToGrid(snapTo: number): boolean {\n return this.pinned ? false : snapPoint(this.pos, snapTo)\n }\n\n recomputeInsideNodes(): void {\n if (!this.graph) throw new NullGraphError()\n const { nodes, reroutes, groups } = this.graph\n const children = this._children\n this._nodes.length = 0\n children.clear()\n\n // Move nodes we overlap the centre point of\n for (const node of nodes) {\n if (containsCentre(this._bounding, node.boundingRect)) {\n this._nodes.push(node)\n children.add(node)\n }\n }\n\n // Move reroutes we overlap the centre point of\n for (const reroute of reroutes.values()) {\n if (isPointInRect(reroute.pos, this._bounding))\n children.add(reroute)\n }\n\n // Move groups we wholly contain\n for (const group of groups) {\n if (containsRect(this._bounding, group._bounding))\n children.add(group)\n }\n\n groups.sort((a, b) => {\n if (a === this) {\n return children.has(b) ? -1 : 0\n } else if (b === this) {\n return children.has(a) ? 1 : 0\n } else {\n return 0\n }\n })\n }\n\n /**\n * Resizes and moves the group to neatly fit all given {@link objects}.\n * @param objects All objects that should be inside the group\n * @param padding Value in graph units to add to all sides of the group. Default: 10\n */\n resizeTo(objects: Iterable<Positionable>, padding: number = 10): void {\n const boundingBox = createBounds(objects, padding)\n if (boundingBox === null) return\n\n this.pos[0] = boundingBox[0]\n this.pos[1] = boundingBox[1] - this.titleHeight\n this.size[0] = boundingBox[2]\n this.size[1] = boundingBox[3] + this.titleHeight\n }\n\n /**\n * Add nodes to the group and adjust the group's position and size accordingly\n * @param nodes The nodes to add to the group\n * @param padding The padding around the group\n */\n addNodes(nodes: LGraphNode[], padding: number = 10): void {\n if (!this._nodes && nodes.length === 0) return\n this.resizeTo([...this.children, ...this._nodes, ...nodes], padding)\n }\n\n getMenuOptions(): (IContextMenuValue<string> | IContextMenuValue<string | null> | null)[] {\n return [\n {\n content: this.pinned ? \"Unpin\" : \"Pin\",\n callback: () => {\n if (this.pinned) this.unpin()\n else this.pin()\n this.setDirtyCanvas(false, true)\n },\n },\n null,\n { content: \"Title\", callback: LGraphCanvas.onShowPropertyEditor },\n {\n content: \"Color\",\n has_submenu: true,\n callback: LGraphCanvas.onMenuNodeColors,\n },\n {\n content: \"Font size\",\n property: \"font_size\",\n type: \"Number\",\n callback: LGraphCanvas.onShowPropertyEditor,\n },\n null,\n { content: \"Remove\", callback: LGraphCanvas.onMenuNodeRemove },\n ]\n }\n\n isPointInTitlebar(x: number, y: number): boolean {\n const b = this.boundingRect\n return isInRectangle(x, y, b[0], b[1], b[2], this.titleHeight)\n }\n\n isInResize(x: number, y: number): boolean {\n const b = this.boundingRect\n const right = b[0] + b[2]\n const bottom = b[1] + b[3]\n\n return (\n x < right &&\n y < bottom &&\n x - right + (y - bottom) > -LGraphGroup.resizeLength\n )\n }\n\n isPointInside = LGraphNode.prototype.isPointInside\n setDirtyCanvas = LGraphNode.prototype.setDirtyCanvas\n}\n","import type {\n CanvasColour,\n INodeInputSlot,\n INodeOutputSlot,\n LinkNetwork,\n LinkSegment,\n Point,\n Positionable,\n ReadonlyLinkNetwork,\n ReadOnlyRect,\n} from \"./interfaces\"\nimport type { LGraphNode, NodeId } from \"./LGraphNode\"\nimport type { Serialisable, SerialisableReroute } from \"./types/serialisation\"\n\nimport { LGraphBadge } from \"./LGraphBadge\"\nimport { type LinkId, LLink } from \"./LLink\"\nimport { distance, isPointInRect } from \"./measure\"\n\nexport type RerouteId = number\n\n/** The input or output slot that an incomplete reroute link is connected to. */\nexport interface FloatingRerouteSlot {\n /** Floating connection to an input or output */\n slotType: \"input\" | \"output\"\n}\n\n/**\n * Represents an additional point on the graph that a link path will travel through. Used for visual organisation only.\n *\n * Requires no disposal or clean up.\n * Stores only primitive values (IDs) to reference other items in its network,\n * and a `WeakRef` to a {@link LinkNetwork} to resolve them.\n */\nexport class Reroute implements Positionable, LinkSegment, Serialisable<SerialisableReroute> {\n static radius: number = 10\n /** Maximum distance from reroutes to their bezier curve control points. */\n static maxSplineOffset: number = 80\n static drawIdBadge: boolean = false\n static slotRadius: number = 5\n /** Distance from reroute centre to slot centre. */\n static get slotOffset(): number {\n const gap = Reroute.slotRadius * 0.33\n return Reroute.radius + gap + Reroute.slotRadius\n }\n\n #malloc = new Float32Array(8)\n\n /** The network this reroute belongs to. Contains all valid links and reroutes. */\n #network: WeakRef<LinkNetwork>\n\n #parentId?: RerouteId\n public get parentId(): RerouteId | undefined {\n return this.#parentId\n }\n\n /** Ignores attempts to create an infinite loop. @inheritdoc */\n public set parentId(value) {\n if (value === this.id) return\n if (this.getReroutes() === null) return\n this.#parentId = value\n }\n\n public get parent(): Reroute | undefined {\n return this.#network.deref()?.getReroute(this.#parentId)\n }\n\n /** This property is only defined on the last reroute of a floating reroute chain (closest to input end). */\n floating?: FloatingRerouteSlot\n\n #pos = this.#malloc.subarray(0, 2)\n /** @inheritdoc */\n get pos(): Point {\n return this.#pos\n }\n\n set pos(value: Point) {\n if (!(value?.length >= 2))\n throw new TypeError(\"Reroute.pos is an x,y point, and expects an indexable with at least two values.\")\n this.#pos[0] = value[0]\n this.#pos[1] = value[1]\n }\n\n /** @inheritdoc */\n get boundingRect(): ReadOnlyRect {\n const { radius } = Reroute\n const [x, y] = this.#pos\n return [x - radius, y - radius, 2 * radius, 2 * radius]\n }\n\n /**\n * Slightly over-sized rectangle, guaranteed to contain the entire surface area for hover detection.\n * Eliminates most hover positions using an extremely cheap check.\n */\n get #hoverArea(): ReadOnlyRect {\n const xOffset = 2 * Reroute.slotOffset\n const yOffset = 2 * Math.max(Reroute.radius, Reroute.slotRadius)\n\n const [x, y] = this.#pos\n return [x - xOffset, y - yOffset, 2 * xOffset, 2 * yOffset]\n }\n\n /** The total number of links & floating links using this reroute */\n get totalLinks(): number {\n return this.linkIds.size + this.floatingLinkIds.size\n }\n\n /** @inheritdoc */\n selected?: boolean\n\n /** The ID ({@link LLink.id}) of every link using this reroute */\n linkIds: Set<LinkId>\n\n /** The ID ({@link LLink.id}) of every floating link using this reroute */\n floatingLinkIds: Set<LinkId>\n\n /** Cached cos */\n cos: number = 0\n sin: number = 0\n\n /** Bezier curve control point for the \"target\" (input) side of the link */\n controlPoint: Point = this.#malloc.subarray(4, 6)\n\n /** @inheritdoc */\n path?: Path2D\n /** @inheritdoc */\n _centreAngle?: number\n /** @inheritdoc */\n _pos: Float32Array = this.#malloc.subarray(6, 8)\n\n /** @inheritdoc */\n _dragging?: boolean\n\n /** Colour of the first link that rendered this reroute */\n _colour?: CanvasColour\n\n /** Colour of the first link that rendered this reroute */\n get colour(): CanvasColour {\n return this._colour ?? \"#18184d\"\n }\n\n /**\n * Used to ensure reroute angles are only executed once per frame.\n * @todo Calculate on change instead.\n */\n #lastRenderTime: number = -Infinity\n\n #inputSlot = new RerouteSlot(this, true)\n #outputSlot = new RerouteSlot(this, false)\n\n get isSlotHovered(): boolean {\n return this.isInputHovered || this.isOutputHovered\n }\n\n get isInputHovered(): boolean {\n return this.#inputSlot.hovering\n }\n\n get isOutputHovered(): boolean {\n return this.#outputSlot.hovering\n }\n\n get firstLink(): LLink | undefined {\n const linkId = this.linkIds.values().next().value\n return linkId === undefined\n ? undefined\n : this.#network\n .deref()\n ?.links\n .get(linkId)\n }\n\n get firstFloatingLink(): LLink | undefined {\n const linkId = this.floatingLinkIds.values().next().value\n return linkId === undefined\n ? undefined\n : this.#network\n .deref()\n ?.floatingLinks\n .get(linkId)\n }\n\n /** @inheritdoc */\n get origin_id(): NodeId | undefined {\n return this.firstLink?.origin_id\n }\n\n /** @inheritdoc */\n get origin_slot(): number | undefined {\n return this.firstLink?.origin_slot\n }\n\n /**\n * Initialises a new link reroute object.\n * @param id Unique identifier for this reroute\n * @param network The network of links this reroute belongs to. Internally converted to a WeakRef.\n * @param pos Position in graph coordinates\n * @param linkIds Link IDs ({@link LLink.id}) of all links that use this reroute\n */\n constructor(\n public readonly id: RerouteId,\n network: LinkNetwork,\n pos?: Point,\n parentId?: RerouteId,\n linkIds?: Iterable<LinkId>,\n floatingLinkIds?: Iterable<LinkId>,\n ) {\n this.#network = new WeakRef(network)\n this.parentId = parentId\n if (pos) this.pos = pos\n this.linkIds = new Set(linkIds)\n this.floatingLinkIds = new Set(floatingLinkIds)\n }\n\n /**\n * Applies a new parentId to the reroute, and optinoally a new position and linkId.\n * Primarily used for deserialisation.\n * @param parentId The ID of the reroute prior to this reroute, or\n * `undefined` if it is the first reroute connected to a nodes output\n * @param pos The position of this reroute\n * @param linkIds All link IDs that pass through this reroute\n */\n update(\n parentId: RerouteId | undefined,\n pos?: Point,\n linkIds?: Iterable<LinkId>,\n floating?: FloatingRerouteSlot,\n ): void {\n this.parentId = parentId\n if (pos) this.pos = pos\n if (linkIds) this.linkIds = new Set(linkIds)\n this.floating = floating\n }\n\n /**\n * Validates the linkIds this reroute has. Removes broken links.\n * @param links Collection of valid links\n * @returns true if any links remain after validation\n */\n validateLinks(links: ReadonlyMap<LinkId, LLink>, floatingLinks: ReadonlyMap<LinkId, LLink>): boolean {\n const { linkIds, floatingLinkIds } = this\n for (const linkId of linkIds) {\n if (!links.has(linkId)) linkIds.delete(linkId)\n }\n for (const linkId of floatingLinkIds) {\n if (!floatingLinks.has(linkId)) floatingLinkIds.delete(linkId)\n }\n return linkIds.size > 0 || floatingLinkIds.size > 0\n }\n\n /**\n * Retrieves an ordered array of all reroutes from the node output.\n * @param visited Internal. A set of reroutes that this function\n * has already visited whilst recursing up the chain.\n * @returns An ordered array of all reroutes from the node output to this reroute, inclusive.\n * `null` if an infinite loop is detected.\n * `undefined` if the reroute chain or {@link LinkNetwork} are invalid.\n */\n getReroutes(visited = new Set<Reroute>()): Reroute[] | null {\n // No parentId - last in the chain\n if (this.#parentId === undefined) return [this]\n // Invalid chain - looped\n if (visited.has(this)) return null\n visited.add(this)\n\n const parent = this.#network.deref()?.reroutes.get(this.#parentId)\n // Invalid parent (or network) - drop silently to recover\n if (!parent) {\n this.#parentId = undefined\n return [this]\n }\n\n const reroutes = parent.getReroutes(visited)\n reroutes?.push(this)\n return reroutes\n }\n\n /**\n * Internal. Called by {@link LLink.findNextReroute}. Not intended for use by itself.\n * @param withParentId The rerouteId to look for\n * @param visited A set of reroutes that have already been visited\n * @returns The reroute that was found, `undefined` if no reroute was found, or `null` if an infinite loop was detected.\n */\n findNextReroute(\n withParentId: RerouteId,\n visited = new Set<Reroute>(),\n ): Reroute | null | undefined {\n if (this.#parentId === withParentId) return this\n if (visited.has(this)) return null\n visited.add(this)\n if (this.#parentId === undefined) return\n\n return this.#network\n .deref()\n ?.reroutes\n .get(this.#parentId)\n ?.findNextReroute(withParentId, visited)\n }\n\n /**\n * Finds the output node and output slot of the first link passing through this reroute.\n * @returns The output node and output slot of the first link passing through this reroute, or `undefined` if no link is found.\n */\n findSourceOutput(): { node: LGraphNode, output: INodeOutputSlot } | undefined {\n const link = this.firstLink ?? this.firstFloatingLink\n if (!link) return\n\n const node = this.#network.deref()?.getNodeById(link.origin_id)\n if (!node) return\n\n return {\n node,\n output: node.outputs[link.origin_slot],\n }\n }\n\n /**\n * Finds the inputs and nodes of (floating) links passing through this reroute.\n * @returns An array of objects containing the node and input slot of each link passing through this reroute.\n */\n findTargetInputs(): { node: LGraphNode, input: INodeInputSlot, link: LLink }[] | undefined {\n const network = this.#network.deref()\n if (!network) return\n\n const results: {\n node: LGraphNode\n input: INodeInputSlot\n link: LLink\n }[] = []\n\n addAllResults(network, this.linkIds, network.links)\n addAllResults(network, this.floatingLinkIds, network.floatingLinks)\n\n return results\n\n function addAllResults(\n network: ReadonlyLinkNetwork,\n linkIds: Iterable<LinkId>,\n links: ReadonlyMap<LinkId, LLink>,\n ) {\n for (const linkId of linkIds) {\n const link = links.get(linkId)\n if (!link) continue\n\n const node = network.getNodeById(link.target_id)\n const input = node?.inputs[link.target_slot]\n if (!input) continue\n\n results.push({ node, input, link })\n }\n }\n }\n\n /**\n * Retrieves all floating links passing through this reroute.\n * @param from Filters the links by the currently connected link side.\n * @returns An array of floating links\n */\n getFloatingLinks(from: \"input\" | \"output\"): LLink[] | undefined {\n const floatingLinks = this.#network.deref()?.floatingLinks\n if (!floatingLinks) return\n\n const idProp = from === \"input\" ? \"origin_id\" : \"target_id\"\n const out: LLink[] = []\n\n for (const linkId of this.floatingLinkIds) {\n const link = floatingLinks.get(linkId)\n if (link?.[idProp] === -1) out.push(link)\n }\n return out\n }\n\n /**\n * Changes the origin node/output of all floating links that pass through this reroute.\n * @param node The new origin node\n * @param output The new origin output slot\n * @param index The slot index of {@link output}\n */\n setFloatingLinkOrigin(node: LGraphNode, output: INodeOutputSlot, index: number) {\n const network = this.#network.deref()\n const floatingOutLinks = this.getFloatingLinks(\"output\")\n if (!floatingOutLinks) throw new Error(\"[setFloatingLinkOrigin]: Invalid network.\")\n if (!floatingOutLinks.length) return\n\n output._floatingLinks ??= new Set()\n\n for (const link of floatingOutLinks) {\n // Update cached floating links\n output._floatingLinks.add(link)\n\n network?.getNodeById(link.origin_id)\n ?.outputs[link.origin_slot]\n ?._floatingLinks\n ?.delete(link)\n\n // Update the floating link\n link.origin_id = node.id\n link.origin_slot = index\n }\n }\n\n /** @inheritdoc */\n move(deltaX: number, deltaY: number) {\n this.#pos[0] += deltaX\n this.#pos[1] += deltaY\n }\n\n /** @inheritdoc */\n snapToGrid(snapTo: number): boolean {\n if (!snapTo) return false\n\n const { pos } = this\n pos[0] = snapTo * Math.round(pos[0] / snapTo)\n pos[1] = snapTo * Math.round(pos[1] / snapTo)\n return true\n }\n\n removeAllFloatingLinks() {\n for (const linkId of this.floatingLinkIds) {\n this.removeFloatingLink(linkId)\n }\n }\n\n removeFloatingLink(linkId: LinkId) {\n const network = this.#network.deref()\n if (!network) return\n\n const floatingLink = network.floatingLinks.get(linkId)\n if (!floatingLink) {\n console.warn(`[Reroute.removeFloatingLink] Floating link not found: ${linkId}, ignoring and discarding ID.`)\n this.floatingLinkIds.delete(linkId)\n return\n }\n\n network.removeFloatingLink(floatingLink)\n }\n\n /**\n * Removes a link or floating link from this reroute, by matching link object instance equality.\n * @param link The link to remove.\n * @remarks Does not remove the link from the network.\n */\n removeLink(link: LLink) {\n const network = this.#network.deref()\n if (!network) return\n\n const floatingLink = network.floatingLinks.get(link.id)\n if (link === floatingLink) {\n this.floatingLinkIds.delete(link.id)\n } else {\n this.linkIds.delete(link.id)\n }\n }\n\n remove() {\n const network = this.#network.deref()\n if (!network) return\n\n network.removeReroute(this.id)\n }\n\n calculateAngle(lastRenderTime: number, network: ReadonlyLinkNetwork, linkStart: Point): void {\n // Ensure we run once per render\n if (!(lastRenderTime > this.#lastRenderTime)) return\n this.#lastRenderTime = lastRenderTime\n\n const { id, pos: thisPos } = this\n\n // Add all link angles\n const angles: number[] = []\n let sum = 0\n calculateAngles(this.linkIds, network.links)\n calculateAngles(this.floatingLinkIds, network.floatingLinks)\n\n // Invalid - reset\n if (!angles.length) {\n this.cos = 0\n this.sin = 0\n this.controlPoint[0] = 0\n this.controlPoint[1] = 0\n return\n }\n\n sum /= angles.length\n\n const originToReroute = Math.atan2(\n this.#pos[1] - linkStart[1],\n this.#pos[0] - linkStart[0],\n )\n let diff = (originToReroute - sum) * 0.5\n if (Math.abs(diff) > Math.PI * 0.5) diff += Math.PI\n const dist = Math.min(Reroute.maxSplineOffset, distance(linkStart, this.#pos) * 0.25)\n\n // Store results\n const originDiff = originToReroute - diff\n const cos = Math.cos(originDiff)\n const sin = Math.sin(originDiff)\n\n this.cos = cos\n this.sin = sin\n this.controlPoint[0] = dist * -cos\n this.controlPoint[1] = dist * -sin\n\n /**\n * Calculates the direction of each link and adds it to the array.\n * @param linkIds The IDs of the links to calculate\n * @param links The link container from the link network.\n */\n function calculateAngles(linkIds: Iterable<LinkId>, links: ReadonlyMap<LinkId, LLink>) {\n for (const linkId of linkIds) {\n const link = links.get(linkId)\n const pos = getNextPos(network, link, id)\n if (!pos) continue\n\n const angle = getDirection(thisPos, pos)\n angles.push(angle)\n sum += angle\n }\n }\n }\n\n /**\n * Renders the reroute on the canvas.\n * @param ctx Canvas context to draw on\n * @param backgroundPattern The canvas background pattern; used to make floating reroutes appear washed out.\n * @remarks Leaves {@link ctx}.fillStyle, strokeStyle, and lineWidth dirty (perf.).\n */\n draw(ctx: CanvasRenderingContext2D, backgroundPattern?: CanvasPattern): void {\n const { globalAlpha } = ctx\n const { pos } = this\n\n ctx.beginPath()\n ctx.arc(pos[0], pos[1], Reroute.radius, 0, 2 * Math.PI)\n\n if (this.linkIds.size === 0) {\n ctx.fillStyle = backgroundPattern ?? \"#797979\"\n ctx.fill()\n ctx.globalAlpha = globalAlpha * 0.33\n }\n\n ctx.fillStyle = this.colour\n ctx.lineWidth = Reroute.radius * 0.1\n ctx.strokeStyle = \"rgb(0,0,0,0.5)\"\n ctx.fill()\n ctx.stroke()\n\n ctx.fillStyle = \"#ffffff55\"\n ctx.strokeStyle = \"rgb(0,0,0,0.3)\"\n ctx.beginPath()\n ctx.arc(pos[0], pos[1], Reroute.radius * 0.8, 0, 2 * Math.PI)\n ctx.fill()\n ctx.stroke()\n\n if (this.selected) {\n ctx.strokeStyle = \"#fff\"\n ctx.beginPath()\n ctx.arc(pos[0], pos[1], Reroute.radius * 1.2, 0, 2 * Math.PI)\n ctx.stroke()\n }\n\n if (Reroute.drawIdBadge) {\n const idBadge = new LGraphBadge({ text: this.id.toString() })\n const x = pos[0] - idBadge.getWidth(ctx) * 0.5\n const y = pos[1] - idBadge.height - Reroute.radius - 2\n idBadge.draw(ctx, x, y)\n }\n\n ctx.globalAlpha = globalAlpha\n }\n\n /**\n * Draws the input and output slots on the canvas, if the slots are visible.\n * @param ctx The canvas context to draw on.\n */\n drawSlots(ctx: CanvasRenderingContext2D): void {\n this.#inputSlot.draw(ctx)\n this.#outputSlot.draw(ctx)\n }\n\n drawHighlight(ctx: CanvasRenderingContext2D, colour: CanvasColour): void {\n const { pos } = this\n\n const { strokeStyle, lineWidth } = ctx\n ctx.strokeStyle = colour\n ctx.lineWidth = 1\n\n ctx.beginPath()\n ctx.arc(pos[0], pos[1], Reroute.radius * 1.5, 0, 2 * Math.PI)\n ctx.stroke()\n\n ctx.strokeStyle = strokeStyle\n ctx.lineWidth = lineWidth\n }\n\n /**\n * Updates visibility of the input and output slots, based on the position of the pointer.\n * @param pos The position of the pointer.\n * @returns `true` if any changes require a redraw.\n */\n updateVisibility(pos: Point): boolean {\n const input = this.#inputSlot\n const output = this.#outputSlot\n input.dirty = false\n output.dirty = false\n\n const { firstFloatingLink } = this\n const hasLink = !!this.firstLink\n\n const showInput = hasLink || firstFloatingLink?.isFloatingOutput\n const showOutput = hasLink || firstFloatingLink?.isFloatingInput\n const showEither = showInput || showOutput\n\n // Check if even in the vicinity\n if (showEither && isPointInRect(pos, this.#hoverArea)) {\n const outlineOnly = this.#contains(pos)\n\n if (showInput) input.update(pos, outlineOnly)\n if (showOutput) output.update(pos, outlineOnly)\n } else {\n this.hideSlots()\n }\n\n return input.dirty || output.dirty\n }\n\n /** Prevents rendering of the input and output slots. */\n hideSlots() {\n this.#inputSlot.hide()\n this.#outputSlot.hide()\n }\n\n /**\n * Precisely determines if {@link pos} is inside this reroute.\n * @param pos The position to check (canvas space)\n * @returns `true` if {@link pos} is within the reroute's radius.\n */\n containsPoint(pos: Point): boolean {\n return isPointInRect(pos, this.#hoverArea) && this.#contains(pos)\n }\n\n #contains(pos: Point): boolean {\n return distance(this.pos, pos) <= Reroute.radius\n }\n\n /** @inheritdoc */\n asSerialisable(): SerialisableReroute {\n const { id, parentId, pos, linkIds } = this\n return {\n id,\n parentId,\n pos: [pos[0], pos[1]],\n linkIds: [...linkIds],\n floating: this.floating ? { slotType: this.floating.slotType } : undefined,\n }\n }\n}\n\n/**\n * Represents a slot on a reroute.\n * @private Designed for internal use within this module.\n */\nclass RerouteSlot {\n /** The reroute that the slot belongs to. */\n readonly #reroute: Reroute\n\n readonly #offsetMultiplier: 1 | -1\n /** Centre point of this slot. */\n get pos(): Point {\n const [x, y] = this.#reroute.pos\n return [x + Reroute.slotOffset * this.#offsetMultiplier, y]\n }\n\n /** Whether any changes require a redraw. */\n dirty: boolean = false\n\n #hovering = false\n /** Whether the pointer is hovering over the slot itself. */\n get hovering() {\n return this.#hovering\n }\n\n set hovering(value) {\n if (!Object.is(this.#hovering, value)) {\n this.#hovering = value\n this.dirty = true\n }\n }\n\n #showOutline = false\n /** Whether the slot outline / faint background is visible. */\n get showOutline() {\n return this.#showOutline\n }\n\n set showOutline(value) {\n if (!Object.is(this.#showOutline, value)) {\n this.#showOutline = value\n this.dirty = true\n }\n }\n\n constructor(reroute: Reroute, isInput: boolean) {\n this.#reroute = reroute\n this.#offsetMultiplier = isInput ? -1 : 1\n }\n\n /**\n * Updates the slot's visibility based on the position of the pointer.\n * @param pos The position of the pointer.\n * @param outlineOnly If `true`, slot will display with the faded outline only ({@link showOutline}).\n */\n update(pos: Point, outlineOnly?: boolean) {\n if (outlineOnly) {\n this.hovering = false\n this.showOutline = true\n } else {\n const dist = distance(this.pos, pos)\n this.hovering = dist <= 2 * Reroute.slotRadius\n this.showOutline = dist <= 5 * Reroute.slotRadius\n }\n }\n\n /** Hides the slot. */\n hide() {\n this.hovering = false\n this.showOutline = false\n }\n\n /**\n * Draws the slot on the canvas.\n * @param ctx The canvas context to draw on.\n */\n draw(ctx: CanvasRenderingContext2D): void {\n const { fillStyle, strokeStyle, lineWidth } = ctx\n const { showOutline, hovering, pos: [x, y] } = this\n if (!showOutline) return\n\n try {\n ctx.fillStyle = hovering\n ? this.#reroute.colour\n : \"rgba(127,127,127,0.3)\"\n ctx.strokeStyle = \"rgb(0,0,0,0.5)\"\n ctx.lineWidth = 1\n\n ctx.beginPath()\n ctx.arc(x, y, Reroute.slotRadius, 0, 2 * Math.PI)\n ctx.fill()\n ctx.stroke()\n } finally {\n ctx.fillStyle = fillStyle\n ctx.strokeStyle = strokeStyle\n ctx.lineWidth = lineWidth\n }\n }\n}\n\n/**\n * Retrieves the position of the next reroute in the chain, or the destination input slot on this link.\n * @param network The network of links\n * @param link The link representing the current reroute chain\n * @param id The ID of \"this\" reroute\n * @returns The position of the next reroute or the input slot target, otherwise `undefined`.\n */\nfunction getNextPos(network: ReadonlyLinkNetwork, link: LLink | undefined, id: RerouteId) {\n if (!link) return\n\n const linkPos = LLink.findNextReroute(network, link, id)?.pos\n if (linkPos) return linkPos\n\n // Floating link with no input to find\n if (link.target_id === -1 || link.target_slot === -1) return\n\n return network.getNodeById(link.target_id)?.getInputPos(link.target_slot)\n}\n\n/** Returns the direction from one point to another in radians. */\nfunction getDirection(fromPos: Point, toPos: Point) {\n return Math.atan2(toPos[1] - fromPos[1], toPos[0] - fromPos[0])\n}\n","import type { ISlotType } from \"./litegraph\"\n\n/**\n * Uses the standard String() function to coerce to string, unless the value is null or undefined - then null.\n * @param value The value to convert\n * @returns String(value) or null\n */\nexport function stringOrNull(value: unknown): string | null {\n return value == null ? null : String(value)\n}\n\n/**\n * Uses the standard String() function to coerce to string, unless the value is null or undefined - then an empty string\n * @param value The value to convert\n * @returns String(value) or \"\"\n */\nexport function stringOrEmpty(value: unknown): string {\n return value == null ? \"\" : String(value)\n}\n\nexport function parseSlotTypes(type: ISlotType): string[] {\n return type == \"\" || type == \"0\" ? [\"*\"] : String(type).toLowerCase().split(\",\")\n}\n\n/**\n * Creates a unique name by appending an underscore and a number to the end of the name\n * if it already exists.\n * @param name The name to make unique\n * @param existingNames The names that already exist. Default: an empty array\n * @returns The name, or a unique name if it already exists.\n */\nexport function nextUniqueName(name: string, existingNames: string[] = []): string {\n let i = 1\n const baseName = name\n while (existingNames.includes(name)) {\n name = `${baseName}_${i++}`\n }\n return name\n}\n","import type { ReadOnlyRect, ReadOnlySize, Size } from \"@/interfaces\"\n\nimport { clamp } from \"@/litegraph\"\n\n/**\n * Basic width and height, with min/max constraints.\n *\n * - The {@link width} and {@link height} properties are readonly\n * - Size is set via {@link desiredWidth} and {@link desiredHeight} properties\n * - Width and height are then updated, clamped to min/max values\n */\nexport class ConstrainedSize {\n #width: number = 0\n #height: number = 0\n #desiredWidth: number = 0\n #desiredHeight: number = 0\n\n minWidth: number = 0\n minHeight: number = 0\n maxWidth: number = Infinity\n maxHeight: number = Infinity\n\n get width() {\n return this.#width\n }\n\n get height() {\n return this.#height\n }\n\n get desiredWidth() {\n return this.#desiredWidth\n }\n\n set desiredWidth(value: number) {\n this.#desiredWidth = value\n this.#width = clamp(value, this.minWidth, this.maxWidth)\n }\n\n get desiredHeight() {\n return this.#desiredHeight\n }\n\n set desiredHeight(value: number) {\n this.#desiredHeight = value\n this.#height = clamp(value, this.minHeight, this.maxHeight)\n }\n\n constructor(width: number, height: number) {\n this.desiredWidth = width\n this.desiredHeight = height\n }\n\n static fromSize(size: ReadOnlySize): ConstrainedSize {\n return new ConstrainedSize(size[0], size[1])\n }\n\n static fromRect(rect: ReadOnlyRect): ConstrainedSize {\n return new ConstrainedSize(rect[2], rect[3])\n }\n\n setSize(size: ReadOnlySize): void {\n this.desiredWidth = size[0]\n this.desiredHeight = size[1]\n }\n\n setValues(width: number, height: number): void {\n this.desiredWidth = width\n this.desiredHeight = height\n }\n\n toSize(): Size {\n return [this.#width, this.#height]\n }\n}\n","import type { SubgraphInput } from \"./SubgraphInput\"\nimport type { SubgraphInputNode } from \"./SubgraphInputNode\"\nimport type { SubgraphOutput } from \"./SubgraphOutput\"\nimport type { SubgraphOutputNode } from \"./SubgraphOutputNode\"\nimport type { DefaultConnectionColors, Hoverable, INodeInputSlot, INodeOutputSlot, Point, ReadOnlyRect, ReadOnlySize } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { LinkId, LLink } from \"@/LLink\"\nimport type { RerouteId } from \"@/Reroute\"\nimport type { CanvasPointerEvent } from \"@/types/events\"\nimport type { Serialisable, SubgraphIO } from \"@/types/serialisation\"\n\nimport { SlotShape } from \"@/draw\"\nimport { ConstrainedSize } from \"@/infrastructure/ConstrainedSize\"\nimport { Rectangle } from \"@/infrastructure/Rectangle\"\nimport { LGraphCanvas } from \"@/LGraphCanvas\"\nimport { LiteGraph } from \"@/litegraph\"\nimport { SlotBase } from \"@/node/SlotBase\"\nimport { createUuidv4, type UUID } from \"@/utils/uuid\"\n\nexport interface SubgraphSlotDrawOptions {\n ctx: CanvasRenderingContext2D\n colorContext: DefaultConnectionColors\n lowQuality?: boolean\n fromSlot?: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput\n editorAlpha?: number\n}\n\n/** Shared base class for the slots used on Subgraph . */\nexport abstract class SubgraphSlot extends SlotBase implements SubgraphIO, Hoverable, Serialisable<SubgraphIO> {\n static get defaultHeight() {\n return LiteGraph.NODE_SLOT_HEIGHT\n }\n\n readonly #pos: Point = new Float32Array(2)\n\n readonly measurement: ConstrainedSize = new ConstrainedSize(SubgraphSlot.defaultHeight, SubgraphSlot.defaultHeight)\n\n readonly id: UUID\n readonly parent: SubgraphInputNode | SubgraphOutputNode\n override type: string\n\n readonly linkIds: LinkId[] = []\n\n override readonly boundingRect: Rectangle = new Rectangle(0, 0, 0, SubgraphSlot.defaultHeight)\n\n override get pos() {\n return this.#pos\n }\n\n override set pos(value) {\n if (!value || value.length < 2) return\n\n this.#pos[0] = value[0]\n this.#pos[1] = value[1]\n }\n\n /** Whether this slot is connected to another slot. */\n override get isConnected() {\n return this.linkIds.length > 0\n }\n\n /** The display name of this slot. */\n get displayName() {\n return this.label ?? this.localized_name ?? this.name\n }\n\n abstract get labelPos(): Point\n\n constructor(slot: SubgraphIO, parent: SubgraphInputNode | SubgraphOutputNode) {\n super(slot.name, slot.type)\n\n Object.assign(this, slot)\n this.id = slot.id ?? createUuidv4()\n this.type = slot.type\n this.parent = parent\n }\n\n isPointerOver: boolean = false\n\n containsPoint(point: Point): boolean {\n return this.boundingRect.containsPoint(point)\n }\n\n onPointerMove(e: CanvasPointerEvent): void {\n this.isPointerOver = this.boundingRect.containsXy(e.canvasX, e.canvasY)\n }\n\n getLinks(): LLink[] {\n const links: LLink[] = []\n const { subgraph } = this.parent\n\n for (const id of this.linkIds) {\n const link = subgraph.getLink(id)\n if (link) links.push(link)\n }\n return links\n }\n\n decrementSlots(inputsOrOutputs: \"inputs\" | \"outputs\"): void {\n const { links } = this.parent.subgraph\n const linkProperty = inputsOrOutputs === \"inputs\" ? \"origin_slot\" : \"target_slot\"\n\n for (const linkId of this.linkIds) {\n const link = links.get(linkId)\n if (link) link[linkProperty]--\n else console.warn(\"decrementSlots: link ID not found\", linkId)\n }\n }\n\n measure(): ReadOnlySize {\n const width = LGraphCanvas._measureText?.(this.displayName) ?? 0\n\n const { defaultHeight } = SubgraphSlot\n this.measurement.setValues(width + defaultHeight, defaultHeight)\n return this.measurement.toSize()\n }\n\n abstract arrange(rect: ReadOnlyRect): void\n\n abstract connect(\n slot: INodeInputSlot | INodeOutputSlot,\n node: LGraphNode,\n afterRerouteId?: RerouteId,\n ): LLink | undefined\n\n /**\n * Disconnects all links connected to this slot.\n */\n disconnect(): void {\n const { subgraph } = this.parent\n\n for (const linkId of this.linkIds) {\n subgraph.removeLink(linkId)\n }\n\n this.linkIds.length = 0\n }\n\n /**\n * Checks if this slot is a valid target for a connection from the given slot.\n * @param fromSlot The slot that is being dragged to connect to this slot.\n * @returns true if the connection is valid, false otherwise.\n */\n abstract isValidTarget(fromSlot: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput): boolean\n\n /** @remarks Leaves the context dirty. */\n draw({ ctx, colorContext, lowQuality, fromSlot, editorAlpha = 1 }: SubgraphSlotDrawOptions): void {\n // Assertion: SlotShape is a subset of RenderShape\n const shape = this.shape as unknown as SlotShape\n const { isPointerOver, pos: [x, y] } = this\n\n // Check if this slot is a valid target for the current dragging connection\n const isValidTarget = fromSlot ? this.isValidTarget(fromSlot) : true\n const isValid = !fromSlot || isValidTarget\n\n // Only highlight if the slot is valid AND mouse is over it\n const highlight = isValid && isPointerOver\n\n // Save current alpha\n const previousAlpha = ctx.globalAlpha\n\n // Set opacity based on validity when dragging a connection\n ctx.globalAlpha = isValid ? editorAlpha : 0.4 * editorAlpha\n\n ctx.beginPath()\n\n // Default rendering for circle, hollow circle.\n const color = this.renderingColor(colorContext)\n if (lowQuality) {\n ctx.fillStyle = color\n\n ctx.rect(x - 4, y - 4, 8, 8)\n ctx.fill()\n } else if (shape === SlotShape.HollowCircle) {\n ctx.lineWidth = 3\n ctx.strokeStyle = color\n\n const radius = highlight ? 4 : 3\n ctx.arc(x, y, radius, 0, Math.PI * 2)\n ctx.stroke()\n } else {\n // Normal circle\n ctx.fillStyle = color\n\n const radius = highlight ? 5 : 4\n ctx.arc(x, y, radius, 0, Math.PI * 2)\n ctx.fill()\n }\n\n // Draw label with current opacity\n if (this.displayName) {\n const [labelX, labelY] = this.labelPos\n // Also apply highlight logic to text color\n ctx.fillStyle = highlight ? \"white\" : (LiteGraph.NODE_TEXT_COLOR || \"#AAA\")\n ctx.fillText(this.displayName, labelX, labelY)\n }\n\n // Restore alpha\n ctx.globalAlpha = previousAlpha\n }\n\n asSerialisable(): SubgraphIO {\n const { id, name, type, linkIds, localized_name, label, dir, shape, color_off, color_on, pos } = this\n return { id, name, type, linkIds, localized_name, label, dir, shape, color_off, color_on, pos }\n }\n}\n","import type { SubgraphInput } from \"./SubgraphInput\"\nimport type { SubgraphOutputNode } from \"./SubgraphOutputNode\"\nimport type { INodeInputSlot, INodeOutputSlot, Point, ReadOnlyRect } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { RerouteId } from \"@/Reroute\"\n\nimport { LiteGraph } from \"@/litegraph\"\nimport { LLink } from \"@/LLink\"\nimport { NodeSlotType } from \"@/types/globalEnums\"\nimport { removeFromArray } from \"@/utils/collections\"\n\nimport { SubgraphSlot } from \"./SubgraphSlotBase\"\nimport { isNodeSlot, isSubgraphInput } from \"./subgraphUtils\"\n\n/**\n * An output \"slot\" from a subgraph to a parent graph.\n *\n * IMPORTANT: A subgraph \"output\" is both an output AND an input. It creates an extra link connection point between\n * a parent graph and a subgraph, so is conceptually similar to a reroute.\n *\n * This can be a little confusing, but is easier to visualise when imagining editing a subgraph.\n * You have \"Subgraph Outputs\", because they go from inside the subgraph and out, but links to them come from \"node outputs\".\n *\n * Functionally, however, when editing a subgraph, that \"subgraph output\" is the \"target\" or \"input side\" of a link.\n */\nexport class SubgraphOutput extends SubgraphSlot {\n declare parent: SubgraphOutputNode\n\n override connect(slot: INodeOutputSlot, node: LGraphNode, afterRerouteId?: RerouteId): LLink | undefined {\n const { subgraph } = this.parent\n\n // Validate type compatibility\n if (!LiteGraph.isValidConnection(slot.type, this.type)) return\n\n // Allow nodes to block connection\n const outputIndex = node.outputs.indexOf(slot)\n if (outputIndex === -1) throw new Error(\"Slot is not an output of the given node\")\n\n if (node.onConnectOutput?.(outputIndex, this.type, this, this.parent, -1) === false) return\n\n // Link should not be present, but just in case, disconnect it\n const existingLink = this.getLinks().at(0)\n if (existingLink != null) {\n subgraph.beforeChange()\n\n existingLink.disconnect(subgraph, \"input\")\n const resolved = existingLink.resolve(subgraph)\n const links = resolved.output?.links\n if (links) removeFromArray(links, existingLink.id)\n }\n\n const link = new LLink(\n ++subgraph.state.lastLinkId,\n slot.type,\n node.id,\n outputIndex,\n this.parent.id,\n this.parent.slots.indexOf(this),\n afterRerouteId,\n )\n\n // Add to graph links list\n subgraph._links.set(link.id, link)\n\n // Set link ID in each slot\n this.linkIds[0] = link.id\n slot.links ??= []\n slot.links.push(link.id)\n\n // Reroutes\n const reroutes = LLink.getReroutes(subgraph, link)\n for (const reroute of reroutes) {\n reroute.linkIds.add(link.id)\n if (reroute.floating) delete reroute.floating\n reroute._dragging = undefined\n }\n\n // If this is the terminus of a floating link, remove it\n const lastReroute = reroutes.at(-1)\n if (lastReroute) {\n for (const linkId of lastReroute.floatingLinkIds) {\n const link = subgraph.floatingLinks.get(linkId)\n if (link?.parentId === lastReroute.id) {\n subgraph.removeFloatingLink(link)\n }\n }\n }\n subgraph._version++\n\n node.onConnectionsChange?.(\n NodeSlotType.OUTPUT,\n outputIndex,\n true,\n link,\n slot,\n )\n\n subgraph.afterChange()\n\n return link\n }\n\n get labelPos(): Point {\n const [x, y, , height] = this.boundingRect\n return [x + height, y + height * 0.5]\n }\n\n override arrange(rect: ReadOnlyRect): void {\n const [left, top, width, height] = rect\n const { boundingRect: b, pos } = this\n\n b[0] = left\n b[1] = top\n b[2] = width\n b[3] = height\n\n pos[0] = left + height * 0.5\n pos[1] = top + height * 0.5\n }\n\n /**\n * Checks if this slot is a valid target for a connection from the given slot.\n * For SubgraphOutput (which acts as an input inside the subgraph),\n * the fromSlot should be an output slot.\n */\n override isValidTarget(fromSlot: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput): boolean {\n if (isNodeSlot(fromSlot)) {\n return \"links\" in fromSlot && LiteGraph.isValidConnection(fromSlot.type, this.type)\n }\n\n if (isSubgraphInput(fromSlot)) {\n return LiteGraph.isValidConnection(fromSlot.type, this.type)\n }\n\n return false\n }\n}\n","import type { SubgraphOutputNode } from \"./SubgraphOutputNode\"\nimport type { INodeOutputSlot, Point } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { RerouteId } from \"@/Reroute\"\n\nimport { LLink } from \"@/LLink\"\nimport { nextUniqueName } from \"@/strings\"\nimport { zeroUuid } from \"@/utils/uuid\"\n\nimport { SubgraphOutput } from \"./SubgraphOutput\"\n\n/**\n * A virtual slot that simply creates a new output slot when connected to.\n */\nexport class EmptySubgraphOutput extends SubgraphOutput {\n declare parent: SubgraphOutputNode\n\n constructor(parent: SubgraphOutputNode) {\n super({\n id: zeroUuid,\n name: \"\",\n type: \"\",\n }, parent)\n }\n\n override connect(slot: INodeOutputSlot, node: LGraphNode, afterRerouteId?: RerouteId): LLink | undefined {\n const { subgraph } = this.parent\n const existingNames = subgraph.outputs.map(x => x.name)\n\n const name = nextUniqueName(slot.name, existingNames)\n const output = subgraph.addOutput(name, String(slot.type))\n return output.connect(slot, node, afterRerouteId)\n }\n\n override get labelPos(): Point {\n const [x, y, , height] = this.boundingRect\n return [x, y + height * 0.5]\n }\n}\n","import type { EmptySubgraphInput } from \"./EmptySubgraphInput\"\nimport type { EmptySubgraphOutput } from \"./EmptySubgraphOutput\"\nimport type { Subgraph } from \"./Subgraph\"\nimport type { SubgraphInput } from \"./SubgraphInput\"\nimport type { SubgraphOutput } from \"./SubgraphOutput\"\nimport type { LinkConnector } from \"@/canvas/LinkConnector\"\nimport type { DefaultConnectionColors, Hoverable, INodeInputSlot, INodeOutputSlot, Point, Positionable } from \"@/interfaces\"\nimport type { NodeId } from \"@/LGraphNode\"\nimport type { ExportedSubgraphIONode, Serialisable } from \"@/types/serialisation\"\n\nimport { Rectangle } from \"@/infrastructure/Rectangle\"\nimport { type CanvasColour, type CanvasPointer, type CanvasPointerEvent, type IContextMenuValue, LiteGraph } from \"@/litegraph\"\nimport { snapPoint } from \"@/measure\"\nimport { CanvasItem } from \"@/types/globalEnums\"\n\nexport abstract class SubgraphIONodeBase<TSlot extends SubgraphInput | SubgraphOutput> implements Positionable, Hoverable, Serialisable<ExportedSubgraphIONode> {\n static margin = 10\n static minWidth = 100\n static roundedRadius = 10\n\n readonly #boundingRect: Rectangle = new Rectangle()\n\n abstract readonly id: NodeId\n\n get boundingRect(): Rectangle {\n return this.#boundingRect\n }\n\n selected: boolean = false\n pinned: boolean = false\n readonly removable = false\n\n isPointerOver: boolean = false\n\n abstract readonly emptySlot: EmptySubgraphInput | EmptySubgraphOutput\n\n get pos() {\n return this.boundingRect.pos\n }\n\n set pos(value) {\n this.boundingRect.pos = value\n }\n\n get size() {\n return this.boundingRect.size\n }\n\n set size(value) {\n this.boundingRect.size = value\n }\n\n protected get sideLineWidth(): number {\n return this.isPointerOver ? 2.5 : 2\n }\n\n protected get sideStrokeStyle(): CanvasColour {\n return this.isPointerOver ? \"white\" : \"#efefef\"\n }\n\n abstract readonly slots: TSlot[]\n abstract get allSlots(): TSlot[]\n\n constructor(\n /** The subgraph that this node belongs to. */\n readonly subgraph: Subgraph,\n ) {}\n\n move(deltaX: number, deltaY: number): void {\n this.pos[0] += deltaX\n this.pos[1] += deltaY\n }\n\n /** @inheritdoc */\n snapToGrid(snapTo: number): boolean {\n return this.pinned ? false : snapPoint(this.pos, snapTo)\n }\n\n abstract onPointerDown(e: CanvasPointerEvent, pointer: CanvasPointer, linkConnector: LinkConnector): void\n\n // #region Hoverable\n\n containsPoint(point: Point): boolean {\n return this.boundingRect.containsPoint(point)\n }\n\n abstract get slotAnchorX(): number\n\n onPointerMove(e: CanvasPointerEvent): CanvasItem {\n const containsPoint = this.boundingRect.containsXy(e.canvasX, e.canvasY)\n let underPointer = containsPoint ? CanvasItem.SubgraphIoNode : CanvasItem.Nothing\n\n if (containsPoint) {\n if (!this.isPointerOver) this.onPointerEnter()\n\n for (const slot of this.allSlots) {\n slot.onPointerMove(e)\n if (slot.isPointerOver) underPointer |= CanvasItem.SubgraphIoSlot\n }\n } else if (this.isPointerOver) {\n this.onPointerLeave()\n }\n return underPointer\n }\n\n onPointerEnter() {\n this.isPointerOver = true\n }\n\n onPointerLeave() {\n this.isPointerOver = false\n\n for (const slot of this.slots) {\n slot.isPointerOver = false\n }\n }\n\n // #endregion Hoverable\n\n /**\n * Renames an IO slot in the subgraph.\n * @param slot The slot to rename.\n * @param name The new name for the slot.\n */\n abstract renameSlot(slot: TSlot, name: string): void\n\n /**\n * Removes an IO slot from the subgraph.\n * @param slot The slot to remove.\n */\n abstract removeSlot(slot: TSlot): void\n\n /**\n * Gets the slot at a given position in canvas space.\n * @param x The x coordinate of the position.\n * @param y The y coordinate of the position.\n * @returns The slot at the given position, otherwise `undefined`.\n */\n getSlotInPosition(x: number, y: number): TSlot | undefined {\n for (const slot of this.allSlots) {\n if (slot.boundingRect.containsXy(x, y)) {\n return slot\n }\n }\n }\n\n /**\n * Shows the context menu for an IO slot.\n * @param slot The slot to show the context menu for.\n * @param event The event that triggered the context menu.\n */\n protected showSlotContextMenu(slot: TSlot, event: CanvasPointerEvent): void {\n const options: IContextMenuValue[] = this.#getSlotMenuOptions(slot)\n if (!(options.length > 0)) return\n\n new LiteGraph.ContextMenu(\n options,\n {\n event: event as any,\n title: slot.name || \"Subgraph Output\",\n callback: (item: IContextMenuValue) => {\n this.#onSlotMenuAction(item, slot, event)\n },\n },\n )\n }\n\n /**\n * Gets the context menu options for an IO slot.\n * @param slot The slot to get the context menu options for.\n * @returns The context menu options.\n */\n #getSlotMenuOptions(slot: TSlot): IContextMenuValue[] {\n const options: IContextMenuValue[] = []\n\n // Disconnect option if slot has connections\n if (slot !== this.emptySlot && slot.linkIds.length > 0) {\n options.push({ content: \"Disconnect Links\", value: \"disconnect\" })\n }\n\n // Remove / rename slot option (except for the empty slot)\n if (slot !== this.emptySlot) {\n options.push(\n { content: \"Remove Slot\", value: \"remove\" },\n { content: \"Rename Slot\", value: \"rename\" },\n )\n }\n\n return options\n }\n\n /**\n * Handles the action for an IO slot context menu.\n * @param selectedItem The item that was selected from the context menu.\n * @param slot The slot\n * @param event The event that triggered the context menu.\n */\n #onSlotMenuAction(selectedItem: IContextMenuValue, slot: TSlot, event: CanvasPointerEvent): void {\n switch (selectedItem.value) {\n // Disconnect all links from this output\n case \"disconnect\":\n slot.disconnect()\n break\n\n // Remove the slot\n case \"remove\":\n if (slot !== this.emptySlot) {\n this.removeSlot(slot)\n }\n break\n\n // Rename the slot\n case \"rename\":\n if (slot !== this.emptySlot) {\n this.subgraph.canvasAction(c => c.prompt(\n \"Slot name\",\n slot.name,\n (newName: string) => {\n if (newName) this.renameSlot(slot, newName)\n },\n event,\n ))\n }\n break\n }\n\n this.subgraph.setDirtyCanvas(true)\n }\n\n /** Arrange the slots in this node. */\n arrange(): void {\n const { minWidth, roundedRadius } = SubgraphIONodeBase\n const [, y] = this.boundingRect\n const x = this.slotAnchorX\n const { size } = this\n\n let maxWidth = minWidth\n let currentY = y + roundedRadius\n\n for (const slot of this.allSlots) {\n const [slotWidth, slotHeight] = slot.measure()\n slot.arrange([x, currentY, slotWidth, slotHeight])\n\n currentY += slotHeight\n if (slotWidth > maxWidth) maxWidth = slotWidth\n }\n\n size[0] = maxWidth + 2 * roundedRadius\n size[1] = currentY - y + roundedRadius\n }\n\n draw(ctx: CanvasRenderingContext2D, colorContext: DefaultConnectionColors, fromSlot?: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput, editorAlpha?: number): void {\n const { lineWidth, strokeStyle, fillStyle, font, textBaseline } = ctx\n this.drawProtected(ctx, colorContext, fromSlot, editorAlpha)\n Object.assign(ctx, { lineWidth, strokeStyle, fillStyle, font, textBaseline })\n }\n\n /** @internal Leaves {@link ctx} dirty. */\n protected abstract drawProtected(ctx: CanvasRenderingContext2D, colorContext: DefaultConnectionColors, fromSlot?: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput, editorAlpha?: number): void\n\n /** @internal Leaves {@link ctx} dirty. */\n protected drawSlots(ctx: CanvasRenderingContext2D, colorContext: DefaultConnectionColors, fromSlot?: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput, editorAlpha?: number): void {\n ctx.fillStyle = \"#AAA\"\n ctx.font = \"12px Arial\"\n ctx.textBaseline = \"middle\"\n\n for (const slot of this.allSlots) {\n slot.draw({ ctx, colorContext, fromSlot, editorAlpha })\n }\n }\n\n configure(data: ExportedSubgraphIONode): void {\n this.#boundingRect.set(data.bounding)\n this.pinned = data.pinned ?? false\n }\n\n asSerialisable(): ExportedSubgraphIONode {\n return {\n id: this.id,\n bounding: this.boundingRect.export(),\n pinned: this.pinned ? true : undefined,\n }\n }\n}\n","import type { SubgraphInput } from \"./SubgraphInput\"\nimport type { SubgraphOutput } from \"./SubgraphOutput\"\nimport type { LinkConnector } from \"@/canvas/LinkConnector\"\nimport type { CanvasPointer } from \"@/CanvasPointer\"\nimport type { DefaultConnectionColors, INodeInputSlot, INodeOutputSlot, ISlotType, Positionable } from \"@/interfaces\"\nimport type { LGraphNode, NodeId } from \"@/LGraphNode\"\nimport type { LLink } from \"@/LLink\"\nimport type { RerouteId } from \"@/Reroute\"\nimport type { CanvasPointerEvent } from \"@/types/events\"\nimport type { NodeLike } from \"@/types/NodeLike\"\nimport type { SubgraphIO } from \"@/types/serialisation\"\n\nimport { SUBGRAPH_OUTPUT_ID } from \"@/constants\"\nimport { Rectangle } from \"@/infrastructure/Rectangle\"\nimport { findFreeSlotOfType } from \"@/utils/collections\"\n\nimport { EmptySubgraphOutput } from \"./EmptySubgraphOutput\"\nimport { SubgraphIONodeBase } from \"./SubgraphIONodeBase\"\n\nexport class SubgraphOutputNode extends SubgraphIONodeBase<SubgraphOutput> implements Positionable {\n readonly id: NodeId = SUBGRAPH_OUTPUT_ID\n\n readonly emptySlot: EmptySubgraphOutput = new EmptySubgraphOutput(this)\n\n get slots() {\n return this.subgraph.outputs\n }\n\n override get allSlots(): SubgraphOutput[] {\n return [...this.slots, this.emptySlot]\n }\n\n get slotAnchorX() {\n const [x] = this.boundingRect\n return x + SubgraphIONodeBase.roundedRadius\n }\n\n override onPointerDown(e: CanvasPointerEvent, pointer: CanvasPointer, linkConnector: LinkConnector): void {\n // Left-click handling for dragging connections\n if (e.button === 0) {\n for (const slot of this.allSlots) {\n const slotBounds = Rectangle.fromCentre(slot.pos, slot.boundingRect.height)\n\n if (slotBounds.containsXy(e.canvasX, e.canvasY)) {\n pointer.onDragStart = () => {\n linkConnector.dragNewFromSubgraphOutput(this.subgraph, this, slot)\n }\n pointer.onDragEnd = (eUp) => {\n linkConnector.dropLinks(this.subgraph, eUp)\n }\n pointer.finally = () => {\n linkConnector.reset(true)\n }\n }\n }\n // Check for right-click\n } else if (e.button === 2) {\n const slot = this.getSlotInPosition(e.canvasX, e.canvasY)\n if (slot) this.showSlotContextMenu(slot, e)\n }\n }\n\n /** @inheritdoc */\n override renameSlot(slot: SubgraphOutput, name: string): void {\n this.subgraph.renameOutput(slot, name)\n }\n\n /** @inheritdoc */\n override removeSlot(slot: SubgraphOutput): void {\n this.subgraph.removeOutput(slot)\n }\n\n canConnectTo(outputNode: NodeLike, fromSlot: SubgraphOutput, output: INodeOutputSlot | SubgraphIO): boolean {\n return outputNode.canConnectTo(this, fromSlot, output)\n }\n\n connectByTypeOutput(\n slot: number,\n target_node: LGraphNode,\n target_slotType: ISlotType,\n optsIn?: { afterRerouteId?: RerouteId },\n ): LLink | undefined {\n const outputSlot = target_node.findOutputByType(target_slotType)\n if (!outputSlot) return\n\n return this.slots[slot].connect(outputSlot.slot, target_node, optsIn?.afterRerouteId)\n }\n\n findInputByType(type: ISlotType): SubgraphOutput | undefined {\n return findFreeSlotOfType(this.slots, type, slot => slot.linkIds.length > 0)?.slot\n }\n\n override drawProtected(ctx: CanvasRenderingContext2D, colorContext: DefaultConnectionColors, fromSlot?: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput, editorAlpha?: number): void {\n const { roundedRadius } = SubgraphIONodeBase\n const transform = ctx.getTransform()\n\n const [x, y, , height] = this.boundingRect\n ctx.translate(x, y)\n\n // Draw bottom rounded part\n ctx.strokeStyle = this.sideStrokeStyle\n ctx.lineWidth = this.sideLineWidth\n ctx.beginPath()\n ctx.arc(roundedRadius, roundedRadius, roundedRadius, Math.PI, Math.PI * 1.5)\n\n // Straight line to bottom\n ctx.moveTo(0, roundedRadius)\n ctx.lineTo(0, height - roundedRadius)\n\n // Bottom rounded part\n ctx.arc(roundedRadius, height - roundedRadius, roundedRadius, Math.PI, Math.PI * 0.5, true)\n ctx.stroke()\n\n // Restore context\n ctx.setTransform(transform)\n\n this.drawSlots(ctx, colorContext, fromSlot, editorAlpha)\n }\n}\n","import type { GraphOrSubgraph } from \"./Subgraph\"\nimport type { SubgraphInput } from \"./SubgraphInput\"\nimport type { SubgraphOutput } from \"./SubgraphOutput\"\nimport type { INodeInputSlot, INodeOutputSlot, Positionable } from \"@/interfaces\"\nimport type { LGraph } from \"@/LGraph\"\nimport type { ISerialisedNode, SerialisableLLink, SubgraphIO } from \"@/types/serialisation\"\nimport type { UUID } from \"@/utils/uuid\"\n\nimport { SUBGRAPH_INPUT_ID, SUBGRAPH_OUTPUT_ID } from \"@/constants\"\nimport { LGraphGroup } from \"@/LGraphGroup\"\nimport { LGraphNode } from \"@/LGraphNode\"\nimport { createUuidv4, LiteGraph } from \"@/litegraph\"\nimport { LLink, type ResolvedConnection } from \"@/LLink\"\nimport { Reroute } from \"@/Reroute\"\nimport { nextUniqueName } from \"@/strings\"\n\nimport { SubgraphInputNode } from \"./SubgraphInputNode\"\nimport { SubgraphOutputNode } from \"./SubgraphOutputNode\"\n\nexport interface FilteredItems {\n nodes: Set<LGraphNode>\n reroutes: Set<Reroute>\n groups: Set<LGraphGroup>\n subgraphInputNodes: Set<SubgraphInputNode>\n subgraphOutputNodes: Set<SubgraphOutputNode>\n unknown: Set<Positionable>\n}\n\nexport function splitPositionables(items: Iterable<Positionable>): FilteredItems {\n const nodes = new Set<LGraphNode>()\n const reroutes = new Set<Reroute>()\n const groups = new Set<LGraphGroup>()\n const subgraphInputNodes = new Set<SubgraphInputNode>()\n const subgraphOutputNodes = new Set<SubgraphOutputNode>()\n\n const unknown = new Set<Positionable>()\n\n for (const item of items) {\n switch (true) {\n case item instanceof LGraphNode:\n nodes.add(item)\n break\n case item instanceof LGraphGroup:\n groups.add(item)\n break\n case item instanceof Reroute:\n reroutes.add(item)\n break\n case item instanceof SubgraphInputNode:\n subgraphInputNodes.add(item)\n break\n case item instanceof SubgraphOutputNode:\n subgraphOutputNodes.add(item)\n break\n default:\n unknown.add(item)\n break\n }\n }\n\n return {\n nodes,\n reroutes,\n groups,\n subgraphInputNodes,\n subgraphOutputNodes,\n unknown,\n }\n}\n\ninterface BoundaryLinks {\n boundaryLinks: LLink[]\n boundaryFloatingLinks: LLink[]\n internalLinks: LLink[]\n boundaryInputLinks: LLink[]\n boundaryOutputLinks: LLink[]\n}\n\nexport function getBoundaryLinks(graph: LGraph, items: Set<Positionable>): BoundaryLinks {\n const internalLinks: LLink[] = []\n const boundaryLinks: LLink[] = []\n const boundaryInputLinks: LLink[] = []\n const boundaryOutputLinks: LLink[] = []\n const boundaryFloatingLinks: LLink[] = []\n const visited = new WeakSet<Positionable>()\n\n for (const item of items) {\n if (visited.has(item)) continue\n visited.add(item)\n\n // Nodes\n if (item instanceof LGraphNode) {\n const node = item\n\n // Inputs\n if (node.inputs) {\n for (const input of node.inputs) {\n addFloatingLinks(input._floatingLinks)\n\n if (input.link == null) continue\n\n const resolved = LLink.resolve(input.link, graph)\n if (!resolved) {\n console.debug(`Failed to resolve link ID [${input.link}]`)\n continue\n }\n\n // Output end of this link is outside the items set\n const { link, outputNode } = resolved\n if (outputNode) {\n if (!items.has(outputNode)) {\n boundaryInputLinks.push(link)\n } else {\n internalLinks.push(link)\n }\n } else if (link.origin_id === SUBGRAPH_INPUT_ID) {\n // Subgraph input node - always boundary\n boundaryInputLinks.push(link)\n }\n }\n }\n\n // Outputs\n if (node.outputs) {\n for (const output of node.outputs) {\n addFloatingLinks(output._floatingLinks)\n\n if (!output.links) continue\n\n const many = LLink.resolveMany(output.links, graph)\n for (const { link, inputNode } of many) {\n if (\n // Subgraph output node\n link.target_id === SUBGRAPH_OUTPUT_ID ||\n // Input end of this link is outside the items set\n (inputNode && !items.has(inputNode))\n ) {\n boundaryOutputLinks.push(link)\n }\n // Internal links are discovered on input side.\n }\n }\n }\n } else if (item instanceof Reroute) {\n // Reroutes\n const reroute = item\n\n // TODO: This reroute should be on one side of the boundary. We should mark the reroute that is on each side of the boundary.\n // TODO: This could occur any number of times on a link; each time should be marked as a separate boundary.\n // TODO: e.g. A link with 3 reroutes, the first and last reroute are in `items`, but the middle reroute is not. This will be two \"in\" and two \"out\" boundaries.\n const results = LLink.resolveMany(reroute.linkIds, graph)\n for (const { link } of results) {\n const reroutes = LLink.getReroutes(graph, link)\n const reroutesOutside = reroutes.filter(reroute => !items.has(reroute))\n\n // for (const reroute of reroutes) {\n // // TODO: Do the checks here.\n // }\n\n const { inputNode, outputNode } = link.resolve(graph)\n\n if (\n reroutesOutside.length ||\n (inputNode && !items.has(inputNode)) ||\n (outputNode && !items.has(outputNode))\n ) {\n boundaryLinks.push(link)\n }\n }\n }\n }\n\n return { boundaryLinks, boundaryFloatingLinks, internalLinks, boundaryInputLinks, boundaryOutputLinks }\n\n /**\n * Adds any floating links that cross the boundary.\n * @param floatingLinks The floating links to check\n */\n function addFloatingLinks(floatingLinks: Set<LLink> | undefined): void {\n if (!floatingLinks) return\n\n for (const link of floatingLinks) {\n const crossesBoundary = LLink\n .getReroutes(graph, link)\n .some(reroute => !items.has(reroute))\n\n if (crossesBoundary) boundaryFloatingLinks.push(link)\n }\n }\n}\n\nexport function multiClone(nodes: Iterable<LGraphNode>): ISerialisedNode[] {\n const clonedNodes: ISerialisedNode[] = []\n\n // Selectively clone - keep IDs & links\n for (const node of nodes) {\n const newNode = LiteGraph.createNode(node.type)\n if (!newNode) {\n console.warn(\"Failed to create node\", node.type)\n continue\n }\n\n // Must be cloned; litegraph \"serialize\" is mostly shallow clone\n const data = LiteGraph.cloneObject(node.serialize())\n newNode.configure(data)\n\n clonedNodes.push(newNode.serialize())\n }\n\n return clonedNodes\n}\n\n/**\n * Groups resolved connections by output object. If the output is nullish, the connection will be in its own group.\n * @param resolvedConnections The resolved connections to group\n * @returns A map of grouped connections.\n */\nexport function groupResolvedByOutput(\n resolvedConnections: ResolvedConnection[],\n): Map<SubgraphIO | INodeOutputSlot | object, ResolvedConnection[]> {\n const groupedByOutput: ReturnType<typeof groupResolvedByOutput> = new Map()\n\n for (const resolved of resolvedConnections) {\n // Force no group (unique object) if output is undefined; corruption or an error has occurred\n const groupBy = resolved.subgraphInput ?? resolved.output ?? {}\n const group = groupedByOutput.get(groupBy)\n if (group) {\n group.push(resolved)\n } else {\n groupedByOutput.set(groupBy, [resolved])\n }\n }\n\n return groupedByOutput\n}\n\nexport function mapSubgraphInputsAndLinks(resolvedInputLinks: ResolvedConnection[], links: SerialisableLLink[]): SubgraphIO[] {\n // Group matching links\n const groupedByOutput = groupResolvedByOutput(resolvedInputLinks)\n\n // Create one input for each output (outside subgraph)\n const inputs: SubgraphIO[] = []\n\n for (const [, connections] of groupedByOutput) {\n const inputLinks: SerialisableLLink[] = []\n\n // Create serialised links for all links (will be recreated in subgraph)\n for (const resolved of connections) {\n const { link, input } = resolved\n if (!input) continue\n\n const linkData = link.asSerialisable()\n linkData.origin_id = SUBGRAPH_INPUT_ID\n linkData.origin_slot = inputs.length\n links.push(linkData)\n inputLinks.push(linkData)\n }\n\n // Use first input link\n const { input } = connections[0]\n if (!input) continue\n\n // Subgraph input slot\n const { color_off, color_on, dir, hasErrors, label, localized_name, name, shape, type } = input\n const uniqueName = nextUniqueName(name, inputs.map(input => input.name))\n const uniqueLocalizedName = localized_name ? nextUniqueName(localized_name, inputs.map(input => input.localized_name ?? \"\")) : undefined\n\n const inputData: SubgraphIO = {\n id: createUuidv4(),\n type: String(type),\n linkIds: inputLinks.map(link => link.id),\n name: uniqueName,\n color_off,\n color_on,\n dir,\n label,\n localized_name: uniqueLocalizedName,\n hasErrors,\n shape,\n }\n\n inputs.push(inputData)\n }\n\n return inputs\n}\n\n/**\n * Clones the output slots, and updates existing links, when converting items to a subgraph.\n * @param resolvedOutputLinks The resolved output links.\n * @param links The links to add to the subgraph.\n * @returns The subgraph output slots.\n */\nexport function mapSubgraphOutputsAndLinks(resolvedOutputLinks: ResolvedConnection[], links: SerialisableLLink[]): SubgraphIO[] {\n // Group matching links\n const groupedByOutput = groupResolvedByOutput(resolvedOutputLinks)\n\n const outputs: SubgraphIO[] = []\n\n for (const [, connections] of groupedByOutput) {\n const outputLinks: SerialisableLLink[] = []\n\n // Create serialised links for all links (will be recreated in subgraph)\n for (const resolved of connections) {\n const { link, output } = resolved\n if (!output) continue\n\n // Link\n const linkData = link.asSerialisable()\n linkData.target_id = SUBGRAPH_OUTPUT_ID\n linkData.target_slot = outputs.length\n links.push(linkData)\n outputLinks.push(linkData)\n }\n\n // Use first output link\n const { output } = connections[0]\n if (!output) continue\n\n // Subgraph output slot\n const { color_off, color_on, dir, hasErrors, label, localized_name, name, shape, type } = output\n const uniqueName = nextUniqueName(name, outputs.map(output => output.name))\n const uniqueLocalizedName = localized_name ? nextUniqueName(localized_name, outputs.map(output => output.localized_name ?? \"\")) : undefined\n\n const outputData = {\n id: createUuidv4(),\n type: String(type),\n linkIds: outputLinks.map(link => link.id),\n name: uniqueName,\n color_off,\n color_on,\n dir,\n label,\n localized_name: uniqueLocalizedName,\n hasErrors,\n shape,\n } satisfies SubgraphIO\n\n outputs.push(structuredClone(outputData))\n }\n return outputs\n}\n\n/**\n * Collects all subgraph IDs used directly in a single graph (non-recursive).\n * @param graph The graph to check for subgraph nodes\n * @returns Set of subgraph IDs used in this graph\n */\nexport function getDirectSubgraphIds(graph: GraphOrSubgraph): Set<UUID> {\n const subgraphIds = new Set<UUID>()\n\n for (const node of graph._nodes) {\n if (node.isSubgraphNode()) {\n subgraphIds.add(node.type)\n }\n }\n\n return subgraphIds\n}\n\n/**\n * Collects all subgraph IDs referenced in a graph hierarchy using BFS.\n * @param rootGraph The graph to start from\n * @param subgraphRegistry Map of all available subgraphs\n * @returns Set of all subgraph IDs found\n */\nexport function findUsedSubgraphIds(\n rootGraph: GraphOrSubgraph,\n subgraphRegistry: Map<UUID, GraphOrSubgraph>,\n): Set<UUID> {\n const usedSubgraphIds = new Set<UUID>()\n const toVisit: GraphOrSubgraph[] = [rootGraph]\n\n while (toVisit.length > 0) {\n const graph = toVisit.shift()!\n const directIds = getDirectSubgraphIds(graph)\n\n for (const id of directIds) {\n if (!usedSubgraphIds.has(id)) {\n usedSubgraphIds.add(id)\n const subgraph = subgraphRegistry.get(id)\n if (subgraph) {\n toVisit.push(subgraph)\n }\n }\n }\n }\n\n return usedSubgraphIds\n}\n\n/**\n * Type guard to check if a slot is a SubgraphInput.\n * @param slot The slot to check\n * @returns true if the slot is a SubgraphInput\n */\nexport function isSubgraphInput(slot: unknown): slot is SubgraphInput {\n return slot != null && typeof slot === \"object\" && \"parent\" in slot &&\n slot.parent instanceof SubgraphInputNode\n}\n\n/**\n * Type guard to check if a slot is a SubgraphOutput.\n * @param slot The slot to check\n * @returns true if the slot is a SubgraphOutput\n */\nexport function isSubgraphOutput(slot: unknown): slot is SubgraphOutput {\n return slot != null && typeof slot === \"object\" && \"parent\" in slot &&\n slot.parent instanceof SubgraphOutputNode\n}\n\n/**\n * Type guard to check if a slot is a regular node slot (INodeInputSlot or INodeOutputSlot).\n * @param slot The slot to check\n * @returns true if the slot is a regular node slot\n */\nexport function isNodeSlot(slot: unknown): slot is INodeInputSlot | INodeOutputSlot {\n return slot != null && typeof slot === \"object\" &&\n (\"link\" in slot || \"links\" in slot)\n}\n","import type { INodeInputSlot, INodeOutputSlot, OptionalProps, ReadOnlyPoint } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { LinkId } from \"@/LLink\"\nimport type { SubgraphInput } from \"@/subgraph/SubgraphInput\"\nimport type { SubgraphOutput } from \"@/subgraph/SubgraphOutput\"\nimport type { IBaseWidget } from \"@/types/widgets\"\n\nimport { LabelPosition } from \"@/draw\"\nimport { LiteGraph } from \"@/litegraph\"\nimport { type IDrawOptions, NodeSlot } from \"@/node/NodeSlot\"\nimport { isSubgraphInput } from \"@/subgraph/subgraphUtils\"\n\nexport class NodeInputSlot extends NodeSlot implements INodeInputSlot {\n link: LinkId | null\n\n get isWidgetInputSlot(): boolean {\n return !!this.widget\n }\n\n #widget: WeakRef<IBaseWidget> | undefined\n\n /** Internal use only; API is not finalised and may change at any time. */\n get _widget(): IBaseWidget | undefined {\n return this.#widget?.deref()\n }\n\n set _widget(widget: IBaseWidget | undefined) {\n this.#widget = widget ? new WeakRef(widget) : undefined\n }\n\n get collapsedPos(): ReadOnlyPoint {\n return [0, LiteGraph.NODE_TITLE_HEIGHT * -0.5]\n }\n\n constructor(slot: OptionalProps<INodeInputSlot, \"boundingRect\">, node: LGraphNode) {\n super(slot, node)\n this.link = slot.link\n }\n\n override get isConnected(): boolean {\n return this.link != null\n }\n\n override isValidTarget(fromSlot: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput): boolean {\n if (\"links\" in fromSlot) {\n return LiteGraph.isValidConnection(fromSlot.type, this.type)\n }\n\n if (isSubgraphInput(fromSlot)) {\n return LiteGraph.isValidConnection(fromSlot.type, this.type)\n }\n\n return false\n }\n\n override draw(ctx: CanvasRenderingContext2D, options: Omit<IDrawOptions, \"doStroke\" | \"labelPosition\">) {\n const { textAlign } = ctx\n ctx.textAlign = \"left\"\n\n super.draw(ctx, {\n ...options,\n labelPosition: LabelPosition.Right,\n doStroke: false,\n })\n\n ctx.textAlign = textAlign\n }\n}\n","import type { INodeInputSlot, INodeOutputSlot, OptionalProps, ReadOnlyPoint } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { LinkId } from \"@/LLink\"\nimport type { SubgraphInput } from \"@/subgraph/SubgraphInput\"\nimport type { SubgraphOutput } from \"@/subgraph/SubgraphOutput\"\n\nimport { LabelPosition } from \"@/draw\"\nimport { LiteGraph } from \"@/litegraph\"\nimport { type IDrawOptions, NodeSlot } from \"@/node/NodeSlot\"\nimport { isSubgraphOutput } from \"@/subgraph/subgraphUtils\"\n\nexport class NodeOutputSlot extends NodeSlot implements INodeOutputSlot {\n #node: LGraphNode\n\n links: LinkId[] | null\n _data?: unknown\n slot_index?: number\n\n get isWidgetInputSlot(): false {\n return false\n }\n\n get collapsedPos(): ReadOnlyPoint {\n return [\n this.#node._collapsed_width ?? LiteGraph.NODE_COLLAPSED_WIDTH,\n LiteGraph.NODE_TITLE_HEIGHT * -0.5,\n ]\n }\n\n constructor(slot: OptionalProps<INodeOutputSlot, \"boundingRect\">, node: LGraphNode) {\n super(slot, node)\n this.links = slot.links\n this._data = slot._data\n this.slot_index = slot.slot_index\n this.#node = node\n }\n\n override isValidTarget(fromSlot: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput): boolean {\n if (\"link\" in fromSlot) {\n return LiteGraph.isValidConnection(this.type, fromSlot.type)\n }\n\n if (isSubgraphOutput(fromSlot)) {\n return LiteGraph.isValidConnection(this.type, fromSlot.type)\n }\n\n return false\n }\n\n override get isConnected(): boolean {\n return this.links != null && this.links.length > 0\n }\n\n override draw(ctx: CanvasRenderingContext2D, options: Omit<IDrawOptions, \"doStroke\" | \"labelPosition\">) {\n const { textAlign, strokeStyle } = ctx\n ctx.textAlign = \"right\"\n ctx.strokeStyle = \"black\"\n\n super.draw(ctx, {\n ...options,\n labelPosition: LabelPosition.Left,\n doStroke: true,\n })\n\n ctx.textAlign = textAlign\n ctx.strokeStyle = strokeStyle\n }\n}\n","import type { IWidgetInputSlot, SharedIntersection } from \"@/interfaces\"\nimport type { INodeInputSlot, INodeOutputSlot, INodeSlot, IWidget } from \"@/litegraph\"\nimport type { ISerialisableNodeInput, ISerialisableNodeOutput } from \"@/types/serialisation\"\n\ntype CommonIoSlotProps = SharedIntersection<ISerialisableNodeInput, ISerialisableNodeOutput>\n\nexport function shallowCloneCommonProps(slot: CommonIoSlotProps): CommonIoSlotProps {\n const { color_off, color_on, dir, label, localized_name, locked, name, nameLocked, removable, shape, type } = slot\n return { color_off, color_on, dir, label, localized_name, locked, name, nameLocked, removable, shape, type }\n}\n\nexport function inputAsSerialisable(slot: INodeInputSlot): ISerialisableNodeInput {\n const { link } = slot\n const widgetOrPos = slot.widget\n ? { widget: { name: slot.widget.name } }\n : { pos: slot.pos }\n\n return {\n ...shallowCloneCommonProps(slot),\n ...widgetOrPos,\n link,\n }\n}\n\nexport function outputAsSerialisable(slot: INodeOutputSlot & { widget?: IWidget }): ISerialisableNodeOutput {\n const { pos, slot_index, links, widget } = slot\n // Output widgets do not exist in Litegraph; this is a temporary downstream workaround.\n const outputWidget = widget\n ? { widget: { name: widget.name } }\n : null\n\n return {\n ...shallowCloneCommonProps(slot),\n ...outputWidget,\n pos,\n slot_index,\n links,\n }\n}\n\nexport function isINodeInputSlot(slot: INodeSlot): slot is INodeInputSlot {\n return \"link\" in slot\n}\n\nexport function isINodeOutputSlot(slot: INodeSlot): slot is INodeOutputSlot {\n return \"links\" in slot\n}\n\n/**\n * Type guard: Whether this input slot is attached to a widget.\n * @param slot The slot to check.\n */\n\nexport function isWidgetInputSlot(slot: INodeInputSlot): slot is IWidgetInputSlot {\n return !!slot.widget\n}\n","import { LiteGraph } from \"@/litegraph\"\n\n/** Guard against unbound allocation. */\nconst UNIQUE_MESSAGE_LIMIT = 10_000\nconst sentWarnings: Set<string> = new Set()\n\n/**\n * Warns that a deprecated function has been used via the public\n * {@link onDeprecationWarning} / {@link onEveryDeprecationWarning} callback arrays.\n * @param message Plain-language detail about what has been deprecated. This **should not** include unique data; use {@link source}.\n * @param source A reference object to include alongside the message, e.g. `this`.\n */\nexport function warnDeprecated(message: string, source?: object): void {\n if (!LiteGraph.alwaysRepeatWarnings) {\n // Do not repeat\n if (sentWarnings.has(message)) return\n\n // Hard limit of unique messages per session\n if (sentWarnings.size > UNIQUE_MESSAGE_LIMIT) return\n\n sentWarnings.add(message)\n }\n\n for (const callback of LiteGraph.onDeprecationWarning) {\n callback(message, source)\n }\n}\n","export interface SpaceRequest {\n minSize: number\n maxSize?: number\n}\n\n/**\n * Distributes available space among items with min/max size constraints\n * @param totalSpace Total space available to distribute\n * @param requests Array of space requests with size constraints\n * @returns Array of space allocations\n */\nexport function distributeSpace(\n totalSpace: number,\n requests: SpaceRequest[],\n): number[] {\n // Handle edge cases\n if (requests.length === 0) return []\n\n // Calculate total minimum space needed\n const totalMinSize = requests.reduce((sum, req) => sum + req.minSize, 0)\n\n // If we can't meet minimum requirements, return the minimum sizes\n if (totalSpace < totalMinSize) {\n return requests.map(req => req.minSize)\n }\n\n // Initialize allocations with minimum sizes\n let allocations = requests.map(req => ({\n computedSize: req.minSize,\n maxSize: req.maxSize ?? Infinity,\n remaining: (req.maxSize ?? Infinity) - req.minSize,\n }))\n\n // Calculate remaining space to distribute\n let remainingSpace = totalSpace - totalMinSize\n\n // Distribute remaining space iteratively\n while (\n remainingSpace > 0 &&\n allocations.some(alloc => alloc.remaining > 0)\n ) {\n // Count items that can still grow\n const growableItems = allocations.filter(\n alloc => alloc.remaining > 0,\n ).length\n\n if (growableItems === 0) break\n\n // Calculate fair share per item\n const sharePerItem = remainingSpace / growableItems\n\n // Track how much space was actually used in this iteration\n let spaceUsedThisRound = 0\n\n // Distribute space\n allocations = allocations.map((alloc) => {\n if (alloc.remaining <= 0) return alloc\n\n const growth = Math.min(sharePerItem, alloc.remaining)\n spaceUsedThisRound += growth\n\n return {\n ...alloc,\n computedSize: alloc.computedSize + growth,\n remaining: alloc.remaining - growth,\n }\n })\n\n remainingSpace -= spaceUsedThisRound\n\n // Break if we couldn't distribute any more space\n if (spaceUsedThisRound === 0) break\n }\n\n // Return only the computed sizes\n return allocations.map(({ computedSize }) => computedSize)\n}\n","/**\n * Truncates text to fit within a given width using binary search for optimal performance.\n * @param ctx The canvas rendering context used for text measurement\n * @param text The text to truncate\n * @param maxWidth The maximum width the text should occupy\n * @param ellipsis The ellipsis string to append (default: \"...\")\n * @returns The truncated text with ellipsis if needed\n */\nexport function truncateText(\n ctx: CanvasRenderingContext2D,\n text: string,\n maxWidth: number,\n ellipsis: string = \"...\",\n): string {\n const textWidth = ctx.measureText(text).width\n\n if (textWidth <= maxWidth || maxWidth <= 0) {\n return text\n }\n\n const ellipsisWidth = ctx.measureText(ellipsis).width\n const availableWidth = maxWidth - ellipsisWidth\n\n if (availableWidth <= 0) {\n return ellipsis\n }\n\n // Binary search for the right length\n let low = 0\n let high = text.length\n let bestFit = 0\n\n while (low <= high) {\n const mid = Math.floor((low + high) / 2)\n const testText = text.substring(0, mid)\n const testWidth = ctx.measureText(testText).width\n\n if (testWidth <= availableWidth) {\n bestFit = mid\n low = mid + 1\n } else {\n high = mid - 1\n }\n }\n\n return text.substring(0, bestFit) + ellipsis\n}\n","import type { IColorable } from \"@/interfaces\"\n\n/**\n * Converts a plain object to a class instance if it is not already an instance of the class.\n *\n * Requires specific constructor signature; first parameter must be the object to convert.\n * @param cls The class to convert to\n * @param args The object to convert, followed by any other constructor arguments\n * @returns The class instance\n */\nexport function toClass<P, C extends P, Args extends unknown[]>(\n cls: new (instance: P, ...args: Args) => C,\n ...args: [P, ...Args]\n): C {\n return args[0] instanceof cls ? args[0] : new cls(...args)\n}\n\n/**\n * Checks if an object is an instance of {@link IColorable}.\n */\nexport function isColorable(obj: unknown): obj is IColorable {\n return typeof obj === \"object\" && obj !== null && \"setColorOption\" in obj && \"getColorOption\" in obj\n}\n","import type { Point } from \"@/interfaces\"\nimport type { CanvasPointer, LGraphCanvas, LGraphNode, Size } from \"@/litegraph\"\nimport type { CanvasPointerEvent } from \"@/types/events\"\nimport type { IBaseWidget } from \"@/types/widgets\"\n\nimport { drawTextInArea } from \"@/draw\"\nimport { Rectangle } from \"@/infrastructure/Rectangle\"\nimport { LiteGraph } from \"@/litegraph\"\n\nexport interface DrawWidgetOptions {\n /** The width of the node where this widget will be displayed. */\n width: number\n /** Synonym for \"low quality\". */\n showText?: boolean\n}\n\nexport interface DrawTruncatingTextOptions extends DrawWidgetOptions {\n /** The canvas context to draw the text on. */\n ctx: CanvasRenderingContext2D\n /** The amount of padding to add to the left of the text. */\n leftPadding?: number\n /** The amount of padding to add to the right of the text. */\n rightPadding?: number\n}\n\nexport interface WidgetEventOptions {\n e: CanvasPointerEvent\n node: LGraphNode\n canvas: LGraphCanvas\n}\n\nexport abstract class BaseWidget<TWidget extends IBaseWidget = IBaseWidget> implements IBaseWidget {\n /** From node edge to widget edge */\n static margin = 15\n /** From widget edge to tip of arrow button */\n static arrowMargin = 6\n /** Arrow button width */\n static arrowWidth = 10\n /** Absolute minimum display width of widget values */\n static minValueWidth = 42\n /** Minimum gap between label and value */\n static labelValueGap = 5\n\n declare computedHeight?: number\n declare serialize?: boolean\n computeLayoutSize?(node: LGraphNode): {\n minHeight: number\n maxHeight?: number\n minWidth: number\n maxWidth?: number\n }\n\n #node: LGraphNode\n /** The node that this widget belongs to. */\n get node() {\n return this.#node\n }\n\n linkedWidgets?: IBaseWidget[]\n name: string\n options: TWidget[\"options\"]\n label?: string\n type: TWidget[\"type\"]\n y: number = 0\n last_y?: number\n width?: number\n disabled?: boolean\n computedDisabled?: boolean\n hidden?: boolean\n advanced?: boolean\n tooltip?: string\n element?: HTMLElement\n callback?(\n value: any,\n canvas?: LGraphCanvas,\n node?: LGraphNode,\n pos?: Point,\n e?: CanvasPointerEvent,\n ): void\n mouse?(event: CanvasPointerEvent, pointerOffset: Point, node: LGraphNode): boolean\n computeSize?(width?: number): Size\n onPointerDown?(pointer: CanvasPointer, node: LGraphNode, canvas: LGraphCanvas): boolean\n\n #value?: TWidget[\"value\"]\n get value(): TWidget[\"value\"] {\n return this.#value\n }\n\n set value(value: TWidget[\"value\"]) {\n this.#value = value\n }\n\n constructor(widget: TWidget & { node: LGraphNode })\n constructor(widget: TWidget, node: LGraphNode)\n constructor(widget: TWidget & { node: LGraphNode }, node?: LGraphNode) {\n // Private fields\n this.#node = node ?? widget.node\n\n // The set and get functions for DOM widget values are hacked on to the options object;\n // attempting to set value before options will throw.\n // https://github.com/Comfy-Org/ComfyUI_frontend/blob/df86da3d672628a452baed3df3347a52c0c8d378/src/scripts/domWidget.ts#L125\n this.name = widget.name\n this.options = widget.options\n this.type = widget.type\n\n // `node` has no setter - Object.assign will throw.\n // TODO: Resolve this workaround. Ref: https://github.com/Comfy-Org/litegraph.js/issues/1022\n // @ts-expect-error Prevent naming conflicts with custom nodes.\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { node: _, outline_color, background_color, height, text_color, secondary_text_color, disabledTextColor, displayName, displayValue, labelBaseline, ...safeValues } = widget\n\n Object.assign(this, safeValues)\n }\n\n get outline_color() {\n return this.advanced ? LiteGraph.WIDGET_ADVANCED_OUTLINE_COLOR : LiteGraph.WIDGET_OUTLINE_COLOR\n }\n\n get background_color() {\n return LiteGraph.WIDGET_BGCOLOR\n }\n\n get height() {\n return LiteGraph.NODE_WIDGET_HEIGHT\n }\n\n get text_color() {\n return LiteGraph.WIDGET_TEXT_COLOR\n }\n\n get secondary_text_color() {\n return LiteGraph.WIDGET_SECONDARY_TEXT_COLOR\n }\n\n get disabledTextColor() {\n return LiteGraph.WIDGET_DISABLED_TEXT_COLOR\n }\n\n get displayName() {\n return this.label || this.name\n }\n\n // TODO: Resolve this workaround. Ref: https://github.com/Comfy-Org/litegraph.js/issues/1022\n get _displayValue(): string {\n return this.computedDisabled ? \"\" : String(this.value)\n }\n\n get labelBaseline() {\n return this.y + this.height * 0.7\n }\n\n /**\n * Draws the widget\n * @param ctx The canvas context\n * @param options The options for drawing the widget\n * @remarks Not naming this `draw` as `draw` conflicts with the `draw` method in\n * custom widgets.\n */\n abstract drawWidget(ctx: CanvasRenderingContext2D, options: DrawWidgetOptions): void\n\n /**\n * Draws the standard widget shape - elongated capsule. The path of the widget shape is not\n * cleared, and may be used for further drawing.\n * @param ctx The canvas context\n * @param options The options for drawing the widget\n * @remarks Leaves {@link ctx} dirty.\n */\n protected drawWidgetShape(ctx: CanvasRenderingContext2D, { width, showText }: DrawWidgetOptions): void {\n const { height, y } = this\n const { margin } = BaseWidget\n\n ctx.textAlign = \"left\"\n ctx.strokeStyle = this.outline_color\n ctx.fillStyle = this.background_color\n ctx.beginPath()\n\n if (showText) {\n ctx.roundRect(margin, y, width - margin * 2, height, [height * 0.5])\n } else {\n ctx.rect(margin, y, width - margin * 2, height)\n }\n ctx.fill()\n if (showText && !this.computedDisabled) ctx.stroke()\n }\n\n /**\n * A shared routine for drawing a label and value as text, truncated\n * if they exceed the available width.\n */\n protected drawTruncatingText({\n ctx,\n width,\n leftPadding = 5,\n rightPadding = 20,\n }: DrawTruncatingTextOptions): void {\n const { height, y } = this\n const { margin } = BaseWidget\n\n // Measure label and value\n const { displayName, _displayValue } = this\n const labelWidth = ctx.measureText(displayName).width\n const valueWidth = ctx.measureText(_displayValue).width\n\n const gap = BaseWidget.labelValueGap\n const x = margin * 2 + leftPadding\n\n const totalWidth = width - x - 2 * margin - rightPadding\n const requiredWidth = labelWidth + gap + valueWidth\n\n const area = new Rectangle(x, y, totalWidth, height * 0.7)\n\n ctx.fillStyle = this.secondary_text_color\n\n if (requiredWidth <= totalWidth) {\n // Draw label & value normally\n drawTextInArea({ ctx, text: displayName, area, align: \"left\" })\n } else if (LiteGraph.truncateWidgetTextEvenly) {\n // Label + value will not fit - scale evenly to fit\n const scale = (totalWidth - gap) / (requiredWidth - gap)\n area.width = labelWidth * scale\n\n drawTextInArea({ ctx, text: displayName, area, align: \"left\" })\n\n // Move the area to the right to render the value\n area.right = x + totalWidth\n area.setWidthRightAnchored(valueWidth * scale)\n } else if (LiteGraph.truncateWidgetValuesFirst) {\n // Label + value will not fit - use legacy scaling of value first\n const cappedLabelWidth = Math.min(labelWidth, totalWidth)\n\n area.width = cappedLabelWidth\n drawTextInArea({ ctx, text: displayName, area, align: \"left\" })\n\n area.right = x + totalWidth\n area.setWidthRightAnchored(Math.max(totalWidth - gap - cappedLabelWidth, 0))\n } else {\n // Label + value will not fit - scale label first\n const cappedValueWidth = Math.min(valueWidth, totalWidth)\n\n area.width = Math.max(totalWidth - gap - cappedValueWidth, 0)\n drawTextInArea({ ctx, text: displayName, area, align: \"left\" })\n\n area.right = x + totalWidth\n area.setWidthRightAnchored(cappedValueWidth)\n }\n ctx.fillStyle = this.text_color\n drawTextInArea({ ctx, text: _displayValue, area, align: \"right\" })\n }\n\n /**\n * Handles the click event for the widget\n * @param options The options for handling the click event\n */\n abstract onClick(options: WidgetEventOptions): void\n\n /**\n * Handles the drag event for the widget\n * @param options The options for handling the drag event\n */\n onDrag?(options: WidgetEventOptions): void\n\n /**\n * Sets the value of the widget\n * @param value The value to set\n * @param options The options for setting the value\n */\n setValue(value: TWidget[\"value\"], { e, node, canvas }: WidgetEventOptions): void {\n const oldValue = this.value\n if (value === this.value) return\n\n const v = this.type === \"number\" ? Number(value) : value\n this.value = v\n if (\n this.options?.property &&\n node.properties[this.options.property] !== undefined\n ) {\n node.setProperty(this.options.property, v)\n }\n const pos = canvas.graph_mouse\n this.callback?.(this.value, canvas, node, pos, e)\n\n node.onWidgetChanged?.(this.name ?? \"\", v, oldValue, this)\n if (node.graph) node.graph._version++\n }\n\n /**\n * Clones the widget.\n * @param node The node that will own the cloned widget.\n * @returns A new widget with the same properties as the original\n * @remarks Subclasses with custom constructors must override this method.\n *\n * Correctly and safely typing this is currently not possible (practical?) in TypeScript 5.8.\n */\n createCopyForNode(node: LGraphNode): this {\n // @ts-expect-error\n const cloned: this = new (this.constructor as typeof this)(this, node)\n cloned.value = this.value\n return cloned\n }\n}\n","import type { IBooleanWidget } from \"@/types/widgets\"\n\nimport { BaseWidget, type DrawWidgetOptions, type WidgetEventOptions } from \"./BaseWidget\"\n\nexport class BooleanWidget extends BaseWidget<IBooleanWidget> implements IBooleanWidget {\n override type = \"toggle\" as const\n\n override drawWidget(ctx: CanvasRenderingContext2D, {\n width,\n showText = true,\n }: DrawWidgetOptions) {\n const { height, y } = this\n const { margin } = BaseWidget\n\n this.drawWidgetShape(ctx, { width, showText })\n\n ctx.fillStyle = this.value ? \"#89A\" : \"#333\"\n ctx.beginPath()\n ctx.arc(\n width - margin * 2,\n y + height * 0.5,\n height * 0.36,\n 0,\n Math.PI * 2,\n )\n ctx.fill()\n\n if (showText) {\n this.drawLabel(ctx, margin * 2)\n this.drawValue(ctx, width - 40)\n }\n }\n\n drawLabel(ctx: CanvasRenderingContext2D, x: number): void {\n // Draw label\n ctx.fillStyle = this.secondary_text_color\n const { displayName } = this\n if (displayName) ctx.fillText(displayName, x, this.labelBaseline)\n }\n\n drawValue(ctx: CanvasRenderingContext2D, x: number): void {\n // Draw value\n ctx.fillStyle = this.value ? this.text_color : this.secondary_text_color\n ctx.textAlign = \"right\"\n const value = this.value ? this.options.on || \"true\" : this.options.off || \"false\"\n ctx.fillText(value, x, this.labelBaseline)\n }\n\n override onClick(options: WidgetEventOptions) {\n this.setValue(!this.value, options)\n }\n}\n","import type { LGraphNode } from \"@/LGraphNode\"\nimport type { IButtonWidget } from \"@/types/widgets\"\n\nimport { BaseWidget, type DrawWidgetOptions, type WidgetEventOptions } from \"./BaseWidget\"\n\nexport class ButtonWidget extends BaseWidget<IButtonWidget> implements IButtonWidget {\n override type = \"button\" as const\n clicked: boolean\n\n constructor(widget: IButtonWidget, node: LGraphNode) {\n super(widget, node)\n this.clicked ??= false\n }\n\n /**\n * Draws the widget\n * @param ctx The canvas context\n * @param options The options for drawing the widget\n */\n override drawWidget(ctx: CanvasRenderingContext2D, {\n width,\n showText = true,\n }: DrawWidgetOptions) {\n // Store original context attributes\n const { fillStyle, strokeStyle, textAlign } = ctx\n\n const { height, y } = this\n const { margin } = BaseWidget\n\n // Draw button background\n ctx.fillStyle = this.background_color\n if (this.clicked) {\n ctx.fillStyle = \"#AAA\"\n this.clicked = false\n }\n ctx.fillRect(margin, y, width - margin * 2, height)\n\n // Draw button outline if not disabled\n if (showText && !this.computedDisabled) {\n ctx.strokeStyle = this.outline_color\n ctx.strokeRect(margin, y, width - margin * 2, height)\n }\n\n // Draw button text\n if (showText) this.drawLabel(ctx, width * 0.5)\n\n // Restore original context attributes\n Object.assign(ctx, { textAlign, strokeStyle, fillStyle })\n }\n\n drawLabel(ctx: CanvasRenderingContext2D, x: number): void {\n ctx.textAlign = \"center\"\n ctx.fillStyle = this.text_color\n ctx.fillText(this.displayName, x, this.y + this.height * 0.7)\n }\n\n override onClick({ e, node, canvas }: WidgetEventOptions) {\n const pos = canvas.graph_mouse\n\n // Set clicked state and mark canvas as dirty\n this.clicked = true\n canvas.setDirty(true)\n\n // Call the callback with widget instance and other context\n this.callback?.(this, canvas, node, pos, e)\n }\n}\n","import type { IBaseWidget } from \"@/types/widgets\"\n\nimport { BaseWidget, type DrawWidgetOptions, type WidgetEventOptions } from \"./BaseWidget\"\n\n/**\n * Base class for widgets that have increment and decrement buttons.\n */\nexport abstract class BaseSteppedWidget<TWidget extends IBaseWidget = IBaseWidget> extends BaseWidget<TWidget> {\n /**\n * Whether the widget can increment its value\n * @returns `true` if the widget can increment its value, otherwise `false`\n */\n abstract canIncrement(): boolean\n /**\n * Whether the widget can decrement its value\n * @returns `true` if the widget can decrement its value, otherwise `false`\n */\n abstract canDecrement(): boolean\n /**\n * Increment the value of the widget\n * @param options The options for the widget event\n */\n abstract incrementValue(options: WidgetEventOptions): void\n /**\n * Decrement the value of the widget\n * @param options The options for the widget event\n */\n abstract decrementValue(options: WidgetEventOptions): void\n\n /**\n * Draw the arrow buttons for the widget\n * @param ctx The canvas rendering context\n * @param width The width of the widget\n */\n drawArrowButtons(ctx: CanvasRenderingContext2D, width: number) {\n const { height, text_color, disabledTextColor, y } = this\n const { arrowMargin, arrowWidth, margin } = BaseWidget\n const arrowTipX = margin + arrowMargin\n const arrowInnerX = arrowTipX + arrowWidth\n\n // Draw left arrow\n ctx.fillStyle = this.canDecrement() ? text_color : disabledTextColor\n ctx.beginPath()\n ctx.moveTo(arrowInnerX, y + 5)\n ctx.lineTo(arrowTipX, y + height * 0.5)\n ctx.lineTo(arrowInnerX, y + height - 5)\n ctx.fill()\n\n // Draw right arrow\n ctx.fillStyle = this.canIncrement() ? text_color : disabledTextColor\n ctx.beginPath()\n ctx.moveTo(width - arrowInnerX, y + 5)\n ctx.lineTo(width - arrowTipX, y + height * 0.5)\n ctx.lineTo(width - arrowInnerX, y + height - 5)\n ctx.fill()\n }\n\n override drawWidget(ctx: CanvasRenderingContext2D, options: DrawWidgetOptions) {\n // Store original context attributes\n const { fillStyle, strokeStyle, textAlign } = ctx\n\n this.drawWidgetShape(ctx, options)\n if (options.showText) {\n if (!this.computedDisabled) this.drawArrowButtons(ctx, options.width)\n\n this.drawTruncatingText({ ctx, width: options.width })\n }\n\n // Restore original context attributes\n Object.assign(ctx, { textAlign, strokeStyle, fillStyle })\n }\n}\n","import type { WidgetEventOptions } from \"./BaseWidget\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { IComboWidget, IStringComboWidget } from \"@/types/widgets\"\n\nimport { clamp, LiteGraph } from \"@/litegraph\"\nimport { warnDeprecated } from \"@/utils/feedback\"\n\nimport { BaseSteppedWidget } from \"./BaseSteppedWidget\"\n\n/**\n * This is used as an (invalid) assertion to resolve issues with legacy duck-typed values.\n *\n * Function style in use by:\n * https://github.com/kijai/ComfyUI-KJNodes/blob/c3dc82108a2a86c17094107ead61d63f8c76200e/web/js/setgetnodes.js#L401-L404\n */\ntype Values = string[] | Record<string, string> | ((widget?: ComboWidget, node?: LGraphNode) => string[])\n\nfunction toArray(values: Values): string[] {\n return Array.isArray(values) ? values : Object.keys(values)\n}\n\nexport class ComboWidget extends BaseSteppedWidget<IStringComboWidget | IComboWidget> implements IComboWidget {\n override type = \"combo\" as const\n\n override get _displayValue() {\n if (this.computedDisabled) return \"\"\n const { values: rawValues } = this.options\n if (rawValues) {\n const values = typeof rawValues === \"function\" ? rawValues() : rawValues\n\n if (values && !Array.isArray(values)) {\n return values[this.value]\n }\n }\n return typeof this.value === \"number\" ? String(this.value) : this.value\n }\n\n #getValues(node: LGraphNode): Values {\n const { values } = this.options\n if (values == null) throw new Error(\"[ComboWidget]: values is required\")\n\n return typeof values === \"function\"\n ? values(this, node)\n : values\n }\n\n /**\n * Checks if the value is {@link Array.at at} the given index in the combo list.\n * @param increment `true` if checking the use of the increment button, `false` for decrement\n * @returns `true` if the value is at the given index, otherwise `false`.\n */\n #canUseButton(increment: boolean): boolean {\n const { values } = this.options\n // If using legacy duck-typed method, false is the most permissive return value\n if (typeof values === \"function\") return false\n\n const valuesArray = toArray(values)\n if (!(valuesArray.length > 1)) return false\n\n // Edge case where the value is both the first and last item in the list\n const firstValue = valuesArray.at(0)\n const lastValue = valuesArray.at(-1)\n if (firstValue === lastValue) return true\n\n return this.value !== (increment ? lastValue : firstValue)\n }\n\n /**\n * Returns `true` if the current value is not the last value in the list.\n * Handles edge case where the value is both the first and last item in the list.\n */\n override canIncrement(): boolean {\n return this.#canUseButton(true)\n }\n\n override canDecrement(): boolean {\n return this.#canUseButton(false)\n }\n\n override incrementValue(options: WidgetEventOptions): void {\n this.#tryChangeValue(1, options)\n }\n\n override decrementValue(options: WidgetEventOptions): void {\n this.#tryChangeValue(-1, options)\n }\n\n #tryChangeValue(delta: number, options: WidgetEventOptions): void {\n const values = this.#getValues(options.node)\n const indexedValues = toArray(values)\n\n // avoids double click event\n options.canvas.last_mouseclick = 0\n\n const foundIndex = typeof values === \"object\"\n ? indexedValues.indexOf(String(this.value)) + delta\n // @ts-expect-error handle non-string values\n : indexedValues.indexOf(this.value) + delta\n\n const index = clamp(foundIndex, 0, indexedValues.length - 1)\n\n const value = Array.isArray(values)\n ? values[index]\n : index\n this.setValue(value, options)\n }\n\n override onClick({ e, node, canvas }: WidgetEventOptions) {\n const x = e.canvasX - node.pos[0]\n const width = this.width || node.size[0]\n\n // Deprecated functionality (warning as of v0.14.5)\n if (typeof this.options.values === \"function\") {\n warnDeprecated(\"Using a function for values is deprecated. Use an array of unique values instead.\")\n }\n\n // Determine if clicked on left/right arrows\n if (x < 40) return this.decrementValue({ e, node, canvas })\n if (x > width - 40) return this.incrementValue({ e, node, canvas })\n\n // Otherwise, show dropdown menu\n const values = this.#getValues(node)\n const values_list = toArray(values)\n\n // Handle center click - show dropdown menu\n const text_values = values != values_list ? Object.values(values) : values\n new LiteGraph.ContextMenu(text_values, {\n scale: Math.max(1, canvas.ds.scale),\n event: e,\n className: \"dark\",\n callback: (value: string) => {\n this.setValue(\n values != values_list\n ? text_values.indexOf(value)\n : value,\n { e, node, canvas },\n )\n },\n })\n }\n}\n","import type { IWidgetOptions } from \"@/types/widgets\"\n\n/**\n * The step value for numeric widgets.\n * Use {@link IWidgetOptions.step2} if available, otherwise fallback to\n * {@link IWidgetOptions.step} which is scaled up by 10x in the legacy frontend logic.\n */\nexport function getWidgetStep(options: IWidgetOptions<unknown>): number {\n return options.step2 || ((options.step || 10) * 0.1)\n}\n","import type { IKnobWidget } from \"@/types/widgets\"\n\nimport { clamp } from \"@/litegraph\"\nimport { getWidgetStep } from \"@/utils/widget\"\n\nimport { BaseWidget, type DrawWidgetOptions, type WidgetEventOptions } from \"./BaseWidget\"\n\nexport class KnobWidget extends BaseWidget<IKnobWidget> implements IKnobWidget {\n override type = \"knob\" as const\n\n /**\n * Compute the layout size of the widget.\n * @returns The layout size of the widget.\n */\n override computeLayoutSize(): {\n minHeight: number\n maxHeight?: number\n minWidth: number\n maxWidth?: number\n } {\n return {\n minHeight: 60,\n minWidth: 20,\n maxHeight: 1_000_000,\n maxWidth: 1_000_000,\n }\n }\n\n override get height(): number {\n return this.computedHeight || super.height\n }\n\n drawWidget(\n ctx: CanvasRenderingContext2D,\n {\n width,\n showText = true,\n }: DrawWidgetOptions,\n ): void {\n // Store original context attributes\n const { fillStyle, strokeStyle, textAlign } = ctx\n\n const { y } = this\n const { margin } = BaseWidget\n\n const { gradient_stops = \"rgb(14, 182, 201); rgb(0, 216, 72)\" } = this.options\n const effective_height = this.computedHeight || this.height\n // Draw background\n const size_modifier =\n Math.min(this.computedHeight || this.height, this.width || 20) / 20 // TODO: replace magic numbers\n const arc_center = { x: width / 2, y: effective_height / 2 + y }\n ctx.lineWidth =\n (Math.min(width, effective_height) - margin * size_modifier) / 6\n const arc_size =\n (Math.min(width, effective_height) -\n margin * size_modifier -\n ctx.lineWidth) / 2\n {\n const gradient = ctx.createRadialGradient(\n arc_center.x,\n arc_center.y,\n arc_size + ctx.lineWidth,\n 0,\n 0,\n arc_size + ctx.lineWidth,\n )\n gradient.addColorStop(0, \"rgb(29, 29, 29)\")\n gradient.addColorStop(1, \"rgb(116, 116, 116)\")\n ctx.fillStyle = gradient\n }\n ctx.beginPath()\n\n {\n ctx.arc(\n arc_center.x,\n arc_center.y,\n arc_size + ctx.lineWidth / 2,\n 0,\n Math.PI * 2,\n false,\n )\n ctx.fill()\n ctx.closePath()\n }\n\n // Draw knob's background\n const arc = {\n start_angle: Math.PI * 0.6,\n end_angle: Math.PI * 2.4,\n }\n ctx.beginPath()\n {\n const gradient = ctx.createRadialGradient(\n arc_center.x,\n arc_center.y,\n arc_size + ctx.lineWidth,\n 0,\n 0,\n arc_size + ctx.lineWidth,\n )\n gradient.addColorStop(0, \"rgb(99, 99, 99)\")\n gradient.addColorStop(1, \"rgb(36, 36, 36)\")\n ctx.strokeStyle = gradient\n }\n ctx.arc(\n arc_center.x,\n arc_center.y,\n arc_size,\n arc.start_angle,\n arc.end_angle,\n false,\n )\n ctx.stroke()\n ctx.closePath()\n\n const range = this.options.max - this.options.min\n let nvalue = (this.value - this.options.min) / range\n nvalue = clamp(nvalue, 0, 1)\n\n // Draw value\n ctx.beginPath()\n const gradient = ctx.createConicGradient(\n arc.start_angle,\n arc_center.x,\n arc_center.y,\n )\n const gs = gradient_stops.split(\";\")\n for (const [index, stop] of gs.entries()) {\n gradient.addColorStop(index, stop.trim())\n }\n\n ctx.strokeStyle = gradient\n const value_end_angle =\n (arc.end_angle - arc.start_angle) * nvalue + arc.start_angle\n ctx.arc(\n arc_center.x,\n arc_center.y,\n arc_size,\n arc.start_angle,\n value_end_angle,\n false,\n )\n ctx.stroke()\n ctx.closePath()\n\n // Draw outline if not disabled\n if (showText && !this.computedDisabled) {\n ctx.strokeStyle = this.outline_color\n // Draw value\n ctx.beginPath()\n ctx.strokeStyle = this.outline_color\n ctx.arc(\n arc_center.x,\n arc_center.y,\n arc_size + ctx.lineWidth / 2,\n 0,\n Math.PI * 2,\n false,\n )\n ctx.lineWidth = 1\n ctx.stroke()\n ctx.closePath()\n }\n\n // Draw marker if present\n // TODO: TBD later when options work\n\n // Draw text\n if (showText) {\n ctx.textAlign = \"center\"\n ctx.fillStyle = this.text_color\n const fixedValue = Number(this.value).toFixed(this.options.precision ?? 3)\n ctx.fillText(\n `${this.label || this.name}\\n${fixedValue}`,\n width * 0.5,\n y + effective_height * 0.5,\n )\n }\n\n // Restore original context attributes\n Object.assign(ctx, { textAlign, strokeStyle, fillStyle })\n }\n\n onClick(): void {\n this.current_drag_offset = 0\n }\n\n current_drag_offset = 0\n override onDrag(options: WidgetEventOptions): void {\n if (this.options.read_only) return\n const { e } = options\n const step = getWidgetStep(this.options)\n // Shift to move by 10% increments\n const range = (this.options.max - this.options.min)\n const range_10_percent = range / 10\n const range_1_percent = range / 100\n const step_for = {\n delta_x: step,\n shift: range_10_percent > step ? range_10_percent - (range_10_percent % step) : step,\n delta_y: range_1_percent > step ? range_1_percent - (range_1_percent % step) : step, // 1% increments\n }\n\n const use_y = Math.abs(e.movementY) > Math.abs(e.movementX)\n const delta = use_y ? -e.movementY : e.movementX // Y is inverted so that UP increases the value\n const drag_threshold = 15\n // Calculate new value based on drag movement\n this.current_drag_offset += delta\n let adjustment = 0\n if (this.current_drag_offset > drag_threshold) {\n adjustment += 1\n this.current_drag_offset -= drag_threshold\n } else if (this.current_drag_offset < -drag_threshold) {\n adjustment -= 1\n this.current_drag_offset += drag_threshold\n }\n\n const step_with_shift_modifier = e.shiftKey\n ? step_for.shift\n : (use_y\n ? step_for.delta_y\n : step)\n\n const deltaValue = adjustment * step_with_shift_modifier\n const newValue = clamp(\n this.value + deltaValue,\n this.options.min,\n this.options.max,\n )\n if (newValue !== this.value) {\n this.setValue(newValue, options)\n }\n }\n}\n","import type { LGraphNode } from \"@/LGraphNode\"\nimport type { IBaseWidget } from \"@/types/widgets\"\n\nimport { LiteGraph } from \"@/litegraph\"\n\nimport { BaseWidget, type DrawWidgetOptions } from \"./BaseWidget\"\n\n/**\n * Wraps a legacy POJO custom widget, so that all widgets may be called via the same internal interface.\n *\n * Support will eventually be removed.\n * @remarks Expect this class to undergo breaking changes without warning.\n */\nexport class LegacyWidget<TWidget extends IBaseWidget = IBaseWidget> extends BaseWidget<TWidget> implements IBaseWidget {\n draw?(\n ctx: CanvasRenderingContext2D,\n node: LGraphNode,\n widget_width: number,\n y: number,\n H: number,\n lowQuality?: boolean,\n ): void\n\n override drawWidget(ctx: CanvasRenderingContext2D, options: DrawWidgetOptions) {\n const H = LiteGraph.NODE_WIDGET_HEIGHT\n this.draw?.(ctx, this.node, options.width, this.y, H, !!options.showText)\n }\n\n override onClick() {\n console.warn(\"Custom widget wrapper onClick was just called. Handling for third party widgets is done via LGraphCanvas - the mouse callback.\")\n }\n}\n","import type { WidgetEventOptions } from \"./BaseWidget\"\nimport type { INumericWidget } from \"@/types/widgets\"\n\nimport { getWidgetStep } from \"@/utils/widget\"\n\nimport { BaseSteppedWidget } from \"./BaseSteppedWidget\"\n\nexport class NumberWidget extends BaseSteppedWidget<INumericWidget> implements INumericWidget {\n override type = \"number\" as const\n\n override get _displayValue() {\n if (this.computedDisabled) return \"\"\n return Number(this.value).toFixed(\n this.options.precision !== undefined\n ? this.options.precision\n : 3,\n )\n }\n\n override canIncrement(): boolean {\n const { max } = this.options\n return max == null || this.value < max\n }\n\n override canDecrement(): boolean {\n const { min } = this.options\n return min == null || this.value > min\n }\n\n override incrementValue(options: WidgetEventOptions): void {\n this.setValue(this.value + getWidgetStep(this.options), options)\n }\n\n override decrementValue(options: WidgetEventOptions): void {\n this.setValue(this.value - getWidgetStep(this.options), options)\n }\n\n override setValue(value: number, options: WidgetEventOptions) {\n let newValue = value\n if (this.options.min != null && newValue < this.options.min) {\n newValue = this.options.min\n }\n if (this.options.max != null && newValue > this.options.max) {\n newValue = this.options.max\n }\n super.setValue(newValue, options)\n }\n\n override onClick({ e, node, canvas }: WidgetEventOptions) {\n const x = e.canvasX - node.pos[0]\n const width = this.width || node.size[0]\n\n // Determine if clicked on left/right arrows\n const delta = x < 40\n ? -1\n : (x > width - 40\n ? 1\n : 0)\n\n if (delta) {\n // Handle left/right arrow clicks\n this.setValue(this.value + delta * getWidgetStep(this.options), { e, node, canvas })\n return\n }\n\n // Handle center click - show prompt\n canvas.prompt(\"Value\", this.value, (v: string) => {\n // Check if v is a valid equation or a number\n if (/^[\\d\\s()*+/-]+|\\d+\\.\\d+$/.test(v)) {\n // Solve the equation if possible\n try {\n v = eval(v)\n } catch {}\n }\n const newValue = Number(v)\n if (!isNaN(newValue)) {\n this.setValue(newValue, { e, node, canvas })\n }\n }, e)\n }\n\n /**\n * Handles drag events for the number widget\n * @param options The options for handling the drag event\n */\n override onDrag({ e, node, canvas }: WidgetEventOptions) {\n const width = this.width || node.width\n const x = e.canvasX - node.pos[0]\n const delta = x < 40\n ? -1\n : (x > width - 40\n ? 1\n : 0)\n\n if (delta && (x > -3 && x < width + 3)) return\n this.setValue(this.value + (e.deltaX ?? 0) * getWidgetStep(this.options), { e, node, canvas })\n }\n}\n","import type { ISliderWidget } from \"@/types/widgets\"\n\nimport { clamp } from \"@/litegraph\"\n\nimport { BaseWidget, type DrawWidgetOptions, type WidgetEventOptions } from \"./BaseWidget\"\n\nexport class SliderWidget extends BaseWidget<ISliderWidget> implements ISliderWidget {\n override type = \"slider\" as const\n\n marker?: number\n\n /**\n * Draws the widget\n * @param ctx The canvas context\n * @param options The options for drawing the widget\n */\n override drawWidget(ctx: CanvasRenderingContext2D, {\n width,\n showText = true,\n }: DrawWidgetOptions) {\n // Store original context attributes\n const { fillStyle, strokeStyle, textAlign } = ctx\n\n const { height, y } = this\n const { margin } = BaseWidget\n\n // Draw background\n ctx.fillStyle = this.background_color\n ctx.fillRect(margin, y, width - margin * 2, height)\n\n // Calculate normalized value\n const range = this.options.max - this.options.min\n let nvalue = (this.value - this.options.min) / range\n nvalue = clamp(nvalue, 0, 1)\n\n // Draw slider bar\n ctx.fillStyle = this.options.slider_color ?? \"#678\"\n ctx.fillRect(margin, y, nvalue * (width - margin * 2), height)\n\n // Draw outline if not disabled\n if (showText && !this.computedDisabled) {\n ctx.strokeStyle = this.outline_color\n ctx.strokeRect(margin, y, width - margin * 2, height)\n }\n\n // Draw marker if present\n if (this.marker != null) {\n let marker_nvalue = (this.marker - this.options.min) / range\n marker_nvalue = clamp(marker_nvalue, 0, 1)\n ctx.fillStyle = this.options.marker_color ?? \"#AA9\"\n ctx.fillRect(\n margin + marker_nvalue * (width - margin * 2),\n y,\n 2,\n height,\n )\n }\n\n // Draw text\n if (showText) {\n ctx.textAlign = \"center\"\n ctx.fillStyle = this.text_color\n const fixedValue = Number(this.value).toFixed(this.options.precision ?? 3)\n ctx.fillText(\n `${this.label || this.name} ${fixedValue}`,\n width * 0.5,\n y + height * 0.7,\n )\n }\n\n // Restore original context attributes\n Object.assign(ctx, { textAlign, strokeStyle, fillStyle })\n }\n\n /**\n * Handles click events for the slider widget\n */\n override onClick(options: WidgetEventOptions) {\n if (this.options.read_only) return\n\n const { e, node } = options\n const width = this.width || node.size[0]\n const x = e.canvasX - node.pos[0]\n\n // Calculate new value based on click position\n const slideFactor = clamp((x - 15) / (width - 30), 0, 1)\n const newValue = this.options.min + (this.options.max - this.options.min) * slideFactor\n\n if (newValue !== this.value) {\n this.setValue(newValue, options)\n }\n }\n\n /**\n * Handles drag events for the slider widget\n */\n override onDrag(options: WidgetEventOptions) {\n if (this.options.read_only) return false\n\n const { e, node } = options\n const width = this.width || node.size[0]\n const x = e.canvasX - node.pos[0]\n\n // Calculate new value based on drag position\n const slideFactor = clamp((x - 15) / (width - 30), 0, 1)\n const newValue = this.options.min + (this.options.max - this.options.min) * slideFactor\n\n if (newValue !== this.value) {\n this.setValue(newValue, options)\n }\n }\n}\n","import type { LGraphNode } from \"@/LGraphNode\"\nimport type { IStringWidget } from \"@/types/widgets\"\n\nimport { BaseWidget, type DrawWidgetOptions, type WidgetEventOptions } from \"./BaseWidget\"\n\nexport class TextWidget extends BaseWidget<IStringWidget> implements IStringWidget {\n constructor(widget: IStringWidget, node: LGraphNode) {\n super(widget, node)\n this.type ??= \"string\"\n this.value = widget.value?.toString() ?? \"\"\n }\n\n /**\n * Draws the widget\n * @param ctx The canvas context\n * @param options The options for drawing the widget\n */\n override drawWidget(ctx: CanvasRenderingContext2D, {\n width,\n showText = true,\n }: DrawWidgetOptions) {\n // Store original context attributes\n const { fillStyle, strokeStyle, textAlign } = ctx\n\n this.drawWidgetShape(ctx, { width, showText })\n\n if (showText) {\n this.drawTruncatingText({ ctx, width, leftPadding: 0, rightPadding: 0 })\n }\n\n // Restore original context attributes\n Object.assign(ctx, { textAlign, strokeStyle, fillStyle })\n }\n\n override onClick({ e, node, canvas }: WidgetEventOptions) {\n // Show prompt dialog for text input\n canvas.prompt(\n \"Value\",\n this.value,\n (v: string) => {\n if (v !== null) {\n this.setValue(v, { e, node, canvas })\n }\n },\n e,\n this.options?.multiline ?? false,\n )\n }\n}\n","import type { LGraphNode } from \"@/LGraphNode\"\nimport type {\n IBaseWidget,\n IBooleanWidget,\n IButtonWidget,\n IComboWidget,\n ICustomWidget,\n IKnobWidget,\n INumericWidget,\n ISliderWidget,\n IStringWidget,\n IWidget,\n TWidgetType,\n} from \"@/types/widgets\"\n\nimport { toClass } from \"@/utils/type\"\n\nimport { BaseWidget } from \"./BaseWidget\"\nimport { BooleanWidget } from \"./BooleanWidget\"\nimport { ButtonWidget } from \"./ButtonWidget\"\nimport { ComboWidget } from \"./ComboWidget\"\nimport { KnobWidget } from \"./KnobWidget\"\nimport { LegacyWidget } from \"./LegacyWidget\"\nimport { NumberWidget } from \"./NumberWidget\"\nimport { SliderWidget } from \"./SliderWidget\"\nimport { TextWidget } from \"./TextWidget\"\n\nexport type WidgetTypeMap = {\n button: ButtonWidget\n toggle: BooleanWidget\n slider: SliderWidget\n knob: KnobWidget\n combo: ComboWidget\n number: NumberWidget\n string: TextWidget\n text: TextWidget\n custom: LegacyWidget\n [key: string]: BaseWidget\n}\n\n/**\n * Convert a widget POJO to a proper widget instance.\n * @param widget The POJO to convert.\n * @param node The node the widget belongs to.\n * @param wrapLegacyWidgets Whether to wrap legacy widgets in a `LegacyWidget` instance.\n * @returns A concrete widget instance.\n */\nexport function toConcreteWidget<TWidget extends IWidget | IBaseWidget>(\n widget: TWidget,\n node: LGraphNode,\n wrapLegacyWidgets?: true,\n): WidgetTypeMap[TWidget[\"type\"]]\nexport function toConcreteWidget<TWidget extends IWidget | IBaseWidget>(\n widget: TWidget,\n node: LGraphNode,\n wrapLegacyWidgets: false): WidgetTypeMap[TWidget[\"type\"]] | undefined\nexport function toConcreteWidget<TWidget extends IWidget | IBaseWidget>(\n widget: TWidget,\n node: LGraphNode,\n wrapLegacyWidgets = true,\n): WidgetTypeMap[TWidget[\"type\"]] | undefined {\n if (widget instanceof BaseWidget) return widget\n\n // Assertion: TypeScript has no concept of \"all strings except X\"\n type RemoveBaseWidgetType<T> = T extends { type: TWidgetType } ? T : never\n const narrowedWidget = widget as RemoveBaseWidgetType<TWidget>\n\n switch (narrowedWidget.type) {\n case \"button\": return toClass(ButtonWidget, narrowedWidget, node)\n case \"toggle\": return toClass(BooleanWidget, narrowedWidget, node)\n case \"slider\": return toClass(SliderWidget, narrowedWidget, node)\n case \"knob\": return toClass(KnobWidget, narrowedWidget, node)\n case \"combo\": return toClass(ComboWidget, narrowedWidget, node)\n case \"number\": return toClass(NumberWidget, narrowedWidget, node)\n case \"string\": return toClass(TextWidget, narrowedWidget, node)\n case \"text\": return toClass(TextWidget, narrowedWidget, node)\n default: {\n if (wrapLegacyWidgets) return toClass(LegacyWidget, widget, node)\n }\n }\n}\n\n// #region Type Guards\n\n/** Type guard: Narrow **from {@link IBaseWidget}** to {@link IButtonWidget}. */\nexport function isButtonWidget(widget: IBaseWidget): widget is IButtonWidget {\n return widget.type === \"button\"\n}\n\n/** Type guard: Narrow **from {@link IBaseWidget}** to {@link IBooleanWidget}. */\nexport function isBooleanWidget(widget: IBaseWidget): widget is IBooleanWidget {\n return widget.type === \"toggle\"\n}\n\n/** Type guard: Narrow **from {@link IBaseWidget}** to {@link ISliderWidget}. */\nexport function isSliderWidget(widget: IBaseWidget): widget is ISliderWidget {\n return widget.type === \"slider\"\n}\n\n/** Type guard: Narrow **from {@link IBaseWidget}** to {@link IKnobWidget}. */\nexport function isKnobWidget(widget: IBaseWidget): widget is IKnobWidget {\n return widget.type === \"knob\"\n}\n\n/** Type guard: Narrow **from {@link IBaseWidget}** to {@link IComboWidget}. */\nexport function isComboWidget(widget: IBaseWidget): widget is IComboWidget {\n return widget.type === \"combo\"\n}\n\n/** Type guard: Narrow **from {@link IBaseWidget}** to {@link INumericWidget}. */\nexport function isNumberWidget(widget: IBaseWidget): widget is INumericWidget {\n return widget.type === \"number\"\n}\n\n/** Type guard: Narrow **from {@link IBaseWidget}** to {@link IStringWidget}. */\nexport function isStringWidget(widget: IBaseWidget): widget is IStringWidget {\n return widget.type === \"string\"\n}\n\n/** Type guard: Narrow **from {@link IBaseWidget}** to {@link ITextWidget}. */\nexport function isTextWidget(widget: IBaseWidget): widget is IStringWidget {\n return widget.type === \"text\"\n}\n\n/** Type guard: Narrow **from {@link IBaseWidget}** to {@link ICustomWidget}. */\nexport function isCustomWidget(widget: IBaseWidget): widget is ICustomWidget {\n return widget.type === \"custom\"\n}\n\n// #endregion Type Guards\n","import type { DragAndScale } from \"./DragAndScale\"\nimport type { IDrawBoundingOptions } from \"./draw\"\nimport type { ReadOnlyRectangle } from \"./infrastructure/Rectangle\"\nimport type {\n ColorOption,\n CompassCorners,\n DefaultConnectionColors,\n Dictionary,\n IColorable,\n IContextMenuValue,\n IFoundSlot,\n INodeFlags,\n INodeInputSlot,\n INodeOutputSlot,\n INodeSlot,\n INodeSlotContextItem,\n IPinnable,\n ISlotType,\n Point,\n Positionable,\n ReadOnlyPoint,\n ReadOnlyRect,\n Rect,\n Size,\n} from \"./interfaces\"\nimport type { LGraph } from \"./LGraph\"\nimport type { Reroute, RerouteId } from \"./Reroute\"\nimport type { SubgraphInputNode } from \"./subgraph/SubgraphInputNode\"\nimport type { SubgraphOutputNode } from \"./subgraph/SubgraphOutputNode\"\nimport type { CanvasPointerEvent } from \"./types/events\"\nimport type { NodeLike } from \"./types/NodeLike\"\nimport type { ISerialisedNode, SubgraphIO } from \"./types/serialisation\"\nimport type { IBaseWidget, IWidgetOptions, TWidgetType, TWidgetValue } from \"./types/widgets\"\n\nimport { getNodeInputOnPos, getNodeOutputOnPos } from \"./canvas/measureSlots\"\nimport { NullGraphError } from \"./infrastructure/NullGraphError\"\nimport { Rectangle } from \"./infrastructure/Rectangle\"\nimport { BadgePosition, LGraphBadge } from \"./LGraphBadge\"\nimport { LGraphButton, type LGraphButtonOptions } from \"./LGraphButton\"\nimport { LGraphCanvas } from \"./LGraphCanvas\"\nimport { type LGraphNodeConstructor, LiteGraph, type Subgraph, type SubgraphNode } from \"./litegraph\"\nimport { LLink } from \"./LLink\"\nimport { createBounds, isInRect, isInRectangle, isPointInRect, snapPoint } from \"./measure\"\nimport { NodeInputSlot } from \"./node/NodeInputSlot\"\nimport { NodeOutputSlot } from \"./node/NodeOutputSlot\"\nimport { inputAsSerialisable, isINodeInputSlot, isWidgetInputSlot, outputAsSerialisable } from \"./node/slotUtils\"\nimport {\n LGraphEventMode,\n NodeSlotType,\n RenderShape,\n TitleMode,\n} from \"./types/globalEnums\"\nimport { findFreeSlotOfType } from \"./utils/collections\"\nimport { warnDeprecated } from \"./utils/feedback\"\nimport { distributeSpace } from \"./utils/spaceDistribution\"\nimport { truncateText } from \"./utils/textUtils\"\nimport { toClass } from \"./utils/type\"\nimport { BaseWidget } from \"./widgets/BaseWidget\"\nimport { toConcreteWidget, type WidgetTypeMap } from \"./widgets/widgetMap\"\n\n// #region Types\n\nexport type NodeId = number | string\n\nexport type NodeProperty = string | number | boolean | object\n\nexport interface INodePropertyInfo {\n name: string\n type?: string\n default_value: NodeProperty | undefined\n}\n\nexport interface IMouseOverData {\n inputId?: number\n outputId?: number\n overWidget?: IBaseWidget\n}\n\nexport interface ConnectByTypeOptions {\n /** @deprecated Events */\n createEventInCase?: boolean\n /** Allow our wildcard slot to connect to typed slots on remote node. Default: true */\n wildcardToTyped?: boolean\n /** Allow our typed slot to connect to wildcard slots on remote node. Default: true */\n typedToWildcard?: boolean\n /** The {@link Reroute.id} that the connection is being dragged from. */\n afterRerouteId?: RerouteId\n}\n\n/** Internal type used for type safety when implementing generic checks for inputs & outputs */\nexport interface IGenericLinkOrLinks {\n links?: INodeOutputSlot[\"links\"]\n link?: INodeInputSlot[\"link\"]\n}\n\nexport interface FindFreeSlotOptions {\n /** Slots matching these types will be ignored. Default: [] */\n typesNotAccepted?: ISlotType[]\n /** If true, the slot itself is returned instead of the index. Default: false */\n returnObj?: boolean\n}\n\ninterface DrawSlotsOptions {\n fromSlot?: INodeInputSlot | INodeOutputSlot\n colorContext: DefaultConnectionColors\n editorAlpha: number\n lowQuality: boolean\n}\n\ninterface DrawWidgetsOptions {\n lowQuality?: boolean\n editorAlpha?: number\n}\n\ninterface DrawTitleOptions {\n scale: number\n title_height?: number\n low_quality?: boolean\n}\n\ninterface DrawTitleTextOptions extends DrawTitleOptions {\n default_title_color: string\n}\n\ninterface DrawTitleBoxOptions extends DrawTitleOptions {\n box_size?: number\n}\n\n/*\ntitle: string\npos: [x,y]\nsize: [x,y]\n\ninput|output: every connection\n + { name:string, type:string, pos: [x,y]=Optional, direction: \"input\"|\"output\", links: Array });\n\ngeneral properties:\n + clip_area: if you render outside the node, it will be clipped\n + unsafe_execution: not allowed for safe execution\n + skip_repeated_outputs: when adding new outputs, it wont show if there is one already connected\n + resizable: if set to false it wont be resizable with the mouse\n + widgets_start_y: widgets start at y distance from the top of the node\n\nflags object:\n + collapsed: if it is collapsed\n\nsupported callbacks:\n + onAdded: when added to graph (warning: this is called BEFORE the node is configured when loading)\n + onRemoved: when removed from graph\n + onStart: when the graph starts playing\n + onStop: when the graph stops playing\n + onDrawForeground: render the inside widgets inside the node\n + onDrawBackground: render the background area inside the node (only in edit mode)\n + onMouseDown\n + onMouseMove\n + onMouseUp\n + onMouseEnter\n + onMouseLeave\n + onExecute: execute the node\n + onPropertyChanged: when a property is changed in the panel (return true to skip default behaviour)\n + onGetInputs: returns an array of possible inputs\n + onGetOutputs: returns an array of possible outputs\n + onBounding: in case this node has a bigger bounding than the node itself (the callback receives the bounding as [x,y,w,h])\n + onDblClick: double clicked in the node\n + onNodeTitleDblClick: double clicked in the node title\n + onInputDblClick: input slot double clicked (can be used to automatically create a node connected)\n + onOutputDblClick: output slot double clicked (can be used to automatically create a node connected)\n + onConfigure: called after the node has been configured\n + onSerialize: to add extra info when serializing (the callback receives the object that should be filled with the data)\n + onSelected\n + onDeselected\n + onDropItem : DOM item dropped over the node\n + onDropFile : file dropped over the node\n + onConnectInput : if returns false the incoming connection will be canceled\n + onConnectionsChange : a connection changed (new one or removed) (NodeSlotType.INPUT or NodeSlotType.OUTPUT, slot, true if connected, link_info, input_info )\n + onAction: action slot triggered\n + getExtraMenuOptions: to add option to context menu\n*/\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport interface LGraphNode {\n constructor: LGraphNodeConstructor\n}\n\n// #endregion Types\n\n/**\n * Base class for all nodes\n * @param title a name for the node\n * @param type a type for the node\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class LGraphNode implements NodeLike, Positionable, IPinnable, IColorable {\n // Static properties used by dynamic child classes\n static title?: string\n static MAX_CONSOLE?: number\n static type?: string\n static category?: string\n static filter?: string\n static skip_list?: boolean\n\n static resizeHandleSize = 15\n static resizeEdgeSize = 5\n\n /** Default setting for {@link LGraphNode.connectInputToOutput}. @see {@link INodeFlags.keepAllLinksOnBypass} */\n static keepAllLinksOnBypass: boolean = false\n\n /** The title text of the node. */\n title: string\n /**\n * The font style used to render the node's title text.\n */\n get titleFontStyle(): string {\n return `${LiteGraph.NODE_TEXT_SIZE}px ${LiteGraph.NODE_FONT}`\n }\n\n get innerFontStyle(): string {\n return `normal ${LiteGraph.NODE_SUBTEXT_SIZE}px ${LiteGraph.NODE_FONT}`\n }\n\n get displayType(): string {\n return this.type\n }\n\n graph: LGraph | Subgraph | null = null\n id: NodeId\n type: string = \"\"\n inputs: INodeInputSlot[] = []\n outputs: INodeOutputSlot[] = []\n\n #concreteInputs: NodeInputSlot[] = []\n #concreteOutputs: NodeOutputSlot[] = []\n\n properties: Dictionary<NodeProperty | undefined> = {}\n properties_info: INodePropertyInfo[] = []\n flags: INodeFlags = {}\n widgets?: IBaseWidget[]\n /**\n * The amount of space available for widgets to grow into.\n * @see {@link layoutWidgets}\n */\n freeWidgetSpace?: number\n\n locked?: boolean\n\n /** Execution order, automatically computed during run @see {@link LGraph.computeExecutionOrder} */\n order: number = 0\n mode: LGraphEventMode = LGraphEventMode.ALWAYS\n last_serialization?: ISerialisedNode\n serialize_widgets?: boolean\n /**\n * The overridden fg color used to render the node.\n * @see {@link renderingColor}\n */\n color?: string\n /**\n * The overridden bg color used to render the node.\n * @see {@link renderingBgColor}\n */\n bgcolor?: string\n /**\n * The overridden box color used to render the node.\n * @see {@link renderingBoxColor}\n */\n boxcolor?: string\n\n /** The fg color used to render the node. */\n get renderingColor(): string {\n return this.color || this.constructor.color || LiteGraph.NODE_DEFAULT_COLOR\n }\n\n /** The bg color used to render the node. */\n get renderingBgColor(): string {\n return this.bgcolor || this.constructor.bgcolor || LiteGraph.NODE_DEFAULT_BGCOLOR\n }\n\n /** The box color used to render the node. */\n get renderingBoxColor(): string {\n if (this.boxcolor) return this.boxcolor\n\n if (LiteGraph.node_box_coloured_when_on) {\n if (this.action_triggered) return \"#FFF\"\n if (this.execute_triggered) return \"#AAA\"\n }\n\n if (LiteGraph.node_box_coloured_by_mode) {\n const modeColour = LiteGraph.NODE_MODES_COLORS[this.mode ?? LGraphEventMode.ALWAYS]\n if (modeColour) return modeColour\n }\n return LiteGraph.NODE_DEFAULT_BOXCOLOR\n }\n\n /** @inheritdoc {@link IColorable.setColorOption} */\n setColorOption(colorOption: ColorOption | null): void {\n if (colorOption == null) {\n delete this.color\n delete this.bgcolor\n } else {\n this.color = colorOption.color\n this.bgcolor = colorOption.bgcolor\n }\n }\n\n /** @inheritdoc {@link IColorable.getColorOption} */\n getColorOption(): ColorOption | null {\n return Object.values(LGraphCanvas.node_colors).find(\n colorOption =>\n colorOption.color === this.color && colorOption.bgcolor === this.bgcolor,\n ) ?? null\n }\n\n /**\n * The stroke styles that should be applied to the node.\n */\n strokeStyles: Record<string, (this: LGraphNode) => IDrawBoundingOptions | undefined>\n\n /**\n * The progress of node execution. Used to render a progress bar. Value between 0 and 1.\n */\n progress?: number\n\n exec_version?: number\n action_call?: string\n execute_triggered?: number\n action_triggered?: number\n widgets_up?: boolean\n widgets_start_y?: number\n lostFocusAt?: number\n gotFocusAt?: number\n badges: (LGraphBadge | (() => LGraphBadge))[] = []\n title_buttons: LGraphButton[] = []\n badgePosition: BadgePosition = BadgePosition.TopLeft\n onOutputRemoved?(this: LGraphNode, slot: number): void\n onInputRemoved?(this: LGraphNode, slot: number, input: INodeInputSlot): void\n /**\n * The width of the node when collapsed.\n * Updated by {@link LGraphCanvas.drawNode}\n */\n _collapsed_width?: number\n /**\n * Called once at the start of every frame. Caller may change the values in {@link out}, which will be reflected in {@link boundingRect}.\n * WARNING: Making changes to boundingRect via onBounding is poorly supported, and will likely result in strange behaviour.\n */\n onBounding?(this: LGraphNode, out: Rect): void\n console?: string[]\n _level?: number\n _shape?: RenderShape\n mouseOver?: IMouseOverData\n redraw_on_mouse?: boolean\n resizable?: boolean\n clonable?: boolean\n _relative_id?: number\n clip_area?: boolean\n ignore_remove?: boolean\n has_errors?: boolean\n removable?: boolean\n block_delete?: boolean\n selected?: boolean\n showAdvanced?: boolean\n\n declare comfyClass?: string\n declare isVirtualNode?: boolean\n applyToGraph?(extraLinks?: LLink[]): void\n\n isSubgraphNode(): this is SubgraphNode {\n return false\n }\n\n /** @inheritdoc {@link renderArea} */\n #renderArea: Float32Array = new Float32Array(4)\n /**\n * Rect describing the node area, including shadows and any protrusions.\n * Determines if the node is visible. Calculated once at the start of every frame.\n */\n get renderArea(): ReadOnlyRect {\n return this.#renderArea\n }\n\n /** @inheritdoc {@link boundingRect} */\n #boundingRect: Rectangle = new Rectangle()\n /**\n * Cached node position & area as `x, y, width, height`. Includes changes made by {@link onBounding}, if present.\n *\n * Determines the node hitbox and other rendering effects. Calculated once at the start of every frame.\n */\n get boundingRect(): ReadOnlyRectangle {\n return this.#boundingRect\n }\n\n /** The offset from {@link pos} to the top-left of {@link boundingRect}. */\n get boundingOffset(): ReadOnlyPoint {\n const { pos: [posX, posY], boundingRect: [bX, bY] } = this\n return [posX - bX, posY - bY]\n }\n\n /** {@link pos} and {@link size} values are backed by this {@link Rect}. */\n _posSize: Float32Array = new Float32Array(4)\n _pos: Point = this._posSize.subarray(0, 2)\n _size: Size = this._posSize.subarray(2, 4)\n\n public get pos() {\n return this._pos\n }\n\n /** Node position does not necessarily correlate to the top-left corner. */\n public set pos(value) {\n if (!value || value.length < 2) return\n\n this._pos[0] = value[0]\n this._pos[1] = value[1]\n }\n\n public get size() {\n return this._size\n }\n\n public set size(value) {\n if (!value || value.length < 2) return\n\n this._size[0] = value[0]\n this._size[1] = value[1]\n }\n\n /**\n * The size of the node used for rendering.\n */\n get renderingSize(): Size {\n return this.flags.collapsed ? [this._collapsed_width ?? 0, 0] : this._size\n }\n\n get shape(): RenderShape | undefined {\n return this._shape\n }\n\n set shape(v: RenderShape | \"default\" | \"box\" | \"round\" | \"circle\" | \"card\") {\n switch (v) {\n case \"default\":\n delete this._shape\n break\n case \"box\":\n this._shape = RenderShape.BOX\n break\n case \"round\":\n this._shape = RenderShape.ROUND\n break\n case \"circle\":\n this._shape = RenderShape.CIRCLE\n break\n case \"card\":\n this._shape = RenderShape.CARD\n break\n default:\n this._shape = v\n }\n }\n\n /**\n * The shape of the node used for rendering. @see {@link RenderShape}\n */\n get renderingShape(): RenderShape {\n return this._shape || this.constructor.shape || LiteGraph.NODE_DEFAULT_SHAPE\n }\n\n public get is_selected(): boolean | undefined {\n return this.selected\n }\n\n public set is_selected(value: boolean) {\n this.selected = value\n }\n\n public get title_mode(): TitleMode {\n return this.constructor.title_mode ?? TitleMode.NORMAL_TITLE\n }\n\n onConnectInput?(\n this: LGraphNode,\n target_slot: number,\n type: unknown,\n output: INodeOutputSlot | SubgraphIO,\n node: LGraphNode | SubgraphInputNode,\n slot: number,\n ): boolean\n onConnectOutput?(\n this: LGraphNode,\n slot: number,\n type: unknown,\n input: INodeInputSlot | SubgraphIO,\n target_node: number | LGraphNode | SubgraphOutputNode,\n target_slot: number,\n ): boolean\n onResize?(this: LGraphNode, size: Size): void\n onPropertyChanged?(\n this: LGraphNode,\n name: string,\n value: unknown,\n prev_value?: unknown,\n ): boolean\n /** Called for each connection that is created, updated, or removed. This includes \"restored\" connections when deserialising. */\n onConnectionsChange?(\n this: LGraphNode,\n type: ISlotType,\n index: number,\n isConnected: boolean,\n link_info: LLink | null | undefined,\n inputOrOutput: INodeInputSlot | INodeOutputSlot | SubgraphIO,\n ): void\n onInputAdded?(this: LGraphNode, input: INodeInputSlot): void\n onOutputAdded?(this: LGraphNode, output: INodeOutputSlot): void\n onConfigure?(this: LGraphNode, serialisedNode: ISerialisedNode): void\n onSerialize?(this: LGraphNode, serialised: ISerialisedNode): any\n onExecute?(\n this: LGraphNode,\n param?: unknown,\n options?: { action_call?: any },\n ): void\n onAction?(\n this: LGraphNode,\n action: string,\n param: unknown,\n options: { action_call?: string },\n ): void\n onDrawBackground?(\n this: LGraphNode,\n ctx: CanvasRenderingContext2D,\n ): void\n onNodeCreated?(this: LGraphNode): void\n /**\n * Callback invoked by {@link connect} to override the target slot index.\n * Its return value overrides the target index selection.\n * @param target_slot The current input slot index\n * @param requested_slot The originally requested slot index - could be negative, or if using (deprecated) name search, a string\n * @returns {number | null} If a number is returned, the connection will be made to that input index.\n * If an invalid index or non-number (false, null, NaN etc) is returned, the connection will be cancelled.\n */\n onBeforeConnectInput?(\n this: LGraphNode,\n target_slot: number,\n requested_slot?: number | string,\n ): number | false | null\n onShowCustomPanelInfo?(this: LGraphNode, panel: any): void\n onAddPropertyToPanel?(this: LGraphNode, pName: string, panel: any): boolean\n onWidgetChanged?(\n this: LGraphNode,\n name: string,\n value: unknown,\n old_value: unknown,\n w: IBaseWidget,\n ): void\n onDeselected?(this: LGraphNode): void\n onKeyUp?(this: LGraphNode, e: KeyboardEvent): void\n onKeyDown?(this: LGraphNode, e: KeyboardEvent): void\n onSelected?(this: LGraphNode): void\n getExtraMenuOptions?(\n this: LGraphNode,\n canvas: LGraphCanvas,\n options: (IContextMenuValue<unknown> | null)[],\n ): (IContextMenuValue<unknown> | null)[]\n getMenuOptions?(this: LGraphNode, canvas: LGraphCanvas): IContextMenuValue[]\n onAdded?(this: LGraphNode, graph: LGraph): void\n onDrawCollapsed?(\n this: LGraphNode,\n ctx: CanvasRenderingContext2D,\n cavnas: LGraphCanvas,\n ): boolean\n onDrawForeground?(\n this: LGraphNode,\n ctx: CanvasRenderingContext2D,\n canvas: LGraphCanvas,\n canvasElement: HTMLCanvasElement,\n ): void\n onMouseLeave?(this: LGraphNode, e: CanvasPointerEvent): void\n /**\n * Override the default slot menu options.\n */\n getSlotMenuOptions?(this: LGraphNode, slot: IFoundSlot): IContextMenuValue[]\n /**\n * Add extra menu options to the slot context menu.\n */\n getExtraSlotMenuOptions?(this: LGraphNode, slot: IFoundSlot): IContextMenuValue[]\n\n // FIXME: Re-typing\n onDropItem?(this: LGraphNode, event: Event): boolean\n onDropData?(\n this: LGraphNode,\n data: string | ArrayBuffer,\n filename: any,\n file: any,\n ): void\n onDropFile?(this: LGraphNode, file: any): void\n onInputClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void\n onInputDblClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void\n onOutputClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void\n onOutputDblClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void\n // TODO: Return type\n onGetPropertyInfo?(this: LGraphNode, property: string): any\n onNodeOutputAdd?(this: LGraphNode, value: unknown): void\n onNodeInputAdd?(this: LGraphNode, value: unknown): void\n onMenuNodeInputs?(\n this: LGraphNode,\n entries: (IContextMenuValue<INodeSlotContextItem> | null)[],\n ): (IContextMenuValue<INodeSlotContextItem> | null)[]\n onMenuNodeOutputs?(\n this: LGraphNode,\n entries: (IContextMenuValue<INodeSlotContextItem> | null)[],\n ): (IContextMenuValue<INodeSlotContextItem> | null)[]\n onMouseUp?(this: LGraphNode, e: CanvasPointerEvent, pos: Point): void\n onMouseEnter?(this: LGraphNode, e: CanvasPointerEvent): void\n /** Blocks drag if return value is truthy. @param pos Offset from {@link LGraphNode.pos}. */\n onMouseDown?(\n this: LGraphNode,\n e: CanvasPointerEvent,\n pos: Point,\n canvas: LGraphCanvas,\n ): boolean\n /** @param pos Offset from {@link LGraphNode.pos}. */\n onDblClick?(\n this: LGraphNode,\n e: CanvasPointerEvent,\n pos: Point,\n canvas: LGraphCanvas,\n ): void\n /** @param pos Offset from {@link LGraphNode.pos}. */\n onNodeTitleDblClick?(\n this: LGraphNode,\n e: CanvasPointerEvent,\n pos: Point,\n canvas: LGraphCanvas,\n ): void\n onDrawTitle?(this: LGraphNode, ctx: CanvasRenderingContext2D): void\n onDrawTitleText?(\n this: LGraphNode,\n ctx: CanvasRenderingContext2D,\n title_height: number,\n size: Size,\n scale: number,\n title_text_font: string,\n selected?: boolean,\n ): void\n onDrawTitleBox?(\n this: LGraphNode,\n ctx: CanvasRenderingContext2D,\n title_height: number,\n size: Size,\n scale: number,\n ): void\n onDrawTitleBar?(\n this: LGraphNode,\n ctx: CanvasRenderingContext2D,\n title_height: number,\n size: Size,\n scale: number,\n fgcolor: any,\n ): void\n onRemoved?(this: LGraphNode): void\n onMouseMove?(\n this: LGraphNode,\n e: CanvasPointerEvent,\n pos: Point,\n arg2: LGraphCanvas,\n ): void\n onPropertyChange?(this: LGraphNode): void\n updateOutputData?(this: LGraphNode, origin_slot: number): void\n\n #getErrorStrokeStyle(this: LGraphNode): IDrawBoundingOptions | undefined {\n if (this.has_errors) {\n return {\n padding: 12,\n lineWidth: 10,\n color: LiteGraph.NODE_ERROR_COLOUR,\n }\n }\n }\n\n #getSelectedStrokeStyle(this: LGraphNode): IDrawBoundingOptions | undefined {\n if (this.selected) {\n return {\n padding: this.has_errors ? 20 : undefined,\n }\n }\n }\n\n constructor(title: string, type?: string) {\n this.id = LiteGraph.use_uuids ? LiteGraph.uuidv4() : -1\n this.title = title || \"Unnamed\"\n this.type = type ?? \"\"\n this.size = [LiteGraph.NODE_WIDTH, 60]\n this.pos = [10, 10]\n this.strokeStyles = {\n error: this.#getErrorStrokeStyle,\n selected: this.#getSelectedStrokeStyle,\n }\n\n // Assign onMouseDown implementation\n this.onMouseDown = (e: CanvasPointerEvent, pos: Point, canvas: LGraphCanvas): boolean => {\n // Check for title button clicks (only if not collapsed)\n if (this.title_buttons?.length && !this.flags.collapsed) {\n // pos contains the offset from the node's position, so we need to use node-relative coordinates\n const nodeRelativeX = pos[0]\n const nodeRelativeY = pos[1]\n\n for (let i = 0; i < this.title_buttons.length; i++) {\n const button = this.title_buttons[i]\n if (button.visible && button.isPointInside(nodeRelativeX, nodeRelativeY)) {\n this.onTitleButtonClick(button, canvas)\n return true // Prevent default behavior\n }\n }\n }\n\n return false // Allow default behavior\n }\n }\n\n /** Internal callback for subgraph nodes. Do not implement externally. */\n _internalConfigureAfterSlots?(): void\n\n /**\n * configure a node from an object containing the serialized info\n */\n configure(info: ISerialisedNode): void {\n if (this.graph) {\n this.graph._version++\n }\n for (const j in info) {\n if (j == \"properties\") {\n // i don't want to clone properties, I want to reuse the old container\n for (const k in info.properties) {\n this.properties[k] = info.properties[k]\n this.onPropertyChanged?.(k, info.properties[k])\n }\n continue\n }\n\n // @ts-expect-error #594\n if (info[j] == null) {\n continue\n // @ts-expect-error #594\n } else if (typeof info[j] == \"object\") {\n // @ts-expect-error #594\n if (this[j]?.configure) {\n // @ts-expect-error #594\n this[j]?.configure(info[j])\n } else {\n // @ts-expect-error #594\n this[j] = LiteGraph.cloneObject(info[j], this[j])\n }\n } else {\n // value\n // @ts-expect-error #594\n this[j] = info[j]\n }\n }\n\n if (!info.title) {\n this.title = this.constructor.title\n }\n\n this.inputs ??= []\n this.inputs = this.inputs.map(input => toClass(NodeInputSlot, input, this))\n for (const [i, input] of this.inputs.entries()) {\n const link = this.graph && input.link != null\n ? this.graph._links.get(input.link)\n : null\n this.onConnectionsChange?.(NodeSlotType.INPUT, i, true, link, input)\n this.onInputAdded?.(input)\n }\n\n this.outputs ??= []\n this.outputs = this.outputs.map(output => toClass(NodeOutputSlot, output, this))\n for (const [i, output] of this.outputs.entries()) {\n if (!output.links) continue\n\n for (const linkId of output.links) {\n const link = this.graph\n ? this.graph._links.get(linkId)\n : null\n this.onConnectionsChange?.(NodeSlotType.OUTPUT, i, true, link, output)\n }\n this.onOutputAdded?.(output)\n }\n\n // SubgraphNode callback.\n this._internalConfigureAfterSlots?.()\n\n if (this.widgets) {\n for (const w of this.widgets) {\n if (!w) continue\n\n if (w.options?.property && this.properties[w.options.property] != undefined)\n w.value = JSON.parse(JSON.stringify(this.properties[w.options.property]))\n }\n\n if (info.widgets_values) {\n const widgetsWithValue = this.widgets.filter(w => w.serialize !== false)\n for (let i = 0; i < info.widgets_values.length; ++i) {\n const widget = widgetsWithValue[i]\n if (widget) {\n widget.value = info.widgets_values[i]\n }\n }\n }\n }\n\n // Sync the state of this.resizable.\n if (this.pinned) this.resizable = false\n\n this.onConfigure?.(info)\n }\n\n /**\n * serialize the content\n */\n serialize(): ISerialisedNode {\n // create serialization object\n const o: ISerialisedNode = {\n id: this.id,\n type: this.type,\n pos: [this.pos[0], this.pos[1]],\n size: [this.size[0], this.size[1]],\n flags: LiteGraph.cloneObject(this.flags),\n order: this.order,\n mode: this.mode,\n showAdvanced: this.showAdvanced,\n }\n\n // special case for when there were errors\n if (this.constructor === LGraphNode && this.last_serialization)\n return this.last_serialization\n\n if (this.inputs) o.inputs = this.inputs.map(input => inputAsSerialisable(input))\n if (this.outputs) o.outputs = this.outputs.map(output => outputAsSerialisable(output))\n\n if (this.title && this.title != this.constructor.title) o.title = this.title\n\n if (this.properties) o.properties = LiteGraph.cloneObject(this.properties)\n\n const { widgets } = this\n if (widgets && this.serialize_widgets) {\n o.widgets_values = []\n for (const [i, widget] of widgets.entries()) {\n if (widget.serialize === false) continue\n // @ts-expect-error #595 No-null\n o.widgets_values[i] = widget ? widget.value : null\n }\n }\n\n if (!o.type) o.type = this.constructor.type\n\n if (this.color) o.color = this.color\n if (this.bgcolor) o.bgcolor = this.bgcolor\n if (this.boxcolor) o.boxcolor = this.boxcolor\n if (this.shape) o.shape = this.shape\n\n if (this.onSerialize?.(o)) console.warn(\"node onSerialize shouldnt return anything, data should be stored in the object pass in the first parameter\")\n\n return o\n }\n\n /* Creates a clone of this node */\n clone(): LGraphNode | null {\n if (this.type == null) return null\n const node = LiteGraph.createNode(this.type)\n if (!node) return null\n\n // we clone it because serialize returns shared containers\n const data = LiteGraph.cloneObject(this.serialize())\n const { inputs, outputs } = data\n\n // remove links\n if (inputs) {\n for (const input of inputs) {\n input.link = null\n }\n }\n\n if (outputs) {\n for (const { links } of outputs) {\n if (links) links.length = 0\n }\n }\n\n // @ts-expect-error Exceptional case: id is removed so that the graph can assign a new one on add.\n delete data.id\n\n if (LiteGraph.use_uuids) data.id = LiteGraph.uuidv4()\n\n node.configure(data)\n\n return node\n }\n\n /**\n * serialize and stringify\n */\n toString(): string {\n return JSON.stringify(this.serialize())\n }\n\n /**\n * get the title string\n */\n getTitle(): string {\n return this.title || this.constructor.title\n }\n\n /**\n * sets the value of a property\n * @param name\n * @param value\n */\n setProperty(name: string, value: TWidgetValue): void {\n this.properties ||= {}\n if (value === this.properties[name]) return\n\n const prev_value = this.properties[name]\n this.properties[name] = value\n // abort change\n if (this.onPropertyChanged?.(name, value, prev_value) === false)\n this.properties[name] = prev_value\n\n if (this.widgets) {\n for (const w of this.widgets) {\n if (!w) continue\n\n if (w.options.property == name) {\n w.value = value\n break\n }\n }\n }\n }\n\n /**\n * sets the output data\n * @param slot\n * @param data\n */\n setOutputData(slot: number, data: number | string | boolean | { toToolTip?(): string }): void {\n const { outputs } = this\n if (!outputs) return\n\n // this maybe slow and a niche case\n if (slot == -1 || slot >= outputs.length) return\n\n const output_info = outputs[slot]\n if (!output_info) return\n\n // store data in the output itself in case we want to debug\n output_info._data = data\n\n if (!this.graph) throw new NullGraphError()\n\n // if there are connections, pass the data to the connections\n const { links } = outputs[slot]\n if (links) {\n for (const id of links) {\n const link = this.graph._links.get(id)\n if (link) link.data = data\n }\n }\n }\n\n /**\n * sets the output data type, useful when you want to be able to overwrite the data type\n */\n setOutputDataType(slot: number, type: ISlotType): void {\n const { outputs } = this\n if (!outputs || (slot == -1 || slot >= outputs.length)) return\n\n const output_info = outputs[slot]\n if (!output_info) return\n // store data in the output itself in case we want to debug\n output_info.type = type\n\n if (!this.graph) throw new NullGraphError()\n\n // if there are connections, pass the data to the connections\n const { links } = outputs[slot]\n if (links) {\n for (const id of links) {\n const link = this.graph._links.get(id)\n if (link) link.type = type\n }\n }\n }\n\n /**\n * Retrieves the input data (data traveling through the connection) from one slot\n * @param slot\n * @param force_update if set to true it will force the connected node of this slot to output data into this link\n * @returns data or if it is not connected returns undefined\n */\n getInputData(slot: number, force_update?: boolean): unknown {\n if (!this.inputs) return\n\n if (slot >= this.inputs.length || this.inputs[slot].link == null) return\n if (!this.graph) throw new NullGraphError()\n\n const link_id = this.inputs[slot].link\n const link = this.graph._links.get(link_id)\n // bug: weird case but it happens sometimes\n if (!link) return null\n\n if (!force_update) return link.data\n\n // special case: used to extract data from the incoming connection before the graph has been executed\n const node = this.graph.getNodeById(link.origin_id)\n if (!node) return link.data\n\n if (node.updateOutputData) {\n node.updateOutputData(link.origin_slot)\n } else {\n node.onExecute?.()\n }\n\n return link.data\n }\n\n /**\n * Retrieves the input data type (in case this supports multiple input types)\n * @param slot\n * @returns datatype in string format\n */\n getInputDataType(slot: number): ISlotType | null {\n if (!this.inputs) return null\n if (slot >= this.inputs.length || this.inputs[slot].link == null) return null\n if (!this.graph) throw new NullGraphError()\n\n const link_id = this.inputs[slot].link\n const link = this.graph._links.get(link_id)\n // bug: weird case but it happens sometimes\n if (!link) return null\n\n const node = this.graph.getNodeById(link.origin_id)\n if (!node) return link.type\n\n const output_info = node.outputs[link.origin_slot]\n return output_info\n ? output_info.type\n : null\n }\n\n /**\n * Retrieves the input data from one slot using its name instead of slot number\n * @param slot_name\n * @param force_update if set to true it will force the connected node of this slot to output data into this link\n * @returns data or if it is not connected returns null\n */\n getInputDataByName(slot_name: string, force_update: boolean): unknown {\n const slot = this.findInputSlot(slot_name)\n return slot == -1\n ? null\n : this.getInputData(slot, force_update)\n }\n\n /**\n * tells you if there is a connection in one input slot\n * @param slot The 0-based index of the input to check\n * @returns `true` if the input slot has a link ID (does not perform validation)\n */\n isInputConnected(slot: number): boolean {\n if (!this.inputs) return false\n return slot < this.inputs.length && this.inputs[slot].link != null\n }\n\n /**\n * tells you info about an input connection (which node, type, etc)\n * @returns object or null { link: id, name: string, type: string or 0 }\n */\n getInputInfo(slot: number): INodeInputSlot | null {\n return !this.inputs || !(slot < this.inputs.length)\n ? null\n : this.inputs[slot]\n }\n\n /**\n * Returns the link info in the connection of an input slot\n * @returns object or null\n */\n getInputLink(slot: number): LLink | null {\n if (!this.inputs) return null\n\n if (slot < this.inputs.length) {\n if (!this.graph) throw new NullGraphError()\n\n const input = this.inputs[slot]\n if (input.link != null) {\n return this.graph._links.get(input.link) ?? null\n }\n }\n return null\n }\n\n /**\n * returns the node connected in the input slot\n * @returns node or null\n */\n getInputNode(slot: number): LGraphNode | null {\n if (!this.inputs) return null\n if (slot >= this.inputs.length) return null\n\n const input = this.inputs[slot]\n if (!input || input.link === null) return null\n if (!this.graph) throw new NullGraphError()\n\n const link_info = this.graph._links.get(input.link)\n if (!link_info) return null\n\n return this.graph.getNodeById(link_info.origin_id)\n }\n\n /**\n * returns the value of an input with this name, otherwise checks if there is a property with that name\n * @returns value\n */\n getInputOrProperty(name: string): unknown {\n const { inputs } = this\n if (!inputs?.length) {\n return this.properties ? this.properties[name] : null\n }\n if (!this.graph) throw new NullGraphError()\n\n for (const input of inputs) {\n if (name == input.name && input.link != null) {\n const link = this.graph._links.get(input.link)\n if (link) return link.data\n }\n }\n return this.properties[name]\n }\n\n /**\n * tells you the last output data that went in that slot\n * @returns object or null\n */\n getOutputData(slot: number): unknown {\n if (!this.outputs) return null\n if (slot >= this.outputs.length) return null\n\n const info = this.outputs[slot]\n return info._data\n }\n\n /**\n * tells you info about an output connection (which node, type, etc)\n * @returns object or null { name: string, type: string, links: [ ids of links in number ] }\n */\n getOutputInfo(slot: number): INodeOutputSlot | null {\n return !this.outputs || !(slot < this.outputs.length)\n ? null\n : this.outputs[slot]\n }\n\n /**\n * tells you if there is a connection in one output slot\n */\n isOutputConnected(slot: number): boolean {\n if (!this.outputs) return false\n return slot < this.outputs.length && Number(this.outputs[slot].links?.length) > 0\n }\n\n /**\n * tells you if there is any connection in the output slots\n */\n isAnyOutputConnected(): boolean {\n const { outputs } = this\n if (!outputs) return false\n\n for (const output of outputs) {\n if (output.links?.length) return true\n }\n return false\n }\n\n /**\n * retrieves all the nodes connected to this output slot\n */\n getOutputNodes(slot: number): LGraphNode[] | null {\n const { outputs } = this\n if (!outputs || outputs.length == 0) return null\n\n if (slot >= outputs.length) return null\n\n const { links } = outputs[slot]\n if (!links || links.length == 0) return null\n if (!this.graph) throw new NullGraphError()\n\n const r: LGraphNode[] = []\n for (const id of links) {\n const link = this.graph._links.get(id)\n if (link) {\n const target_node = this.graph.getNodeById(link.target_id)\n if (target_node) {\n r.push(target_node)\n }\n }\n }\n return r\n }\n\n addOnTriggerInput(): number {\n const trigS = this.findInputSlot(\"onTrigger\")\n if (trigS == -1) {\n this.addInput(\"onTrigger\", LiteGraph.EVENT, {\n nameLocked: true,\n })\n return this.findInputSlot(\"onTrigger\")\n }\n return trigS\n }\n\n addOnExecutedOutput(): number {\n const trigS = this.findOutputSlot(\"onExecuted\")\n if (trigS == -1) {\n this.addOutput(\"onExecuted\", LiteGraph.ACTION, {\n nameLocked: true,\n })\n return this.findOutputSlot(\"onExecuted\")\n }\n return trigS\n }\n\n onAfterExecuteNode(param: unknown, options?: { action_call?: any }) {\n const trigS = this.findOutputSlot(\"onExecuted\")\n if (trigS != -1) {\n this.triggerSlot(trigS, param, null, options)\n }\n }\n\n changeMode(modeTo: number): boolean {\n switch (modeTo) {\n case LGraphEventMode.ON_EVENT:\n break\n\n case LGraphEventMode.ON_TRIGGER:\n this.addOnTriggerInput()\n this.addOnExecutedOutput()\n break\n\n case LGraphEventMode.NEVER:\n break\n\n case LGraphEventMode.ALWAYS:\n break\n\n // @ts-expect-error Not impl.\n case LiteGraph.ON_REQUEST:\n break\n\n default:\n return false\n break\n }\n this.mode = modeTo\n return true\n }\n\n /**\n * Triggers the node code execution, place a boolean/counter to mark the node as being executed\n */\n doExecute(param?: unknown, options?: { action_call?: any }): void {\n options = options || {}\n if (this.onExecute) {\n // enable this to give the event an ID\n options.action_call ||= `${this.id}_exec_${Math.floor(Math.random() * 9999)}`\n if (!this.graph) throw new NullGraphError()\n\n // @ts-expect-error Technically it works when id is a string. Array gets props.\n this.graph.nodes_executing[this.id] = true\n this.onExecute(param, options)\n // @ts-expect-error deprecated\n this.graph.nodes_executing[this.id] = false\n\n // save execution/action ref\n this.exec_version = this.graph.iteration\n if (options?.action_call) {\n this.action_call = options.action_call\n // @ts-expect-error deprecated\n this.graph.nodes_executedAction[this.id] = options.action_call\n }\n }\n // the nFrames it will be used (-- each step), means \"how old\" is the event\n this.execute_triggered = 2\n this.onAfterExecuteNode?.(param, options)\n }\n\n /**\n * Triggers an action, wrapped by logics to control execution flow\n * @param action name\n */\n actionDo(\n action: string,\n param: unknown,\n options: { action_call?: string },\n ): void {\n options = options || {}\n if (this.onAction) {\n // enable this to give the event an ID\n options.action_call ||= `${this.id}_${action || \"action\"}_${Math.floor(Math.random() * 9999)}`\n if (!this.graph) throw new NullGraphError()\n\n // @ts-expect-error deprecated\n this.graph.nodes_actioning[this.id] = action || \"actioning\"\n this.onAction(action, param, options)\n // @ts-expect-error deprecated\n this.graph.nodes_actioning[this.id] = false\n\n // save execution/action ref\n if (options?.action_call) {\n this.action_call = options.action_call\n // @ts-expect-error deprecated\n this.graph.nodes_executedAction[this.id] = options.action_call\n }\n }\n // the nFrames it will be used (-- each step), means \"how old\" is the event\n this.action_triggered = 2\n this.onAfterExecuteNode?.(param, options)\n }\n\n /**\n * Triggers an event in this node, this will trigger any output with the same name\n * @param action name ( \"on_play\", ... ) if action is equivalent to false then the event is send to all\n */\n trigger(\n action: string,\n param: unknown,\n options: { action_call?: any },\n ): void {\n const { outputs } = this\n if (!outputs || !outputs.length) {\n return\n }\n\n if (this.graph) this.graph._last_trigger_time = LiteGraph.getTime()\n\n for (const [i, output] of outputs.entries()) {\n if (\n !output ||\n output.type !== LiteGraph.EVENT ||\n (action && output.name != action)\n ) {\n continue\n }\n this.triggerSlot(i, param, null, options)\n }\n }\n\n /**\n * Triggers a slot event in this node: cycle output slots and launch execute/action on connected nodes\n * @param slot the index of the output slot\n * @param link_id [optional] in case you want to trigger and specific output link in a slot\n */\n triggerSlot(\n slot: number,\n param: unknown,\n link_id: number | null,\n options?: { action_call?: any },\n ): void {\n options = options || {}\n if (!this.outputs) return\n\n if (slot == null) {\n console.error(\"slot must be a number\")\n return\n }\n\n if (typeof slot !== \"number\")\n console.warn(\"slot must be a number, use node.trigger('name') if you want to use a string\")\n\n const output = this.outputs[slot]\n if (!output) return\n\n const links = output.links\n if (!links || !links.length) return\n\n if (!this.graph) throw new NullGraphError()\n this.graph._last_trigger_time = LiteGraph.getTime()\n\n // for every link attached here\n for (const id of links) {\n // to skip links\n if (link_id != null && link_id != id) continue\n\n const link_info = this.graph._links.get(id)\n // not connected\n if (!link_info) continue\n\n link_info._last_time = LiteGraph.getTime()\n const node = this.graph.getNodeById(link_info.target_id)\n // node not found?\n if (!node) continue\n\n if (node.mode === LGraphEventMode.ON_TRIGGER) {\n // generate unique trigger ID if not present\n if (!options.action_call)\n options.action_call = `${this.id}_trigg_${Math.floor(Math.random() * 9999)}`\n // -- wrapping node.onExecute(param); --\n node.doExecute?.(param, options)\n } else if (node.onAction) {\n // generate unique action ID if not present\n if (!options.action_call)\n options.action_call = `${this.id}_act_${Math.floor(Math.random() * 9999)}`\n // pass the action name\n const target_connection = node.inputs[link_info.target_slot]\n node.actionDo(target_connection.name, param, options)\n }\n }\n }\n\n /**\n * clears the trigger slot animation\n * @param slot the index of the output slot\n * @param link_id [optional] in case you want to trigger and specific output link in a slot\n */\n clearTriggeredSlot(slot: number, link_id: number): void {\n if (!this.outputs) return\n\n const output = this.outputs[slot]\n if (!output) return\n\n const links = output.links\n if (!links || !links.length) return\n\n if (!this.graph) throw new NullGraphError()\n\n // for every link attached here\n for (const id of links) {\n // to skip links\n if (link_id != null && link_id != id) continue\n\n const link_info = this.graph._links.get(id)\n // not connected\n if (!link_info) continue\n\n link_info._last_time = 0\n }\n }\n\n /**\n * changes node size and triggers callback\n */\n setSize(size: Size): void {\n this.size = size\n this.onResize?.(this.size)\n }\n\n /**\n * Expands the node size to fit its content.\n */\n expandToFitContent(): void {\n const newSize = this.computeSize()\n this.setSize([\n Math.max(this.size[0], newSize[0]),\n Math.max(this.size[1], newSize[1]),\n ])\n }\n\n /**\n * add a new property to this node\n * @param type string defining the output type (\"vec3\",\"number\",...)\n * @param extra_info this can be used to have special properties of the property (like values, etc)\n */\n addProperty(\n name: string,\n default_value: NodeProperty | undefined,\n type?: string,\n extra_info?: Partial<INodePropertyInfo>,\n ): INodePropertyInfo {\n const o: INodePropertyInfo = { name, type, default_value }\n if (extra_info) Object.assign(o, extra_info)\n\n this.properties_info ||= []\n this.properties_info.push(o)\n this.properties ||= {}\n this.properties[name] = default_value\n return o\n }\n\n /**\n * add a new output slot to use in this node\n * @param type string defining the output type (\"vec3\",\"number\",...)\n * @param extra_info this can be used to have special properties of an output (label, special color, position, etc)\n */\n addOutput<TProperties extends Partial<INodeOutputSlot>>(\n name: string,\n type: ISlotType,\n extra_info?: TProperties,\n ): INodeOutputSlot & TProperties {\n const output = Object.assign(\n new NodeOutputSlot({ name, type, links: null }, this),\n extra_info,\n )\n\n this.outputs ||= []\n this.outputs.push(output)\n this.onOutputAdded?.(output)\n\n if (LiteGraph.auto_load_slot_types)\n LiteGraph.registerNodeAndSlotType(this, type, true)\n\n this.expandToFitContent()\n this.setDirtyCanvas(true, true)\n return output\n }\n\n /**\n * remove an existing output slot\n */\n removeOutput(slot: number): void {\n this.disconnectOutput(slot)\n const { outputs } = this\n outputs.splice(slot, 1)\n\n for (let i = slot; i < outputs.length; ++i) {\n const output = outputs[i]\n if (!output || !output.links) continue\n\n for (const linkId of output.links) {\n if (!this.graph) throw new NullGraphError()\n\n const link = this.graph._links.get(linkId)\n if (link) link.origin_slot--\n }\n }\n\n this.onOutputRemoved?.(slot)\n this.setDirtyCanvas(true, true)\n }\n\n /**\n * add a new input slot to use in this node\n * @param type string defining the input type (\"vec3\",\"number\",...), it its a generic one use 0\n * @param extra_info this can be used to have special properties of an input (label, color, position, etc)\n */\n addInput<TProperties extends Partial<INodeInputSlot>>(name: string, type: ISlotType, extra_info?: TProperties): INodeInputSlot & TProperties {\n type ||= 0\n\n const input = Object.assign(\n new NodeInputSlot({ name, type, link: null }, this),\n extra_info,\n )\n\n this.inputs ||= []\n this.inputs.push(input)\n this.expandToFitContent()\n\n this.onInputAdded?.(input)\n LiteGraph.registerNodeAndSlotType(this, type)\n\n this.setDirtyCanvas(true, true)\n return input\n }\n\n /**\n * remove an existing input slot\n */\n removeInput(slot: number): void {\n this.disconnectInput(slot, true)\n const { inputs } = this\n const slot_info = inputs.splice(slot, 1)\n\n for (let i = slot; i < inputs.length; ++i) {\n const input = inputs[i]\n if (!input?.link) continue\n\n if (!this.graph) throw new NullGraphError()\n const link = this.graph._links.get(input.link)\n if (link) link.target_slot--\n }\n this.onInputRemoved?.(slot, slot_info[0])\n this.setDirtyCanvas(true, true)\n }\n\n /**\n * computes the minimum size of a node according to its inputs and output slots\n * @returns the total size\n */\n computeSize(out?: Size): Size {\n const ctorSize = this.constructor.size\n if (ctorSize) return [ctorSize[0], ctorSize[1]]\n\n const { inputs, outputs, widgets } = this\n let rows = Math.max(\n inputs ? inputs.filter(input => !isWidgetInputSlot(input)).length : 1,\n outputs ? outputs.length : 1,\n )\n const size = out || new Float32Array([0, 0])\n rows = Math.max(rows, 1)\n // although it should be graphcanvas.inner_text_font size\n const font_size = LiteGraph.NODE_TEXT_SIZE\n\n const padLeft = LiteGraph.NODE_TITLE_HEIGHT\n const padRight = padLeft * 0.33\n const title_width = padLeft + compute_text_size(this.title, this.titleFontStyle) + padRight\n let input_width = 0\n let widgetWidth = 0\n let output_width = 0\n\n if (inputs) {\n for (const input of inputs) {\n const text = input.label || input.localized_name || input.name || \"\"\n const text_width = compute_text_size(text, this.innerFontStyle)\n if (isWidgetInputSlot(input)) {\n const widget = this.getWidgetFromSlot(input)\n if (widget && !this.isWidgetVisible(widget)) continue\n\n if (text_width > widgetWidth) widgetWidth = text_width\n } else {\n if (text_width > input_width) input_width = text_width\n }\n }\n }\n\n if (outputs) {\n for (const output of outputs) {\n const text = output.label || output.localized_name || output.name || \"\"\n const text_width = compute_text_size(text, this.innerFontStyle)\n if (output_width < text_width)\n output_width = text_width\n }\n }\n\n const minWidth = LiteGraph.NODE_WIDTH * (widgets?.length ? 1.5 : 1)\n // Text + slot width + centre padding\n const centrePadding = input_width && output_width ? 5 : 0\n const slotsWidth = input_width + output_width + (2 * LiteGraph.NODE_SLOT_HEIGHT) + centrePadding\n\n // Total distance from edge of node to the inner edge of the widget 'previous' arrow button\n const widgetMargin = BaseWidget.margin + BaseWidget.arrowMargin + BaseWidget.arrowWidth\n const widgetPadding = BaseWidget.minValueWidth + (2 * widgetMargin)\n if (widgetWidth) widgetWidth += widgetPadding\n\n size[0] = Math.max(slotsWidth, widgetWidth, title_width, minWidth)\n size[1] = (this.constructor.slot_start_y || 0) + rows * LiteGraph.NODE_SLOT_HEIGHT\n\n // Get widget height & expand size if necessary\n let widgets_height = 0\n if (widgets?.length) {\n for (const widget of widgets) {\n if (!this.isWidgetVisible(widget)) continue\n\n let widget_height = 0\n if (widget.computeSize) {\n widget_height += widget.computeSize(size[0])[1]\n } else if (widget.computeLayoutSize) {\n // Expand widget width if necessary\n const { minHeight, minWidth } = widget.computeLayoutSize(this)\n const widgetWidth = minWidth + widgetPadding\n if (widgetWidth > size[0]) size[0] = widgetWidth\n\n widget_height += minHeight\n } else {\n widget_height += LiteGraph.NODE_WIDGET_HEIGHT\n }\n widgets_height += widget_height + 4\n }\n widgets_height += 8\n }\n\n // compute height using widgets height\n if (this.widgets_up)\n size[1] = Math.max(size[1], widgets_height)\n else if (this.widgets_start_y != null)\n size[1] = Math.max(size[1], widgets_height + this.widgets_start_y)\n else\n size[1] += widgets_height\n\n function compute_text_size(text: string, fontStyle: string) {\n return LGraphCanvas._measureText?.(text, fontStyle) ??\n font_size * (text?.length ?? 0) * 0.6\n }\n\n if (this.constructor.min_height && size[1] < this.constructor.min_height) {\n size[1] = this.constructor.min_height\n }\n\n // margin\n size[1] += 6\n\n return size\n }\n\n inResizeCorner(canvasX: number, canvasY: number): boolean {\n const rows = this.outputs ? this.outputs.length : 1\n const outputs_offset = (this.constructor.slot_start_y || 0) + rows * LiteGraph.NODE_SLOT_HEIGHT\n return isInRectangle(\n canvasX,\n canvasY,\n this.pos[0] + this.size[0] - 15,\n this.pos[1] + Math.max(this.size[1] - 15, outputs_offset),\n 20,\n 20,\n )\n }\n\n /**\n * Returns which resize corner the point is over, if any.\n * @param canvasX X position in canvas coordinates\n * @param canvasY Y position in canvas coordinates\n * @returns The compass corner the point is in, otherwise `undefined`.\n */\n findResizeDirection(canvasX: number, canvasY: number): CompassCorners | undefined {\n if (this.resizable === false) return\n\n const { boundingRect } = this\n if (!boundingRect.containsXy(canvasX, canvasY)) return\n\n // Check corners first (they take priority over edges)\n return boundingRect.findContainingCorner(canvasX, canvasY, LGraphNode.resizeHandleSize)\n }\n\n /**\n * returns all the info available about a property of this node.\n * @param property name of the property\n * @returns the object with all the available info\n */\n getPropertyInfo(property: string) {\n let info = null\n\n // there are several ways to define info about a property\n // legacy mode\n const { properties_info } = this\n if (properties_info) {\n for (const propInfo of properties_info) {\n if (propInfo.name == property) {\n info = propInfo\n break\n }\n }\n }\n // litescene mode using the constructor\n // @ts-expect-error deprecated https://github.com/Comfy-Org/litegraph.js/issues/639\n if (this.constructor[`@${property}`]) info = this.constructor[`@${property}`]\n\n if (this.constructor.widgets_info?.[property])\n info = this.constructor.widgets_info[property]\n\n // litescene mode using the constructor\n if (!info && this.onGetPropertyInfo) {\n info = this.onGetPropertyInfo(property)\n }\n\n info ||= {}\n info.type ||= typeof this.properties[property]\n if (info.widget == \"combo\") info.type = \"enum\"\n\n return info\n }\n\n /**\n * Defines a widget inside the node, it will be rendered on top of the node, you can control lots of properties\n * @param type the widget type\n * @param name the text to show on the widget\n * @param value the default value\n * @param callback function to call when it changes (optionally, it can be the name of the property to modify)\n * @param options the object that contains special properties of this widget\n * @returns the created widget object\n */\n addWidget<Type extends TWidgetType, TValue extends WidgetTypeMap[Type][\"value\"]>(\n type: Type,\n name: string,\n value: TValue,\n callback: IBaseWidget[\"callback\"] | string | null,\n options?: IWidgetOptions | string,\n ): WidgetTypeMap[Type] | IBaseWidget {\n this.widgets ||= []\n\n if (!options && callback && typeof callback === \"object\") {\n options = callback\n callback = null\n }\n\n // options can be the property name\n options ||= {}\n if (typeof options === \"string\")\n options = { property: options }\n\n // callback can be the property name\n if (callback && typeof callback === \"string\") {\n options.property = callback\n callback = null\n }\n\n const w: IBaseWidget & { type: Type } = {\n // @ts-expect-error\n type: type.toLowerCase(),\n name: name,\n value: value,\n callback: typeof callback !== \"function\" ? undefined : callback,\n options,\n y: 0,\n }\n\n if (w.options.y !== undefined) {\n w.y = w.options.y\n }\n\n if (!callback && !w.options.callback && !w.options.property) {\n console.warn(\"LiteGraph addWidget(...) without a callback or property assigned\")\n }\n if (type == \"combo\" && !w.options.values) {\n throw \"LiteGraph addWidget('combo',...) requires to pass values in options: { values:['red','blue'] }\"\n }\n\n const widget = this.addCustomWidget(w)\n this.expandToFitContent()\n return widget\n }\n\n addCustomWidget<TPlainWidget extends IBaseWidget>(\n custom_widget: TPlainWidget,\n ): TPlainWidget | WidgetTypeMap[TPlainWidget[\"type\"]] {\n this.widgets ||= []\n const widget = toConcreteWidget(custom_widget, this, false) ?? custom_widget\n this.widgets.push(widget)\n return widget\n }\n\n addTitleButton(options: LGraphButtonOptions): LGraphButton {\n this.title_buttons ||= []\n const button = new LGraphButton(options)\n this.title_buttons.push(button)\n return button\n }\n\n onTitleButtonClick(button: LGraphButton, canvas: LGraphCanvas): void {\n // Dispatch event for button click\n canvas.dispatch(\"litegraph:node-title-button-clicked\", {\n node: this,\n button: button,\n })\n }\n\n removeWidgetByName(name: string): void {\n const widget = this.widgets?.find(x => x.name === name)\n if (widget) this.removeWidget(widget)\n }\n\n removeWidget(widget: IBaseWidget): void {\n if (!this.widgets) throw new Error(\"removeWidget called on node without widgets\")\n\n const widgetIndex = this.widgets.indexOf(widget)\n if (widgetIndex === -1) throw new Error(\"Widget not found on this node\")\n\n // Clean up slot references to prevent memory leaks\n if (this.inputs) {\n for (const input of this.inputs) {\n if (input._widget === widget) {\n input._widget = undefined\n delete input.widget\n }\n }\n }\n\n this.widgets.splice(widgetIndex, 1)\n }\n\n ensureWidgetRemoved(widget: IBaseWidget): void {\n try {\n this.removeWidget(widget)\n } catch (error) {\n console.debug(\"Failed to remove widget\", error)\n }\n }\n\n move(deltaX: number, deltaY: number): void {\n if (this.pinned) return\n\n this.pos[0] += deltaX\n this.pos[1] += deltaY\n }\n\n /**\n * Internal method to measure the node for rendering. Prefer {@link boundingRect} where possible.\n *\n * Populates {@link out} with the results in graph space.\n * Populates {@link _collapsed_width} with the collapsed width if the node is collapsed.\n * Adjusts for title and collapsed status, but does not call {@link onBounding}.\n * @param out `x, y, width, height` are written to this array.\n * @param ctx The canvas context to use for measuring text.\n */\n measure(out: Rect, ctx: CanvasRenderingContext2D): void {\n const titleMode = this.title_mode\n const renderTitle =\n titleMode != TitleMode.TRANSPARENT_TITLE &&\n titleMode != TitleMode.NO_TITLE\n const titleHeight = renderTitle ? LiteGraph.NODE_TITLE_HEIGHT : 0\n\n out[0] = this.pos[0]\n out[1] = this.pos[1] + -titleHeight\n if (!this.flags?.collapsed) {\n out[2] = this.size[0]\n out[3] = this.size[1] + titleHeight\n } else {\n ctx.font = this.innerFontStyle\n this._collapsed_width = Math.min(\n this.size[0],\n ctx.measureText(this.getTitle() ?? \"\").width + LiteGraph.NODE_TITLE_HEIGHT * 2,\n )\n out[2] = (this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH)\n out[3] = LiteGraph.NODE_TITLE_HEIGHT\n }\n }\n\n /**\n * returns the bounding of the object, used for rendering purposes\n * @param out {Float32Array[4]?} [optional] a place to store the output, to free garbage\n * @param includeExternal {boolean?} [optional] set to true to\n * include the shadow and connection points in the bounding calculation\n * @returns the bounding box in format of [topleft_cornerx, topleft_cornery, width, height]\n */\n getBounding(out?: Rect, includeExternal?: boolean): Rect {\n out ||= new Float32Array(4)\n\n const rect = includeExternal ? this.renderArea : this.boundingRect\n out[0] = rect[0]\n out[1] = rect[1]\n out[2] = rect[2]\n out[3] = rect[3]\n\n return out\n }\n\n /**\n * Calculates the render area of this node, populating both {@link boundingRect} and {@link renderArea}.\n * Called automatically at the start of every frame.\n */\n updateArea(ctx: CanvasRenderingContext2D): void {\n const bounds = this.#boundingRect\n this.measure(bounds, ctx)\n this.onBounding?.(bounds)\n\n const renderArea = this.#renderArea\n renderArea.set(bounds)\n // 4 offset for collapsed node connection points\n renderArea[0] -= 4\n renderArea[1] -= 4\n // Add shadow & left offset\n renderArea[2] += 6 + 4\n // Add shadow & top offsets\n renderArea[3] += 5 + 4\n }\n\n /**\n * checks if a point is inside the shape of a node\n */\n isPointInside(x: number, y: number): boolean {\n return isInRect(x, y, this.boundingRect)\n }\n\n /**\n * Checks if the provided point is inside this node's collapse button area.\n * @param x X co-ordinate to check\n * @param y Y co-ordinate to check\n * @returns true if the x,y point is in the collapse button area, otherwise false\n */\n isPointInCollapse(x: number, y: number): boolean {\n const squareLength = LiteGraph.NODE_TITLE_HEIGHT\n return isInRectangle(\n x,\n y,\n this.pos[0],\n this.pos[1] - squareLength,\n squareLength,\n squareLength,\n )\n }\n\n /**\n * Returns the input slot at the given position. Uses full 20 height, and approximates the label length.\n * @param pos The graph co-ordinates to check\n * @returns The input slot at the given position if found, otherwise `undefined`.\n */\n getInputOnPos(pos: Point): INodeInputSlot | undefined {\n return getNodeInputOnPos(this, pos[0], pos[1])?.input\n }\n\n /**\n * Returns the output slot at the given position. Uses full 20x20 box for the slot.\n * @param pos The graph co-ordinates to check\n * @returns The output slot at the given position if found, otherwise `undefined`.\n */\n getOutputOnPos(pos: Point): INodeOutputSlot | undefined {\n return getNodeOutputOnPos(this, pos[0], pos[1])?.output\n }\n\n /**\n * Returns the input or output slot at the given position.\n *\n * Tries {@link getNodeInputOnPos} first, then {@link getNodeOutputOnPos}.\n * @param pos The graph co-ordinates to check\n * @returns The input or output slot at the given position if found, otherwise `undefined`.\n */\n getSlotOnPos(pos: Point): INodeInputSlot | INodeOutputSlot | undefined {\n if (!isPointInRect(pos, this.boundingRect)) return\n\n return this.getInputOnPos(pos) ?? this.getOutputOnPos(pos)\n }\n\n /**\n * @deprecated Use {@link getSlotOnPos} instead.\n * checks if a point is inside a node slot, and returns info about which slot\n * @param x\n * @param y\n * @returns if found the object contains { input|output: slot object, slot: number, link_pos: [x,y] }\n */\n getSlotInPosition(x: number, y: number): IFoundSlot | null {\n // search for inputs\n const { inputs, outputs } = this\n\n if (inputs) {\n for (const [i, input] of inputs.entries()) {\n const pos = this.getInputPos(i)\n if (isInRectangle(x, y, pos[0] - 10, pos[1] - 10, 20, 20)) {\n return { input, slot: i, link_pos: pos }\n }\n }\n }\n\n if (outputs) {\n for (const [i, output] of outputs.entries()) {\n const pos = this.getOutputPos(i)\n if (isInRectangle(x, y, pos[0] - 10, pos[1] - 10, 20, 20)) {\n return { output, slot: i, link_pos: pos }\n }\n }\n }\n\n return null\n }\n\n /**\n * Gets the widget on this node at the given co-ordinates.\n * @param canvasX X co-ordinate in graph space\n * @param canvasY Y co-ordinate in graph space\n * @returns The widget found, otherwise `null`\n */\n getWidgetOnPos(\n canvasX: number,\n canvasY: number,\n includeDisabled = false,\n ): IBaseWidget | undefined {\n const { widgets, pos, size } = this\n if (!widgets?.length) return\n\n const x = canvasX - pos[0]\n const y = canvasY - pos[1]\n const nodeWidth = size[0]\n\n for (const widget of widgets) {\n if (\n (widget.computedDisabled && !includeDisabled) ||\n !this.isWidgetVisible(widget)\n ) {\n continue\n }\n\n const h = widget.computedHeight ??\n widget.computeSize?.(nodeWidth)[1] ??\n LiteGraph.NODE_WIDGET_HEIGHT\n\n const w = widget.width || nodeWidth\n if (\n widget.last_y !== undefined &&\n isInRectangle(x, y, 6, widget.last_y, w - 12, h)\n ) {\n return widget\n }\n }\n }\n\n /**\n * Returns the input slot with a given name (used for dynamic slots), -1 if not found\n * @param name the name of the slot to find\n * @param returnObj if the obj itself wanted\n * @returns the slot (-1 if not found)\n */\n findInputSlot<TReturn extends false>(name: string, returnObj?: TReturn): number\n findInputSlot<TReturn extends true>(name: string, returnObj?: TReturn): INodeInputSlot\n findInputSlot(name: string, returnObj: boolean = false) {\n const { inputs } = this\n if (!inputs) return -1\n\n for (const [i, input] of inputs.entries()) {\n if (name == input.name) {\n return !returnObj ? i : input\n }\n }\n return -1\n }\n\n /**\n * returns the output slot with a given name (used for dynamic slots), -1 if not found\n * @param name the name of the slot to find\n * @param returnObj if the obj itself wanted\n * @returns the slot (-1 if not found)\n */\n findOutputSlot<TReturn extends false>(name: string, returnObj?: TReturn): number\n findOutputSlot<TReturn extends true>(name: string, returnObj?: TReturn): INodeOutputSlot\n findOutputSlot(name: string, returnObj: boolean = false) {\n const { outputs } = this\n if (!outputs) return -1\n\n for (const [i, output] of outputs.entries()) {\n if (name == output.name) {\n return !returnObj ? i : output\n }\n }\n return -1\n }\n\n /**\n * Finds the first free input slot.\n * @param optsIn\n * @returns The index of the first matching slot, the slot itself if returnObj is true, or -1 if not found.\n */\n findInputSlotFree<TReturn extends false>(\n optsIn?: FindFreeSlotOptions & { returnObj?: TReturn },\n ): number\n findInputSlotFree<TReturn extends true>(\n optsIn?: FindFreeSlotOptions & { returnObj?: TReturn },\n ): INodeInputSlot | -1\n findInputSlotFree(optsIn?: FindFreeSlotOptions) {\n return this.#findFreeSlot(this.inputs, optsIn)\n }\n\n /**\n * Finds the first free output slot.\n * @param optsIn\n * @returns The index of the first matching slot, the slot itself if returnObj is true, or -1 if not found.\n */\n findOutputSlotFree<TReturn extends false>(\n optsIn?: FindFreeSlotOptions & { returnObj?: TReturn },\n ): number\n findOutputSlotFree<TReturn extends true>(\n optsIn?: FindFreeSlotOptions & { returnObj?: TReturn },\n ): INodeOutputSlot | -1\n findOutputSlotFree(optsIn?: FindFreeSlotOptions) {\n return this.#findFreeSlot(this.outputs, optsIn)\n }\n\n /**\n * Finds the next free slot\n * @param slots The slots to search, i.e. this.inputs or this.outputs\n */\n #findFreeSlot<TSlot extends INodeInputSlot | INodeOutputSlot>(\n slots: TSlot[],\n options?: FindFreeSlotOptions,\n ): TSlot | number {\n const defaults = {\n returnObj: false,\n typesNotAccepted: [],\n }\n const opts = Object.assign(defaults, options || {})\n const length = slots?.length\n if (!(length > 0)) return -1\n\n for (let i = 0; i < length; ++i) {\n const slot: TSlot & IGenericLinkOrLinks = slots[i]\n if (!slot || slot.link || slot.links?.length) continue\n if (opts.typesNotAccepted?.includes?.(slot.type)) continue\n return !opts.returnObj ? i : slot\n }\n return -1\n }\n\n /**\n * findSlotByType for INPUTS\n */\n findInputSlotByType<TReturn extends false>(\n type: ISlotType,\n returnObj?: TReturn,\n preferFreeSlot?: boolean,\n doNotUseOccupied?: boolean,\n ): number\n findInputSlotByType<TReturn extends true>(\n type: ISlotType,\n returnObj?: TReturn,\n preferFreeSlot?: boolean,\n doNotUseOccupied?: boolean,\n ): INodeInputSlot\n findInputSlotByType(\n type: ISlotType,\n returnObj?: boolean,\n preferFreeSlot?: boolean,\n doNotUseOccupied?: boolean,\n ) {\n return this.#findSlotByType(\n this.inputs,\n type,\n returnObj,\n preferFreeSlot,\n doNotUseOccupied,\n )\n }\n\n /**\n * findSlotByType for OUTPUTS\n */\n findOutputSlotByType<TReturn extends false>(\n type: ISlotType,\n returnObj?: TReturn,\n preferFreeSlot?: boolean,\n doNotUseOccupied?: boolean,\n ): number\n findOutputSlotByType<TReturn extends true>(\n type: ISlotType,\n returnObj?: TReturn,\n preferFreeSlot?: boolean,\n doNotUseOccupied?: boolean,\n ): INodeOutputSlot\n findOutputSlotByType(\n type: ISlotType,\n returnObj?: boolean,\n preferFreeSlot?: boolean,\n doNotUseOccupied?: boolean,\n ) {\n return this.#findSlotByType(\n this.outputs,\n type,\n returnObj,\n preferFreeSlot,\n doNotUseOccupied,\n )\n }\n\n /**\n * returns the output (or input) slot with a given type, -1 if not found\n * @param input uise inputs instead of outputs\n * @param type the type of the slot to find\n * @param returnObj if the obj itself wanted\n * @param preferFreeSlot if we want a free slot (if not found, will return the first of the type anyway)\n * @returns the slot (-1 if not found)\n */\n findSlotByType<TSlot extends true | false, TReturn extends false>(\n input: TSlot,\n type: ISlotType,\n returnObj?: TReturn,\n preferFreeSlot?: boolean,\n doNotUseOccupied?: boolean,\n ): number\n findSlotByType<TSlot extends true, TReturn extends true>(\n input: TSlot,\n type: ISlotType,\n returnObj?: TReturn,\n preferFreeSlot?: boolean,\n doNotUseOccupied?: boolean,\n ): INodeInputSlot | -1\n findSlotByType<TSlot extends false, TReturn extends true>(\n input: TSlot,\n type: ISlotType,\n returnObj?: TReturn,\n preferFreeSlot?: boolean,\n doNotUseOccupied?: boolean,\n ): INodeOutputSlot | -1\n findSlotByType(\n input: boolean,\n type: ISlotType,\n returnObj?: boolean,\n preferFreeSlot?: boolean,\n doNotUseOccupied?: boolean,\n ): number | INodeOutputSlot | INodeInputSlot {\n return input\n ? this.#findSlotByType(\n this.inputs,\n type,\n returnObj,\n preferFreeSlot,\n doNotUseOccupied,\n )\n : this.#findSlotByType(\n this.outputs,\n type,\n returnObj,\n preferFreeSlot,\n doNotUseOccupied,\n )\n }\n\n /**\n * Finds a matching slot from those provided, returning the slot itself or its index in {@link slots}.\n * @param slots Slots to search (this.inputs or this.outputs)\n * @param type Type of slot to look for\n * @param returnObj If true, returns the slot itself. Otherwise, the index.\n * @param preferFreeSlot Prefer a free slot, but if none are found, fall back to an occupied slot.\n * @param doNotUseOccupied Do not fall back to occupied slots.\n * @see {findSlotByType}\n * @see {findOutputSlotByType}\n * @see {findInputSlotByType}\n * @returns If a match is found, the slot if returnObj is true, otherwise the index. If no matches are found, -1\n */\n #findSlotByType<TSlot extends INodeInputSlot | INodeOutputSlot>(\n slots: TSlot[],\n type: ISlotType,\n returnObj?: boolean,\n preferFreeSlot?: boolean,\n doNotUseOccupied?: boolean,\n ): TSlot | number {\n const length = slots?.length\n if (!length) return -1\n\n // Empty string and * match anything (type: 0)\n if (type == \"\" || type == \"*\") type = 0\n const sourceTypes = String(type).toLowerCase().split(\",\")\n\n // Run the search\n let occupiedSlot: number | TSlot | null = null\n for (let i = 0; i < length; ++i) {\n const slot: TSlot & IGenericLinkOrLinks = slots[i]\n const destTypes = slot.type == \"0\" || slot.type == \"*\"\n ? [\"0\"]\n : String(slot.type).toLowerCase().split(\",\")\n\n for (const sourceType of sourceTypes) {\n // TODO: Remove _event_ entirely.\n const source = sourceType == \"_event_\" ? LiteGraph.EVENT : sourceType\n\n for (const destType of destTypes) {\n const dest = destType == \"_event_\" ? LiteGraph.EVENT : destType\n\n if (source == dest || source === \"*\" || dest === \"*\") {\n if (preferFreeSlot && (slot.links?.length || slot.link != null)) {\n // In case we can't find a free slot.\n occupiedSlot ??= returnObj ? slot : i\n continue\n }\n return returnObj ? slot : i\n }\n }\n }\n }\n\n return doNotUseOccupied ? -1 : occupiedSlot ?? -1\n }\n\n /**\n * Determines the slot index to connect to when attempting to connect by type.\n * @param findInputs If true, searches for an input. Otherwise, an output.\n * @param node The node at the other end of the connection.\n * @param slotType The type of slot at the other end of the connection.\n * @param options Search restrictions to adhere to.\n * @see {connectByType}\n * @see {connectByTypeOutput}\n */\n findConnectByTypeSlot(\n findInputs: boolean,\n node: LGraphNode,\n slotType: ISlotType,\n options?: ConnectByTypeOptions,\n ): number | undefined {\n // LEGACY: Old options names\n if (options && typeof options === \"object\") {\n if (\"firstFreeIfInputGeneralInCase\" in options) options.wildcardToTyped = !!options.firstFreeIfInputGeneralInCase\n if (\"firstFreeIfOutputGeneralInCase\" in options) options.wildcardToTyped = !!options.firstFreeIfOutputGeneralInCase\n if (\"generalTypeInCase\" in options) options.typedToWildcard = !!options.generalTypeInCase\n }\n const optsDef: ConnectByTypeOptions = {\n createEventInCase: true,\n wildcardToTyped: true,\n typedToWildcard: true,\n }\n const opts = Object.assign(optsDef, options)\n\n if (!this.graph) throw new NullGraphError()\n\n if (node && typeof node === \"number\") {\n const nodeById = this.graph.getNodeById(node)\n if (!nodeById) return\n\n node = nodeById\n }\n const slot = node.findSlotByType(findInputs, slotType, false, true)\n if (slot >= 0 && slot !== null) return slot\n\n // TODO: Remove or reimpl. events. WILL CREATE THE onTrigger IN SLOT\n if (opts.createEventInCase && slotType == LiteGraph.EVENT) {\n if (findInputs) return -1\n if (LiteGraph.do_add_triggers_slots) return node.addOnExecutedOutput()\n }\n\n // connect to the first general output slot if not found a specific type and\n if (opts.typedToWildcard) {\n const generalSlot = node.findSlotByType(findInputs, 0, false, true, true)\n if (generalSlot >= 0) return generalSlot\n }\n // connect to the first free input slot if not found a specific type and this output is general\n if (\n opts.wildcardToTyped &&\n (slotType == 0 || slotType == \"*\" || slotType == \"\")\n ) {\n const opt = { typesNotAccepted: [LiteGraph.EVENT] }\n const nonEventSlot = findInputs\n ? node.findInputSlotFree(opt)\n : node.findOutputSlotFree(opt)\n if (nonEventSlot >= 0) return nonEventSlot\n }\n }\n\n /**\n * Finds the first free output slot with any of the comma-delimited types in {@link type}.\n *\n * If no slots are free, falls back in order to:\n * - The first free wildcard slot\n * - The first occupied slot\n * - The first occupied wildcard slot\n * @param type The {@link ISlotType type} of slot to find\n * @returns The index and slot if found, otherwise `undefined`.\n */\n findOutputByType(type: ISlotType): { index: number, slot: INodeOutputSlot } | undefined {\n return findFreeSlotOfType(this.outputs, type, output => !output.links?.length)\n }\n\n /**\n * Finds the first free input slot with any of the comma-delimited types in {@link type}.\n *\n * If no slots are free, falls back in order to:\n * - The first free wildcard slot\n * - The first occupied slot\n * - The first occupied wildcard slot\n * @param type The {@link ISlotType type} of slot to find\n * @returns The index and slot if found, otherwise `undefined`.\n */\n findInputByType(type: ISlotType): { index: number, slot: INodeInputSlot } | undefined {\n return findFreeSlotOfType(this.inputs, type, input => input.link == null)\n }\n\n /**\n * connect this node output to the input of another node BY TYPE\n * @param slot (could be the number of the slot or the string with the name of the slot)\n * @param target_node the target node\n * @param target_slotType the input slot type of the target node\n * @returns the link_info is created, otherwise null\n */\n connectByType(\n slot: number | string,\n target_node: LGraphNode,\n target_slotType: ISlotType,\n optsIn?: ConnectByTypeOptions,\n ): LLink | null {\n const slotIndex = this.findConnectByTypeSlot(\n true,\n target_node,\n target_slotType,\n optsIn,\n )\n if (slotIndex !== undefined)\n return this.connect(slot, target_node, slotIndex, optsIn?.afterRerouteId)\n\n console.debug(\"[connectByType]: no way to connect type:\", target_slotType, \"to node:\", target_node)\n return null\n }\n\n /**\n * connect this node input to the output of another node BY TYPE\n * @param slot (could be the number of the slot or the string with the name of the slot)\n * @param source_node the target node\n * @param source_slotType the output slot type of the target node\n * @returns the link_info is created, otherwise null\n */\n connectByTypeOutput(\n slot: number | string,\n source_node: LGraphNode,\n source_slotType: ISlotType,\n optsIn?: ConnectByTypeOptions,\n ): LLink | null {\n // LEGACY: Old options names\n if (typeof optsIn === \"object\") {\n if (\"firstFreeIfInputGeneralInCase\" in optsIn) optsIn.wildcardToTyped = !!optsIn.firstFreeIfInputGeneralInCase\n if (\"generalTypeInCase\" in optsIn) optsIn.typedToWildcard = !!optsIn.generalTypeInCase\n }\n const slotIndex = this.findConnectByTypeSlot(\n false,\n source_node,\n source_slotType,\n optsIn,\n )\n if (slotIndex !== undefined)\n return source_node.connect(slotIndex, this, slot, optsIn?.afterRerouteId)\n\n console.debug(\"[connectByType]: no way to connect type:\", source_slotType, \"to node:\", source_node)\n return null\n }\n\n canConnectTo(\n node: NodeLike,\n toSlot: INodeInputSlot | SubgraphIO,\n fromSlot: INodeOutputSlot | SubgraphIO,\n ) {\n return this.id !== node.id && LiteGraph.isValidConnection(fromSlot.type, toSlot.type)\n }\n\n /**\n * Connect an output of this node to an input of another node\n * @param slot (could be the number of the slot or the string with the name of the slot)\n * @param target_node the target node\n * @param target_slot the input slot of the target node (could be the number of the slot or the string with the name of the slot, or -1 to connect a trigger)\n * @returns the link_info is created, otherwise null\n */\n connect(\n slot: number | string,\n target_node: LGraphNode,\n target_slot: ISlotType,\n afterRerouteId?: RerouteId,\n ): LLink | null {\n // Allow legacy API support for searching target_slot by string, without mutating the input variables\n let targetIndex: number | null\n\n const { graph, outputs } = this\n if (!graph) {\n // could be connected before adding it to a graph\n // due to link ids being associated with graphs\n console.log(\"Connect: Error, node doesn't belong to any graph. Nodes must be added first to a graph before connecting them.\")\n return null\n }\n\n // seek for the output slot\n if (typeof slot === \"string\") {\n slot = this.findOutputSlot(slot)\n if (slot == -1) {\n if (LiteGraph.debug) console.log(`Connect: Error, no slot of name ${slot}`)\n return null\n }\n } else if (!outputs || slot >= outputs.length) {\n if (LiteGraph.debug) console.log(\"Connect: Error, slot number not found\")\n return null\n }\n\n if (target_node && typeof target_node === \"number\") {\n const nodeById = graph.getNodeById(target_node)\n if (!nodeById) throw \"target node is null\"\n\n target_node = nodeById\n }\n if (!target_node) throw \"target node is null\"\n\n // avoid loopback\n if (target_node == this) return null\n\n // you can specify the slot by name\n if (typeof target_slot === \"string\") {\n targetIndex = target_node.findInputSlot(target_slot)\n if (targetIndex == -1) {\n if (LiteGraph.debug) console.log(`Connect: Error, no slot of name ${targetIndex}`)\n return null\n }\n } else if (target_slot === LiteGraph.EVENT) {\n // TODO: Events\n if (LiteGraph.do_add_triggers_slots) {\n target_node.changeMode(LGraphEventMode.ON_TRIGGER)\n targetIndex = target_node.findInputSlot(\"onTrigger\")\n } else {\n return null\n }\n } else if (typeof target_slot === \"number\") {\n targetIndex = target_slot\n } else {\n targetIndex = 0\n }\n\n // Allow target node to change slot\n if (target_node.onBeforeConnectInput) {\n // This way node can choose another slot (or make a new one?)\n const requestedIndex = target_node.onBeforeConnectInput(targetIndex, target_slot)\n targetIndex = typeof requestedIndex === \"number\" ? requestedIndex : null\n }\n\n if (\n targetIndex === null ||\n !target_node.inputs ||\n targetIndex >= target_node.inputs.length\n ) {\n if (LiteGraph.debug) console.log(\"Connect: Error, slot number not found\")\n return null\n }\n\n const input = target_node.inputs[targetIndex]\n const output = outputs[slot]\n\n if (!output) return null\n\n if (output.links?.length) {\n if (output.type === LiteGraph.EVENT && !LiteGraph.allow_multi_output_for_events) {\n graph.beforeChange()\n // @ts-expect-error Unused param\n this.disconnectOutput(slot, false, { doProcessChange: false })\n }\n }\n\n const link = this.connectSlots(output, target_node, input, afterRerouteId)\n return link ?? null\n }\n\n /**\n * Connect two slots between two nodes\n * @param output The output slot to connect\n * @param inputNode The node that the input slot is on\n * @param input The input slot to connect\n * @param afterRerouteId The reroute ID to use for the link\n * @returns The link that was created, or null if the connection was blocked\n */\n connectSlots(\n output: INodeOutputSlot,\n inputNode: LGraphNode,\n input: INodeInputSlot,\n afterRerouteId: RerouteId | undefined,\n ): LLink | null | undefined {\n const { graph } = this\n if (!graph) throw new NullGraphError()\n\n const outputIndex = this.outputs.indexOf(output)\n if (outputIndex === -1) {\n console.warn(\"connectSlots: output not found\")\n return\n }\n const inputIndex = inputNode.inputs.indexOf(input)\n if (inputIndex === -1) {\n console.warn(\"connectSlots: input not found\")\n return\n }\n\n // check targetSlot and check connection types\n if (!LiteGraph.isValidConnection(output.type, input.type)) {\n this.setDirtyCanvas(false, true)\n return null\n }\n\n // Allow nodes to block connection\n if (inputNode.onConnectInput?.(inputIndex, output.type, output, this, outputIndex) === false)\n return null\n if (this.onConnectOutput?.(outputIndex, input.type, input, inputNode, inputIndex) === false)\n return null\n\n // if there is something already plugged there, disconnect\n if (inputNode.inputs[inputIndex]?.link != null) {\n graph.beforeChange()\n inputNode.disconnectInput(inputIndex, true)\n }\n\n const link = new LLink(\n ++graph.state.lastLinkId,\n input.type || output.type,\n this.id,\n outputIndex,\n inputNode.id,\n inputIndex,\n afterRerouteId,\n )\n\n // add to graph links list\n graph._links.set(link.id, link)\n\n // connect in output\n output.links ??= []\n output.links.push(link.id)\n // connect in input\n inputNode.inputs[inputIndex].link = link.id\n\n // Reroutes\n const reroutes = LLink.getReroutes(graph, link)\n for (const reroute of reroutes) {\n reroute.linkIds.add(link.id)\n if (reroute.floating) delete reroute.floating\n reroute._dragging = undefined\n }\n\n // If this is the terminus of a floating link, remove it\n const lastReroute = reroutes.at(-1)\n if (lastReroute) {\n for (const linkId of lastReroute.floatingLinkIds) {\n const link = graph.floatingLinks.get(linkId)\n if (link?.parentId === lastReroute.id) {\n graph.removeFloatingLink(link)\n }\n }\n }\n graph._version++\n\n // link has been created now, so its updated\n this.onConnectionsChange?.(\n NodeSlotType.OUTPUT,\n outputIndex,\n true,\n link,\n output,\n )\n\n inputNode.onConnectionsChange?.(\n NodeSlotType.INPUT,\n inputIndex,\n true,\n link,\n input,\n )\n\n this.setDirtyCanvas(false, true)\n graph.afterChange()\n\n return link\n }\n\n connectFloatingReroute(pos: Point, slot: INodeInputSlot | INodeOutputSlot, afterRerouteId?: RerouteId): Reroute {\n const { graph, id } = this\n if (!graph) throw new NullGraphError()\n\n // Assertion: It's either there or it isn't.\n const inputIndex = this.inputs.indexOf(slot as INodeInputSlot)\n const outputIndex = this.outputs.indexOf(slot as INodeOutputSlot)\n if (inputIndex === -1 && outputIndex === -1) throw new Error(\"Invalid slot\")\n\n const slotType = outputIndex === -1 ? \"input\" : \"output\"\n\n const reroute = graph.setReroute({\n pos,\n parentId: afterRerouteId,\n linkIds: [],\n floating: { slotType },\n })\n\n const parentReroute = graph.getReroute(afterRerouteId)\n const fromLastFloatingReroute = parentReroute?.floating?.slotType === \"output\"\n\n // Adding from an ouput, or a floating reroute that is NOT the tip of an existing floating chain\n if (afterRerouteId == null || !fromLastFloatingReroute) {\n const link = new LLink(\n -1,\n slot.type,\n outputIndex === -1 ? -1 : id,\n outputIndex,\n inputIndex === -1 ? -1 : id,\n inputIndex,\n )\n link.parentId = reroute.id\n graph.addFloatingLink(link)\n return reroute\n }\n\n // Adding a new floating reroute from the tip of a floating chain.\n if (!parentReroute) throw new Error(\"[connectFloatingReroute] Parent reroute not found\")\n\n const link = parentReroute.getFloatingLinks(\"output\")?.[0]\n if (!link) throw new Error(\"[connectFloatingReroute] Floating link not found\")\n\n reroute.floatingLinkIds.add(link.id)\n link.parentId = reroute.id\n delete parentReroute.floating\n return reroute\n }\n\n /**\n * disconnect one output to an specific node\n * @param slot (could be the number of the slot or the string with the name of the slot)\n * @param target_node the target node to which this slot is connected [Optional,\n * if not target_node is specified all nodes will be disconnected]\n * @returns if it was disconnected successfully\n */\n disconnectOutput(slot: string | number, target_node?: LGraphNode): boolean {\n if (typeof slot === \"string\") {\n slot = this.findOutputSlot(slot)\n if (slot == -1) {\n if (LiteGraph.debug) console.log(`Connect: Error, no slot of name ${slot}`)\n return false\n }\n } else if (!this.outputs || slot >= this.outputs.length) {\n if (LiteGraph.debug) console.log(\"Connect: Error, slot number not found\")\n return false\n }\n\n // get output slot\n const output = this.outputs[slot]\n if (!output) return false\n\n if (output._floatingLinks) {\n for (const link of output._floatingLinks) {\n if (link.hasOrigin(this.id, slot)) {\n this.graph?.removeFloatingLink(link)\n }\n }\n }\n\n if (!output.links || output.links.length == 0) return false\n const { links } = output\n\n // one of the output links in this slot\n const graph = this.graph\n if (!graph) throw new NullGraphError()\n\n if (target_node) {\n const target = typeof target_node === \"number\"\n ? graph.getNodeById(target_node)\n : target_node\n if (!target) throw \"Target Node not found\"\n\n for (const [i, link_id] of links.entries()) {\n const link_info = graph._links.get(link_id)\n if (link_info?.target_id != target.id) continue\n\n // is the link we are searching for...\n // remove here\n links.splice(i, 1)\n const input = target.inputs[link_info.target_slot]\n // remove there\n input.link = null\n\n // remove the link from the links pool\n link_info.disconnect(graph, \"input\")\n graph._version++\n\n // link_info hasn't been modified so its ok\n target.onConnectionsChange?.(\n NodeSlotType.INPUT,\n link_info.target_slot,\n false,\n link_info,\n input,\n )\n this.onConnectionsChange?.(\n NodeSlotType.OUTPUT,\n slot,\n false,\n link_info,\n output,\n )\n\n break\n }\n } else {\n // all the links in this output slot\n for (const link_id of links) {\n const link_info = graph._links.get(link_id)\n if (!link_info) continue\n\n const target = graph.getNodeById(link_info.target_id)\n graph._version++\n\n if (target) {\n const input = target.inputs[link_info.target_slot]\n // remove other side link\n input.link = null\n\n // link_info hasn't been modified so its ok\n target.onConnectionsChange?.(\n NodeSlotType.INPUT,\n link_info.target_slot,\n false,\n link_info,\n input,\n )\n }\n // remove the link from the links pool\n link_info.disconnect(graph, \"input\")\n\n this.onConnectionsChange?.(\n NodeSlotType.OUTPUT,\n slot,\n false,\n link_info,\n output,\n )\n }\n output.links = null\n }\n\n this.setDirtyCanvas(false, true)\n return true\n }\n\n /**\n * Disconnect one input\n * @param slot Input slot index, or the name of the slot\n * @param keepReroutes If `true`, reroutes will not be garbage collected.\n * @returns true if disconnected successfully or already disconnected, otherwise false\n */\n disconnectInput(slot: number | string, keepReroutes?: boolean): boolean {\n // Allow search by string\n if (typeof slot === \"string\") {\n slot = this.findInputSlot(slot)\n if (slot == -1) {\n if (LiteGraph.debug) console.log(`Connect: Error, no slot of name ${slot}`)\n return false\n }\n } else if (!this.inputs || slot >= this.inputs.length) {\n if (LiteGraph.debug) {\n console.log(\"Connect: Error, slot number not found\")\n }\n return false\n }\n\n const input = this.inputs[slot]\n if (!input) {\n console.debug(\"disconnectInput: input not found\", slot, this.inputs)\n return false\n }\n\n const { graph } = this\n if (!graph) throw new NullGraphError()\n\n // Break floating links\n if (input._floatingLinks?.size) {\n for (const link of input._floatingLinks) {\n graph.removeFloatingLink(link)\n }\n }\n\n const link_id = this.inputs[slot].link\n if (link_id != null) {\n this.inputs[slot].link = null\n\n // remove other side\n const link_info = graph._links.get(link_id)\n if (link_info) {\n // Let SubgraphInput do the disconnect.\n if (link_info.origin_id === -10 && \"inputNode\" in graph) {\n graph.inputNode._disconnectNodeInput(this, input, link_info)\n return true\n }\n\n const target_node = graph.getNodeById(link_info.origin_id)\n if (!target_node) {\n console.debug(\"disconnectInput: target node not found\", link_info.origin_id)\n return false\n }\n\n const output = target_node.outputs[link_info.origin_slot]\n if (!(output?.links?.length)) {\n console.debug(\"disconnectInput: output not found\", link_info.origin_slot)\n return false\n }\n\n // search in the inputs list for this link\n let i = 0\n for (const l = output.links.length; i < l; i++) {\n if (output.links[i] == link_id) {\n output.links.splice(i, 1)\n break\n }\n }\n\n link_info.disconnect(graph, keepReroutes ? \"output\" : undefined)\n if (graph) graph._version++\n\n this.onConnectionsChange?.(\n NodeSlotType.INPUT,\n slot,\n false,\n link_info,\n input,\n )\n target_node.onConnectionsChange?.(\n NodeSlotType.OUTPUT,\n i,\n false,\n link_info,\n output,\n )\n }\n }\n\n this.setDirtyCanvas(false, true)\n return true\n }\n\n /**\n * @deprecated Use {@link getInputPos} or {@link getOutputPos} instead.\n * returns the center of a connection point in canvas coords\n * @param is_input true if if a input slot, false if it is an output\n * @param slot_number (could be the number of the slot or the string with the name of the slot)\n * @param out [optional] a place to store the output, to free garbage\n * @returns the position\n */\n getConnectionPos(is_input: boolean, slot_number: number, out?: Point): Point {\n out ||= new Float32Array(2)\n\n const { pos: [nodeX, nodeY], inputs, outputs } = this\n\n if (this.flags.collapsed) {\n const w = this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH\n out[0] = is_input ? nodeX : nodeX + w\n out[1] = nodeY - LiteGraph.NODE_TITLE_HEIGHT * 0.5\n return out\n }\n\n // weird feature that never got finished\n if (is_input && slot_number == -1) {\n out[0] = nodeX + LiteGraph.NODE_TITLE_HEIGHT * 0.5\n out[1] = nodeY + LiteGraph.NODE_TITLE_HEIGHT * 0.5\n return out\n }\n\n // hard-coded pos\n const inputPos = inputs?.[slot_number]?.pos\n const outputPos = outputs?.[slot_number]?.pos\n\n if (is_input && inputPos) {\n out[0] = nodeX + inputPos[0]\n out[1] = nodeY + inputPos[1]\n return out\n } else if (!is_input && outputPos) {\n out[0] = nodeX + outputPos[0]\n out[1] = nodeY + outputPos[1]\n return out\n }\n\n // default vertical slots\n const offset = LiteGraph.NODE_SLOT_HEIGHT * 0.5\n const slotIndex = is_input\n ? this.#defaultVerticalInputs.indexOf(this.inputs[slot_number])\n : this.#defaultVerticalOutputs.indexOf(this.outputs[slot_number])\n\n out[0] = is_input\n ? nodeX + offset\n : nodeX + this.size[0] + 1 - offset\n out[1] =\n nodeY +\n (slotIndex + 0.7) * LiteGraph.NODE_SLOT_HEIGHT +\n (this.constructor.slot_start_y || 0)\n return out\n }\n\n /**\n * @internal The inputs that are not positioned with absolute coordinates.\n */\n get #defaultVerticalInputs() {\n return this.inputs.filter(\n slot => !slot.pos && !(this.widgets?.length && isWidgetInputSlot(slot)),\n )\n }\n\n /**\n * @internal The outputs that are not positioned with absolute coordinates.\n */\n get #defaultVerticalOutputs() {\n return this.outputs.filter((slot: INodeOutputSlot) => !slot.pos)\n }\n\n /**\n * Gets the position of an input slot, in graph co-ordinates.\n *\n * This method is preferred over the legacy {@link getConnectionPos} method.\n * @param slot Input slot index\n * @returns Position of the input slot\n */\n getInputPos(slot: number): Point {\n return this.getInputSlotPos(this.inputs[slot])\n }\n\n /**\n * Gets the position of an input slot, in graph co-ordinates.\n * @param input The actual node input object\n * @returns Position of the centre of the input slot in graph co-ordinates.\n */\n getInputSlotPos(input: INodeInputSlot): Point {\n const { pos: [nodeX, nodeY] } = this\n\n if (this.flags.collapsed) {\n const halfTitle = LiteGraph.NODE_TITLE_HEIGHT * 0.5\n return [nodeX, nodeY - halfTitle]\n }\n\n const { pos } = input\n if (pos) return [nodeX + pos[0], nodeY + pos[1]]\n\n // default vertical slots\n const offsetX = LiteGraph.NODE_SLOT_HEIGHT * 0.5\n const nodeOffsetY = this.constructor.slot_start_y || 0\n const slotIndex = this.#defaultVerticalInputs.indexOf(input)\n const slotY = (slotIndex + 0.7) * LiteGraph.NODE_SLOT_HEIGHT\n\n return [nodeX + offsetX, nodeY + slotY + nodeOffsetY]\n }\n\n /**\n * Gets the position of an output slot, in graph co-ordinates.\n *\n * This method is preferred over the legacy {@link getConnectionPos} method.\n * @param slot Output slot index\n * @returns Position of the output slot\n */\n getOutputPos(slot: number): Point {\n const { pos: [nodeX, nodeY], outputs, size: [width] } = this\n\n if (this.flags.collapsed) {\n const width = this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH\n const halfTitle = LiteGraph.NODE_TITLE_HEIGHT * 0.5\n return [nodeX + width, nodeY - halfTitle]\n }\n\n const outputPos = outputs?.[slot]?.pos\n if (outputPos) return [nodeX + outputPos[0], nodeY + outputPos[1]]\n\n // default vertical slots\n const offsetX = LiteGraph.NODE_SLOT_HEIGHT * 0.5\n const nodeOffsetY = this.constructor.slot_start_y || 0\n const slotIndex = this.#defaultVerticalOutputs.indexOf(this.outputs[slot])\n const slotY = (slotIndex + 0.7) * LiteGraph.NODE_SLOT_HEIGHT\n\n // TODO: Why +1?\n return [nodeX + width + 1 - offsetX, nodeY + slotY + nodeOffsetY]\n }\n\n /** @inheritdoc */\n snapToGrid(snapTo: number): boolean {\n return this.pinned ? false : snapPoint(this.pos, snapTo)\n }\n\n /** @see {@link snapToGrid} */\n alignToGrid(): void {\n this.snapToGrid(LiteGraph.CANVAS_GRID_SIZE)\n }\n\n /* Console output */\n trace(msg: string): void {\n this.console ||= []\n this.console.push(msg)\n // @ts-expect-error deprecated\n if (this.console.length > LGraphNode.MAX_CONSOLE)\n this.console.shift()\n }\n\n /* Forces to redraw or the main canvas (LGraphNode) or the bg canvas (links) */\n setDirtyCanvas(dirty_foreground: boolean, dirty_background?: boolean): void {\n this.graph?.canvasAction(c => c.setDirty(dirty_foreground, dirty_background))\n }\n\n loadImage(url: string): HTMLImageElement {\n interface AsyncImageElement extends HTMLImageElement { ready?: boolean }\n\n const img: AsyncImageElement = new Image()\n img.src = LiteGraph.node_images_path + url\n img.ready = false\n\n const dirty = () => this.setDirtyCanvas(true)\n img.addEventListener(\"load\", function (this: AsyncImageElement) {\n this.ready = true\n dirty()\n })\n return img\n }\n\n /**\n * Allows to get onMouseMove and onMouseUp events even if the mouse is out of focus\n * @deprecated Use {@link LGraphCanvas.pointer} instead.\n */\n captureInput(v: boolean): void {\n warnDeprecated(\"[DEPRECATED] captureInput will be removed in a future version. Please use LGraphCanvas.pointer (CanvasPointer) instead.\")\n if (!this.graph || !this.graph.list_of_graphcanvas) return\n\n const list = this.graph.list_of_graphcanvas\n\n for (const c of list) {\n // releasing somebody elses capture?!\n if (!v && c.node_capturing_input != this) continue\n\n // change\n c.node_capturing_input = v ? this : null\n }\n }\n\n get collapsed() {\n return !!this.flags.collapsed\n }\n\n get collapsible() {\n return !this.pinned && this.constructor.collapsable !== false\n }\n\n /**\n * Toggle node collapse (makes it smaller on the canvas)\n */\n collapse(force?: boolean): void {\n if (!this.collapsible && !force) return\n if (!this.graph) throw new NullGraphError()\n this.graph._version++\n this.flags.collapsed = !this.flags.collapsed\n this.setDirtyCanvas(true, true)\n }\n\n /**\n * Toggles advanced mode of the node, showing advanced widgets\n */\n toggleAdvanced() {\n if (!this.widgets?.some(w => w.advanced)) return\n if (!this.graph) throw new NullGraphError()\n this.graph._version++\n this.showAdvanced = !this.showAdvanced\n this.expandToFitContent()\n this.setDirtyCanvas(true, true)\n }\n\n get pinned() {\n return !!this.flags.pinned\n }\n\n /**\n * Prevents the node being accidentally moved or resized by mouse interaction.\n * Toggles pinned state if no value is provided.\n */\n pin(v?: boolean): void {\n if (!this.graph) throw new NullGraphError()\n\n this.graph._version++\n this.flags.pinned = v ?? !this.flags.pinned\n this.resizable = !this.pinned\n // Delete the flag if unpinned, so that we don't get unnecessary\n // flags.pinned = false in serialized object.\n if (!this.pinned) delete this.flags.pinned\n }\n\n unpin(): void {\n this.pin(false)\n }\n\n localToScreen(x: number, y: number, dragAndScale: DragAndScale): Point {\n return [\n (x + this.pos[0]) * dragAndScale.scale + dragAndScale.offset[0],\n (y + this.pos[1]) * dragAndScale.scale + dragAndScale.offset[1],\n ]\n }\n\n get width() {\n return this.collapsed\n ? this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH\n : this.size[0]\n }\n\n /**\n * Returns the height of the node, including the title bar.\n */\n get height() {\n return LiteGraph.NODE_TITLE_HEIGHT + this.bodyHeight\n }\n\n /**\n * Returns the height of the node, excluding the title bar.\n */\n get bodyHeight() {\n return this.collapsed ? 0 : this.size[1]\n }\n\n drawBadges(ctx: CanvasRenderingContext2D, { gap = 2 } = {}): void {\n const badgeInstances = this.badges.map(badge =>\n badge instanceof LGraphBadge ? badge : badge())\n const isLeftAligned = this.badgePosition === BadgePosition.TopLeft\n\n let currentX = isLeftAligned\n ? 0\n : this.width - badgeInstances.reduce((acc, badge) => acc + badge.getWidth(ctx) + gap, 0)\n const y = -(LiteGraph.NODE_TITLE_HEIGHT + gap)\n\n for (const badge of badgeInstances) {\n badge.draw(ctx, currentX, y - badge.height)\n currentX += badge.getWidth(ctx) + gap\n }\n }\n\n /**\n * Renders the node's title bar background\n */\n drawTitleBarBackground(ctx: CanvasRenderingContext2D, {\n scale,\n title_height = LiteGraph.NODE_TITLE_HEIGHT,\n low_quality = false,\n }: DrawTitleOptions): void {\n const fgcolor = this.renderingColor\n const shape = this.renderingShape\n const size = this.renderingSize\n\n if (this.onDrawTitleBar) {\n this.onDrawTitleBar(ctx, title_height, size, scale, fgcolor)\n return\n }\n\n if (this.title_mode === TitleMode.TRANSPARENT_TITLE) {\n return\n }\n\n if (this.collapsed) {\n ctx.shadowColor = LiteGraph.DEFAULT_SHADOW_COLOR\n }\n\n ctx.fillStyle = this.constructor.title_color || fgcolor\n ctx.beginPath()\n\n if (shape == RenderShape.BOX || low_quality) {\n ctx.rect(0, -title_height, size[0], title_height)\n } else if (shape == RenderShape.ROUND || shape == RenderShape.CARD) {\n ctx.roundRect(\n 0,\n -title_height,\n size[0],\n title_height,\n this.collapsed\n ? [LiteGraph.ROUND_RADIUS]\n : [LiteGraph.ROUND_RADIUS, LiteGraph.ROUND_RADIUS, 0, 0],\n )\n }\n ctx.fill()\n ctx.shadowColor = \"transparent\"\n }\n\n /**\n * Renders the node's title box, i.e. the dot in front of the title text that\n * when clicked toggles the node's collapsed state. The term `title box` comes\n * from the original LiteGraph implementation.\n */\n drawTitleBox(ctx: CanvasRenderingContext2D, {\n scale,\n low_quality = false,\n title_height = LiteGraph.NODE_TITLE_HEIGHT,\n box_size = 10,\n }: DrawTitleBoxOptions): void {\n const size = this.renderingSize\n const shape = this.renderingShape\n\n if (this.onDrawTitleBox) {\n this.onDrawTitleBox(ctx, title_height, size, scale)\n return\n }\n\n if (\n [RenderShape.ROUND, RenderShape.CIRCLE, RenderShape.CARD].includes(shape)\n ) {\n if (low_quality) {\n ctx.fillStyle = \"black\"\n ctx.beginPath()\n ctx.arc(\n title_height * 0.5,\n title_height * -0.5,\n box_size * 0.5 + 1,\n 0,\n Math.PI * 2,\n )\n ctx.fill()\n }\n\n ctx.fillStyle = this.renderingBoxColor\n if (low_quality) {\n ctx.fillRect(\n title_height * 0.5 - box_size * 0.5,\n title_height * -0.5 - box_size * 0.5,\n box_size,\n box_size,\n )\n } else {\n ctx.beginPath()\n ctx.arc(\n title_height * 0.5,\n title_height * -0.5,\n box_size * 0.5,\n 0,\n Math.PI * 2,\n )\n ctx.fill()\n }\n } else {\n if (low_quality) {\n ctx.fillStyle = \"black\"\n ctx.fillRect(\n (title_height - box_size) * 0.5 - 1,\n (title_height + box_size) * -0.5 - 1,\n box_size + 2,\n box_size + 2,\n )\n }\n ctx.fillStyle = this.renderingBoxColor\n ctx.fillRect(\n (title_height - box_size) * 0.5,\n (title_height + box_size) * -0.5,\n box_size,\n box_size,\n )\n }\n }\n\n /**\n * Renders the node's title text.\n */\n drawTitleText(ctx: CanvasRenderingContext2D, {\n scale,\n default_title_color,\n low_quality = false,\n title_height = LiteGraph.NODE_TITLE_HEIGHT,\n }: DrawTitleTextOptions): void {\n const size = this.renderingSize\n const selected = this.selected\n\n if (this.onDrawTitleText) {\n this.onDrawTitleText(\n ctx,\n title_height,\n size,\n scale,\n this.titleFontStyle,\n selected,\n )\n return\n }\n\n // Don't render title text if low quality\n if (low_quality) {\n return\n }\n\n ctx.font = this.titleFontStyle\n const rawTitle = this.getTitle() ?? `❌ ${this.type}`\n const title = String(rawTitle) + (this.pinned ? \"📌\" : \"\")\n if (title) {\n if (selected) {\n ctx.fillStyle = LiteGraph.NODE_SELECTED_TITLE_COLOR\n } else {\n ctx.fillStyle = this.constructor.title_text_color || default_title_color\n }\n\n // Calculate available width for title\n let availableWidth = size[0] - title_height * 2 // Basic margins\n\n // Subtract space for title buttons\n if (this.title_buttons?.length > 0) {\n let buttonsWidth = 0\n const savedFont = ctx.font // Save current font\n for (const button of this.title_buttons) {\n if (button.visible) {\n buttonsWidth += button.getWidth(ctx) + 2 // button width + gap\n }\n }\n ctx.font = savedFont // Restore font after button measurements\n if (buttonsWidth > 0) {\n buttonsWidth += 10 // Extra margin before buttons\n availableWidth -= buttonsWidth\n }\n }\n\n // Truncate title if needed\n let displayTitle = title\n\n if (this.collapsed) {\n // For collapsed nodes, limit to 20 chars as before\n displayTitle = title.substr(0, 20)\n } else if (availableWidth > 0) {\n // For regular nodes, truncate based on available width\n displayTitle = truncateText(ctx, title, availableWidth)\n }\n\n ctx.textAlign = \"left\"\n ctx.fillText(\n displayTitle,\n title_height,\n LiteGraph.NODE_TITLE_TEXT_Y - title_height,\n )\n }\n }\n\n /**\n * Attempts to gracefully bypass this node in all of its connections by reconnecting all links.\n *\n * Each input is checked against each output. This is done on a matching index basis, i.e. input 3 -> output 3.\n * If there are any input links remaining,\n * and {@link flags}.{@link INodeFlags.keepAllLinksOnBypass keepAllLinksOnBypass} is `true`,\n * each input will check for outputs that match, and take the first one that matches\n * `true`: Try the index matching first, then every input to every output.\n * `false`: Only matches indexes, e.g. input 3 to output 3.\n *\n * If {@link flags}.{@link INodeFlags.keepAllLinksOnBypass keepAllLinksOnBypass} is `undefined`, it will fall back to\n * the static {@link keepAllLinksOnBypass}.\n * @returns `true` if any new links were established, otherwise `false`.\n * @todo Decision: Change API to return array of new links instead?\n */\n connectInputToOutput(): boolean | undefined {\n const { inputs, outputs, graph } = this\n if (!inputs || !outputs) return\n if (!graph) throw new NullGraphError()\n\n const { _links } = graph\n let madeAnyConnections = false\n\n // First pass: only match exactly index-to-index\n for (const [index, input] of inputs.entries()) {\n if (input.link == null) continue\n\n const output = outputs[index]\n if (!output || !LiteGraph.isValidConnection(input.type, output.type)) continue\n\n const inLink = _links.get(input.link)\n if (!inLink) continue\n const inNode = graph.getNodeById(inLink?.origin_id)\n if (!inNode) continue\n\n bypassAllLinks(output, inNode, inLink, graph)\n }\n // Configured to only use index-to-index matching\n if (!(this.flags.keepAllLinksOnBypass ?? LGraphNode.keepAllLinksOnBypass))\n return madeAnyConnections\n\n // Second pass: match any remaining links\n for (const input of inputs) {\n if (input.link == null) continue\n\n const inLink = _links.get(input.link)\n if (!inLink) continue\n const inNode = graph.getNodeById(inLink?.origin_id)\n if (!inNode) continue\n\n for (const output of outputs) {\n if (!LiteGraph.isValidConnection(input.type, output.type)) continue\n\n bypassAllLinks(output, inNode, inLink, graph)\n break\n }\n }\n return madeAnyConnections\n\n function bypassAllLinks(output: INodeOutputSlot, inNode: LGraphNode, inLink: LLink, graph: LGraph) {\n const outLinks = output.links\n ?.map(x => _links.get(x))\n .filter(x => !!x)\n if (!outLinks?.length) return\n\n for (const outLink of outLinks) {\n const outNode = graph.getNodeById(outLink.target_id)\n if (!outNode) continue\n\n const result = inNode.connect(\n inLink.origin_slot,\n outNode,\n outLink.target_slot,\n inLink.parentId,\n )\n madeAnyConnections ||= !!result\n }\n }\n }\n\n /**\n * Returns `true` if the widget is visible, otherwise `false`.\n */\n isWidgetVisible(widget: IBaseWidget): boolean {\n const isHidden = (\n this.collapsed ||\n widget.hidden ||\n (widget.advanced && !this.showAdvanced)\n )\n return !isHidden\n }\n\n drawWidgets(ctx: CanvasRenderingContext2D, {\n lowQuality = false,\n editorAlpha = 1,\n }: DrawWidgetsOptions): void {\n if (!this.widgets) return\n\n const nodeWidth = this.size[0]\n const { widgets } = this\n const H = LiteGraph.NODE_WIDGET_HEIGHT\n const showText = !lowQuality\n ctx.save()\n ctx.globalAlpha = editorAlpha\n\n for (const widget of widgets) {\n if (!this.isWidgetVisible(widget)) continue\n\n const { y } = widget\n const outlineColour = widget.advanced ? LiteGraph.WIDGET_ADVANCED_OUTLINE_COLOR : LiteGraph.WIDGET_OUTLINE_COLOR\n\n widget.last_y = y\n // Disable widget if it is disabled or if the value is passed from socket connection.\n widget.computedDisabled = widget.disabled || this.getSlotFromWidget(widget)?.link != null\n\n ctx.strokeStyle = outlineColour\n ctx.fillStyle = \"#222\"\n ctx.textAlign = \"left\"\n if (widget.computedDisabled) ctx.globalAlpha *= 0.5\n const width = widget.width || nodeWidth\n\n if (typeof widget.draw === \"function\") {\n widget.draw(ctx, this, width, y, H, lowQuality)\n } else {\n toConcreteWidget(widget, this, false)?.drawWidget(ctx, { width, showText })\n }\n ctx.globalAlpha = editorAlpha\n }\n ctx.restore()\n }\n\n /**\n * When {@link LGraphNode.collapsed} is `true`, this method draws the node's collapsed slots.\n */\n drawCollapsedSlots(ctx: CanvasRenderingContext2D): void {\n // Render the first connected slot only.\n for (const slot of this.#concreteInputs) {\n if (slot.link != null) {\n slot.drawCollapsed(ctx)\n break\n }\n }\n for (const slot of this.#concreteOutputs) {\n if (slot.links?.length) {\n slot.drawCollapsed(ctx)\n break\n }\n }\n }\n\n get slots(): (INodeInputSlot | INodeOutputSlot)[] {\n return [...this.inputs, ...this.outputs]\n }\n\n #measureSlot(slot: NodeInputSlot | NodeOutputSlot, slotIndex: number, isInput: boolean): void {\n const pos = isInput ? this.getInputPos(slotIndex) : this.getOutputPos(slotIndex)\n\n slot.boundingRect[0] = pos[0] - LiteGraph.NODE_SLOT_HEIGHT * 0.5\n slot.boundingRect[1] = pos[1] - LiteGraph.NODE_SLOT_HEIGHT * 0.5\n slot.boundingRect[2] = slot.isWidgetInputSlot ? BaseWidget.margin : LiteGraph.NODE_SLOT_HEIGHT\n slot.boundingRect[3] = LiteGraph.NODE_SLOT_HEIGHT\n }\n\n #measureSlots(): ReadOnlyRect | null {\n const slots: (NodeInputSlot | NodeOutputSlot)[] = []\n\n for (const [slotIndex, slot] of this.#concreteInputs.entries()) {\n // Unrecognized nodes (Nodes with error) has inputs but no widgets. Treat\n // converted inputs as normal inputs.\n /** Widget input slots are handled in {@link layoutWidgetInputSlots} */\n if (this.widgets?.length && isWidgetInputSlot(slot)) continue\n\n this.#measureSlot(slot, slotIndex, true)\n slots.push(slot)\n }\n for (const [slotIndex, slot] of this.#concreteOutputs.entries()) {\n this.#measureSlot(slot, slotIndex, false)\n slots.push(slot)\n }\n\n return slots.length ? createBounds(slots, 0) : null\n }\n\n #getMouseOverSlot(slot: INodeSlot): INodeSlot | null {\n const isInput = isINodeInputSlot(slot)\n const mouseOverId = this.mouseOver?.[isInput ? \"inputId\" : \"outputId\"] ?? -1\n if (mouseOverId === -1) {\n return null\n }\n return isInput ? this.inputs[mouseOverId] : this.outputs[mouseOverId]\n }\n\n #isMouseOverSlot(slot: INodeSlot): boolean {\n return this.#getMouseOverSlot(slot) === slot\n }\n\n #isMouseOverWidget(widget: IBaseWidget | undefined): boolean {\n if (!widget) return false\n return this.mouseOver?.overWidget === widget\n }\n\n /**\n * Returns the input slot that is associated with the given widget.\n */\n getSlotFromWidget(widget: IBaseWidget | undefined): INodeInputSlot | undefined {\n if (widget) return this.inputs.find(slot => isWidgetInputSlot(slot) && slot.widget.name === widget.name)\n }\n\n /**\n * Returns the widget that is associated with the given input slot.\n */\n getWidgetFromSlot(slot: INodeInputSlot): IBaseWidget | undefined {\n if (!isWidgetInputSlot(slot)) return\n return this.widgets?.find(w => w.name === slot.widget.name)\n }\n\n /**\n * Draws the node's input and output slots.\n */\n drawSlots(ctx: CanvasRenderingContext2D, {\n fromSlot,\n colorContext,\n editorAlpha,\n lowQuality,\n }: DrawSlotsOptions) {\n for (const slot of [...this.#concreteInputs, ...this.#concreteOutputs]) {\n const isValidTarget = fromSlot && slot.isValidTarget(fromSlot)\n const isMouseOverSlot = this.#isMouseOverSlot(slot)\n\n // change opacity of incompatible slots when dragging a connection\n const isValid = !fromSlot || isValidTarget\n const highlight = isValid && isMouseOverSlot\n\n // Show slot if it's not a widget input slot\n // or if it's a widget input slot and satisfies one of the following:\n // - the mouse is over the widget\n // - the slot is valid during link drop\n // - the slot is connected\n if (\n isMouseOverSlot ||\n isValidTarget ||\n !slot.isWidgetInputSlot ||\n this.#isMouseOverWidget(this.getWidgetFromSlot(slot)) ||\n slot.isConnected\n ) {\n ctx.globalAlpha = isValid ? editorAlpha : 0.4 * editorAlpha\n slot.draw(ctx, {\n colorContext,\n lowQuality,\n highlight,\n })\n }\n }\n }\n\n /**\n * Arranges the node's widgets vertically.\n * Sets following properties on each widget:\n * - {@link IBaseWidget.computedHeight}\n * - {@link IBaseWidget.y}\n * @param widgetStartY The y-coordinate of the first widget\n */\n #arrangeWidgets(widgetStartY: number): void {\n if (!this.widgets || !this.widgets.length) return\n\n const bodyHeight = this.bodyHeight\n const startY = this.widgets_start_y ?? (\n (this.widgets_up ? 0 : widgetStartY) + 2\n )\n\n let freeSpace = bodyHeight - startY\n\n // Collect fixed height widgets first\n let fixedWidgetHeight = 0\n const growableWidgets: {\n minHeight: number\n prefHeight?: number\n w: IBaseWidget\n }[] = []\n\n for (const w of this.widgets) {\n if (w.computeSize) {\n const height = w.computeSize()[1] + 4\n w.computedHeight = height\n fixedWidgetHeight += height\n } else if (w.computeLayoutSize) {\n const { minHeight, maxHeight } = w.computeLayoutSize(this)\n growableWidgets.push({\n minHeight,\n prefHeight: maxHeight,\n w,\n })\n } else {\n const height = LiteGraph.NODE_WIDGET_HEIGHT + 4\n w.computedHeight = height\n fixedWidgetHeight += height\n }\n }\n\n // Calculate remaining space for DOM widgets\n freeSpace -= fixedWidgetHeight\n this.freeWidgetSpace = freeSpace\n\n // Prepare space requests for distribution\n const spaceRequests = growableWidgets.map(d => ({\n minSize: d.minHeight,\n maxSize: d.prefHeight,\n }))\n\n // Distribute space among DOM widgets\n const allocations = distributeSpace(Math.max(0, freeSpace), spaceRequests)\n\n // Apply computed heights\n for (const [i, d] of growableWidgets.entries()) {\n d.w.computedHeight = allocations[i]\n }\n\n // Position widgets\n let y = startY\n for (const w of this.widgets) {\n w.y = y\n y += w.computedHeight ?? 0\n }\n\n if (!this.graph) throw new NullGraphError()\n\n // Grow the node if necessary.\n // Ref: https://github.com/Comfy-Org/ComfyUI_frontend/issues/2652\n // TODO: Move the layout logic before drawing of the node shape, so we don't\n // need to trigger extra round of rendering.\n if (y > bodyHeight) {\n this.setSize([this.size[0], y])\n this.graph.setDirtyCanvas(false, true)\n }\n }\n\n /**\n * Arranges the layout of the node's widget input slots.\n */\n #arrangeWidgetInputSlots(): void {\n if (!this.widgets) return\n\n const slotByWidgetName = new Map<string, INodeInputSlot & { index: number }>()\n\n for (const [i, slot] of this.inputs.entries()) {\n if (!isWidgetInputSlot(slot)) continue\n\n slotByWidgetName.set(slot.widget.name, { ...slot, index: i })\n }\n if (!slotByWidgetName.size) return\n\n for (const widget of this.widgets) {\n const slot = slotByWidgetName.get(widget.name)\n if (!slot) continue\n\n const actualSlot = this.#concreteInputs[slot.index]\n const offset = LiteGraph.NODE_SLOT_HEIGHT * 0.5\n actualSlot.pos = [offset, widget.y + offset]\n this.#measureSlot(actualSlot, slot.index, true)\n }\n }\n\n /**\n * @internal Sets the internal concrete slot arrays, ensuring they are instances of\n * {@link NodeInputSlot} or {@link NodeOutputSlot}.\n *\n * A temporary workaround until duck-typed inputs and outputs\n * have been removed from the ecosystem.\n */\n _setConcreteSlots(): void {\n this.#concreteInputs = this.inputs.map(slot => toClass(NodeInputSlot, slot, this))\n this.#concreteOutputs = this.outputs.map(slot => toClass(NodeOutputSlot, slot, this))\n }\n\n /**\n * Arranges node elements in preparation for rendering (slots & widgets).\n */\n arrange(): void {\n const slotsBounds = this.#measureSlots()\n const widgetStartY = slotsBounds ? slotsBounds[1] + slotsBounds[3] - this.pos[1] : 0\n this.#arrangeWidgets(widgetStartY)\n this.#arrangeWidgetInputSlots()\n }\n\n /**\n * Draws a progress bar on the node.\n * @param ctx The canvas context to draw on\n */\n drawProgressBar(ctx: CanvasRenderingContext2D): void {\n if (!this.progress) return\n\n const originalFillStyle = ctx.fillStyle\n ctx.fillStyle = \"green\"\n ctx.fillRect(\n 0,\n 0,\n this.width * this.progress,\n 6,\n )\n ctx.fillStyle = originalFillStyle\n }\n}\n","import type { ConnectingLink, ISlotType, Positionable } from \"../interfaces\"\nimport type { LinkId } from \"@/LLink\"\n\nimport { LGraphNode } from \"@/LGraphNode\"\nimport { parseSlotTypes } from \"@/strings\"\n\n/**\n * Creates a flat set of all positionable items by recursively iterating through all child items.\n *\n * Does not include or recurse into pinned items.\n * @param items The original set of items to iterate through\n * @returns All unpinned items in the original set, and recursively, their children\n */\nexport function getAllNestedItems(items: ReadonlySet<Positionable>): Set<Positionable> {\n const allItems = new Set<Positionable>()\n if (items) {\n for (const item of items) addRecursively(item, allItems)\n }\n return allItems\n\n function addRecursively(item: Positionable, flatSet: Set<Positionable>): void {\n if (flatSet.has(item) || item.pinned) return\n flatSet.add(item)\n if (item.children) {\n for (const child of item.children) addRecursively(child, flatSet)\n }\n }\n}\n\n/**\n * Iterates through a collection of {@link Positionable} items, returning the first {@link LGraphNode}.\n * @param items The items to search through\n * @returns The first node found in {@link items}, otherwise `undefined`\n */\nexport function findFirstNode(items: Iterable<Positionable>): LGraphNode | undefined {\n for (const item of items) {\n if (item instanceof LGraphNode) return item\n }\n}\n\n/** @returns `true` if the provided link ID is currently being dragged. */\nexport function isDraggingLink(linkId: LinkId, connectingLinks: ConnectingLink[] | null | undefined): ConnectingLink | undefined {\n if (connectingLinks == null) return\n\n for (const connectingLink of connectingLinks) {\n if (connectingLink.link == null) continue\n if (linkId === connectingLink.link.id) return connectingLink\n }\n}\n\ntype FreeSlotResult<T extends { type: ISlotType }> = { index: number, slot: T } | undefined\n\n/**\n * Finds the first free in/out slot with any of the comma-delimited types in {@link type}.\n *\n * If no slots are free, falls back in order to:\n * - The first free wildcard slot\n * - The first occupied slot\n * - The first occupied wildcard slot\n * @param slots The iterable of node slots slots to search through\n * @param type The {@link ISlotType type} of slot to find\n * @param hasNoLinks A predicate that returns `true` if the slot is free.\n * @returns The index and slot if found, otherwise `undefined`.\n */\nexport function findFreeSlotOfType<T extends { type: ISlotType }>(\n slots: T[],\n type: ISlotType,\n hasNoLinks: (slot: T) => boolean,\n) {\n if (!slots?.length) return\n\n let occupiedSlot: FreeSlotResult<T>\n let wildSlot: FreeSlotResult<T>\n let occupiedWildSlot: FreeSlotResult<T>\n\n const validTypes = parseSlotTypes(type)\n\n for (const [index, slot] of slots.entries()) {\n const slotTypes = parseSlotTypes(slot.type)\n\n for (const validType of validTypes) {\n for (const slotType of slotTypes) {\n if (slotType === validType) {\n if (hasNoLinks(slot)) {\n // Exact match - short circuit\n return { index, slot }\n }\n // In case we can't find a free slot.\n occupiedSlot ??= { index, slot }\n } else if (!wildSlot && (validType === \"*\" || slotType === \"*\")) {\n // Save the first free wildcard slot as a fallback\n if (hasNoLinks(slot)) {\n wildSlot = { index, slot }\n } else {\n occupiedWildSlot ??= { index, slot }\n }\n }\n }\n }\n }\n return wildSlot ?? occupiedSlot ?? occupiedWildSlot\n}\n\nexport function removeFromArray<T>(array: T[], value: T): boolean {\n const index = array.indexOf(value)\n const found = index !== -1\n\n if (found) array.splice(index, 1)\n return found\n}\n","import type { SubgraphInputNode } from \"./SubgraphInputNode\"\nimport type { SubgraphOutput } from \"./SubgraphOutput\"\nimport type { SubgraphInputEventMap } from \"@/infrastructure/SubgraphInputEventMap\"\nimport type { INodeInputSlot, INodeOutputSlot, Point, ReadOnlyRect } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { RerouteId } from \"@/Reroute\"\nimport type { IBaseWidget } from \"@/types/widgets\"\n\nimport { CustomEventTarget } from \"@/infrastructure/CustomEventTarget\"\nimport { LiteGraph } from \"@/litegraph\"\nimport { LLink } from \"@/LLink\"\nimport { NodeSlotType } from \"@/types/globalEnums\"\n\nimport { SubgraphSlot } from \"./SubgraphSlotBase\"\nimport { isNodeSlot, isSubgraphOutput } from \"./subgraphUtils\"\n\n/**\n * An input \"slot\" from a parent graph into a subgraph.\n *\n * IMPORTANT: A subgraph \"input\" is both an input AND an output. It creates an extra link connection point between\n * a parent graph and a subgraph, so is conceptually similar to a reroute.\n *\n * This can be a little confusing, but is easier to visualise when imagining editing a subgraph.\n * You have \"Subgraph Inputs\", because they are coming into the subgraph, which then connect to \"node inputs\".\n *\n * Functionally, however, when editing a subgraph, that \"subgraph input\" is the \"origin\" or \"output side\" of a link.\n */\nexport class SubgraphInput extends SubgraphSlot {\n declare parent: SubgraphInputNode\n\n events = new CustomEventTarget<SubgraphInputEventMap>()\n\n /** The linked widget that this slot is connected to. */\n #widgetRef?: WeakRef<IBaseWidget>\n\n get _widget() {\n return this.#widgetRef?.deref()\n }\n\n set _widget(widget) {\n this.#widgetRef = widget ? new WeakRef(widget) : undefined\n }\n\n override connect(slot: INodeInputSlot, node: LGraphNode, afterRerouteId?: RerouteId): LLink | undefined {\n const { subgraph } = this.parent\n\n // Allow nodes to block connection\n const inputIndex = node.inputs.indexOf(slot)\n if (node.onConnectInput?.(inputIndex, this.type, this, this.parent, -1) === false) return\n\n // if (slot instanceof SubgraphOutput) {\n // // Subgraph IO nodes have no special handling at present.\n // return new LLink(\n // ++subgraph.state.lastLinkId,\n // this.type,\n // this.parent.id,\n // this.parent.slots.indexOf(this),\n // node.id,\n // inputIndex,\n // afterRerouteId,\n // )\n // }\n\n // Disconnect target input, if it is already connected.\n if (slot.link != null) {\n subgraph.beforeChange()\n const link = subgraph.getLink(slot.link)\n this.parent._disconnectNodeInput(node, slot, link)\n }\n\n const inputWidget = node.getWidgetFromSlot(slot)\n if (inputWidget) {\n if (!this.matchesWidget(inputWidget)) {\n console.warn(\"Target input has invalid widget.\", slot, node)\n return\n }\n\n this._widget ??= inputWidget\n this.events.dispatch(\"input-connected\", { input: slot, widget: inputWidget })\n }\n\n const link = new LLink(\n ++subgraph.state.lastLinkId,\n slot.type,\n this.parent.id,\n this.parent.slots.indexOf(this),\n node.id,\n inputIndex,\n afterRerouteId,\n )\n\n // Add to graph links list\n subgraph._links.set(link.id, link)\n\n // Set link ID in each slot\n this.linkIds.push(link.id)\n slot.link = link.id\n\n // Reroutes\n const reroutes = LLink.getReroutes(subgraph, link)\n for (const reroute of reroutes) {\n reroute.linkIds.add(link.id)\n if (reroute.floating) delete reroute.floating\n reroute._dragging = undefined\n }\n\n // If this is the terminus of a floating link, remove it\n const lastReroute = reroutes.at(-1)\n if (lastReroute) {\n for (const linkId of lastReroute.floatingLinkIds) {\n const link = subgraph.floatingLinks.get(linkId)\n if (link?.parentId === lastReroute.id) {\n subgraph.removeFloatingLink(link)\n }\n }\n }\n subgraph._version++\n\n node.onConnectionsChange?.(\n NodeSlotType.INPUT,\n inputIndex,\n true,\n link,\n slot,\n )\n\n subgraph.afterChange()\n\n return link\n }\n\n get labelPos(): Point {\n const [x, y, , height] = this.boundingRect\n return [x, y + height * 0.5]\n }\n\n getConnectedWidgets(): IBaseWidget[] {\n const { subgraph } = this.parent\n const widgets: IBaseWidget[] = []\n\n for (const linkId of this.linkIds) {\n const link = subgraph.getLink(linkId)\n if (!link) {\n console.error(\"Link not found\", linkId)\n continue\n }\n\n const resolved = link.resolve(subgraph)\n if (resolved.input && resolved.inputNode?.widgets) {\n // Has no widget\n const widgetNamePojo = resolved.input.widget\n if (!widgetNamePojo) continue\n\n // Invalid widget name\n if (!widgetNamePojo.name) {\n console.warn(\"Invalid widget name\", widgetNamePojo)\n continue\n }\n\n const widget = resolved.inputNode.widgets.find(w => w.name === widgetNamePojo.name)\n if (!widget) {\n console.warn(\"Widget not found\", widgetNamePojo)\n continue\n }\n\n widgets.push(widget)\n } else {\n console.debug(\"No input found on link id\", linkId, link)\n }\n }\n return widgets\n }\n\n /**\n * Validates that the connection between the new slot and the existing widget is valid.\n * Used to prevent connections between widgets that are not of the same type.\n * @param otherWidget The widget to compare to.\n * @returns `true` if the connection is valid, otherwise `false`.\n */\n matchesWidget(otherWidget: IBaseWidget): boolean {\n const widget = this.#widgetRef?.deref()\n if (!widget) return true\n\n if (\n otherWidget.type !== widget.type ||\n otherWidget.options.min !== widget.options.min ||\n otherWidget.options.max !== widget.options.max ||\n otherWidget.options.step !== widget.options.step ||\n otherWidget.options.step2 !== widget.options.step2 ||\n otherWidget.options.precision !== widget.options.precision\n ) {\n return false\n }\n\n return true\n }\n\n override disconnect(): void {\n super.disconnect()\n\n this.events.dispatch(\"input-disconnected\", { input: this })\n }\n\n /** For inputs, x is the right edge of the input node. */\n override arrange(rect: ReadOnlyRect): void {\n const [right, top, width, height] = rect\n const { boundingRect: b, pos } = this\n\n b[0] = right - width\n b[1] = top\n b[2] = width\n b[3] = height\n\n pos[0] = right - height * 0.5\n pos[1] = top + height * 0.5\n }\n\n /**\n * Checks if this slot is a valid target for a connection from the given slot.\n * For SubgraphInput (which acts as an output inside the subgraph),\n * the fromSlot should be an input slot.\n */\n override isValidTarget(fromSlot: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput): boolean {\n if (isNodeSlot(fromSlot)) {\n return \"link\" in fromSlot && LiteGraph.isValidConnection(this.type, fromSlot.type)\n }\n\n if (isSubgraphOutput(fromSlot)) {\n return LiteGraph.isValidConnection(this.type, fromSlot.type)\n }\n\n return false\n }\n}\n","import type { SubgraphInputNode } from \"./SubgraphInputNode\"\nimport type { INodeInputSlot, Point } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { RerouteId } from \"@/Reroute\"\n\nimport { LLink } from \"@/LLink\"\nimport { nextUniqueName } from \"@/strings\"\nimport { zeroUuid } from \"@/utils/uuid\"\n\nimport { SubgraphInput } from \"./SubgraphInput\"\n\n/**\n * A virtual slot that simply creates a new input slot when connected to.\n */\nexport class EmptySubgraphInput extends SubgraphInput {\n declare parent: SubgraphInputNode\n\n constructor(parent: SubgraphInputNode) {\n super({\n id: zeroUuid,\n name: \"\",\n type: \"\",\n }, parent)\n }\n\n override connect(slot: INodeInputSlot, node: LGraphNode, afterRerouteId?: RerouteId): LLink | undefined {\n const { subgraph } = this.parent\n const existingNames = subgraph.inputs.map(x => x.name)\n\n const name = nextUniqueName(slot.name, existingNames)\n const input = subgraph.addInput(name, String(slot.type))\n return input.connect(slot, node, afterRerouteId)\n }\n\n override get labelPos(): Point {\n const [x, y, , height] = this.boundingRect\n return [x, y + height * 0.5]\n }\n}\n","import type { SubgraphInput } from \"./SubgraphInput\"\nimport type { SubgraphOutput } from \"./SubgraphOutput\"\nimport type { LinkConnector } from \"@/canvas/LinkConnector\"\nimport type { CanvasPointer } from \"@/CanvasPointer\"\nimport type { DefaultConnectionColors, INodeInputSlot, INodeOutputSlot, ISlotType, Positionable } from \"@/interfaces\"\nimport type { LGraphNode, NodeId } from \"@/LGraphNode\"\nimport type { RerouteId } from \"@/Reroute\"\nimport type { CanvasPointerEvent } from \"@/types/events\"\nimport type { NodeLike } from \"@/types/NodeLike\"\n\nimport { SUBGRAPH_INPUT_ID } from \"@/constants\"\nimport { Rectangle } from \"@/infrastructure/Rectangle\"\nimport { LLink } from \"@/LLink\"\nimport { NodeSlotType } from \"@/types/globalEnums\"\nimport { findFreeSlotOfType } from \"@/utils/collections\"\n\nimport { EmptySubgraphInput } from \"./EmptySubgraphInput\"\nimport { SubgraphIONodeBase } from \"./SubgraphIONodeBase\"\n\nexport class SubgraphInputNode extends SubgraphIONodeBase<SubgraphInput> implements Positionable {\n readonly id: NodeId = SUBGRAPH_INPUT_ID\n\n readonly emptySlot: EmptySubgraphInput = new EmptySubgraphInput(this)\n\n get slots() {\n return this.subgraph.inputs\n }\n\n override get allSlots(): SubgraphInput[] {\n return [...this.slots, this.emptySlot]\n }\n\n get slotAnchorX() {\n const [x, , width] = this.boundingRect\n return x + width - SubgraphIONodeBase.roundedRadius\n }\n\n override onPointerDown(e: CanvasPointerEvent, pointer: CanvasPointer, linkConnector: LinkConnector): void {\n // Left-click handling for dragging connections\n if (e.button === 0) {\n for (const slot of this.allSlots) {\n const slotBounds = Rectangle.fromCentre(slot.pos, slot.boundingRect.height)\n\n if (slotBounds.containsXy(e.canvasX, e.canvasY)) {\n pointer.onDragStart = () => {\n linkConnector.dragNewFromSubgraphInput(this.subgraph, this, slot)\n }\n pointer.onDragEnd = (eUp) => {\n linkConnector.dropLinks(this.subgraph, eUp)\n }\n pointer.finally = () => {\n linkConnector.reset(true)\n }\n }\n }\n // Check for right-click\n } else if (e.button === 2) {\n const slot = this.getSlotInPosition(e.canvasX, e.canvasY)\n if (slot) this.showSlotContextMenu(slot, e)\n }\n }\n\n /** @inheritdoc */\n override renameSlot(slot: SubgraphInput, name: string): void {\n this.subgraph.renameInput(slot, name)\n }\n\n /** @inheritdoc */\n override removeSlot(slot: SubgraphInput): void {\n this.subgraph.removeInput(slot)\n }\n\n canConnectTo(inputNode: NodeLike, input: INodeInputSlot, fromSlot: SubgraphInput): boolean {\n return inputNode.canConnectTo(this, input, fromSlot)\n }\n\n connectSlots(fromSlot: SubgraphInput, inputNode: LGraphNode, input: INodeInputSlot, afterRerouteId: RerouteId | undefined): LLink {\n const { subgraph } = this\n\n const outputIndex = this.slots.indexOf(fromSlot)\n const inputIndex = inputNode.inputs.indexOf(input)\n\n if (outputIndex === -1 || inputIndex === -1) throw new Error(\"Invalid slot indices.\")\n\n return new LLink(\n ++subgraph.state.lastLinkId,\n input.type || fromSlot.type,\n this.id,\n outputIndex,\n inputNode.id,\n inputIndex,\n afterRerouteId,\n )\n }\n\n // #region Legacy LGraphNode compatibility\n\n connectByType(\n slot: number,\n target_node: LGraphNode,\n target_slotType: ISlotType,\n optsIn?: { afterRerouteId?: RerouteId },\n ): LLink | undefined {\n const inputSlot = target_node.findInputByType(target_slotType)\n if (!inputSlot) return\n\n if (slot === -1) {\n // This indicates a connection is being made from the \"Empty\" slot.\n // We need to create a new, concrete input on the subgraph that matches the target.\n const newSubgraphInput = this.subgraph.addInput(inputSlot.slot.name, String(inputSlot.slot.type ?? \"\"))\n const newSlotIndex = this.slots.indexOf(newSubgraphInput)\n if (newSlotIndex === -1) {\n console.error(\"Could not find newly created subgraph input slot.\")\n return\n }\n slot = newSlotIndex\n }\n\n return this.slots[slot].connect(inputSlot.slot, target_node, optsIn?.afterRerouteId)\n }\n\n findOutputSlot(name: string): SubgraphInput | undefined {\n return this.slots.find(output => output.name === name)\n }\n\n findOutputByType(type: ISlotType): SubgraphInput | undefined {\n return findFreeSlotOfType(this.slots, type, slot => slot.linkIds.length > 0)?.slot\n }\n\n // #endregion Legacy LGraphNode compatibility\n\n _disconnectNodeInput(node: LGraphNode, input: INodeInputSlot, link: LLink | undefined): void {\n const { subgraph } = this\n\n // Break floating links\n if (input._floatingLinks?.size) {\n for (const link of input._floatingLinks) {\n subgraph.removeFloatingLink(link)\n }\n }\n\n input.link = null\n subgraph.setDirtyCanvas(false, true)\n\n if (!link) return\n\n const subgraphInputIndex = link.origin_slot\n link.disconnect(subgraph, \"output\")\n subgraph._version++\n\n const subgraphInput = this.slots.at(subgraphInputIndex)\n if (!subgraphInput) {\n console.debug(\"disconnectNodeInput: subgraphInput not found\", this, subgraphInputIndex)\n return\n }\n\n // search in the inputs list for this link\n const index = subgraphInput.linkIds.indexOf(link.id)\n if (index !== -1) {\n subgraphInput.linkIds.splice(index, 1)\n } else {\n console.debug(\"disconnectNodeInput: link ID not found in subgraphInput linkIds\", link.id)\n }\n\n node.onConnectionsChange?.(\n NodeSlotType.OUTPUT,\n index,\n false,\n link,\n subgraphInput,\n )\n }\n\n override drawProtected(ctx: CanvasRenderingContext2D, colorContext: DefaultConnectionColors, fromSlot?: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput, editorAlpha?: number): void {\n const { roundedRadius } = SubgraphIONodeBase\n const transform = ctx.getTransform()\n\n const [x, y, width, height] = this.boundingRect\n ctx.translate(x, y)\n\n // Draw top rounded part\n ctx.strokeStyle = this.sideStrokeStyle\n ctx.lineWidth = this.sideLineWidth\n ctx.beginPath()\n ctx.arc(width - roundedRadius, roundedRadius, roundedRadius, Math.PI * 1.5, 0)\n\n // Straight line to bottom\n ctx.moveTo(width, roundedRadius)\n ctx.lineTo(width, height - roundedRadius)\n\n // Bottom rounded part\n ctx.arc(width - roundedRadius, height - roundedRadius, roundedRadius, 0, Math.PI * 0.5)\n ctx.stroke()\n\n // Restore context\n ctx.setTransform(transform)\n\n this.drawSlots(ctx, colorContext, fromSlot, editorAlpha)\n }\n}\n","import type { RenderLink } from \"./RenderLink\"\nimport type { CustomEventTarget } from \"@/infrastructure/CustomEventTarget\"\nimport type { LinkConnectorEventMap } from \"@/infrastructure/LinkConnectorEventMap\"\nimport type { INodeOutputSlot, LinkNetwork } from \"@/interfaces\"\nimport type { INodeInputSlot } from \"@/interfaces\"\nimport type { Point } from \"@/interfaces\"\nimport type { LGraphNode, NodeId } from \"@/LGraphNode\"\nimport type { LLink } from \"@/LLink\"\nimport type { Reroute } from \"@/Reroute\"\nimport type { SubgraphInput } from \"@/subgraph/SubgraphInput\"\nimport type { SubgraphOutput } from \"@/subgraph/SubgraphOutput\"\n\nimport { SUBGRAPH_INPUT_ID, SUBGRAPH_OUTPUT_ID } from \"@/constants\"\nimport { LinkDirection } from \"@/types/globalEnums\"\n\n/**\n * Represents a floating link that is currently being dragged from one slot to another.\n *\n * This is a heavier, but short-lived convenience data structure. All refs to FloatingRenderLinks should be discarded on drop.\n * @remarks\n * At time of writing, Litegraph is using several different styles and methods to handle link dragging.\n *\n * Once the library has undergone more substantial changes to the way links are managed,\n * many properties of this class will be superfluous and removable.\n */\nexport class FloatingRenderLink implements RenderLink {\n readonly node: LGraphNode\n readonly fromSlot: INodeOutputSlot | INodeInputSlot\n readonly fromPos: Point\n readonly fromDirection: LinkDirection\n readonly fromSlotIndex: number\n\n readonly outputNodeId: NodeId = -1\n readonly outputNode?: LGraphNode\n readonly outputSlot?: INodeOutputSlot\n readonly outputIndex: number = -1\n readonly outputPos?: Point\n\n readonly inputNodeId: NodeId = -1\n readonly inputNode?: LGraphNode\n readonly inputSlot?: INodeInputSlot\n readonly inputIndex: number = -1\n readonly inputPos?: Point\n\n constructor(\n readonly network: LinkNetwork,\n readonly link: LLink,\n readonly toType: \"input\" | \"output\",\n readonly fromReroute: Reroute,\n readonly dragDirection: LinkDirection = LinkDirection.CENTER,\n ) {\n const {\n origin_id: outputNodeId,\n target_id: inputNodeId,\n origin_slot: outputIndex,\n target_slot: inputIndex,\n } = link\n\n if (outputNodeId !== -1) {\n // Output connected\n const outputNode = network.getNodeById(outputNodeId) ?? undefined\n if (!outputNode) throw new Error(`Creating DraggingRenderLink for link [${link.id}] failed: Output node [${outputNodeId}] not found.`)\n\n const outputSlot = outputNode?.outputs.at(outputIndex)\n if (!outputSlot) throw new Error(`Creating DraggingRenderLink for link [${link.id}] failed: Output slot [${outputIndex}] not found.`)\n\n this.outputNodeId = outputNodeId\n this.outputNode = outputNode\n this.outputSlot = outputSlot\n this.outputIndex = outputIndex\n this.outputPos = outputNode.getOutputPos(outputIndex)\n\n // RenderLink props\n this.node = outputNode\n this.fromSlot = outputSlot\n this.fromPos = fromReroute?.pos ?? this.outputPos\n this.fromDirection = LinkDirection.LEFT\n this.dragDirection = LinkDirection.RIGHT\n this.fromSlotIndex = outputIndex\n } else {\n // Input connected\n const inputNode = network.getNodeById(inputNodeId) ?? undefined\n if (!inputNode) throw new Error(`Creating DraggingRenderLink for link [${link.id}] failed: Input node [${inputNodeId}] not found.`)\n\n const inputSlot = inputNode?.inputs.at(inputIndex)\n if (!inputSlot) throw new Error(`Creating DraggingRenderLink for link [${link.id}] failed: Input slot [${inputIndex}] not found.`)\n\n this.inputNodeId = inputNodeId\n this.inputNode = inputNode\n this.inputSlot = inputSlot\n this.inputIndex = inputIndex\n this.inputPos = inputNode.getInputPos(inputIndex)\n\n // RenderLink props\n this.node = inputNode\n this.fromSlot = inputSlot\n this.fromDirection = LinkDirection.RIGHT\n this.fromSlotIndex = inputIndex\n }\n this.fromPos = fromReroute.pos\n }\n\n canConnectToInput(): boolean {\n return this.toType === \"input\"\n }\n\n canConnectToOutput(): boolean {\n return this.toType === \"output\"\n }\n\n canConnectToReroute(reroute: Reroute): boolean {\n if (this.toType === \"input\") {\n if (reroute.origin_id === this.inputNode?.id) return false\n } else {\n if (reroute.origin_id === this.outputNode?.id) return false\n }\n return true\n }\n\n connectToInput(node: LGraphNode, input: INodeInputSlot, _events?: CustomEventTarget<LinkConnectorEventMap>): void {\n const floatingLink = this.link\n floatingLink.target_id = node.id\n floatingLink.target_slot = node.inputs.indexOf(input)\n\n node.disconnectInput(node.inputs.indexOf(input))\n\n this.fromSlot._floatingLinks?.delete(floatingLink)\n input._floatingLinks ??= new Set()\n input._floatingLinks.add(floatingLink)\n }\n\n connectToOutput(node: LGraphNode, output: INodeOutputSlot, _events?: CustomEventTarget<LinkConnectorEventMap>): void {\n const floatingLink = this.link\n floatingLink.origin_id = node.id\n floatingLink.origin_slot = node.outputs.indexOf(output)\n\n this.fromSlot._floatingLinks?.delete(floatingLink)\n output._floatingLinks ??= new Set()\n output._floatingLinks.add(floatingLink)\n }\n\n connectToSubgraphInput(input: SubgraphInput, _events?: CustomEventTarget<LinkConnectorEventMap>): void {\n const floatingLink = this.link\n floatingLink.origin_id = SUBGRAPH_INPUT_ID\n floatingLink.origin_slot = input.parent.slots.indexOf(input)\n\n this.fromSlot._floatingLinks?.delete(floatingLink)\n input._floatingLinks ??= new Set()\n input._floatingLinks.add(floatingLink)\n }\n\n connectToSubgraphOutput(output: SubgraphOutput, _events?: CustomEventTarget<LinkConnectorEventMap>): void {\n const floatingLink = this.link\n floatingLink.origin_id = SUBGRAPH_OUTPUT_ID\n floatingLink.origin_slot = output.parent.slots.indexOf(output)\n\n this.fromSlot._floatingLinks?.delete(floatingLink)\n output._floatingLinks ??= new Set()\n output._floatingLinks.add(floatingLink)\n }\n\n connectToRerouteInput(\n reroute: Reroute,\n { node: inputNode, input }: { node: LGraphNode, input: INodeInputSlot },\n events: CustomEventTarget<LinkConnectorEventMap>,\n ) {\n const floatingLink = this.link\n floatingLink.target_id = inputNode.id\n floatingLink.target_slot = inputNode.inputs.indexOf(input)\n\n this.fromSlot._floatingLinks?.delete(floatingLink)\n input._floatingLinks ??= new Set()\n input._floatingLinks.add(floatingLink)\n\n events.dispatch(\"input-moved\", this)\n }\n\n connectToRerouteOutput(\n reroute: Reroute,\n outputNode: LGraphNode,\n output: INodeOutputSlot,\n events: CustomEventTarget<LinkConnectorEventMap>,\n ) {\n const floatingLink = this.link\n floatingLink.origin_id = outputNode.id\n floatingLink.origin_slot = outputNode.outputs.indexOf(output)\n\n this.fromSlot._floatingLinks?.delete(floatingLink)\n output._floatingLinks ??= new Set()\n output._floatingLinks.add(floatingLink)\n\n events.dispatch(\"output-moved\", this)\n }\n}\n","import type { RenderLink } from \"./RenderLink\"\nimport type { CustomEventTarget } from \"@/infrastructure/CustomEventTarget\"\nimport type { LinkConnectorEventMap } from \"@/infrastructure/LinkConnectorEventMap\"\nimport type { INodeInputSlot, INodeOutputSlot, LinkNetwork, Point } from \"@/interfaces\"\nimport type { LGraphNode, NodeId } from \"@/LGraphNode\"\nimport type { LLink } from \"@/LLink\"\nimport type { Reroute } from \"@/Reroute\"\nimport type { SubgraphInput } from \"@/subgraph/SubgraphInput\"\nimport type { SubgraphOutput } from \"@/subgraph/SubgraphOutput\"\n\nimport { LinkDirection } from \"@/types/globalEnums\"\n\n/**\n * Represents an existing link that is currently being dragged by the user from one slot to another.\n *\n * This is a heavier, but short-lived convenience data structure.\n * All refs to {@link MovingInputLink} and {@link MovingOutputLink} should be discarded on drop.\n * @remarks\n * At time of writing, Litegraph is using several different styles and methods to handle link dragging.\n *\n * Once the library has undergone more substantial changes to the way links are managed,\n * many properties of this class will be superfluous and removable.\n */\n\nexport abstract class MovingLinkBase implements RenderLink {\n abstract readonly node: LGraphNode\n abstract readonly fromSlot: INodeOutputSlot | INodeInputSlot\n abstract readonly fromPos: Point\n abstract readonly fromDirection: LinkDirection\n abstract readonly fromSlotIndex: number\n\n readonly outputNodeId: NodeId\n readonly outputNode: LGraphNode\n readonly outputSlot: INodeOutputSlot\n readonly outputIndex: number\n readonly outputPos: Point\n\n readonly inputNodeId: NodeId\n readonly inputNode: LGraphNode\n readonly inputSlot: INodeInputSlot\n readonly inputIndex: number\n readonly inputPos: Point\n\n constructor(\n readonly network: LinkNetwork,\n readonly link: LLink,\n readonly toType: \"input\" | \"output\",\n readonly fromReroute?: Reroute,\n readonly dragDirection: LinkDirection = LinkDirection.CENTER,\n ) {\n const {\n origin_id: outputNodeId,\n target_id: inputNodeId,\n origin_slot: outputIndex,\n target_slot: inputIndex,\n } = link\n\n // Store output info\n const outputNode = network.getNodeById(outputNodeId) ?? undefined\n if (!outputNode) throw new Error(`Creating MovingRenderLink for link [${link.id}] failed: Output node [${outputNodeId}] not found.`)\n\n const outputSlot = outputNode.outputs.at(outputIndex)\n if (!outputSlot) throw new Error(`Creating MovingRenderLink for link [${link.id}] failed: Output slot [${outputIndex}] not found.`)\n\n this.outputNodeId = outputNodeId\n this.outputNode = outputNode\n this.outputSlot = outputSlot\n this.outputIndex = outputIndex\n this.outputPos = outputNode.getOutputPos(outputIndex)\n\n // Store input info\n const inputNode = network.getNodeById(inputNodeId) ?? undefined\n if (!inputNode) throw new Error(`Creating DraggingRenderLink for link [${link.id}] failed: Input node [${inputNodeId}] not found.`)\n\n const inputSlot = inputNode.inputs.at(inputIndex)\n if (!inputSlot) throw new Error(`Creating DraggingRenderLink for link [${link.id}] failed: Input slot [${inputIndex}] not found.`)\n\n this.inputNodeId = inputNodeId\n this.inputNode = inputNode\n this.inputSlot = inputSlot\n this.inputIndex = inputIndex\n this.inputPos = inputNode.getInputPos(inputIndex)\n }\n\n abstract connectToInput(node: LGraphNode, input: INodeInputSlot, events?: CustomEventTarget<LinkConnectorEventMap>): void\n abstract connectToOutput(node: LGraphNode, output: INodeOutputSlot, events?: CustomEventTarget<LinkConnectorEventMap>): void\n abstract connectToSubgraphInput(input: SubgraphInput, events?: CustomEventTarget<LinkConnectorEventMap>): void\n abstract connectToSubgraphOutput(output: SubgraphOutput, events?: CustomEventTarget<LinkConnectorEventMap>): void\n abstract connectToRerouteInput(reroute: Reroute, { node, input, link }: { node: LGraphNode, input: INodeInputSlot, link: LLink }, events: CustomEventTarget<LinkConnectorEventMap>, originalReroutes: Reroute[]): void\n abstract connectToRerouteOutput(reroute: Reroute, outputNode: LGraphNode, output: INodeOutputSlot, events: CustomEventTarget<LinkConnectorEventMap>): void\n\n abstract disconnect(): boolean\n}\n","import type { CustomEventTarget } from \"@/infrastructure/CustomEventTarget\"\nimport type { LinkConnectorEventMap } from \"@/infrastructure/LinkConnectorEventMap\"\nimport type { INodeInputSlot, INodeOutputSlot, LinkNetwork, Point } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { LLink } from \"@/LLink\"\nimport type { Reroute } from \"@/Reroute\"\nimport type { SubgraphOutput } from \"@/subgraph/SubgraphOutput\"\nimport type { NodeLike } from \"@/types/NodeLike\"\nimport type { SubgraphIO } from \"@/types/serialisation\"\n\nimport { LinkDirection } from \"@/types/globalEnums\"\n\nimport { MovingLinkBase } from \"./MovingLinkBase\"\n\nexport class MovingInputLink extends MovingLinkBase {\n override readonly toType = \"input\"\n\n readonly node: LGraphNode\n readonly fromSlot: INodeOutputSlot\n readonly fromPos: Point\n readonly fromDirection: LinkDirection\n readonly fromSlotIndex: number\n\n constructor(network: LinkNetwork, link: LLink, fromReroute?: Reroute, dragDirection: LinkDirection = LinkDirection.CENTER) {\n super(network, link, \"input\", fromReroute, dragDirection)\n\n this.node = this.outputNode\n this.fromSlot = this.outputSlot\n this.fromPos = fromReroute?.pos ?? this.outputPos\n this.fromDirection = LinkDirection.NONE\n this.fromSlotIndex = this.outputIndex\n }\n\n canConnectToInput(inputNode: NodeLike, input: INodeInputSlot | SubgraphIO): boolean {\n return this.node.canConnectTo(inputNode, input, this.outputSlot)\n }\n\n canConnectToOutput(): false {\n return false\n }\n\n canConnectToReroute(reroute: Reroute): boolean {\n return reroute.origin_id !== this.inputNode.id\n }\n\n connectToInput(inputNode: LGraphNode, input: INodeInputSlot, events: CustomEventTarget<LinkConnectorEventMap>): LLink | null | undefined {\n if (input === this.inputSlot) return\n\n this.inputNode.disconnectInput(this.inputIndex, true)\n const link = this.outputNode.connectSlots(this.outputSlot, inputNode, input, this.fromReroute?.id)\n if (link) events.dispatch(\"input-moved\", this)\n return link\n }\n\n connectToOutput(): never {\n throw new Error(\"MovingInputLink cannot connect to an output.\")\n }\n\n connectToSubgraphInput(): void {\n throw new Error(\"MovingInputLink cannot connect to a subgraph input.\")\n }\n\n connectToSubgraphOutput(output: SubgraphOutput, events?: CustomEventTarget<LinkConnectorEventMap>): void {\n const newLink = output.connect(this.fromSlot, this.node, this.fromReroute?.id)\n events?.dispatch(\"link-created\", newLink)\n }\n\n connectToRerouteInput(\n reroute: Reroute,\n { node: inputNode, input, link: existingLink }: { node: LGraphNode, input: INodeInputSlot, link: LLink },\n events: CustomEventTarget<LinkConnectorEventMap>,\n originalReroutes: Reroute[],\n ): void {\n const { outputNode, outputSlot, fromReroute } = this\n\n // Clean up reroutes\n for (const reroute of originalReroutes) {\n if (reroute.id === this.link.parentId) break\n\n if (reroute.totalLinks === 1) reroute.remove()\n }\n // Set the parentId of the reroute we dropped on, to the reroute we dragged from\n reroute.parentId = fromReroute?.id\n\n const newLink = outputNode.connectSlots(outputSlot, inputNode, input, existingLink.parentId)\n if (newLink) events.dispatch(\"input-moved\", this)\n }\n\n connectToRerouteOutput(): never {\n throw new Error(\"MovingInputLink cannot connect to an output.\")\n }\n\n disconnect(): boolean {\n return this.inputNode.disconnectInput(this.inputIndex, true)\n }\n}\n","import type { CustomEventTarget } from \"@/infrastructure/CustomEventTarget\"\nimport type { LinkConnectorEventMap } from \"@/infrastructure/LinkConnectorEventMap\"\nimport type { INodeInputSlot, INodeOutputSlot, LinkNetwork, Point } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { LLink } from \"@/LLink\"\nimport type { Reroute } from \"@/Reroute\"\nimport type { SubgraphInput } from \"@/subgraph/SubgraphInput\"\nimport type { NodeLike } from \"@/types/NodeLike\"\nimport type { SubgraphIO } from \"@/types/serialisation\"\n\nimport { LinkDirection } from \"@/types/globalEnums\"\n\nimport { MovingLinkBase } from \"./MovingLinkBase\"\n\nexport class MovingOutputLink extends MovingLinkBase {\n override readonly toType = \"output\"\n\n readonly node: LGraphNode\n readonly fromSlot: INodeInputSlot\n readonly fromPos: Point\n readonly fromDirection: LinkDirection\n readonly fromSlotIndex: number\n\n constructor(network: LinkNetwork, link: LLink, fromReroute?: Reroute, dragDirection: LinkDirection = LinkDirection.CENTER) {\n super(network, link, \"output\", fromReroute, dragDirection)\n\n this.node = this.inputNode\n this.fromSlot = this.inputSlot\n this.fromPos = fromReroute?.pos ?? this.inputPos\n this.fromDirection = LinkDirection.LEFT\n this.fromSlotIndex = this.inputIndex\n }\n\n canConnectToInput(): false {\n return false\n }\n\n canConnectToOutput(outputNode: NodeLike, output: INodeOutputSlot | SubgraphIO): boolean {\n return outputNode.canConnectTo(this.node, this.inputSlot, output)\n }\n\n canConnectToReroute(reroute: Reroute): boolean {\n return reroute.origin_id !== this.outputNode.id\n }\n\n connectToInput(): never {\n throw new Error(\"MovingOutputLink cannot connect to an input.\")\n }\n\n connectToOutput(outputNode: LGraphNode, output: INodeOutputSlot, events: CustomEventTarget<LinkConnectorEventMap>): LLink | null | undefined {\n if (output === this.outputSlot) return\n\n const link = outputNode.connectSlots(output, this.inputNode, this.inputSlot, this.link.parentId)\n if (link) events.dispatch(\"output-moved\", this)\n return link\n }\n\n connectToSubgraphInput(input: SubgraphInput, events?: CustomEventTarget<LinkConnectorEventMap>): void {\n const newLink = input.connect(this.fromSlot, this.node, this.fromReroute?.id)\n events?.dispatch(\"link-created\", newLink)\n }\n\n connectToSubgraphOutput(): void {\n throw new Error(\"MovingOutputLink cannot connect to a subgraph output.\")\n }\n\n connectToRerouteInput(): never {\n throw new Error(\"MovingOutputLink cannot connect to an input.\")\n }\n\n connectToRerouteOutput(\n reroute: Reroute,\n outputNode: LGraphNode,\n output: INodeOutputSlot,\n events: CustomEventTarget<LinkConnectorEventMap>,\n ): void {\n // Moving output side of links\n const { inputNode, inputSlot, fromReroute } = this\n\n // Creating a new link removes floating prop - check before connecting\n const floatingTerminus = reroute?.floating?.slotType === \"output\"\n\n // Connect the first reroute of the link being dragged to the reroute being dropped on\n if (fromReroute) {\n fromReroute.parentId = reroute.id\n } else {\n // If there are no reroutes, directly connect the link\n this.link.parentId = reroute.id\n }\n // Use the last reroute id on the link to retain all reroutes\n outputNode.connectSlots(output, inputNode, inputSlot, this.link.parentId)\n\n // Connecting from the final reroute of a floating reroute chain\n if (floatingTerminus) reroute.removeAllFloatingLinks()\n\n events.dispatch(\"output-moved\", this)\n }\n\n disconnect(): boolean {\n return this.outputNode.disconnectOutput(this.outputIndex, this.inputNode)\n }\n}\n","import type { RenderLink } from \"./RenderLink\"\nimport type { CustomEventTarget } from \"@/infrastructure/CustomEventTarget\"\nimport type { LinkConnectorEventMap } from \"@/infrastructure/LinkConnectorEventMap\"\nimport type { INodeInputSlot, LinkNetwork, Point } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { LLink } from \"@/LLink\"\nimport type { Reroute } from \"@/Reroute\"\nimport type { SubgraphInput } from \"@/subgraph/SubgraphInput\"\nimport type { SubgraphInputNode } from \"@/subgraph/SubgraphInputNode\"\nimport type { NodeLike } from \"@/types/NodeLike\"\n\nimport { LinkDirection } from \"@/types/globalEnums\"\n\n/** Connecting TO an input slot. */\n\nexport class ToInputFromIoNodeLink implements RenderLink {\n readonly toType = \"input\"\n readonly fromSlotIndex: number\n readonly fromPos: Point\n fromDirection: LinkDirection = LinkDirection.RIGHT\n readonly existingLink?: LLink\n\n constructor(\n readonly network: LinkNetwork,\n readonly node: SubgraphInputNode,\n readonly fromSlot: SubgraphInput,\n readonly fromReroute?: Reroute,\n public dragDirection: LinkDirection = LinkDirection.CENTER,\n existingLink?: LLink,\n ) {\n const outputIndex = node.slots.indexOf(fromSlot)\n if (outputIndex === -1 && fromSlot !== node.emptySlot) {\n throw new Error(`Creating render link for node [${this.node.id}] failed: Slot index not found.`)\n }\n\n this.fromSlotIndex = outputIndex\n this.fromPos = fromReroute\n ? fromReroute.pos\n : fromSlot.pos\n this.existingLink = existingLink\n }\n\n canConnectToInput(inputNode: NodeLike, input: INodeInputSlot): boolean {\n return this.node.canConnectTo(inputNode, input, this.fromSlot)\n }\n\n canConnectToOutput(): false {\n return false\n }\n\n connectToInput(node: LGraphNode, input: INodeInputSlot, events: CustomEventTarget<LinkConnectorEventMap>) {\n const { fromSlot, fromReroute, existingLink } = this\n\n const newLink = fromSlot.connect(input, node, fromReroute?.id)\n\n if (existingLink) {\n // Moving an existing link\n events.dispatch(\"input-moved\", this)\n } else {\n // Creating a new link\n events.dispatch(\"link-created\", newLink)\n }\n }\n\n connectToSubgraphOutput(): void {\n throw new Error(\"Not implemented\")\n }\n\n connectToRerouteInput(\n reroute: Reroute,\n {\n node: inputNode,\n input,\n link,\n }: { node: LGraphNode, input: INodeInputSlot, link: LLink },\n events: CustomEventTarget<LinkConnectorEventMap>,\n originalReroutes: Reroute[],\n ) {\n const { fromSlot, fromReroute } = this\n\n // Check before creating new link overwrites the value\n const floatingTerminus = fromReroute?.floating?.slotType === \"output\"\n\n // Set the parentId of the reroute we dropped on, to the reroute we dragged from\n reroute.parentId = fromReroute?.id\n\n const newLink = fromSlot.connect(input, inputNode, link.parentId)\n\n // Connecting from the final reroute of a floating reroute chain\n if (floatingTerminus) fromReroute.removeAllFloatingLinks()\n\n // Clean up reroutes\n for (const reroute of originalReroutes) {\n if (reroute.id === fromReroute?.id) break\n\n reroute.removeLink(link)\n if (reroute.totalLinks === 0) {\n if (link.isFloating) {\n // Cannot float from both sides - remove\n reroute.remove()\n } else {\n // Convert to floating\n const cl = link.toFloating(\"output\", reroute.id)\n this.network.addFloatingLink(cl)\n reroute.floating = { slotType: \"output\" }\n }\n }\n }\n\n if (this.existingLink) {\n // Moving an existing link\n events.dispatch(\"input-moved\", this)\n } else {\n // Creating a new link\n events.dispatch(\"link-created\", newLink)\n }\n }\n\n connectToOutput() {\n throw new Error(\"ToInputRenderLink cannot connect to an output.\")\n }\n\n connectToSubgraphInput(): void {\n throw new Error(\"ToInputRenderLink cannot connect to a subgraph input.\")\n }\n\n connectToRerouteOutput() {\n throw new Error(\"ToInputRenderLink cannot connect to an output.\")\n }\n}\n","import type { RenderLink } from \"./RenderLink\"\nimport type { CustomEventTarget } from \"@/infrastructure/CustomEventTarget\"\nimport type { LinkConnectorEventMap } from \"@/infrastructure/LinkConnectorEventMap\"\nimport type { INodeInputSlot, INodeOutputSlot, LinkNetwork, Point } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { LLink } from \"@/LLink\"\nimport type { Reroute } from \"@/Reroute\"\nimport type { SubgraphOutput } from \"@/subgraph/SubgraphOutput\"\nimport type { NodeLike } from \"@/types/NodeLike\"\n\nimport { LinkDirection } from \"@/types/globalEnums\"\n\n/** Connecting TO an input slot. */\n\nexport class ToInputRenderLink implements RenderLink {\n readonly toType = \"input\"\n readonly fromPos: Point\n readonly fromSlotIndex: number\n fromDirection: LinkDirection = LinkDirection.RIGHT\n\n constructor(\n readonly network: LinkNetwork,\n readonly node: LGraphNode,\n readonly fromSlot: INodeOutputSlot,\n readonly fromReroute?: Reroute,\n public dragDirection: LinkDirection = LinkDirection.CENTER,\n ) {\n const outputIndex = node.outputs.indexOf(fromSlot)\n if (outputIndex === -1) throw new Error(`Creating render link for node [${this.node.id}] failed: Slot index not found.`)\n\n this.fromSlotIndex = outputIndex\n this.fromPos = fromReroute\n ? fromReroute.pos\n : this.node.getOutputPos(outputIndex)\n }\n\n canConnectToInput(inputNode: NodeLike, input: INodeInputSlot): boolean {\n return this.node.canConnectTo(inputNode, input, this.fromSlot)\n }\n\n canConnectToOutput(): false {\n return false\n }\n\n connectToInput(node: LGraphNode, input: INodeInputSlot, events: CustomEventTarget<LinkConnectorEventMap>) {\n const { node: outputNode, fromSlot, fromReroute } = this\n if (node === outputNode) return\n\n const newLink = outputNode.connectSlots(fromSlot, node, input, fromReroute?.id)\n events.dispatch(\"link-created\", newLink)\n }\n\n connectToSubgraphOutput(output: SubgraphOutput, events: CustomEventTarget<LinkConnectorEventMap>) {\n const newLink = output.connect(this.fromSlot, this.node, this.fromReroute?.id)\n events.dispatch(\"link-created\", newLink)\n }\n\n connectToRerouteInput(\n reroute: Reroute,\n {\n node: inputNode,\n input,\n link,\n }: { node: LGraphNode, input: INodeInputSlot, link: LLink },\n events: CustomEventTarget<LinkConnectorEventMap>,\n originalReroutes: Reroute[],\n ) {\n const { node: outputNode, fromSlot, fromReroute } = this\n\n // Check before creating new link overwrites the value\n const floatingTerminus = fromReroute?.floating?.slotType === \"output\"\n\n // Set the parentId of the reroute we dropped on, to the reroute we dragged from\n reroute.parentId = fromReroute?.id\n\n const newLink = outputNode.connectSlots(fromSlot, inputNode, input, link.parentId)\n\n // Connecting from the final reroute of a floating reroute chain\n if (floatingTerminus) fromReroute.removeAllFloatingLinks()\n\n // Clean up reroutes\n for (const reroute of originalReroutes) {\n if (reroute.id === fromReroute?.id) break\n\n reroute.removeLink(link)\n if (reroute.totalLinks === 0) {\n if (link.isFloating) {\n // Cannot float from both sides - remove\n reroute.remove()\n } else {\n // Convert to floating\n const cl = link.toFloating(\"output\", reroute.id)\n this.network.addFloatingLink(cl)\n reroute.floating = { slotType: \"output\" }\n }\n }\n }\n events.dispatch(\"link-created\", newLink)\n }\n\n connectToOutput() {\n throw new Error(\"ToInputRenderLink cannot connect to an output.\")\n }\n\n connectToSubgraphInput(): void {\n throw new Error(\"ToInputRenderLink cannot connect to a subgraph input.\")\n }\n\n connectToRerouteOutput() {\n throw new Error(\"ToInputRenderLink cannot connect to an output.\")\n }\n}\n","import type { RenderLink } from \"./RenderLink\"\nimport type { CustomEventTarget } from \"@/infrastructure/CustomEventTarget\"\nimport type { LinkConnectorEventMap } from \"@/infrastructure/LinkConnectorEventMap\"\nimport type { INodeOutputSlot, LinkNetwork, Point } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { Reroute } from \"@/Reroute\"\nimport type { SubgraphOutput } from \"@/subgraph/SubgraphOutput\"\nimport type { SubgraphOutputNode } from \"@/subgraph/SubgraphOutputNode\"\nimport type { NodeLike } from \"@/types/NodeLike\"\nimport type { SubgraphIO } from \"@/types/serialisation\"\n\nimport { LinkDirection } from \"@/types/globalEnums\"\n\n/** Connecting TO an output slot. */\n\nexport class ToOutputFromIoNodeLink implements RenderLink {\n readonly toType = \"output\"\n readonly fromPos: Point\n readonly fromSlotIndex: number\n fromDirection: LinkDirection = LinkDirection.LEFT\n\n constructor(\n readonly network: LinkNetwork,\n readonly node: SubgraphOutputNode,\n readonly fromSlot: SubgraphOutput,\n readonly fromReroute?: Reroute,\n public dragDirection: LinkDirection = LinkDirection.CENTER,\n ) {\n const inputIndex = node.slots.indexOf(fromSlot)\n if (inputIndex === -1 && fromSlot !== node.emptySlot) {\n throw new Error(`Creating render link for node [${this.node.id}] failed: Slot index not found.`)\n }\n\n this.fromSlotIndex = inputIndex\n this.fromPos = fromReroute\n ? fromReroute.pos\n : fromSlot.pos\n }\n\n canConnectToInput(): false {\n return false\n }\n\n canConnectToOutput(outputNode: NodeLike, output: INodeOutputSlot | SubgraphIO): boolean {\n return this.node.canConnectTo(outputNode, this.fromSlot, output)\n }\n\n canConnectToReroute(reroute: Reroute): boolean {\n if (reroute.origin_id === this.node.id) return false\n return true\n }\n\n connectToOutput(node: LGraphNode, output: INodeOutputSlot, events: CustomEventTarget<LinkConnectorEventMap>) {\n const { fromSlot, fromReroute } = this\n\n const newLink = fromSlot.connect(output, node, fromReroute?.id)\n events.dispatch(\"link-created\", newLink)\n }\n\n connectToSubgraphInput(): void {\n throw new Error(\"Not implemented\")\n }\n\n connectToRerouteOutput(\n reroute: Reroute,\n outputNode: LGraphNode,\n output: INodeOutputSlot,\n events: CustomEventTarget<LinkConnectorEventMap>,\n ): void {\n const { fromSlot } = this\n\n const newLink = fromSlot.connect(output, outputNode, reroute?.id)\n events.dispatch(\"link-created\", newLink)\n }\n\n connectToInput() {\n throw new Error(\"ToOutputRenderLink cannot connect to an input.\")\n }\n\n connectToSubgraphOutput(): void {\n throw new Error(\"ToOutputRenderLink cannot connect to a subgraph output.\")\n }\n\n connectToRerouteInput() {\n throw new Error(\"ToOutputRenderLink cannot connect to an input.\")\n }\n}\n","import type { RenderLink } from \"./RenderLink\"\nimport type { CustomEventTarget } from \"@/infrastructure/CustomEventTarget\"\nimport type { LinkConnectorEventMap } from \"@/infrastructure/LinkConnectorEventMap\"\nimport type { INodeInputSlot, INodeOutputSlot, LinkNetwork, Point } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { Reroute } from \"@/Reroute\"\nimport type { SubgraphInput } from \"@/subgraph/SubgraphInput\"\nimport type { NodeLike } from \"@/types/NodeLike\"\nimport type { SubgraphIO } from \"@/types/serialisation\"\n\nimport { LinkDirection } from \"@/types/globalEnums\"\n\n/** Connecting TO an output slot. */\n\nexport class ToOutputRenderLink implements RenderLink {\n readonly toType = \"output\"\n readonly fromPos: Point\n readonly fromSlotIndex: number\n fromDirection: LinkDirection = LinkDirection.LEFT\n\n constructor(\n readonly network: LinkNetwork,\n readonly node: LGraphNode,\n readonly fromSlot: INodeInputSlot,\n readonly fromReroute?: Reroute,\n public dragDirection: LinkDirection = LinkDirection.CENTER,\n ) {\n const inputIndex = node.inputs.indexOf(fromSlot)\n if (inputIndex === -1) throw new Error(`Creating render link for node [${this.node.id}] failed: Slot index not found.`)\n\n this.fromSlotIndex = inputIndex\n this.fromPos = fromReroute\n ? fromReroute.pos\n : this.node.getInputPos(inputIndex)\n }\n\n canConnectToInput(): false {\n return false\n }\n\n canConnectToOutput(outputNode: NodeLike, output: INodeOutputSlot | SubgraphIO): boolean {\n return this.node.canConnectTo(outputNode, this.fromSlot, output)\n }\n\n canConnectToReroute(reroute: Reroute): boolean {\n if (reroute.origin_id === this.node.id) return false\n return true\n }\n\n connectToOutput(node: LGraphNode, output: INodeOutputSlot, events: CustomEventTarget<LinkConnectorEventMap>) {\n const { node: inputNode, fromSlot, fromReroute } = this\n if (!inputNode) return\n\n const newLink = node.connectSlots(output, inputNode, fromSlot, fromReroute?.id)\n events.dispatch(\"link-created\", newLink)\n }\n\n connectToSubgraphInput(input: SubgraphInput, events?: CustomEventTarget<LinkConnectorEventMap>): void {\n const newLink = input.connect(this.fromSlot, this.node, this.fromReroute?.id)\n events?.dispatch(\"link-created\", newLink)\n }\n\n connectToRerouteOutput(\n reroute: Reroute,\n outputNode: LGraphNode,\n output: INodeOutputSlot,\n events: CustomEventTarget<LinkConnectorEventMap>,\n ): void {\n const { node: inputNode, fromSlot } = this\n const newLink = outputNode.connectSlots(output, inputNode, fromSlot, reroute?.id)\n events.dispatch(\"link-created\", newLink)\n }\n\n connectToInput() {\n throw new Error(\"ToOutputRenderLink cannot connect to an input.\")\n }\n\n connectToSubgraphOutput(): void {\n throw new Error(\"ToOutputRenderLink cannot connect to a subgraph output.\")\n }\n\n connectToRerouteInput() {\n throw new Error(\"ToOutputRenderLink cannot connect to an input.\")\n }\n}\n","import type { LinkConnector } from \"./LinkConnector\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { INodeInputSlot, INodeOutputSlot, LinkNetwork } from \"@/litegraph\"\nimport type { Reroute } from \"@/Reroute\"\n\nimport { ToInputRenderLink } from \"./ToInputRenderLink\"\nimport { ToOutputRenderLink } from \"./ToOutputRenderLink\"\n\n/**\n * @internal A workaround class to support connecting to reroutes to node outputs.\n */\nexport class ToOutputFromRerouteLink extends ToOutputRenderLink {\n constructor(\n network: LinkNetwork,\n node: LGraphNode,\n fromSlot: INodeInputSlot,\n override readonly fromReroute: Reroute,\n readonly linkConnector: LinkConnector,\n ) {\n super(network, node, fromSlot, fromReroute)\n }\n\n override canConnectToReroute(): false {\n return false\n }\n\n override connectToOutput(node: LGraphNode, output: INodeOutputSlot) {\n const nuRenderLink = new ToInputRenderLink(this.network, node, output)\n this.linkConnector._connectOutputToReroute(this.fromReroute, nuRenderLink)\n }\n}\n","import type { RenderLink } from \"./RenderLink\"\nimport type { LinkConnectorEventMap } from \"@/infrastructure/LinkConnectorEventMap\"\nimport type { ConnectingLink, ItemLocator, LinkNetwork, LinkSegment } from \"@/interfaces\"\nimport type { INodeInputSlot, INodeOutputSlot } from \"@/interfaces\"\nimport type { LGraphNode } from \"@/LGraphNode\"\nimport type { Reroute } from \"@/Reroute\"\nimport type { SubgraphInput } from \"@/subgraph/SubgraphInput\"\nimport type { SubgraphOutput } from \"@/subgraph/SubgraphOutput\"\nimport type { CanvasPointerEvent } from \"@/types/events\"\nimport type { IBaseWidget } from \"@/types/widgets\"\n\nimport { SUBGRAPH_INPUT_ID, SUBGRAPH_OUTPUT_ID } from \"@/constants\"\nimport { CustomEventTarget } from \"@/infrastructure/CustomEventTarget\"\nimport { LLink } from \"@/LLink\"\nimport { Subgraph } from \"@/subgraph/Subgraph\"\nimport { SubgraphInputNode } from \"@/subgraph/SubgraphInputNode\"\nimport { SubgraphOutputNode } from \"@/subgraph/SubgraphOutputNode\"\nimport { LinkDirection } from \"@/types/globalEnums\"\n\nimport { FloatingRenderLink } from \"./FloatingRenderLink\"\nimport { MovingInputLink } from \"./MovingInputLink\"\nimport { MovingLinkBase } from \"./MovingLinkBase\"\nimport { MovingOutputLink } from \"./MovingOutputLink\"\nimport { ToInputFromIoNodeLink } from \"./ToInputFromIoNodeLink\"\nimport { ToInputRenderLink } from \"./ToInputRenderLink\"\nimport { ToOutputFromIoNodeLink } from \"./ToOutputFromIoNodeLink\"\nimport { ToOutputFromRerouteLink } from \"./ToOutputFromRerouteLink\"\nimport { ToOutputRenderLink } from \"./ToOutputRenderLink\"\n\n/**\n * A Litegraph state object for the {@link LinkConnector}.\n * References are only held atomically within a function, never passed.\n * The concrete implementation may be replaced or proxied without side-effects.\n */\nexport interface LinkConnectorState {\n /**\n * The type of slot that links are being connected **to**.\n * - When `undefined`, no operation is being performed.\n * - A change in this property indicates the start or end of dragging links.\n */\n connectingTo: \"input\" | \"output\" | undefined\n multi: boolean\n /** When `true`, existing links are being repositioned. Otherwise, new links are being created. */\n draggingExistingLinks: boolean\n /** When set, connecting links will all snap to this position. */\n snapLinksPos?: [number, number]\n}\n\n/** Discriminated union to simplify type narrowing. */\ntype RenderLinkUnion =\n | MovingInputLink\n | MovingOutputLink\n | FloatingRenderLink\n | ToInputRenderLink\n | ToOutputRenderLink\n | ToInputFromIoNodeLink\n | ToOutputFromIoNodeLink\n\nexport interface LinkConnectorExport {\n renderLinks: RenderLink[]\n inputLinks: LLink[]\n outputLinks: LLink[]\n floatingLinks: LLink[]\n state: LinkConnectorState\n network: LinkNetwork\n}\n\n/**\n * Component of {@link LGraphCanvas} that handles connecting and moving links.\n * @see {@link LLink}\n */\nexport class LinkConnector {\n /**\n * Link connection state POJO. Source of truth for state of link drag operations.\n *\n * Can be replaced or proxied to allow notifications.\n * Is always dereferenced at the start of an operation.\n */\n state: LinkConnectorState = {\n connectingTo: undefined,\n multi: false,\n draggingExistingLinks: false,\n snapLinksPos: undefined,\n }\n\n readonly events = new CustomEventTarget<LinkConnectorEventMap>()\n\n /** Contains information for rendering purposes only. */\n readonly renderLinks: RenderLinkUnion[] = []\n\n /** Existing links that are being moved **to** a new input slot. */\n readonly inputLinks: LLink[] = []\n /** Existing links that are being moved **to** a new output slot. */\n readonly outputLinks: LLink[] = []\n /** Existing floating links that are being moved to a new slot. */\n readonly floatingLinks: LLink[] = []\n\n readonly hiddenReroutes: Set<Reroute> = new Set()\n\n /** The widget beneath the pointer, if it is a valid connection target. */\n overWidget?: IBaseWidget\n /** The type (returned by downstream callback) for {@link overWidget} */\n overWidgetType?: string\n\n /** The reroute beneath the pointer, if it is a valid connection target. */\n overReroute?: Reroute\n\n readonly #setConnectingLinks: (value: ConnectingLink[]) => void\n\n constructor(setConnectingLinks: (value: ConnectingLink[]) => void) {\n this.#setConnectingLinks = setConnectingLinks\n }\n\n get isConnecting() {\n return this.state.connectingTo !== undefined\n }\n\n get draggingExistingLinks() {\n return this.state.draggingExistingLinks\n }\n\n /** Drag an existing link to a different input. */\n moveInputLink(network: LinkNetwork, input: INodeInputSlot): void {\n if (this.isConnecting) throw new Error(\"Already dragging links.\")\n\n const { state, inputLinks, renderLinks } = this\n\n const linkId = input.link\n if (linkId == null) {\n // No link connected, check for a floating link\n const floatingLink = input._floatingLinks?.values().next().value\n if (floatingLink?.parentId == null) return\n\n try {\n const reroute = network.reroutes.get(floatingLink.parentId)\n if (!reroute) throw new Error(`Invalid reroute id: [${floatingLink.parentId}] for floating link id: [${floatingLink.id}].`)\n\n const renderLink = new FloatingRenderLink(network, floatingLink, \"input\", reroute)\n const mayContinue = this.events.dispatch(\"before-move-input\", renderLink)\n if (mayContinue === false) return\n\n renderLinks.push(renderLink)\n } catch (error) {\n console.warn(`Could not create render link for link id: [${floatingLink.id}].`, floatingLink, error)\n }\n\n floatingLink._dragging = true\n this.floatingLinks.push(floatingLink)\n } else {\n const link = network.links.get(linkId)\n if (!link) return\n\n // Special handling for links from subgraph input nodes\n if (link.origin_id === SUBGRAPH_INPUT_ID) {\n // For subgraph input links, we need to handle them differently\n // since they don't have a regular output node\n const subgraphInput = network.inputNode?.slots[link.origin_slot]\n if (!subgraphInput) {\n console.warn(`Could not find subgraph input for slot [${link.origin_slot}]`)\n return\n }\n\n try {\n const reroute = network.getReroute(link.parentId)\n const renderLink = new ToInputFromIoNodeLink(network, network.inputNode, subgraphInput, reroute, LinkDirection.CENTER, link)\n\n // Note: We don't dispatch the before-move-input event for subgraph input links\n // as the event type doesn't support ToInputFromIoNodeLink\n\n renderLinks.push(renderLink)\n\n this.listenUntilReset(\"input-moved\", () => {\n link.disconnect(network, \"input\")\n })\n } catch (error) {\n console.warn(`Could not create render link for subgraph input link id: [${link.id}].`, link, error)\n return\n }\n\n link._dragging = true\n inputLinks.push(link)\n } else {\n // Regular node links\n try {\n const reroute = network.getReroute(link.parentId)\n const renderLink = new MovingInputLink(network, link, reroute)\n\n const mayContinue = this.events.dispatch(\"before-move-input\", renderLink)\n if (mayContinue === false) return\n\n renderLinks.push(renderLink)\n\n this.listenUntilReset(\"input-moved\", (e) => {\n if (\"link\" in e.detail && e.detail.link) {\n e.detail.link.disconnect(network, \"output\")\n }\n })\n } catch (error) {\n console.warn(`Could not create render link for link id: [${link.id}].`, link, error)\n return\n }\n\n link._dragging = true\n inputLinks.push(link)\n }\n }\n\n state.connectingTo = \"input\"\n state.draggingExistingLinks = true\n\n this.#setLegacyLinks(false)\n }\n\n /** Drag all links from an output to a new output. */\n moveOutputLink(network: LinkNetwork, output: INodeOutputSlot): void {\n if (this.isConnecting) throw new Error(\"Already dragging links.\")\n\n const { state, renderLinks } = this\n\n // Floating links\n if (output._floatingLinks?.size) {\n for (const floatingLink of output._floatingLinks.values()) {\n try {\n const reroute = LLink.getFirstReroute(network, floatingLink)\n if (!reroute) throw new Error(`Invalid reroute id: [${floatingLink.parentId}] for floating link id: [${floatingLink.id}].`)\n\n const renderLink = new FloatingRenderLink(network, floatingLink, \"output\", reroute)\n const mayContinue = this.events.dispatch(\"before-move-output\", renderLink)\n if (mayContinue === false) continue\n\n renderLinks.push(renderLink)\n this.floatingLinks.push(floatingLink)\n } catch (error) {\n console.warn(`Could not create render link for link id: [${floatingLink.id}].`, floatingLink, error)\n }\n }\n }\n\n // Normal links\n if (output.links?.length) {\n for (const linkId of output.links) {\n const link = network.links.get(linkId)\n if (!link) continue\n\n const firstReroute = LLink.getFirstReroute(network, link)\n if (firstReroute) {\n firstReroute._dragging = true\n this.hiddenReroutes.add(firstReroute)\n } else {\n link._dragging = true\n }\n this.outputLinks.push(link)\n\n try {\n const renderLink = new MovingOutputLink(network, link, firstReroute, LinkDirection.RIGHT)\n\n const mayContinue = this.events.dispatch(\"before-move-output\", renderLink)\n if (mayContinue === false) continue\n\n renderLinks.push(renderLink)\n } catch (error) {\n console.warn(`Could not create render link for link id: [${link.id}].`, link, error)\n continue\n }\n }\n }\n\n if (renderLinks.length === 0) return\n\n state.draggingExistingLinks = true\n state.multi = true\n state.connectingTo = \"output\"\n\n this.#setLegacyLinks(true)\n }\n\n /**\n * Drags a new link from an output slot to an input slot.\n * @param network The network that the link being connected belongs to\n * @param node The node the link is being dragged from\n * @param output The output slot that the link is being dragged from\n */\n dragNewFromOutput(network: LinkNetwork, node: LGraphNode, output: INodeOutputSlot, fromReroute?: Reroute): void {\n if (this.isConnecting) throw new Error(\"Already dragging links.\")\n\n const { state } = this\n const renderLink = new ToInputRenderLink(network, node, output, fromReroute)\n this.renderLinks.push(renderLink)\n\n state.connectingTo = \"input\"\n\n this.#setLegacyLinks(false)\n }\n\n /**\n * Drags a new link from an input slot to an output slot.\n * @param network The network that the link being connected belongs to\n * @param node The node the link is being dragged from\n * @param input The input slot that the link is being dragged from\n */\n dragNewFromInput(network: LinkNetwork, node: LGraphNode, input: INodeInputSlot, fromReroute?: Reroute): void {\n if (this.isConnecting) throw new Error(\"Already dragging links.\")\n\n const { state } = this\n const renderLink = new ToOutputRenderLink(network, node, input, fromReroute)\n this.renderLinks.push(renderLink)\n\n state.connectingTo = \"output\"\n\n this.#setLegacyLinks(true)\n }\n\n dragNewFromSubgraphInput(network: LinkNetwork, inputNode: SubgraphInputNode, input: SubgraphInput, fromReroute?: Reroute): void {\n if (this.isConnecting) throw new Error(\"Already dragging links.\")\n\n const renderLink = new ToInputFromIoNodeLink(network, inputNode, input, fromReroute)\n this.renderLinks.push(renderLink)\n\n this.state.connectingTo = \"input\"\n\n this.#setLegacyLinks(false)\n }\n\n dragNewFromSubgraphOutput(network: LinkNetwork, outputNode: SubgraphOutputNode, output: SubgraphOutput, fromReroute?: Reroute): void {\n if (this.isConnecting) throw new Error(\"Already dragging links.\")\n\n const renderLink = new ToOutputFromIoNodeLink(network, outputNode, output, fromReroute)\n this.renderLinks.push(renderLink)\n\n this.state.connectingTo = \"output\"\n\n this.#setLegacyLinks(true)\n }\n\n /**\n * Drags a new link from a reroute to an input slot.\n * @param network The network that the link being connected belongs to\n * @param reroute The reroute that the link is being dragged from\n */\n dragFromReroute(network: LinkNetwork, reroute: Reroute): void {\n if (this.isConnecting) throw new Error(\"Already dragging links.\")\n\n const link = reroute.firstLink ?? reroute.firstFloatingLink\n if (!link) {\n console.warn(\"No link found for reroute.\")\n return\n }\n\n if (link.origin_id === SUBGRAPH_INPUT_ID) {\n if (!(network instanceof Subgraph)) {\n console.warn(\"Subgraph input link found in non-subgraph network.\")\n return\n }\n\n const input = network.inputs.at(link.origin_slot)\n if (!input) throw new Error(\"No subgraph input found for link.\")\n\n const renderLink = new ToInputFromIoNodeLink(network, network.inputNode, input, reroute)\n renderLink.fromDirection = LinkDirection.NONE\n this.renderLinks.push(renderLink)\n\n this.state.connectingTo = \"input\"\n\n this.#setLegacyLinks(false)\n return\n }\n\n const outputNode = network.getNodeById(link.origin_id)\n if (!outputNode) {\n console.warn(\"No output node found for link.\", link)\n return\n }\n\n const outputSlot = outputNode.outputs.at(link.origin_slot)\n if (!outputSlot) {\n console.warn(\"No output slot found for link.\", link)\n return\n }\n\n const renderLink = new ToInputRenderLink(network, outputNode, outputSlot, reroute)\n renderLink.fromDirection = LinkDirection.NONE\n this.renderLinks.push(renderLink)\n\n this.state.connectingTo = \"input\"\n\n this.#setLegacyLinks(false)\n }\n\n /**\n * Drags a new link from a reroute to an output slot.\n * @param network The network that the link being connected belongs to\n * @param reroute The reroute that the link is being dragged from\n */\n dragFromRerouteToOutput(network: LinkNetwork, reroute: Reroute): void {\n if (this.isConnecting) throw new Error(\"Already dragging links.\")\n\n const link = reroute.firstLink ?? reroute.firstFloatingLink\n if (!link) {\n console.warn(\"No link found for reroute.\")\n return\n }\n\n if (link.target_id === SUBGRAPH_OUTPUT_ID) {\n if (!(network instanceof Subgraph)) {\n console.warn(\"Subgraph output link found in non-subgraph network.\")\n return\n }\n\n const output = network.outputs.at(link.target_slot)\n if (!output) throw new Error(\"No subgraph output found for link.\")\n\n const renderLink = new ToOutputFromIoNodeLink(network, network.outputNode, output, reroute)\n renderLink.fromDirection = LinkDirection.NONE\n this.renderLinks.push(renderLink)\n\n this.state.connectingTo = \"output\"\n\n this.#setLegacyLinks(false)\n return\n }\n\n const inputNode = network.getNodeById(link.target_id)\n if (!inputNode) {\n console.warn(\"No input node found for link.\", link)\n return\n }\n\n const inputSlot = inputNode.inputs.at(link.target_slot)\n if (!inputSlot) {\n console.warn(\"No input slot found for link.\", link)\n return\n }\n\n const renderLink = new ToOutputFromRerouteLink(network, inputNode, inputSlot, reroute, this)\n renderLink.fromDirection = LinkDirection.LEFT\n this.renderLinks.push(renderLink)\n\n this.state.connectingTo = \"output\"\n\n this.#setLegacyLinks(true)\n }\n\n dragFromLinkSegment(network: LinkNetwork, linkSegment: LinkSegment): void {\n if (this.isConnecting) throw new Error(\"Already dragging links.\")\n\n const { state } = this\n if (linkSegment.origin_id == null || linkSegment.origin_slot == null) return\n\n const node = network.getNodeById(linkSegment.origin_id)\n if (!node) return\n\n const slot = node.outputs.at(linkSegment.origin_slot)\n if (!slot) return\n\n const reroute = network.getReroute(linkSegment.parentId)\n const renderLink = new ToInputRenderLink(network, node, slot, reroute)\n renderLink.fromDirection = LinkDirection.NONE\n this.renderLinks.push(renderLink)\n\n state.connectingTo = \"input\"\n\n this.#setLegacyLinks(false)\n }\n\n /**\n * Connects the links being dropped\n * @param event Contains the drop location, in canvas space\n */\n dropLinks(locator: ItemLocator, event: CanvasPointerEvent): void {\n if (!this.isConnecting) {\n const mayContinue = this.events.dispatch(\"before-drop-links\", { renderLinks: this.renderLinks, event })\n if (mayContinue === false) return\n }\n\n try {\n const { canvasX, canvasY } = event\n\n const ioNode = locator.getIoNodeOnPos?.(canvasX, canvasY)\n if (ioNode) {\n this.dropOnIoNode(ioNode, event)\n return\n }\n\n const node = locator.getNodeOnPos(canvasX, canvasY) ?? undefined\n if (node) {\n this.dropOnNode(node, event)\n } else {\n // Get reroute if no node is found\n const reroute = locator.getRerouteOnPos(canvasX, canvasY)\n // Drop output->input link on reroute is not impl.\n if (reroute && this.isRerouteValidDrop(reroute)) {\n this.dropOnReroute(reroute, event)\n } else {\n this.dropOnNothing(event)\n }\n }\n } finally {\n this.events.dispatch(\"after-drop-links\", { renderLinks: this.renderLinks, event })\n }\n }\n\n dropOnIoNode(ioNode: SubgraphInputNode | SubgraphOutputNode, event: CanvasPointerEvent): void {\n const { renderLinks, state } = this\n const { connectingTo } = state\n const { canvasX, canvasY } = event\n\n if (connectingTo === \"input\" && ioNode instanceof SubgraphOutputNode) {\n const output = ioNode.getSlotInPosition(canvasX, canvasY)\n if (!output) throw new Error(\"No output slot found for link.\")\n\n for (const link of renderLinks) {\n link.connectToSubgraphOutput(output, this.events)\n }\n } else if (connectingTo === \"output\" && ioNode instanceof SubgraphInputNode) {\n const input = ioNode.getSlotInPosition(canvasX, canvasY)\n if (!input) throw new Error(\"No input slot found for link.\")\n\n for (const link of renderLinks) {\n link.connectToSubgraphInput(input, this.events)\n }\n } else {\n console.error(\"Invalid connectingTo state &/ ioNode\", connectingTo, ioNode)\n }\n }\n\n dropOnNode(node: LGraphNode, event: CanvasPointerEvent) {\n const { renderLinks, state } = this\n const { connectingTo } = state\n const { canvasX, canvasY } = event\n\n // Do nothing if every connection would loop back\n if (renderLinks.every(link => link.node === node)) return\n\n // To output\n if (connectingTo === \"output\") {\n const output = node.getOutputOnPos([canvasX, canvasY])\n\n if (output) {\n this.#dropOnOutput(node, output)\n } else {\n this.connectToNode(node, event)\n }\n // To input\n } else if (connectingTo === \"input\") {\n const input = node.getInputOnPos([canvasX, canvasY])\n const inputOrSocket = input ?? node.getSlotFromWidget(this.overWidget)\n\n // Input slot\n if (inputOrSocket) {\n this.#dropOnInput(node, inputOrSocket)\n } else {\n // Node background / title\n this.connectToNode(node, event)\n }\n }\n }\n\n dropOnReroute(reroute: Reroute, event: CanvasPointerEvent): void {\n const mayContinue = this.events.dispatch(\"dropped-on-reroute\", { reroute, event })\n if (mayContinue === false) return\n\n // Connecting to input\n if (this.state.connectingTo === \"input\") {\n if (this.renderLinks.length !== 1) throw new Error(`Attempted to connect ${this.renderLinks.length} input links to a reroute.`)\n\n const renderLink = this.renderLinks[0]\n this._connectOutputToReroute(reroute, renderLink)\n\n return\n }\n\n // Connecting to output\n for (const link of this.renderLinks) {\n if (link.toType !== \"output\") continue\n\n const result = reroute.findSourceOutput()\n if (!result) continue\n\n const { node, output } = result\n if (!link.canConnectToOutput(node, output)) continue\n\n link.connectToRerouteOutput(reroute, node, output, this.events)\n }\n }\n\n /** @internal Temporary workaround - requires refactor. */\n _connectOutputToReroute(reroute: Reroute, renderLink: RenderLinkUnion): void {\n const results = reroute.findTargetInputs()\n if (!results?.length) return\n\n const maybeReroutes = reroute.getReroutes()\n if (maybeReroutes === null) throw new Error(\"Reroute loop detected.\")\n\n const originalReroutes = maybeReroutes.slice(0, -1).reverse()\n\n // From reroute to reroute\n if (renderLink instanceof ToInputRenderLink) {\n const { node, fromSlot, fromSlotIndex, fromReroute } = renderLink\n\n reroute.setFloatingLinkOrigin(node, fromSlot, fromSlotIndex)\n\n // Clean floating link IDs from reroutes about to be removed from the chain\n if (fromReroute != null) {\n for (const originalReroute of originalReroutes) {\n if (originalReroute.id === fromReroute.id) break\n\n for (const linkId of reroute.floatingLinkIds) {\n originalReroute.floatingLinkIds.delete(linkId)\n }\n }\n }\n }\n\n // Filter before any connections are re-created\n const filtered = results.filter(result => renderLink.toType === \"input\" && canConnectInputLinkToReroute(renderLink, result.node, result.input, reroute))\n\n for (const result of filtered) {\n renderLink.connectToRerouteInput(reroute, result, this.events, originalReroutes)\n }\n\n return\n }\n\n dropOnNothing(event: CanvasPointerEvent): void {\n // For external event only.\n const mayContinue = this.events.dispatch(\"dropped-on-canvas\", event)\n if (mayContinue === false) return\n\n this.disconnectLinks()\n }\n\n /**\n * Disconnects all moving links.\n * @remarks This is called when the links are dropped on the canvas.\n * May be called by consumers to e.g. drag links into a bin / void.\n */\n disconnectLinks(): void {\n for (const link of this.renderLinks) {\n if (link instanceof MovingLinkBase) {\n link.disconnect()\n }\n }\n }\n\n /**\n * Connects the links being dropped onto a node to the first matching slot.\n * @param node The node that the links are being dropped on\n * @param event Contains the drop location, in canvas space\n */\n connectToNode(node: LGraphNode, event: CanvasPointerEvent): void {\n const { state: { connectingTo } } = this\n\n const mayContinue = this.events.dispatch(\"dropped-on-node\", { node, event })\n if (mayContinue === false) return\n\n // Assume all links are the same type, disallow loopback\n const firstLink = this.renderLinks[0]\n if (!firstLink) return\n\n // Use a single type check before looping; ensures all dropped links go to the same slot\n if (connectingTo === \"output\") {\n // Dropping new output link\n const output = node.findOutputByType(firstLink.fromSlot.type)?.slot\n console.debug(\"out\", node, output, firstLink.fromSlot)\n if (output === undefined) {\n console.warn(`Could not find slot for link type: [${firstLink.fromSlot.type}].`)\n return\n }\n\n this.#dropOnOutput(node, output)\n } else if (connectingTo === \"input\") {\n // Dropping new input link\n const input = node.findInputByType(firstLink.fromSlot.type)?.slot\n console.debug(\"in\", node, input, firstLink.fromSlot)\n if (input === undefined) {\n console.warn(`Could not find slot for link type: [${firstLink.fromSlot.type}].`)\n return\n }\n\n this.#dropOnInput(node, input)\n }\n }\n\n #dropOnInput(node: LGraphNode, input: INodeInputSlot): void {\n for (const link of this.renderLinks) {\n if (!link.canConnectToInput(node, input)) continue\n\n link.connectToInput(node, input, this.events)\n }\n }\n\n #dropOnOutput(node: LGraphNode, output: INodeOutputSlot): void {\n for (const link of this.renderLinks) {\n if (!link.canConnectToOutput(node, output)) {\n if (link instanceof MovingOutputLink && link.link.parentId !== undefined) {\n // Reconnect link without reroutes\n link.outputNode.connectSlots(link.outputSlot, link.inputNode, link.inputSlot, undefined!)\n }\n continue\n }\n\n link.connectToOutput(node, output, this.events)\n }\n }\n\n isInputValidDrop(node: LGraphNode, input: INodeInputSlot): boolean {\n return this.renderLinks.some(link => link.canConnectToInput(node, input))\n }\n\n isNodeValidDrop(node: LGraphNode): boolean {\n if (this.state.connectingTo === \"output\") {\n return node.outputs.some(output => this.renderLinks.some(link => link.canConnectToOutput(node, output)))\n }\n\n return node.inputs.some(input => this.renderLinks.some(link => link.canConnectToInput(node, input)))\n }\n\n /**\n * Checks if a reroute is a valid drop target for any of the links being connected.\n * @param reroute The reroute that would be dropped on.\n * @returns `true` if any of the current links being connected are valid for the given reroute.\n */\n isRerouteValidDrop(reroute: Reroute): boolean {\n if (this.state.connectingTo === \"input\") {\n const results = reroute.findTargetInputs()\n if (!results?.length) return false\n\n for (const { node, input } of results) {\n for (const renderLink of this.renderLinks) {\n if (renderLink.toType !== \"input\") continue\n if (canConnectInputLinkToReroute(renderLink, node, input, reroute)) return true\n }\n }\n } else {\n const result = reroute.findSourceOutput()\n if (!result) return false\n\n const { node, output } = result\n\n for (const renderLink of this.renderLinks) {\n if (renderLink.toType !== \"output\") continue\n if (!renderLink.canConnectToReroute(reroute)) continue\n if (renderLink.canConnectToOutput(node, output)) return true\n }\n }\n\n return false\n }\n\n /** Sets connecting_links, used by some extensions still. */\n #setLegacyLinks(fromSlotIsInput: boolean): void {\n const links = this.renderLinks.map((link) => {\n const input = fromSlotIsInput ? link.fromSlot as INodeInputSlot : null\n const output = fromSlotIsInput ? null : link.fromSlot as INodeOutputSlot\n\n const afterRerouteId = link instanceof MovingLinkBase ? link.link?.parentId : link.fromReroute?.id\n\n return {\n node: link.node as LGraphNode,\n slot: link.fromSlotIndex,\n input,\n output,\n pos: link.fromPos,\n afterRerouteId,\n } satisfies ConnectingLink\n })\n this.#setConnectingLinks(links)\n }\n\n /**\n * Exports the current state of the link connector.\n * @param network The network that the links being connected belong to.\n * @returns A POJO with the state of the link connector, links being connected, and their network.\n * @remarks Other than {@link network}, all properties are shallow cloned.\n */\n export(network: LinkNetwork): LinkConnectorExport {\n return {\n renderLinks: [...this.renderLinks],\n inputLinks: [...this.inputLinks],\n outputLinks: [...this.outputLinks],\n floatingLinks: [...this.floatingLinks],\n state: { ...this.state },\n network,\n }\n }\n\n /**\n * Adds an event listener that will be automatically removed when the reset event is fired.\n * @param eventName The event to listen for.\n * @param listener The listener to call when the event is fired.\n */\n listenUntilReset<K extends keyof LinkConnectorEventMap>(\n eventName: K,\n listener: Parameters<typeof this.events.addEventListener<K>>[1],\n options?: Parameters<typeof this.events.addEventListener<K>>[2],\n ) {\n this.events.addEventListener(eventName, listener, options)\n this.events.addEventListener(\"reset\", () => this.events.removeEventListener(eventName, listener), { once: true })\n }\n\n /**\n * Resets everything to its initial state.\n *\n * Effectively cancels moving or connecting links.\n */\n reset(force = false): void {\n const mayContinue = this.events.dispatch(\"reset\", force)\n if (mayContinue === false) return\n\n const { state, outputLinks, inputLinks, hiddenReroutes, renderLinks, floatingLinks } = this\n\n if (!force && state.connectingTo === undefined) return\n state.connectingTo = undefined\n\n for (const link of outputLinks) delete link._dragging\n for (const link of inputLinks) delete link._dragging\n for (const link of floatingLinks) delete link._dragging\n for (const reroute of hiddenReroutes) delete reroute._dragging\n\n renderLinks.length = 0\n inputLinks.length = 0\n outputLinks.length = 0\n floatingLinks.length = 0\n hiddenReroutes.clear()\n state.multi = false\n state.draggingExistingLinks = false\n state.snapLinksPos = undefined\n }\n}\n\n/** Validates that a single {@link RenderLink} can be dropped on the specified reroute. */\nfunction canConnectInputLinkToReroute(\n link: ToInputRenderLink | MovingInputLink | FloatingRenderLink | ToInputFromIoNodeLink,\n inputNode: LGraphNode,\n input: INodeInputSlot,\n reroute: Reroute,\n): boolean {\n const { fromReroute } = link\n\n if (\n !link.canConnectToInput(inputNode, input) ||\n // Would result in no change\n fromReroute?.id === reroute.id ||\n // Cannot connect from child to parent reroute\n fromReroute?.getReroutes()?.includes(reroute)\n ) {\n return false\n }\n\n // Would result in no change\n if (link instanceof ToInputRenderLink) {\n if (reroute.parentId == null) {\n // Link would make no change - output to reroute\n if (reroute.firstLink?.hasOrigin(link.node.id, link.fromSlotIndex)) return false\n } else if (link.fromReroute?.id === reroute.parentId) {\n return false\n }\n }\n return true\n}\n","import type { CompassCorners } from \"./interfaces\"\nimport type { CanvasPointerEvent } from \"./types/events\"\n\nimport { dist2 } from \"./measure\"\n\n/**\n * Allows click and drag actions to be declared ahead of time during a pointerdown event.\n *\n * By default, it retains the most recent event of each type until it is reset (on pointerup).\n * - {@link eDown}\n * - {@link eMove}\n * - {@link eUp}\n *\n * Depending on whether the user clicks or drags the pointer, only the appropriate callbacks are called:\n * - {@link onClick}\n * - {@link onDoubleClick}\n * - {@link onDragStart}\n * - {@link onDrag}\n * - {@link onDragEnd}\n * - {@link finally}\n * @see\n * - {@link LGraphCanvas.processMouseDown}\n * - {@link LGraphCanvas.processMouseMove}\n * - {@link LGraphCanvas.processMouseUp}\n */\nexport class CanvasPointer {\n /** Maximum time in milliseconds to ignore click drift */\n static bufferTime = 150\n\n /** Maximum gap between pointerup and pointerdown events to be considered as a double click */\n static doubleClickTime = 300\n\n /** Maximum offset from click location */\n static get maxClickDrift() {\n return this.#maxClickDrift\n }\n\n static set maxClickDrift(value) {\n this.#maxClickDrift = value\n this.#maxClickDrift2 = value * value\n }\n\n static #maxClickDrift = 6\n /** {@link maxClickDrift} squared. Used to calculate click drift without `sqrt`. */\n static #maxClickDrift2 = this.#maxClickDrift ** 2\n\n /** The element this PointerState should capture input against when dragging. */\n element: Element\n /** Pointer ID used by drag capture. */\n pointerId?: number\n\n /** Set to true when if the pointer moves far enough after a down event, before the corresponding up event is fired. */\n dragStarted: boolean = false\n\n /** The {@link eUp} from the last successful click */\n eLastDown?: CanvasPointerEvent\n\n /** Used downstream for touch event support. */\n isDouble: boolean = false\n /** Used downstream for touch event support. */\n isDown: boolean = false\n\n /** The resize handle currently being hovered or dragged */\n resizeDirection?: CompassCorners\n\n /**\n * If `true`, {@link eDown}, {@link eMove}, and {@link eUp} will be set to\n * `undefined` when {@link reset} is called.\n *\n * Default: `true`\n */\n clearEventsOnReset: boolean = true\n\n /** The last pointerdown event for the primary button */\n eDown?: CanvasPointerEvent\n /** The last pointermove event for the primary button */\n eMove?: CanvasPointerEvent\n /** The last pointerup event for the primary button */\n eUp?: CanvasPointerEvent\n\n /**\n * If set, as soon as the mouse moves outside the click drift threshold, this action is run once.\n * @param pointer [DEPRECATED] This parameter will be removed in a future release.\n * @param eMove The pointermove event of this ongoing drag action.\n *\n * It is possible for no `pointermove` events to occur, but still be far from\n * the original `pointerdown` event. In this case, {@link eMove} will be null, and\n * {@link onDragEnd} will be called immediately after {@link onDragStart}.\n */\n onDragStart?(pointer: this, eMove?: CanvasPointerEvent): unknown\n\n /**\n * Called on pointermove whilst dragging.\n * @param eMove The pointermove event of this ongoing drag action\n */\n onDrag?(eMove: CanvasPointerEvent): unknown\n\n /**\n * Called on pointerup after dragging (i.e. not called if clicked).\n * @param upEvent The pointerup or pointermove event that triggered this callback\n */\n onDragEnd?(upEvent: CanvasPointerEvent): unknown\n\n /**\n * Callback that will be run once, the next time a pointerup event appears to be a normal click.\n * @param upEvent The pointerup or pointermove event that triggered this callback\n */\n onClick?(upEvent: CanvasPointerEvent): unknown\n\n /**\n * Callback that will be run once, the next time a pointerup event appears to be a normal click.\n * @param upEvent The pointerup or pointermove event that triggered this callback\n */\n onDoubleClick?(upEvent: CanvasPointerEvent): unknown\n\n /**\n * Run-once callback, called at the end of any click or drag, whether or not it was successful in any way.\n *\n * The setter of this callback will call the existing value before replacing it.\n * Therefore, simply setting this value twice will execute the first callback.\n */\n get finally() {\n return this.#finally\n }\n\n set finally(value) {\n try {\n this.#finally?.()\n } finally {\n this.#finally = value\n }\n }\n\n #finally?: () => unknown\n\n constructor(element: Element) {\n this.element = element\n }\n\n /**\n * Callback for `pointerdown` events. To be used as the event handler (or called by it).\n * @param e The `pointerdown` event\n */\n down(e: CanvasPointerEvent): void {\n this.reset()\n this.eDown = e\n this.pointerId = e.pointerId\n this.element.setPointerCapture(e.pointerId)\n }\n\n /**\n * Callback for `pointermove` events. To be used as the event handler (or called by it).\n * @param e The `pointermove` event\n */\n move(e: CanvasPointerEvent): void {\n const { eDown } = this\n if (!eDown) return\n\n // No buttons down, but eDown exists - clean up & leave\n if (!e.buttons) {\n this.reset()\n return\n }\n\n // Primary button released - treat as pointerup.\n if (!(e.buttons & eDown.buttons)) {\n this.#completeClick(e)\n this.reset()\n return\n }\n this.eMove = e\n this.onDrag?.(e)\n\n // Dragging, but no callback to run\n if (this.dragStarted) return\n\n const longerThanBufferTime = e.timeStamp - eDown.timeStamp > CanvasPointer.bufferTime\n if (longerThanBufferTime || !this.#hasSamePosition(e, eDown)) {\n this.#setDragStarted(e)\n }\n }\n\n /**\n * Callback for `pointerup` events. To be used as the event handler (or called by it).\n * @param e The `pointerup` event\n */\n up(e: CanvasPointerEvent): boolean {\n if (e.button !== this.eDown?.button) return false\n\n this.#completeClick(e)\n const { dragStarted } = this\n this.reset()\n return !dragStarted\n }\n\n #completeClick(e: CanvasPointerEvent): void {\n const { eDown } = this\n if (!eDown) return\n\n this.eUp = e\n\n if (this.dragStarted) {\n // A move event already started drag\n this.onDragEnd?.(e)\n } else if (!this.#hasSamePosition(e, eDown)) {\n // Teleport without a move event (e.g. tab out, move, tab back)\n this.#setDragStarted()\n this.onDragEnd?.(e)\n } else if (this.onDoubleClick && this.#isDoubleClick()) {\n // Double-click event\n this.onDoubleClick(e)\n this.eLastDown = undefined\n } else {\n // Normal click event\n this.onClick?.(e)\n this.eLastDown = eDown\n }\n }\n\n /**\n * Checks if two events occurred near each other - not further apart than the maximum click drift.\n * @param a The first event to compare\n * @param b The second event to compare\n * @param tolerance2 The maximum distance (squared) before the positions are considered different\n * @returns `true` if the two events were no more than {@link maxClickDrift} apart, otherwise `false`\n */\n #hasSamePosition(\n a: PointerEvent,\n b: PointerEvent,\n tolerance2 = CanvasPointer.#maxClickDrift2,\n ): boolean {\n const drift = dist2(a.clientX, a.clientY, b.clientX, b.clientY)\n return drift <= tolerance2\n }\n\n /**\n * Checks whether the pointer is currently past the max click drift threshold.\n * @returns `true` if the latest pointer event is past the the click drift threshold\n */\n #isDoubleClick(): boolean {\n const { eDown, eLastDown } = this\n if (!eDown || !eLastDown) return false\n\n // Use thrice the drift distance for double-click gap\n const tolerance2 = (3 * CanvasPointer.#maxClickDrift) ** 2\n const diff = eDown.timeStamp - eLastDown.timeStamp\n return diff > 0 &&\n diff < CanvasPointer.doubleClickTime &&\n this.#hasSamePosition(eDown, eLastDown, tolerance2)\n }\n\n #setDragStarted(eMove?: CanvasPointerEvent): void {\n this.dragStarted = true\n this.onDragStart?.(this, eMove)\n delete this.onDragStart\n }\n\n /**\n * Resets the state of this {@link CanvasPointer} instance.\n *\n * The {@link finally} callback is first executed, then all callbacks and intra-click\n * state is cleared.\n */\n reset(): void {\n // The setter executes the callback before clearing it\n this.finally = undefined\n delete this.onClick\n delete this.onDoubleClick\n delete this.onDragStart\n delete this.onDrag\n delete this.onDragEnd\n\n this.isDown = false\n this.isDouble = false\n this.dragStarted = false\n this.resizeDirection = undefined\n\n if (this.clearEventsOnReset) {\n this.eDown = undefined\n this.eMove = undefined\n this.eUp = undefined\n }\n\n const { element, pointerId } = this\n this.pointerId = undefined\n if (typeof pointerId === \"number\" && element.hasPointerCapture(pointerId)) {\n element.releasePointerCapture(pointerId)\n }\n }\n}\n","import type { Point, ReadOnlyRect, Rect } from \"./interfaces\"\n\nimport { EaseFunction, Rectangle } from \"./litegraph\"\n\nexport interface DragAndScaleState {\n /**\n * The offset from the top-left of the current canvas viewport to `[0, 0]` in graph space.\n * Or said another way, the inverse offset of the viewport.\n */\n offset: [number, number]\n /** The scale of the graph. */\n scale: number\n}\n\nexport type AnimationOptions = {\n /** Duration of the animation in milliseconds. */\n duration?: number\n /** Relative target zoom level. 1 means the view is fit exactly on the bounding box. */\n zoom?: number\n /** The animation easing function (curve) */\n easing?: EaseFunction\n}\n\nexport class DragAndScale {\n /**\n * The state of this DragAndScale instance.\n *\n * Implemented as a POCO that can be proxied without side-effects.\n */\n state: DragAndScaleState\n lastState: DragAndScaleState = {\n offset: [0, 0],\n scale: 0,\n }\n\n /** Maximum scale (zoom in) */\n max_scale: number\n /** Minimum scale (zoom out) */\n min_scale: number\n enabled: boolean\n last_mouse: Point\n element: HTMLCanvasElement\n visible_area: Rectangle\n dragging?: boolean\n viewport?: Rect\n\n onredraw?(das: DragAndScale): void\n onChanged?(scale: number, offset: Point): void\n\n get offset(): [number, number] {\n return this.state.offset\n }\n\n set offset(value: Point) {\n this.state.offset[0] = value[0]\n this.state.offset[1] = value[1]\n }\n\n get scale(): number {\n return this.state.scale\n }\n\n set scale(value: number) {\n this.state.scale = value\n }\n\n constructor(element: HTMLCanvasElement) {\n this.state = {\n offset: [0, 0],\n scale: 1,\n }\n this.max_scale = 10\n this.min_scale = 0.1\n this.enabled = true\n this.last_mouse = [0, 0]\n this.visible_area = new Rectangle()\n\n this.element = element\n }\n\n /**\n * Returns `true` if the current state has changed from the previous state.\n * @returns `true` if the current state has changed from the previous state, otherwise `false`.\n */\n #stateHasChanged(): boolean {\n const current = this.state\n const previous = this.lastState\n\n return current.scale !== previous.scale ||\n current.offset[0] !== previous.offset[0] ||\n current.offset[1] !== previous.offset[1]\n }\n\n computeVisibleArea(viewport: Rect | undefined): void {\n const { scale, offset, visible_area } = this\n\n if (this.#stateHasChanged()) {\n this.onChanged?.(scale, offset)\n copyState(this.state, this.lastState)\n }\n\n if (!this.element) {\n visible_area[0] = visible_area[1] = visible_area[2] = visible_area[3] = 0\n return\n }\n let { width, height } = this.element\n let startx = -offset[0]\n let starty = -offset[1]\n if (viewport) {\n startx += viewport[0] / scale\n starty += viewport[1] / scale\n width = viewport[2]\n height = viewport[3]\n }\n const endx = startx + width / scale\n const endy = starty + height / scale\n visible_area[0] = startx\n visible_area[1] = starty\n visible_area.resizeBottomRight(endx, endy)\n }\n\n toCanvasContext(ctx: CanvasRenderingContext2D): void {\n ctx.scale(this.scale, this.scale)\n ctx.translate(this.offset[0], this.offset[1])\n }\n\n convertOffsetToCanvas(pos: Point): Point {\n return [\n (pos[0] + this.offset[0]) * this.scale,\n (pos[1] + this.offset[1]) * this.scale,\n ]\n }\n\n convertCanvasToOffset(pos: Point, out?: Point): Point {\n out = out || [0, 0]\n out[0] = pos[0] / this.scale - this.offset[0]\n out[1] = pos[1] / this.scale - this.offset[1]\n return out\n }\n\n /** @deprecated Has not been kept up to date */\n mouseDrag(x: number, y: number): void {\n this.offset[0] += x / this.scale\n this.offset[1] += y / this.scale\n\n this.onredraw?.(this)\n }\n\n changeScale(value: number, zooming_center?: Point, roundToScaleOne = true): void {\n if (value < this.min_scale) {\n value = this.min_scale\n } else if (value > this.max_scale) {\n value = this.max_scale\n }\n if (value == this.scale) return\n\n const rect = this.element.getBoundingClientRect()\n if (!rect) return\n\n zooming_center = zooming_center ?? [rect.width * 0.5, rect.height * 0.5]\n\n const normalizedCenter: Point = [\n zooming_center[0] - rect.x,\n zooming_center[1] - rect.y,\n ]\n const center = this.convertCanvasToOffset(normalizedCenter)\n this.scale = value\n if (roundToScaleOne && Math.abs(this.scale - 1) < 0.01) this.scale = 1\n const new_center = this.convertCanvasToOffset(normalizedCenter)\n const delta_offset = [\n new_center[0] - center[0],\n new_center[1] - center[1],\n ]\n\n this.offset[0] += delta_offset[0]\n this.offset[1] += delta_offset[1]\n\n this.onredraw?.(this)\n }\n\n changeDeltaScale(value: number, zooming_center?: Point): void {\n this.changeScale(this.scale * value, zooming_center)\n }\n\n /**\n * Fits the view to the specified bounds.\n * @param bounds The bounds to fit the view to, defined by a rectangle.\n */\n fitToBounds(bounds: ReadOnlyRect, { zoom = 0.75 }: { zoom?: number } = {}): void {\n const cw = this.element.width / window.devicePixelRatio\n const ch = this.element.height / window.devicePixelRatio\n let targetScale = this.scale\n\n if (zoom > 0) {\n const targetScaleX = (zoom * cw) / Math.max(bounds[2], 300)\n const targetScaleY = (zoom * ch) / Math.max(bounds[3], 300)\n\n // Choose the smaller scale to ensure the node fits into the viewport\n // Ensure we don't go over the max scale\n targetScale = Math.min(targetScaleX, targetScaleY, this.max_scale)\n }\n\n const scaledWidth = cw / targetScale\n const scaledHeight = ch / targetScale\n\n // Calculate the target position to center the bounds in the viewport\n const targetX = -bounds[0] - (bounds[2] * 0.5) + (scaledWidth * 0.5)\n const targetY = -bounds[1] - (bounds[3] * 0.5) + (scaledHeight * 0.5)\n\n // Apply the changes immediately\n this.offset[0] = targetX\n this.offset[1] = targetY\n this.scale = targetScale\n }\n\n /**\n * Starts an animation to fit the view around the specified selection of nodes.\n * @param bounds The bounds to animate the view to, defined by a rectangle.\n */\n animateToBounds(\n bounds: ReadOnlyRect,\n setDirty: () => void,\n {\n duration = 350,\n zoom = 0.75,\n easing = EaseFunction.EASE_IN_OUT_QUAD,\n }: AnimationOptions = {},\n ) {\n if (!(duration > 0)) throw new RangeError(\"Duration must be greater than 0\")\n\n const easeFunctions = {\n linear: (t: number) => t,\n easeInQuad: (t: number) => t * t,\n easeOutQuad: (t: number) => t * (2 - t),\n easeInOutQuad: (t: number) => (t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t),\n }\n const easeFunction = easeFunctions[easing] ?? easeFunctions.linear\n\n const startTimestamp = performance.now()\n const cw = this.element.width / window.devicePixelRatio\n const ch = this.element.height / window.devicePixelRatio\n const startX = this.offset[0]\n const startY = this.offset[1]\n const startX2 = startX - (cw / this.scale)\n const startY2 = startY - (ch / this.scale)\n const startScale = this.scale\n let targetScale = startScale\n\n if (zoom > 0) {\n const targetScaleX = (zoom * cw) / Math.max(bounds[2], 300)\n const targetScaleY = (zoom * ch) / Math.max(bounds[3], 300)\n\n // Choose the smaller scale to ensure the node fits into the viewport\n // Ensure we don't go over the max scale\n targetScale = Math.min(targetScaleX, targetScaleY, this.max_scale)\n }\n const scaledWidth = cw / targetScale\n const scaledHeight = ch / targetScale\n\n const targetX = -bounds[0] - (bounds[2] * 0.5) + (scaledWidth * 0.5)\n const targetY = -bounds[1] - (bounds[3] * 0.5) + (scaledHeight * 0.5)\n const targetX2 = targetX - scaledWidth\n const targetY2 = targetY - scaledHeight\n\n const animate = (timestamp: number) => {\n const elapsed = timestamp - startTimestamp\n const progress = Math.min(elapsed / duration, 1)\n const easedProgress = easeFunction(progress)\n\n const currentX = startX + ((targetX - startX) * easedProgress)\n const currentY = startY + ((targetY - startY) * easedProgress)\n this.offset[0] = currentX\n this.offset[1] = currentY\n\n if (zoom > 0) {\n const currentX2 = startX2 + ((targetX2 - startX2) * easedProgress)\n const currentY2 = startY2 + ((targetY2 - startY2) * easedProgress)\n const currentWidth = Math.abs(currentX2 - currentX)\n const currentHeight = Math.abs(currentY2 - currentY)\n\n this.scale = Math.min(cw / currentWidth, ch / currentHeight)\n }\n\n setDirty()\n\n if (progress < 1) {\n animationId = requestAnimationFrame(animate)\n } else {\n cancelAnimationFrame(animationId)\n }\n }\n let animationId = requestAnimationFrame(animate)\n }\n\n reset(): void {\n this.scale = 1\n this.offset[0] = 0\n this.offset[1] = 0\n }\n}\n\n/**\n * Copies the values of one state into another, preserving references.\n * @param from The state to copy values from.\n * @param to The state to copy values into.\n */\nfunction copyState(from: DragAndScaleState, to: DragAndScaleState): void {\n to.scale = from.scale\n to.offset[0] = from.offset[0]\n to.offset[1] = from.offset[1]\n}\n","import type { Direction, IBoundaryNodes } from \"../interfaces\"\nimport type { LGraphNode } from \"../LGraphNode\"\n\n/**\n * Finds the nodes that are farthest in all four directions, representing the boundary of the nodes.\n * @param nodes The nodes to check the edges of\n * @returns An object listing the furthest node (edge) in all four directions.\n * `null` if no nodes were supplied or the first node was falsy.\n */\nexport function getBoundaryNodes(nodes: LGraphNode[]): IBoundaryNodes | null {\n const valid = nodes?.find(x => x)\n if (!valid) return null\n\n let top = valid\n let right = valid\n let bottom = valid\n let left = valid\n\n for (const node of nodes) {\n if (!node) continue\n const [x, y] = node.pos\n const [width, height] = node.size\n\n if (y < top.pos[1]) top = node\n if (x + width > right.pos[0] + right.size[0]) right = node\n if (y + height > bottom.pos[1] + bottom.size[1]) bottom = node\n if (x < left.pos[0]) left = node\n }\n\n return {\n top,\n right,\n bottom,\n left,\n }\n}\n\n/**\n * Distributes nodes evenly along a horizontal or vertical plane.\n * @param nodes The nodes to distribute\n * @param horizontal If true, distributes along the horizontal plane. Otherwise, the vertical plane.\n */\nexport function distributeNodes(nodes: LGraphNode[], horizontal?: boolean): void {\n const nodeCount = nodes?.length\n if (!(nodeCount > 1)) return\n\n const index = horizontal ? 0 : 1\n\n let total = 0\n let highest = -Infinity\n\n for (const node of nodes) {\n total += node.size[index]\n\n const high = node.pos[index] + node.size[index]\n if (high > highest) highest = high\n }\n const sorted = [...nodes].sort((a, b) => a.pos[index] - b.pos[index])\n const lowest = sorted[0].pos[index]\n\n const gap = (highest - lowest - total) / (nodeCount - 1)\n let startAt = lowest\n for (let i = 0; i < nodeCount; i++) {\n const node = sorted[i]\n node.pos[index] = startAt + gap * i\n startAt += node.size[index]\n }\n}\n\n/**\n * Aligns all nodes along the edge of a node.\n * @param nodes The nodes to align\n * @param direction The edge to align nodes on\n * @param align_to The node to align all other nodes to. If undefined, the farthest node will be used.\n */\nexport function alignNodes(\n nodes: LGraphNode[],\n direction: Direction,\n align_to?: LGraphNode,\n): void {\n if (!nodes) return\n\n const boundary = align_to === undefined\n ? getBoundaryNodes(nodes)\n : { top: align_to, right: align_to, bottom: align_to, left: align_to }\n\n if (boundary === null) return\n\n for (const node of nodes) {\n switch (direction) {\n case \"right\":\n node.pos[0] = boundary.right.pos[0] + boundary.right.size[0] - node.size[0]\n break\n case \"left\":\n node.pos[0] = boundary.left.pos[0]\n break\n case \"top\":\n node.pos[1] = boundary.top.pos[1]\n break\n case \"bottom\":\n node.pos[1] = boundary.bottom.pos[1] + boundary.bottom.size[1] - node.size[1]\n break\n }\n }\n}\n","import type { ContextMenu } from \"./ContextMenu\"\nimport type { CustomEventDispatcher, ICustomEventTarget } from \"./infrastructure/CustomEventTarget\"\nimport type { LGraphCanvasEventMap } from \"./infrastructure/LGraphCanvasEventMap\"\nimport type {\n CanvasColour,\n ColorOption,\n ConnectingLink,\n ContextMenuDivElement,\n DefaultConnectionColors,\n Dictionary,\n Direction,\n IBoundaryNodes,\n IColorable,\n IContextMenuOptions,\n IContextMenuValue,\n INodeInputSlot,\n INodeOutputSlot,\n INodeSlot,\n INodeSlotContextItem,\n ISlotType,\n LinkSegment,\n NullableProperties,\n Point,\n Positionable,\n ReadOnlyPoint,\n ReadOnlyRect,\n Rect,\n Size,\n} from \"./interfaces\"\nimport type { LGraph } from \"./LGraph\"\nimport type {\n CanvasPointerEvent,\n CanvasPointerExtensions,\n} from \"./types/events\"\nimport type { ClipboardItems, SubgraphIO } from \"./types/serialisation\"\nimport type { NeverNever } from \"./types/utility\"\nimport type { PickNevers } from \"./types/utility\"\nimport type { IBaseWidget } from \"./types/widgets\"\nimport type { UUID } from \"./utils/uuid\"\n\nimport { LinkConnector } from \"@/canvas/LinkConnector\"\n\nimport { isOverNodeInput, isOverNodeOutput } from \"./canvas/measureSlots\"\nimport { CanvasPointer } from \"./CanvasPointer\"\nimport { type AnimationOptions, DragAndScale } from \"./DragAndScale\"\nimport { strokeShape } from \"./draw\"\nimport { NullGraphError } from \"./infrastructure/NullGraphError\"\nimport { LGraphGroup } from \"./LGraphGroup\"\nimport { LGraphNode, type NodeId, type NodeProperty } from \"./LGraphNode\"\nimport { createUuidv4, LiteGraph, Rectangle, SubgraphNode } from \"./litegraph\"\nimport { type LinkId, LLink } from \"./LLink\"\nimport {\n containsRect,\n createBounds,\n distance,\n findPointOnCurve,\n isInRect,\n isInRectangle,\n isPointInRect,\n overlapBounding,\n snapPoint,\n} from \"./measure\"\nimport { NodeInputSlot } from \"./node/NodeInputSlot\"\nimport { Reroute, type RerouteId } from \"./Reroute\"\nimport { stringOrEmpty } from \"./strings\"\nimport { Subgraph } from \"./subgraph/Subgraph\"\nimport { SubgraphInputNode } from \"./subgraph/SubgraphInputNode\"\nimport { SubgraphIONodeBase } from \"./subgraph/SubgraphIONodeBase\"\nimport { SubgraphOutputNode } from \"./subgraph/SubgraphOutputNode\"\nimport {\n CanvasItem,\n LGraphEventMode,\n LinkDirection,\n LinkMarkerShape,\n LinkRenderType,\n RenderShape,\n TitleMode,\n} from \"./types/globalEnums\"\nimport { alignNodes, distributeNodes, getBoundaryNodes } from \"./utils/arrange\"\nimport { findFirstNode, getAllNestedItems } from \"./utils/collections\"\nimport { BaseWidget } from \"./widgets/BaseWidget\"\nimport { toConcreteWidget } from \"./widgets/widgetMap\"\n\ninterface IShowSearchOptions {\n node_to?: LGraphNode | null\n node_from?: LGraphNode | null\n slot_from: number | INodeOutputSlot | INodeInputSlot | null | undefined\n type_filter_in?: ISlotType\n type_filter_out?: ISlotType | false\n\n // TODO check for registered_slot_[in/out]_types not empty // this will be checked for functionality enabled : filter on slot type, in and out\n do_type_filter?: boolean\n show_general_if_none_on_typefilter?: boolean\n show_general_after_typefiltered?: boolean\n hide_on_mouse_leave?: boolean\n show_all_if_empty?: boolean\n show_all_on_open?: boolean\n}\n\ninterface ICreateNodeOptions {\n /** input */\n nodeFrom?: SubgraphInputNode | LGraphNode | null\n /** input */\n slotFrom?: number | INodeOutputSlot | INodeInputSlot | SubgraphIO | null\n /** output */\n nodeTo?: SubgraphOutputNode | LGraphNode | null\n /** output */\n slotTo?: number | INodeOutputSlot | INodeInputSlot | SubgraphIO | null\n /** pass the event coords */\n\n /** Create the connection from a reroute */\n afterRerouteId?: RerouteId\n\n // FIXME: Should not be optional\n /** choose a nodetype to add, AUTO to set at first good */\n nodeType?: string\n e?: CanvasPointerEvent\n allow_searchbox?: boolean\n}\n\ninterface ICreateDefaultNodeOptions extends ICreateNodeOptions {\n /** Position of new node */\n position: Point\n /** adjust x,y */\n posAdd?: Point\n /** alpha, adjust the position x,y based on the new node size w,h */\n posSizeFix?: Point\n}\n\ninterface HasShowSearchCallback {\n /** See {@link LGraphCanvas.showSearchBox} */\n showSearchBox: (\n event: MouseEvent,\n options?: IShowSearchOptions,\n ) => HTMLDivElement | void\n}\n\ninterface ICloseable {\n close(): void\n}\n\ninterface IDialogExtensions extends ICloseable {\n modified(): void\n is_modified: boolean\n}\n\ninterface IDialog extends HTMLDivElement, IDialogExtensions {}\ntype PromptDialog = Omit<IDialog, \"modified\">\n\ninterface IDialogOptions {\n position?: Point\n event?: MouseEvent\n checkForInput?: boolean\n closeOnLeave?: boolean\n onclose?(): void\n}\n\n/** @inheritdoc {@link LGraphCanvas.state} */\nexport interface LGraphCanvasState {\n /** {@link Positionable} items are being dragged on the canvas. */\n draggingItems: boolean\n /** The canvas itself is being dragged. */\n draggingCanvas: boolean\n /** The canvas is read-only, preventing changes to nodes, disconnecting links, moving items, etc. */\n readOnly: boolean\n\n /** Bit flags indicating what is currently below the pointer. */\n hoveringOver: CanvasItem\n /** If `true`, pointer move events will set the canvas cursor style. */\n shouldSetCursor: boolean\n\n /**\n * Dirty flag indicating that {@link selectedItems} has changed.\n * Downstream consumers may reset to false once actioned.\n */\n selectionChanged: boolean\n}\n\n/**\n * The items created by a clipboard paste operation.\n * Includes maps of original copied IDs to newly created items.\n */\ninterface ClipboardPasteResult {\n /** All successfully created items */\n created: Positionable[]\n /** Map: original node IDs to newly created nodes */\n nodes: Map<NodeId, LGraphNode>\n /** Map: original link IDs to new link IDs */\n links: Map<LinkId, LLink>\n /** Map: original reroute IDs to newly created reroutes */\n reroutes: Map<RerouteId, Reroute>\n /** Map: original subgraph IDs to newly created subgraphs */\n subgraphs: Map<UUID, Subgraph>\n}\n\n/** Options for {@link LGraphCanvas.pasteFromClipboard}. */\ninterface IPasteFromClipboardOptions {\n /** If `true`, always attempt to connect inputs of pasted nodes - including to nodes that were not pasted. */\n connectInputs?: boolean\n /** The position to paste the items at. */\n position?: Point\n}\n\ninterface ICreatePanelOptions {\n closable?: any\n window?: any\n onOpen?: () => void\n onClose?: () => void\n width?: any\n height?: any\n}\n\nconst cursors = {\n NE: \"nesw-resize\",\n SE: \"nwse-resize\",\n SW: \"nesw-resize\",\n NW: \"nwse-resize\",\n} as const\n\n/**\n * This class is in charge of rendering one graph inside a canvas. And provides all the interaction required.\n * Valid callbacks are: onNodeSelected, onNodeDeselected, onShowNodePanel, onNodeDblClicked\n */\nexport class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap> {\n // Optimised buffers used during rendering\n static #temp = new Float32Array(4)\n static #temp_vec2 = new Float32Array(2)\n static #tmp_area = new Float32Array(4)\n static #margin_area = new Float32Array(4)\n static #link_bounding = new Float32Array(4)\n static #lTempA: Point = new Float32Array(2)\n static #lTempB: Point = new Float32Array(2)\n static #lTempC: Point = new Float32Array(2)\n\n static DEFAULT_BACKGROUND_IMAGE = \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII=\"\n\n static DEFAULT_EVENT_LINK_COLOR = \"#A86\"\n\n /** Link type to colour dictionary. */\n static link_type_colors: Dictionary<string> = {\n \"-1\": LGraphCanvas.DEFAULT_EVENT_LINK_COLOR,\n \"number\": \"#AAA\",\n \"node\": \"#DCA\",\n }\n\n static gradients: Record<string, CanvasGradient> = {}\n\n static search_limit = -1\n static node_colors: Record<string, ColorOption> = {\n red: { color: \"#322\", bgcolor: \"#533\", groupcolor: \"#A88\" },\n brown: { color: \"#332922\", bgcolor: \"#593930\", groupcolor: \"#b06634\" },\n green: { color: \"#232\", bgcolor: \"#353\", groupcolor: \"#8A8\" },\n blue: { color: \"#223\", bgcolor: \"#335\", groupcolor: \"#88A\" },\n pale_blue: {\n color: \"#2a363b\",\n bgcolor: \"#3f5159\",\n groupcolor: \"#3f789e\",\n },\n cyan: { color: \"#233\", bgcolor: \"#355\", groupcolor: \"#8AA\" },\n purple: { color: \"#323\", bgcolor: \"#535\", groupcolor: \"#a1309b\" },\n yellow: { color: \"#432\", bgcolor: \"#653\", groupcolor: \"#b58b2a\" },\n black: { color: \"#222\", bgcolor: \"#000\", groupcolor: \"#444\" },\n }\n\n /**\n * @internal Exclusively a workaround for design limitation in {@link LGraphNode.computeSize}.\n */\n static _measureText?: (text: string, fontStyle?: string) => number\n\n /**\n * The state of this canvas, e.g. whether it is being dragged, or read-only.\n *\n * Implemented as a POCO that can be proxied without side-effects.\n */\n state: LGraphCanvasState = {\n draggingItems: false,\n draggingCanvas: false,\n readOnly: false,\n hoveringOver: CanvasItem.Nothing,\n shouldSetCursor: true,\n selectionChanged: false,\n }\n\n #subgraph?: Subgraph\n get subgraph(): Subgraph | undefined {\n return this.#subgraph\n }\n\n set subgraph(value: Subgraph | undefined) {\n if (value !== this.#subgraph) {\n this.#subgraph = value\n if (value) this.dispatch(\"litegraph:set-graph\", { oldGraph: this.#subgraph, newGraph: value })\n }\n }\n\n /** Dispatches a custom event on the canvas. */\n dispatch<T extends keyof NeverNever<LGraphCanvasEventMap>>(type: T, detail: LGraphCanvasEventMap[T]): boolean\n dispatch<T extends keyof PickNevers<LGraphCanvasEventMap>>(type: T): boolean\n dispatch<T extends keyof LGraphCanvasEventMap>(type: T, detail?: LGraphCanvasEventMap[T]) {\n const event = new CustomEvent(type as string, { detail, bubbles: true })\n return this.canvas.dispatchEvent(event)\n }\n\n dispatchEvent<TEvent extends keyof LGraphCanvasEventMap>(type: TEvent, detail: LGraphCanvasEventMap[TEvent]) {\n this.canvas.dispatchEvent(new CustomEvent(type, { detail }))\n }\n\n #updateCursorStyle() {\n if (!this.state.shouldSetCursor) return\n\n const crosshairItems =\n CanvasItem.Node |\n CanvasItem.RerouteSlot |\n CanvasItem.SubgraphIoNode |\n CanvasItem.SubgraphIoSlot\n\n let cursor = \"default\"\n if (this.state.draggingCanvas) {\n cursor = \"grabbing\"\n } else if (this.state.readOnly) {\n cursor = \"grab\"\n } else if (this.pointer.resizeDirection) {\n cursor = cursors[this.pointer.resizeDirection] ?? cursors.SE\n } else if (this.state.hoveringOver & crosshairItems) {\n cursor = \"crosshair\"\n } else if (this.state.hoveringOver & CanvasItem.Reroute) {\n cursor = \"grab\"\n }\n\n this.canvas.style.cursor = cursor\n }\n\n // Whether the canvas was previously being dragged prior to pressing space key.\n // null if space key is not pressed.\n private _previously_dragging_canvas: boolean | null = null\n\n // #region Legacy accessors\n /** @deprecated @inheritdoc {@link LGraphCanvasState.readOnly} */\n get read_only(): boolean {\n return this.state.readOnly\n }\n\n set read_only(value: boolean) {\n this.state.readOnly = value\n this.#updateCursorStyle()\n }\n\n get isDragging(): boolean {\n return this.state.draggingItems\n }\n\n set isDragging(value: boolean) {\n this.state.draggingItems = value\n }\n\n get hoveringOver(): CanvasItem {\n return this.state.hoveringOver\n }\n\n set hoveringOver(value: CanvasItem) {\n this.state.hoveringOver = value\n this.#updateCursorStyle()\n }\n\n /** @deprecated Replace all references with {@link pointer}.{@link CanvasPointer.isDown isDown}. */\n get pointer_is_down() {\n return this.pointer.isDown\n }\n\n /** @deprecated Replace all references with {@link pointer}.{@link CanvasPointer.isDouble isDouble}. */\n get pointer_is_double() {\n return this.pointer.isDouble\n }\n\n /** @deprecated @inheritdoc {@link LGraphCanvasState.draggingCanvas} */\n get dragging_canvas(): boolean {\n return this.state.draggingCanvas\n }\n\n set dragging_canvas(value: boolean) {\n this.state.draggingCanvas = value\n this.#updateCursorStyle()\n }\n\n /**\n * @deprecated Use {@link LGraphNode.titleFontStyle} instead.\n */\n get title_text_font(): string {\n return `${LiteGraph.NODE_TEXT_SIZE}px ${LiteGraph.NODE_FONT}`\n }\n // #endregion Legacy accessors\n\n get inner_text_font(): string {\n return `normal ${LiteGraph.NODE_SUBTEXT_SIZE}px ${LiteGraph.NODE_FONT}`\n }\n\n #maximumFrameGap = 0\n /** Maximum frames per second to render. 0: unlimited. Default: 0 */\n public get maximumFps() {\n return this.#maximumFrameGap > Number.EPSILON ? this.#maximumFrameGap / 1000 : 0\n }\n\n public set maximumFps(value) {\n this.#maximumFrameGap = value > Number.EPSILON ? 1000 / value : 0\n }\n\n /**\n * @deprecated Use {@link LiteGraphGlobal.ROUND_RADIUS} instead.\n */\n get round_radius() {\n return LiteGraph.ROUND_RADIUS\n }\n\n /**\n * @deprecated Use {@link LiteGraphGlobal.ROUND_RADIUS} instead.\n */\n set round_radius(value: number) {\n LiteGraph.ROUND_RADIUS = value\n }\n\n /**\n * Render low quality when zoomed out.\n */\n get low_quality(): boolean {\n return this.ds.scale < this.low_quality_zoom_threshold\n }\n\n options: {\n skip_events?: any\n viewport?: any\n skip_render?: any\n autoresize?: any\n }\n\n background_image: string\n readonly ds: DragAndScale\n readonly pointer: CanvasPointer\n zoom_modify_alpha: boolean\n zoom_speed: number\n node_title_color: string\n default_link_color: string\n default_connection_color: {\n input_off: string\n input_on: string\n output_off: string\n output_on: string\n }\n\n default_connection_color_byType: Dictionary<CanvasColour>\n default_connection_color_byTypeOff: Dictionary<CanvasColour>\n\n /** Gets link colours. Extremely basic impl. until the legacy object dictionaries are removed. */\n colourGetter: DefaultConnectionColors = {\n getConnectedColor: (type: string) =>\n this.default_connection_color_byType[type] ||\n this.default_connection_color.output_on,\n getDisconnectedColor: (type: string) =>\n this.default_connection_color_byTypeOff[type] ||\n this.default_connection_color_byType[type] ||\n this.default_connection_color.output_off,\n }\n\n highquality_render: boolean\n use_gradients: boolean\n editor_alpha: number\n pause_rendering: boolean\n clear_background: boolean\n clear_background_color: string\n render_only_selected: boolean\n show_info: boolean\n allow_dragcanvas: boolean\n allow_dragnodes: boolean\n allow_interaction: boolean\n multi_select: boolean\n allow_searchbox: boolean\n allow_reconnect_links: boolean\n align_to_grid: boolean\n drag_mode: boolean\n dragging_rectangle: Rect | null\n filter?: string | null\n set_canvas_dirty_on_mouse_event: boolean\n always_render_background: boolean\n render_shadows: boolean\n render_canvas_border: boolean\n render_connections_shadows: boolean\n render_connections_border: boolean\n render_curved_connections: boolean\n render_connection_arrows: boolean\n render_collapsed_slots: boolean\n render_execution_order: boolean\n render_link_tooltip: boolean\n\n /** Shape of the markers shown at the midpoint of links. Default: Circle */\n linkMarkerShape: LinkMarkerShape = LinkMarkerShape.Circle\n links_render_mode: number\n /** Zoom threshold for low quality rendering. Zoom below this threshold will render low quality. */\n low_quality_zoom_threshold: number = 0.6\n /** mouse in canvas coordinates, where 0,0 is the top-left corner of the blue rectangle */\n readonly mouse: Point\n /** mouse in graph coordinates, where 0,0 is the top-left corner of the blue rectangle */\n readonly graph_mouse: Point\n /** @deprecated LEGACY: REMOVE THIS, USE {@link graph_mouse} INSTEAD */\n canvas_mouse: Point\n /** to personalize the search box */\n onSearchBox?: (helper: Element, str: string, canvas: LGraphCanvas) => any\n onSearchBoxSelection?: (name: any, event: any, canvas: LGraphCanvas) => void\n onMouse?: (e: CanvasPointerEvent) => boolean\n /** to render background objects (behind nodes and connections) in the canvas affected by transform */\n onDrawBackground?: (ctx: CanvasRenderingContext2D, visible_area: any) => void\n /** to render foreground objects (above nodes and connections) in the canvas affected by transform */\n onDrawForeground?: (arg0: CanvasRenderingContext2D, arg1: any) => void\n connections_width: number\n /** The current node being drawn by {@link drawNode}. This should NOT be used to determine the currently selected node. See {@link selectedItems} */\n current_node: LGraphNode | null\n /** used for widgets */\n node_widget?: [LGraphNode, IBaseWidget] | null\n /** The link to draw a tooltip for. */\n over_link_center?: LinkSegment\n last_mouse_position: Point\n /** The visible area of this canvas. Tightly coupled with {@link ds}. */\n visible_area: Rectangle\n /** Contains all links and reroutes that were rendered. Repopulated every render cycle. */\n renderedPaths: Set<LinkSegment> = new Set()\n /** @deprecated Replaced by {@link renderedPaths}, but length is set to 0 by some extensions. */\n visible_links: LLink[] = []\n /** @deprecated This array is populated and cleared to support legacy extensions. The contents are ignored by Litegraph. */\n connecting_links: ConnectingLink[] | null\n linkConnector = new LinkConnector(links => this.connecting_links = links)\n /** The viewport of this canvas. Tightly coupled with {@link ds}. */\n readonly viewport?: Rect\n autoresize: boolean\n static active_canvas: LGraphCanvas\n frame = 0\n last_draw_time = 0\n render_time = 0\n fps = 0\n /** @deprecated See {@link LGraphCanvas.selectedItems} */\n selected_nodes: Dictionary<LGraphNode> = {}\n /** All selected nodes, groups, and reroutes */\n selectedItems: Set<Positionable> = new Set()\n /** The group currently being resized. */\n resizingGroup: LGraphGroup | null = null\n /** @deprecated See {@link LGraphCanvas.selectedItems} */\n selected_group: LGraphGroup | null = null\n /** The nodes that are currently visible on the canvas. */\n visible_nodes: LGraphNode[] = []\n /**\n * The IDs of the nodes that are currently visible on the canvas. More\n * performant than {@link visible_nodes} for visibility checks.\n */\n #visible_node_ids: Set<NodeId> = new Set()\n node_over?: LGraphNode\n node_capturing_input?: LGraphNode | null\n highlighted_links: Dictionary<boolean> = {}\n\n #visibleReroutes: Set<Reroute> = new Set()\n\n dirty_canvas: boolean = true\n dirty_bgcanvas: boolean = true\n /** A map of nodes that require selective-redraw */\n dirty_nodes = new Map<NodeId, LGraphNode>()\n dirty_area?: Rect | null\n /** @deprecated Unused */\n node_in_panel?: LGraphNode | null\n last_mouse: ReadOnlyPoint = [0, 0]\n last_mouseclick: number = 0\n graph: LGraph | Subgraph | null\n get _graph(): LGraph | Subgraph {\n if (!this.graph) throw new NullGraphError()\n return this.graph\n }\n\n canvas: HTMLCanvasElement & ICustomEventTarget<LGraphCanvasEventMap>\n bgcanvas: HTMLCanvasElement\n ctx: CanvasRenderingContext2D\n _events_binded?: boolean\n _mousedown_callback?(e: PointerEvent): void\n _mousewheel_callback?(e: WheelEvent): void\n _mousemove_callback?(e: PointerEvent): void\n _mouseup_callback?(e: PointerEvent): void\n _mouseout_callback?(e: PointerEvent): void\n _mousecancel_callback?(e: PointerEvent): void\n _key_callback?(e: KeyboardEvent): void\n bgctx?: CanvasRenderingContext2D | null\n is_rendering?: boolean\n /** @deprecated Panels */\n block_click?: boolean\n /** @deprecated Panels */\n last_click_position?: Point | null\n resizing_node?: LGraphNode | null\n /** @deprecated See {@link LGraphCanvas.resizingGroup} */\n selected_group_resizing?: boolean\n /** @deprecated See {@link pointer}.{@link CanvasPointer.dragStarted dragStarted} */\n last_mouse_dragging?: boolean\n onMouseDown?: (arg0: CanvasPointerEvent) => void\n _highlight_pos?: Point\n _highlight_input?: INodeInputSlot\n // TODO: Check if panels are used\n /** @deprecated Panels */\n node_panel?: any\n /** @deprecated Panels */\n options_panel?: any\n _bg_img?: HTMLImageElement\n _pattern?: CanvasPattern\n _pattern_img?: HTMLImageElement\n // TODO: This looks like another panel thing\n prompt_box?: PromptDialog | null\n search_box?: HTMLDivElement\n /** @deprecated Panels */\n SELECTED_NODE?: LGraphNode\n /** @deprecated Panels */\n NODEPANEL_IS_OPEN?: boolean\n\n /** Once per frame check of snap to grid value. @todo Update on change. */\n #snapToGrid?: number\n /** Set on keydown, keyup. @todo */\n #shiftDown: boolean = false\n\n /** If true, enable drag zoom. Ctrl+Shift+Drag Up/Down: zoom canvas. */\n dragZoomEnabled: boolean = false\n /** The start position of the drag zoom. */\n #dragZoomStart: { pos: Point, scale: number } | null = null\n\n getMenuOptions?(): IContextMenuValue<string>[]\n getExtraMenuOptions?(\n canvas: LGraphCanvas,\n options: IContextMenuValue<string>[],\n ): IContextMenuValue<string>[]\n static active_node: LGraphNode\n /** called before modifying the graph */\n onBeforeChange?(graph: LGraph): void\n /** called after modifying the graph */\n onAfterChange?(graph: LGraph): void\n onClear?: () => void\n /** called after moving a node @deprecated Does not handle multi-node move, and can return the wrong node. */\n onNodeMoved?: (node_dragged: LGraphNode | undefined) => void\n /** @deprecated Called with the deprecated {@link selected_nodes} when the selection changes. Replacement not yet impl. */\n onSelectionChange?: (selected: Dictionary<Positionable>) => void\n /** called when rendering a tooltip */\n onDrawLinkTooltip?: (\n ctx: CanvasRenderingContext2D,\n link: LLink | null,\n canvas?: LGraphCanvas,\n ) => boolean\n\n /** to render foreground objects not affected by transform (for GUIs) */\n onDrawOverlay?: (ctx: CanvasRenderingContext2D) => void\n onRenderBackground?: (\n canvas: HTMLCanvasElement,\n ctx: CanvasRenderingContext2D,\n ) => boolean\n\n onNodeDblClicked?: (n: LGraphNode) => void\n onShowNodePanel?: (n: LGraphNode) => void\n onNodeSelected?: (node: LGraphNode) => void\n onNodeDeselected?: (node: LGraphNode) => void\n onRender?: (canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D) => void\n\n /**\n * Creates a new instance of LGraphCanvas.\n * @param canvas The canvas HTML element (or its id) to use, or null / undefined to leave blank.\n * @param graph The graph that owns this canvas.\n * @param options\n */\n constructor(\n canvas: HTMLCanvasElement,\n graph: LGraph,\n options?: LGraphCanvas[\"options\"],\n ) {\n options ||= {}\n this.options = options\n\n // if(graph === undefined)\n // throw (\"No graph assigned\");\n this.background_image = LGraphCanvas.DEFAULT_BACKGROUND_IMAGE\n\n this.ds = new DragAndScale(canvas)\n this.pointer = new CanvasPointer(canvas)\n\n this.linkConnector.events.addEventListener(\"link-created\", () => this.#dirty())\n\n // @deprecated Workaround: Keep until connecting_links is removed.\n this.linkConnector.events.addEventListener(\"reset\", () => {\n this.connecting_links = null\n this.dirty_bgcanvas = true\n })\n\n // Dropped a link on the canvas\n this.linkConnector.events.addEventListener(\"dropped-on-canvas\", (customEvent) => {\n if (!this.connecting_links) return\n\n const e = customEvent.detail\n this.emitEvent({\n subType: \"empty-release\",\n originalEvent: e,\n linkReleaseContext: { links: this.connecting_links },\n })\n\n const firstLink = this.linkConnector.renderLinks[0]\n\n // No longer in use\n // add menu when releasing link in empty space\n if (LiteGraph.release_link_on_empty_shows_menu) {\n const linkReleaseContext = this.linkConnector.state.connectingTo === \"input\"\n ? {\n node_from: firstLink.node as LGraphNode,\n slot_from: firstLink.fromSlot as INodeOutputSlot,\n type_filter_in: firstLink.fromSlot.type,\n }\n : {\n node_to: firstLink.node as LGraphNode,\n slot_to: firstLink.fromSlot as INodeInputSlot,\n type_filter_out: firstLink.fromSlot.type,\n }\n\n const afterRerouteId = firstLink.fromReroute?.id\n\n if (\"shiftKey\" in e && e.shiftKey) {\n if (this.allow_searchbox) {\n this.showSearchBox(e as unknown as MouseEvent, linkReleaseContext as IShowSearchOptions)\n }\n } else if (this.linkConnector.state.connectingTo === \"input\") {\n this.showConnectionMenu({ nodeFrom: firstLink.node as LGraphNode, slotFrom: firstLink.fromSlot as INodeOutputSlot, e, afterRerouteId })\n } else {\n this.showConnectionMenu({ nodeTo: firstLink.node as LGraphNode, slotTo: firstLink.fromSlot as INodeInputSlot, e, afterRerouteId })\n }\n }\n })\n\n // otherwise it generates ugly patterns when scaling down too much\n this.zoom_modify_alpha = true\n // in range (1.01, 2.5). Less than 1 will invert the zoom direction\n this.zoom_speed = 1.1\n\n this.node_title_color = LiteGraph.NODE_TITLE_COLOR\n this.default_link_color = LiteGraph.LINK_COLOR\n this.default_connection_color = {\n input_off: \"#778\",\n input_on: \"#7F7\",\n output_off: \"#778\",\n output_on: \"#7F7\",\n }\n this.default_connection_color_byType = {\n /* number: \"#7F7\",\n string: \"#77F\",\n boolean: \"#F77\", */\n }\n this.default_connection_color_byTypeOff = {\n /* number: \"#474\",\n string: \"#447\",\n boolean: \"#744\", */\n }\n\n this.highquality_render = true\n // set to true to render titlebar with gradients\n this.use_gradients = false\n // used for transition\n this.editor_alpha = 1\n this.pause_rendering = false\n this.clear_background = true\n this.clear_background_color = \"#222\"\n\n this.render_only_selected = true\n this.show_info = true\n this.allow_dragcanvas = true\n this.allow_dragnodes = true\n // allow to control widgets, buttons, collapse, etc\n this.allow_interaction = true\n // allow selecting multi nodes without pressing extra keys\n this.multi_select = false\n this.allow_searchbox = true\n // allows to change a connection with having to redo it again\n this.allow_reconnect_links = true\n // snap to grid\n this.align_to_grid = false\n\n this.drag_mode = false\n this.dragging_rectangle = null\n\n // allows to filter to only accept some type of nodes in a graph\n this.filter = null\n\n // forces to redraw the canvas on mouse events (except move)\n this.set_canvas_dirty_on_mouse_event = true\n this.always_render_background = false\n this.render_shadows = true\n this.render_canvas_border = true\n // too much cpu\n this.render_connections_shadows = false\n this.render_connections_border = true\n this.render_curved_connections = false\n this.render_connection_arrows = false\n this.render_collapsed_slots = true\n this.render_execution_order = false\n this.render_link_tooltip = true\n\n this.links_render_mode = LinkRenderType.SPLINE_LINK\n\n this.mouse = [0, 0]\n this.graph_mouse = [0, 0]\n this.canvas_mouse = this.graph_mouse\n\n this.connections_width = 3\n\n this.current_node = null\n this.node_widget = null\n this.last_mouse_position = [0, 0]\n this.visible_area = this.ds.visible_area\n // Explicitly null-checked\n this.connecting_links = null\n\n // to constraint render area to a portion of the canvas\n this.viewport = options.viewport || null\n\n // link canvas and graph\n this.graph = graph\n graph?.attachCanvas(this)\n\n // TypeScript strict workaround: cannot use method to initialize properties.\n this.canvas = undefined!\n this.bgcanvas = undefined!\n this.ctx = undefined!\n\n this.setCanvas(canvas, options.skip_events)\n this.clear()\n\n LGraphCanvas._measureText = (text: string, fontStyle = this.inner_text_font) => {\n const { ctx } = this\n const { font } = ctx\n try {\n ctx.font = fontStyle\n return ctx.measureText(text).width\n } finally {\n ctx.font = font\n }\n }\n\n if (!options.skip_render) {\n this.startRendering()\n }\n\n this.autoresize = options.autoresize\n }\n\n static onGroupAdd(info: unknown, entry: unknown, mouse_event: MouseEvent): void {\n const canvas = LGraphCanvas.active_canvas\n\n const group = new LiteGraph.LGraphGroup()\n group.pos = canvas.convertEventToCanvasOffset(mouse_event)\n if (!canvas.graph) throw new NullGraphError()\n canvas.graph.add(group)\n }\n\n /**\n * @deprecated Functionality moved to {@link getBoundaryNodes}. The new function returns null on failure, instead of an object with all null properties.\n * Determines the furthest nodes in each direction\n * @param nodes the nodes to from which boundary nodes will be extracted\n * @returns\n */\n static getBoundaryNodes(\n nodes: LGraphNode[] | Dictionary<LGraphNode>,\n ): NullableProperties<IBoundaryNodes> {\n const _nodes = Array.isArray(nodes) ? nodes : Object.values(nodes)\n return (\n getBoundaryNodes(_nodes) ?? {\n top: null,\n right: null,\n bottom: null,\n left: null,\n }\n )\n }\n\n /**\n * @deprecated Functionality moved to {@link alignNodes}. The new function does not set dirty canvas.\n * @param nodes a list of nodes\n * @param direction Direction to align the nodes\n * @param align_to Node to align to (if null, align to the furthest node in the given direction)\n */\n static alignNodes(\n nodes: Dictionary<LGraphNode>,\n direction: Direction,\n align_to?: LGraphNode,\n ): void {\n alignNodes(Object.values(nodes), direction, align_to)\n LGraphCanvas.active_canvas.setDirty(true, true)\n }\n\n static onNodeAlign(\n value: IContextMenuValue,\n options: IContextMenuOptions,\n event: MouseEvent,\n prev_menu: ContextMenu<string>,\n node: LGraphNode,\n ): void {\n new LiteGraph.ContextMenu([\"Top\", \"Bottom\", \"Left\", \"Right\"], {\n event,\n callback: inner_clicked,\n parentMenu: prev_menu,\n })\n\n function inner_clicked(value: string) {\n alignNodes(\n Object.values(LGraphCanvas.active_canvas.selected_nodes),\n value.toLowerCase() as Direction,\n node,\n )\n LGraphCanvas.active_canvas.setDirty(true, true)\n }\n }\n\n static onGroupAlign(\n value: IContextMenuValue,\n options: IContextMenuOptions,\n event: MouseEvent,\n prev_menu: ContextMenu<string>,\n ): void {\n new LiteGraph.ContextMenu([\"Top\", \"Bottom\", \"Left\", \"Right\"], {\n event,\n callback: inner_clicked,\n parentMenu: prev_menu,\n })\n\n function inner_clicked(value: string) {\n alignNodes(\n Object.values(LGraphCanvas.active_canvas.selected_nodes),\n value.toLowerCase() as Direction,\n )\n LGraphCanvas.active_canvas.setDirty(true, true)\n }\n }\n\n static createDistributeMenu(\n value: IContextMenuValue,\n options: IContextMenuOptions,\n event: MouseEvent,\n prev_menu: ContextMenu<string>,\n ): void {\n new LiteGraph.ContextMenu([\"Vertically\", \"Horizontally\"], {\n event,\n callback: inner_clicked,\n parentMenu: prev_menu,\n })\n\n function inner_clicked(value: string) {\n const canvas = LGraphCanvas.active_canvas\n distributeNodes(Object.values(canvas.selected_nodes), value === \"Horizontally\")\n canvas.setDirty(true, true)\n }\n }\n\n static onMenuAdd(\n value: unknown,\n options: unknown,\n e: MouseEvent,\n prev_menu?: ContextMenu<string>,\n callback?: (node: LGraphNode | null) => void,\n ): boolean | undefined {\n const canvas = LGraphCanvas.active_canvas\n const ref_window = canvas.getCanvasWindow()\n const { graph } = canvas\n if (!graph) return\n\n inner_onMenuAdded(\"\", prev_menu)\n return false\n\n type AddNodeMenu = Omit<IContextMenuValue<string>, \"callback\"> & {\n callback: (\n value: { value: string },\n event: Event,\n mouseEvent: MouseEvent,\n contextMenu: ContextMenu<string>\n ) => void\n }\n\n function inner_onMenuAdded(base_category: string, prev_menu?: ContextMenu<string>): void {\n if (!graph) return\n\n const categories = LiteGraph\n .getNodeTypesCategories(canvas.filter || graph.filter)\n .filter(category => category.startsWith(base_category))\n const entries: AddNodeMenu[] = []\n\n for (const category of categories) {\n if (!category) continue\n\n const base_category_regex = new RegExp(`^(${base_category})`)\n const category_name = category\n .replace(base_category_regex, \"\")\n .split(\"/\", 1)[0]\n const category_path =\n base_category === \"\"\n ? `${category_name}/`\n : `${base_category}${category_name}/`\n\n let name = category_name\n // in case it has a namespace like \"shader::math/rand\" it hides the namespace\n if (name.includes(\"::\")) name = name.split(\"::\", 2)[1]\n\n const index = entries.findIndex(entry => entry.value === category_path)\n if (index === -1) {\n entries.push({\n value: category_path,\n content: name,\n has_submenu: true,\n callback: function (value, event, mouseEvent, contextMenu) {\n inner_onMenuAdded(value.value, contextMenu)\n },\n })\n }\n }\n\n const nodes = LiteGraph.getNodeTypesInCategory(\n base_category.slice(0, -1),\n canvas.filter || graph.filter,\n )\n\n for (const node of nodes) {\n if (node.skip_list) continue\n\n const entry: AddNodeMenu = {\n value: node.type,\n content: node.title,\n has_submenu: false,\n callback: function (value, event, mouseEvent, contextMenu) {\n if (!canvas.graph) throw new NullGraphError()\n\n const first_event = contextMenu.getFirstEvent()\n canvas.graph.beforeChange()\n const node = LiteGraph.createNode(value.value)\n if (node) {\n if (!first_event) throw new TypeError(\"Context menu event was null. This should not occur in normal usage.\")\n node.pos = canvas.convertEventToCanvasOffset(first_event)\n canvas.graph.add(node)\n } else {\n console.warn(\"Failed to create node of type:\", value.value)\n }\n\n callback?.(node)\n canvas.graph.afterChange()\n },\n }\n\n entries.push(entry)\n }\n\n // @ts-expect-error Remove param ref_window - unused\n new LiteGraph.ContextMenu(entries, { event: e, parentMenu: prev_menu }, ref_window)\n }\n }\n\n static onMenuCollapseAll() {}\n static onMenuNodeEdit() {}\n\n /** @param _options Parameter is never used */\n static showMenuNodeOptionalOutputs(\n v: unknown,\n /** Unused - immediately overwritten */\n _options: INodeOutputSlot[],\n e: MouseEvent,\n prev_menu: ContextMenu<INodeSlotContextItem>,\n node: LGraphNode,\n ): boolean | undefined {\n if (!node) return\n\n const canvas = LGraphCanvas.active_canvas\n\n let entries: (IContextMenuValue<INodeSlotContextItem> | null)[] = []\n\n if (LiteGraph.do_add_triggers_slots && node.findOutputSlot(\"onExecuted\") == -1) {\n entries.push({ content: \"On Executed\", value: [\"onExecuted\", LiteGraph.EVENT, { nameLocked: true }], className: \"event\" })\n }\n // add callback for modifing the menu elements onMenuNodeOutputs\n const retEntries = node.onMenuNodeOutputs?.(entries)\n if (retEntries) entries = retEntries\n\n if (!entries.length) return\n\n new LiteGraph.ContextMenu<INodeSlotContextItem>(\n entries,\n {\n event: e,\n callback: inner_clicked,\n parentMenu: prev_menu,\n node,\n },\n )\n\n function inner_clicked(this: ContextMenuDivElement<INodeSlotContextItem>, v: IContextMenuValue<INodeSlotContextItem>, e: any, prev: any) {\n if (!node) return\n\n // TODO: This is a static method, so the below \"that\" appears broken.\n if (v.callback) v.callback.call(this, node, v, e, prev)\n\n if (!v.value) return\n\n const value = v.value[1]\n\n if (value &&\n (typeof value === \"object\" || Array.isArray(value))) {\n // submenu why?\n const entries = []\n for (const i in value) {\n entries.push({ content: i, value: value[i] })\n }\n new LiteGraph.ContextMenu(entries, {\n event: e,\n callback: inner_clicked,\n parentMenu: prev_menu,\n node,\n })\n return false\n }\n\n const { graph } = node\n if (!graph) throw new NullGraphError()\n\n graph.beforeChange()\n node.addOutput(v.value[0], v.value[1], v.value[2])\n\n // a callback to the node when adding a slot\n node.onNodeOutputAdd?.(v.value)\n canvas.setDirty(true, true)\n graph.afterChange()\n }\n\n return false\n }\n\n /** @param value Parameter is never used */\n static onShowMenuNodeProperties(\n value: NodeProperty | undefined,\n options: unknown,\n e: MouseEvent,\n prev_menu: ContextMenu<string>,\n node: LGraphNode,\n ): boolean | undefined {\n if (!node || !node.properties) return\n\n const canvas = LGraphCanvas.active_canvas\n const ref_window = canvas.getCanvasWindow()\n\n const entries: IContextMenuValue<string>[] = []\n for (const i in node.properties) {\n value = node.properties[i] !== undefined ? node.properties[i] : \" \"\n if (typeof value == \"object\")\n value = JSON.stringify(value)\n const info = node.getPropertyInfo(i)\n if (info.type == \"enum\" || info.type == \"combo\")\n value = LGraphCanvas.getPropertyPrintableValue(value, info.values)\n\n // value could contain invalid html characters, clean that\n value = LGraphCanvas.decodeHTML(stringOrEmpty(value))\n entries.push({\n content:\n `<span class='property_name'>${info.label || i}</span>` +\n `<span class='property_value'>${value}</span>`,\n value: i,\n })\n }\n if (!entries.length) {\n return\n }\n\n new LiteGraph.ContextMenu<string>(\n entries,\n {\n event: e,\n callback: inner_clicked,\n parentMenu: prev_menu,\n allow_html: true,\n node,\n },\n // @ts-expect-error Unused\n ref_window,\n )\n\n function inner_clicked(this: ContextMenuDivElement, v: { value: any }) {\n if (!node) return\n\n const rect = this.getBoundingClientRect()\n canvas.showEditPropertyValue(node, v.value, {\n position: [rect.left, rect.top],\n })\n }\n\n return false\n }\n\n /** @deprecated */\n static decodeHTML(str: string): string {\n const e = document.createElement(\"div\")\n e.textContent = str\n return e.innerHTML\n }\n\n static onMenuResizeNode(\n value: IContextMenuValue,\n options: IContextMenuOptions,\n e: MouseEvent,\n menu: ContextMenu,\n node: LGraphNode,\n ): void {\n if (!node) return\n\n const fApplyMultiNode = function (node: LGraphNode) {\n node.setSize(node.computeSize())\n }\n\n const canvas = LGraphCanvas.active_canvas\n if (!canvas.selected_nodes || Object.keys(canvas.selected_nodes).length <= 1) {\n fApplyMultiNode(node)\n } else {\n for (const i in canvas.selected_nodes) {\n fApplyMultiNode(canvas.selected_nodes[i])\n }\n }\n\n canvas.setDirty(true, true)\n }\n\n // TODO refactor :: this is used fot title but not for properties!\n static onShowPropertyEditor(\n item: { property: keyof LGraphNode, type: string },\n options: IContextMenuOptions<string>,\n e: MouseEvent,\n menu: ContextMenu<string>,\n node: LGraphNode,\n ): void {\n const property = item.property || \"title\"\n const value = node[property]\n\n const title = document.createElement(\"span\")\n title.className = \"name\"\n title.textContent = property\n\n const input = document.createElement(\"input\")\n Object.assign(input, { type: \"text\", className: \"value\", autofocus: true })\n\n const button = document.createElement(\"button\")\n button.textContent = \"OK\"\n\n // TODO refactor :: use createDialog ?\n const dialog = Object.assign(document.createElement(\"div\"), {\n is_modified: false,\n className: \"graphdialog\",\n close: () => dialog.remove(),\n })\n dialog.append(title, input, button)\n\n input.value = String(value)\n input.addEventListener(\"blur\", function () {\n this.focus()\n })\n input.addEventListener(\"keydown\", (e: KeyboardEvent) => {\n dialog.is_modified = true\n if (e.key == \"Escape\") {\n // ESC\n dialog.close()\n } else if (e.key == \"Enter\") {\n // save\n inner()\n } else if (!e.target || !(\"localName\" in e.target) || e.target.localName != \"textarea\") {\n return\n }\n e.preventDefault()\n e.stopPropagation()\n })\n\n const canvas = LGraphCanvas.active_canvas\n const canvasEl = canvas.canvas\n\n const rect = canvasEl.getBoundingClientRect()\n const offsetx = rect ? -20 - rect.left : -20\n const offsety = rect ? -20 - rect.top : -20\n\n if (e) {\n dialog.style.left = `${e.clientX + offsetx}px`\n dialog.style.top = `${e.clientY + offsety}px`\n } else {\n dialog.style.left = `${canvasEl.width * 0.5 + offsetx}px`\n dialog.style.top = `${canvasEl.height * 0.5 + offsety}px`\n }\n\n button.addEventListener(\"click\", inner)\n\n if (canvasEl.parentNode == null) throw new TypeError(\"canvasEl.parentNode was null\")\n canvasEl.parentNode.append(dialog)\n\n input.focus()\n\n let dialogCloseTimer: number\n dialog.addEventListener(\"mouseleave\", function () {\n if (LiteGraph.dialog_close_on_mouse_leave) {\n if (!dialog.is_modified && LiteGraph.dialog_close_on_mouse_leave) {\n dialogCloseTimer = setTimeout(\n dialog.close,\n LiteGraph.dialog_close_on_mouse_leave_delay,\n )\n }\n }\n })\n dialog.addEventListener(\"mouseenter\", function () {\n if (LiteGraph.dialog_close_on_mouse_leave) {\n if (dialogCloseTimer) clearTimeout(dialogCloseTimer)\n }\n })\n\n function inner() {\n if (input) setValue(input.value)\n }\n\n function setValue(value: NodeProperty) {\n if (item.type == \"Number\") {\n value = Number(value)\n } else if (item.type == \"Boolean\") {\n value = Boolean(value)\n }\n // @ts-expect-error Requires refactor.\n node[property] = value\n dialog.remove()\n canvas.setDirty(true, true)\n }\n }\n\n static getPropertyPrintableValue(value: unknown, values: unknown[] | object | undefined): string | undefined {\n if (!values) return String(value)\n\n if (Array.isArray(values)) {\n return String(value)\n }\n\n if (typeof values === \"object\") {\n let desc_value = \"\"\n for (const k in values) {\n // @ts-expect-error deprecated #578\n if (values[k] != value) continue\n\n desc_value = k\n break\n }\n return `${String(value)} (${desc_value})`\n }\n }\n\n static onMenuNodeCollapse(\n value: IContextMenuValue,\n options: IContextMenuOptions,\n e: MouseEvent,\n menu: ContextMenu,\n node: LGraphNode,\n ): void {\n if (!node.graph) throw new NullGraphError()\n\n node.graph.beforeChange()\n\n const fApplyMultiNode = function (node: LGraphNode) {\n node.collapse()\n }\n\n const graphcanvas = LGraphCanvas.active_canvas\n if (!graphcanvas.selected_nodes || Object.keys(graphcanvas.selected_nodes).length <= 1) {\n fApplyMultiNode(node)\n } else {\n for (const i in graphcanvas.selected_nodes) {\n fApplyMultiNode(graphcanvas.selected_nodes[i])\n }\n }\n\n node.graph.afterChange()\n }\n\n static onMenuToggleAdvanced(\n value: IContextMenuValue,\n options: IContextMenuOptions,\n e: MouseEvent,\n menu: ContextMenu,\n node: LGraphNode,\n ): void {\n if (!node.graph) throw new NullGraphError()\n\n node.graph.beforeChange()\n const fApplyMultiNode = function (node: LGraphNode) {\n node.toggleAdvanced()\n }\n\n const graphcanvas = LGraphCanvas.active_canvas\n if (!graphcanvas.selected_nodes || Object.keys(graphcanvas.selected_nodes).length <= 1) {\n fApplyMultiNode(node)\n } else {\n for (const i in graphcanvas.selected_nodes) {\n fApplyMultiNode(graphcanvas.selected_nodes[i])\n }\n }\n node.graph.afterChange()\n }\n\n static onMenuNodeMode(\n value: IContextMenuValue,\n options: IContextMenuOptions,\n e: MouseEvent,\n menu: ContextMenu,\n node: LGraphNode,\n ): boolean {\n new LiteGraph.ContextMenu(\n LiteGraph.NODE_MODES,\n { event: e, callback: inner_clicked, parentMenu: menu, node },\n )\n\n function inner_clicked(v: string) {\n if (!node) return\n\n const kV = Object.values(LiteGraph.NODE_MODES).indexOf(v)\n const fApplyMultiNode = function (node: LGraphNode) {\n if (kV !== -1 && LiteGraph.NODE_MODES[kV]) {\n node.changeMode(kV)\n } else {\n console.warn(`unexpected mode: ${v}`)\n node.changeMode(LGraphEventMode.ALWAYS)\n }\n }\n\n const graphcanvas = LGraphCanvas.active_canvas\n if (!graphcanvas.selected_nodes || Object.keys(graphcanvas.selected_nodes).length <= 1) {\n fApplyMultiNode(node)\n } else {\n for (const i in graphcanvas.selected_nodes) {\n fApplyMultiNode(graphcanvas.selected_nodes[i])\n }\n }\n }\n\n return false\n }\n\n /** @param value Parameter is never used */\n static onMenuNodeColors(\n value: IContextMenuValue<string | null>,\n options: IContextMenuOptions,\n e: MouseEvent,\n menu: ContextMenu<string | null>,\n node: LGraphNode,\n ): boolean {\n if (!node) throw \"no node for color\"\n\n const values: IContextMenuValue<string | null, unknown, { value: string | null }>[] = []\n values.push({\n value: null,\n content: \"<span style='display: block; padding-left: 4px;'>No color</span>\",\n })\n\n for (const i in LGraphCanvas.node_colors) {\n const color = LGraphCanvas.node_colors[i]\n value = {\n value: i,\n content: `<span style='display: block; color: #999; padding-left: 4px;` +\n ` border-left: 8px solid ${color.color}; background-color:${color.bgcolor}'>${i}</span>`,\n }\n values.push(value)\n }\n new LiteGraph.ContextMenu<string | null>(values, {\n event: e,\n callback: inner_clicked,\n parentMenu: menu,\n node,\n })\n\n function inner_clicked(v: IContextMenuValue<string>) {\n if (!node) return\n\n const fApplyColor = function (item: IColorable) {\n const colorOption = v.value ? LGraphCanvas.node_colors[v.value] : null\n item.setColorOption(colorOption)\n }\n\n const canvas = LGraphCanvas.active_canvas\n if (!canvas.selected_nodes || Object.keys(canvas.selected_nodes).length <= 1) {\n fApplyColor(node)\n } else {\n for (const i in canvas.selected_nodes) {\n fApplyColor(canvas.selected_nodes[i])\n }\n }\n canvas.setDirty(true, true)\n }\n\n return false\n }\n\n static onMenuNodeShapes(\n value: IContextMenuValue<typeof LiteGraph.VALID_SHAPES[number]>,\n options: IContextMenuOptions<typeof LiteGraph.VALID_SHAPES[number]>,\n e: MouseEvent,\n menu?: ContextMenu<typeof LiteGraph.VALID_SHAPES[number]>,\n node?: LGraphNode,\n ): boolean {\n if (!node) throw \"no node passed\"\n\n new LiteGraph.ContextMenu<typeof LiteGraph.VALID_SHAPES[number]>(LiteGraph.VALID_SHAPES, {\n event: e,\n callback: inner_clicked,\n parentMenu: menu,\n node,\n })\n\n function inner_clicked(v: typeof LiteGraph.VALID_SHAPES[number]) {\n if (!node) return\n if (!node.graph) throw new NullGraphError()\n\n node.graph.beforeChange()\n\n const fApplyMultiNode = function (node: LGraphNode) {\n node.shape = v\n }\n\n const canvas = LGraphCanvas.active_canvas\n if (!canvas.selected_nodes || Object.keys(canvas.selected_nodes).length <= 1) {\n fApplyMultiNode(node)\n } else {\n for (const i in canvas.selected_nodes) {\n fApplyMultiNode(canvas.selected_nodes[i])\n }\n }\n\n node.graph.afterChange()\n canvas.setDirty(true)\n }\n\n return false\n }\n\n static onMenuNodeRemove(): void {\n LGraphCanvas.active_canvas.deleteSelected()\n }\n\n static onMenuNodeClone(\n value: IContextMenuValue,\n options: IContextMenuOptions,\n e: MouseEvent,\n menu: ContextMenu,\n node: LGraphNode,\n ): void {\n const { graph } = node\n if (!graph) throw new NullGraphError()\n graph.beforeChange()\n\n const newSelected = new Set<LGraphNode>()\n\n const fApplyMultiNode = function (node: LGraphNode, newNodes: Set<LGraphNode>): void {\n if (node.clonable === false) return\n\n const newnode = node.clone()\n if (!newnode) return\n\n newnode.pos = [node.pos[0] + 5, node.pos[1] + 5]\n if (!node.graph) throw new NullGraphError()\n\n node.graph.add(newnode)\n newNodes.add(newnode)\n }\n\n const canvas = LGraphCanvas.active_canvas\n if (!canvas.selected_nodes || Object.keys(canvas.selected_nodes).length <= 1) {\n fApplyMultiNode(node, newSelected)\n } else {\n for (const i in canvas.selected_nodes) {\n fApplyMultiNode(canvas.selected_nodes[i], newSelected)\n }\n }\n\n if (newSelected.size) {\n canvas.selectNodes([...newSelected])\n }\n\n graph.afterChange()\n\n canvas.setDirty(true, true)\n }\n\n /**\n * clears all the data inside\n *\n */\n clear(): void {\n this.frame = 0\n this.last_draw_time = 0\n this.render_time = 0\n this.fps = 0\n\n // this.scale = 1;\n // this.offset = [0,0];\n this.dragging_rectangle = null\n\n this.selected_nodes = {}\n this.selected_group = null\n this.selectedItems.clear()\n this.state.selectionChanged = true\n this.onSelectionChange?.(this.selected_nodes)\n\n this.visible_nodes = []\n this.node_over = undefined\n this.node_capturing_input = null\n this.connecting_links = null\n this.highlighted_links = {}\n\n this.dragging_canvas = false\n\n this.#dirty()\n this.dirty_area = null\n\n this.node_in_panel = null\n this.node_widget = null\n\n this.last_mouse = [0, 0]\n this.last_mouseclick = 0\n this.pointer.reset()\n this.visible_area.set([0, 0, 0, 0])\n\n this.onClear?.()\n }\n\n /**\n * Assigns a new graph to this canvas.\n */\n setGraph(newGraph: LGraph | Subgraph): void {\n const { graph } = this\n if (newGraph === graph) return\n\n this.clear()\n newGraph.attachCanvas(this)\n\n this.dispatch(\"litegraph:set-graph\", { newGraph, oldGraph: graph })\n this.#dirty()\n }\n\n openSubgraph(subgraph: Subgraph): void {\n const { graph } = this\n if (!graph) throw new NullGraphError()\n\n const options = { bubbles: true, detail: { subgraph, closingGraph: graph }, cancelable: true }\n const mayContinue = this.canvas.dispatchEvent(new CustomEvent(\"subgraph-opening\", options))\n if (!mayContinue) return\n\n this.clear()\n this.subgraph = subgraph\n this.setGraph(subgraph)\n\n this.canvas.dispatchEvent(new CustomEvent(\"subgraph-opened\", options))\n }\n\n /**\n * @returns the visually active graph (in case there are more in the stack)\n */\n getCurrentGraph(): LGraph | null {\n return this.graph\n }\n\n /**\n * Finds the canvas if required, throwing on failure.\n * @param canvas Canvas element, or its element ID\n * @returns The canvas element\n * @throws If {@link canvas} is an element ID that does not belong to a valid HTML canvas element\n */\n #validateCanvas(\n canvas: string | HTMLCanvasElement,\n ): HTMLCanvasElement & { data?: LGraphCanvas } {\n if (typeof canvas === \"string\") {\n const el = document.getElementById(canvas)\n if (!(el instanceof HTMLCanvasElement)) throw \"Error validating LiteGraph canvas: Canvas element not found\"\n return el\n }\n return canvas\n }\n\n /**\n * Sets the current HTML canvas element.\n * Calls bindEvents to add input event listeners, and (re)creates the background canvas.\n * @param canvas The canvas element to assign, or its HTML element ID. If null or undefined, the current reference is cleared.\n * @param skip_events If true, events on the previous canvas will not be removed. Has no effect on the first invocation.\n */\n setCanvas(canvas: string | HTMLCanvasElement, skip_events?: boolean) {\n const element = this.#validateCanvas(canvas)\n if (element === this.canvas) return\n // maybe detach events from old_canvas\n if (!element && this.canvas && !skip_events) this.unbindEvents()\n\n this.canvas = element\n this.ds.element = element\n this.pointer.element = element\n\n if (!element) return\n\n // TODO: classList.add\n element.className += \" lgraphcanvas\"\n element.data = this\n\n // Background canvas: To render objects behind nodes (background, links, groups)\n this.bgcanvas = document.createElement(\"canvas\")\n this.bgcanvas.width = this.canvas.width\n this.bgcanvas.height = this.canvas.height\n\n const ctx = element.getContext?.(\"2d\")\n if (ctx == null) {\n if (element.localName != \"canvas\") {\n throw `Element supplied for LGraphCanvas must be a <canvas> element, you passed a ${element.localName}`\n }\n throw \"This browser doesn't support Canvas\"\n }\n this.ctx = ctx\n\n if (!skip_events) this.bindEvents()\n }\n\n /** Captures an event and prevents default - returns false. */\n _doNothing(e: Event): boolean {\n // console.log(\"pointerevents: _doNothing \"+e.type);\n e.preventDefault()\n return false\n }\n\n /** Captures an event and prevents default - returns true. */\n _doReturnTrue(e: Event): boolean {\n e.preventDefault()\n return true\n }\n\n /**\n * binds mouse, keyboard, touch and drag events to the canvas\n */\n bindEvents(): void {\n if (this._events_binded) {\n console.warn(\"LGraphCanvas: events already bound\")\n return\n }\n\n const { canvas } = this\n // hack used when moving canvas between windows\n const { document } = this.getCanvasWindow()\n\n this._mousedown_callback = this.processMouseDown.bind(this)\n this._mousewheel_callback = this.processMouseWheel.bind(this)\n this._mousemove_callback = this.processMouseMove.bind(this)\n this._mouseup_callback = this.processMouseUp.bind(this)\n this._mouseout_callback = this.processMouseOut.bind(this)\n this._mousecancel_callback = this.processMouseCancel.bind(this)\n\n canvas.addEventListener(\"pointerdown\", this._mousedown_callback, true)\n canvas.addEventListener(\"wheel\", this._mousewheel_callback, false)\n\n canvas.addEventListener(\"pointerup\", this._mouseup_callback, true)\n canvas.addEventListener(\"pointermove\", this._mousemove_callback)\n canvas.addEventListener(\"pointerout\", this._mouseout_callback)\n canvas.addEventListener(\"pointercancel\", this._mousecancel_callback, true)\n\n canvas.addEventListener(\"contextmenu\", this._doNothing)\n\n // Keyboard\n this._key_callback = this.processKey.bind(this)\n\n canvas.addEventListener(\"keydown\", this._key_callback, true)\n // keyup event must be bound on the document\n document.addEventListener(\"keyup\", this._key_callback, true)\n\n canvas.addEventListener(\"dragover\", this._doNothing, false)\n canvas.addEventListener(\"dragend\", this._doNothing, false)\n canvas.addEventListener(\"dragenter\", this._doReturnTrue, false)\n\n this._events_binded = true\n }\n\n /**\n * unbinds mouse events from the canvas\n */\n unbindEvents(): void {\n if (!this._events_binded) {\n console.warn(\"LGraphCanvas: no events bound\")\n return\n }\n\n // console.log(\"pointerevents: unbindEvents\");\n const { document } = this.getCanvasWindow()\n const { canvas } = this\n\n // Assertions: removing nullish is fine.\n canvas.removeEventListener(\"pointercancel\", this._mousecancel_callback!)\n canvas.removeEventListener(\"pointerout\", this._mouseout_callback!)\n canvas.removeEventListener(\"pointermove\", this._mousemove_callback!)\n canvas.removeEventListener(\"pointerup\", this._mouseup_callback!)\n canvas.removeEventListener(\"pointerdown\", this._mousedown_callback!)\n canvas.removeEventListener(\"wheel\", this._mousewheel_callback!)\n canvas.removeEventListener(\"keydown\", this._key_callback!)\n document.removeEventListener(\"keyup\", this._key_callback!)\n canvas.removeEventListener(\"contextmenu\", this._doNothing)\n canvas.removeEventListener(\"dragenter\", this._doReturnTrue)\n\n this._mousedown_callback = undefined\n this._mousewheel_callback = undefined\n this._key_callback = undefined\n\n this._events_binded = false\n }\n\n /**\n * Ensures the canvas will be redrawn on the next frame by setting the dirty flag(s).\n * Without parameters, this function does nothing.\n * @todo Impl. `setDirty()` or similar as shorthand to redraw everything.\n * @param fgcanvas If true, marks the foreground canvas as dirty (nodes and anything drawn on top of them). Default: false\n * @param bgcanvas If true, mark the background canvas as dirty (background, groups, links). Default: false\n */\n setDirty(fgcanvas: boolean, bgcanvas?: boolean): void {\n if (fgcanvas) this.dirty_canvas = true\n if (bgcanvas) this.dirty_bgcanvas = true\n }\n\n /** Marks the entire canvas as dirty. */\n #dirty(): void {\n this.dirty_canvas = true\n this.dirty_bgcanvas = true\n }\n\n #linkConnectorDrop(): void {\n const { graph, linkConnector, pointer } = this\n if (!graph) throw new NullGraphError()\n\n pointer.onDragEnd = upEvent => linkConnector.dropLinks(graph, upEvent)\n pointer.finally = () => this.linkConnector.reset(true)\n }\n\n /**\n * Used to attach the canvas in a popup\n * @returns returns the window where the canvas is attached (the DOM root node)\n */\n getCanvasWindow(): Window {\n if (!this.canvas) return window\n\n const doc = this.canvas.ownerDocument\n // @ts-expect-error Check if required\n return doc.defaultView || doc.parentWindow\n }\n\n /**\n * starts rendering the content of the canvas when needed\n *\n */\n startRendering(): void {\n // already rendering\n if (this.is_rendering) return\n\n this.is_rendering = true\n renderFrame.call(this)\n\n /** Render loop */\n function renderFrame(this: LGraphCanvas) {\n if (!this.pause_rendering) {\n this.draw()\n }\n\n const window = this.getCanvasWindow()\n if (this.is_rendering) {\n if (this.#maximumFrameGap > 0) {\n // Manual FPS limit\n const gap = this.#maximumFrameGap - (LiteGraph.getTime() - this.last_draw_time)\n setTimeout(renderFrame.bind(this), Math.max(1, gap))\n } else {\n // FPS limited by refresh rate\n window.requestAnimationFrame(renderFrame.bind(this))\n }\n }\n }\n }\n\n /**\n * stops rendering the content of the canvas (to save resources)\n *\n */\n stopRendering(): void {\n this.is_rendering = false\n /*\n if(this.rendering_timer_id)\n {\n clearInterval(this.rendering_timer_id);\n this.rendering_timer_id = null;\n }\n */\n }\n\n /* LiteGraphCanvas input */\n // used to block future mouse events (because of im gui)\n blockClick(): void {\n this.block_click = true\n this.last_mouseclick = 0\n }\n\n /**\n * Gets the widget at the current cursor position.\n * @param node Optional node to check for widgets under cursor\n * @returns The widget located at the current cursor position, if any is found.\n * @deprecated Use {@link LGraphNode.getWidgetOnPos} instead.\n * ```ts\n * const [x, y] = canvas.graph_mouse\n * const widget = canvas.node_over?.getWidgetOnPos(x, y, true)\n * ```\n */\n getWidgetAtCursor(node?: LGraphNode): IBaseWidget | undefined {\n node ??= this.node_over\n return node?.getWidgetOnPos(this.graph_mouse[0], this.graph_mouse[1], true)\n }\n\n /**\n * Clears highlight and mouse-over information from nodes that should not have it.\n *\n * Intended to be called when the pointer moves away from a node.\n * @param node The node that the mouse is now over\n * @param e MouseEvent that is triggering this\n */\n updateMouseOverNodes(node: LGraphNode | null, e: CanvasPointerEvent): void {\n if (!this.graph) throw new NullGraphError()\n\n const { pointer } = this\n const nodes = this.graph._nodes\n for (const otherNode of nodes) {\n if (otherNode.mouseOver && node != otherNode) {\n // mouse leave\n if (!pointer.eDown) pointer.resizeDirection = undefined\n otherNode.mouseOver = undefined\n this._highlight_input = undefined\n this._highlight_pos = undefined\n this.linkConnector.overWidget = undefined\n\n // Hover transitions\n // TODO: Implement single lerp ease factor for current progress on hover in/out.\n // In drawNode, multiply by ease factor and differential value (e.g. bg alpha +0.5).\n otherNode.lostFocusAt = LiteGraph.getTime()\n\n this.node_over?.onMouseLeave?.(e)\n this.node_over = undefined\n this.dirty_canvas = true\n }\n }\n }\n\n processMouseDown(e: PointerEvent): void {\n if (this.dragZoomEnabled && e.ctrlKey && e.shiftKey && !e.altKey && e.buttons) {\n this.#dragZoomStart = { pos: [e.x, e.y], scale: this.ds.scale }\n return\n }\n\n const { graph, pointer } = this\n this.adjustMouseEvent(e)\n if (e.isPrimary) pointer.down(e)\n\n if (this.set_canvas_dirty_on_mouse_event) this.dirty_canvas = true\n\n if (!graph) return\n\n const ref_window = this.getCanvasWindow()\n LGraphCanvas.active_canvas = this\n\n const x = e.clientX\n const y = e.clientY\n this.ds.viewport = this.viewport\n const is_inside = !this.viewport || isInRect(x, y, this.viewport)\n\n if (!is_inside) return\n\n const node = graph.getNodeOnPos(e.canvasX, e.canvasY, this.visible_nodes) ?? undefined\n\n this.mouse[0] = x\n this.mouse[1] = y\n this.graph_mouse[0] = e.canvasX\n this.graph_mouse[1] = e.canvasY\n this.last_click_position = [this.mouse[0], this.mouse[1]]\n\n pointer.isDouble = pointer.isDown && e.isPrimary\n pointer.isDown = true\n\n this.canvas.focus()\n\n LiteGraph.closeAllContextMenus(ref_window)\n\n if (this.onMouse?.(e) == true) return\n\n // left button mouse / single finger\n if (e.button === 0 && !pointer.isDouble) {\n this.#processPrimaryButton(e, node)\n } else if (e.button === 1) {\n this.#processMiddleButton(e, node)\n } else if (\n (e.button === 2 || pointer.isDouble) &&\n this.allow_interaction &&\n !this.read_only\n ) {\n // Right / aux button\n const { linkConnector, subgraph } = this\n\n // Sticky select - won't remove single nodes\n if (subgraph?.inputNode.containsPoint(this.graph_mouse)) {\n // Subgraph input node\n this.processSelect(subgraph.inputNode, e, true)\n subgraph.inputNode.onPointerDown(e, pointer, linkConnector)\n } else if (subgraph?.outputNode.containsPoint(this.graph_mouse)) {\n // Subgraph output node\n this.processSelect(subgraph.outputNode, e, true)\n subgraph.outputNode.onPointerDown(e, pointer, linkConnector)\n } else {\n if (node) {\n this.processSelect(node, e, true)\n } else if (this.links_render_mode !== LinkRenderType.HIDDEN_LINK) {\n // Reroutes\n const reroute = graph.getRerouteOnPos(e.canvasX, e.canvasY, this.#visibleReroutes)\n if (reroute) {\n if (e.altKey) {\n pointer.onClick = (upEvent) => {\n if (upEvent.altKey) {\n // Ensure deselected\n if (reroute.selected) {\n this.deselect(reroute)\n this.onSelectionChange?.(this.selected_nodes)\n }\n reroute.remove()\n }\n }\n } else {\n this.processSelect(reroute, e, true)\n }\n }\n }\n\n // Show context menu for the node or group under the pointer\n pointer.onClick ??= () => this.processContextMenu(node, e)\n }\n }\n\n this.last_mouse = [x, y]\n this.last_mouseclick = LiteGraph.getTime()\n this.last_mouse_dragging = true\n\n graph.change()\n\n // this is to ensure to defocus(blur) if a text input element is on focus\n if (\n !ref_window.document.activeElement ||\n (ref_window.document.activeElement.nodeName.toLowerCase() != \"input\" &&\n ref_window.document.activeElement.nodeName.toLowerCase() != \"textarea\")\n ) {\n e.preventDefault()\n }\n e.stopPropagation()\n\n this.onMouseDown?.(e)\n }\n\n /**\n * Returns the first matching positionable item at the given co-ordinates.\n *\n * Order of preference:\n * - Subgraph IO Nodes\n * - Reroutes\n * - Group titlebars\n * @param x The x coordinate in canvas space\n * @param y The y coordinate in canvas space\n * @returns The positionable item or undefined\n */\n #getPositionableOnPos(x: number, y: number): Positionable | undefined {\n const ioNode = this.subgraph?.getIoNodeOnPos(x, y)\n if (ioNode) return ioNode\n\n for (const reroute of this.#visibleReroutes) {\n if (reroute.containsPoint([x, y])) return reroute\n }\n\n return this.graph?.getGroupTitlebarOnPos(x, y)\n }\n\n #processPrimaryButton(e: CanvasPointerEvent, node: LGraphNode | undefined) {\n const { pointer, graph, linkConnector, subgraph } = this\n if (!graph) throw new NullGraphError()\n\n const x = e.canvasX\n const y = e.canvasY\n\n // Modifiers\n const ctrlOrMeta = e.ctrlKey || e.metaKey\n\n // Multi-select drag rectangle\n if (ctrlOrMeta && !e.altKey && LiteGraph.canvasNavigationMode === \"legacy\") {\n this.#setupNodeSelectionDrag(e, pointer, node)\n\n return\n }\n\n if (this.read_only) {\n pointer.finally = () => this.dragging_canvas = false\n this.dragging_canvas = true\n return\n }\n\n // clone node ALT dragging\n if (LiteGraph.alt_drag_do_clone_nodes && e.altKey && !e.ctrlKey && node && this.allow_interaction) {\n let newType = node.type\n\n if (node instanceof SubgraphNode) {\n const cloned = node.subgraph\n .clone()\n .asSerialisable()\n\n const subgraph = graph.createSubgraph(cloned)\n subgraph.configure(cloned)\n newType = subgraph.id\n }\n\n const node_data = node.clone()?.serialize()\n if (node_data?.type != null) {\n const cloned = LiteGraph.createNode(newType)\n if (cloned) {\n cloned.configure(node_data)\n cloned.pos[0] += 5\n cloned.pos[1] += 5\n\n if (this.allow_dragnodes) {\n pointer.onDragStart = (pointer) => {\n graph.add(cloned, false)\n this.#startDraggingItems(cloned, pointer)\n }\n pointer.onDragEnd = e => this.#processDraggedItems(e)\n } else {\n // TODO: Check if before/after change are necessary here.\n graph.beforeChange()\n graph.add(cloned, false)\n graph.afterChange()\n }\n\n return\n }\n }\n }\n\n // Node clicked\n if (node && (this.allow_interaction || node.flags.allow_interaction)) {\n this.#processNodeClick(e, ctrlOrMeta, node)\n } else {\n // Subgraph IO nodes\n if (subgraph) {\n const { inputNode, outputNode } = subgraph\n\n if (processSubgraphIONode(this, inputNode)) return\n if (processSubgraphIONode(this, outputNode)) return\n\n function processSubgraphIONode(canvas: LGraphCanvas, ioNode: SubgraphInputNode | SubgraphOutputNode) {\n if (!ioNode.containsPoint([x, y])) return false\n\n ioNode.onPointerDown(e, pointer, linkConnector)\n pointer.onClick ??= () => canvas.processSelect(ioNode, e)\n pointer.onDragStart ??= () => canvas.#startDraggingItems(ioNode, pointer, true)\n pointer.onDragEnd ??= eUp => canvas.#processDraggedItems(eUp)\n return true\n }\n }\n\n // Reroutes\n if (this.links_render_mode !== LinkRenderType.HIDDEN_LINK) {\n for (const reroute of this.#visibleReroutes) {\n const overReroute = reroute.containsPoint([x, y])\n if (!reroute.isSlotHovered && !overReroute) continue\n\n if (overReroute) {\n pointer.onClick = () => this.processSelect(reroute, e)\n if (!e.shiftKey) {\n pointer.onDragStart = pointer => this.#startDraggingItems(reroute, pointer, true)\n pointer.onDragEnd = e => this.#processDraggedItems(e)\n }\n }\n\n if (reroute.isOutputHovered || (overReroute && e.shiftKey)) {\n linkConnector.dragFromReroute(graph, reroute)\n this.#linkConnectorDrop()\n }\n\n if (reroute.isInputHovered) {\n linkConnector.dragFromRerouteToOutput(graph, reroute)\n this.#linkConnectorDrop()\n }\n\n reroute.hideSlots()\n this.dirty_bgcanvas = true\n return\n }\n }\n\n // Links - paths of links & reroutes\n // Set the width of the line for isPointInStroke checks\n const { lineWidth } = this.ctx\n this.ctx.lineWidth = this.connections_width + 7\n const dpi = window?.devicePixelRatio || 1\n\n for (const linkSegment of this.renderedPaths) {\n const centre = linkSegment._pos\n if (!centre) continue\n\n // If we shift click on a link then start a link from that input\n if (\n (e.shiftKey || e.altKey) &&\n linkSegment.path &&\n this.ctx.isPointInStroke(linkSegment.path, x * dpi, y * dpi)\n ) {\n this.ctx.lineWidth = lineWidth\n\n if (e.shiftKey && !e.altKey) {\n linkConnector.dragFromLinkSegment(graph, linkSegment)\n this.#linkConnectorDrop()\n\n return\n } else if (e.altKey && !e.shiftKey) {\n const newReroute = graph.createReroute([x, y], linkSegment)\n pointer.onDragStart = pointer => this.#startDraggingItems(newReroute, pointer)\n pointer.onDragEnd = e => this.#processDraggedItems(e)\n return\n }\n } else if (isInRectangle(x, y, centre[0] - 4, centre[1] - 4, 8, 8)) {\n this.ctx.lineWidth = lineWidth\n\n pointer.onClick = () => this.showLinkMenu(linkSegment, e)\n pointer.onDragStart = () => this.dragging_canvas = true\n pointer.finally = () => this.dragging_canvas = false\n\n // clear tooltip\n this.over_link_center = undefined\n return\n }\n }\n\n // Restore line width\n this.ctx.lineWidth = lineWidth\n\n // Groups\n const group = graph.getGroupOnPos(x, y)\n this.selected_group = group ?? null\n if (group) {\n if (group.isInResize(x, y)) {\n // Resize group\n const b = group.boundingRect\n const offsetX = x - (b[0] + b[2])\n const offsetY = y - (b[1] + b[3])\n\n pointer.onDragStart = () => this.resizingGroup = group\n pointer.onDrag = (eMove) => {\n if (this.read_only) return\n\n // Resize only by the exact pointer movement\n const pos: Point = [\n eMove.canvasX - group.pos[0] - offsetX,\n eMove.canvasY - group.pos[1] - offsetY,\n ]\n // Unless snapping.\n if (this.#snapToGrid) snapPoint(pos, this.#snapToGrid)\n\n const resized = group.resize(pos[0], pos[1])\n if (resized) this.dirty_bgcanvas = true\n }\n pointer.finally = () => this.resizingGroup = null\n } else {\n const f = group.font_size || LiteGraph.DEFAULT_GROUP_FONT_SIZE\n const headerHeight = f * 1.4\n if (\n isInRectangle(\n x,\n y,\n group.pos[0],\n group.pos[1],\n group.size[0],\n headerHeight,\n )\n ) {\n // In title bar\n pointer.onClick = () => this.processSelect(group, e)\n pointer.onDragStart = (pointer) => {\n group.recomputeInsideNodes()\n this.#startDraggingItems(group, pointer, true)\n }\n pointer.onDragEnd = e => this.#processDraggedItems(e)\n }\n }\n\n pointer.onDoubleClick = () => {\n this.emitEvent({\n subType: \"group-double-click\",\n originalEvent: e,\n group,\n })\n }\n } else {\n pointer.onDoubleClick = () => {\n // Double click within group should not trigger the searchbox.\n if (this.allow_searchbox) {\n this.showSearchBox(e)\n e.preventDefault()\n }\n this.emitEvent({\n subType: \"empty-double-click\",\n originalEvent: e,\n })\n }\n }\n }\n\n if (\n !pointer.onDragStart &&\n !pointer.onClick &&\n !pointer.onDrag &&\n this.allow_dragcanvas\n ) {\n // allow dragging canvas if canvas is not in standard, or read-only (pan mode in standard)\n if (LiteGraph.canvasNavigationMode !== \"standard\" || this.read_only) {\n pointer.onClick = () => this.processSelect(null, e)\n pointer.finally = () => this.dragging_canvas = false\n this.dragging_canvas = true\n } else {\n this.#setupNodeSelectionDrag(e, pointer)\n }\n }\n }\n\n #setupNodeSelectionDrag(e: CanvasPointerEvent, pointer: CanvasPointer, node?: LGraphNode | undefined): void {\n const dragRect = new Float32Array(4)\n\n dragRect[0] = e.canvasX\n dragRect[1] = e.canvasY\n dragRect[2] = 1\n dragRect[3] = 1\n\n pointer.onClick = (eUp) => {\n // Click, not drag\n const clickedItem = node ?? this.#getPositionableOnPos(eUp.canvasX, eUp.canvasY)\n this.processSelect(clickedItem, eUp)\n }\n pointer.onDragStart = () => this.dragging_rectangle = dragRect\n pointer.onDragEnd = upEvent => this.#handleMultiSelect(upEvent, dragRect)\n pointer.finally = () => this.dragging_rectangle = null\n }\n\n /**\n * Processes a pointerdown event inside the bounds of a node. Part of {@link processMouseDown}.\n * @param e The pointerdown event\n * @param ctrlOrMeta Ctrl or meta key is pressed\n * @param node The node to process a click event for\n */\n #processNodeClick(\n e: CanvasPointerEvent,\n ctrlOrMeta: boolean,\n node: LGraphNode,\n ): void {\n const { pointer, graph, linkConnector } = this\n if (!graph) throw new NullGraphError()\n\n const x = e.canvasX\n const y = e.canvasY\n\n pointer.onClick = () => this.processSelect(node, e)\n\n // Immediately bring to front\n if (!node.flags.pinned) {\n this.bringToFront(node)\n }\n\n // Collapse toggle\n const inCollapse = node.isPointInCollapse(x, y)\n if (inCollapse) {\n pointer.onClick = () => {\n node.collapse()\n this.setDirty(true, true)\n }\n } else if (!node.flags.collapsed) {\n const { inputs, outputs } = node\n\n // Outputs\n if (outputs) {\n for (const [i, output] of outputs.entries()) {\n const link_pos = node.getOutputPos(i)\n if (isInRectangle(x, y, link_pos[0] - 15, link_pos[1] - 10, 30, 20)) {\n // Drag multiple output links\n if (e.shiftKey && (output.links?.length || output._floatingLinks?.size)) {\n linkConnector.moveOutputLink(graph, output)\n this.#linkConnectorDrop()\n return\n }\n\n // New output link\n linkConnector.dragNewFromOutput(graph, node, output)\n this.#linkConnectorDrop()\n\n if (LiteGraph.shift_click_do_break_link_from) {\n if (e.shiftKey) {\n node.disconnectOutput(i)\n }\n } else if (LiteGraph.ctrl_alt_click_do_break_link) {\n if (ctrlOrMeta && e.altKey && !e.shiftKey) {\n node.disconnectOutput(i)\n }\n }\n\n // TODO: Move callbacks to the start of this closure (onInputClick is already correct).\n pointer.onDoubleClick = () => node.onOutputDblClick?.(i, e)\n pointer.onClick = () => node.onOutputClick?.(i, e)\n\n return\n }\n }\n }\n\n // Inputs\n if (inputs) {\n for (const [i, input] of inputs.entries()) {\n const link_pos = node.getInputPos(i)\n const isInSlot = input instanceof NodeInputSlot\n ? isInRect(x, y, input.boundingRect)\n : isInRectangle(x, y, link_pos[0] - 15, link_pos[1] - 10, 30, 20)\n\n if (isInSlot) {\n pointer.onDoubleClick = () => node.onInputDblClick?.(i, e)\n pointer.onClick = () => node.onInputClick?.(i, e)\n\n const shouldBreakLink = LiteGraph.ctrl_alt_click_do_break_link &&\n ctrlOrMeta &&\n e.altKey &&\n !e.shiftKey\n if (input.link !== null || input._floatingLinks?.size) {\n // Existing link\n if (shouldBreakLink || LiteGraph.click_do_break_link_to) {\n node.disconnectInput(i, true)\n } else if (e.shiftKey || this.allow_reconnect_links) {\n linkConnector.moveInputLink(graph, input)\n }\n }\n\n // Dragging a new link from input to output\n if (!linkConnector.isConnecting) {\n linkConnector.dragNewFromInput(graph, node, input)\n }\n\n this.#linkConnectorDrop()\n this.dirty_bgcanvas = true\n\n return\n }\n }\n }\n }\n\n // Click was inside the node, but not on input/output, or resize area\n const pos: Point = [x - node.pos[0], y - node.pos[1]]\n\n // Widget\n const widget = node.getWidgetOnPos(x, y)\n if (widget) {\n this.#processWidgetClick(e, node, widget)\n this.node_widget = [node, widget]\n } else {\n // Node background\n pointer.onDoubleClick = () => {\n // Double-click\n // Check if it's a double click on the title bar\n // Note: pos[1] is the y-coordinate of the node's body\n // If clicking on node header (title), pos[1] is negative\n if (pos[1] < 0 && !inCollapse) {\n node.onNodeTitleDblClick?.(e, pos, this)\n } else if (node instanceof SubgraphNode) {\n this.openSubgraph(node.subgraph)\n }\n\n node.onDblClick?.(e, pos, this)\n this.emitEvent({\n subType: \"node-double-click\",\n originalEvent: e,\n node,\n })\n this.processNodeDblClicked(node)\n }\n\n // Mousedown callback - can block drag\n if (node.onMouseDown?.(e, pos, this)) {\n // Node handled the event (e.g., title button clicked)\n // Set a no-op click handler to prevent fallback canvas dragging\n pointer.onClick = () => {}\n return\n }\n\n if (!this.allow_dragnodes) return\n\n // Check for resize AFTER checking all other interaction areas\n if (!node.flags.collapsed) {\n const resizeDirection = node.findResizeDirection(x, y)\n if (resizeDirection) {\n pointer.resizeDirection = resizeDirection\n const startBounds = new Rectangle(node.pos[0], node.pos[1], node.size[0], node.size[1])\n\n pointer.onDragStart = () => {\n graph.beforeChange()\n this.resizing_node = node\n }\n\n pointer.onDrag = (eMove) => {\n if (this.read_only) return\n\n const deltaX = eMove.canvasX - x\n const deltaY = eMove.canvasY - y\n\n const newBounds = new Rectangle(startBounds.x, startBounds.y, startBounds.width, startBounds.height)\n\n // Handle resize based on the direction\n switch (resizeDirection) {\n case \"NE\": // North-East (top-right)\n newBounds.y = startBounds.y + deltaY\n newBounds.width = startBounds.width + deltaX\n newBounds.height = startBounds.height - deltaY\n break\n case \"SE\": // South-East (bottom-right)\n newBounds.width = startBounds.width + deltaX\n newBounds.height = startBounds.height + deltaY\n break\n case \"SW\": // South-West (bottom-left)\n newBounds.x = startBounds.x + deltaX\n newBounds.width = startBounds.width - deltaX\n newBounds.height = startBounds.height + deltaY\n break\n case \"NW\": // North-West (top-left)\n newBounds.x = startBounds.x + deltaX\n newBounds.y = startBounds.y + deltaY\n newBounds.width = startBounds.width - deltaX\n newBounds.height = startBounds.height - deltaY\n break\n }\n\n // Apply snapping to position changes\n if (this.#snapToGrid) {\n if (resizeDirection.includes(\"N\") || resizeDirection.includes(\"W\")) {\n const originalX = newBounds.x\n const originalY = newBounds.y\n\n snapPoint(newBounds.pos, this.#snapToGrid)\n\n // Adjust size to compensate for snapped position\n if (resizeDirection.includes(\"N\")) {\n newBounds.height += originalY - newBounds.y\n }\n if (resizeDirection.includes(\"W\")) {\n newBounds.width += originalX - newBounds.x\n }\n }\n\n snapPoint(newBounds.size, this.#snapToGrid)\n }\n\n // Apply snapping to size changes\n\n // Enforce minimum size\n const min = node.computeSize()\n if (newBounds.width < min[0]) {\n // If resizing from left, adjust position to maintain right edge\n if (resizeDirection.includes(\"W\")) {\n newBounds.x = startBounds.x + startBounds.width - min[0]\n }\n newBounds.width = min[0]\n }\n if (newBounds.height < min[1]) {\n // If resizing from top, adjust position to maintain bottom edge\n if (resizeDirection.includes(\"N\")) {\n newBounds.y = startBounds.y + startBounds.height - min[1]\n }\n newBounds.height = min[1]\n }\n\n node.pos = newBounds.pos\n node.setSize(newBounds.size)\n\n this.#dirty()\n }\n\n pointer.onDragEnd = () => {\n this.#dirty()\n graph.afterChange(node)\n }\n pointer.finally = () => {\n this.resizing_node = null\n pointer.resizeDirection = undefined\n }\n\n // Set appropriate cursor for resize direction\n this.canvas.style.cursor = cursors[resizeDirection]\n return\n }\n }\n\n // Drag node\n pointer.onDragStart = pointer => this.#startDraggingItems(node, pointer, true)\n pointer.onDragEnd = e => this.#processDraggedItems(e)\n }\n\n this.dirty_canvas = true\n }\n\n #processWidgetClick(e: CanvasPointerEvent, node: LGraphNode, widget: IBaseWidget) {\n const { pointer } = this\n\n // Custom widget - CanvasPointer\n if (typeof widget.onPointerDown === \"function\") {\n const handled = widget.onPointerDown(pointer, node, this)\n if (handled) return\n }\n\n const oldValue = widget.value\n\n const pos = this.graph_mouse\n const x = pos[0] - node.pos[0]\n const y = pos[1] - node.pos[1]\n\n const widgetInstance = toConcreteWidget(widget, node, false)\n if (widgetInstance) {\n pointer.onClick = () => widgetInstance.onClick({\n e,\n node,\n canvas: this,\n })\n pointer.onDrag = eMove => widgetInstance.onDrag?.({\n e: eMove,\n node,\n canvas: this,\n })\n } else if (widget.mouse) {\n const result = widget.mouse(e, [x, y], node)\n if (result != null) this.dirty_canvas = result\n }\n\n // value changed\n if (oldValue != widget.value) {\n node.onWidgetChanged?.(widget.name, widget.value, oldValue, widget)\n if (!node.graph) throw new NullGraphError()\n node.graph._version++\n }\n\n // Clean up state var\n pointer.finally = () => {\n // Legacy custom widget callback\n if (widget.mouse) {\n const { eUp } = pointer\n if (!eUp) return\n const { canvasX, canvasY } = eUp\n widget.mouse(eUp, [canvasX - node.pos[0], canvasY - node.pos[1]], node)\n }\n\n this.node_widget = null\n }\n }\n\n /**\n * Pointer middle button click processing. Part of {@link processMouseDown}.\n * @param e The pointerdown event\n * @param node The node to process a click event for\n */\n #processMiddleButton(e: CanvasPointerEvent, node: LGraphNode | undefined) {\n const { pointer } = this\n\n if (\n LiteGraph.middle_click_slot_add_default_node &&\n node &&\n this.allow_interaction &&\n !this.read_only &&\n !this.connecting_links &&\n !node.flags.collapsed\n ) {\n // not dragging mouse to connect two slots\n let mClikSlot: INodeSlot | false = false\n let mClikSlot_index: number | false = false\n let mClikSlot_isOut: boolean = false\n const { inputs, outputs } = node\n\n // search for outputs\n if (outputs) {\n for (const [i, output] of outputs.entries()) {\n const link_pos = node.getOutputPos(i)\n if (isInRectangle(e.canvasX, e.canvasY, link_pos[0] - 15, link_pos[1] - 10, 30, 20)) {\n mClikSlot = output\n mClikSlot_index = i\n mClikSlot_isOut = true\n break\n }\n }\n }\n\n // search for inputs\n if (inputs) {\n for (const [i, input] of inputs.entries()) {\n const link_pos = node.getInputPos(i)\n if (isInRectangle(e.canvasX, e.canvasY, link_pos[0] - 15, link_pos[1] - 10, 30, 20)) {\n mClikSlot = input\n mClikSlot_index = i\n mClikSlot_isOut = false\n break\n }\n }\n }\n // Middle clicked a slot\n if (mClikSlot && mClikSlot_index !== false) {\n const alphaPosY =\n 0.5 -\n (mClikSlot_index + 1) /\n (mClikSlot_isOut ? outputs.length : inputs.length)\n const node_bounding = node.getBounding()\n // estimate a position: this is a bad semi-bad-working mess .. REFACTOR with\n // a correct autoplacement that knows about the others slots and nodes\n const posRef: Point = [\n !mClikSlot_isOut\n ? node_bounding[0]\n : node_bounding[0] + node_bounding[2],\n e.canvasY - 80,\n ]\n\n pointer.onClick = () => this.createDefaultNodeForSlot({\n nodeFrom: !mClikSlot_isOut ? null : node,\n slotFrom: !mClikSlot_isOut ? null : mClikSlot_index,\n nodeTo: !mClikSlot_isOut ? node : null,\n slotTo: !mClikSlot_isOut ? mClikSlot_index : null,\n position: posRef,\n nodeType: \"AUTO\",\n posAdd: [!mClikSlot_isOut ? -30 : 30, -alphaPosY * 130],\n posSizeFix: [!mClikSlot_isOut ? -1 : 0, 0],\n })\n }\n }\n\n // Drag canvas using middle mouse button\n if (this.allow_dragcanvas) {\n pointer.onDragStart = () => this.dragging_canvas = true\n pointer.finally = () => this.dragging_canvas = false\n }\n }\n\n #processDragZoom(e: PointerEvent): void {\n // stop canvas zoom action\n if (!e.buttons) {\n this.#dragZoomStart = null\n return\n }\n\n const start = this.#dragZoomStart\n if (!start) throw new TypeError(\"Drag-zoom state object was null\")\n if (!this.graph) throw new NullGraphError()\n\n // calculate delta\n const deltaY = e.y - start.pos[1]\n const startScale = start.scale\n\n const scale = startScale - deltaY / 100\n\n this.ds.changeScale(scale, start.pos)\n this.graph.change()\n }\n\n /**\n * Called when a mouse move event has to be processed\n */\n processMouseMove(e: PointerEvent): void {\n if (this.dragZoomEnabled && e.ctrlKey && e.shiftKey && this.#dragZoomStart) {\n this.#processDragZoom(e)\n return\n }\n\n if (this.autoresize) this.resize()\n\n if (this.set_canvas_dirty_on_mouse_event) this.dirty_canvas = true\n\n const { graph, resizingGroup, linkConnector, pointer, subgraph } = this\n if (!graph) return\n\n LGraphCanvas.active_canvas = this\n this.adjustMouseEvent(e)\n const mouse: ReadOnlyPoint = [e.clientX, e.clientY]\n this.mouse[0] = mouse[0]\n this.mouse[1] = mouse[1]\n const delta = [\n mouse[0] - this.last_mouse[0],\n mouse[1] - this.last_mouse[1],\n ]\n this.last_mouse = mouse\n const { canvasX: x, canvasY: y } = e\n this.graph_mouse[0] = x\n this.graph_mouse[1] = y\n\n if (e.isPrimary) pointer.move(e)\n\n /** See {@link state}.{@link LGraphCanvasState.hoveringOver hoveringOver} */\n let underPointer = CanvasItem.Nothing\n if (subgraph) {\n underPointer |= subgraph.inputNode.onPointerMove(e)\n underPointer |= subgraph.outputNode.onPointerMove(e)\n }\n\n if (this.block_click) {\n e.preventDefault()\n return\n }\n\n e.dragging = this.last_mouse_dragging\n\n if (this.node_widget) {\n // Legacy widget mouse callbacks for pointermove events\n const [node, widget] = this.node_widget\n\n if (widget?.mouse) {\n const relativeX = x - node.pos[0]\n const relativeY = y - node.pos[1]\n const result = widget.mouse(e, [relativeX, relativeY], node)\n if (result != null) this.dirty_canvas = result\n }\n }\n\n // get node over\n const node = graph.getNodeOnPos(\n x,\n y,\n this.visible_nodes,\n )\n\n const dragRect = this.dragging_rectangle\n if (dragRect) {\n dragRect[2] = x - dragRect[0]\n dragRect[3] = y - dragRect[1]\n this.dirty_canvas = true\n } else if (resizingGroup) {\n // Resizing a group\n underPointer |= CanvasItem.Group\n pointer.resizeDirection = \"SE\"\n } else if (this.dragging_canvas) {\n this.ds.offset[0] += delta[0] / this.ds.scale\n this.ds.offset[1] += delta[1] / this.ds.scale\n this.#dirty()\n } else if (\n (this.allow_interaction || node?.flags.allow_interaction) &&\n !this.read_only\n ) {\n if (linkConnector.isConnecting) this.dirty_canvas = true\n\n // remove mouseover flag\n this.updateMouseOverNodes(node, e)\n\n // mouse over a node\n if (node) {\n underPointer |= CanvasItem.Node\n\n if (node.redraw_on_mouse) this.dirty_canvas = true\n\n // For input/output hovering\n // to store the output of isOverNodeInput\n const pos: Point = [0, 0]\n const inputId = isOverNodeInput(node, x, y, pos)\n const outputId = isOverNodeOutput(node, x, y, pos)\n const overWidget = node.getWidgetOnPos(x, y, true) ?? undefined\n\n if (!node.mouseOver) {\n // mouse enter\n node.mouseOver = {}\n this.node_over = node\n this.dirty_canvas = true\n\n for (const reroute of this.#visibleReroutes) {\n reroute.hideSlots()\n this.dirty_bgcanvas = true\n }\n node.onMouseEnter?.(e)\n }\n\n // in case the node wants to do something\n node.onMouseMove?.(e, [x - node.pos[0], y - node.pos[1]], this)\n\n // The input the mouse is over has changed\n const { mouseOver } = node\n if (\n mouseOver.inputId !== inputId ||\n mouseOver.outputId !== outputId ||\n mouseOver.overWidget !== overWidget\n ) {\n mouseOver.inputId = inputId\n mouseOver.outputId = outputId\n mouseOver.overWidget = overWidget\n\n // State reset\n linkConnector.overWidget = undefined\n\n // Check if link is over anything it could connect to - record position of valid target for snap / highlight\n if (linkConnector.isConnecting) {\n const firstLink = linkConnector.renderLinks.at(0)\n\n // Default: nothing highlighted\n let highlightPos: Point | undefined\n let highlightInput: INodeInputSlot | undefined\n\n if (!firstLink || !linkConnector.isNodeValidDrop(node)) {\n // No link, or none of the dragged links may be dropped here\n } else if (linkConnector.state.connectingTo === \"input\") {\n if (overWidget) {\n // Check widgets first - inputId is only valid if over the input socket\n const slot = node.getSlotFromWidget(overWidget)\n\n if (slot && linkConnector.isInputValidDrop(node, slot)) {\n highlightInput = slot\n highlightPos = node.getInputSlotPos(slot)\n linkConnector.overWidget = overWidget\n }\n }\n\n // Not over a valid widget - treat drop on invalid widget same as node background\n if (!linkConnector.overWidget) {\n if (inputId === -1 && outputId === -1) {\n // Node background / title under the pointer\n const result = node.findInputByType(firstLink.fromSlot.type)\n if (result) {\n highlightInput = result.slot\n highlightPos = node.getInputSlotPos(result.slot)\n }\n } else if (\n inputId != -1 &&\n node.inputs[inputId] &&\n LiteGraph.isValidConnection(firstLink.fromSlot.type, node.inputs[inputId].type)\n ) {\n highlightPos = pos\n // XXX CHECK THIS\n highlightInput = node.inputs[inputId]\n }\n\n if (highlightInput) {\n const widget = node.getWidgetFromSlot(highlightInput)\n if (widget) linkConnector.overWidget = widget\n }\n }\n } else if (linkConnector.state.connectingTo === \"output\") {\n // Connecting from an input to an output\n if (inputId === -1 && outputId === -1) {\n const result = node.findOutputByType(firstLink.fromSlot.type)\n if (result) {\n highlightPos = node.getOutputPos(result.index)\n }\n } else {\n // check if I have a slot below de mouse\n if (\n outputId != -1 &&\n node.outputs[outputId] &&\n LiteGraph.isValidConnection(firstLink.fromSlot.type, node.outputs[outputId].type)\n ) {\n highlightPos = pos\n }\n }\n }\n this._highlight_pos = highlightPos\n this._highlight_input = highlightInput\n }\n\n this.dirty_canvas = true\n }\n\n // Resize direction - only show resize cursor if not over inputs/outputs/widgets\n if (!pointer.eDown) {\n if (inputId === -1 && outputId === -1 && !overWidget) {\n pointer.resizeDirection = node.findResizeDirection(x, y)\n } else {\n // Clear resize direction when over inputs/outputs/widgets\n pointer.resizeDirection &&= undefined\n }\n }\n } else {\n // Reroutes\n underPointer = this.#updateReroutes(underPointer)\n\n // Not over a node\n const segment = this.#getLinkCentreOnPos(e)\n if (this.over_link_center !== segment) {\n underPointer |= CanvasItem.Link\n this.over_link_center = segment\n this.dirty_bgcanvas = true\n }\n\n if (this.canvas) {\n const group = graph.getGroupOnPos(x, y)\n if (\n group &&\n !e.ctrlKey &&\n !this.read_only &&\n group.isInResize(x, y)\n ) {\n pointer.resizeDirection = \"SE\"\n } else {\n pointer.resizeDirection &&= undefined\n }\n }\n }\n\n // send event to node if capturing input (used with widgets that allow drag outside of the area of the node)\n if (this.node_capturing_input && this.node_capturing_input != node) {\n this.node_capturing_input.onMouseMove?.(\n e,\n [\n x - this.node_capturing_input.pos[0],\n y - this.node_capturing_input.pos[1],\n ],\n this,\n )\n }\n\n // Items being dragged\n if (this.isDragging) {\n const selected = this.selectedItems\n const allItems = e.ctrlKey ? selected : getAllNestedItems(selected)\n\n const deltaX = delta[0] / this.ds.scale\n const deltaY = delta[1] / this.ds.scale\n for (const item of allItems) {\n item.move(deltaX, deltaY, true)\n }\n\n this.#dirty()\n }\n }\n\n this.hoveringOver = underPointer\n\n e.preventDefault()\n return\n }\n\n /**\n * Updates the hover / snap state of all visible reroutes.\n * @returns The original value of {@link underPointer}, with any found reroute items added.\n */\n #updateReroutes(underPointer: CanvasItem): CanvasItem {\n const { graph, pointer, linkConnector } = this\n if (!graph) throw new NullGraphError()\n\n // Update reroute hover state\n if (!pointer.isDown) {\n let anyChanges = false\n for (const reroute of this.#visibleReroutes) {\n anyChanges ||= reroute.updateVisibility(this.graph_mouse)\n\n if (reroute.isSlotHovered) underPointer |= CanvasItem.RerouteSlot\n }\n if (anyChanges) this.dirty_bgcanvas = true\n } else if (linkConnector.isConnecting) {\n // Highlight the reroute that the mouse is over\n for (const reroute of this.#visibleReroutes) {\n if (reroute.containsPoint(this.graph_mouse)) {\n if (linkConnector.isRerouteValidDrop(reroute)) {\n linkConnector.overReroute = reroute\n this._highlight_pos = reroute.pos\n }\n\n return underPointer |= CanvasItem.RerouteSlot\n }\n }\n }\n\n this._highlight_pos &&= undefined\n linkConnector.overReroute &&= undefined\n return underPointer\n }\n\n /**\n * Start dragging an item, optionally including all other selected items.\n *\n * ** This function sets the {@link CanvasPointer.finally}() callback. **\n * @param item The item that the drag event started on\n * @param pointer The pointer event that initiated the drag, e.g. pointerdown\n * @param sticky If `true`, the item is added to the selection - see {@link processSelect}\n */\n #startDraggingItems(item: Positionable, pointer: CanvasPointer, sticky = false): void {\n this.emitBeforeChange()\n this.graph?.beforeChange()\n // Ensure that dragging is properly cleaned up, on success or failure.\n pointer.finally = () => {\n this.isDragging = false\n this.graph?.afterChange()\n this.emitAfterChange()\n }\n\n this.processSelect(item, pointer.eDown, sticky)\n this.isDragging = true\n }\n\n /**\n * Handles shared clean up and placement after items have been dragged.\n * @param e The event that completed the drag, e.g. pointerup, pointermove\n */\n #processDraggedItems(e: CanvasPointerEvent): void {\n const { graph } = this\n if (e.shiftKey || LiteGraph.alwaysSnapToGrid)\n graph?.snapToGrid(this.selectedItems)\n\n this.dirty_canvas = true\n this.dirty_bgcanvas = true\n\n // TODO: Replace legacy behaviour: callbacks were never extended for multiple items\n this.onNodeMoved?.(findFirstNode(this.selectedItems))\n }\n\n /**\n * Called when a mouse up event has to be processed\n */\n processMouseUp(e: PointerEvent): void {\n // early exit for extra pointer\n if (e.isPrimary === false) return\n\n const { graph, pointer } = this\n if (!graph) return\n\n LGraphCanvas.active_canvas = this\n\n this.adjustMouseEvent(e)\n\n const now = LiteGraph.getTime()\n e.click_time = now - this.last_mouseclick\n\n /** The mouseup event occurred near the mousedown event. */\n /** Normal-looking click event - mouseUp occurred near mouseDown, without dragging. */\n const isClick = pointer.up(e)\n if (isClick === true) {\n pointer.isDown = false\n pointer.isDouble = false\n // Required until all link behaviour is added to Pointer API\n this.connecting_links = null\n this.dragging_canvas = false\n\n graph.change()\n\n e.stopPropagation()\n e.preventDefault()\n return\n }\n\n this.last_mouse_dragging = false\n this.last_click_position = null\n\n // used to avoid sending twice a click in an immediate button\n this.block_click &&= false\n\n if (e.button === 0) {\n // left button\n this.selected_group = null\n\n this.isDragging = false\n\n const x = e.canvasX\n const y = e.canvasY\n\n if (!this.linkConnector.isConnecting) {\n this.dirty_canvas = true\n\n // @ts-expect-error Unused param\n this.node_over?.onMouseUp?.(e, [x - this.node_over.pos[0], y - this.node_over.pos[1]], this)\n this.node_capturing_input?.onMouseUp?.(e, [\n x - this.node_capturing_input.pos[0],\n y - this.node_capturing_input.pos[1],\n ])\n }\n } else if (e.button === 1) {\n // middle button\n this.dirty_canvas = true\n this.dragging_canvas = false\n } else if (e.button === 2) {\n // right button\n this.dirty_canvas = true\n }\n\n pointer.isDown = false\n pointer.isDouble = false\n\n graph.change()\n\n e.stopPropagation()\n e.preventDefault()\n return\n }\n\n /**\n * Called when the mouse moves off the canvas. Clears all node hover states.\n * @param e\n */\n processMouseOut(e: PointerEvent): void {\n // TODO: Check if document.contains(e.relatedTarget) - handle mouseover node textarea etc.\n this.adjustMouseEvent(e)\n this.updateMouseOverNodes(null, e)\n }\n\n processMouseCancel(): void {\n console.warn(\"Pointer cancel!\")\n this.pointer.reset()\n }\n\n /**\n * Called when a mouse wheel event has to be processed\n */\n processMouseWheel(e: WheelEvent): void {\n if (!this.graph || !this.allow_dragcanvas) return\n\n // TODO: Mouse wheel zoom rewrite\n // @ts-expect-error\n const delta = e.wheelDeltaY ?? e.detail * -60\n\n this.adjustMouseEvent(e)\n\n const pos: Point = [e.clientX, e.clientY]\n if (this.viewport && !isPointInRect(pos, this.viewport)) return\n\n let { scale } = this.ds\n\n if (LiteGraph.canvasNavigationMode === \"legacy\" || (LiteGraph.canvasNavigationMode === \"standard\" && e.ctrlKey)) {\n if (delta > 0) {\n scale *= this.zoom_speed\n } else if (delta < 0) {\n scale *= 1 / (this.zoom_speed)\n }\n this.ds.changeScale(scale, [e.clientX, e.clientY])\n } else if (\n LiteGraph.macTrackpadGestures &&\n (!LiteGraph.macGesturesRequireMac || navigator.userAgent.includes(\"Mac\"))\n ) {\n if (e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey) {\n if (e.deltaY > 0) {\n scale *= 1 / this.zoom_speed\n } else if (e.deltaY < 0) {\n scale *= this.zoom_speed\n }\n this.ds.changeScale(scale, [e.clientX, e.clientY])\n } else if (e.ctrlKey) {\n scale *= 1 + e.deltaY * (1 - this.zoom_speed) * 0.18\n this.ds.changeScale(scale, [e.clientX, e.clientY], false)\n } else if (e.shiftKey) {\n this.ds.offset[0] -= e.deltaY * 1.18 * (1 / scale)\n } else {\n this.ds.offset[0] -= e.deltaX * 1.18 * (1 / scale)\n this.ds.offset[1] -= e.deltaY * 1.18 * (1 / scale)\n }\n }\n\n this.graph.change()\n\n e.preventDefault()\n return\n }\n\n #noItemsSelected(): void {\n const event = new CustomEvent(\"litegraph:no-items-selected\", { bubbles: true })\n this.canvas.dispatchEvent(event)\n }\n\n /**\n * process a key event\n */\n processKey(e: KeyboardEvent): void {\n this.#shiftDown = e.shiftKey\n\n const { graph } = this\n if (!graph) return\n\n let block_default = false\n // @ts-expect-error\n if (e.target.localName == \"input\") return\n\n if (e.type == \"keydown\") {\n // TODO: Switch\n if (e.key === \" \") {\n // space\n this.read_only = true\n if (this._previously_dragging_canvas === null) {\n this._previously_dragging_canvas = this.dragging_canvas\n }\n this.dragging_canvas = this.pointer.isDown\n block_default = true\n } else if (e.key === \"Escape\") {\n // esc\n if (this.linkConnector.isConnecting) {\n this.linkConnector.reset()\n e.preventDefault()\n return\n }\n this.node_panel?.close()\n this.options_panel?.close()\n if (this.node_panel || this.options_panel) block_default = true\n } else if (e.keyCode === 65 && e.ctrlKey) {\n // select all Control A\n this.selectItems()\n block_default = true\n } else if (e.keyCode === 67 && (e.metaKey || e.ctrlKey) && !e.shiftKey) {\n // copy\n if (this.selected_nodes) {\n this.copyToClipboard()\n block_default = true\n }\n } else if (e.keyCode === 86 && (e.metaKey || e.ctrlKey)) {\n // paste\n this.pasteFromClipboard({ connectInputs: e.shiftKey })\n } else if (e.key === \"Delete\" || e.key === \"Backspace\") {\n // delete or backspace\n // @ts-expect-error\n if (e.target.localName != \"input\" && e.target.localName != \"textarea\") {\n if (this.selectedItems.size === 0) {\n this.#noItemsSelected()\n return\n }\n\n this.deleteSelected()\n block_default = true\n }\n }\n\n // TODO\n for (const node of Object.values(this.selected_nodes)) {\n node.onKeyDown?.(e)\n }\n } else if (e.type == \"keyup\") {\n if (e.key === \" \") {\n // space\n this.read_only = false\n this.dragging_canvas = (this._previously_dragging_canvas ?? false) && this.pointer.isDown\n this._previously_dragging_canvas = null\n }\n\n for (const node of Object.values(this.selected_nodes)) {\n node.onKeyUp?.(e)\n }\n }\n\n // TODO: Do we need to remeasure and recalculate everything on every key down/up?\n graph.change()\n\n if (block_default) {\n e.preventDefault()\n e.stopImmediatePropagation()\n }\n }\n\n /**\n * Copies canvas items to an internal, app-specific clipboard backed by local storage.\n * When called without parameters, it copies {@link selectedItems}.\n * @param items The items to copy. If nullish, all selected items are copied.\n */\n copyToClipboard(items?: Iterable<Positionable>): void {\n const serialisable: Required<ClipboardItems> = {\n nodes: [],\n groups: [],\n reroutes: [],\n links: [],\n subgraphs: [],\n }\n\n const subgraphs = new Set<Subgraph>()\n\n // Create serialisable objects\n for (const item of items ?? this.selectedItems) {\n if (item instanceof LGraphNode) {\n // Nodes\n if (item.clonable === false) continue\n\n const cloned = item.clone()?.serialize()\n if (!cloned) continue\n\n cloned.id = item.id\n serialisable.nodes.push(cloned)\n\n // Links\n if (item.inputs) {\n for (const { link: linkId } of item.inputs) {\n if (linkId == null) continue\n\n const link = this.graph?._links.get(linkId)?.asSerialisable()\n if (link) serialisable.links.push(link)\n }\n }\n\n // Find all unique referenced subgraphs\n if (item instanceof SubgraphNode) {\n subgraphs.add(item.subgraph)\n }\n } else if (item instanceof LGraphGroup) {\n // Groups\n serialisable.groups.push(item.serialize())\n } else if (item instanceof Reroute) {\n // Reroutes\n serialisable.reroutes.push(item.asSerialisable())\n }\n }\n\n // Add unique subgraph entries\n // TODO: Must find all nested subgraphs\n for (const subgraph of subgraphs) {\n const cloned = subgraph\n .clone(true)\n .asSerialisable()\n serialisable.subgraphs.push(cloned)\n }\n\n localStorage.setItem(\n \"litegrapheditor_clipboard\",\n JSON.stringify(serialisable),\n )\n }\n\n emitEvent(detail: LGraphCanvasEventMap[\"litegraph:canvas\"]): void {\n this.canvas.dispatchEvent(\n new CustomEvent(\"litegraph:canvas\", {\n bubbles: true,\n detail,\n }),\n )\n }\n\n /** @todo Refactor to where it belongs - e.g. Deleting / creating nodes is not actually canvas event. */\n emitBeforeChange(): void {\n this.emitEvent({\n subType: \"before-change\",\n })\n }\n\n /** @todo See {@link emitBeforeChange} */\n emitAfterChange(): void {\n this.emitEvent({\n subType: \"after-change\",\n })\n }\n\n /**\n * Pastes the items from the canvas \"clipbaord\" - a local storage variable.\n */\n _pasteFromClipboard(options: IPasteFromClipboardOptions = {}): ClipboardPasteResult | undefined {\n const {\n connectInputs = false,\n position = this.graph_mouse,\n } = options\n\n // if ctrl + shift + v is off, return when isConnectUnselected is true (shift is pressed) to maintain old behavior\n if (!LiteGraph.ctrl_shift_v_paste_connect_unselected_outputs && connectInputs) return\n\n const data = localStorage.getItem(\"litegrapheditor_clipboard\")\n if (!data) return\n\n const { graph } = this\n if (!graph) throw new NullGraphError()\n graph.beforeChange()\n\n // Parse & initialise\n const parsed: ClipboardItems = JSON.parse(data)\n parsed.nodes ??= []\n parsed.groups ??= []\n parsed.reroutes ??= []\n parsed.links ??= []\n parsed.subgraphs ??= []\n\n // Find top-left-most boundary\n let offsetX = Infinity\n let offsetY = Infinity\n for (const item of [...parsed.nodes, ...parsed.reroutes]) {\n if (item.pos == null) throw new TypeError(\"Invalid node encounterd on paste. `pos` was null.\")\n\n if (item.pos[0] < offsetX) offsetX = item.pos[0]\n if (item.pos[1] < offsetY) offsetY = item.pos[1]\n }\n\n // TODO: Remove when implementing `asSerialisable`\n if (parsed.groups) {\n for (const group of parsed.groups) {\n if (group.bounding[0] < offsetX) offsetX = group.bounding[0]\n if (group.bounding[1] < offsetY) offsetY = group.bounding[1]\n }\n }\n\n const results: ClipboardPasteResult = {\n created: [],\n nodes: new Map<NodeId, LGraphNode>(),\n links: new Map<LinkId, LLink>(),\n reroutes: new Map<RerouteId, Reroute>(),\n subgraphs: new Map<UUID, Subgraph>(),\n }\n const { created, nodes, links, reroutes } = results\n\n // const failedNodes: ISerialisedNode[] = []\n\n // Subgraphs\n for (const info of parsed.subgraphs) {\n // SubgraphV2: Remove always-clone behaviour\n const originalId = info.id\n info.id = createUuidv4()\n\n const subgraph = graph.createSubgraph(info)\n subgraph.configure(info)\n results.subgraphs.set(originalId, subgraph)\n }\n\n // Groups\n for (const info of parsed.groups) {\n info.id = -1\n\n const group = new LGraphGroup()\n group.configure(info)\n graph.add(group)\n created.push(group)\n }\n\n // Nodes\n for (const info of parsed.nodes) {\n // If the subgraph was cloned, update references to use the new subgraph ID.\n const subgraph = results.subgraphs.get(info.type)\n if (subgraph) info.type = subgraph.id\n\n const node = info.type == null ? null : LiteGraph.createNode(info.type)\n if (!node) {\n // failedNodes.push(info)\n continue\n }\n\n nodes.set(info.id, node)\n info.id = -1\n\n node.configure(info)\n graph.add(node)\n\n created.push(node)\n }\n\n // Reroutes\n for (const info of parsed.reroutes) {\n const { id, ...rerouteInfo } = info\n\n const reroute = graph.setReroute(rerouteInfo)\n created.push(reroute)\n reroutes.set(id, reroute)\n }\n\n // Remap reroute parentIds for pasted reroutes\n for (const reroute of reroutes.values()) {\n if (reroute.parentId == null) continue\n\n const mapped = reroutes.get(reroute.parentId)\n if (mapped) reroute.parentId = mapped.id\n }\n\n // Links\n for (const info of parsed.links) {\n // Find the copied node / reroute ID\n let outNode: LGraphNode | null | undefined = nodes.get(info.origin_id)\n let afterRerouteId: number | undefined\n if (info.parentId != null) afterRerouteId = reroutes.get(info.parentId)?.id\n\n // If it wasn't copied, use the original graph value\n if (connectInputs && LiteGraph.ctrl_shift_v_paste_connect_unselected_outputs) {\n outNode ??= graph.getNodeById(info.origin_id)\n afterRerouteId ??= info.parentId\n }\n\n const inNode = nodes.get(info.target_id)\n if (inNode) {\n const link = outNode?.connect(\n info.origin_slot,\n inNode,\n info.target_slot,\n afterRerouteId,\n )\n if (link) links.set(info.id, link)\n }\n }\n\n // Remap linkIds\n for (const reroute of reroutes.values()) {\n const ids = [...reroute.linkIds].map(x => links.get(x)?.id ?? x)\n reroute.update(reroute.parentId, undefined, ids, reroute.floating)\n\n // Remove any invalid items\n if (!reroute.validateLinks(graph.links, graph.floatingLinks)) {\n graph.removeReroute(reroute.id)\n }\n }\n\n // Adjust positions\n for (const item of created) {\n item.pos[0] += position[0] - offsetX\n item.pos[1] += position[1] - offsetY\n }\n\n // TODO: Report failures, i.e. `failedNodes`\n\n this.selectItems(created)\n\n graph.afterChange()\n\n return results\n }\n\n pasteFromClipboard(options: IPasteFromClipboardOptions = {}): void {\n this.emitBeforeChange()\n try {\n this._pasteFromClipboard(options)\n } finally {\n this.emitAfterChange()\n }\n }\n\n processNodeDblClicked(n: LGraphNode): void {\n this.onShowNodePanel?.(n)\n this.onNodeDblClicked?.(n)\n\n this.setDirty(true)\n }\n\n #handleMultiSelect(e: CanvasPointerEvent, dragRect: Float32Array) {\n // Process drag\n // Convert Point pair (pos, offset) to Rect\n const { graph, selectedItems, subgraph } = this\n if (!graph) throw new NullGraphError()\n\n const w = Math.abs(dragRect[2])\n const h = Math.abs(dragRect[3])\n if (dragRect[2] < 0) dragRect[0] -= w\n if (dragRect[3] < 0) dragRect[1] -= h\n dragRect[2] = w\n dragRect[3] = h\n\n // Select nodes - any part of the node is in the select area\n const isSelected = new Set<Positionable>()\n const notSelected: Positionable[] = []\n\n if (subgraph) {\n const { inputNode, outputNode } = subgraph\n\n if (overlapBounding(dragRect, inputNode.boundingRect)) {\n addPositionable(inputNode)\n }\n if (overlapBounding(dragRect, outputNode.boundingRect)) {\n addPositionable(outputNode)\n }\n }\n\n for (const nodeX of graph._nodes) {\n if (overlapBounding(dragRect, nodeX.boundingRect)) {\n addPositionable(nodeX)\n }\n }\n\n // Select groups - the group is wholly inside the select area\n for (const group of graph.groups) {\n if (!containsRect(dragRect, group._bounding)) continue\n\n group.recomputeInsideNodes()\n addPositionable(group)\n }\n\n // Select reroutes - the centre point is inside the select area\n for (const reroute of graph.reroutes.values()) {\n if (!isPointInRect(reroute.pos, dragRect)) continue\n\n selectedItems.add(reroute)\n reroute.selected = true\n addPositionable(reroute)\n }\n\n if (e.shiftKey) {\n // Add to selection\n for (const item of notSelected) this.select(item)\n } else if (e.altKey) {\n // Remove from selection\n for (const item of isSelected) this.deselect(item)\n } else {\n // Replace selection\n for (const item of selectedItems.values()) {\n if (!isSelected.has(item)) this.deselect(item)\n }\n for (const item of notSelected) this.select(item)\n }\n this.onSelectionChange?.(this.selected_nodes)\n\n function addPositionable(item: Positionable): void {\n if (!item.selected || !selectedItems.has(item)) notSelected.push(item)\n else isSelected.add(item)\n }\n }\n\n /**\n * Determines whether to select or deselect an item that has received a pointer event. Will deselect other nodes if\n * @param item Canvas item to select/deselect\n * @param e The MouseEvent to handle\n * @param sticky Prevents deselecting individual nodes (as used by aux/right-click)\n * @remarks\n * Accessibility: anyone using {@link mutli_select} always deselects when clicking empty space.\n */\n processSelect<TPositionable extends Positionable = LGraphNode>(\n item: TPositionable | null | undefined,\n e: CanvasPointerEvent | undefined,\n sticky: boolean = false,\n ): void {\n const addModifier = e?.shiftKey\n const subtractModifier = e != null && (e.metaKey || e.ctrlKey)\n const eitherModifier = addModifier || subtractModifier\n const modifySelection = eitherModifier || this.multi_select\n\n if (!item) {\n if (!eitherModifier || this.multi_select) this.deselectAll()\n } else if (!item.selected || !this.selectedItems.has(item)) {\n if (!modifySelection) this.deselectAll(item)\n this.select(item)\n } else if (modifySelection && !sticky) {\n this.deselect(item)\n } else if (!sticky) {\n this.deselectAll(item)\n } else {\n return\n }\n this.onSelectionChange?.(this.selected_nodes)\n this.setDirty(true)\n }\n\n /**\n * Selects a {@link Positionable} item.\n * @param item The canvas item to add to the selection.\n */\n select<TPositionable extends Positionable = LGraphNode>(item: TPositionable): void {\n if (item.selected && this.selectedItems.has(item)) return\n\n item.selected = true\n this.selectedItems.add(item)\n this.state.selectionChanged = true\n if (!(item instanceof LGraphNode)) return\n\n // Node-specific handling\n item.onSelected?.()\n this.selected_nodes[item.id] = item\n\n this.onNodeSelected?.(item)\n\n // Highlight links\n if (item.inputs) {\n for (const input of item.inputs) {\n if (input.link == null) continue\n this.highlighted_links[input.link] = true\n }\n }\n if (item.outputs) {\n for (const id of item.outputs.flatMap(x => x.links)) {\n if (id == null) continue\n this.highlighted_links[id] = true\n }\n }\n }\n\n /**\n * Deselects a {@link Positionable} item.\n * @param item The canvas item to remove from the selection.\n */\n deselect<TPositionable extends Positionable = LGraphNode>(item: TPositionable): void {\n if (!item.selected && !this.selectedItems.has(item)) return\n\n item.selected = false\n this.selectedItems.delete(item)\n this.state.selectionChanged = true\n if (!(item instanceof LGraphNode)) return\n\n // Node-specific handling\n item.onDeselected?.()\n delete this.selected_nodes[item.id]\n\n this.onNodeDeselected?.(item)\n\n // Should be moved to top of function, and throw if null\n const { graph } = this\n if (!graph) return\n\n // Clear link highlight\n if (item.inputs) {\n for (const input of item.inputs) {\n if (input.link == null) continue\n\n const node = LLink.getOriginNode(graph, input.link)\n if (node && this.selectedItems.has(node)) continue\n\n delete this.highlighted_links[input.link]\n }\n }\n if (item.outputs) {\n for (const id of item.outputs.flatMap(x => x.links)) {\n if (id == null) continue\n\n const node = LLink.getTargetNode(graph, id)\n if (node && this.selectedItems.has(node)) continue\n\n delete this.highlighted_links[id]\n }\n }\n }\n\n /** @deprecated See {@link LGraphCanvas.processSelect} */\n processNodeSelected(item: LGraphNode, e: CanvasPointerEvent): void {\n this.processSelect(\n item,\n e,\n e && (e.shiftKey || e.metaKey || e.ctrlKey || this.multi_select),\n )\n }\n\n /** @deprecated See {@link LGraphCanvas.select} */\n selectNode(node: LGraphNode, add_to_current_selection?: boolean): void {\n if (node == null) {\n this.deselectAll()\n } else {\n this.selectNodes([node], add_to_current_selection)\n }\n }\n\n get empty(): boolean {\n if (!this.graph) throw new NullGraphError()\n return this.graph.empty\n }\n\n get positionableItems() {\n if (!this.graph) throw new NullGraphError()\n return this.graph.positionableItems()\n }\n\n /**\n * Selects several items.\n * @param items Items to select - if falsy, all items on the canvas will be selected\n * @param add_to_current_selection If set, the items will be added to the current selection instead of replacing it\n */\n selectItems(items?: Positionable[], add_to_current_selection?: boolean): void {\n const itemsToSelect = items ?? this.positionableItems\n if (!add_to_current_selection) this.deselectAll()\n for (const item of itemsToSelect) this.select(item)\n this.onSelectionChange?.(this.selected_nodes)\n this.setDirty(true)\n }\n\n /**\n * selects several nodes (or adds them to the current selection)\n * @deprecated See {@link LGraphCanvas.selectItems}\n */\n selectNodes(nodes?: LGraphNode[], add_to_current_selection?: boolean): void {\n this.selectItems(nodes, add_to_current_selection)\n }\n\n /** @deprecated See {@link LGraphCanvas.deselect} */\n deselectNode(node: LGraphNode): void {\n this.deselect(node)\n }\n\n /**\n * Deselects all items on the canvas.\n * @param keepSelected If set, this item will not be removed from the selection.\n */\n deselectAll(keepSelected?: Positionable): void {\n if (!this.graph) return\n\n const selected = this.selectedItems\n if (!selected.size) return\n\n let wasSelected: Positionable | undefined\n for (const sel of selected) {\n if (sel === keepSelected) {\n wasSelected = sel\n continue\n }\n sel.onDeselected?.()\n sel.selected = false\n }\n selected.clear()\n if (wasSelected) selected.add(wasSelected)\n\n this.setDirty(true)\n\n // Legacy code\n const oldNode = keepSelected?.id == null ? null : this.selected_nodes[keepSelected.id]\n this.selected_nodes = {}\n this.current_node = null\n this.highlighted_links = {}\n\n if (keepSelected instanceof LGraphNode) {\n // Handle old object lookup\n if (oldNode) this.selected_nodes[oldNode.id] = oldNode\n\n // Highlight links\n if (keepSelected.inputs) {\n for (const input of keepSelected.inputs) {\n if (input.link == null) continue\n this.highlighted_links[input.link] = true\n }\n }\n if (keepSelected.outputs) {\n for (const id of keepSelected.outputs.flatMap(x => x.links)) {\n if (id == null) continue\n this.highlighted_links[id] = true\n }\n }\n }\n\n this.state.selectionChanged = true\n this.onSelectionChange?.(this.selected_nodes)\n }\n\n /** @deprecated See {@link LGraphCanvas.deselectAll} */\n deselectAllNodes(): void {\n this.deselectAll()\n }\n\n /**\n * Deletes all selected items from the graph.\n * @todo Refactor deletion task to LGraph. Selection is a canvas property, delete is a graph action.\n */\n deleteSelected(): void {\n const { graph } = this\n if (!graph) throw new NullGraphError()\n\n this.emitBeforeChange()\n graph.beforeChange()\n\n for (const item of this.selectedItems) {\n if (item instanceof LGraphNode) {\n const node = item\n if (node.block_delete) continue\n node.connectInputToOutput()\n graph.remove(node)\n this.onNodeDeselected?.(node)\n } else if (item instanceof LGraphGroup) {\n graph.remove(item)\n } else if (item instanceof Reroute) {\n graph.removeReroute(item.id)\n }\n }\n\n this.selected_nodes = {}\n this.selectedItems.clear()\n this.current_node = null\n this.highlighted_links = {}\n\n this.state.selectionChanged = true\n this.onSelectionChange?.(this.selected_nodes)\n this.setDirty(true)\n graph.afterChange()\n this.emitAfterChange()\n }\n\n /**\n * deletes all nodes in the current selection from the graph\n * @deprecated See {@link LGraphCanvas.deleteSelected}\n */\n deleteSelectedNodes(): void {\n this.deleteSelected()\n }\n\n /**\n * centers the camera on a given node\n */\n centerOnNode(node: LGraphNode): void {\n const dpi = window?.devicePixelRatio || 1\n this.ds.offset[0] =\n -node.pos[0] -\n node.size[0] * 0.5 +\n (this.canvas.width * 0.5) / (this.ds.scale * dpi)\n this.ds.offset[1] =\n -node.pos[1] -\n node.size[1] * 0.5 +\n (this.canvas.height * 0.5) / (this.ds.scale * dpi)\n this.setDirty(true, true)\n }\n\n /**\n * adds some useful properties to a mouse event, like the position in graph coordinates\n */\n adjustMouseEvent<T extends MouseEvent>(\n e: T & Partial<CanvasPointerExtensions>,\n ): asserts e is T & CanvasPointerEvent {\n let clientX_rel = e.clientX\n let clientY_rel = e.clientY\n\n if (this.canvas) {\n const b = this.canvas.getBoundingClientRect()\n clientX_rel -= b.left\n clientY_rel -= b.top\n }\n\n e.safeOffsetX = clientX_rel\n e.safeOffsetY = clientY_rel\n\n // TODO: Find a less brittle way to do this\n\n // Only set deltaX and deltaY if not already set.\n // If deltaX and deltaY are already present, they are read-only.\n // Setting them would result browser error => zoom in/out feature broken.\n if (e.deltaX === undefined)\n e.deltaX = clientX_rel - this.last_mouse_position[0]\n if (e.deltaY === undefined)\n e.deltaY = clientY_rel - this.last_mouse_position[1]\n\n this.last_mouse_position[0] = clientX_rel\n this.last_mouse_position[1] = clientY_rel\n\n e.canvasX = clientX_rel / this.ds.scale - this.ds.offset[0]\n e.canvasY = clientY_rel / this.ds.scale - this.ds.offset[1]\n }\n\n /**\n * changes the zoom level of the graph (default is 1), you can pass also a place used to pivot the zoom\n */\n setZoom(value: number, zooming_center: Point) {\n this.ds.changeScale(value, zooming_center)\n this.#dirty()\n }\n\n /**\n * converts a coordinate from graph coordinates to canvas2D coordinates\n */\n convertOffsetToCanvas(pos: Point, out: Point): Point {\n // @ts-expect-error Unused param\n return this.ds.convertOffsetToCanvas(pos, out)\n }\n\n /**\n * converts a coordinate from Canvas2D coordinates to graph space\n */\n convertCanvasToOffset(pos: Point, out?: Point): Point {\n return this.ds.convertCanvasToOffset(pos, out)\n }\n\n // converts event coordinates from canvas2D to graph coordinates\n convertEventToCanvasOffset(e: MouseEvent): Point {\n const rect = this.canvas.getBoundingClientRect()\n // TODO: -> this.ds.convertCanvasToOffset\n return this.convertCanvasToOffset([\n e.clientX - rect.left,\n e.clientY - rect.top,\n ])\n }\n\n /**\n * brings a node to front (above all other nodes)\n */\n bringToFront(node: LGraphNode): void {\n const { graph } = this\n if (!graph) throw new NullGraphError()\n\n const i = graph._nodes.indexOf(node)\n if (i == -1) return\n\n graph._nodes.splice(i, 1)\n graph._nodes.push(node)\n }\n\n /**\n * sends a node to the back (below all other nodes)\n */\n sendToBack(node: LGraphNode): void {\n const { graph } = this\n if (!graph) throw new NullGraphError()\n\n const i = graph._nodes.indexOf(node)\n if (i == -1) return\n\n graph._nodes.splice(i, 1)\n graph._nodes.unshift(node)\n }\n\n /**\n * Determines which nodes are visible and populates {@link out} with the results.\n * @param nodes The list of nodes to check - if falsy, all nodes in the graph will be checked\n * @param out Array to write visible nodes into - if falsy, a new array is created instead\n * @returns Array passed ({@link out}), or a new array containing all visible nodes\n */\n computeVisibleNodes(nodes?: LGraphNode[], out?: LGraphNode[]): LGraphNode[] {\n const visible_nodes = out || []\n visible_nodes.length = 0\n if (!this.graph) throw new NullGraphError()\n\n const _nodes = nodes || this.graph._nodes\n for (const node of _nodes) {\n node.updateArea(this.ctx)\n // Not in visible area\n if (!overlapBounding(this.visible_area, node.renderArea)) continue\n\n visible_nodes.push(node)\n }\n return visible_nodes\n }\n\n /**\n * Checks if a node is visible on the canvas.\n * @param node The node to check\n * @returns `true` if the node is visible, otherwise `false`\n */\n isNodeVisible(node: LGraphNode): boolean {\n return this.#visible_node_ids.has(node.id)\n }\n\n /**\n * renders the whole canvas content, by rendering in two separated canvas, one containing the background grid and the connections, and one containing the nodes)\n */\n draw(force_canvas?: boolean, force_bgcanvas?: boolean): void {\n if (!this.canvas || this.canvas.width == 0 || this.canvas.height == 0) return\n\n // fps counting\n const now = LiteGraph.getTime()\n this.render_time = (now - this.last_draw_time) * 0.001\n this.last_draw_time = now\n\n if (this.graph) this.ds.computeVisibleArea(this.viewport)\n\n // Compute node size before drawing links.\n if (this.dirty_canvas || force_canvas) {\n this.computeVisibleNodes(undefined, this.visible_nodes)\n // Update visible node IDs\n this.#visible_node_ids = new Set(this.visible_nodes.map(node => node.id))\n\n // Arrange subgraph IO nodes\n const { subgraph } = this\n if (subgraph) {\n subgraph.inputNode.arrange()\n subgraph.outputNode.arrange()\n }\n }\n\n if (\n this.dirty_bgcanvas ||\n force_bgcanvas ||\n this.always_render_background ||\n (this.graph?._last_trigger_time &&\n now - this.graph._last_trigger_time < 1000)\n ) {\n this.drawBackCanvas()\n }\n\n if (this.dirty_canvas || force_canvas) this.drawFrontCanvas()\n\n this.fps = this.render_time ? 1.0 / this.render_time : 0\n this.frame++\n }\n\n /**\n * draws the front canvas (the one containing all the nodes)\n */\n drawFrontCanvas(): void {\n this.dirty_canvas = false\n\n const { ctx, canvas, graph, linkConnector } = this\n\n // @ts-expect-error\n if (ctx.start2D && !this.viewport) {\n // @ts-expect-error\n ctx.start2D()\n ctx.restore()\n ctx.setTransform(1, 0, 0, 1, 0, 0)\n }\n\n // clip dirty area if there is one, otherwise work in full canvas\n const area = this.viewport || this.dirty_area\n if (area) {\n ctx.save()\n ctx.beginPath()\n ctx.rect(area[0], area[1], area[2], area[3])\n ctx.clip()\n }\n\n // TODO: Set snapping value when changed instead of once per frame\n this.#snapToGrid = this.#shiftDown || LiteGraph.alwaysSnapToGrid\n ? this.graph?.getSnapToGridSize()\n : undefined\n\n // clear\n // canvas.width = canvas.width;\n if (this.clear_background) {\n if (area) ctx.clearRect(area[0], area[1], area[2], area[3])\n else ctx.clearRect(0, 0, canvas.width, canvas.height)\n }\n\n // draw bg canvas\n if (this.bgcanvas == this.canvas) {\n this.drawBackCanvas()\n } else {\n const scale = window.devicePixelRatio\n ctx.drawImage(\n this.bgcanvas,\n 0,\n 0,\n this.bgcanvas.width / scale,\n this.bgcanvas.height / scale,\n )\n }\n\n // rendering\n this.onRender?.(canvas, ctx)\n\n // info widget\n if (this.show_info) {\n this.renderInfo(ctx, area ? area[0] : 0, area ? area[1] : 0)\n }\n\n if (graph) {\n // apply transformations\n ctx.save()\n this.ds.toCanvasContext(ctx)\n\n // draw nodes\n const { visible_nodes } = this\n const drawSnapGuides = this.#snapToGrid && this.isDragging\n\n for (const node of visible_nodes) {\n ctx.save()\n\n // Draw snap shadow\n if (drawSnapGuides && this.selectedItems.has(node))\n this.drawSnapGuide(ctx, node)\n\n // Localise co-ordinates to node position\n ctx.translate(node.pos[0], node.pos[1])\n\n // Draw\n this.drawNode(node, ctx)\n\n ctx.restore()\n }\n\n // Draw subgraph IO nodes\n this.subgraph?.draw(ctx, this.colourGetter, this.linkConnector.renderLinks[0]?.fromSlot, this.editor_alpha)\n\n // on top (debug)\n if (this.render_execution_order) {\n this.drawExecutionOrder(ctx)\n }\n\n // connections ontop?\n if (graph.config.links_ontop) {\n this.drawConnections(ctx)\n }\n\n if (linkConnector.isConnecting) {\n // current connection (the one being dragged by the mouse)\n const { renderLinks } = linkConnector\n const highlightPos = this.#getHighlightPosition()\n ctx.lineWidth = this.connections_width\n\n for (const renderLink of renderLinks) {\n const { fromSlot, fromPos: pos, fromDirection, dragDirection } = renderLink\n const connShape = fromSlot.shape\n const connType = fromSlot.type\n\n const colour = connType === LiteGraph.EVENT\n ? LiteGraph.EVENT_LINK_COLOR\n : LiteGraph.CONNECTING_LINK_COLOR\n\n // the connection being dragged by the mouse\n this.renderLink(\n ctx,\n pos,\n highlightPos,\n null,\n false,\n null,\n colour,\n fromDirection,\n dragDirection,\n )\n\n ctx.beginPath()\n if (connType === LiteGraph.EVENT || connShape === RenderShape.BOX) {\n ctx.rect(pos[0] - 6 + 0.5, pos[1] - 5 + 0.5, 14, 10)\n ctx.rect(\n highlightPos[0] - 6 + 0.5,\n highlightPos[1] - 5 + 0.5,\n 14,\n 10,\n )\n } else if (connShape === RenderShape.ARROW) {\n ctx.moveTo(pos[0] + 8, pos[1] + 0.5)\n ctx.lineTo(pos[0] - 4, pos[1] + 6 + 0.5)\n ctx.lineTo(pos[0] - 4, pos[1] - 6 + 0.5)\n ctx.closePath()\n } else {\n ctx.arc(pos[0], pos[1], 4, 0, Math.PI * 2)\n ctx.arc(highlightPos[0], highlightPos[1], 4, 0, Math.PI * 2)\n }\n ctx.fill()\n }\n\n // Gradient half-border over target node\n this.#renderSnapHighlight(ctx, highlightPos)\n }\n\n // Area-selection rectangle\n if (this.dragging_rectangle) {\n const { eDown, eMove } = this.pointer\n ctx.strokeStyle = \"#FFF\"\n\n if (eDown && eMove) {\n // Do not scale the selection box\n const transform = ctx.getTransform()\n const ratio = Math.max(1, window.devicePixelRatio)\n ctx.setTransform(ratio, 0, 0, ratio, 0, 0)\n\n const x = eDown.safeOffsetX\n const y = eDown.safeOffsetY\n ctx.strokeRect(x, y, eMove.safeOffsetX - x, eMove.safeOffsetY - y)\n\n ctx.setTransform(transform)\n } else {\n // Fallback to legacy behaviour\n const [x, y, w, h] = this.dragging_rectangle\n ctx.strokeRect(x, y, w, h)\n }\n }\n\n // on top of link center\n if (!this.isDragging && this.over_link_center && this.render_link_tooltip) {\n this.drawLinkTooltip(ctx, this.over_link_center)\n } else {\n this.onDrawLinkTooltip?.(ctx, null)\n }\n\n // custom info\n this.onDrawForeground?.(ctx, this.visible_area)\n\n ctx.restore()\n }\n\n this.onDrawOverlay?.(ctx)\n\n if (area) ctx.restore()\n }\n\n /** @returns If the pointer is over a link centre marker, the link segment it belongs to. Otherwise, `undefined`. */\n #getLinkCentreOnPos(e: CanvasPointerEvent): LinkSegment | undefined {\n for (const linkSegment of this.renderedPaths) {\n const centre = linkSegment._pos\n if (!centre) continue\n\n if (isInRectangle(e.canvasX, e.canvasY, centre[0] - 4, centre[1] - 4, 8, 8)) {\n return linkSegment\n }\n }\n }\n\n /** Get the target snap / highlight point in graph space */\n #getHighlightPosition(): ReadOnlyPoint {\n return LiteGraph.snaps_for_comfy\n ? this.linkConnector.state.snapLinksPos ?? this._highlight_pos ?? this.graph_mouse\n : this.graph_mouse\n }\n\n /**\n * Renders indicators showing where a link will connect if released.\n * Partial border over target node and a highlight over the slot itself.\n * @param ctx Canvas 2D context\n */\n #renderSnapHighlight(\n ctx: CanvasRenderingContext2D,\n highlightPos: ReadOnlyPoint,\n ): void {\n const linkConnectorSnap = !!this.linkConnector.state.snapLinksPos\n if (!this._highlight_pos && !linkConnectorSnap) return\n\n ctx.fillStyle = \"#ffcc00\"\n ctx.beginPath()\n const shape = this._highlight_input?.shape\n\n if (shape === RenderShape.ARROW) {\n ctx.moveTo(highlightPos[0] + 8, highlightPos[1] + 0.5)\n ctx.lineTo(highlightPos[0] - 4, highlightPos[1] + 6 + 0.5)\n ctx.lineTo(highlightPos[0] - 4, highlightPos[1] - 6 + 0.5)\n ctx.closePath()\n } else {\n ctx.arc(highlightPos[0], highlightPos[1], 6, 0, Math.PI * 2)\n }\n ctx.fill()\n\n const { linkConnector } = this\n const { overReroute, overWidget } = linkConnector\n if (!LiteGraph.snap_highlights_node || !linkConnector.isConnecting || linkConnectorSnap) return\n\n // Reroute highlight\n overReroute?.drawHighlight(ctx, \"#ffcc00aa\")\n\n // Ensure we're mousing over a node and connecting a link\n const node = this.node_over\n if (!node) return\n\n const { strokeStyle, lineWidth } = ctx\n\n const area = node.boundingRect\n const gap = 3\n const radius = LiteGraph.ROUND_RADIUS + gap\n\n const x = area[0] - gap\n const y = area[1] - gap\n const width = area[2] + gap * 2\n const height = area[3] + gap * 2\n\n ctx.beginPath()\n ctx.roundRect(x, y, width, height, radius)\n\n // TODO: Currently works on LTR slots only. Add support for other directions.\n const start = linkConnector.state.connectingTo === \"output\" ? 0 : 1\n const inverter = start ? -1 : 1\n\n // Radial highlight centred on highlight pos\n const hx = highlightPos[0]\n const hy = highlightPos[1]\n const gRadius = width < height\n ? width\n : width * Math.max(height / width, 0.5)\n\n const gradient = ctx.createRadialGradient(hx, hy, 0, hx, hy, gRadius)\n gradient.addColorStop(1, \"#00000000\")\n gradient.addColorStop(0, \"#ffcc00aa\")\n\n // Linear gradient over half the node.\n const linearGradient = ctx.createLinearGradient(x, y, x + width, y)\n linearGradient.addColorStop(0.5, \"#00000000\")\n linearGradient.addColorStop(start + 0.67 * inverter, \"#ddeeff33\")\n linearGradient.addColorStop(start + inverter, \"#ffcc0055\")\n\n /**\n * Workaround for a canvas render issue.\n * In Chromium 129 (2024-10-15), rounded corners can be rendered with the wrong part of a gradient colour.\n * Occurs only at certain thicknesses / arc sizes.\n */\n ctx.setLineDash([radius, radius * 0.001])\n\n ctx.lineWidth = 1\n ctx.strokeStyle = linearGradient\n ctx.stroke()\n\n if (overWidget) {\n const { computedHeight } = overWidget\n\n ctx.beginPath()\n const { pos: [nodeX, nodeY] } = node\n const height = LiteGraph.NODE_WIDGET_HEIGHT\n if (\n overWidget.type.startsWith(\"custom\") &&\n computedHeight != null &&\n computedHeight > height * 2\n ) {\n // Most likely DOM widget text box\n ctx.rect(\n nodeX + 9,\n nodeY + overWidget.y + 9,\n (overWidget.width ?? area[2]) - 18,\n computedHeight - 18,\n )\n } else {\n // Regular widget, probably\n ctx.roundRect(\n nodeX + BaseWidget.margin,\n nodeY + overWidget.y,\n overWidget.width ?? area[2],\n height,\n height * 0.5,\n )\n }\n ctx.stroke()\n }\n\n ctx.strokeStyle = gradient\n ctx.stroke()\n\n ctx.setLineDash([])\n ctx.lineWidth = lineWidth\n ctx.strokeStyle = strokeStyle\n }\n\n /**\n * draws some useful stats in the corner of the canvas\n */\n renderInfo(ctx: CanvasRenderingContext2D, x: number, y: number): void {\n x = x || 10\n y = y || this.canvas.offsetHeight - 80\n\n ctx.save()\n ctx.translate(x, y)\n\n ctx.font = `10px ${LiteGraph.DEFAULT_FONT}`\n ctx.fillStyle = \"#888\"\n ctx.textAlign = \"left\"\n if (this.graph) {\n ctx.fillText(`T: ${this.graph.globaltime.toFixed(2)}s`, 5, 13 * 1)\n ctx.fillText(`I: ${this.graph.iteration}`, 5, 13 * 2)\n ctx.fillText(`N: ${this.graph._nodes.length} [${this.visible_nodes.length}]`, 5, 13 * 3)\n ctx.fillText(`V: ${this.graph._version}`, 5, 13 * 4)\n ctx.fillText(`FPS:${this.fps.toFixed(2)}`, 5, 13 * 5)\n } else {\n ctx.fillText(\"No graph selected\", 5, 13 * 1)\n }\n ctx.restore()\n }\n\n /**\n * draws the back canvas (the one containing the background and the connections)\n */\n drawBackCanvas(): void {\n const canvas = this.bgcanvas\n if (\n canvas.width != this.canvas.width ||\n canvas.height != this.canvas.height\n ) {\n canvas.width = this.canvas.width\n canvas.height = this.canvas.height\n }\n\n if (!this.bgctx) {\n this.bgctx = this.bgcanvas.getContext(\"2d\")\n }\n const ctx = this.bgctx\n if (!ctx) throw new TypeError(\"Background canvas context was null.\")\n\n const viewport = this.viewport || [0, 0, ctx.canvas.width, ctx.canvas.height]\n\n // clear\n if (this.clear_background) {\n ctx.clearRect(viewport[0], viewport[1], viewport[2], viewport[3])\n }\n\n const bg_already_painted = this.onRenderBackground\n ? this.onRenderBackground(canvas, ctx)\n : false\n\n // reset in case of error\n if (!this.viewport) {\n const scale = window.devicePixelRatio\n ctx.restore()\n ctx.setTransform(scale, 0, 0, scale, 0, 0)\n }\n\n if (this.graph) {\n // apply transformations\n ctx.save()\n this.ds.toCanvasContext(ctx)\n\n // render BG\n if (\n this.ds.scale < 1.5 &&\n !bg_already_painted &&\n this.clear_background_color\n ) {\n ctx.fillStyle = this.clear_background_color\n ctx.fillRect(\n this.visible_area[0],\n this.visible_area[1],\n this.visible_area[2],\n this.visible_area[3],\n )\n }\n\n if (this.background_image && this.ds.scale > 0.5 && !bg_already_painted) {\n if (this.zoom_modify_alpha) {\n ctx.globalAlpha = (1.0 - 0.5 / this.ds.scale) * this.editor_alpha\n } else {\n ctx.globalAlpha = this.editor_alpha\n }\n ctx.imageSmoothingEnabled = false\n if (!this._bg_img || this._bg_img.name != this.background_image) {\n this._bg_img = new Image()\n this._bg_img.name = this.background_image\n this._bg_img.src = this.background_image\n const that = this\n this._bg_img.addEventListener(\"load\", function () {\n that.draw(true, true)\n })\n }\n\n let pattern = this._pattern\n if (pattern == null && this._bg_img.width > 0) {\n pattern = ctx.createPattern(this._bg_img, \"repeat\") ?? undefined\n this._pattern_img = this._bg_img\n this._pattern = pattern\n }\n\n // NOTE: This ridiculous kludge provides a significant performance increase when rendering many large (> canvas width) paths in HTML canvas.\n // I could find no documentation or explanation. Requires that the BG image is set.\n if (pattern) {\n ctx.fillStyle = pattern\n ctx.fillRect(\n this.visible_area[0],\n this.visible_area[1],\n this.visible_area[2],\n this.visible_area[3],\n )\n ctx.fillStyle = \"transparent\"\n }\n\n ctx.globalAlpha = 1.0\n ctx.imageSmoothingEnabled = true\n }\n\n // groups\n if (this.graph._groups.length) {\n this.drawGroups(canvas, ctx)\n }\n\n this.onDrawBackground?.(ctx, this.visible_area)\n\n // DEBUG: show clipping area\n // ctx.fillStyle = \"red\";\n // ctx.fillRect( this.visible_area[0] + 10, this.visible_area[1] + 10, this.visible_area[2] - 20, this.visible_area[3] - 20);\n // bg\n if (this.render_canvas_border) {\n ctx.strokeStyle = \"#235\"\n ctx.strokeRect(0, 0, canvas.width, canvas.height)\n }\n\n if (this.render_connections_shadows) {\n ctx.shadowColor = \"#000\"\n ctx.shadowOffsetX = 0\n ctx.shadowOffsetY = 0\n ctx.shadowBlur = 6\n } else {\n ctx.shadowColor = \"rgba(0,0,0,0)\"\n }\n\n // draw connections\n this.drawConnections(ctx)\n\n ctx.shadowColor = \"rgba(0,0,0,0)\"\n\n // restore state\n ctx.restore()\n }\n\n this.dirty_bgcanvas = false\n // Forces repaint of the front canvas.\n this.dirty_canvas = true\n }\n\n /**\n * draws the given node inside the canvas\n */\n drawNode(node: LGraphNode, ctx: CanvasRenderingContext2D): void {\n this.current_node = node\n\n const color = node.renderingColor\n const bgcolor = node.renderingBgColor\n\n const { low_quality, editor_alpha } = this\n ctx.globalAlpha = editor_alpha\n\n if (this.render_shadows && !low_quality) {\n ctx.shadowColor = LiteGraph.DEFAULT_SHADOW_COLOR\n ctx.shadowOffsetX = 2 * this.ds.scale\n ctx.shadowOffsetY = 2 * this.ds.scale\n ctx.shadowBlur = 3 * this.ds.scale\n } else {\n ctx.shadowColor = \"transparent\"\n }\n\n // custom draw collapsed method (draw after shadows because they are affected)\n if (node.flags.collapsed && node.onDrawCollapsed?.(ctx, this) == true)\n return\n\n // clip if required (mask)\n const shape = node._shape || RenderShape.BOX\n const size = LGraphCanvas.#temp_vec2\n size.set(node.renderingSize)\n\n if (node.collapsed) {\n ctx.font = this.inner_text_font\n }\n\n if (node.clip_area) {\n // Start clipping\n ctx.save()\n ctx.beginPath()\n if (shape == RenderShape.BOX) {\n ctx.rect(0, 0, size[0], size[1])\n } else if (shape == RenderShape.ROUND) {\n ctx.roundRect(0, 0, size[0], size[1], [10])\n } else if (shape == RenderShape.CIRCLE) {\n ctx.arc(size[0] * 0.5, size[1] * 0.5, size[0] * 0.5, 0, Math.PI * 2)\n }\n ctx.clip()\n }\n\n // draw shape\n this.drawNodeShape(\n node,\n ctx,\n size,\n color,\n bgcolor,\n !!node.selected,\n )\n\n // Render title buttons (if not collapsed)\n if (node.title_buttons && !node.flags.collapsed) {\n const title_height = LiteGraph.NODE_TITLE_HEIGHT\n let current_x = size[0] // Start flush with right edge\n\n for (let i = 0; i < node.title_buttons.length; i++) {\n const button = node.title_buttons[i]\n if (!button.visible) {\n continue\n }\n\n const button_width = button.getWidth(ctx)\n current_x -= button_width\n\n // Center button vertically in title bar\n const button_y = -title_height + (title_height - button.height) / 2\n\n button.draw(ctx, current_x, button_y)\n current_x -= 2\n }\n }\n\n if (!low_quality) {\n node.drawBadges(ctx)\n }\n\n ctx.shadowColor = \"transparent\"\n\n // TODO: Legacy behaviour: onDrawForeground received ctx in this state\n ctx.strokeStyle = LiteGraph.NODE_BOX_OUTLINE_COLOR\n\n // Draw Foreground\n node.onDrawForeground?.(ctx, this, this.canvas)\n\n // connection slots\n ctx.font = this.inner_text_font\n\n // render inputs and outputs\n node._setConcreteSlots()\n if (!node.collapsed) {\n node.arrange()\n node.drawSlots(ctx, {\n fromSlot: this.linkConnector.renderLinks[0]?.fromSlot as INodeOutputSlot | INodeInputSlot,\n colorContext: this.colourGetter,\n editorAlpha: this.editor_alpha,\n lowQuality: this.low_quality,\n })\n\n ctx.textAlign = \"left\"\n ctx.globalAlpha = 1\n\n this.drawNodeWidgets(node, null, ctx)\n } else if (this.render_collapsed_slots) {\n node.drawCollapsedSlots(ctx)\n }\n\n if (node.clip_area) {\n ctx.restore()\n }\n\n ctx.globalAlpha = 1.0\n }\n\n /**\n * Draws the link mouseover effect and tooltip.\n * @param ctx Canvas 2D context to draw on\n * @param link The link to render the mouseover effect for\n * @remarks\n * Called against {@link LGraphCanvas.over_link_center}.\n * @todo Split tooltip from hover, so it can be drawn / eased separately\n */\n drawLinkTooltip(ctx: CanvasRenderingContext2D, link: LinkSegment): void {\n const pos = link._pos\n ctx.fillStyle = \"black\"\n ctx.beginPath()\n if (this.linkMarkerShape === LinkMarkerShape.Arrow) {\n const transform = ctx.getTransform()\n ctx.translate(pos[0], pos[1])\n // Assertion: Number.isFinite guarantees this is a number.\n if (Number.isFinite(link._centreAngle)) ctx.rotate(link._centreAngle as number)\n ctx.moveTo(-2, -3)\n ctx.lineTo(+4, 0)\n ctx.lineTo(-2, +3)\n ctx.setTransform(transform)\n } else if (\n this.linkMarkerShape == null ||\n this.linkMarkerShape === LinkMarkerShape.Circle\n ) {\n ctx.arc(pos[0], pos[1], 3, 0, Math.PI * 2)\n }\n ctx.fill()\n\n // @ts-expect-error TODO: Better value typing\n const { data } = link\n if (data == null) return\n\n // @ts-expect-error TODO: Better value typing\n if (this.onDrawLinkTooltip?.(ctx, link, this) == true) return\n\n let text: string | null = null\n\n if (typeof data === \"number\")\n text = data.toFixed(2)\n else if (typeof data === \"string\")\n text = `\"${data}\"`\n else if (typeof data === \"boolean\")\n text = String(data)\n else if (data.toToolTip)\n text = data.toToolTip()\n else\n text = `[${data.constructor.name}]`\n\n if (text == null) return\n\n // Hard-coded tooltip limit\n text = text.substring(0, 30)\n\n ctx.font = \"14px Courier New\"\n const info = ctx.measureText(text)\n const w = info.width + 20\n const h = 24\n ctx.shadowColor = \"black\"\n ctx.shadowOffsetX = 2\n ctx.shadowOffsetY = 2\n ctx.shadowBlur = 3\n ctx.fillStyle = \"#454\"\n ctx.beginPath()\n ctx.roundRect(pos[0] - w * 0.5, pos[1] - 15 - h, w, h, [3])\n ctx.moveTo(pos[0] - 10, pos[1] - 15)\n ctx.lineTo(pos[0] + 10, pos[1] - 15)\n ctx.lineTo(pos[0], pos[1] - 5)\n ctx.fill()\n ctx.shadowColor = \"transparent\"\n ctx.textAlign = \"center\"\n ctx.fillStyle = \"#CEC\"\n ctx.fillText(text, pos[0], pos[1] - 15 - h * 0.3)\n }\n\n /**\n * Draws the shape of the given node on the canvas\n * @param node The node to draw\n * @param ctx 2D canvas rendering context used to draw\n * @param size Size of the background to draw, in graph units. Differs from node size if collapsed, etc.\n * @param fgcolor Foreground colour - used for text\n * @param bgcolor Background colour of the node\n * @param _selected Whether to render the node as selected. Likely to be removed in future, as current usage is simply the selected property of the node.\n */\n drawNodeShape(\n node: LGraphNode,\n ctx: CanvasRenderingContext2D,\n size: Size,\n fgcolor: CanvasColour,\n bgcolor: CanvasColour,\n _selected: boolean,\n ): void {\n // Rendering options\n ctx.strokeStyle = fgcolor\n ctx.fillStyle = bgcolor\n\n const title_height = LiteGraph.NODE_TITLE_HEIGHT\n const { low_quality } = this\n\n const { collapsed } = node.flags\n const shape = node.renderingShape\n const { title_mode } = node\n\n const render_title = title_mode == TitleMode.TRANSPARENT_TITLE || title_mode == TitleMode.NO_TITLE\n ? false\n : true\n\n // Normalised node dimensions\n const area = LGraphCanvas.#tmp_area\n area.set(node.boundingRect)\n area[0] -= node.pos[0]\n area[1] -= node.pos[1]\n\n const old_alpha = ctx.globalAlpha\n\n // Draw node background (shape)\n ctx.beginPath()\n if (shape == RenderShape.BOX || low_quality) {\n ctx.rect(area[0], area[1], area[2], area[3])\n } else if (shape == RenderShape.ROUND || shape == RenderShape.CARD) {\n ctx.roundRect(\n area[0],\n area[1],\n area[2],\n area[3],\n shape == RenderShape.CARD\n ? [LiteGraph.ROUND_RADIUS, LiteGraph.ROUND_RADIUS, 0, 0]\n : [LiteGraph.ROUND_RADIUS],\n )\n } else if (shape == RenderShape.CIRCLE) {\n ctx.arc(size[0] * 0.5, size[1] * 0.5, size[0] * 0.5, 0, Math.PI * 2)\n }\n ctx.fill()\n\n // Separator - title bar <-> body\n if (!collapsed && render_title) {\n ctx.shadowColor = \"transparent\"\n ctx.fillStyle = \"rgba(0,0,0,0.2)\"\n ctx.fillRect(0, -1, area[2], 2)\n }\n ctx.shadowColor = \"transparent\"\n\n node.onDrawBackground?.(ctx)\n\n // Title bar background (remember, it is rendered ABOVE the node)\n if (render_title || title_mode == TitleMode.TRANSPARENT_TITLE) {\n node.drawTitleBarBackground(ctx, {\n scale: this.ds.scale,\n low_quality,\n })\n\n // title box\n node.drawTitleBox(ctx, {\n scale: this.ds.scale,\n low_quality,\n box_size: 10,\n })\n\n ctx.globalAlpha = old_alpha\n\n // title text\n node.drawTitleText(ctx, {\n scale: this.ds.scale,\n default_title_color: this.node_title_color,\n low_quality,\n })\n\n // custom title render\n node.onDrawTitle?.(ctx)\n }\n\n // Draw stroke styles\n for (const getStyle of Object.values(node.strokeStyles)) {\n const strokeStyle = getStyle.call(node)\n if (strokeStyle) {\n strokeShape(ctx, area, {\n shape,\n title_height,\n title_mode,\n collapsed,\n ...strokeStyle,\n })\n }\n }\n\n node.drawProgressBar(ctx)\n\n // these counter helps in conditioning drawing based on if the node has been executed or an action occurred\n if (node.execute_triggered != null && node.execute_triggered > 0) node.execute_triggered--\n if (node.action_triggered != null && node.action_triggered > 0) node.action_triggered--\n }\n\n /**\n * Draws a snap guide for a {@link Positionable} item.\n *\n * Initial design was a simple white rectangle representing the location the\n * item would land if dropped.\n * @param ctx The 2D canvas context to draw on\n * @param item The item to draw a snap guide for\n * @param shape The shape of the snap guide to draw\n * @todo Update to align snapping with boundingRect\n * @todo Shapes\n */\n drawSnapGuide(\n ctx: CanvasRenderingContext2D,\n item: Positionable,\n shape = RenderShape.ROUND,\n ) {\n const snapGuide = LGraphCanvas.#temp\n snapGuide.set(item.boundingRect)\n\n // Not all items have pos equal to top-left of bounds\n const { pos } = item\n const offsetX = pos[0] - snapGuide[0]\n const offsetY = pos[1] - snapGuide[1]\n\n // Normalise boundingRect to pos to snap\n snapGuide[0] += offsetX\n snapGuide[1] += offsetY\n if (this.#snapToGrid) snapPoint(snapGuide, this.#snapToGrid)\n snapGuide[0] -= offsetX\n snapGuide[1] -= offsetY\n\n const { globalAlpha } = ctx\n ctx.globalAlpha = 1\n ctx.beginPath()\n const [x, y, w, h] = snapGuide\n if (shape === RenderShape.CIRCLE) {\n const midX = x + (w * 0.5)\n const midY = y + (h * 0.5)\n const radius = Math.min(w * 0.5, h * 0.5)\n ctx.arc(midX, midY, radius, 0, Math.PI * 2)\n } else {\n ctx.rect(x, y, w, h)\n }\n\n ctx.lineWidth = 0.5\n ctx.strokeStyle = \"#FFFFFF66\"\n ctx.fillStyle = \"#FFFFFF22\"\n ctx.fill()\n ctx.stroke()\n ctx.globalAlpha = globalAlpha\n }\n\n drawConnections(ctx: CanvasRenderingContext2D): void {\n this.renderedPaths.clear()\n if (this.links_render_mode === LinkRenderType.HIDDEN_LINK) return\n\n const { graph, subgraph } = this\n if (!graph) throw new NullGraphError()\n\n const visibleReroutes: Reroute[] = []\n\n const now = LiteGraph.getTime()\n const { visible_area } = this\n LGraphCanvas.#margin_area[0] = visible_area[0] - 20\n LGraphCanvas.#margin_area[1] = visible_area[1] - 20\n LGraphCanvas.#margin_area[2] = visible_area[2] + 40\n LGraphCanvas.#margin_area[3] = visible_area[3] + 40\n\n // draw connections\n ctx.lineWidth = this.connections_width\n\n ctx.fillStyle = \"#AAA\"\n ctx.strokeStyle = \"#AAA\"\n ctx.globalAlpha = this.editor_alpha\n // for every node\n const nodes = graph._nodes\n for (const node of nodes) {\n // for every input (we render just inputs because it is easier as every slot can only have one input)\n const { inputs } = node\n if (!inputs?.length) continue\n\n for (const [i, input] of inputs.entries()) {\n if (!input || input.link == null) continue\n\n const link_id = input.link\n const link = graph._links.get(link_id)\n if (!link) continue\n\n const endPos = node.getInputPos(i)\n\n // find link info\n const start_node = graph.getNodeById(link.origin_id)\n if (start_node == null) continue\n\n const outputId = link.origin_slot\n const startPos: Point = outputId === -1\n ? [start_node.pos[0] + 10, start_node.pos[1] + 10]\n : start_node.getOutputPos(outputId)\n\n const output = start_node.outputs[outputId]\n if (!output) continue\n\n this.#renderAllLinkSegments(ctx, link, startPos, endPos, visibleReroutes, now, output.dir, input.dir)\n }\n }\n\n if (subgraph) {\n for (const output of subgraph.inputNode.slots) {\n if (!output.linkIds.length) continue\n\n // find link info\n for (const linkId of output.linkIds) {\n const resolved = LLink.resolve(linkId, graph)\n if (!resolved) continue\n\n const { link, inputNode, input } = resolved\n if (!inputNode || !input) continue\n\n const endPos = inputNode.getInputPos(link.target_slot)\n\n this.#renderAllLinkSegments(ctx, link, output.pos, endPos, visibleReroutes, now, input.dir, input.dir)\n }\n }\n\n for (const input of subgraph.outputNode.slots) {\n if (!input.linkIds.length) continue\n\n // find link info\n const resolved = LLink.resolve(input.linkIds[0], graph)\n if (!resolved) continue\n\n const { link, outputNode, output } = resolved\n if (!outputNode || !output) continue\n\n const startPos = outputNode.getOutputPos(link.origin_slot)\n\n this.#renderAllLinkSegments(ctx, link, startPos, input.pos, visibleReroutes, now, output.dir, input.dir)\n }\n }\n\n if (graph.floatingLinks.size > 0) {\n this.#renderFloatingLinks(ctx, graph, visibleReroutes, now)\n }\n\n const rerouteSet = this.#visibleReroutes\n rerouteSet.clear()\n\n // Render reroutes, ordered by number of non-floating links\n visibleReroutes.sort((a, b) => a.linkIds.size - b.linkIds.size)\n for (const reroute of visibleReroutes) {\n rerouteSet.add(reroute)\n\n if (\n this.#snapToGrid &&\n this.isDragging &&\n this.selectedItems.has(reroute)\n ) {\n this.drawSnapGuide(ctx, reroute, RenderShape.CIRCLE)\n }\n reroute.draw(ctx, this._pattern)\n\n // Never draw slots when the pointer is down\n if (!this.pointer.isDown) reroute.drawSlots(ctx)\n }\n ctx.globalAlpha = 1\n }\n\n #renderFloatingLinks(ctx: CanvasRenderingContext2D, graph: LGraph, visibleReroutes: Reroute[], now: number) {\n // Render floating links with 3/4 current alpha\n const { globalAlpha } = ctx\n ctx.globalAlpha = globalAlpha * 0.33\n\n // Floating reroutes\n for (const link of graph.floatingLinks.values()) {\n const reroutes = LLink.getReroutes(graph, link)\n const firstReroute = reroutes[0]\n const reroute = reroutes.at(-1)\n if (!firstReroute || !reroute?.floating) continue\n\n // Input not connected\n if (reroute.floating.slotType === \"input\") {\n const node = graph.getNodeById(link.target_id)\n if (!node) continue\n\n const startPos = firstReroute.pos\n const endPos = node.getInputPos(link.target_slot)\n const endDirection = node.inputs[link.target_slot]?.dir\n\n firstReroute._dragging = true\n this.#renderAllLinkSegments(ctx, link, startPos, endPos, visibleReroutes, now, LinkDirection.CENTER, endDirection, true)\n } else {\n const node = graph.getNodeById(link.origin_id)\n if (!node) continue\n\n const startPos = node.getOutputPos(link.origin_slot)\n const endPos = reroute.pos\n const startDirection = node.outputs[link.origin_slot]?.dir\n\n link._dragging = true\n this.#renderAllLinkSegments(ctx, link, startPos, endPos, visibleReroutes, now, startDirection, LinkDirection.CENTER, true)\n }\n }\n ctx.globalAlpha = globalAlpha\n }\n\n #renderAllLinkSegments(\n ctx: CanvasRenderingContext2D,\n link: LLink,\n startPos: Point,\n endPos: Point,\n visibleReroutes: Reroute[],\n now: number,\n startDirection?: LinkDirection,\n endDirection?: LinkDirection,\n disabled: boolean = false,\n ) {\n const { graph, renderedPaths } = this\n if (!graph) return\n\n // Get all points this link passes through\n const reroutes = LLink.getReroutes(graph, link)\n const points: [Point, ...Point[], Point] = [\n startPos,\n ...reroutes.map(x => x.pos),\n endPos,\n ]\n\n // Bounding box of all points (bezier overshoot on long links will be cut)\n const pointsX = points.map(x => x[0])\n const pointsY = points.map(x => x[1])\n LGraphCanvas.#link_bounding[0] = Math.min(...pointsX)\n LGraphCanvas.#link_bounding[1] = Math.min(...pointsY)\n LGraphCanvas.#link_bounding[2] = Math.max(...pointsX) - LGraphCanvas.#link_bounding[0]\n LGraphCanvas.#link_bounding[3] = Math.max(...pointsY) - LGraphCanvas.#link_bounding[1]\n\n // skip links outside of the visible area of the canvas\n if (!overlapBounding(LGraphCanvas.#link_bounding, LGraphCanvas.#margin_area))\n return\n\n const start_dir = startDirection || LinkDirection.RIGHT\n const end_dir = endDirection || LinkDirection.LEFT\n\n // Has reroutes\n if (reroutes.length) {\n let startControl: Point | undefined\n\n const l = reroutes.length\n for (let j = 0; j < l; j++) {\n const reroute = reroutes[j]\n\n // Only render once\n if (!renderedPaths.has(reroute)) {\n renderedPaths.add(reroute)\n visibleReroutes.push(reroute)\n reroute._colour = link.color ||\n LGraphCanvas.link_type_colors[link.type] ||\n this.default_link_color\n\n const prevReroute = graph.getReroute(reroute.parentId)\n const rerouteStartPos = prevReroute?.pos ?? startPos\n reroute.calculateAngle(this.last_draw_time, graph, rerouteStartPos)\n\n // Skip the first segment if it is being dragged\n if (!reroute._dragging) {\n this.renderLink(\n ctx,\n rerouteStartPos,\n reroute.pos,\n link,\n false,\n 0,\n null,\n startControl === undefined ? start_dir : LinkDirection.CENTER,\n LinkDirection.CENTER,\n {\n startControl,\n endControl: reroute.controlPoint,\n reroute,\n disabled,\n },\n )\n }\n }\n\n if (!startControl && reroutes.at(-1)?.floating?.slotType === \"input\") {\n // Floating link connected to an input\n startControl = [0, 0]\n } else {\n // Calculate start control for the next iter control point\n const nextPos = reroutes[j + 1]?.pos ?? endPos\n const dist = Math.min(Reroute.maxSplineOffset, distance(reroute.pos, nextPos) * 0.25)\n startControl = [dist * reroute.cos, dist * reroute.sin]\n }\n }\n\n // Skip the last segment if it is being dragged\n if (link._dragging) return\n\n // Use runtime fallback; TypeScript cannot evaluate this correctly.\n const segmentStartPos = points.at(-2) ?? startPos\n\n // Render final link segment\n this.renderLink(\n ctx,\n segmentStartPos,\n endPos,\n link,\n false,\n 0,\n null,\n LinkDirection.CENTER,\n end_dir,\n { startControl, disabled },\n )\n // Skip normal render when link is being dragged\n } else if (!link._dragging) {\n this.renderLink(\n ctx,\n startPos,\n endPos,\n link,\n false,\n 0,\n null,\n start_dir,\n end_dir,\n )\n }\n renderedPaths.add(link)\n\n // event triggered rendered on top\n if (link?._last_time && now - link._last_time < 1000) {\n const f = 2.0 - (now - link._last_time) * 0.002\n const tmp = ctx.globalAlpha\n ctx.globalAlpha = tmp * f\n this.renderLink(\n ctx,\n startPos,\n endPos,\n link,\n true,\n f,\n \"white\",\n start_dir,\n end_dir,\n )\n ctx.globalAlpha = tmp\n }\n }\n\n /**\n * draws a link between two points\n * @param ctx Canvas 2D rendering context\n * @param a start pos\n * @param b end pos\n * @param link the link object with all the link info\n * @param skip_border ignore the shadow of the link\n * @param flow show flow animation (for events)\n * @param color the color for the link\n * @param start_dir the direction enum\n * @param end_dir the direction enum\n */\n renderLink(\n ctx: CanvasRenderingContext2D,\n a: ReadOnlyPoint,\n b: ReadOnlyPoint,\n link: LLink | null,\n skip_border: boolean,\n flow: number | null,\n color: CanvasColour | null,\n start_dir: LinkDirection,\n end_dir: LinkDirection,\n {\n startControl,\n endControl,\n reroute,\n num_sublines = 1,\n disabled = false,\n }: {\n /** When defined, render data will be saved to this reroute instead of the {@link link}. */\n reroute?: Reroute\n /** Offset of the bezier curve control point from {@link a point a} (output side) */\n startControl?: ReadOnlyPoint\n /** Offset of the bezier curve control point from {@link b point b} (input side) */\n endControl?: ReadOnlyPoint\n /** Number of sublines (useful to represent vec3 or rgb) @todo If implemented, refactor calculations out of the loop */\n num_sublines?: number\n /** Whether this is a floating link segment */\n disabled?: boolean\n } = {},\n ): void {\n const linkColour =\n link != null && this.highlighted_links[link.id]\n ? \"#FFF\"\n : color ||\n link?.color ||\n (link?.type != null && LGraphCanvas.link_type_colors[link.type]) ||\n this.default_link_color\n const startDir = start_dir || LinkDirection.RIGHT\n const endDir = end_dir || LinkDirection.LEFT\n\n const dist = this.links_render_mode == LinkRenderType.SPLINE_LINK && (!endControl || !startControl)\n ? distance(a, b)\n : 0\n\n // TODO: Subline code below was inserted in the wrong place - should be before this statement\n if (this.render_connections_border && !this.low_quality) {\n ctx.lineWidth = this.connections_width + 4\n }\n ctx.lineJoin = \"round\"\n num_sublines ||= 1\n if (num_sublines > 1) ctx.lineWidth = 0.5\n\n // begin line shape\n const path = new Path2D()\n\n /** The link or reroute we're currently rendering */\n const linkSegment = reroute ?? link\n if (linkSegment) linkSegment.path = path\n\n const innerA = LGraphCanvas.#lTempA\n const innerB = LGraphCanvas.#lTempB\n\n /** Reference to {@link reroute._pos} if present, or {@link link._pos} if present. Caches the centre point of the link. */\n const pos: Point = linkSegment?._pos ?? [0, 0]\n\n for (let i = 0; i < num_sublines; i++) {\n const offsety = (i - (num_sublines - 1) * 0.5) * 5\n innerA[0] = a[0]\n innerA[1] = a[1]\n innerB[0] = b[0]\n innerB[1] = b[1]\n\n if (this.links_render_mode == LinkRenderType.SPLINE_LINK) {\n if (endControl) {\n innerB[0] = b[0] + endControl[0]\n innerB[1] = b[1] + endControl[1]\n } else {\n this.#addSplineOffset(innerB, endDir, dist)\n }\n if (startControl) {\n innerA[0] = a[0] + startControl[0]\n innerA[1] = a[1] + startControl[1]\n } else {\n this.#addSplineOffset(innerA, startDir, dist)\n }\n path.moveTo(a[0], a[1] + offsety)\n path.bezierCurveTo(\n innerA[0],\n innerA[1] + offsety,\n innerB[0],\n innerB[1] + offsety,\n b[0],\n b[1] + offsety,\n )\n\n // Calculate centre point\n findPointOnCurve(pos, a, b, innerA, innerB, 0.5)\n\n if (linkSegment && this.linkMarkerShape === LinkMarkerShape.Arrow) {\n const justPastCentre = LGraphCanvas.#lTempC\n findPointOnCurve(justPastCentre, a, b, innerA, innerB, 0.51)\n\n linkSegment._centreAngle = Math.atan2(\n justPastCentre[1] - pos[1],\n justPastCentre[0] - pos[0],\n )\n }\n } else {\n const l = this.links_render_mode == LinkRenderType.LINEAR_LINK ? 15 : 10\n switch (startDir) {\n case LinkDirection.LEFT:\n innerA[0] += -l\n break\n case LinkDirection.RIGHT:\n innerA[0] += l\n break\n case LinkDirection.UP:\n innerA[1] += -l\n break\n case LinkDirection.DOWN:\n innerA[1] += l\n break\n }\n switch (endDir) {\n case LinkDirection.LEFT:\n innerB[0] += -l\n break\n case LinkDirection.RIGHT:\n innerB[0] += l\n break\n case LinkDirection.UP:\n innerB[1] += -l\n break\n case LinkDirection.DOWN:\n innerB[1] += l\n break\n }\n if (this.links_render_mode == LinkRenderType.LINEAR_LINK) {\n path.moveTo(a[0], a[1] + offsety)\n path.lineTo(innerA[0], innerA[1] + offsety)\n path.lineTo(innerB[0], innerB[1] + offsety)\n path.lineTo(b[0], b[1] + offsety)\n\n // Calculate centre point\n pos[0] = (innerA[0] + innerB[0]) * 0.5\n pos[1] = (innerA[1] + innerB[1]) * 0.5\n\n if (linkSegment && this.linkMarkerShape === LinkMarkerShape.Arrow) {\n linkSegment._centreAngle = Math.atan2(\n innerB[1] - innerA[1],\n innerB[0] - innerA[0],\n )\n }\n } else if (this.links_render_mode == LinkRenderType.STRAIGHT_LINK) {\n const midX = (innerA[0] + innerB[0]) * 0.5\n\n path.moveTo(a[0], a[1])\n path.lineTo(innerA[0], innerA[1])\n path.lineTo(midX, innerA[1])\n path.lineTo(midX, innerB[1])\n path.lineTo(innerB[0], innerB[1])\n path.lineTo(b[0], b[1])\n\n // Calculate centre point\n pos[0] = midX\n pos[1] = (innerA[1] + innerB[1]) * 0.5\n\n if (linkSegment && this.linkMarkerShape === LinkMarkerShape.Arrow) {\n const diff = innerB[1] - innerA[1]\n if (Math.abs(diff) < 4) linkSegment._centreAngle = 0\n else if (diff > 0) linkSegment._centreAngle = Math.PI * 0.5\n else linkSegment._centreAngle = -(Math.PI * 0.5)\n }\n } else {\n return\n }\n }\n }\n\n // rendering the outline of the connection can be a little bit slow\n if (this.render_connections_border && !this.low_quality && !skip_border) {\n ctx.strokeStyle = \"rgba(0,0,0,0.5)\"\n ctx.stroke(path)\n }\n\n ctx.lineWidth = this.connections_width\n ctx.fillStyle = ctx.strokeStyle = linkColour\n ctx.stroke(path)\n\n // render arrow in the middle\n if (\n this.ds.scale >= 0.6 &&\n this.highquality_render &&\n linkSegment\n ) {\n // render arrow\n if (this.render_connection_arrows) {\n // compute two points in the connection\n const posA = this.computeConnectionPoint(a, b, 0.25, startDir, endDir)\n const posB = this.computeConnectionPoint(a, b, 0.26, startDir, endDir)\n const posC = this.computeConnectionPoint(a, b, 0.75, startDir, endDir)\n const posD = this.computeConnectionPoint(a, b, 0.76, startDir, endDir)\n\n // compute the angle between them so the arrow points in the right direction\n let angleA = 0\n let angleB = 0\n if (this.render_curved_connections) {\n angleA = -Math.atan2(posB[0] - posA[0], posB[1] - posA[1])\n angleB = -Math.atan2(posD[0] - posC[0], posD[1] - posC[1])\n } else {\n angleB = angleA = b[1] > a[1] ? 0 : Math.PI\n }\n\n // render arrow\n const transform = ctx.getTransform()\n ctx.translate(posA[0], posA[1])\n ctx.rotate(angleA)\n ctx.beginPath()\n ctx.moveTo(-5, -3)\n ctx.lineTo(0, +7)\n ctx.lineTo(+5, -3)\n ctx.fill()\n ctx.setTransform(transform)\n\n ctx.translate(posC[0], posC[1])\n ctx.rotate(angleB)\n ctx.beginPath()\n ctx.moveTo(-5, -3)\n ctx.lineTo(0, +7)\n ctx.lineTo(+5, -3)\n ctx.fill()\n ctx.setTransform(transform)\n }\n\n // Draw link centre marker\n ctx.beginPath()\n if (this.linkMarkerShape === LinkMarkerShape.Arrow) {\n const transform = ctx.getTransform()\n ctx.translate(pos[0], pos[1])\n if (linkSegment._centreAngle) ctx.rotate(linkSegment._centreAngle)\n // The math is off, but it currently looks better in chromium\n ctx.moveTo(-3.2, -5)\n ctx.lineTo(+7, 0)\n ctx.lineTo(-3.2, +5)\n ctx.setTransform(transform)\n } else if (\n this.linkMarkerShape == null ||\n this.linkMarkerShape === LinkMarkerShape.Circle\n ) {\n ctx.arc(pos[0], pos[1], 5, 0, Math.PI * 2)\n }\n if (disabled) {\n const { fillStyle, globalAlpha } = ctx\n ctx.fillStyle = this._pattern ?? \"#797979\"\n ctx.globalAlpha = 0.75\n ctx.fill()\n ctx.globalAlpha = globalAlpha\n ctx.fillStyle = fillStyle\n }\n ctx.fill()\n\n if (LLink._drawDebug) {\n const { fillStyle, font, globalAlpha, lineWidth, strokeStyle } = ctx\n ctx.globalAlpha = 1\n ctx.lineWidth = 4\n ctx.fillStyle = \"white\"\n ctx.strokeStyle = \"black\"\n ctx.font = \"16px Arial\"\n\n const text = String(linkSegment.id)\n const { width, actualBoundingBoxAscent } = ctx.measureText(text)\n const x = pos[0] - width * 0.5\n const y = pos[1] + actualBoundingBoxAscent * 0.5\n ctx.strokeText(text, x, y)\n ctx.fillText(text, x, y)\n\n ctx.font = font\n ctx.globalAlpha = globalAlpha\n ctx.lineWidth = lineWidth\n ctx.fillStyle = fillStyle\n ctx.strokeStyle = strokeStyle\n }\n }\n\n // render flowing points\n if (flow) {\n ctx.fillStyle = linkColour\n for (let i = 0; i < 5; ++i) {\n const f = (LiteGraph.getTime() * 0.001 + i * 0.2) % 1\n const flowPos = this.computeConnectionPoint(a, b, f, startDir, endDir)\n ctx.beginPath()\n ctx.arc(flowPos[0], flowPos[1], 5, 0, 2 * Math.PI)\n ctx.fill()\n }\n }\n }\n\n /**\n * Finds a point along a spline represented by a to b, with spline endpoint directions dictacted by start_dir and end_dir.\n * @param a Start point\n * @param b End point\n * @param t Time: distance between points (e.g 0.25 is 25% along the line)\n * @param start_dir Spline start direction\n * @param end_dir Spline end direction\n * @returns The point at {@link t} distance along the spline a-b.\n */\n computeConnectionPoint(\n a: ReadOnlyPoint,\n b: ReadOnlyPoint,\n t: number,\n start_dir: LinkDirection,\n end_dir: LinkDirection,\n ): Point {\n start_dir ||= LinkDirection.RIGHT\n end_dir ||= LinkDirection.LEFT\n\n const dist = distance(a, b)\n const pa: Point = [a[0], a[1]]\n const pb: Point = [b[0], b[1]]\n\n this.#addSplineOffset(pa, start_dir, dist)\n this.#addSplineOffset(pb, end_dir, dist)\n\n const c1 = (1 - t) * (1 - t) * (1 - t)\n const c2 = 3 * ((1 - t) * (1 - t)) * t\n const c3 = 3 * (1 - t) * (t * t)\n const c4 = t * t * t\n\n const x = c1 * a[0] + c2 * pa[0] + c3 * pb[0] + c4 * b[0]\n const y = c1 * a[1] + c2 * pa[1] + c3 * pb[1] + c4 * b[1]\n return [x, y]\n }\n\n /**\n * Modifies an existing point, adding a single-axis offset.\n * @param point The point to add the offset to\n * @param direction The direction to add the offset in\n * @param dist Distance to offset\n * @param factor Distance is mulitplied by this value. Default: 0.25\n */\n #addSplineOffset(\n point: Point,\n direction: LinkDirection,\n dist: number,\n factor = 0.25,\n ): void {\n switch (direction) {\n case LinkDirection.LEFT:\n point[0] += dist * -factor\n break\n case LinkDirection.RIGHT:\n point[0] += dist * factor\n break\n case LinkDirection.UP:\n point[1] += dist * -factor\n break\n case LinkDirection.DOWN:\n point[1] += dist * factor\n break\n }\n }\n\n drawExecutionOrder(ctx: CanvasRenderingContext2D): void {\n ctx.shadowColor = \"transparent\"\n ctx.globalAlpha = 0.25\n\n ctx.textAlign = \"center\"\n ctx.strokeStyle = \"white\"\n ctx.globalAlpha = 0.75\n\n const { visible_nodes } = this\n for (const node of visible_nodes) {\n ctx.fillStyle = \"black\"\n ctx.fillRect(\n node.pos[0] - LiteGraph.NODE_TITLE_HEIGHT,\n node.pos[1] - LiteGraph.NODE_TITLE_HEIGHT,\n LiteGraph.NODE_TITLE_HEIGHT,\n LiteGraph.NODE_TITLE_HEIGHT,\n )\n if (node.order == 0) {\n ctx.strokeRect(\n node.pos[0] - LiteGraph.NODE_TITLE_HEIGHT + 0.5,\n node.pos[1] - LiteGraph.NODE_TITLE_HEIGHT + 0.5,\n LiteGraph.NODE_TITLE_HEIGHT,\n LiteGraph.NODE_TITLE_HEIGHT,\n )\n }\n ctx.fillStyle = \"#FFF\"\n ctx.fillText(\n stringOrEmpty(node.order),\n node.pos[0] + LiteGraph.NODE_TITLE_HEIGHT * -0.5,\n node.pos[1] - 6,\n )\n }\n ctx.globalAlpha = 1\n }\n\n /**\n * draws the widgets stored inside a node\n * @deprecated Use {@link LGraphNode.drawWidgets} instead.\n * @remarks Currently there are extensions hijacking this function, so we cannot remove it.\n */\n drawNodeWidgets(\n node: LGraphNode,\n _posY: null,\n ctx: CanvasRenderingContext2D,\n ): void {\n node.drawWidgets(ctx, {\n lowQuality: this.low_quality,\n editorAlpha: this.editor_alpha,\n })\n }\n\n /**\n * draws every group area in the background\n */\n drawGroups(canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D): void {\n if (!this.graph) return\n\n const groups = this.graph._groups\n\n ctx.save()\n ctx.globalAlpha = 0.5 * this.editor_alpha\n const drawSnapGuides = this.#snapToGrid && this.isDragging\n\n for (const group of groups) {\n // out of the visible area\n if (!overlapBounding(this.visible_area, group._bounding)) {\n continue\n }\n\n // Draw snap shadow\n if (drawSnapGuides && this.selectedItems.has(group))\n this.drawSnapGuide(ctx, group)\n\n group.draw(this, ctx)\n }\n\n ctx.restore()\n }\n\n /**\n * resizes the canvas to a given size, if no size is passed, then it tries to fill the parentNode\n * @todo Remove or rewrite\n */\n resize(width?: number, height?: number): void {\n if (!width && !height) {\n const parent = this.canvas.parentElement\n if (!parent) throw new TypeError(\"Attempted to resize canvas, but parent element was null.\")\n width = parent.offsetWidth\n height = parent.offsetHeight\n }\n\n if (this.canvas.width == width && this.canvas.height == height) return\n\n this.canvas.width = width ?? 0\n this.canvas.height = height ?? 0\n this.bgcanvas.width = this.canvas.width\n this.bgcanvas.height = this.canvas.height\n this.setDirty(true, true)\n }\n\n onNodeSelectionChange(): void {}\n\n /**\n * Determines the furthest nodes in each direction for the currently selected nodes\n */\n boundaryNodesForSelection(): NullableProperties<IBoundaryNodes> {\n return LGraphCanvas.getBoundaryNodes(this.selected_nodes)\n }\n\n showLinkMenu(segment: LinkSegment, e: CanvasPointerEvent): boolean {\n const { graph } = this\n if (!graph) throw new NullGraphError()\n\n const title = \"data\" in segment && segment.data != null\n ? segment.data.constructor.name\n : undefined\n\n const { origin_id, origin_slot } = segment\n if (origin_id == null || origin_slot == null) {\n new LiteGraph.ContextMenu<string>([\"Link has no origin\"], {\n event: e,\n title,\n })\n return false\n }\n\n const node_left = graph.getNodeById(origin_id)\n const fromType = node_left?.outputs?.[origin_slot]?.type\n\n const options = [\"Add Node\", \"Add Reroute\", null, \"Delete\", null]\n\n const menu = new LiteGraph.ContextMenu<string>(options, {\n event: e,\n title,\n callback: inner_clicked.bind(this),\n })\n\n return false\n\n function inner_clicked(this: LGraphCanvas, v: string, options: unknown, e: MouseEvent) {\n if (!graph) throw new NullGraphError()\n\n switch (v) {\n case \"Add Node\":\n LGraphCanvas.onMenuAdd(null, null, e, menu, (node) => {\n if (!node?.inputs?.length || !node?.outputs?.length || origin_slot == null) return\n\n // leave the connection type checking inside connectByType\n const options = { afterRerouteId: segment.parentId }\n if (node_left?.connectByType(origin_slot, node, fromType ?? \"*\", options)) {\n node.pos[0] -= node.size[0] * 0.5\n }\n })\n break\n\n case \"Add Reroute\": {\n try {\n this.emitBeforeChange()\n this.adjustMouseEvent(e)\n graph.createReroute(segment._pos, segment)\n this.setDirty(false, true)\n } catch (error) {\n console.error(error)\n } finally {\n this.emitAfterChange()\n }\n break\n }\n\n case \"Delete\":\n graph.removeLink(segment.id)\n break\n default:\n }\n }\n }\n\n createDefaultNodeForSlot(optPass: ICreateDefaultNodeOptions): boolean {\n type DefaultOptions = ICreateDefaultNodeOptions & {\n posAdd: Point\n posSizeFix: Point\n }\n\n const opts = Object.assign<DefaultOptions, ICreateDefaultNodeOptions>({\n nodeFrom: null,\n slotFrom: null,\n nodeTo: null,\n slotTo: null,\n position: [0, 0],\n nodeType: undefined,\n posAdd: [0, 0],\n posSizeFix: [0, 0],\n }, optPass)\n const { afterRerouteId } = opts\n\n const isFrom = opts.nodeFrom && opts.slotFrom !== null\n const isTo = !isFrom && opts.nodeTo && opts.slotTo !== null\n\n if (!isFrom && !isTo) {\n console.warn(`No data passed to createDefaultNodeForSlot`, opts.nodeFrom, opts.slotFrom, opts.nodeTo, opts.slotTo)\n return false\n }\n if (!opts.nodeType) {\n console.warn(\"No type to createDefaultNodeForSlot\")\n return false\n }\n\n const nodeX = isFrom ? opts.nodeFrom : opts.nodeTo\n if (!nodeX) throw new TypeError(\"nodeX was null when creating default node for slot.\")\n\n let slotX = isFrom ? opts.slotFrom : opts.slotTo\n\n let iSlotConn: number | false = false\n if (nodeX instanceof SubgraphIONodeBase) {\n if (typeof slotX !== \"object\" || !slotX) {\n console.warn(\"Cant get slot information\", slotX)\n return false\n }\n const { name } = slotX\n iSlotConn = nodeX.slots.findIndex(s => s.name === name)\n slotX = nodeX.slots[iSlotConn]\n if (!slotX) {\n console.warn(\"Cant get slot information\", slotX)\n return false\n }\n } else {\n switch (typeof slotX) {\n case \"string\":\n iSlotConn = isFrom ? nodeX.findOutputSlot(slotX, false) : nodeX.findInputSlot(slotX, false)\n slotX = isFrom ? nodeX.outputs[slotX] : nodeX.inputs[slotX]\n break\n case \"object\":\n if (slotX === null) {\n console.warn(\"Cant get slot information\", slotX)\n return false\n }\n\n // ok slotX\n iSlotConn = isFrom ? nodeX.findOutputSlot(slotX.name) : nodeX.findInputSlot(slotX.name)\n break\n case \"number\":\n iSlotConn = slotX\n slotX = isFrom ? nodeX.outputs[slotX] : nodeX.inputs[slotX]\n break\n case \"undefined\":\n default:\n console.warn(\"Cant get slot information\", slotX)\n return false\n }\n }\n\n // check for defaults nodes for this slottype\n const fromSlotType = slotX.type == LiteGraph.EVENT ? \"_event_\" : slotX.type\n const slotTypesDefault = isFrom\n ? LiteGraph.slot_types_default_out\n : LiteGraph.slot_types_default_in\n if (slotTypesDefault?.[fromSlotType]) {\n // TODO: Remove \"any\" kludge\n let nodeNewType: any = false\n if (typeof slotTypesDefault[fromSlotType] == \"object\") {\n for (const typeX in slotTypesDefault[fromSlotType]) {\n if (\n opts.nodeType == slotTypesDefault[fromSlotType][typeX] ||\n opts.nodeType == \"AUTO\"\n ) {\n nodeNewType = slotTypesDefault[fromSlotType][typeX]\n break\n }\n }\n } else if (\n opts.nodeType == slotTypesDefault[fromSlotType] ||\n opts.nodeType == \"AUTO\"\n ) {\n nodeNewType = slotTypesDefault[fromSlotType]\n }\n if (nodeNewType) {\n // TODO: Remove \"any\" kludge\n let nodeNewOpts: any = false\n if (typeof nodeNewType == \"object\" && nodeNewType.node) {\n nodeNewOpts = nodeNewType\n nodeNewType = nodeNewType.node\n }\n\n // that.graph.beforeChange();\n const newNode = LiteGraph.createNode(nodeNewType)\n if (newNode) {\n // if is object pass options\n if (nodeNewOpts) {\n if (nodeNewOpts.properties) {\n for (const i in nodeNewOpts.properties) {\n newNode.addProperty(i, nodeNewOpts.properties[i])\n }\n }\n if (nodeNewOpts.inputs) {\n newNode.inputs = []\n for (const i in nodeNewOpts.inputs) {\n newNode.addOutput(\n nodeNewOpts.inputs[i][0],\n nodeNewOpts.inputs[i][1],\n )\n }\n }\n if (nodeNewOpts.outputs) {\n newNode.outputs = []\n for (const i in nodeNewOpts.outputs) {\n newNode.addOutput(\n nodeNewOpts.outputs[i][0],\n nodeNewOpts.outputs[i][1],\n )\n }\n }\n if (nodeNewOpts.title) {\n newNode.title = nodeNewOpts.title\n }\n if (nodeNewOpts.json) {\n newNode.configure(nodeNewOpts.json)\n }\n }\n\n // add the node\n if (!this.graph) throw new NullGraphError()\n\n this.graph.add(newNode)\n newNode.pos = [\n opts.position[0] + opts.posAdd[0] + (opts.posSizeFix[0] ? opts.posSizeFix[0] * newNode.size[0] : 0),\n opts.position[1] + opts.posAdd[1] + (opts.posSizeFix[1] ? opts.posSizeFix[1] * newNode.size[1] : 0),\n ]\n\n // Interim API - allow the link connection to be canceled.\n // TODO: https://github.com/Comfy-Org/litegraph.js/issues/946\n const detail = { node: newNode, opts }\n const mayConnectLinks = this.canvas.dispatchEvent(new CustomEvent(\"connect-new-default-node\", { detail, cancelable: true }))\n if (!mayConnectLinks) return true\n\n // connect the two!\n if (isFrom) {\n if (!opts.nodeFrom) throw new TypeError(\"createDefaultNodeForSlot - nodeFrom was null\")\n opts.nodeFrom.connectByType(iSlotConn, newNode, fromSlotType, { afterRerouteId })\n } else {\n if (!opts.nodeTo) throw new TypeError(\"createDefaultNodeForSlot - nodeTo was null\")\n opts.nodeTo.connectByTypeOutput(iSlotConn, newNode, fromSlotType, { afterRerouteId })\n }\n\n // if connecting in between\n if (isFrom && isTo) {\n // TODO\n }\n\n return true\n }\n console.log(`failed creating ${nodeNewType}`)\n }\n }\n return false\n }\n\n showConnectionMenu(optPass: Partial<ICreateNodeOptions & { e: MouseEvent }>): ContextMenu<string> | undefined {\n const opts = Object.assign<ICreateNodeOptions & HasShowSearchCallback, ICreateNodeOptions>({\n nodeFrom: null,\n slotFrom: null,\n nodeTo: null,\n slotTo: null,\n e: undefined,\n allow_searchbox: this.allow_searchbox,\n showSearchBox: this.showSearchBox,\n }, optPass || {})\n const dirty = () => this.#dirty()\n const that = this\n const { graph } = this\n const { afterRerouteId } = opts\n\n const isFrom = opts.nodeFrom && opts.slotFrom\n const isTo = !isFrom && opts.nodeTo && opts.slotTo\n\n if (!isFrom && !isTo) {\n console.warn(\"No data passed to showConnectionMenu\")\n return\n }\n\n const nodeX = isFrom ? opts.nodeFrom : opts.nodeTo\n if (!nodeX) throw new TypeError(\"nodeX was null when creating default node for slot.\")\n let slotX = isFrom ? opts.slotFrom : opts.slotTo\n\n let iSlotConn: number\n if (nodeX instanceof SubgraphIONodeBase) {\n if (typeof slotX !== \"object\" || !slotX) {\n console.warn(\"Cant get slot information\", slotX)\n return\n }\n const { name } = slotX\n iSlotConn = nodeX.slots.findIndex(s => s.name === name)\n // If it's not found in the main slots, it might be the empty slot from a Subgraph node.\n // In that case, the original `slotX` object is the correct one, so don't overwrite it.\n if (iSlotConn !== -1) {\n slotX = nodeX.slots[iSlotConn]\n }\n if (!slotX) {\n console.warn(\"Cant get slot information\", slotX)\n return\n }\n } else {\n switch (typeof slotX) {\n case \"string\":\n iSlotConn = isFrom\n ? nodeX.findOutputSlot(slotX, false)\n : nodeX.findInputSlot(slotX, false)\n slotX = isFrom ? nodeX.outputs[slotX] : nodeX.inputs[slotX]\n break\n case \"object\":\n if (slotX === null) {\n console.warn(\"Cant get slot information\", slotX)\n return\n }\n\n // ok slotX\n iSlotConn = isFrom\n ? nodeX.findOutputSlot(slotX.name)\n : nodeX.findInputSlot(slotX.name)\n break\n case \"number\":\n iSlotConn = slotX\n slotX = isFrom ? nodeX.outputs[slotX] : nodeX.inputs[slotX]\n break\n default:\n console.warn(\"Cant get slot information\", slotX)\n return\n }\n }\n\n const options = [\"Add Node\", \"Add Reroute\", null]\n\n if (opts.allow_searchbox) {\n options.push(\"Search\", null)\n }\n\n // get defaults nodes for this slottype\n const fromSlotType = slotX.type == LiteGraph.EVENT ? \"_event_\" : slotX.type\n const slotTypesDefault = isFrom\n ? LiteGraph.slot_types_default_out\n : LiteGraph.slot_types_default_in\n if (slotTypesDefault?.[fromSlotType]) {\n if (typeof slotTypesDefault[fromSlotType] == \"object\") {\n for (const typeX in slotTypesDefault[fromSlotType]) {\n options.push(slotTypesDefault[fromSlotType][typeX])\n }\n } else {\n options.push(slotTypesDefault[fromSlotType])\n }\n }\n\n // build menu\n const menu = new LiteGraph.ContextMenu<string>(options, {\n event: opts.e,\n extra: slotX,\n title:\n (slotX && slotX.name != \"\"\n ? slotX.name + (fromSlotType ? \" | \" : \"\")\n : \"\") + (slotX && fromSlotType ? fromSlotType : \"\"),\n callback: inner_clicked,\n })\n\n return menu\n\n // callback\n function inner_clicked(v: string | undefined, options: IContextMenuOptions<string, INodeInputSlot | INodeOutputSlot>, e: MouseEvent) {\n switch (v) {\n case \"Add Node\":\n LGraphCanvas.onMenuAdd(null, null, e, menu, function (node) {\n if (!node) return\n\n if (isFrom) {\n if (!opts.nodeFrom) throw new TypeError(\"Cannot add node to SubgraphInputNode: nodeFrom was null\")\n const slot = opts.nodeFrom.connectByType(iSlotConn, node, fromSlotType, { afterRerouteId })\n if (!slot) console.warn(\"Failed to make new connection.\")\n // }\n } else {\n if (!opts.nodeTo) throw new TypeError(\"Cannot add node to SubgraphInputNode: nodeTo was null\")\n opts.nodeTo.connectByTypeOutput(iSlotConn, node, fromSlotType, { afterRerouteId })\n }\n })\n break\n case \"Add Reroute\":{\n const node = isFrom ? opts.nodeFrom : opts.nodeTo\n const slot = options.extra\n\n if (!graph) throw new NullGraphError()\n if (!node) throw new TypeError(\"Cannot add reroute: node was null\")\n if (!slot) throw new TypeError(\"Cannot add reroute: slot was null\")\n if (!opts.e) throw new TypeError(\"Cannot add reroute: CanvasPointerEvent was null\")\n\n if (node instanceof SubgraphIONodeBase) {\n throw new TypeError(\"Cannot add floating reroute to Subgraph IO Nodes\")\n } else {\n const reroute = node.connectFloatingReroute([opts.e.canvasX, opts.e.canvasY], slot, afterRerouteId)\n if (!reroute) throw new Error(\"Failed to create reroute\")\n }\n\n dirty()\n break\n }\n case \"Search\":\n if (isFrom) {\n // @ts-expect-error Subgraph\n opts.showSearchBox(e, { node_from: opts.nodeFrom, slot_from: slotX, type_filter_in: fromSlotType })\n } else {\n // @ts-expect-error Subgraph\n opts.showSearchBox(e, { node_to: opts.nodeTo, slot_from: slotX, type_filter_out: fromSlotType })\n }\n break\n default: {\n const customProps = {\n position: [opts.e?.canvasX ?? 0, opts.e?.canvasY ?? 0],\n nodeType: v,\n afterRerouteId,\n } satisfies Partial<ICreateDefaultNodeOptions>\n\n const options = Object.assign(opts, customProps)\n if (!that.createDefaultNodeForSlot(options))\n break\n }\n }\n }\n }\n\n // refactor: there are different dialogs, some uses createDialog some dont\n prompt(\n title: string,\n value: any,\n callback: (arg0: any) => void,\n event: CanvasPointerEvent,\n multiline?: boolean,\n ): HTMLDivElement {\n const that = this\n title = title || \"\"\n\n const customProperties = {\n is_modified: false,\n className: \"graphdialog rounded\",\n innerHTML: multiline\n ? \"<span class='name'></span> <textarea autofocus class='value'></textarea><button class='rounded'>OK</button>\"\n : \"<span class='name'></span> <input autofocus type='text' class='value'/><button class='rounded'>OK</button>\",\n close() {\n that.prompt_box = null\n if (dialog.parentNode) {\n dialog.remove()\n }\n },\n } satisfies Partial<IDialog>\n\n const div = document.createElement(\"div\")\n const dialog: PromptDialog = Object.assign(div, customProperties)\n\n const graphcanvas = LGraphCanvas.active_canvas\n const { canvas } = graphcanvas\n if (!canvas.parentNode) throw new TypeError(\"canvas element parentNode was null when opening a prompt.\")\n canvas.parentNode.append(dialog)\n\n if (this.ds.scale > 1) dialog.style.transform = `scale(${this.ds.scale})`\n\n let dialogCloseTimer: number\n let prevent_timeout = 0\n LiteGraph.pointerListenerAdd(dialog, \"leave\", function () {\n if (prevent_timeout) return\n if (LiteGraph.dialog_close_on_mouse_leave) {\n if (!dialog.is_modified && LiteGraph.dialog_close_on_mouse_leave) {\n dialogCloseTimer = setTimeout(\n dialog.close,\n LiteGraph.dialog_close_on_mouse_leave_delay,\n )\n }\n }\n })\n LiteGraph.pointerListenerAdd(dialog, \"enter\", function () {\n if (LiteGraph.dialog_close_on_mouse_leave && dialogCloseTimer)\n clearTimeout(dialogCloseTimer)\n })\n const selInDia = dialog.querySelectorAll(\"select\")\n if (selInDia) {\n // if filtering, check focus changed to comboboxes and prevent closing\n for (const selIn of selInDia) {\n selIn.addEventListener(\"click\", function () {\n prevent_timeout++\n })\n selIn.addEventListener(\"blur\", function () {\n prevent_timeout = 0\n })\n selIn.addEventListener(\"change\", function () {\n prevent_timeout = -1\n })\n }\n }\n this.prompt_box?.close()\n this.prompt_box = dialog\n\n const name_element: HTMLSpanElement | null = dialog.querySelector(\".name\")\n if (!name_element) throw new TypeError(\"name_element was null\")\n\n name_element.textContent = title\n const value_element: HTMLInputElement | null = dialog.querySelector(\".value\")\n if (!value_element) throw new TypeError(\"value_element was null\")\n\n value_element.value = value\n value_element.select()\n\n const input = value_element\n input.addEventListener(\"keydown\", function (e: KeyboardEvent) {\n dialog.is_modified = true\n if (e.key == \"Escape\") {\n // ESC\n dialog.close()\n } else if (\n e.key == \"Enter\" &&\n (e.target as Element).localName != \"textarea\"\n ) {\n if (callback) {\n callback(this.value)\n }\n dialog.close()\n } else {\n return\n }\n e.preventDefault()\n e.stopPropagation()\n })\n\n const button = dialog.querySelector(\"button\")\n if (!button) throw new TypeError(\"button was null when opening prompt\")\n\n button.addEventListener(\"click\", function () {\n callback?.(input.value)\n that.setDirty(true)\n dialog.close()\n })\n\n const rect = canvas.getBoundingClientRect()\n let offsetx = -20\n let offsety = -20\n if (rect) {\n offsetx -= rect.left\n offsety -= rect.top\n }\n\n if (event) {\n dialog.style.left = `${event.clientX + offsetx}px`\n dialog.style.top = `${event.clientY + offsety}px`\n } else {\n dialog.style.left = `${canvas.width * 0.5 + offsetx}px`\n dialog.style.top = `${canvas.height * 0.5 + offsety}px`\n }\n\n setTimeout(function () {\n input.focus()\n const clickTime = Date.now()\n function handleOutsideClick(e: Event) {\n if (e.target === canvas && Date.now() - clickTime > 256) {\n dialog.close()\n canvas.parentElement?.removeEventListener(\"click\", handleOutsideClick)\n canvas.parentElement?.removeEventListener(\"touchend\", handleOutsideClick)\n }\n }\n canvas.parentElement?.addEventListener(\"click\", handleOutsideClick)\n canvas.parentElement?.addEventListener(\"touchend\", handleOutsideClick)\n }, 10)\n\n return dialog\n }\n\n showSearchBox(\n event: MouseEvent,\n searchOptions?: IShowSearchOptions,\n ): HTMLDivElement {\n // proposed defaults\n const options: IShowSearchOptions = {\n slot_from: null,\n node_from: null,\n node_to: null,\n // TODO check for registered_slot_[in/out]_types not empty\n // this will be checked for functionality enabled : filter on slot type, in and out\n do_type_filter: LiteGraph.search_filter_enabled,\n\n // these are default: pass to set initially set values\n // @ts-expect-error\n type_filter_in: false,\n\n type_filter_out: false,\n show_general_if_none_on_typefilter: true,\n show_general_after_typefiltered: true,\n hide_on_mouse_leave: LiteGraph.search_hide_on_mouse_leave,\n show_all_if_empty: true,\n show_all_on_open: LiteGraph.search_show_all_on_open,\n }\n Object.assign(options, searchOptions)\n\n // console.log(options);\n const that = this\n const graphcanvas = LGraphCanvas.active_canvas\n const { canvas } = graphcanvas\n const root_document = canvas.ownerDocument || document\n\n const div = document.createElement(\"div\")\n const dialog = Object.assign(div, {\n close(this: typeof div) {\n that.search_box = undefined\n this.blur()\n canvas.focus()\n root_document.body.style.overflow = \"\"\n\n // important, if canvas loses focus keys wont be captured\n setTimeout(() => canvas.focus(), 20)\n dialog.remove()\n },\n } satisfies Partial<HTMLDivElement> & ICloseable)\n dialog.className = \"litegraph litesearchbox graphdialog rounded\"\n dialog.innerHTML = \"<span class='name'>Search</span> <input autofocus type='text' class='value rounded'/>\"\n if (options.do_type_filter) {\n dialog.innerHTML += \"<select class='slot_in_type_filter'><option value=''></option></select>\"\n dialog.innerHTML += \"<select class='slot_out_type_filter'><option value=''></option></select>\"\n }\n const helper = document.createElement(\"div\")\n helper.className = \"helper\"\n dialog.append(helper)\n\n if (root_document.fullscreenElement) {\n root_document.fullscreenElement.append(dialog)\n } else {\n root_document.body.append(dialog)\n root_document.body.style.overflow = \"hidden\"\n }\n\n // dialog element has been appended\n let selIn\n let selOut\n if (options.do_type_filter) {\n selIn = dialog.querySelector(\".slot_in_type_filter\")\n selOut = dialog.querySelector(\".slot_out_type_filter\")\n }\n\n if (this.ds.scale > 1) {\n dialog.style.transform = `scale(${this.ds.scale})`\n }\n\n // hide on mouse leave\n if (options.hide_on_mouse_leave) {\n // FIXME: Remove \"any\" kludge\n let prevent_timeout: any = false\n let timeout_close: number | null = null\n LiteGraph.pointerListenerAdd(dialog, \"enter\", function () {\n if (timeout_close) {\n clearTimeout(timeout_close)\n timeout_close = null\n }\n })\n dialog.addEventListener(\"pointerleave\", function () {\n if (prevent_timeout) return\n\n const hideDelay = options.hide_on_mouse_leave\n const delay = typeof hideDelay === \"number\" ? hideDelay : 500\n timeout_close = setTimeout(dialog.close, delay)\n })\n // if filtering, check focus changed to comboboxes and prevent closing\n if (options.do_type_filter) {\n if (!selIn) throw new TypeError(\"selIn was null when showing search box\")\n if (!selOut) throw new TypeError(\"selOut was null when showing search box\")\n\n selIn.addEventListener(\"click\", function () {\n prevent_timeout++\n })\n selIn.addEventListener(\"blur\", function () {\n prevent_timeout = 0\n })\n selIn.addEventListener(\"change\", function () {\n prevent_timeout = -1\n })\n selOut.addEventListener(\"click\", function () {\n prevent_timeout++\n })\n selOut.addEventListener(\"blur\", function () {\n prevent_timeout = 0\n })\n selOut.addEventListener(\"change\", function () {\n prevent_timeout = -1\n })\n }\n }\n\n // @ts-expect-error Panel?\n that.search_box?.close()\n that.search_box = dialog\n\n let first: string | null = null\n let timeout: number | null = null\n let selected: ChildNode | null = null\n\n const maybeInput = dialog.querySelector(\"input\")\n if (!maybeInput) throw new TypeError(\"Could not create search input box.\")\n\n const input = maybeInput\n\n if (input) {\n input.addEventListener(\"blur\", function () {\n this.focus()\n })\n input.addEventListener(\"keydown\", function (e) {\n if (e.key == \"ArrowUp\") {\n // UP\n changeSelection(false)\n } else if (e.key == \"ArrowDown\") {\n // DOWN\n changeSelection(true)\n } else if (e.key == \"Escape\") {\n // ESC\n dialog.close()\n } else if (e.key == \"Enter\") {\n if (selected instanceof HTMLElement) {\n select(unescape(String(selected.dataset[\"type\"])))\n } else if (first) {\n select(first)\n } else {\n dialog.close()\n }\n } else {\n if (timeout) {\n clearInterval(timeout)\n }\n timeout = setTimeout(refreshHelper, 10)\n return\n }\n e.preventDefault()\n e.stopPropagation()\n e.stopImmediatePropagation()\n return true\n })\n }\n\n // if should filter on type, load and fill selected and choose elements if passed\n if (options.do_type_filter) {\n if (selIn) {\n const aSlots = LiteGraph.slot_types_in\n const nSlots = aSlots.length\n\n if (\n options.type_filter_in == LiteGraph.EVENT ||\n options.type_filter_in == LiteGraph.ACTION\n ) {\n options.type_filter_in = \"_event_\"\n }\n for (let iK = 0; iK < nSlots; iK++) {\n const opt = document.createElement(\"option\")\n opt.value = aSlots[iK]\n opt.innerHTML = aSlots[iK]\n selIn.append(opt)\n if (\n // @ts-expect-error\n options.type_filter_in !== false &&\n String(options.type_filter_in).toLowerCase() ==\n String(aSlots[iK]).toLowerCase()\n ) {\n opt.selected = true\n }\n }\n selIn.addEventListener(\"change\", function () {\n refreshHelper()\n })\n }\n if (selOut) {\n const aSlots = LiteGraph.slot_types_out\n\n if (\n options.type_filter_out == LiteGraph.EVENT ||\n options.type_filter_out == LiteGraph.ACTION\n ) {\n options.type_filter_out = \"_event_\"\n }\n for (const aSlot of aSlots) {\n const opt = document.createElement(\"option\")\n opt.value = aSlot\n opt.innerHTML = aSlot\n selOut.append(opt)\n if (\n options.type_filter_out !== false &&\n String(options.type_filter_out).toLowerCase() ==\n String(aSlot).toLowerCase()\n ) {\n opt.selected = true\n }\n }\n selOut.addEventListener(\"change\", function () {\n refreshHelper()\n })\n }\n }\n\n // compute best position\n const rect = canvas.getBoundingClientRect()\n\n const left = (event ? event.clientX : rect.left + rect.width * 0.5) - 80\n const top = (event ? event.clientY : rect.top + rect.height * 0.5) - 20\n dialog.style.left = `${left}px`\n dialog.style.top = `${top}px`\n\n // To avoid out of screen problems\n if (event.layerY > rect.height - 200) {\n helper.style.maxHeight = `${rect.height - event.layerY - 20}px`\n }\n requestAnimationFrame(function () {\n input.focus()\n })\n if (options.show_all_on_open) refreshHelper()\n\n function select(name: string) {\n if (name) {\n if (that.onSearchBoxSelection) {\n that.onSearchBoxSelection(name, event, graphcanvas)\n } else {\n if (!graphcanvas.graph) throw new NullGraphError()\n\n graphcanvas.graph.beforeChange()\n const node = LiteGraph.createNode(name)\n if (node) {\n node.pos = graphcanvas.convertEventToCanvasOffset(event)\n graphcanvas.graph.add(node, false)\n }\n\n // join node after inserting\n if (options.node_from) {\n // FIXME: any\n let iS: any = false\n switch (typeof options.slot_from) {\n case \"string\":\n iS = options.node_from.findOutputSlot(options.slot_from)\n break\n case \"object\":\n if (options.slot_from == null) throw new TypeError(\"options.slot_from was null when showing search box\")\n\n iS = options.slot_from.name\n ? options.node_from.findOutputSlot(options.slot_from.name)\n : -1\n // @ts-expect-error change interface check\n if (iS == -1 && options.slot_from.slot_index !== undefined) iS = options.slot_from.slot_index\n break\n case \"number\":\n iS = options.slot_from\n break\n default:\n // try with first if no name set\n iS = 0\n }\n if (options.node_from.outputs[iS] !== undefined) {\n if (iS !== false && iS > -1) {\n if (node == null) throw new TypeError(\"options.slot_from was null when showing search box\")\n\n options.node_from.connectByType(iS, node, options.node_from.outputs[iS].type)\n }\n } else {\n // console.warn(\"cant find slot \" + options.slot_from);\n }\n }\n if (options.node_to) {\n // FIXME: any\n let iS: any = false\n switch (typeof options.slot_from) {\n case \"string\":\n iS = options.node_to.findInputSlot(options.slot_from)\n break\n case \"object\":\n if (options.slot_from == null) throw new TypeError(\"options.slot_from was null when showing search box\")\n\n iS = options.slot_from.name\n ? options.node_to.findInputSlot(options.slot_from.name)\n : -1\n // @ts-expect-error change interface check\n if (iS == -1 && options.slot_from.slot_index !== undefined) iS = options.slot_from.slot_index\n break\n case \"number\":\n iS = options.slot_from\n break\n default:\n // try with first if no name set\n iS = 0\n }\n if (options.node_to.inputs[iS] !== undefined) {\n if (iS !== false && iS > -1) {\n if (node == null) throw new TypeError(\"options.slot_from was null when showing search box\")\n // try connection\n options.node_to.connectByTypeOutput(iS, node, options.node_to.inputs[iS].type)\n }\n } else {\n // console.warn(\"cant find slot_nodeTO \" + options.slot_from);\n }\n }\n\n graphcanvas.graph.afterChange()\n }\n }\n\n dialog.close()\n }\n\n function changeSelection(forward: boolean) {\n const prev = selected\n if (!selected) {\n selected = forward\n ? helper.childNodes[0]\n : helper.childNodes[helper.childNodes.length]\n } else if (selected instanceof Element) {\n selected.classList.remove(\"selected\")\n selected = forward\n ? selected.nextSibling\n : selected.previousSibling\n selected ||= prev\n }\n\n if (selected instanceof Element) {\n selected.classList.add(\"selected\")\n selected.scrollIntoView({ block: \"end\", behavior: \"smooth\" })\n }\n }\n\n function refreshHelper() {\n timeout = null\n let str = input.value\n first = null\n helper.innerHTML = \"\"\n if (!str && !options.show_all_if_empty) return\n\n if (that.onSearchBox) {\n const list = that.onSearchBox(helper, str, graphcanvas)\n if (list) {\n for (const item of list) {\n addResult(item)\n }\n }\n } else {\n let c = 0\n str = str.toLowerCase()\n if (!graphcanvas.graph) throw new NullGraphError()\n\n const filter = graphcanvas.filter || graphcanvas.graph.filter\n\n // FIXME: any\n // filter by type preprocess\n let sIn: any = false\n let sOut: any = false\n if (options.do_type_filter && that.search_box) {\n sIn = that.search_box.querySelector(\".slot_in_type_filter\")\n sOut = that.search_box.querySelector(\".slot_out_type_filter\")\n }\n\n const keys = Object.keys(LiteGraph.registered_node_types)\n const filtered = keys.filter(x => inner_test_filter(x))\n\n for (const item of filtered) {\n addResult(item)\n if (LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit)\n break\n }\n\n // add general type if filtering\n if (\n options.show_general_after_typefiltered &&\n (sIn.value || sOut.value)\n ) {\n // FIXME: Undeclared variable again\n // @ts-expect-error\n filtered_extra = []\n for (const i in LiteGraph.registered_node_types) {\n if (\n inner_test_filter(i, {\n inTypeOverride: sIn && sIn.value ? \"*\" : false,\n outTypeOverride: sOut && sOut.value ? \"*\" : false,\n })\n ) {\n // @ts-expect-error\n filtered_extra.push(i)\n }\n }\n // @ts-expect-error\n for (const extraItem of filtered_extra) {\n addResult(extraItem, \"generic_type\")\n if (LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit)\n break\n }\n }\n\n // check il filtering gave no results\n if (\n (sIn.value || sOut.value) &&\n helper.childNodes.length == 0 &&\n options.show_general_if_none_on_typefilter\n ) {\n // @ts-expect-error\n filtered_extra = []\n for (const i in LiteGraph.registered_node_types) {\n if (inner_test_filter(i, { skipFilter: true }))\n // @ts-expect-error\n filtered_extra.push(i)\n }\n // @ts-expect-error\n for (const extraItem of filtered_extra) {\n addResult(extraItem, \"not_in_filter\")\n if (LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit)\n break\n }\n }\n\n function inner_test_filter(\n type: string,\n optsIn?: {\n inTypeOverride?: string | boolean\n outTypeOverride?: string | boolean\n skipFilter?: boolean\n },\n ): boolean {\n optsIn = optsIn || {}\n const optsDef = {\n skipFilter: false,\n inTypeOverride: false,\n outTypeOverride: false,\n }\n const opts = Object.assign(optsDef, optsIn)\n const ctor = LiteGraph.registered_node_types[type]\n if (filter && ctor.filter != filter) return false\n if (\n (!options.show_all_if_empty || str) &&\n !type.toLowerCase().includes(str) &&\n (!ctor.title || !ctor.title.toLowerCase().includes(str))\n ) {\n return false\n }\n\n // filter by slot IN, OUT types\n if (options.do_type_filter && !opts.skipFilter) {\n const sType = type\n\n let sV = opts.inTypeOverride !== false\n ? opts.inTypeOverride\n : sIn.value\n // type is stored\n if (sIn && sV && LiteGraph.registered_slot_in_types[sV]?.nodes) {\n const doesInc = LiteGraph.registered_slot_in_types[sV].nodes.includes(sType)\n if (doesInc === false) return false\n }\n\n sV = sOut.value\n if (opts.outTypeOverride !== false) sV = opts.outTypeOverride\n // type is stored\n if (sOut && sV && LiteGraph.registered_slot_out_types[sV]?.nodes) {\n const doesInc = LiteGraph.registered_slot_out_types[sV].nodes.includes(sType)\n if (doesInc === false) return false\n }\n }\n return true\n }\n }\n\n function addResult(type: string, className?: string): void {\n const help = document.createElement(\"div\")\n first ||= type\n\n const nodeType = LiteGraph.registered_node_types[type]\n if (nodeType?.title) {\n help.textContent = nodeType?.title\n const typeEl = document.createElement(\"span\")\n typeEl.className = \"litegraph lite-search-item-type\"\n typeEl.textContent = type\n help.append(typeEl)\n } else {\n help.textContent = type\n }\n\n help.dataset[\"type\"] = escape(type)\n help.className = \"litegraph lite-search-item\"\n if (className) {\n help.className += ` ${className}`\n }\n help.addEventListener(\"click\", function () {\n select(unescape(String(this.dataset[\"type\"])))\n })\n helper.append(help)\n }\n }\n\n return dialog\n }\n\n showEditPropertyValue(\n node: LGraphNode,\n property: string,\n options: IDialogOptions,\n ): IDialog | undefined {\n if (!node || node.properties[property] === undefined) return\n\n options = options || {}\n\n const info = node.getPropertyInfo(property)\n const { type } = info\n\n let input_html = \"\"\n\n if (\n type == \"string\" ||\n type == \"number\" ||\n type == \"array\" ||\n type == \"object\"\n ) {\n input_html = \"<input autofocus type='text' class='value'/>\"\n } else if ((type == \"enum\" || type == \"combo\") && info.values) {\n input_html = \"<select autofocus type='text' class='value'>\"\n for (const i in info.values) {\n const v = Array.isArray(info.values) ? info.values[i] : i\n\n const selected = v == node.properties[property] ? \"selected\" : \"\"\n input_html += `<option value='${v}' ${selected}>${info.values[i]}</option>`\n }\n input_html += \"</select>\"\n } else if (type == \"boolean\" || type == \"toggle\") {\n const checked = node.properties[property] ? \"checked\" : \"\"\n input_html = `<input autofocus type='checkbox' class='value' ${checked}/>`\n } else {\n console.warn(`unknown type: ${type}`)\n return\n }\n\n const dialog = this.createDialog(\n `<span class='name'>${info.label || property}</span>${input_html}<button>OK</button>`,\n options,\n )\n\n let input: HTMLInputElement | HTMLSelectElement | null\n if ((type == \"enum\" || type == \"combo\") && info.values) {\n input = dialog.querySelector(\"select\")\n input?.addEventListener(\"change\", function (e) {\n dialog.modified()\n setValue((e.target as HTMLSelectElement)?.value)\n })\n } else if (type == \"boolean\" || type == \"toggle\") {\n input = dialog.querySelector(\"input\")\n input?.addEventListener(\"click\", function () {\n dialog.modified()\n // @ts-expect-error\n setValue(!!input.checked)\n })\n } else {\n input = dialog.querySelector(\"input\")\n if (input) {\n input.addEventListener(\"blur\", function () {\n this.focus()\n })\n\n let v = node.properties[property] !== undefined\n ? node.properties[property]\n : \"\"\n if (type !== \"string\") {\n v = JSON.stringify(v)\n }\n\n // @ts-expect-error\n input.value = v\n input.addEventListener(\"keydown\", function (e) {\n if (e.key == \"Escape\") {\n // ESC\n dialog.close()\n } else if (e.key == \"Enter\") {\n // ENTER\n // save\n inner()\n } else {\n dialog.modified()\n return\n }\n e.preventDefault()\n e.stopPropagation()\n })\n }\n }\n input?.focus()\n\n const button = dialog.querySelector(\"button\")\n if (!button) throw new TypeError(\"Show edit property value button was null.\")\n button.addEventListener(\"click\", inner)\n\n function inner() {\n setValue(input?.value)\n }\n const dirty = () => this.#dirty()\n\n function setValue(value: string | number | undefined) {\n if (\n info?.values &&\n typeof info.values === \"object\" &&\n info.values[value] != undefined\n ) {\n value = info.values[value]\n }\n\n if (typeof node.properties[property] == \"number\") {\n value = Number(value)\n }\n if (type == \"array\" || type == \"object\") {\n // @ts-expect-error JSON.parse doesn't care.\n value = JSON.parse(value)\n }\n node.properties[property] = value\n if (node.graph) {\n node.graph._version++\n }\n node.onPropertyChanged?.(property, value)\n options.onclose?.()\n dialog.close()\n dirty()\n }\n\n return dialog\n }\n\n // TODO refactor, theer are different dialog, some uses createDialog, some dont\n createDialog(html: string, options: IDialogOptions): IDialog {\n const def_options = {\n checkForInput: false,\n closeOnLeave: true,\n closeOnLeave_checkModified: true,\n }\n options = Object.assign(def_options, options || {})\n\n const customProperties = {\n className: \"graphdialog\",\n innerHTML: html,\n is_modified: false,\n modified() {\n this.is_modified = true\n },\n close(this: IDialog) {\n this.remove()\n },\n } satisfies Partial<IDialog>\n\n const div = document.createElement(\"div\")\n const dialog: IDialog = Object.assign(div, customProperties)\n\n const rect = this.canvas.getBoundingClientRect()\n let offsetx = -20\n let offsety = -20\n if (rect) {\n offsetx -= rect.left\n offsety -= rect.top\n }\n\n if (options.position) {\n offsetx += options.position[0]\n offsety += options.position[1]\n } else if (options.event) {\n offsetx += options.event.clientX\n offsety += options.event.clientY\n } else {\n // centered\n offsetx += this.canvas.width * 0.5\n offsety += this.canvas.height * 0.5\n }\n\n dialog.style.left = `${offsetx}px`\n dialog.style.top = `${offsety}px`\n\n if (!this.canvas.parentNode) throw new TypeError(\"Canvas parent element was null.\")\n this.canvas.parentNode.append(dialog)\n\n // acheck for input and use default behaviour: save on enter, close on esc\n if (options.checkForInput) {\n const aI = dialog.querySelectorAll(\"input\")\n if (aI) {\n for (const iX of aI) {\n iX.addEventListener(\"keydown\", function (e) {\n dialog.modified()\n if (e.key == \"Escape\") {\n dialog.close()\n } else if (e.key != \"Enter\") {\n return\n }\n e.preventDefault()\n e.stopPropagation()\n })\n iX.focus()\n }\n }\n }\n\n let dialogCloseTimer: number\n let prevent_timeout = 0\n dialog.addEventListener(\"mouseleave\", function () {\n if (prevent_timeout) return\n\n if (!dialog.is_modified && LiteGraph.dialog_close_on_mouse_leave) {\n dialogCloseTimer = setTimeout(\n dialog.close,\n LiteGraph.dialog_close_on_mouse_leave_delay,\n )\n }\n })\n dialog.addEventListener(\"mouseenter\", function () {\n if (options.closeOnLeave || LiteGraph.dialog_close_on_mouse_leave) {\n if (dialogCloseTimer) clearTimeout(dialogCloseTimer)\n }\n })\n const selInDia = dialog.querySelectorAll(\"select\")\n // if filtering, check focus changed to comboboxes and prevent closing\n if (selInDia) {\n for (const selIn of selInDia) {\n selIn.addEventListener(\"click\", function () {\n prevent_timeout++\n })\n selIn.addEventListener(\"blur\", function () {\n prevent_timeout = 0\n })\n selIn.addEventListener(\"change\", function () {\n prevent_timeout = -1\n })\n }\n }\n\n return dialog\n }\n\n createPanel(title: string, options: ICreatePanelOptions) {\n options = options || {}\n\n const ref_window = options.window || window\n // TODO: any kludge\n const root: any = document.createElement(\"div\")\n root.className = \"litegraph dialog\"\n root.innerHTML = \"<div class='dialog-header'><span class='dialog-title'></span></div><div class='dialog-content'></div><div style='display:none;' class='dialog-alt-content'></div><div class='dialog-footer'></div>\"\n root.header = root.querySelector(\".dialog-header\")\n\n if (options.width)\n root.style.width = options.width + (typeof options.width === \"number\" ? \"px\" : \"\")\n if (options.height)\n root.style.height = options.height + (typeof options.height === \"number\" ? \"px\" : \"\")\n if (options.closable) {\n const close = document.createElement(\"span\")\n close.innerHTML = \"&#10005;\"\n close.classList.add(\"close\")\n close.addEventListener(\"click\", function () {\n root.close()\n })\n root.header.append(close)\n }\n root.title_element = root.querySelector(\".dialog-title\")\n root.title_element.textContent = title\n root.content = root.querySelector(\".dialog-content\")\n root.alt_content = root.querySelector(\".dialog-alt-content\")\n root.footer = root.querySelector(\".dialog-footer\")\n\n root.close = function () {\n if (typeof root.onClose == \"function\") root.onClose()\n root.remove()\n this.remove()\n }\n\n // function to swap panel content\n root.toggleAltContent = function (force: unknown) {\n let vTo: string\n let vAlt: string\n if (force !== undefined) {\n vTo = force ? \"block\" : \"none\"\n vAlt = force ? \"none\" : \"block\"\n } else {\n vTo = root.alt_content.style.display != \"block\" ? \"block\" : \"none\"\n vAlt = root.alt_content.style.display != \"block\" ? \"none\" : \"block\"\n }\n root.alt_content.style.display = vTo\n root.content.style.display = vAlt\n }\n\n root.toggleFooterVisibility = function (force: unknown) {\n let vTo: string\n if (force !== undefined) {\n vTo = force ? \"block\" : \"none\"\n } else {\n vTo = root.footer.style.display != \"block\" ? \"block\" : \"none\"\n }\n root.footer.style.display = vTo\n }\n\n root.clear = function () {\n this.content.innerHTML = \"\"\n }\n\n root.addHTML = function (code: string, classname: string, on_footer: any) {\n const elem = document.createElement(\"div\")\n if (classname) elem.className = classname\n elem.innerHTML = code\n if (on_footer) root.footer.append(elem)\n else root.content.append(elem)\n return elem\n }\n\n root.addButton = function (name: any, callback: any, options: any) {\n // TODO: any kludge\n const elem: any = document.createElement(\"button\")\n elem.textContent = name\n elem.options = options\n elem.classList.add(\"btn\")\n elem.addEventListener(\"click\", callback)\n root.footer.append(elem)\n return elem\n }\n\n root.addSeparator = function () {\n const elem = document.createElement(\"div\")\n elem.className = \"separator\"\n root.content.append(elem)\n }\n\n root.addWidget = function (type: string, name: any, value: unknown, options: { label?: any, type?: any, values?: any, callback?: any }, callback: (arg0: any, arg1: any, arg2: any) => void) {\n options = options || {}\n let str_value = String(value)\n type = type.toLowerCase()\n if (type == \"number\" && typeof value === \"number\") str_value = value.toFixed(3)\n\n // FIXME: any kludge\n const elem: HTMLDivElement & { options?: unknown, value?: unknown } = document.createElement(\"div\")\n elem.className = \"property\"\n elem.innerHTML = \"<span class='property_name'></span><span class='property_value'></span>\"\n const nameSpan = elem.querySelector(\".property_name\")\n if (!nameSpan) throw new TypeError(\"Property name element was null.\")\n\n nameSpan.textContent = options.label || name\n // TODO: any kludge\n const value_element: HTMLSpanElement | null = elem.querySelector(\".property_value\")\n if (!value_element) throw new TypeError(\"Property name element was null.\")\n value_element.textContent = str_value\n elem.dataset[\"property\"] = name\n elem.dataset[\"type\"] = options.type || type\n elem.options = options\n elem.value = value\n\n if (type == \"code\") {\n elem.addEventListener(\"click\", function () {\n root.inner_showCodePad(this.dataset[\"property\"])\n })\n } else if (type == \"boolean\") {\n elem.classList.add(\"boolean\")\n if (value) elem.classList.add(\"bool-on\")\n elem.addEventListener(\"click\", () => {\n const propname = elem.dataset[\"property\"]\n elem.value = !elem.value\n elem.classList.toggle(\"bool-on\")\n if (!value_element) throw new TypeError(\"Property name element was null.\")\n\n value_element.textContent = elem.value\n ? \"true\"\n : \"false\"\n innerChange(propname, elem.value)\n })\n } else if (type == \"string\" || type == \"number\") {\n if (!value_element) throw new TypeError(\"Property name element was null.\")\n value_element.setAttribute(\"contenteditable\", \"true\")\n value_element.addEventListener(\"keydown\", function (e) {\n // allow for multiline\n if (e.code == \"Enter\" && (type != \"string\" || !e.shiftKey)) {\n e.preventDefault()\n this.blur()\n }\n })\n value_element.addEventListener(\"blur\", function () {\n let v: string | number | null = this.textContent\n const propname = this.parentElement?.dataset[\"property\"]\n const proptype = this.parentElement?.dataset[\"type\"]\n if (proptype == \"number\") v = Number(v)\n innerChange(propname, v)\n })\n } else if (type == \"enum\" || type == \"combo\") {\n const str_value = LGraphCanvas.getPropertyPrintableValue(value, options.values)\n if (!value_element) throw new TypeError(\"Property name element was null.\")\n value_element.textContent = str_value ?? \"\"\n\n value_element.addEventListener(\"click\", function (event) {\n const values = options.values || []\n const propname = this.parentElement?.dataset[\"property\"]\n const inner_clicked = (v: string | null) => {\n // node.setProperty(propname,v);\n // graphcanvas.dirty_canvas = true;\n this.textContent = v\n innerChange(propname, v)\n return false\n }\n new LiteGraph.ContextMenu(\n values,\n {\n event,\n className: \"dark\",\n callback: inner_clicked,\n },\n // @ts-expect-error\n ref_window,\n )\n })\n }\n\n root.content.append(elem)\n\n function innerChange(name: string | undefined, value: unknown) {\n options.callback?.(name, value, options)\n callback?.(name, value, options)\n }\n\n return elem\n }\n\n if (typeof root.onOpen == \"function\") root.onOpen()\n\n return root\n }\n\n closePanels(): void {\n type MightHaveClose = HTMLDivElement & Partial<ICloseable>\n document.querySelector<MightHaveClose>(\"#node-panel\")?.close?.()\n document.querySelector<MightHaveClose>(\"#option-panel\")?.close?.()\n }\n\n showShowNodePanel(node: LGraphNode): void {\n this.SELECTED_NODE = node\n this.closePanels()\n const ref_window = this.getCanvasWindow()\n const panel = this.createPanel(node.title || \"\", {\n closable: true,\n window: ref_window,\n onOpen: () => {\n this.NODEPANEL_IS_OPEN = true\n },\n onClose: () => {\n this.NODEPANEL_IS_OPEN = false\n this.node_panel = null\n },\n })\n this.node_panel = panel\n panel.id = \"node-panel\"\n panel.node = node\n panel.classList.add(\"settings\")\n\n const inner_refresh = () => {\n // clear\n panel.content.innerHTML = \"\"\n // @ts-expect-error ctor props\n panel.addHTML(`<span class='node_type'>${node.type}</span><span class='node_desc'>${node.constructor.desc || \"\"}</span><span class='separator'></span>`)\n\n panel.addHTML(\"<h3>Properties</h3>\")\n\n const fUpdate = (name: string, value: string | number | boolean | object | undefined) => {\n if (!this.graph) throw new NullGraphError()\n this.graph.beforeChange(node)\n switch (name) {\n case \"Title\":\n if (typeof value !== \"string\") throw new TypeError(\"Attempting to set title to non-string value.\")\n\n node.title = value\n break\n case \"Mode\": {\n if (typeof value !== \"string\") throw new TypeError(\"Attempting to set mode to non-string value.\")\n\n const kV = Object.values(LiteGraph.NODE_MODES).indexOf(value)\n if (kV !== -1 && LiteGraph.NODE_MODES[kV]) {\n node.changeMode(kV)\n } else {\n console.warn(`unexpected mode: ${value}`)\n }\n break\n }\n case \"Color\":\n if (typeof value !== \"string\") throw new TypeError(\"Attempting to set colour to non-string value.\")\n\n if (LGraphCanvas.node_colors[value]) {\n node.color = LGraphCanvas.node_colors[value].color\n node.bgcolor = LGraphCanvas.node_colors[value].bgcolor\n } else {\n console.warn(`unexpected color: ${value}`)\n }\n break\n default:\n node.setProperty(name, value)\n break\n }\n this.graph.afterChange()\n this.dirty_canvas = true\n }\n\n panel.addWidget(\"string\", \"Title\", node.title, {}, fUpdate)\n\n const mode = node.mode == null ? undefined : LiteGraph.NODE_MODES[node.mode]\n panel.addWidget(\"combo\", \"Mode\", mode, { values: LiteGraph.NODE_MODES }, fUpdate)\n\n const nodeCol = node.color !== undefined\n ? Object.keys(LGraphCanvas.node_colors).filter(function (nK) { return LGraphCanvas.node_colors[nK].color == node.color })\n : \"\"\n\n panel.addWidget(\"combo\", \"Color\", nodeCol, { values: Object.keys(LGraphCanvas.node_colors) }, fUpdate)\n\n for (const pName in node.properties) {\n const value = node.properties[pName]\n const info = node.getPropertyInfo(pName)\n\n // in case the user wants control over the side panel widget\n if (node.onAddPropertyToPanel?.(pName, panel)) continue\n\n panel.addWidget(info.widget || info.type, pName, value, info, fUpdate)\n }\n\n panel.addSeparator()\n\n node.onShowCustomPanelInfo?.(panel)\n\n // clear\n panel.footer.innerHTML = \"\"\n panel.addButton(\"Delete\", function () {\n if (node.block_delete) return\n if (!node.graph) throw new NullGraphError()\n\n node.graph.remove(node)\n panel.close()\n }).classList.add(\"delete\")\n }\n\n panel.inner_showCodePad = function (propname: string) {\n panel.classList.remove(\"settings\")\n panel.classList.add(\"centered\")\n\n panel.alt_content.innerHTML = \"<textarea class='code'></textarea>\"\n const textarea: HTMLTextAreaElement = panel.alt_content.querySelector(\"textarea\")\n const fDoneWith = function () {\n panel.toggleAltContent(false)\n panel.toggleFooterVisibility(true)\n textarea.remove()\n panel.classList.add(\"settings\")\n panel.classList.remove(\"centered\")\n inner_refresh()\n }\n textarea.value = String(node.properties[propname])\n textarea.addEventListener(\"keydown\", function (e: KeyboardEvent) {\n if (e.code == \"Enter\" && e.ctrlKey) {\n node.setProperty(propname, textarea.value)\n fDoneWith()\n }\n })\n panel.toggleAltContent(true)\n panel.toggleFooterVisibility(false)\n textarea.style.height = \"calc(100% - 40px)\"\n\n const assign = panel.addButton(\"Assign\", function () {\n node.setProperty(propname, textarea.value)\n fDoneWith()\n })\n panel.alt_content.append(assign)\n const button = panel.addButton(\"Close\", fDoneWith)\n button.style.float = \"right\"\n panel.alt_content.append(button)\n }\n\n inner_refresh()\n\n if (!this.canvas.parentNode) throw new TypeError(\"showNodePanel - this.canvas.parentNode was null\")\n this.canvas.parentNode.append(panel)\n }\n\n checkPanels(): void {\n if (!this.canvas) return\n\n if (!this.canvas.parentNode) throw new TypeError(\"checkPanels - this.canvas.parentNode was null\")\n const panels = this.canvas.parentNode.querySelectorAll(\".litegraph.dialog\")\n for (const panel of panels) {\n // @ts-expect-error Panel\n if (!panel.node) continue\n // @ts-expect-error Panel\n if (!panel.node.graph || panel.graph != this.graph) panel.close()\n }\n }\n\n getCanvasMenuOptions(): IContextMenuValue<string>[] {\n let options: IContextMenuValue<string>[]\n if (this.getMenuOptions) {\n options = this.getMenuOptions()\n } else {\n options = [\n {\n content: \"Add Node\",\n has_submenu: true,\n callback: LGraphCanvas.onMenuAdd,\n },\n { content: \"Add Group\", callback: LGraphCanvas.onGroupAdd },\n // { content: \"Arrange\", callback: that.graph.arrange },\n // {content:\"Collapse All\", callback: LGraphCanvas.onMenuCollapseAll }\n ]\n if (Object.keys(this.selected_nodes).length > 1) {\n options.push({\n content: \"Convert to Subgraph 🆕\",\n callback: () => {\n if (!this.selectedItems.size) throw new Error(\"Convert to Subgraph: Nothing selected.\")\n this._graph.convertToSubgraph(this.selectedItems)\n },\n }, {\n content: \"Align\",\n has_submenu: true,\n callback: LGraphCanvas.onGroupAlign,\n })\n }\n }\n\n const extra = this.getExtraMenuOptions?.(this, options)\n return Array.isArray(extra)\n ? options.concat(extra)\n : options\n }\n\n // called by processContextMenu to extract the menu list\n getNodeMenuOptions(node: LGraphNode) {\n let options: (IContextMenuValue<string> | IContextMenuValue<string | null> | IContextMenuValue<INodeSlotContextItem> | IContextMenuValue<unknown, LGraphNode> | IContextMenuValue<typeof LiteGraph.VALID_SHAPES[number]> | null)[]\n\n if (node.getMenuOptions) {\n options = node.getMenuOptions(this)\n } else {\n options = [\n {\n content: \"Inputs\",\n has_submenu: true,\n disabled: true,\n },\n {\n content: \"Outputs\",\n has_submenu: true,\n disabled: true,\n callback: LGraphCanvas.showMenuNodeOptionalOutputs,\n },\n null,\n {\n content: \"Convert to Subgraph 🆕\",\n callback: () => {\n if (!this.selectedItems.size) throw new Error(\"Convert to Subgraph: Nothing selected.\")\n this._graph.convertToSubgraph(this.selectedItems)\n },\n },\n {\n content: \"Properties\",\n has_submenu: true,\n callback: LGraphCanvas.onShowMenuNodeProperties,\n },\n {\n content: \"Properties Panel\",\n callback: function (item: any, options: any, e: any, menu: any, node: LGraphNode) { LGraphCanvas.active_canvas.showShowNodePanel(node) },\n },\n null,\n {\n content: \"Title\",\n callback: LGraphCanvas.onShowPropertyEditor,\n },\n {\n content: \"Mode\",\n has_submenu: true,\n callback: LGraphCanvas.onMenuNodeMode,\n },\n ]\n if (node.resizable !== false) {\n options.push({\n content: \"Resize\",\n callback: LGraphCanvas.onMenuResizeNode,\n })\n }\n if (node.collapsible) {\n options.push({\n content: node.collapsed ? \"Expand\" : \"Collapse\",\n callback: LGraphCanvas.onMenuNodeCollapse,\n })\n }\n if (node.widgets?.some(w => w.advanced)) {\n options.push({\n content: node.showAdvanced ? \"Hide Advanced\" : \"Show Advanced\",\n callback: LGraphCanvas.onMenuToggleAdvanced,\n })\n }\n options.push(\n {\n content: node.pinned ? \"Unpin\" : \"Pin\",\n callback: () => {\n for (const i in this.selected_nodes) {\n const node = this.selected_nodes[i]\n node.pin()\n }\n this.setDirty(true, true)\n },\n },\n {\n content: \"Colors\",\n has_submenu: true,\n callback: LGraphCanvas.onMenuNodeColors,\n },\n {\n content: \"Shapes\",\n has_submenu: true,\n callback: LGraphCanvas.onMenuNodeShapes,\n },\n null,\n )\n }\n\n const extra = node.getExtraMenuOptions?.(this, options)\n if (Array.isArray(extra) && extra.length > 0) {\n extra.push(null)\n options = extra.concat(options)\n }\n\n if (node.clonable !== false) {\n options.push({\n content: \"Clone\",\n callback: LGraphCanvas.onMenuNodeClone,\n })\n }\n\n if (Object.keys(this.selected_nodes).length > 1) {\n options.push({\n content: \"Align Selected To\",\n has_submenu: true,\n callback: LGraphCanvas.onNodeAlign,\n }, {\n content: \"Distribute Nodes\",\n has_submenu: true,\n callback: LGraphCanvas.createDistributeMenu,\n })\n }\n\n options.push(null, {\n content: \"Remove\",\n disabled: !(node.removable !== false && !node.block_delete),\n callback: LGraphCanvas.onMenuNodeRemove,\n })\n\n node.graph?.onGetNodeMenuOptions?.(options, node)\n\n return options\n }\n\n /** @deprecated */\n getGroupMenuOptions(group: LGraphGroup) {\n console.warn(\"LGraphCanvas.getGroupMenuOptions is deprecated, use LGraphGroup.getMenuOptions instead\")\n return group.getMenuOptions()\n }\n\n processContextMenu(node: LGraphNode | undefined, event: CanvasPointerEvent): void {\n const canvas = LGraphCanvas.active_canvas\n const ref_window = canvas.getCanvasWindow()\n\n // TODO: Remove type kludge\n let menu_info: (IContextMenuValue | string | null)[]\n const options: IContextMenuOptions = {\n event,\n callback: inner_option_clicked,\n extra: node,\n }\n\n if (node) {\n options.title = node.displayType ?? node.type ?? undefined\n LGraphCanvas.active_node = node\n\n // check if mouse is in input\n const slot = node.getSlotInPosition(event.canvasX, event.canvasY)\n if (slot) {\n // on slot\n menu_info = []\n if (node.getSlotMenuOptions) {\n menu_info = node.getSlotMenuOptions(slot)\n } else {\n if (slot.output?.links?.length || slot.input?.link != null) {\n menu_info.push({ content: \"Disconnect Links\", slot })\n }\n\n const _slot = slot.input || slot.output\n if (!_slot) throw new TypeError(\"Both in put and output slots were null when processing context menu.\")\n\n if (_slot.removable) {\n menu_info.push(\n _slot.locked\n ? \"Cannot remove\"\n : { content: \"Remove Slot\", slot },\n )\n }\n if (!_slot.nameLocked && !((\"link\" in _slot) && _slot.widget)) {\n menu_info.push({ content: \"Rename Slot\", slot })\n }\n\n if (node.getExtraSlotMenuOptions) {\n menu_info.push(...node.getExtraSlotMenuOptions(slot))\n }\n }\n // @ts-expect-error Slot type can be number and has number checks\n options.title = (slot.input ? slot.input.type : slot.output.type) || \"*\"\n if (slot.input && slot.input.type == LiteGraph.ACTION)\n options.title = \"Action\"\n\n if (slot.output && slot.output.type == LiteGraph.EVENT)\n options.title = \"Event\"\n } else {\n // on node\n menu_info = this.getNodeMenuOptions(node)\n }\n } else {\n menu_info = this.getCanvasMenuOptions()\n if (!this.graph) throw new NullGraphError()\n\n // Check for reroutes\n if (this.links_render_mode !== LinkRenderType.HIDDEN_LINK) {\n const reroute = this.graph.getRerouteOnPos(event.canvasX, event.canvasY, this.#visibleReroutes)\n if (reroute) {\n menu_info.unshift({\n content: \"Delete Reroute\",\n callback: () => {\n if (!this.graph) throw new NullGraphError()\n\n this.graph.removeReroute(reroute.id)\n },\n }, null)\n }\n }\n\n const group = this.graph.getGroupOnPos(\n event.canvasX,\n event.canvasY,\n )\n if (group) {\n // on group\n menu_info.push(null, {\n content: \"Edit Group\",\n has_submenu: true,\n submenu: {\n title: \"Group\",\n extra: group,\n options: group.getMenuOptions(),\n },\n })\n }\n }\n\n // show menu\n if (!menu_info) return\n\n // @ts-expect-error Remove param ref_window - unused\n new LiteGraph.ContextMenu(menu_info, options, ref_window)\n\n const createDialog = (options: IDialogOptions) => this.createDialog(\n \"<span class='name'>Name</span><input autofocus type='text'/><button>OK</button>\",\n options,\n )\n const setDirty = () => this.setDirty(true)\n\n function inner_option_clicked(v: IContextMenuValue<unknown>, options: IDialogOptions) {\n if (!v) return\n\n if (v.content == \"Remove Slot\") {\n if (!node?.graph) throw new NullGraphError()\n\n const info = v.slot\n if (!info) throw new TypeError(\"Found-slot info was null when processing context menu.\")\n\n node.graph.beforeChange()\n if (info.input) {\n node.removeInput(info.slot)\n } else if (info.output) {\n node.removeOutput(info.slot)\n }\n node.graph.afterChange()\n return\n } else if (v.content == \"Disconnect Links\") {\n if (!node?.graph) throw new NullGraphError()\n\n const info = v.slot\n if (!info) throw new TypeError(\"Found-slot info was null when processing context menu.\")\n\n node.graph.beforeChange()\n if (info.output) {\n node.disconnectOutput(info.slot)\n } else if (info.input) {\n node.disconnectInput(info.slot, true)\n }\n node.graph.afterChange()\n return\n } else if (v.content == \"Rename Slot\") {\n if (!node) throw new TypeError(\"`node` was null when processing the context menu.\")\n\n const info = v.slot\n if (!info) throw new TypeError(\"Found-slot info was null when processing context menu.\")\n\n const slot_info = info.input\n ? node.getInputInfo(info.slot)\n : node.getOutputInfo(info.slot)\n const dialog = createDialog(options)\n\n const input = dialog.querySelector(\"input\")\n if (input && slot_info) {\n input.value = slot_info.label || \"\"\n }\n const inner = function () {\n if (!node.graph) throw new NullGraphError()\n\n node.graph.beforeChange()\n if (input?.value) {\n if (slot_info) {\n slot_info.label = input.value\n }\n setDirty()\n }\n dialog.close()\n node.graph.afterChange()\n }\n dialog.querySelector(\"button\")?.addEventListener(\"click\", inner)\n if (!input) throw new TypeError(\"Input element was null when processing context menu.\")\n\n input.addEventListener(\"keydown\", function (e) {\n dialog.is_modified = true\n if (e.key == \"Escape\") {\n // ESC\n dialog.close()\n } else if (e.key == \"Enter\") {\n // save\n inner()\n } else if ((e.target as Element).localName != \"textarea\") {\n return\n }\n e.preventDefault()\n e.stopPropagation()\n })\n input.focus()\n }\n }\n }\n\n /**\n * Starts an animation to fit the view around the specified selection of nodes.\n * @param bounds The bounds to animate the view to, defined by a rectangle.\n */\n animateToBounds(bounds: ReadOnlyRect, options: AnimationOptions = {}) {\n const setDirty = () => this.setDirty(true, true)\n this.ds.animateToBounds(bounds, setDirty, options)\n }\n\n /**\n * Fits the view to the selected nodes with animation.\n * If nothing is selected, the view is fitted around all items in the graph.\n */\n fitViewToSelectionAnimated(options: AnimationOptions = {}) {\n const items = this.selectedItems.size\n ? Array.from(this.selectedItems)\n : this.positionableItems\n const bounds = createBounds(items)\n if (!bounds) throw new TypeError(\"Attempted to fit to view but could not calculate bounds.\")\n\n const setDirty = () => this.setDirty(true, true)\n this.ds.animateToBounds(bounds, setDirty, options)\n }\n}\n","/**\n * Temporary workaround until downstream consumers migrate to Map.\n * A brittle wrapper with many flaws, but should be fine for simple maps using int indexes.\n */\nexport class MapProxyHandler<V> implements ProxyHandler<Map<number | string, V>> {\n getOwnPropertyDescriptor(\n target: Map<number | string, V>,\n p: string | symbol,\n ): PropertyDescriptor | undefined {\n const value = this.get(target, p)\n if (value) {\n return {\n configurable: true,\n enumerable: true,\n value,\n }\n }\n }\n\n has(target: Map<number | string, V>, p: string | symbol): boolean {\n if (typeof p === \"symbol\") return false\n\n const int = parseInt(p, 10)\n return target.has(!isNaN(int) ? int : p)\n }\n\n ownKeys(target: Map<number | string, V>): ArrayLike<string | symbol> {\n return [...target.keys()].map(String)\n }\n\n get(target: Map<number | string, V>, p: string | symbol): any {\n // Workaround does not support link IDs of \"values\", \"entries\", \"constructor\", etc.\n if (p in target) return Reflect.get(target, p, target)\n if (typeof p === \"symbol\") return\n\n const int = parseInt(p, 10)\n return target.get(!isNaN(int) ? int : p)\n }\n\n set(target: Map<number | string, V>, p: string | symbol, newValue: any): boolean {\n if (typeof p === \"symbol\") return false\n\n const int = parseInt(p, 10)\n target.set(!isNaN(int) ? int : p, newValue)\n return true\n }\n\n deleteProperty(target: Map<number | string, V>, p: string | symbol): boolean {\n return target.delete(p as number | string)\n }\n\n static bindAllMethods(map: Map<any, any>): void {\n map.clear = map.clear.bind(map)\n map.delete = map.delete.bind(map)\n map.forEach = map.forEach.bind(map)\n map.get = map.get.bind(map)\n map.has = map.has.bind(map)\n map.set = map.set.bind(map)\n map.entries = map.entries.bind(map)\n map.keys = map.keys.bind(map)\n map.values = map.values.bind(map)\n\n map[Symbol.iterator] = map[Symbol.iterator].bind(map)\n }\n}\n","import type { DragAndScaleState } from \"./DragAndScale\"\nimport type { LGraphEventMap } from \"./infrastructure/LGraphEventMap\"\nimport type {\n Dictionary,\n IContextMenuValue,\n LinkNetwork,\n LinkSegment,\n MethodNames,\n OptionalProps,\n Point,\n Positionable,\n} from \"./interfaces\"\nimport type {\n ExportedSubgraph,\n ISerialisedGraph,\n ISerialisedNode,\n Serialisable,\n SerialisableGraph,\n SerialisableReroute,\n} from \"./types/serialisation\"\nimport type { UUID } from \"@/utils/uuid\"\n\nimport { SUBGRAPH_INPUT_ID, SUBGRAPH_OUTPUT_ID } from \"@/constants\"\nimport { createUuidv4, zeroUuid } from \"@/utils/uuid\"\n\nimport { CustomEventTarget } from \"./infrastructure/CustomEventTarget\"\nimport { LGraphCanvas } from \"./LGraphCanvas\"\nimport { LGraphGroup } from \"./LGraphGroup\"\nimport { LGraphNode, type NodeId } from \"./LGraphNode\"\nimport { LiteGraph, SubgraphNode } from \"./litegraph\"\nimport { type LinkId, LLink } from \"./LLink\"\nimport { MapProxyHandler } from \"./MapProxyHandler\"\nimport { alignOutsideContainer, alignToContainer, createBounds } from \"./measure\"\nimport { Reroute, type RerouteId } from \"./Reroute\"\nimport { stringOrEmpty } from \"./strings\"\nimport { type GraphOrSubgraph, Subgraph } from \"./subgraph/Subgraph\"\nimport { SubgraphInput } from \"./subgraph/SubgraphInput\"\nimport { SubgraphOutput } from \"./subgraph/SubgraphOutput\"\nimport { findUsedSubgraphIds, getBoundaryLinks, groupResolvedByOutput, mapSubgraphInputsAndLinks, mapSubgraphOutputsAndLinks, multiClone, splitPositionables } from \"./subgraph/subgraphUtils\"\nimport { Alignment, LGraphEventMode } from \"./types/globalEnums\"\nimport { getAllNestedItems } from \"./utils/collections\"\n\nexport interface LGraphState {\n lastGroupId: number\n lastNodeId: number\n lastLinkId: number\n lastRerouteId: number\n}\n\ntype ParamsArray<T extends Record<any, any>, K extends MethodNames<T>> =\n Parameters<T[K]>[1] extends undefined\n ? Parameters<T[K]> | Parameters<T[K]>[0]\n : Parameters<T[K]>\n\n/** Configuration used by {@link LGraph} `config`. */\nexport interface LGraphConfig {\n /** @deprecated Legacy config - unused */\n align_to_grid?: any\n links_ontop?: any\n}\n\nexport interface LGraphExtra extends Dictionary<unknown> {\n reroutes?: SerialisableReroute[]\n linkExtensions?: { id: number, parentId: number | undefined }[]\n ds?: DragAndScaleState\n}\n\nexport interface BaseLGraph {\n /** The root graph. */\n readonly rootGraph: LGraph\n}\n\n/**\n * LGraph is the class that contain a full graph. We instantiate one and add nodes to it, and then we can run the execution loop.\n * supported callbacks:\n * + onNodeAdded: when a new node is added to the graph\n * + onNodeRemoved: when a node inside this graph is removed\n */\nexport class LGraph implements LinkNetwork, BaseLGraph, Serialisable<SerialisableGraph> {\n static serialisedSchemaVersion = 1 as const\n\n static STATUS_STOPPED = 1\n static STATUS_RUNNING = 2\n\n /** List of LGraph properties that are manually handled by {@link LGraph.configure}. */\n static readonly ConfigureProperties = new Set([\n \"nodes\",\n \"groups\",\n \"links\",\n \"state\",\n \"reroutes\",\n \"floatingLinks\",\n \"id\",\n \"subgraphs\",\n \"definitions\",\n \"inputs\",\n \"outputs\",\n \"widgets\",\n \"inputNode\",\n \"outputNode\",\n \"extra\",\n ])\n\n id: UUID = zeroUuid\n revision: number = 0\n\n _version: number = -1\n /** The backing store for links. Keys are wrapped in String() */\n _links: Map<LinkId, LLink> = new Map()\n /**\n * Indexed property access is deprecated.\n * Backwards compatibility with a Proxy has been added, but will eventually be removed.\n *\n * Use {@link Map} methods:\n * ```\n * const linkId = 123\n * const link = graph.links.get(linkId)\n * // Deprecated: const link = graph.links[linkId]\n * ```\n */\n links: Map<LinkId, LLink> & Record<LinkId, LLink>\n list_of_graphcanvas: LGraphCanvas[] | null\n status: number = LGraph.STATUS_STOPPED\n\n state: LGraphState = {\n lastGroupId: 0,\n lastNodeId: 0,\n lastLinkId: 0,\n lastRerouteId: 0,\n }\n\n readonly events = new CustomEventTarget<LGraphEventMap>()\n readonly _subgraphs: Map<UUID, Subgraph> = new Map()\n\n _nodes: (LGraphNode | SubgraphNode)[] = []\n _nodes_by_id: Record<NodeId, LGraphNode> = {}\n _nodes_in_order: LGraphNode[] = []\n _nodes_executable: LGraphNode[] | null = null\n _groups: LGraphGroup[] = []\n iteration: number = 0\n globaltime: number = 0\n /** @deprecated Unused */\n runningtime: number = 0\n fixedtime: number = 0\n fixedtime_lapse: number = 0.01\n elapsed_time: number = 0.01\n last_update_time: number = 0\n starttime: number = 0\n catch_errors: boolean = true\n execution_timer_id?: number | null\n errors_in_execution?: boolean\n /** @deprecated Unused */\n execution_time!: number\n _last_trigger_time?: number\n filter?: string\n /** Must contain serialisable values, e.g. primitive types */\n config: LGraphConfig = {}\n vars: Dictionary<unknown> = {}\n nodes_executing: boolean[] = []\n nodes_actioning: (string | boolean)[] = []\n nodes_executedAction: string[] = []\n extra: LGraphExtra = {}\n\n /** @deprecated Deserialising a workflow sets this unused property. */\n version?: number\n\n /** @returns Whether the graph has no items */\n get empty(): boolean {\n return this._nodes.length + this._groups.length + this.reroutes.size === 0\n }\n\n /** @returns All items on the canvas that can be selected */\n *positionableItems(): Generator<LGraphNode | LGraphGroup | Reroute> {\n for (const node of this._nodes) yield node\n for (const group of this._groups) yield group\n for (const reroute of this.reroutes.values()) yield reroute\n return\n }\n\n /** Internal only. Not required for serialisation; calculated on deserialise. */\n #lastFloatingLinkId: number = 0\n\n #floatingLinks: Map<LinkId, LLink> = new Map()\n get floatingLinks(): ReadonlyMap<LinkId, LLink> {\n return this.#floatingLinks\n }\n\n #reroutes = new Map<RerouteId, Reroute>()\n /** All reroutes in this graph. */\n public get reroutes(): Map<RerouteId, Reroute> {\n return this.#reroutes\n }\n\n get rootGraph(): LGraph {\n return this\n }\n\n get isRootGraph(): boolean {\n return this.rootGraph === this\n }\n\n /** @deprecated See {@link state}.{@link LGraphState.lastNodeId lastNodeId} */\n get last_node_id() {\n return this.state.lastNodeId\n }\n\n set last_node_id(value) {\n this.state.lastNodeId = value\n }\n\n /** @deprecated See {@link state}.{@link LGraphState.lastLinkId lastLinkId} */\n get last_link_id() {\n return this.state.lastLinkId\n }\n\n set last_link_id(value) {\n this.state.lastLinkId = value\n }\n\n onAfterStep?(): void\n onBeforeStep?(): void\n onPlayEvent?(): void\n onStopEvent?(): void\n onAfterExecute?(): void\n onExecuteStep?(): void\n onNodeAdded?(node: LGraphNode): void\n onNodeRemoved?(node: LGraphNode): void\n onTrigger?(action: string, param: unknown): void\n onBeforeChange?(graph: LGraph, info?: LGraphNode): void\n onAfterChange?(graph: LGraph, info?: LGraphNode | null): void\n onConnectionChange?(node: LGraphNode): void\n on_change?(graph: LGraph): void\n onSerialize?(data: ISerialisedGraph | SerialisableGraph): void\n onConfigure?(data: ISerialisedGraph | SerialisableGraph): void\n onGetNodeMenuOptions?(options: (IContextMenuValue<unknown> | null)[], node: LGraphNode): void\n\n private _input_nodes?: LGraphNode[]\n\n /**\n * See {@link LGraph}\n * @param o data from previous serialization [optional]\n */\n constructor(o?: ISerialisedGraph | SerialisableGraph) {\n if (LiteGraph.debug) console.log(\"Graph created\")\n\n /** @see MapProxyHandler */\n const links = this._links\n MapProxyHandler.bindAllMethods(links)\n const handler = new MapProxyHandler<LLink>()\n this.links = new Proxy(links, handler) as Map<LinkId, LLink> & Record<LinkId, LLink>\n\n this.list_of_graphcanvas = null\n this.clear()\n\n if (o) this.configure(o)\n }\n\n /**\n * Removes all nodes from this graph\n */\n clear(): void {\n this.stop()\n this.status = LGraph.STATUS_STOPPED\n\n this.id = zeroUuid\n this.revision = 0\n\n this.state = {\n lastGroupId: 0,\n lastNodeId: 0,\n lastLinkId: 0,\n lastRerouteId: 0,\n }\n\n // used to detect changes\n this._version = -1\n this._subgraphs.clear()\n\n // safe clear\n if (this._nodes) {\n for (const _node of this._nodes) {\n _node.onRemoved?.()\n }\n }\n\n // nodes\n this._nodes = []\n this._nodes_by_id = {}\n // nodes sorted in execution order\n this._nodes_in_order = []\n // nodes that contain onExecute sorted in execution order\n this._nodes_executable = null\n\n this._links.clear()\n this.reroutes.clear()\n this.#floatingLinks.clear()\n\n this.#lastFloatingLinkId = 0\n\n // other scene stuff\n this._groups = []\n\n // iterations\n this.iteration = 0\n\n // custom data\n this.config = {}\n this.vars = {}\n // to store custom data\n this.extra = {}\n\n // timing\n this.globaltime = 0\n this.runningtime = 0\n this.fixedtime = 0\n this.fixedtime_lapse = 0.01\n this.elapsed_time = 0.01\n this.last_update_time = 0\n this.starttime = 0\n\n this.catch_errors = true\n\n this.nodes_executing = []\n this.nodes_actioning = []\n this.nodes_executedAction = []\n\n // notify canvas to redraw\n this.change()\n\n this.canvasAction(c => c.clear())\n }\n\n get subgraphs(): Map<UUID, Subgraph> {\n return this.rootGraph._subgraphs\n }\n\n get nodes() {\n return this._nodes\n }\n\n get groups() {\n return this._groups\n }\n\n /**\n * Attach Canvas to this graph\n */\n attachCanvas(canvas: LGraphCanvas): void {\n if (!(canvas instanceof LGraphCanvas)) {\n throw new TypeError(\"attachCanvas expects an LGraphCanvas instance\")\n }\n\n this.primaryCanvas = canvas\n\n this.list_of_graphcanvas ??= []\n if (!this.list_of_graphcanvas.includes(canvas)) {\n this.list_of_graphcanvas.push(canvas)\n }\n\n if (canvas.graph === this) return\n\n canvas.graph?.detachCanvas(canvas)\n canvas.graph = this\n canvas.subgraph = undefined\n }\n\n /**\n * Detach Canvas from this graph\n */\n detachCanvas(canvas: LGraphCanvas): void {\n canvas.graph = null\n const canvases = this.list_of_graphcanvas\n if (canvases) {\n const pos = canvases.indexOf(canvas)\n if (pos !== -1) canvases.splice(pos, 1)\n }\n }\n\n /**\n * @deprecated Will be removed in 0.9\n * Starts running this graph every interval milliseconds.\n * @param interval amount of milliseconds between executions, if 0 then it renders to the monitor refresh rate\n */\n start(interval?: number): void {\n if (this.status == LGraph.STATUS_RUNNING) return\n this.status = LGraph.STATUS_RUNNING\n\n this.onPlayEvent?.()\n this.sendEventToAllNodes(\"onStart\")\n\n // launch\n this.starttime = LiteGraph.getTime()\n this.last_update_time = this.starttime\n interval ||= 0\n\n // execute once per frame\n if (\n interval == 0 &&\n typeof window != \"undefined\" &&\n window.requestAnimationFrame\n ) {\n const on_frame = () => {\n if (this.execution_timer_id != -1) return\n\n window.requestAnimationFrame(on_frame)\n this.onBeforeStep?.()\n this.runStep(1, !this.catch_errors)\n this.onAfterStep?.()\n }\n this.execution_timer_id = -1\n on_frame()\n } else {\n // execute every 'interval' ms\n this.execution_timer_id = setInterval(() => {\n // execute\n this.onBeforeStep?.()\n this.runStep(1, !this.catch_errors)\n this.onAfterStep?.()\n }, interval)\n }\n }\n\n /**\n * @deprecated Will be removed in 0.9\n * Stops the execution loop of the graph\n */\n stop(): void {\n if (this.status == LGraph.STATUS_STOPPED) return\n\n this.status = LGraph.STATUS_STOPPED\n\n this.onStopEvent?.()\n\n if (this.execution_timer_id != null) {\n if (this.execution_timer_id != -1) {\n clearInterval(this.execution_timer_id)\n }\n this.execution_timer_id = null\n }\n\n this.sendEventToAllNodes(\"onStop\")\n }\n\n /**\n * Run N steps (cycles) of the graph\n * @param num number of steps to run, default is 1\n * @param do_not_catch_errors [optional] if you want to try/catch errors\n * @param limit max number of nodes to execute (used to execute from start to a node)\n */\n runStep(num: number, do_not_catch_errors: boolean, limit?: number): void {\n num = num || 1\n\n const start = LiteGraph.getTime()\n this.globaltime = 0.001 * (start - this.starttime)\n\n const nodes = this._nodes_executable || this._nodes\n if (!nodes) return\n\n limit = limit || nodes.length\n\n if (do_not_catch_errors) {\n // iterations\n for (let i = 0; i < num; i++) {\n for (let j = 0; j < limit; ++j) {\n const node = nodes[j]\n // FIXME: Looks like copy/paste broken logic - checks for \"on\", executes \"do\"\n if (node.mode == LGraphEventMode.ALWAYS && node.onExecute) {\n // wrap node.onExecute();\n node.doExecute?.()\n }\n }\n\n this.fixedtime += this.fixedtime_lapse\n this.onExecuteStep?.()\n }\n\n this.onAfterExecute?.()\n } else {\n try {\n // iterations\n for (let i = 0; i < num; i++) {\n for (let j = 0; j < limit; ++j) {\n const node = nodes[j]\n if (node.mode == LGraphEventMode.ALWAYS) {\n node.onExecute?.()\n }\n }\n\n this.fixedtime += this.fixedtime_lapse\n this.onExecuteStep?.()\n }\n\n this.onAfterExecute?.()\n this.errors_in_execution = false\n } catch (error) {\n this.errors_in_execution = true\n if (LiteGraph.throw_errors) throw error\n\n if (LiteGraph.debug) console.log(\"Error during execution:\", error)\n this.stop()\n }\n }\n\n const now = LiteGraph.getTime()\n let elapsed = now - start\n if (elapsed == 0) elapsed = 1\n\n this.execution_time = 0.001 * elapsed\n this.globaltime += 0.001 * elapsed\n this.iteration += 1\n this.elapsed_time = (now - this.last_update_time) * 0.001\n this.last_update_time = now\n this.nodes_executing = []\n this.nodes_actioning = []\n this.nodes_executedAction = []\n }\n\n /**\n * Updates the graph execution order according to relevance of the nodes (nodes with only outputs have more relevance than\n * nodes with only inputs.\n */\n updateExecutionOrder(): void {\n this._nodes_in_order = this.computeExecutionOrder(false)\n this._nodes_executable = []\n for (const node of this._nodes_in_order) {\n if (node.onExecute) {\n this._nodes_executable.push(node)\n }\n }\n }\n\n // This is more internal, it computes the executable nodes in order and returns it\n computeExecutionOrder(\n only_onExecute: boolean,\n set_level?: boolean,\n ): LGraphNode[] {\n const L: LGraphNode[] = []\n const S: LGraphNode[] = []\n const M: Dictionary<LGraphNode> = {}\n // to avoid repeating links\n const visited_links: Record<NodeId, boolean> = {}\n const remaining_links: Record<NodeId, number> = {}\n\n // search for the nodes without inputs (starting nodes)\n for (const node of this._nodes) {\n if (only_onExecute && !node.onExecute) {\n continue\n }\n\n // add to pending nodes\n M[node.id] = node\n\n // num of input connections\n let num = 0\n if (node.inputs) {\n for (const input of node.inputs) {\n if (input?.link != null) {\n num += 1\n }\n }\n }\n\n if (num == 0) {\n // is a starting node\n S.push(node)\n if (set_level) node._level = 1\n } else {\n // num of input links\n if (set_level) node._level = 0\n remaining_links[node.id] = num\n }\n }\n\n while (true) {\n // get an starting node\n const node = S.shift()\n if (node === undefined) break\n\n // add to ordered list\n L.push(node)\n // remove from the pending nodes\n delete M[node.id]\n\n if (!node.outputs) continue\n\n // for every output\n for (const output of node.outputs) {\n // not connected\n // TODO: Confirm functionality, clean condition\n if (output?.links == null || output.links.length == 0)\n continue\n\n // for every connection\n for (const link_id of output.links) {\n const link = this._links.get(link_id)\n if (!link) continue\n\n // already visited link (ignore it)\n if (visited_links[link.id]) continue\n\n const target_node = this.getNodeById(link.target_id)\n if (target_node == null) {\n visited_links[link.id] = true\n continue\n }\n\n if (set_level) {\n node._level ??= 0\n if (!target_node._level || target_node._level <= node._level) {\n target_node._level = node._level + 1\n }\n }\n\n // mark as visited\n visited_links[link.id] = true\n // reduce the number of links remaining\n remaining_links[target_node.id] -= 1\n\n // if no more links, then add to starters array\n if (remaining_links[target_node.id] == 0) S.push(target_node)\n }\n }\n }\n\n // the remaining ones (loops)\n for (const i in M) {\n L.push(M[i])\n }\n\n if (L.length != this._nodes.length && LiteGraph.debug)\n console.warn(\"something went wrong, nodes missing\")\n\n /** Ensure type is set */\n type OrderedLGraphNode = LGraphNode & { order: number }\n\n /** Sets the order property of each provided node to its index in {@link nodes}. */\n function setOrder(nodes: LGraphNode[]): asserts nodes is OrderedLGraphNode[] {\n const l = nodes.length\n for (let i = 0; i < l; ++i) {\n nodes[i].order = i\n }\n }\n\n // save order number in the node\n setOrder(L)\n\n // sort now by priority\n L.sort(function (A, B) {\n // @ts-expect-error ctor props\n const Ap = A.constructor.priority || A.priority || 0\n // @ts-expect-error ctor props\n const Bp = B.constructor.priority || B.priority || 0\n // if same priority, sort by order\n\n return Ap == Bp\n ? A.order - B.order\n : Ap - Bp\n })\n\n // save order number in the node, again...\n setOrder(L)\n\n return L\n }\n\n /**\n * Positions every node in a more readable manner\n */\n arrange(margin?: number, layout?: string): void {\n margin = margin || 100\n\n const nodes = this.computeExecutionOrder(false, true)\n const columns: LGraphNode[][] = []\n for (const node of nodes) {\n const col = node._level || 1\n columns[col] ||= []\n columns[col].push(node)\n }\n\n let x = margin\n\n for (const column of columns) {\n if (!column) continue\n\n let max_size = 100\n let y = margin + LiteGraph.NODE_TITLE_HEIGHT\n for (const node of column) {\n node.pos[0] = layout == LiteGraph.VERTICAL_LAYOUT ? y : x\n node.pos[1] = layout == LiteGraph.VERTICAL_LAYOUT ? x : y\n const max_size_index = layout == LiteGraph.VERTICAL_LAYOUT ? 1 : 0\n if (node.size[max_size_index] > max_size) {\n max_size = node.size[max_size_index]\n }\n const node_size_index = layout == LiteGraph.VERTICAL_LAYOUT ? 0 : 1\n y += node.size[node_size_index] + margin + LiteGraph.NODE_TITLE_HEIGHT\n }\n x += max_size + margin\n }\n\n this.setDirtyCanvas(true, true)\n }\n\n /**\n * Returns the amount of time the graph has been running in milliseconds\n * @returns number of milliseconds the graph has been running\n */\n getTime(): number {\n return this.globaltime\n }\n\n /**\n * Returns the amount of time accumulated using the fixedtime_lapse var.\n * This is used in context where the time increments should be constant\n * @returns number of milliseconds the graph has been running\n */\n getFixedTime(): number {\n return this.fixedtime\n }\n\n /**\n * Returns the amount of time it took to compute the latest iteration.\n * Take into account that this number could be not correct\n * if the nodes are using graphical actions\n * @returns number of milliseconds it took the last cycle\n */\n getElapsedTime(): number {\n return this.elapsed_time\n }\n\n /**\n * @deprecated Will be removed in 0.9\n * Sends an event to all the nodes, useful to trigger stuff\n * @param eventname the name of the event (function to be called)\n * @param params parameters in array format\n */\n sendEventToAllNodes(\n eventname: string,\n params?: object | object[],\n mode?: LGraphEventMode,\n ): void {\n mode = mode || LGraphEventMode.ALWAYS\n\n const nodes = this._nodes_in_order || this._nodes\n if (!nodes) return\n\n for (const node of nodes) {\n // @ts-expect-error deprecated\n if (!node[eventname] || node.mode != mode) continue\n if (params === undefined) {\n // @ts-expect-error deprecated\n node[eventname]()\n } else if (params && params.constructor === Array) {\n // @ts-expect-error deprecated\n node[eventname].apply(node, params)\n } else {\n // @ts-expect-error deprecated\n node[eventname](params)\n }\n }\n }\n\n /**\n * Runs an action on every canvas registered to this graph.\n * @param action Action to run for every canvas\n */\n canvasAction(action: (canvas: LGraphCanvas) => void): void {\n const canvases = this.list_of_graphcanvas\n if (!canvases) return\n for (const canvas of canvases) action(canvas)\n }\n\n /** @deprecated See {@link LGraph.canvasAction} */\n sendActionToCanvas<T extends MethodNames<LGraphCanvas>>(\n action: T,\n params?: ParamsArray<LGraphCanvas, T>,\n ): void {\n const { list_of_graphcanvas } = this\n if (!list_of_graphcanvas) return\n\n for (const c of list_of_graphcanvas) {\n c[action]?.apply(c, params)\n }\n }\n\n /**\n * Adds a new node instance to this graph\n * @param node the instance of the node\n */\n add(\n node: LGraphNode | LGraphGroup,\n skip_compute_order?: boolean,\n ): LGraphNode | null | undefined {\n if (!node) return\n const { state } = this\n\n // Ensure created items are snapped\n if (LiteGraph.alwaysSnapToGrid) {\n const snapTo = this.getSnapToGridSize()\n if (snapTo) node.snapToGrid(snapTo)\n }\n\n // LEGACY: This was changed from constructor === LGraphGroup\n // groups\n if (node instanceof LGraphGroup) {\n // Assign group ID\n if (node.id == null || node.id === -1) node.id = ++state.lastGroupId\n if (node.id > state.lastGroupId) state.lastGroupId = node.id\n\n this._groups.push(node)\n this.setDirtyCanvas(true)\n this.change()\n node.graph = this\n this._version++\n return\n }\n\n // nodes\n if (node.id != -1 && this._nodes_by_id[node.id] != null) {\n console.warn(\n \"LiteGraph: there is already a node with this ID, changing it\",\n )\n node.id = LiteGraph.use_uuids\n ? LiteGraph.uuidv4()\n : ++state.lastNodeId\n }\n\n if (this._nodes.length >= LiteGraph.MAX_NUMBER_OF_NODES) {\n throw \"LiteGraph: max number of nodes in a graph reached\"\n }\n\n // give him an id\n if (LiteGraph.use_uuids) {\n if (node.id == null || node.id == -1)\n node.id = LiteGraph.uuidv4()\n } else {\n if (node.id == null || node.id == -1) {\n node.id = ++state.lastNodeId\n } else if (typeof node.id === \"number\" && state.lastNodeId < node.id) {\n state.lastNodeId = node.id\n }\n }\n\n node.graph = this\n this._version++\n\n this._nodes.push(node)\n this._nodes_by_id[node.id] = node\n\n node.onAdded?.(this)\n\n if (this.config.align_to_grid) node.alignToGrid()\n\n if (!skip_compute_order) this.updateExecutionOrder()\n\n this.onNodeAdded?.(node)\n\n this.setDirtyCanvas(true)\n this.change()\n\n // to chain actions\n return node\n }\n\n /**\n * Removes a node from the graph\n * @param node the instance of the node\n */\n remove(node: LGraphNode | LGraphGroup): void {\n // LEGACY: This was changed from constructor === LiteGraph.LGraphGroup\n if (node instanceof LGraphGroup) {\n this.canvasAction(c => c.deselect(node))\n\n const index = this._groups.indexOf(node)\n if (index != -1) {\n this._groups.splice(index, 1)\n }\n node.graph = undefined\n this._version++\n this.setDirtyCanvas(true, true)\n this.change()\n return\n }\n\n // not found\n if (this._nodes_by_id[node.id] == null) {\n console.warn(\"LiteGraph: node not found\", node)\n return\n }\n // cannot be removed\n if (node.ignore_remove) {\n console.warn(\"LiteGraph: node cannot be removed\", node)\n return\n }\n\n // sure? - almost sure is wrong\n this.beforeChange()\n\n const { inputs, outputs } = node\n\n // disconnect inputs\n if (inputs) {\n for (const [i, slot] of inputs.entries()) {\n if (slot.link != null) node.disconnectInput(i, true)\n }\n }\n\n // disconnect outputs\n if (outputs) {\n for (const [i, slot] of outputs.entries()) {\n if (slot.links?.length) node.disconnectOutput(i)\n }\n }\n\n // Floating links\n for (const link of this.floatingLinks.values()) {\n if (link.origin_id === node.id || link.target_id === node.id) {\n this.removeFloatingLink(link)\n }\n }\n\n // callback\n node.onRemoved?.()\n\n node.graph = null\n this._version++\n\n // remove from canvas render\n const { list_of_graphcanvas } = this\n if (list_of_graphcanvas) {\n for (const canvas of list_of_graphcanvas) {\n if (canvas.selected_nodes[node.id])\n delete canvas.selected_nodes[node.id]\n\n canvas.deselect(node)\n }\n }\n\n // remove from containers\n const pos = this._nodes.indexOf(node)\n if (pos != -1) this._nodes.splice(pos, 1)\n\n delete this._nodes_by_id[node.id]\n\n this.onNodeRemoved?.(node)\n\n // close panels\n this.canvasAction(c => c.checkPanels())\n\n this.setDirtyCanvas(true, true)\n // sure? - almost sure is wrong\n this.afterChange()\n this.change()\n\n this.updateExecutionOrder()\n }\n\n /**\n * Returns a node by its id.\n */\n getNodeById(id: NodeId | null | undefined): LGraphNode | null {\n return id != null\n ? this._nodes_by_id[id]\n : null\n }\n\n /**\n * Returns a list of nodes that matches a class\n * @param classObject the class itself (not an string)\n * @returns a list with all the nodes of this type\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n findNodesByClass(classObject: Function, result?: LGraphNode[]): LGraphNode[] {\n result = result || []\n result.length = 0\n const { _nodes } = this\n for (const node of _nodes) {\n if (node.constructor === classObject)\n result.push(node)\n }\n return result\n }\n\n /**\n * Returns a list of nodes that matches a type\n * @param type the name of the node type\n * @returns a list with all the nodes of this type\n */\n findNodesByType(type: string, result: LGraphNode[]): LGraphNode[] {\n const matchType = type.toLowerCase()\n result = result || []\n result.length = 0\n const { _nodes } = this\n for (const node of _nodes) {\n if (node.type?.toLowerCase() == matchType)\n result.push(node)\n }\n return result\n }\n\n /**\n * Returns the first node that matches a name in its title\n * @param title the name of the node to search\n * @returns the node or null\n */\n findNodeByTitle(title: string): LGraphNode | null {\n const { _nodes } = this\n for (const node of _nodes) {\n if (node.title == title)\n return node\n }\n return null\n }\n\n /**\n * Returns a list of nodes that matches a name\n * @param title the name of the node to search\n * @returns a list with all the nodes with this name\n */\n findNodesByTitle(title: string): LGraphNode[] {\n const result: LGraphNode[] = []\n const { _nodes } = this\n for (const node of _nodes) {\n if (node.title == title)\n result.push(node)\n }\n return result\n }\n\n /**\n * Returns the top-most node in this position of the canvas\n * @param x the x coordinate in canvas space\n * @param y the y coordinate in canvas space\n * @param nodeList a list with all the nodes to search from, by default is all the nodes in the graph\n * @returns the node at this position or null\n */\n getNodeOnPos(\n x: number,\n y: number,\n nodeList?: LGraphNode[],\n ): LGraphNode | null {\n const nodes = nodeList || this._nodes\n let i = nodes.length\n while (--i >= 0) {\n const node = nodes[i]\n if (node.isPointInside(x, y)) return node\n }\n return null\n }\n\n /**\n * Returns the top-most group in that position\n * @param x The x coordinate in canvas space\n * @param y The y coordinate in canvas space\n * @returns The group or null\n */\n getGroupOnPos(x: number, y: number): LGraphGroup | undefined {\n return this._groups.toReversed().find(g => g.isPointInside(x, y))\n }\n\n /**\n * Returns the top-most group with a titlebar in the provided position.\n * @param x The x coordinate in canvas space\n * @param y The y coordinate in canvas space\n * @returns The group or null\n */\n getGroupTitlebarOnPos(x: number, y: number): LGraphGroup | undefined {\n return this._groups.toReversed().find(g => g.isPointInTitlebar(x, y))\n }\n\n /**\n * Finds a reroute a the given graph point\n * @param x X co-ordinate in graph space\n * @param y Y co-ordinate in graph space\n * @returns The first reroute under the given co-ordinates, or undefined\n */\n getRerouteOnPos(x: number, y: number, reroutes?: Iterable<Reroute>): Reroute | undefined {\n for (const reroute of reroutes ?? this.reroutes.values()) {\n if (reroute.containsPoint([x, y])) return reroute\n }\n }\n\n /**\n * Snaps the provided items to a grid.\n *\n * Item positions are reounded to the nearest multiple of {@link LiteGraph.CANVAS_GRID_SIZE}.\n *\n * When {@link LiteGraph.alwaysSnapToGrid} is enabled\n * and the grid size is falsy, a default of 1 is used.\n * @param items The items to be snapped to the grid\n * @todo Currently only snaps nodes.\n */\n snapToGrid(items: Set<Positionable>): void {\n const snapTo = this.getSnapToGridSize()\n if (!snapTo) return\n\n for (const item of getAllNestedItems(items)) {\n if (!item.pinned) item.snapToGrid(snapTo)\n }\n }\n\n /**\n * Finds the size of the grid that items should be snapped to when moved.\n * @returns The size of the grid that items should be snapped to\n */\n getSnapToGridSize(): number {\n // Default to 1 when always snapping\n return LiteGraph.alwaysSnapToGrid\n ? LiteGraph.CANVAS_GRID_SIZE || 1\n : LiteGraph.CANVAS_GRID_SIZE\n }\n\n /**\n * @deprecated Will be removed in 0.9\n * Checks that the node type matches the node type registered,\n * used when replacing a nodetype by a newer version during execution\n * this replaces the ones using the old version with the new version\n */\n checkNodeTypes() {\n const { _nodes } = this\n for (const [i, node] of _nodes.entries()) {\n const ctor = LiteGraph.registered_node_types[node.type]\n if (node.constructor == ctor) continue\n\n console.log(\"node being replaced by newer version:\", node.type)\n const newnode = LiteGraph.createNode(node.type)\n if (!newnode) continue\n _nodes[i] = newnode\n newnode.configure(node.serialize())\n newnode.graph = this\n this._nodes_by_id[newnode.id] = newnode\n\n if (node.inputs) newnode.inputs = [...node.inputs]\n if (node.outputs) newnode.outputs = [...node.outputs]\n }\n this.updateExecutionOrder()\n }\n\n // ********** GLOBALS *****************\n trigger(action: string, param: unknown) {\n this.onTrigger?.(action, param)\n }\n\n /** @todo Clean up - never implemented. */\n triggerInput(name: string, value: any): void {\n const nodes = this.findNodesByTitle(name)\n for (const node of nodes) {\n // @ts-expect-error\n node.onTrigger(value)\n }\n }\n\n /** @todo Clean up - never implemented. */\n setCallback(name: string, func: any): void {\n const nodes = this.findNodesByTitle(name)\n for (const node of nodes) {\n // @ts-expect-error\n node.setTrigger(func)\n }\n }\n\n // used for undo, called before any change is made to the graph\n beforeChange(info?: LGraphNode): void {\n this.onBeforeChange?.(this, info)\n this.canvasAction(c => c.onBeforeChange?.(this))\n }\n\n // used to resend actions, called after any change is made to the graph\n afterChange(info?: LGraphNode | null): void {\n this.onAfterChange?.(this, info)\n this.canvasAction(c => c.onAfterChange?.(this))\n }\n\n /**\n * clears the triggered slot animation in all links (stop visual animation)\n */\n clearTriggeredSlots(): void {\n for (const link_info of this._links.values()) {\n if (!link_info) continue\n\n if (link_info._last_time) link_info._last_time = 0\n }\n }\n\n /* Called when something visually changed (not the graph!) */\n change(): void {\n if (LiteGraph.debug) {\n console.log(\"Graph changed\")\n }\n this.canvasAction(c => c.setDirty(true, true))\n this.on_change?.(this)\n }\n\n setDirtyCanvas(fg: boolean, bg?: boolean): void {\n this.canvasAction(c => c.setDirty(fg, bg))\n }\n\n addFloatingLink(link: LLink): LLink {\n if (link.id === -1) {\n link.id = ++this.#lastFloatingLinkId\n }\n this.#floatingLinks.set(link.id, link)\n\n const slot = link.target_id !== -1\n ? this.getNodeById(link.target_id)?.inputs?.[link.target_slot]\n : this.getNodeById(link.origin_id)?.outputs?.[link.origin_slot]\n if (slot) {\n slot._floatingLinks ??= new Set()\n slot._floatingLinks.add(link)\n } else {\n console.warn(`Adding invalid floating link: target/slot: [${link.target_id}/${link.target_slot}] origin/slot: [${link.origin_id}/${link.origin_slot}]`)\n }\n\n const reroutes = LLink.getReroutes(this, link)\n for (const reroute of reroutes) {\n reroute.floatingLinkIds.add(link.id)\n }\n return link\n }\n\n removeFloatingLink(link: LLink): void {\n this.#floatingLinks.delete(link.id)\n\n const slot = link.target_id !== -1\n ? this.getNodeById(link.target_id)?.inputs?.[link.target_slot]\n : this.getNodeById(link.origin_id)?.outputs?.[link.origin_slot]\n if (slot) {\n slot._floatingLinks?.delete(link)\n }\n\n const reroutes = LLink.getReroutes(this, link)\n for (const reroute of reroutes) {\n reroute.floatingLinkIds.delete(link.id)\n if (reroute.floatingLinkIds.size === 0) {\n delete reroute.floating\n }\n\n if (reroute.totalLinks === 0) this.removeReroute(reroute.id)\n }\n }\n\n /**\n * Finds the link with the provided ID.\n * @param id ID of link to find\n * @returns The link with the provided {@link id}, otherwise `undefined`. Always returns `undefined` if `id` is nullish.\n */\n getLink(id: null | undefined): undefined\n getLink(id: LinkId | null | undefined): LLink | undefined\n getLink(id: LinkId | null | undefined): LLink | undefined {\n return id == null ? undefined : this._links.get(id)\n }\n\n /**\n * Finds the reroute with the provided ID.\n * @param id ID of reroute to find\n * @returns The reroute with the provided {@link id}, otherwise `undefined`. Always returns `undefined` if `id` is nullish.\n */\n getReroute(id: null | undefined): undefined\n getReroute(id: RerouteId | null | undefined): Reroute | undefined\n getReroute(id: RerouteId | null | undefined): Reroute | undefined {\n return id == null ? undefined : this.reroutes.get(id)\n }\n\n /**\n * Configures a reroute on the graph where ID is already known (probably deserialisation).\n * Creates the object if it does not exist.\n * @param serialisedReroute See {@link SerialisableReroute}\n */\n setReroute({ id, parentId, pos, linkIds, floating }: OptionalProps<SerialisableReroute, \"id\">): Reroute {\n id ??= ++this.state.lastRerouteId\n if (id > this.state.lastRerouteId) this.state.lastRerouteId = id\n\n const reroute = this.reroutes.get(id) ?? new Reroute(id, this)\n reroute.update(parentId, pos, linkIds, floating)\n this.reroutes.set(id, reroute)\n return reroute\n }\n\n /**\n * Creates a new reroute and adds it to the graph.\n * @param pos Position in graph space\n * @param before The existing link segment (reroute, link) that will be after this reroute,\n * going from the node output to input.\n * @returns The newly created reroute - typically ignored.\n */\n createReroute(pos: Point, before: LinkSegment): Reroute {\n const rerouteId = ++this.state.lastRerouteId\n const linkIds = before instanceof Reroute\n ? before.linkIds\n : [before.id]\n const floatingLinkIds = before instanceof Reroute\n ? before.floatingLinkIds\n : [before.id]\n const reroute = new Reroute(rerouteId, this, pos, before.parentId, linkIds, floatingLinkIds)\n this.reroutes.set(rerouteId, reroute)\n for (const linkId of linkIds) {\n const link = this._links.get(linkId)\n if (!link) continue\n if (link.parentId === before.parentId) link.parentId = rerouteId\n\n const reroutes = LLink.getReroutes(this, link)\n for (const x of reroutes.filter(x => x.parentId === before.parentId)) {\n x.parentId = rerouteId\n }\n }\n\n for (const linkId of floatingLinkIds) {\n const link = this.floatingLinks.get(linkId)\n if (!link) continue\n if (link.parentId === before.parentId) link.parentId = rerouteId\n\n const reroutes = LLink.getReroutes(this, link)\n for (const x of reroutes.filter(x => x.parentId === before.parentId)) {\n x.parentId = rerouteId\n }\n }\n\n return reroute\n }\n\n /**\n * Removes a reroute from the graph\n * @param id ID of reroute to remove\n */\n removeReroute(id: RerouteId): void {\n const { reroutes } = this\n const reroute = reroutes.get(id)\n if (!reroute) return\n\n this.canvasAction(c => c.deselect(reroute))\n\n // Extract reroute from the reroute chain\n const { parentId, linkIds, floatingLinkIds } = reroute\n for (const reroute of reroutes.values()) {\n if (reroute.parentId === id) reroute.parentId = parentId\n }\n\n for (const linkId of linkIds) {\n const link = this._links.get(linkId)\n if (link && link.parentId === id) link.parentId = parentId\n }\n\n for (const linkId of floatingLinkIds) {\n const link = this.floatingLinks.get(linkId)\n if (!link) {\n console.warn(`Removed reroute had floating link ID that did not exist [${linkId}]`)\n continue\n }\n\n // A floating link is a unique branch; if there is no parent reroute, or\n // the parent reroute has any other links, remove this floating link.\n const floatingReroutes = LLink.getReroutes(this, link)\n const lastReroute = floatingReroutes.at(-1)\n const secondLastReroute = floatingReroutes.at(-2)\n\n if (reroute !== lastReroute) {\n continue\n } else if (secondLastReroute?.totalLinks !== 1) {\n this.removeFloatingLink(link)\n } else if (link.parentId === id) {\n link.parentId = parentId\n secondLastReroute.floating = reroute.floating\n }\n }\n\n reroutes.delete(id)\n // This does not belong here; it should be handled by the caller, or run by a remove-many API.\n // https://github.com/Comfy-Org/litegraph.js/issues/898\n this.setDirtyCanvas(false, true)\n }\n\n /**\n * Destroys a link\n */\n removeLink(link_id: LinkId): void {\n const link = this._links.get(link_id)\n if (!link) return\n\n const node = this.getNodeById(link.target_id)\n node?.disconnectInput(link.target_slot, false)\n\n link.disconnect(this)\n }\n\n /**\n * Creates a new subgraph definition, and adds it to the graph.\n * @param data Exported data (typically serialised) to configure the new subgraph with\n * @returns The newly created subgraph definition.\n */\n createSubgraph(data: ExportedSubgraph): Subgraph {\n const { id } = data\n\n const subgraph = new Subgraph(this.rootGraph, data)\n this.subgraphs.set(id, subgraph)\n\n // FE: Create node defs\n this.rootGraph.events.dispatch(\"subgraph-created\", { subgraph, data })\n return subgraph\n }\n\n convertToSubgraph(items: Set<Positionable>): { subgraph: Subgraph, node: SubgraphNode } {\n if (items.size === 0) throw new Error(\"Cannot convert to subgraph: nothing to convert\")\n const { state, revision, config } = this\n\n const { boundaryLinks, boundaryFloatingLinks, internalLinks, boundaryInputLinks, boundaryOutputLinks } = getBoundaryLinks(this, items)\n const { nodes, reroutes, groups } = splitPositionables(items)\n\n const boundingRect = createBounds(items)\n if (!boundingRect) throw new Error(\"Failed to create bounding rect for subgraph\")\n\n const resolvedInputLinks = boundaryInputLinks.map(x => x.resolve(this))\n const resolvedOutputLinks = boundaryOutputLinks.map(x => x.resolve(this))\n\n const clonedNodes = multiClone(nodes)\n\n // Inputs, outputs, and links\n const links = internalLinks.map(x => x.asSerialisable())\n const inputs = mapSubgraphInputsAndLinks(resolvedInputLinks, links)\n const outputs = mapSubgraphOutputsAndLinks(resolvedOutputLinks, links)\n\n // Prepare subgraph data\n const data = {\n id: createUuidv4(),\n name: \"New Subgraph\",\n inputNode: {\n id: SUBGRAPH_INPUT_ID,\n bounding: [0, 0, 75, 100],\n },\n outputNode: {\n id: SUBGRAPH_OUTPUT_ID,\n bounding: [0, 0, 75, 100],\n },\n inputs,\n outputs,\n widgets: [],\n version: LGraph.serialisedSchemaVersion,\n state,\n revision,\n config,\n links,\n nodes: clonedNodes,\n reroutes: structuredClone([...reroutes].map(reroute => reroute.asSerialisable())),\n groups: structuredClone([...groups].map(group => group.serialize())),\n } satisfies ExportedSubgraph\n\n const subgraph = this.createSubgraph(data)\n subgraph.configure(data)\n\n // Position the subgraph input nodes\n subgraph.inputNode.arrange()\n subgraph.outputNode.arrange()\n const { boundingRect: inputRect } = subgraph.inputNode\n const { boundingRect: outputRect } = subgraph.outputNode\n alignOutsideContainer(inputRect, Alignment.MidLeft, boundingRect, [50, 0])\n alignOutsideContainer(outputRect, Alignment.MidRight, boundingRect, [50, 0])\n\n // Remove items converted to subgraph\n for (const resolved of resolvedInputLinks) resolved.inputNode?.disconnectInput(resolved.inputNode.inputs.indexOf(resolved.input!), true)\n for (const resolved of resolvedOutputLinks) resolved.outputNode?.disconnectOutput(resolved.outputNode.outputs.indexOf(resolved.output!), resolved.inputNode)\n\n for (const node of nodes) this.remove(node)\n for (const reroute of reroutes) this.removeReroute(reroute.id)\n for (const group of groups) this.remove(group)\n\n this.rootGraph.events.dispatch(\"convert-to-subgraph\", {\n subgraph,\n bounds: boundingRect,\n exportedSubgraph: data,\n boundaryLinks,\n resolvedInputLinks,\n resolvedOutputLinks,\n boundaryFloatingLinks,\n internalLinks,\n })\n\n // Create subgraph node object\n const subgraphNode = LiteGraph.createNode(subgraph.id, subgraph.name, {\n inputs: structuredClone(inputs),\n outputs: structuredClone(outputs),\n })\n if (!subgraphNode) throw new Error(\"Failed to create subgraph node\")\n\n // Resize to inputs/outputs\n subgraphNode.setSize(subgraphNode.computeSize())\n\n // Center the subgraph node\n alignToContainer(subgraphNode._posSize, Alignment.Centre | Alignment.Middle, boundingRect)\n\n // Add the subgraph node to the graph\n this.add(subgraphNode)\n\n // Group matching input links\n const groupedByOutput = groupResolvedByOutput(resolvedInputLinks)\n\n // Reconnect input links in parent graph\n let i = 0\n for (const [, connections] of groupedByOutput.entries()) {\n const [firstResolved, ...others] = connections\n const { output, outputNode, link, subgraphInput } = firstResolved\n\n // Special handling: Subgraph input node\n i++\n if (link.origin_id === SUBGRAPH_INPUT_ID) {\n link.target_id = subgraphNode.id\n link.target_slot = i - 1\n if (subgraphInput instanceof SubgraphInput) {\n subgraphInput.connect(subgraphNode.findInputSlotByType(link.type, true, true), subgraphNode, link.parentId)\n } else {\n throw new TypeError(\"Subgraph input node is not a SubgraphInput\")\n }\n console.debug(\"Reconnect input links in parent graph\", { ...link }, this.links.get(link.id), this.links.get(link.id) === link)\n\n for (const resolved of others) {\n resolved.link.disconnect(this)\n }\n continue\n }\n\n if (!output || !outputNode) {\n console.warn(\"Convert to Subgraph reconnect: Failed to resolve input link\", connections[0])\n continue\n }\n\n const input = subgraphNode.findInputSlotByType(link.type, true, true)\n outputNode.connectSlots(\n output,\n subgraphNode,\n input,\n link.parentId,\n )\n }\n\n // Group matching links\n const outputsGroupedByOutput = groupResolvedByOutput(resolvedOutputLinks)\n\n // Reconnect output links in parent graph\n i = 0\n for (const [, connections] of outputsGroupedByOutput.entries()) {\n // Special handling: Subgraph output node\n i++\n for (const connection of connections) {\n const { input, inputNode, link, subgraphOutput } = connection\n if (link.target_id === SUBGRAPH_OUTPUT_ID) {\n link.origin_id = subgraphNode.id\n link.origin_slot = i - 1\n this.links.set(link.id, link)\n if (subgraphOutput instanceof SubgraphOutput) {\n subgraphOutput.connect(subgraphNode.findOutputSlotByType(link.type, true, true), subgraphNode, link.parentId)\n } else {\n throw new TypeError(\"Subgraph input node is not a SubgraphInput\")\n }\n continue\n }\n\n if (!input || !inputNode) {\n console.warn(\"Convert to Subgraph reconnect: Failed to resolve output link\", connection)\n continue\n }\n\n const output = subgraphNode.outputs[i - 1]\n subgraphNode.connectSlots(\n output,\n inputNode,\n input,\n link.parentId,\n )\n }\n }\n\n return { subgraph, node: subgraphNode as SubgraphNode }\n }\n\n /**\n * Resolve a path of subgraph node IDs into a list of subgraph nodes.\n * Not intended to be run from subgraphs.\n * @param nodeIds An ordered list of node IDs, from the root graph to the most nested subgraph node\n * @returns An ordered list of nested subgraph nodes.\n */\n resolveSubgraphIdPath(nodeIds: readonly NodeId[]): SubgraphNode[] {\n const result: SubgraphNode[] = []\n let currentGraph: GraphOrSubgraph = this.rootGraph\n\n for (const nodeId of nodeIds) {\n const node: LGraphNode | null = currentGraph.getNodeById(nodeId)\n if (!node) throw new Error(`Node [${nodeId}] not found. ID Path: ${nodeIds.join(\":\")}`)\n if (!node.isSubgraphNode()) throw new Error(`Node [${nodeId}] is not a SubgraphNode. ID Path: ${nodeIds.join(\":\")}`)\n\n result.push(node)\n currentGraph = node.subgraph\n }\n\n return result\n }\n\n /**\n * Creates a Object containing all the info about this graph, it can be serialized\n * @deprecated Use {@link asSerialisable}, which returns the newer schema version.\n * @returns value of the node\n */\n serialize(option?: { sortNodes: boolean }): ISerialisedGraph {\n const { config, state, groups, nodes, reroutes, extra, floatingLinks, definitions } = this.asSerialisable(option)\n const linkArray = [...this._links.values()]\n const links = linkArray.map(x => x.serialize())\n\n if (reroutes?.length) {\n // Link parent IDs cannot go in 0.4 schema arrays\n extra.linkExtensions = linkArray\n .filter(x => x.parentId !== undefined)\n .map(x => ({ id: x.id, parentId: x.parentId }))\n }\n\n extra.reroutes = reroutes?.length ? reroutes : undefined\n return {\n id: this.id,\n revision: this.revision,\n last_node_id: state.lastNodeId,\n last_link_id: state.lastLinkId,\n nodes,\n links,\n floatingLinks,\n groups,\n definitions,\n config,\n extra,\n version: LiteGraph.VERSION,\n }\n }\n\n /** @returns The drag and scale state of the first attached canvas, otherwise `undefined`. */\n #getDragAndScale(): DragAndScaleState | undefined {\n const ds = this.list_of_graphcanvas?.at(0)?.ds\n if (ds) return { scale: ds.scale, offset: ds.offset }\n }\n\n /**\n * Prepares a shallow copy of this object for immediate serialisation or structuredCloning.\n * The return value should be discarded immediately.\n * @param options Serialise options = currently `sortNodes: boolean`, whether to sort nodes by ID.\n * @returns A shallow copy of parts of this graph, with shallow copies of its serialisable objects.\n * Mutating the properties of the return object may result in changes to your graph.\n * It is intended for use with {@link structuredClone} or {@link JSON.stringify}.\n */\n asSerialisable(options?: { sortNodes: boolean }): SerialisableGraph & Required<Pick<SerialisableGraph, \"nodes\" | \"groups\" | \"extra\">> {\n const { id, revision, config, state } = this\n\n const nodeList = !LiteGraph.use_uuids && options?.sortNodes\n // @ts-expect-error If LiteGraph.use_uuids is false, ids are numbers.\n ? [...this._nodes].sort((a, b) => a.id - b.id)\n : this._nodes\n\n const nodes = nodeList.map(node => node.serialize())\n const groups = this._groups.map(x => x.serialize())\n\n const links = this._links.size ? [...this._links.values()].map(x => x.asSerialisable()) : undefined\n const floatingLinks = this.floatingLinks.size ? [...this.floatingLinks.values()].map(x => x.asSerialisable()) : undefined\n const reroutes = this.reroutes.size ? [...this.reroutes.values()].map(x => x.asSerialisable()) : undefined\n\n // Save scale and offset\n const extra = { ...this.extra }\n if (LiteGraph.saveViewportWithGraph) extra.ds = this.#getDragAndScale()\n if (!extra.ds) delete extra.ds\n\n const data: ReturnType<typeof this.asSerialisable> = {\n id,\n revision,\n version: LGraph.serialisedSchemaVersion,\n config,\n state,\n groups,\n nodes,\n links,\n floatingLinks,\n reroutes,\n extra,\n }\n\n if (this.isRootGraph && this._subgraphs.size) {\n const usedSubgraphIds = findUsedSubgraphIds(this, this._subgraphs)\n const usedSubgraphs = [...this._subgraphs.values()]\n .filter(subgraph => usedSubgraphIds.has(subgraph.id))\n .map(x => x.asSerialisable())\n\n if (usedSubgraphs.length > 0) {\n data.definitions = { subgraphs: usedSubgraphs }\n }\n }\n\n this.onSerialize?.(data)\n return data\n }\n\n protected _configureBase(data: ISerialisedGraph | SerialisableGraph): void {\n const { id, extra } = data\n\n // Create a new graph ID if none is provided\n if (id) {\n this.id = id\n } else if (this.id === zeroUuid) {\n this.id = createUuidv4()\n }\n\n // Extra\n this.extra = extra ? structuredClone(extra) : {}\n\n // Ensure auto-generated serialisation data is removed from extra\n delete this.extra.linkExtensions\n }\n\n /**\n * Configure a graph from a JSON string\n * @param data The deserialised object to configure this graph from\n * @param keep_old If `true`, the graph will not be cleared prior to\n * adding the configuration.\n */\n configure(\n data: ISerialisedGraph | SerialisableGraph,\n keep_old?: boolean,\n ): boolean | undefined {\n const options: LGraphEventMap[\"configuring\"] = {\n data,\n clearGraph: !keep_old,\n }\n const mayContinue = this.events.dispatch(\"configuring\", options)\n if (!mayContinue) return\n\n try {\n // TODO: Finish typing configure()\n if (!data) return\n if (options.clearGraph) this.clear()\n\n this._configureBase(data)\n\n let reroutes: SerialisableReroute[] | undefined\n\n // TODO: Determine whether this should this fall back to 0.4.\n if (data.version === 0.4) {\n const { extra } = data\n // Deprecated - old schema version, links are arrays\n if (Array.isArray(data.links)) {\n for (const linkData of data.links) {\n const link = LLink.createFromArray(linkData)\n this._links.set(link.id, link)\n }\n }\n // #region `extra` embeds for v0.4\n\n // LLink parentIds\n if (Array.isArray(extra?.linkExtensions)) {\n for (const linkEx of extra.linkExtensions) {\n const link = this._links.get(linkEx.id)\n if (link) link.parentId = linkEx.parentId\n }\n }\n\n // Reroutes\n reroutes = extra?.reroutes\n\n // #endregion `extra` embeds for v0.4\n } else {\n // New schema - one version so far, no check required.\n\n // State\n if (data.state) {\n const { lastGroupId, lastLinkId, lastNodeId, lastRerouteId } = data.state\n const { state } = this\n if (lastGroupId != null) state.lastGroupId = lastGroupId\n if (lastLinkId != null) state.lastLinkId = lastLinkId\n if (lastNodeId != null) state.lastNodeId = lastNodeId\n if (lastRerouteId != null) state.lastRerouteId = lastRerouteId\n }\n\n // Links\n if (Array.isArray(data.links)) {\n for (const linkData of data.links) {\n const link = LLink.create(linkData)\n this._links.set(link.id, link)\n }\n }\n\n reroutes = data.reroutes\n }\n\n // Reroutes\n if (Array.isArray(reroutes)) {\n for (const rerouteData of reroutes) {\n this.setReroute(rerouteData)\n }\n }\n\n const nodesData = data.nodes\n\n // copy all stored fields\n for (const i in data) {\n if (LGraph.ConfigureProperties.has(i)) continue\n\n // @ts-expect-error #574 Legacy property assignment\n this[i] = data[i]\n }\n\n // Subgraph definitions\n const subgraphs = data.definitions?.subgraphs\n if (subgraphs) {\n for (const subgraph of subgraphs) this.createSubgraph(subgraph)\n for (const subgraph of subgraphs) this.subgraphs.get(subgraph.id)?.configure(subgraph)\n }\n\n let error = false\n const nodeDataMap = new Map<NodeId, ISerialisedNode>()\n\n // create nodes\n this._nodes = []\n if (nodesData) {\n for (const n_info of nodesData) {\n // stored info\n let node = LiteGraph.createNode(String(n_info.type), n_info.title)\n if (!node) {\n if (LiteGraph.debug) console.log(\"Node not found or has errors:\", n_info.type)\n\n // in case of error we create a replacement node to avoid losing info\n node = new LGraphNode(\"\")\n node.last_serialization = n_info\n node.has_errors = true\n error = true\n // continue;\n }\n\n // id it or it will create a new id\n node.id = n_info.id\n // add before configure, otherwise configure cannot create links\n this.add(node, true)\n nodeDataMap.set(node.id, n_info)\n }\n\n // configure nodes afterwards so they can reach each other\n for (const [id, nodeData] of nodeDataMap) {\n this.getNodeById(id)?.configure(nodeData)\n }\n }\n\n // Floating links\n if (Array.isArray(data.floatingLinks)) {\n for (const linkData of data.floatingLinks) {\n const floatingLink = LLink.create(linkData)\n this.addFloatingLink(floatingLink)\n\n if (floatingLink.id > this.#lastFloatingLinkId) this.#lastFloatingLinkId = floatingLink.id\n }\n }\n\n // Drop broken reroutes\n for (const reroute of this.reroutes.values()) {\n // Drop broken links, and ignore reroutes with no valid links\n if (!reroute.validateLinks(this._links, this.floatingLinks)) {\n this.reroutes.delete(reroute.id)\n }\n }\n\n // groups\n this._groups.length = 0\n const groupData = data.groups\n if (groupData) {\n for (const data of groupData) {\n // TODO: Search/remove these global object refs\n const group = new LiteGraph.LGraphGroup()\n group.configure(data)\n this.add(group)\n }\n }\n\n this.updateExecutionOrder()\n\n this.onConfigure?.(data)\n this._version++\n\n // Ensure the primary canvas is set to the correct graph\n const { primaryCanvas } = this\n const subgraphId = primaryCanvas?.subgraph?.id\n if (subgraphId) {\n const subgraph = this.subgraphs.get(subgraphId)\n if (subgraph) {\n primaryCanvas.setGraph(subgraph)\n } else {\n primaryCanvas.setGraph(this)\n }\n }\n\n this.setDirtyCanvas(true, true)\n return error\n } finally {\n this.events.dispatch(\"configured\")\n }\n }\n\n #canvas?: LGraphCanvas\n get primaryCanvas(): LGraphCanvas | undefined {\n return this.rootGraph.#canvas\n }\n\n set primaryCanvas(canvas: LGraphCanvas) {\n this.rootGraph.#canvas = canvas\n }\n\n load(url: string | Blob | URL | File, callback: () => void) {\n const that = this\n\n // from file\n if (url instanceof Blob || url instanceof File) {\n const reader = new FileReader()\n reader.addEventListener(\"load\", function (event) {\n const result = stringOrEmpty(event.target?.result)\n const data = JSON.parse(result)\n that.configure(data)\n callback?.()\n })\n\n reader.readAsText(url)\n return\n }\n\n // is a string, then an URL\n const req = new XMLHttpRequest()\n req.open(\"GET\", url, true)\n req.send(null)\n req.addEventListener(\"load\", function () {\n if (req.status !== 200) {\n console.error(\"Error loading graph:\", req.status, req.response)\n return\n }\n const data = JSON.parse(req.response)\n that.configure(data)\n callback?.()\n })\n req.addEventListener(\"error\", (err) => {\n console.error(\"Error loading graph:\", err)\n })\n }\n}\n","import type { SubgraphEventMap } from \"@/infrastructure/SubgraphEventMap\"\nimport type { DefaultConnectionColors, INodeInputSlot, INodeOutputSlot } from \"@/interfaces\"\nimport type { LGraphCanvas } from \"@/LGraphCanvas\"\nimport type { ExportedSubgraph, ExposedWidget, ISerialisedGraph, Serialisable, SerialisableGraph } from \"@/types/serialisation\"\n\nimport { CustomEventTarget } from \"@/infrastructure/CustomEventTarget\"\nimport { type BaseLGraph, LGraph } from \"@/LGraph\"\nimport { createUuidv4 } from \"@/utils/uuid\"\n\nimport { SubgraphInput } from \"./SubgraphInput\"\nimport { SubgraphInputNode } from \"./SubgraphInputNode\"\nimport { SubgraphOutput } from \"./SubgraphOutput\"\nimport { SubgraphOutputNode } from \"./SubgraphOutputNode\"\n\n/** Internal; simplifies type definitions. */\nexport type GraphOrSubgraph = LGraph | Subgraph\n\n/** A subgraph definition. */\nexport class Subgraph extends LGraph implements BaseLGraph, Serialisable<ExportedSubgraph> {\n declare readonly events: CustomEventTarget<SubgraphEventMap>\n\n /** Limits the number of levels / depth that subgraphs may be nested. Prevents uncontrolled programmatic nesting. */\n static MAX_NESTED_SUBGRAPHS = 1000\n\n /** The display name of the subgraph. */\n name: string = \"Unnamed Subgraph\"\n\n readonly inputNode = new SubgraphInputNode(this)\n readonly outputNode = new SubgraphOutputNode(this)\n\n /** Ordered list of inputs to the subgraph itself. Similar to a reroute, with the input side in the graph, and the output side in the subgraph. */\n readonly inputs: SubgraphInput[] = []\n /** Ordered list of outputs from the subgraph itself. Similar to a reroute, with the input side in the subgraph, and the output side in the graph. */\n readonly outputs: SubgraphOutput[] = []\n /** A list of node widgets displayed in the parent graph, on the subgraph object. */\n readonly widgets: ExposedWidget[] = []\n\n #rootGraph: LGraph\n override get rootGraph(): LGraph {\n return this.#rootGraph\n }\n\n constructor(\n rootGraph: LGraph,\n data: ExportedSubgraph,\n ) {\n if (!rootGraph) throw new Error(\"Root graph is required\")\n\n super()\n\n this.#rootGraph = rootGraph\n\n const cloned = structuredClone(data)\n this._configureBase(cloned)\n this.#configureSubgraph(cloned)\n }\n\n getIoNodeOnPos(x: number, y: number): SubgraphInputNode | SubgraphOutputNode | undefined {\n const { inputNode, outputNode } = this\n if (inputNode.containsPoint([x, y])) return inputNode\n if (outputNode.containsPoint([x, y])) return outputNode\n }\n\n #configureSubgraph(data: ISerialisedGraph & ExportedSubgraph | SerialisableGraph & ExportedSubgraph): void {\n const { name, inputs, outputs, widgets } = data\n\n this.name = name\n if (inputs) {\n this.inputs.length = 0\n for (const input of inputs) {\n const subgraphInput = new SubgraphInput(input, this.inputNode)\n this.inputs.push(subgraphInput)\n this.events.dispatch(\"input-added\", { input: subgraphInput })\n }\n }\n\n if (outputs) {\n this.outputs.length = 0\n for (const output of outputs) {\n this.outputs.push(new SubgraphOutput(output, this.outputNode))\n }\n }\n\n if (widgets) {\n this.widgets.length = 0\n for (const widget of widgets) {\n this.widgets.push(widget)\n }\n }\n\n this.inputNode.configure(data.inputNode)\n this.outputNode.configure(data.outputNode)\n }\n\n override configure(data: ISerialisedGraph & ExportedSubgraph | SerialisableGraph & ExportedSubgraph, keep_old?: boolean): boolean | undefined {\n const r = super.configure(data, keep_old)\n\n this.#configureSubgraph(data)\n return r\n }\n\n override attachCanvas(canvas: LGraphCanvas): void {\n super.attachCanvas(canvas)\n canvas.subgraph = this\n }\n\n addInput(name: string, type: string): SubgraphInput {\n this.events.dispatch(\"adding-input\", { name, type })\n\n const input = new SubgraphInput({\n id: createUuidv4(),\n name,\n type,\n }, this.inputNode)\n\n this.inputs.push(input)\n this.events.dispatch(\"input-added\", { input })\n\n return input\n }\n\n addOutput(name: string, type: string): SubgraphOutput {\n this.events.dispatch(\"adding-output\", { name, type })\n\n const output = new SubgraphOutput({\n id: createUuidv4(),\n name,\n type,\n }, this.outputNode)\n\n this.outputs.push(output)\n this.events.dispatch(\"output-added\", { output })\n\n return output\n }\n\n /**\n * Renames an input slot in the subgraph.\n * @param input The input slot to rename.\n * @param name The new name for the input slot.\n */\n renameInput(input: SubgraphInput, name: string): void {\n const index = this.inputs.indexOf(input)\n if (index === -1) throw new Error(\"Input not found\")\n\n const oldName = input.displayName\n this.events.dispatch(\"renaming-input\", { input, index, oldName, newName: name })\n\n input.label = name\n }\n\n /**\n * Renames an output slot in the subgraph.\n * @param output The output slot to rename.\n * @param name The new name for the output slot.\n */\n renameOutput(output: SubgraphOutput, name: string): void {\n const index = this.outputs.indexOf(output)\n if (index === -1) throw new Error(\"Output not found\")\n\n const oldName = output.displayName\n this.events.dispatch(\"renaming-output\", { output, index, oldName, newName: name })\n\n output.label = name\n }\n\n /**\n * Removes an input slot from the subgraph.\n * @param input The input slot to remove.\n */\n removeInput(input: SubgraphInput): void {\n input.disconnect()\n\n const index = this.inputs.indexOf(input)\n if (index === -1) throw new Error(\"Input not found\")\n\n const mayContinue = this.events.dispatch(\"removing-input\", { input, index })\n if (!mayContinue) return\n\n this.inputs.splice(index, 1)\n\n const { length } = this.inputs\n for (let i = index; i < length; i++) {\n this.inputs[i].decrementSlots(\"inputs\")\n }\n }\n\n /**\n * Removes an output slot from the subgraph.\n * @param output The output slot to remove.\n */\n removeOutput(output: SubgraphOutput): void {\n output.disconnect()\n\n const index = this.outputs.indexOf(output)\n if (index === -1) throw new Error(\"Output not found\")\n\n const mayContinue = this.events.dispatch(\"removing-output\", { output, index })\n if (!mayContinue) return\n\n this.outputs.splice(index, 1)\n\n const { length } = this.outputs\n for (let i = index; i < length; i++) {\n this.outputs[i].decrementSlots(\"outputs\")\n }\n }\n\n draw(ctx: CanvasRenderingContext2D, colorContext: DefaultConnectionColors, fromSlot?: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput, editorAlpha?: number): void {\n this.inputNode.draw(ctx, colorContext, fromSlot, editorAlpha)\n this.outputNode.draw(ctx, colorContext, fromSlot, editorAlpha)\n }\n\n /**\n * Clones the subgraph, creating an identical copy with a new ID.\n * @returns A new subgraph with the same configuration, but a new ID.\n */\n clone(keepId: boolean = false): Subgraph {\n const exported = this.asSerialisable()\n if (!keepId) exported.id = createUuidv4()\n\n const subgraph = new Subgraph(this.rootGraph, exported)\n subgraph.configure(exported)\n return subgraph\n }\n\n override asSerialisable(): ExportedSubgraph & Required<Pick<SerialisableGraph, \"nodes\" | \"groups\" | \"extra\">> {\n return {\n id: this.id,\n version: LGraph.serialisedSchemaVersion,\n state: this.state,\n revision: this.revision,\n config: this.config,\n name: this.name,\n inputNode: this.inputNode.asSerialisable(),\n outputNode: this.outputNode.asSerialisable(),\n inputs: this.inputs.map(x => x.asSerialisable()),\n outputs: this.outputs.map(x => x.asSerialisable()),\n widgets: [...this.widgets],\n nodes: this.nodes.map(node => node.serialize()),\n groups: this.groups.map(group => group.serialize()),\n links: [...this.links.values()].map(x => x.asSerialisable()),\n extra: this.extra,\n }\n }\n}\n","import type { LGraphCanvas } from \"@/LGraphCanvas\"\n\n/**\n * A class that can be added to the render cycle to show pointer / keyboard status symbols.\n *\n * Used to create videos of feature changes.\n *\n * Example usage with ComfyUI_frontend, via console / devtools:\n *\n * ```ts\n * const inputIndicators = new InputIndicators(canvas)\n * // Dispose:\n * inputIndicators.dispose()\n * ```\n */\nexport class InputIndicators implements Disposable {\n // #region config\n radius = 8\n startAngle = 0\n endAngle = Math.PI * 2\n\n inactiveColour = \"#ffffff10\"\n colour1 = \"#ff5f00\"\n colour2 = \"#00ff7c\"\n colour3 = \"#dea7ff\"\n fontString = \"bold 12px Arial\"\n // #endregion\n\n // #region state\n enabled: boolean = true\n\n shiftDown: boolean = false\n undoDown: boolean = false\n redoDown: boolean = false\n ctrlDown: boolean = false\n altDown: boolean = false\n mouse0Down: boolean = false\n mouse1Down: boolean = false\n mouse2Down: boolean = false\n\n x: number = 0\n y: number = 0\n // #endregion\n\n controller?: AbortController\n\n constructor(public canvas: LGraphCanvas) {\n this.controller = new AbortController()\n const { signal } = this.controller\n\n const element = canvas.canvas\n const options = { capture: true, signal } satisfies AddEventListenerOptions\n\n element.addEventListener(\"pointerdown\", this.#onPointerDownOrMove, options)\n element.addEventListener(\"pointermove\", this.#onPointerDownOrMove, options)\n element.addEventListener(\"pointerup\", this.#onPointerUp, options)\n element.addEventListener(\"keydown\", this.#onKeyDownOrUp, options)\n document.addEventListener(\"keyup\", this.#onKeyDownOrUp, options)\n\n const origDrawFrontCanvas = canvas.drawFrontCanvas.bind(canvas)\n signal.addEventListener(\"abort\", () => {\n canvas.drawFrontCanvas = origDrawFrontCanvas\n })\n\n canvas.drawFrontCanvas = () => {\n origDrawFrontCanvas()\n this.draw()\n }\n }\n\n #onPointerDownOrMove = this.onPointerDownOrMove.bind(this)\n onPointerDownOrMove(e: MouseEvent): void {\n this.mouse0Down = (e.buttons & 1) === 1\n this.mouse1Down = (e.buttons & 4) === 4\n this.mouse2Down = (e.buttons & 2) === 2\n\n this.x = e.clientX\n this.y = e.clientY\n\n this.canvas.setDirty(true)\n }\n\n #onPointerUp = this.onPointerUp.bind(this)\n onPointerUp(): void {\n this.mouse0Down = false\n this.mouse1Down = false\n this.mouse2Down = false\n }\n\n #onKeyDownOrUp = this.onKeyDownOrUp.bind(this)\n onKeyDownOrUp(e: KeyboardEvent): void {\n this.ctrlDown = e.ctrlKey\n this.altDown = e.altKey\n this.shiftDown = e.shiftKey\n this.undoDown = e.ctrlKey && e.code === \"KeyZ\" && e.type === \"keydown\"\n this.redoDown = e.ctrlKey && e.code === \"KeyY\" && e.type === \"keydown\"\n }\n\n draw() {\n const {\n canvas: { ctx },\n radius,\n startAngle,\n endAngle,\n x,\n y,\n inactiveColour,\n colour1,\n colour2,\n colour3,\n fontString,\n } = this\n\n const { fillStyle, font } = ctx\n\n const mouseDotX = x\n const mouseDotY = y - 80\n\n const textX = mouseDotX\n const textY = mouseDotY - 15\n ctx.font = fontString\n\n textMarker(textX + 0, textY, \"Shift\", this.shiftDown ? colour1 : inactiveColour)\n textMarker(textX + 45, textY + 20, \"Alt\", this.altDown ? colour2 : inactiveColour)\n textMarker(textX + 30, textY, \"Control\", this.ctrlDown ? colour3 : inactiveColour)\n textMarker(textX - 30, textY, \"↩️\", this.undoDown ? \"#000\" : \"transparent\")\n textMarker(textX + 45, textY, \"↪️\", this.redoDown ? \"#000\" : \"transparent\")\n\n ctx.beginPath()\n drawDot(mouseDotX, mouseDotY)\n drawDot(mouseDotX + 15, mouseDotY)\n drawDot(mouseDotX + 30, mouseDotY)\n ctx.fillStyle = inactiveColour\n ctx.fill()\n\n const leftButtonColour = this.mouse0Down ? colour1 : inactiveColour\n const middleButtonColour = this.mouse1Down ? colour2 : inactiveColour\n const rightButtonColour = this.mouse2Down ? colour3 : inactiveColour\n if (this.mouse0Down) mouseMarker(mouseDotX, mouseDotY, leftButtonColour)\n if (this.mouse1Down) mouseMarker(mouseDotX + 15, mouseDotY, middleButtonColour)\n if (this.mouse2Down) mouseMarker(mouseDotX + 30, mouseDotY, rightButtonColour)\n\n ctx.fillStyle = fillStyle\n ctx.font = font\n\n function textMarker(x: number, y: number, text: string, colour: string) {\n ctx.fillStyle = colour\n ctx.fillText(text, x, y)\n }\n\n function mouseMarker(x: number, y: number, colour: string) {\n ctx.beginPath()\n ctx.fillStyle = colour\n drawDot(x, y)\n ctx.fill()\n }\n\n function drawDot(x: number, y: number) {\n ctx.arc(x, y, radius, startAngle, endAngle)\n }\n }\n\n dispose() {\n this.controller?.abort()\n this.controller = undefined\n }\n\n [Symbol.dispose](): void {\n this.dispose()\n }\n}\n","import type { ContextMenuDivElement, IContextMenuOptions, IContextMenuValue } from \"./interfaces\"\n\nimport { LiteGraph } from \"./litegraph\"\n\n// TODO: Replace this pattern with something more modern.\nexport interface ContextMenu<TValue = unknown> {\n constructor: new (...args: ConstructorParameters<typeof ContextMenu<TValue>>) => ContextMenu<TValue>\n}\n\n/**\n * ContextMenu from LiteGUI\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class ContextMenu<TValue = unknown> {\n options: IContextMenuOptions<TValue>\n parentMenu?: ContextMenu<TValue>\n root: ContextMenuDivElement<TValue>\n current_submenu?: ContextMenu<TValue>\n lock?: boolean\n\n controller: AbortController = new AbortController()\n\n /**\n * @todo Interface for values requires functionality change - currently accepts\n * an array of strings, functions, objects, nulls, or undefined.\n * @param values (allows object { title: \"Nice text\", callback: function ... })\n * @param options [optional] Some options:\\\n * - title: title to show on top of the menu\n * - callback: function to call when an option is clicked, it receives the item information\n * - ignore_item_callbacks: ignores the callback inside the item, it just calls the options.callback\n * - event: you can pass a MouseEvent, this way the ContextMenu appears in that position\n */\n constructor(values: readonly (string | IContextMenuValue<TValue> | null)[], options: IContextMenuOptions<TValue>) {\n options ||= {}\n this.options = options\n\n // to link a menu with its parent\n const parent = options.parentMenu\n if (parent) {\n if (!(parent instanceof ContextMenu)) {\n console.error(\"parentMenu must be of class ContextMenu, ignoring it\")\n options.parentMenu = undefined\n } else {\n this.parentMenu = parent\n this.parentMenu.lock = true\n this.parentMenu.current_submenu = this\n }\n if (parent.options?.className === \"dark\") {\n options.className = \"dark\"\n }\n }\n\n // use strings because comparing classes between windows doesnt work\n const eventClass = options.event\n ? options.event.constructor.name\n : null\n if (\n eventClass !== \"MouseEvent\" &&\n eventClass !== \"CustomEvent\" &&\n eventClass !== \"PointerEvent\"\n ) {\n console.error(`Event passed to ContextMenu is not of type MouseEvent or CustomEvent. Ignoring it. (${eventClass})`)\n options.event = undefined\n }\n\n const root: ContextMenuDivElement<TValue> = document.createElement(\"div\")\n let classes = \"litegraph litecontextmenu litemenubar-panel\"\n if (options.className) classes += ` ${options.className}`\n root.className = classes\n root.style.minWidth = \"100\"\n root.style.minHeight = \"100\"\n\n // Close the context menu when a click occurs outside this context menu or its submenus\n const { signal } = this.controller\n const eventOptions = { capture: true, signal }\n\n if (!this.parentMenu) {\n document.addEventListener(\"pointerdown\", (e) => {\n if (e.target instanceof Node && !this.containsNode(e.target)) {\n this.close()\n }\n }, eventOptions)\n }\n\n // this prevents the default context browser menu to open in case this menu was created when pressing right button\n root.addEventListener(\"pointerup\", e => e.preventDefault(), eventOptions)\n\n // Right button\n root.addEventListener(\n \"contextmenu\",\n (e) => {\n if (e.button === 2) e.preventDefault()\n },\n eventOptions,\n )\n\n root.addEventListener(\n \"pointerdown\",\n (e) => {\n if (e.button == 2) {\n this.close()\n e.preventDefault()\n }\n },\n eventOptions,\n )\n\n this.root = root\n\n // title\n if (options.title) {\n const element = document.createElement(\"div\")\n element.className = \"litemenu-title\"\n element.innerHTML = options.title\n root.append(element)\n }\n\n // entries\n for (let i = 0; i < values.length; i++) {\n const value = values[i]\n let name = Array.isArray(values) ? value : String(i)\n\n if (typeof name !== \"string\") {\n name = name != null\n ? (name.content === undefined ? String(name) : name.content)\n : name\n }\n\n this.addItem(name, value, options)\n }\n\n // insert before checking position\n const ownerDocument = (options.event?.target as Node | null | undefined)?.ownerDocument\n const root_document = ownerDocument || document\n\n if (root_document.fullscreenElement)\n root_document.fullscreenElement.append(root)\n else\n root_document.body.append(root)\n\n // compute best position\n let left = options.left || 0\n let top = options.top || 0\n if (options.event) {\n left = options.event.clientX - 10\n top = options.event.clientY - 10\n if (options.title) top -= 20\n\n if (parent) {\n const rect = parent.root.getBoundingClientRect()\n left = rect.left + rect.width\n }\n\n const body_rect = document.body.getBoundingClientRect()\n const root_rect = root.getBoundingClientRect()\n if (body_rect.height == 0)\n console.error(\"document.body height is 0. That is dangerous, set html,body { height: 100%; }\")\n\n if (body_rect.width && left > body_rect.width - root_rect.width - 10)\n left = body_rect.width - root_rect.width - 10\n if (body_rect.height && top > body_rect.height - root_rect.height - 10)\n top = body_rect.height - root_rect.height - 10\n }\n\n root.style.left = `${left}px`\n root.style.top = `${top}px`\n\n if (LiteGraph.context_menu_scaling && options.scale) {\n root.style.transform = `scale(${Math.round(options.scale * 4) * 0.25})`\n }\n }\n\n /**\n * Checks if {@link node} is inside this context menu or any of its submenus\n * @param node The {@link Node} to check\n * @param visited A set of visited menus to avoid circular references\n * @returns `true` if {@link node} is inside this context menu or any of its submenus\n */\n containsNode(node: Node, visited: Set<this> = new Set()): boolean {\n if (visited.has(this)) return false\n visited.add(this)\n\n return this.current_submenu?.containsNode(node, visited) || this.root.contains(node)\n }\n\n addItem(\n name: string | null,\n value: string | IContextMenuValue<TValue> | null,\n options: IContextMenuOptions<TValue>,\n ): HTMLElement {\n options ||= {}\n\n const element: ContextMenuDivElement<TValue> = document.createElement(\"div\")\n element.className = \"litemenu-entry submenu\"\n\n let disabled = false\n\n if (value === null) {\n element.classList.add(\"separator\")\n } else {\n const innerHtml = name === null ? \"\" : String(name)\n if (typeof value === \"string\") {\n element.innerHTML = innerHtml\n } else {\n element.innerHTML = value?.title ?? innerHtml\n\n if (value.disabled) {\n disabled = true\n element.classList.add(\"disabled\")\n element.setAttribute(\"aria-disabled\", \"true\")\n }\n if (value.submenu || value.has_submenu) {\n element.classList.add(\"has_submenu\")\n element.setAttribute(\"aria-haspopup\", \"true\")\n element.setAttribute(\"aria-expanded\", \"false\")\n }\n if (value.className) element.className += ` ${value.className}`\n }\n element.value = value\n element.setAttribute(\"role\", \"menuitem\")\n\n if (typeof value === \"function\") {\n element.dataset[\"value\"] = String(name)\n element.onclick_callback = value\n } else {\n element.dataset[\"value\"] = String(value)\n }\n }\n\n this.root.append(element)\n if (!disabled) element.addEventListener(\"click\", inner_onclick)\n if (!disabled && options.autoopen)\n element.addEventListener(\"pointerenter\", inner_over)\n\n const setAriaExpanded = () => {\n const entries = this.root.querySelectorAll(\"div.litemenu-entry.has_submenu\")\n if (entries) {\n for (const entry of entries) {\n entry.setAttribute(\"aria-expanded\", \"false\")\n }\n }\n element.setAttribute(\"aria-expanded\", \"true\")\n }\n\n function inner_over(this: ContextMenuDivElement<TValue>, e: MouseEvent) {\n const value = this.value\n if (!value || !(value as IContextMenuValue).has_submenu) return\n\n // if it is a submenu, autoopen like the item was clicked\n inner_onclick.call(this, e)\n setAriaExpanded()\n }\n\n // menu option clicked\n const that = this\n function inner_onclick(this: ContextMenuDivElement<TValue>, e: MouseEvent) {\n const value = this.value\n let close_parent = true\n\n that.current_submenu?.close(e)\n if (\n (value as IContextMenuValue)?.has_submenu ||\n (value as IContextMenuValue)?.submenu\n ) {\n setAriaExpanded()\n }\n\n // global callback\n if (options.callback) {\n const r = options.callback.call(\n this,\n value,\n options,\n e,\n that,\n options.node,\n )\n if (r === true) close_parent = false\n }\n\n // special cases\n if (typeof value === \"object\") {\n if (\n value.callback &&\n !options.ignore_item_callbacks &&\n value.disabled !== true\n ) {\n // item callback\n const r = value.callback.call(\n this,\n value,\n options,\n e,\n that,\n options.extra,\n )\n if (r === true) close_parent = false\n }\n if (value.submenu) {\n if (!value.submenu.options) throw \"ContextMenu submenu needs options\"\n\n new that.constructor(value.submenu.options, {\n callback: value.submenu.callback,\n event: e,\n parentMenu: that,\n ignore_item_callbacks: value.submenu.ignore_item_callbacks,\n title: value.submenu.title,\n extra: value.submenu.extra,\n autoopen: options.autoopen,\n })\n close_parent = false\n }\n }\n\n if (close_parent && !that.lock) that.close()\n }\n\n return element\n }\n\n close(e?: MouseEvent, ignore_parent_menu?: boolean): void {\n this.controller.abort()\n this.root.remove()\n if (this.parentMenu && !ignore_parent_menu) {\n this.parentMenu.lock = false\n this.parentMenu.current_submenu = undefined\n if (e === undefined) {\n this.parentMenu.close()\n } else if (e && !ContextMenu.isCursorOverElement(e, this.parentMenu.root)) {\n ContextMenu.trigger(\n this.parentMenu.root,\n `${LiteGraph.pointerevents_method}leave`,\n e,\n )\n }\n }\n this.current_submenu?.close(e, true)\n }\n\n /** @deprecated Likely unused, however code search was inconclusive (too many results to check by hand). */\n // this code is used to trigger events easily (used in the context menu mouseleave\n static trigger(\n element: HTMLDivElement,\n event_name: string,\n params: MouseEvent,\n ): CustomEvent {\n const evt = document.createEvent(\"CustomEvent\")\n evt.initCustomEvent(event_name, true, true, params)\n if (element.dispatchEvent) element.dispatchEvent(evt)\n // else nothing seems bound here so nothing to do\n return evt\n }\n\n // returns the top most menu\n getTopMenu(): ContextMenu<TValue> {\n return this.options.parentMenu\n ? this.options.parentMenu.getTopMenu()\n : this\n }\n\n getFirstEvent(): MouseEvent | undefined {\n return this.options.parentMenu\n ? this.options.parentMenu.getFirstEvent()\n : this.options.event\n }\n\n /** @deprecated Unused. */\n static isCursorOverElement(\n event: MouseEvent,\n element: HTMLDivElement,\n ): boolean {\n const left = event.clientX\n const top = event.clientY\n const rect = element.getBoundingClientRect()\n if (!rect) return false\n\n if (\n top > rect.top &&\n top < rect.top + rect.height &&\n left > rect.left &&\n left < rect.left + rect.width\n ) {\n return true\n }\n return false\n }\n}\n","import type { Point, Rect } from \"./interfaces\"\n\nimport { clamp, LGraphCanvas } from \"./litegraph\"\nimport { distance } from \"./measure\"\n\n// used by some widgets to render a curve editor\n\nexport class CurveEditor {\n points: Point[]\n selected: number\n nearest: number\n size: Rect | null\n must_update: boolean\n margin: number\n _nearest?: number\n\n constructor(points: Point[]) {\n this.points = points\n this.selected = -1\n this.nearest = -1\n // stores last size used\n this.size = null\n this.must_update = true\n this.margin = 5\n }\n\n static sampleCurve(f: number, points: Point[]): number | undefined {\n if (!points) return\n\n for (let i = 0; i < points.length - 1; ++i) {\n const p = points[i]\n const pn = points[i + 1]\n if (pn[0] < f) continue\n\n const r = pn[0] - p[0]\n if (Math.abs(r) < 0.000_01) return p[1]\n\n const local_f = (f - p[0]) / r\n return p[1] * (1.0 - local_f) + pn[1] * local_f\n }\n return 0\n }\n\n draw(\n ctx: CanvasRenderingContext2D,\n size: Rect,\n graphcanvas?: LGraphCanvas,\n background_color?: string,\n line_color?: string,\n inactive = false,\n ): void {\n const points = this.points\n if (!points) return\n\n this.size = size\n const w = size[0] - this.margin * 2\n const h = size[1] - this.margin * 2\n\n line_color = line_color || \"#666\"\n\n ctx.save()\n ctx.translate(this.margin, this.margin)\n\n if (background_color) {\n ctx.fillStyle = \"#111\"\n ctx.fillRect(0, 0, w, h)\n ctx.fillStyle = \"#222\"\n ctx.fillRect(w * 0.5, 0, 1, h)\n ctx.strokeStyle = \"#333\"\n ctx.strokeRect(0, 0, w, h)\n }\n ctx.strokeStyle = line_color\n if (inactive) ctx.globalAlpha = 0.5\n ctx.beginPath()\n for (const p of points) {\n ctx.lineTo(p[0] * w, (1.0 - p[1]) * h)\n }\n ctx.stroke()\n ctx.globalAlpha = 1\n if (!inactive) {\n for (const [i, p] of points.entries()) {\n ctx.fillStyle = this.selected == i\n ? \"#FFF\"\n : (this.nearest == i ? \"#DDD\" : \"#AAA\")\n ctx.beginPath()\n ctx.arc(p[0] * w, (1.0 - p[1]) * h, 2, 0, Math.PI * 2)\n ctx.fill()\n }\n }\n ctx.restore()\n }\n\n // localpos is mouse in curve editor space\n onMouseDown(localpos: Point, graphcanvas: LGraphCanvas): boolean | undefined {\n const points = this.points\n if (!points) return\n if (localpos[1] < 0) return\n\n // this.captureInput(true);\n if (this.size == null) throw new Error(\"CurveEditor.size was null or undefined.\")\n const w = this.size[0] - this.margin * 2\n const h = this.size[1] - this.margin * 2\n const x = localpos[0] - this.margin\n const y = localpos[1] - this.margin\n const pos: Point = [x, y]\n const max_dist = 30 / graphcanvas.ds.scale\n // search closer one\n this.selected = this.getCloserPoint(pos, max_dist)\n // create one\n if (this.selected == -1) {\n const point: Point = [x / w, 1 - y / h]\n points.push(point)\n points.sort(function (a, b) {\n return a[0] - b[0]\n })\n this.selected = points.indexOf(point)\n this.must_update = true\n }\n if (this.selected != -1) return true\n }\n\n onMouseMove(localpos: Point, graphcanvas: LGraphCanvas): void {\n const points = this.points\n if (!points) return\n\n const s = this.selected\n if (s < 0) return\n\n if (this.size == null) throw new Error(\"CurveEditor.size was null or undefined.\")\n const x = (localpos[0] - this.margin) / (this.size[0] - this.margin * 2)\n const y = (localpos[1] - this.margin) / (this.size[1] - this.margin * 2)\n const curvepos: Point = [\n localpos[0] - this.margin,\n localpos[1] - this.margin,\n ]\n const max_dist = 30 / graphcanvas.ds.scale\n this._nearest = this.getCloserPoint(curvepos, max_dist)\n const point = points[s]\n if (point) {\n const is_edge_point = s == 0 || s == points.length - 1\n if (\n !is_edge_point &&\n (localpos[0] < -10 ||\n localpos[0] > this.size[0] + 10 ||\n localpos[1] < -10 ||\n localpos[1] > this.size[1] + 10)\n ) {\n points.splice(s, 1)\n this.selected = -1\n return\n }\n // not edges\n if (!is_edge_point) point[0] = clamp(x, 0, 1)\n else point[0] = s == 0 ? 0 : 1\n point[1] = 1.0 - clamp(y, 0, 1)\n points.sort(function (a, b) {\n return a[0] - b[0]\n })\n this.selected = points.indexOf(point)\n this.must_update = true\n }\n }\n\n // Former params: localpos, graphcanvas\n onMouseUp(): boolean {\n this.selected = -1\n return false\n }\n\n getCloserPoint(pos: Point, max_dist: number): number {\n const points = this.points\n if (!points) return -1\n\n max_dist = max_dist || 30\n if (this.size == null) throw new Error(\"CurveEditor.size was null or undefined.\")\n const w = this.size[0] - this.margin * 2\n const h = this.size[1] - this.margin * 2\n const num = points.length\n const p2: Point = [0, 0]\n let min_dist = 1_000_000\n let closest = -1\n\n for (let i = 0; i < num; ++i) {\n const p = points[i]\n p2[0] = p[0] * w\n p2[1] = (1.0 - p[1]) * h\n const dist = distance(pos, p2)\n if (dist > min_dist || dist > max_dist) continue\n\n closest = i\n min_dist = dist\n }\n return closest\n }\n}\n","import type { Dictionary, ISlotType, Rect, WhenNullish } from \"./interfaces\"\n\nimport { InputIndicators } from \"./canvas/InputIndicators\"\nimport { ContextMenu } from \"./ContextMenu\"\nimport { CurveEditor } from \"./CurveEditor\"\nimport { DragAndScale } from \"./DragAndScale\"\nimport { LabelPosition, SlotDirection, SlotShape, SlotType } from \"./draw\"\nimport { Rectangle } from \"./infrastructure/Rectangle\"\nimport { LGraph } from \"./LGraph\"\nimport { LGraphCanvas } from \"./LGraphCanvas\"\nimport { LGraphGroup } from \"./LGraphGroup\"\nimport { LGraphNode } from \"./LGraphNode\"\nimport { LLink } from \"./LLink\"\nimport { distance, isInsideRectangle, overlapBounding } from \"./measure\"\nimport { Reroute } from \"./Reroute\"\nimport { SubgraphIONodeBase } from \"./subgraph/SubgraphIONodeBase\"\nimport { SubgraphSlot } from \"./subgraph/SubgraphSlotBase\"\nimport {\n LGraphEventMode,\n LinkDirection,\n LinkRenderType,\n NodeSlotType,\n RenderShape,\n TitleMode,\n} from \"./types/globalEnums\"\nimport { createUuidv4 } from \"./utils/uuid\"\n\n/**\n * The Global Scope. It contains all the registered node classes.\n */\nexport class LiteGraphGlobal {\n // Enums\n SlotShape = SlotShape\n SlotDirection = SlotDirection\n SlotType = SlotType\n LabelPosition = LabelPosition\n\n /** Used in serialised graphs at one point. */\n VERSION = 0.4 as const\n\n CANVAS_GRID_SIZE = 10\n\n NODE_TITLE_HEIGHT = 30\n NODE_TITLE_TEXT_Y = 20\n NODE_SLOT_HEIGHT = 20\n NODE_WIDGET_HEIGHT = 20\n NODE_WIDTH = 140\n NODE_MIN_WIDTH = 50\n NODE_COLLAPSED_RADIUS = 10\n NODE_COLLAPSED_WIDTH = 80\n NODE_TITLE_COLOR = \"#999\"\n NODE_SELECTED_TITLE_COLOR = \"#FFF\"\n NODE_TEXT_SIZE = 14\n NODE_TEXT_COLOR = \"#AAA\"\n NODE_TEXT_HIGHLIGHT_COLOR = \"#EEE\"\n NODE_SUBTEXT_SIZE = 12\n NODE_DEFAULT_COLOR = \"#333\"\n NODE_DEFAULT_BGCOLOR = \"#353535\"\n NODE_DEFAULT_BOXCOLOR = \"#666\"\n NODE_DEFAULT_SHAPE = RenderShape.ROUND\n NODE_BOX_OUTLINE_COLOR = \"#FFF\"\n NODE_ERROR_COLOUR = \"#E00\"\n NODE_FONT = \"Arial\"\n\n DEFAULT_FONT = \"Arial\"\n DEFAULT_SHADOW_COLOR = \"rgba(0,0,0,0.5)\"\n\n DEFAULT_GROUP_FONT = 24\n DEFAULT_GROUP_FONT_SIZE?: any\n GROUP_FONT = \"Arial\"\n\n WIDGET_BGCOLOR = \"#222\"\n WIDGET_OUTLINE_COLOR = \"#666\"\n WIDGET_ADVANCED_OUTLINE_COLOR = \"rgba(56, 139, 253, 0.8)\"\n WIDGET_TEXT_COLOR = \"#DDD\"\n WIDGET_SECONDARY_TEXT_COLOR = \"#999\"\n WIDGET_DISABLED_TEXT_COLOR = \"#666\"\n\n LINK_COLOR = \"#9A9\"\n EVENT_LINK_COLOR = \"#A86\"\n CONNECTING_LINK_COLOR = \"#AFA\"\n\n /** avoid infinite loops */\n MAX_NUMBER_OF_NODES = 10_000\n /** default node position */\n DEFAULT_POSITION = [100, 100]\n /** ,\"circle\" */\n VALID_SHAPES = [\"default\", \"box\", \"round\", \"card\"] satisfies (\"default\" | Lowercase<keyof typeof RenderShape>)[]\n ROUND_RADIUS = 8\n\n // shapes are used for nodes but also for slots\n BOX_SHAPE = RenderShape.BOX\n ROUND_SHAPE = RenderShape.ROUND\n CIRCLE_SHAPE = RenderShape.CIRCLE\n CARD_SHAPE = RenderShape.CARD\n ARROW_SHAPE = RenderShape.ARROW\n /** intended for slot arrays */\n GRID_SHAPE = RenderShape.GRID\n\n // enums\n INPUT = NodeSlotType.INPUT\n OUTPUT = NodeSlotType.OUTPUT\n\n // TODO: -1 can lead to ambiguity in JS; these should be updated to a more explicit constant or Symbol.\n /** for outputs */\n EVENT = -1 as const\n /** for inputs */\n ACTION = -1 as const\n\n /** helper, will add \"On Request\" and more in the future */\n NODE_MODES = [\"Always\", \"On Event\", \"Never\", \"On Trigger\"]\n /** use with node_box_coloured_by_mode */\n NODE_MODES_COLORS = [\"#666\", \"#422\", \"#333\", \"#224\", \"#626\"]\n ALWAYS = LGraphEventMode.ALWAYS\n ON_EVENT = LGraphEventMode.ON_EVENT\n NEVER = LGraphEventMode.NEVER\n ON_TRIGGER = LGraphEventMode.ON_TRIGGER\n\n UP = LinkDirection.UP\n DOWN = LinkDirection.DOWN\n LEFT = LinkDirection.LEFT\n RIGHT = LinkDirection.RIGHT\n CENTER = LinkDirection.CENTER\n\n /** helper */\n LINK_RENDER_MODES = [\"Straight\", \"Linear\", \"Spline\"]\n HIDDEN_LINK = LinkRenderType.HIDDEN_LINK\n STRAIGHT_LINK = LinkRenderType.STRAIGHT_LINK\n LINEAR_LINK = LinkRenderType.LINEAR_LINK\n SPLINE_LINK = LinkRenderType.SPLINE_LINK\n\n NORMAL_TITLE = TitleMode.NORMAL_TITLE\n NO_TITLE = TitleMode.NO_TITLE\n TRANSPARENT_TITLE = TitleMode.TRANSPARENT_TITLE\n AUTOHIDE_TITLE = TitleMode.AUTOHIDE_TITLE\n\n /** arrange nodes vertically */\n VERTICAL_LAYOUT = \"vertical\"\n\n /** used to redirect calls */\n proxy = null\n node_images_path = \"\"\n\n debug = false\n catch_exceptions = true\n throw_errors = true\n /** if set to true some nodes like Formula would be allowed to evaluate code that comes from unsafe sources (like node configuration), which could lead to exploits */\n allow_scripts = false\n /** nodetypes by string */\n registered_node_types: Record<string, typeof LGraphNode> = {}\n /** @deprecated used for dropping files in the canvas. It appears the code that enables this was removed, but the object remains and is references by built-in drag drop. */\n node_types_by_file_extension: Record<string, { type: string }> = {}\n /** node types by classname */\n Nodes: Record<string, typeof LGraphNode> = {}\n /** used to store vars between graphs */\n Globals = {}\n\n /** @deprecated Unused and will be deleted. */\n searchbox_extras: Dictionary<unknown> = {}\n\n /** [true!] this make the nodes box (top left circle) coloured when triggered (execute/action), visual feedback */\n node_box_coloured_when_on = false\n /** [true!] nodebox based on node mode, visual feedback */\n node_box_coloured_by_mode = false\n\n /** [false on mobile] better true if not touch device, TODO add an helper/listener to close if false */\n dialog_close_on_mouse_leave = false\n dialog_close_on_mouse_leave_delay = 500\n\n /** [false!] prefer false if results too easy to break links - implement with ALT or TODO custom keys */\n shift_click_do_break_link_from = false\n /** [false!]prefer false, way too easy to break links */\n click_do_break_link_to = false\n /** [true!] who accidentally ctrl-alt-clicks on an in/output? nobody! that's who! */\n ctrl_alt_click_do_break_link = true\n /** [true!] snaps links when dragging connections over valid targets */\n snaps_for_comfy = true\n /** [true!] renders a partial border to highlight when a dragged link is snapped to a node */\n snap_highlights_node = true\n\n /**\n * If `true`, items always snap to the grid - modifier keys are ignored.\n * When {@link snapToGrid} is falsy, a value of `1` is used.\n * Default: `false`\n */\n alwaysSnapToGrid?: boolean\n\n /**\n * When set to a positive number, when nodes are moved their positions will\n * be rounded to the nearest multiple of this value. Half up.\n * Default: `undefined`\n * @todo Not implemented - see {@link LiteGraph.CANVAS_GRID_SIZE}\n */\n snapToGrid?: number\n\n /** [false on mobile] better true if not touch device, TODO add an helper/listener to close if false */\n search_hide_on_mouse_leave = true\n /**\n * [true!] enable filtering slots type in the search widget\n * !requires auto_load_slot_types or manual set registered_slot_[in/out]_types and slot_types_[in/out]\n */\n search_filter_enabled = false\n /** [true!] opens the results list when opening the search widget */\n search_show_all_on_open = true\n\n /**\n * [if want false, use true, run, get vars values to be statically set, than disable]\n * nodes types and nodeclass association with node types need to be calculated,\n * if dont want this, calculate once and set registered_slot_[in/out]_types and slot_types_[in/out]\n */\n auto_load_slot_types = false\n\n // set these values if not using auto_load_slot_types\n /** slot types for nodeclass */\n registered_slot_in_types: Record<string, { nodes: string[] }> = {}\n /** slot types for nodeclass */\n registered_slot_out_types: Record<string, { nodes: string[] }> = {}\n /** slot types IN */\n slot_types_in: string[] = []\n /** slot types OUT */\n slot_types_out: string[] = []\n /**\n * specify for each IN slot type a(/many) default node(s), use single string, array, or object\n * (with node, title, parameters, ..) like for search\n */\n slot_types_default_in: Record<string, string[]> = {}\n /**\n * specify for each OUT slot type a(/many) default node(s), use single string, array, or object\n * (with node, title, parameters, ..) like for search\n */\n slot_types_default_out: Record<string, string[]> = {}\n\n /** [true!] very handy, ALT click to clone and drag the new node */\n alt_drag_do_clone_nodes = false\n\n /**\n * [true!] will create and connect event slots when using action/events connections,\n * !WILL CHANGE node mode when using onTrigger (enable mode colors), onExecuted does not need this\n */\n do_add_triggers_slots = false\n\n /** [false!] being events, it is strongly reccomended to use them sequentially, one by one */\n allow_multi_output_for_events = true\n\n /** [true!] allows to create and connect a ndoe clicking with the third button (wheel) */\n middle_click_slot_add_default_node = false\n\n /** [true!] dragging a link to empty space will open a menu, add from list, search or defaults */\n release_link_on_empty_shows_menu = false\n\n /** \"mouse\"|\"pointer\" use mouse for retrocompatibility issues? (none found @ now) */\n pointerevents_method = \"pointer\"\n\n /**\n * [true!] allows ctrl + shift + v to paste nodes with the outputs of the unselected nodes connected\n * with the inputs of the newly pasted nodes\n */\n ctrl_shift_v_paste_connect_unselected_outputs = true\n\n // if true, all newly created nodes/links will use string UUIDs for their id fields instead of integers.\n // use this if you must have node IDs that are unique across all graphs and subgraphs.\n use_uuids = false\n\n // Whether to highlight the bounding box of selected groups\n highlight_selected_group = true\n\n /** Whether to scale context with the graph when zooming in. Zooming out never makes context menus smaller. */\n context_menu_scaling = false\n\n /**\n * Debugging flag. Repeats deprecation warnings every time they are reported.\n * May impact performance.\n */\n alwaysRepeatWarnings: boolean = false\n\n /**\n * Array of callbacks to execute when Litegraph first reports a deprecated API being used.\n * @see alwaysRepeatWarnings By default, will not repeat identical messages.\n */\n onDeprecationWarning: ((message: string, source?: object) => void)[] = [console.warn]\n\n /**\n * If `true`, mouse wheel events will be interpreted as trackpad gestures.\n * Tested on MacBook M4 Pro.\n * @default false\n * @see macGesturesRequireMac\n */\n macTrackpadGestures: boolean = false\n\n /**\n * If both this setting and {@link macTrackpadGestures} are `true`, trackpad gestures will\n * only be enabled when the browser user agent includes \"Mac\".\n * @default true\n * @see macTrackpadGestures\n */\n macGesturesRequireMac: boolean = true\n\n /**\n * \"standard\": change the dragging on left mouse button click to select, enable middle-click or spacebar+left-click dragging\n * \"legacy\": Enable dragging on left-click (original behavior)\n * @default \"legacy\"\n */\n canvasNavigationMode: \"standard\" | \"legacy\" = \"legacy\"\n\n /**\n * If `true`, widget labels and values will both be truncated (proportionally to size),\n * until they fit within the widget.\n *\n * Otherwise, the label will be truncated completely before the value is truncated.\n * @default false\n */\n truncateWidgetTextEvenly: boolean = false\n\n /**\n * If `true`, widget values will be completely truncated when shrinking a widget,\n * before truncating widget labels. {@link truncateWidgetTextEvenly} must be `false`.\n * @default false\n */\n truncateWidgetValuesFirst: boolean = false\n\n /**\n * If `true`, the current viewport scale & offset of the first attached canvas will be included with the graph when exporting.\n * @default true\n */\n saveViewportWithGraph: boolean = true\n\n // TODO: Remove legacy accessors\n LGraph = LGraph\n LLink = LLink\n LGraphNode = LGraphNode\n LGraphGroup = LGraphGroup\n DragAndScale = DragAndScale\n LGraphCanvas = LGraphCanvas\n ContextMenu = ContextMenu\n CurveEditor = CurveEditor\n Reroute = Reroute\n\n constructor() {\n Object.defineProperty(this, \"Classes\", { writable: false })\n }\n\n Classes = {\n get SubgraphSlot() { return SubgraphSlot },\n get SubgraphIONodeBase() { return SubgraphIONodeBase },\n\n // Rich drawing\n get Rectangle() { return Rectangle },\n\n // Debug / helpers\n get InputIndicators() { return InputIndicators },\n }\n\n onNodeTypeRegistered?(type: string, base_class: typeof LGraphNode): void\n onNodeTypeReplaced?(type: string, base_class: typeof LGraphNode, prev: unknown): void\n\n /**\n * Register a node class so it can be listed when the user wants to create a new one\n * @param type name of the node and path\n * @param base_class class containing the structure of a node\n */\n registerNodeType(type: string, base_class: typeof LGraphNode): void {\n if (!base_class.prototype)\n throw \"Cannot register a simple object, it must be a class with a prototype\"\n base_class.type = type\n\n if (this.debug) console.log(\"Node registered:\", type)\n\n const classname = base_class.name\n\n const pos = type.lastIndexOf(\"/\")\n base_class.category = type.substring(0, pos)\n\n base_class.title ||= classname\n\n // extend class\n for (const i in LGraphNode.prototype) {\n // @ts-expect-error #576 This functionality is deprecated and should be removed.\n base_class.prototype[i] ||= LGraphNode.prototype[i]\n }\n\n const prev = this.registered_node_types[type]\n if (prev && this.debug) {\n console.log(\"replacing node type:\", type)\n }\n\n this.registered_node_types[type] = base_class\n if (base_class.constructor.name) this.Nodes[classname] = base_class\n\n this.onNodeTypeRegistered?.(type, base_class)\n if (prev) this.onNodeTypeReplaced?.(type, base_class, prev)\n\n // warnings\n if (base_class.prototype.onPropertyChange)\n console.warn(`LiteGraph node class ${type} has onPropertyChange method, it must be called onPropertyChanged with d at the end`)\n\n // TODO one would want to know input and ouput :: this would allow through registerNodeAndSlotType to get all the slots types\n if (this.auto_load_slot_types) new base_class(base_class.title || \"tmpnode\")\n }\n\n /**\n * removes a node type from the system\n * @param type name of the node or the node constructor itself\n */\n unregisterNodeType(type: string | typeof LGraphNode): void {\n const base_class = typeof type === \"string\"\n ? this.registered_node_types[type]\n : type\n if (!base_class) throw `node type not found: ${String(type)}`\n\n delete this.registered_node_types[String(base_class.type)]\n\n const name = base_class.constructor.name\n if (name) delete this.Nodes[name]\n }\n\n /**\n * Save a slot type and his node\n * @param type name of the node or the node constructor itself\n * @param slot_type name of the slot type (variable type), eg. string, number, array, boolean, ..\n */\n registerNodeAndSlotType(\n type: LGraphNode,\n slot_type: ISlotType,\n out?: boolean,\n ): void {\n out ||= false\n // @ts-expect-error Confirm this function no longer supports string types - base_class should always be an instance not a constructor.\n const base_class = typeof type === \"string\" && this.registered_node_types[type] !== \"anonymous\"\n ? this.registered_node_types[type]\n : type\n\n // @ts-expect-error Confirm this function no longer supports string types - base_class should always be an instance not a constructor.\n const class_type = base_class.constructor.type\n\n let allTypes = []\n if (typeof slot_type === \"string\") {\n allTypes = slot_type.split(\",\")\n } else if (slot_type == this.EVENT || slot_type == this.ACTION) {\n allTypes = [\"_event_\"]\n } else {\n allTypes = [\"*\"]\n }\n\n for (let slotType of allTypes) {\n if (slotType === \"\") slotType = \"*\"\n\n const register = out\n ? this.registered_slot_out_types\n : this.registered_slot_in_types\n register[slotType] ??= { nodes: [] }\n\n const { nodes } = register[slotType]\n if (!nodes.includes(class_type)) nodes.push(class_type)\n\n // check if is a new type\n const types = out\n ? this.slot_types_out\n : this.slot_types_in\n const type = slotType.toLowerCase()\n\n if (!types.includes(type)) {\n types.push(type)\n types.sort()\n }\n }\n }\n\n /**\n * Removes all previously registered node's types\n */\n clearRegisteredTypes(): void {\n this.registered_node_types = {}\n this.node_types_by_file_extension = {}\n this.Nodes = {}\n this.searchbox_extras = {}\n }\n\n /**\n * Create a node of a given type with a name. The node is not attached to any graph yet.\n * @param type full name of the node class. p.e. \"math/sin\"\n * @param title a name to distinguish from other nodes\n * @param options to set options\n */\n createNode(\n type: string,\n title?: string,\n options?: Dictionary<unknown>,\n ): LGraphNode | null {\n const base_class = this.registered_node_types[type]\n if (!base_class) {\n if (this.debug) console.log(`GraphNode type \"${type}\" not registered.`)\n return null\n }\n\n title = title || base_class.title || type\n\n let node = null\n\n if (this.catch_exceptions) {\n try {\n node = new base_class(title)\n } catch (error) {\n console.error(error)\n return null\n }\n } else {\n node = new base_class(title)\n }\n\n node.type = type\n\n if (!node.title && title) node.title = title\n node.properties ||= {}\n node.properties_info ||= []\n node.flags ||= {}\n // call onresize?\n node.size ||= node.computeSize()\n node.pos ||= [this.DEFAULT_POSITION[0], this.DEFAULT_POSITION[1]]\n node.mode ||= LGraphEventMode.ALWAYS\n\n // extra options\n if (options) {\n for (const i in options) {\n // @ts-expect-error #577 Requires interface\n node[i] = options[i]\n }\n }\n\n // callback\n node.onNodeCreated?.()\n return node\n }\n\n /**\n * Returns a registered node type with a given name\n * @param type full name of the node class. p.e. \"math/sin\"\n * @returns the node class\n */\n getNodeType(type: string): typeof LGraphNode {\n return this.registered_node_types[type]\n }\n\n /**\n * Returns a list of node types matching one category\n * @param category category name\n * @returns array with all the node classes\n */\n getNodeTypesInCategory(category: string, filter?: string) {\n const r = []\n for (const i in this.registered_node_types) {\n const type = this.registered_node_types[i]\n if (type.filter != filter) continue\n\n if (category == \"\") {\n if (type.category == null) r.push(type)\n } else if (type.category == category) {\n r.push(type)\n }\n }\n\n return r\n }\n\n /**\n * Returns a list with all the node type categories\n * @param filter only nodes with ctor.filter equal can be shown\n * @returns array with all the names of the categories\n */\n getNodeTypesCategories(filter?: string): string[] {\n const categories: Dictionary<number> = { \"\": 1 }\n for (const i in this.registered_node_types) {\n const type = this.registered_node_types[i]\n if (type.category && !type.skip_list) {\n if (type.filter != filter) continue\n\n categories[type.category] = 1\n }\n }\n const result = []\n for (const i in categories) {\n result.push(i)\n }\n return result\n }\n\n // debug purposes: reloads all the js scripts that matches a wildcard\n reloadNodes(folder_wildcard: string): void {\n const tmp = document.getElementsByTagName(\"script\")\n // weird, this array changes by its own, so we use a copy\n const script_files = []\n for (const element of tmp) {\n script_files.push(element)\n }\n\n const docHeadObj = document.getElementsByTagName(\"head\")[0]\n folder_wildcard = document.location.href + folder_wildcard\n\n for (const script_file of script_files) {\n const src = script_file.src\n if (!src || src.substr(0, folder_wildcard.length) != folder_wildcard)\n continue\n\n try {\n if (this.debug) console.log(\"Reloading:\", src)\n const dynamicScript = document.createElement(\"script\")\n dynamicScript.type = \"text/javascript\"\n dynamicScript.src = src\n docHeadObj.append(dynamicScript)\n script_file.remove()\n } catch (error) {\n if (this.throw_errors) throw error\n if (this.debug) console.log(\"Error while reloading\", src)\n }\n }\n\n if (this.debug) console.log(\"Nodes reloaded\")\n }\n\n // separated just to improve if it doesn't work\n /** @deprecated Prefer {@link structuredClone} */\n cloneObject<T extends object | undefined | null>(obj: T, target?: T): WhenNullish<T, null> {\n if (obj == null) return null as WhenNullish<T, null>\n\n const r = JSON.parse(JSON.stringify(obj))\n if (!target) return r\n\n for (const i in r) {\n // @ts-expect-error deprecated\n target[i] = r[i]\n }\n return target\n }\n\n /** @see {@link createUuidv4} @inheritdoc */\n uuidv4 = createUuidv4\n\n /**\n * Returns if the types of two slots are compatible (taking into account wildcards, etc)\n * @param type_a output\n * @param type_b input\n * @returns true if they can be connected\n */\n isValidConnection(type_a: ISlotType, type_b: ISlotType): boolean {\n if (type_a == \"\" || type_a === \"*\") type_a = 0\n if (type_b == \"\" || type_b === \"*\") type_b = 0\n // If generic in/output, matching types (valid for triggers), or event/action types\n if (\n !type_a ||\n !type_b ||\n type_a == type_b ||\n (type_a == this.EVENT && type_b == this.ACTION)\n ) {\n return true\n }\n\n // Enforce string type to handle toLowerCase call (-1 number not ok)\n type_a = String(type_a)\n type_b = String(type_b)\n type_a = type_a.toLowerCase()\n type_b = type_b.toLowerCase()\n\n // For nodes supporting multiple connection types\n if (!type_a.includes(\",\") && !type_b.includes(\",\"))\n return type_a == type_b\n\n // Check all permutations to see if one is valid\n const supported_types_a = type_a.split(\",\")\n const supported_types_b = type_b.split(\",\")\n for (const a of supported_types_a) {\n for (const b of supported_types_b) {\n if (this.isValidConnection(a, b))\n return true\n }\n }\n\n return false\n }\n\n // used to create nodes from wrapping functions\n getParameterNames(func: (...args: any) => any): string[] {\n return String(func)\n .replaceAll(/\\/\\/.*$/gm, \"\") // strip single-line comments\n .replaceAll(/\\s+/g, \"\") // strip white space\n .replaceAll(/\\/\\*[^*/]*\\*\\//g, \"\") // strip multi-line comments /**/\n .split(\"){\", 1)[0]\n .replace(/^[^(]*\\(/, \"\") // extract the parameters\n .replaceAll(/=[^,]+/g, \"\") // strip any ES6 defaults\n .split(\",\")\n .filter(Boolean) // split & filter [\"\"]\n }\n\n /* helper for interaction: pointer, touch, mouse Listeners\n used by LGraphCanvas DragAndScale ContextMenu */\n pointerListenerAdd(oDOM: Node, sEvIn: string, fCall: (e: Event) => boolean | void, capture = false): void {\n if (!oDOM || !oDOM.addEventListener || !sEvIn || typeof fCall !== \"function\") return\n\n let sMethod = this.pointerevents_method\n let sEvent = sEvIn\n\n // UNDER CONSTRUCTION\n // convert pointerevents to touch event when not available\n if (sMethod == \"pointer\" && !window.PointerEvent) {\n console.warn(\"sMethod=='pointer' && !window.PointerEvent\")\n console.log(`Converting pointer[${sEvent}] : down move up cancel enter TO touchstart touchmove touchend, etc ..`)\n switch (sEvent) {\n case \"down\": {\n sMethod = \"touch\"\n sEvent = \"start\"\n break\n }\n case \"move\": {\n sMethod = \"touch\"\n // sEvent = \"move\";\n break\n }\n case \"up\": {\n sMethod = \"touch\"\n sEvent = \"end\"\n break\n }\n case \"cancel\": {\n sMethod = \"touch\"\n // sEvent = \"cancel\";\n break\n }\n case \"enter\": {\n console.log(\"debug: Should I send a move event?\") // ???\n break\n }\n // case \"over\": case \"out\": not used at now\n default: {\n console.warn(`PointerEvent not available in this browser ? The event ${sEvent} would not be called`)\n }\n }\n }\n\n switch (sEvent) {\n // @ts-expect-error\n // both pointer and move events\n case \"down\": case \"up\": case \"move\": case \"over\": case \"out\": case \"enter\":\n {\n oDOM.addEventListener(sMethod + sEvent, fCall, capture)\n }\n // @ts-expect-error\n // only pointerevents\n case \"leave\": case \"cancel\": case \"gotpointercapture\": case \"lostpointercapture\":\n {\n if (sMethod != \"mouse\") {\n return oDOM.addEventListener(sMethod + sEvent, fCall, capture)\n }\n }\n // not \"pointer\" || \"mouse\"\n default:\n return oDOM.addEventListener(sEvent, fCall, capture)\n }\n }\n\n pointerListenerRemove(oDOM: Node, sEvent: string, fCall: (e: Event) => boolean | void, capture = false): void {\n if (!oDOM || !oDOM.removeEventListener || !sEvent || typeof fCall !== \"function\") return\n\n switch (sEvent) {\n // @ts-expect-error\n // both pointer and move events\n case \"down\": case \"up\": case \"move\": case \"over\": case \"out\": case \"enter\":\n {\n if (this.pointerevents_method == \"pointer\" || this.pointerevents_method == \"mouse\") {\n oDOM.removeEventListener(this.pointerevents_method + sEvent, fCall, capture)\n }\n }\n // @ts-expect-error\n // only pointerevents\n case \"leave\": case \"cancel\": case \"gotpointercapture\": case \"lostpointercapture\":\n {\n if (this.pointerevents_method == \"pointer\") {\n return oDOM.removeEventListener(this.pointerevents_method + sEvent, fCall, capture)\n }\n }\n // not \"pointer\" || \"mouse\"\n default:\n return oDOM.removeEventListener(sEvent, fCall, capture)\n }\n }\n\n getTime(): number {\n return performance.now()\n }\n\n distance = distance\n\n colorToString(c: [number, number, number, number]): string {\n return (\n `rgba(${\n Math.round(c[0] * 255).toFixed()\n },${\n Math.round(c[1] * 255).toFixed()\n },${\n Math.round(c[2] * 255).toFixed()\n },${\n c.length == 4 ? c[3].toFixed(2) : \"1.0\"\n })`\n )\n }\n\n isInsideRectangle = isInsideRectangle\n\n // [minx,miny,maxx,maxy]\n growBounding(bounding: Rect, x: number, y: number): void {\n if (x < bounding[0]) {\n bounding[0] = x\n } else if (x > bounding[2]) {\n bounding[2] = x\n }\n\n if (y < bounding[1]) {\n bounding[1] = y\n } else if (y > bounding[3]) {\n bounding[3] = y\n }\n }\n\n overlapBounding = overlapBounding\n\n // point inside bounding box\n isInsideBounding(p: number[], bb: number[][]): boolean {\n if (\n p[0] < bb[0][0] ||\n p[1] < bb[0][1] ||\n p[0] > bb[1][0] ||\n p[1] > bb[1][1]\n ) {\n return false\n }\n return true\n }\n\n // Convert a hex value to its decimal value - the inputted hex must be in the\n // format of a hex triplet - the kind we use for HTML colours. The function\n // will return an array with three values.\n hex2num(hex: string): number[] {\n if (hex.charAt(0) == \"#\") {\n hex = hex.slice(1)\n // Remove the '#' char - if there is one.\n }\n hex = hex.toUpperCase()\n const hex_alphabets = \"0123456789ABCDEF\"\n const value = new Array(3)\n let k = 0\n let int1, int2\n for (let i = 0; i < 6; i += 2) {\n int1 = hex_alphabets.indexOf(hex.charAt(i))\n int2 = hex_alphabets.indexOf(hex.charAt(i + 1))\n value[k] = int1 * 16 + int2\n k++\n }\n return value\n }\n\n // Give a array with three values as the argument and the function will return\n // the corresponding hex triplet.\n num2hex(triplet: number[]): string {\n const hex_alphabets = \"0123456789ABCDEF\"\n let hex = \"#\"\n let int1, int2\n for (let i = 0; i < 3; i++) {\n int1 = triplet[i] / 16\n int2 = triplet[i] % 16\n\n hex += hex_alphabets.charAt(int1) + hex_alphabets.charAt(int2)\n }\n return hex\n }\n\n closeAllContextMenus(ref_window: Window = window): void {\n const elements = [...ref_window.document.querySelectorAll(\".litecontextmenu\")]\n if (!elements.length) return\n\n for (const element of elements) {\n if (\"close\" in element && typeof element.close === \"function\") {\n element.close()\n } else {\n element.remove()\n }\n }\n }\n\n extendClass(target: any, origin: any): void {\n for (const i in origin) {\n // copy class properties\n if (target.hasOwnProperty(i)) continue\n target[i] = origin[i]\n }\n\n if (origin.prototype) {\n // copy prototype properties\n for (const i in origin.prototype) {\n // only enumerable\n if (!origin.prototype.hasOwnProperty(i)) continue\n\n // avoid overwriting existing ones\n if (target.prototype.hasOwnProperty(i)) continue\n\n // copy getters\n if (origin.prototype.__lookupGetter__(i)) {\n target.prototype.__defineGetter__(\n i,\n origin.prototype.__lookupGetter__(i),\n )\n } else {\n target.prototype[i] = origin.prototype[i]\n }\n\n // and setters\n if (origin.prototype.__lookupSetter__(i)) {\n target.prototype.__defineSetter__(\n i,\n origin.prototype.__lookupSetter__(i),\n )\n }\n }\n }\n }\n}\n","// @ts-expect-error Polyfill\nSymbol.dispose ??= Symbol(\"Symbol.dispose\")\n// @ts-expect-error Polyfill\nSymbol.asyncDispose ??= Symbol(\"Symbol.asyncDispose\")\n\n// API *************************************************\n// like rect but rounded corners\nexport function loadPolyfills() {\n if (\n typeof window != \"undefined\" &&\n window.CanvasRenderingContext2D &&\n !window.CanvasRenderingContext2D.prototype.roundRect\n ) {\n // @ts-expect-error Slightly broken polyfill - radius_low not impl. anywhere\n window.CanvasRenderingContext2D.prototype.roundRect = function (\n x: number,\n y: number,\n w: number,\n h: number,\n radius: number | number[],\n radius_low: number | number[],\n ) {\n let top_left_radius = 0\n let top_right_radius = 0\n let bottom_left_radius = 0\n let bottom_right_radius = 0\n\n if (radius === 0) {\n this.rect(x, y, w, h)\n return\n }\n\n if (radius_low === undefined) radius_low = radius\n\n // make it compatible with official one\n if (Array.isArray(radius)) {\n if (radius.length == 1) {\n top_left_radius = top_right_radius = bottom_left_radius = bottom_right_radius = radius[0]\n } else if (radius.length == 2) {\n top_left_radius = bottom_right_radius = radius[0]\n top_right_radius = bottom_left_radius = radius[1]\n } else if (radius.length == 4) {\n top_left_radius = radius[0]\n top_right_radius = radius[1]\n bottom_left_radius = radius[2]\n bottom_right_radius = radius[3]\n } else {\n return\n }\n } else {\n // old using numbers\n top_left_radius = radius || 0\n top_right_radius = radius || 0\n\n const low = !Array.isArray(radius_low) && radius_low ? radius_low : 0\n bottom_left_radius = low\n bottom_right_radius = low\n }\n\n // top right\n this.moveTo(x + top_left_radius, y)\n this.lineTo(x + w - top_right_radius, y)\n this.quadraticCurveTo(x + w, y, x + w, y + top_right_radius)\n\n // bottom right\n this.lineTo(x + w, y + h - bottom_right_radius)\n this.quadraticCurveTo(\n x + w,\n y + h,\n x + w - bottom_right_radius,\n y + h,\n )\n\n // bottom left\n this.lineTo(x + bottom_right_radius, y + h)\n this.quadraticCurveTo(x, y + h, x, y + h - bottom_left_radius)\n\n // top left\n this.lineTo(x, y + bottom_left_radius)\n this.quadraticCurveTo(x, y, x + top_left_radius, y)\n }\n }\n\n if (typeof window != \"undefined\" && !window[\"requestAnimationFrame\"]) {\n window.requestAnimationFrame =\n // @ts-expect-error Legacy code\n window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame ||\n function (callback) {\n window.setTimeout(callback, 1000 / 60)\n }\n }\n}\n","export class InvalidLinkError extends Error {\n constructor(message: string = \"Attempted to access a link that was invalid.\", cause?: Error) {\n super(message, { cause })\n this.name = \"InvalidLinkError\"\n }\n}\n","/**\n * Error thrown when infinite recursion is detected.\n */\nexport class RecursionError extends Error {\n constructor(subject: string) {\n super(subject)\n this.name = \"RecursionError\"\n }\n}\n","export class SlotIndexError extends Error {\n constructor(message: string = \"Attempted to access a slot that was out of bounds.\", cause?: Error) {\n super(message, { cause })\n this.name = \"SlotIndexError\"\n }\n}\n","import type { SubgraphNode } from \"./SubgraphNode\"\nimport type { CallbackParams, CallbackReturn, ISlotType } from \"@/interfaces\"\nimport type { LGraph } from \"@/LGraph\"\nimport type { LGraphNode, NodeId } from \"@/LGraphNode\"\n\nimport { InvalidLinkError } from \"@/infrastructure/InvalidLinkError\"\nimport { NullGraphError } from \"@/infrastructure/NullGraphError\"\nimport { RecursionError } from \"@/infrastructure/RecursionError\"\nimport { SlotIndexError } from \"@/infrastructure/SlotIndexError\"\nimport { LGraphEventMode } from \"@/litegraph\"\n\nimport { Subgraph } from \"./Subgraph\"\n\nexport type ExecutionId = string\n\n/**\n * Interface describing the data transfer objects used when compiling a graph for execution.\n */\nexport type ExecutableLGraphNode = Omit<ExecutableNodeDTO, \"graph\" | \"node\" | \"subgraphNode\">\n\n/**\n * The end result of resolving a DTO input.\n * When a widget value is returned, {@link widgetInfo} is present and {@link origin_slot} is `-1`.\n */\ntype ResolvedInput = {\n /** DTO for the node that the link originates from. */\n node: ExecutableLGraphNode\n /** Full unique execution ID of the node that the link originates from. In the case of a widget value, this is the ID of the subgraph node. */\n origin_id: ExecutionId\n /** The slot index of the output on the node that the link originates from. `-1` when widget value is set. */\n origin_slot: number\n /** Boxed widget value (e.g. for widgets). If this box is `undefined`, then an input link is connected, and widget values from the subgraph node are ignored. */\n widgetInfo?: { value: unknown }\n}\n\n/**\n * Concrete implementation of {@link ExecutableLGraphNode}.\n * @remarks This is the class that is used to create the data transfer objects for executable nodes.\n */\nexport class ExecutableNodeDTO implements ExecutableLGraphNode {\n applyToGraph?(...args: CallbackParams<typeof this.node.applyToGraph>): CallbackReturn<typeof this.node.applyToGraph>\n\n /** The graph that this node is a part of. */\n readonly graph: LGraph | Subgraph\n\n inputs: { linkId: number | null, name: string, type: ISlotType }[]\n\n /** Backing field for {@link id}. */\n #id: ExecutionId\n\n /**\n * The path to the acutal node through subgraph instances, represented as a list of all subgraph node IDs (instances),\n * followed by the actual original node ID within the subgraph. Each segment is separated by `:`.\n *\n * e.g. `1:2:3`:\n * - `1` is the node ID of the first subgraph node in the parent workflow\n * - `2` is the node ID of the second subgraph node in the first subgraph\n * - `3` is the node ID of the actual node in the subgraph definition\n */\n get id() {\n return this.#id\n }\n\n get type() {\n return this.node.type\n }\n\n get title() {\n return this.node.title\n }\n\n get mode() {\n return this.node.mode\n }\n\n get comfyClass() {\n return this.node.comfyClass\n }\n\n get isVirtualNode() {\n return this.node.isVirtualNode\n }\n\n get widgets() {\n return this.node.widgets\n }\n\n get subgraphId() {\n return this.subgraphNode?.subgraph.id\n }\n\n constructor(\n /** The actual node that this DTO wraps. */\n readonly node: LGraphNode | SubgraphNode,\n /** A list of subgraph instance node IDs from the root graph to the containing instance. @see {@link id} */\n readonly subgraphNodePath: readonly NodeId[],\n /** A flattened map of all DTOs in this node network. Subgraph instances have been expanded into their inner nodes. */\n readonly nodesByExecutionId: Map<ExecutionId, ExecutableLGraphNode>,\n /** The actual subgraph instance that contains this node, otherise undefined. */\n readonly subgraphNode?: SubgraphNode,\n ) {\n if (!node.graph) throw new NullGraphError()\n\n // Set the internal ID of the DTO\n this.#id = [...this.subgraphNodePath, this.node.id].join(\":\")\n this.graph = node.graph\n this.inputs = this.node.inputs.map(x => ({\n linkId: x.link,\n name: x.name,\n type: x.type,\n }))\n\n // Only create a wrapper if the node has an applyToGraph method\n if (this.node.applyToGraph) {\n this.applyToGraph = (...args) => this.node.applyToGraph?.(...args)\n }\n }\n\n /** Returns either the DTO itself, or the DTOs of the inner nodes of the subgraph. */\n getInnerNodes(): ExecutableLGraphNode[] {\n return this.node.isSubgraphNode() ? this.node.getInnerNodes(this.nodesByExecutionId, this.subgraphNodePath) : [this]\n }\n\n /**\n * Resolves the executable node & link IDs for a given input slot.\n * @param slot The slot index of the input.\n * @param visited Leave empty unless overriding this method.\n * A set of unique IDs, used to guard against infinite recursion.\n * If overriding, ensure that the set is passed on all recursive calls.\n * @returns The node and the origin ID / slot index of the output.\n */\n resolveInput(slot: number, visited = new Set<string>()): ResolvedInput | undefined {\n const uniqueId = `${this.subgraphNode?.subgraph.id}:${this.node.id}[I]${slot}`\n if (visited.has(uniqueId)) {\n const nodeInfo = `${this.node.id}${this.node.title ? ` (${this.node.title})` : \"\"}`\n const pathInfo = this.subgraphNodePath.length > 0 ? ` at path ${this.subgraphNodePath.join(\":\")}` : \"\"\n throw new RecursionError(\n `Circular reference detected while resolving input ${slot} of node ${nodeInfo}${pathInfo}. ` +\n `This creates an infinite loop in link resolution. UniqueID: [${uniqueId}]`,\n )\n }\n visited.add(uniqueId)\n\n const input = this.inputs.at(slot)\n if (!input) throw new SlotIndexError(`No input found for flattened id [${this.id}] slot [${slot}]`)\n\n // Nothing connected\n if (input.linkId == null) return\n\n const link = this.graph.getLink(input.linkId)\n if (!link) throw new InvalidLinkError(`No link found in parent graph for id [${this.id}] slot [${slot}] ${input.name}`)\n\n const { subgraphNode } = this\n\n // Link goes up and out of this subgraph\n if (subgraphNode && link.originIsIoNode) {\n const subgraphNodeInput = subgraphNode.inputs.at(link.origin_slot)\n if (!subgraphNodeInput) throw new SlotIndexError(`No input found for slot [${link.origin_slot}] ${input.name}`)\n\n // Nothing connected\n const linkId = subgraphNodeInput.link\n if (linkId == null) {\n const widget = subgraphNode.getWidgetFromSlot(subgraphNodeInput)\n if (!widget) return\n\n // Special case: SubgraphNode widget.\n return {\n node: this,\n origin_id: this.id,\n origin_slot: -1,\n widgetInfo: { value: widget.value },\n }\n }\n\n const outerLink = subgraphNode.graph.getLink(linkId)\n if (!outerLink) throw new InvalidLinkError(`No outer link found for slot [${link.origin_slot}] ${input.name}`)\n\n const subgraphNodeExecutionId = this.subgraphNodePath.join(\":\")\n const subgraphNodeDto = this.nodesByExecutionId.get(subgraphNodeExecutionId)\n if (!subgraphNodeDto) throw new Error(`No subgraph node DTO found for id [${subgraphNodeExecutionId}]`)\n\n return subgraphNodeDto.resolveInput(outerLink.target_slot, visited)\n }\n\n // Not part of a subgraph; use the original link\n const outputNode = this.graph.getNodeById(link.origin_id)\n if (!outputNode) throw new InvalidLinkError(`No input node found for id [${this.id}] slot [${slot}] ${input.name}`)\n\n const outputNodeExecutionId = [...this.subgraphNodePath, outputNode.id].join(\":\")\n const outputNodeDto = this.nodesByExecutionId.get(outputNodeExecutionId)\n if (!outputNodeDto) throw new Error(`No output node DTO found for id [${outputNodeExecutionId}]`)\n\n return outputNodeDto.resolveOutput(link.origin_slot, input.type, visited)\n }\n\n /**\n * Determines whether this output is a valid endpoint for a link (non-virtual, non-bypass).\n * @param slot The slot index of the output.\n * @param type The type of the input\n * @param visited A set of unique IDs to guard against infinite recursion. See {@link resolveInput}.\n * @returns The node and the origin ID / slot index of the output.\n */\n resolveOutput(slot: number, type: ISlotType, visited: Set<string>): ResolvedInput | undefined {\n const uniqueId = `${this.subgraphNode?.subgraph.id}:${this.node.id}[O]${slot}`\n if (visited.has(uniqueId)) {\n const nodeInfo = `${this.node.id}${this.node.title ? ` (${this.node.title})` : \"\"}`\n const pathInfo = this.subgraphNodePath.length > 0 ? ` at path ${this.subgraphNodePath.join(\":\")}` : \"\"\n throw new RecursionError(\n `Circular reference detected while resolving output ${slot} of node ${nodeInfo}${pathInfo}. ` +\n `This creates an infinite loop in link resolution. UniqueID: [${uniqueId}]`,\n )\n }\n visited.add(uniqueId)\n\n // Upstreamed: Bypass nodes are bypassed using the first input with matching type\n if (this.mode === LGraphEventMode.BYPASS) {\n const { inputs } = this\n\n // Bypass nodes by finding first input with matching type\n const parentInputIndexes = Object.keys(inputs).map(Number)\n // Prioritise exact slot index\n const indexes = [slot, ...parentInputIndexes]\n const matchingIndex = indexes.find(i => inputs[i]?.type === type)\n\n // No input types match\n if (matchingIndex === undefined) {\n console.debug(`[ExecutableNodeDTO.resolveOutput] No input types match type [${type}] for id [${this.id}] slot [${slot}]`, this)\n return\n }\n\n return this.resolveInput(matchingIndex, visited)\n }\n\n const { node } = this\n if (node.isSubgraphNode()) return this.#resolveSubgraphOutput(slot, type, visited)\n\n // Upstreamed: Other virtual nodes are bypassed using the same input/output index (slots must match)\n if (node.isVirtualNode) {\n if (this.inputs.at(slot)) return this.resolveInput(slot, visited)\n\n // Fallback check for nodes performing link redirection\n const virtualLink = this.node.getInputLink(slot)\n if (virtualLink) {\n const outputNode = this.graph.getNodeById(virtualLink.origin_id)\n if (!outputNode) throw new InvalidLinkError(`Virtual node failed to resolve parent [${this.id}] slot [${slot}]`)\n\n const outputNodeExecutionId = [...this.subgraphNodePath, outputNode.id].join(\":\")\n const outputNodeDto = this.nodesByExecutionId.get(outputNodeExecutionId)\n if (!outputNodeDto) throw new Error(`No output node DTO found for id [${outputNode.id}]`)\n\n return outputNodeDto.resolveOutput(virtualLink.origin_slot, type, visited)\n }\n\n // Virtual nodes without a matching input should be discarded.\n return\n }\n\n return {\n node: this,\n origin_id: this.id,\n origin_slot: slot,\n }\n }\n\n /**\n * Resolves the link inside a subgraph node, from the subgraph IO node to the node inside the subgraph.\n * @param slot The slot index of the output on the subgraph node.\n * @param visited A set of unique IDs to guard against infinite recursion. See {@link resolveInput}.\n * @returns A DTO for the node, and the origin ID / slot index of the output.\n */\n #resolveSubgraphOutput(slot: number, type: ISlotType, visited: Set<string>): ResolvedInput | undefined {\n const { node } = this\n const output = node.outputs.at(slot)\n\n if (!output) throw new SlotIndexError(`No output found for flattened id [${this.id}] slot [${slot}]`)\n if (!node.isSubgraphNode()) throw new TypeError(`Node is not a subgraph node: ${node.id}`)\n\n // Link inside the subgraph\n const innerResolved = node.resolveSubgraphOutputLink(slot)\n if (!innerResolved) return\n\n const innerNode = innerResolved.outputNode\n if (!innerNode) throw new Error(`No output node found for id [${this.id}] slot [${slot}] ${output.name}`)\n\n // Recurse into the subgraph\n const innerNodeExecutionId = [...this.subgraphNodePath, node.id, innerNode.id].join(\":\")\n const innerNodeDto = this.nodesByExecutionId.get(innerNodeExecutionId)\n if (!innerNodeDto) throw new Error(`No inner node DTO found for id [${innerNodeExecutionId}]`)\n\n return innerNodeDto.resolveOutput(innerResolved.link.origin_slot, type, visited)\n }\n}\n","import type { SubgraphInput } from \"./SubgraphInput\"\nimport type { ISubgraphInput } from \"@/interfaces\"\nimport type { BaseLGraph, LGraph } from \"@/LGraph\"\nimport type { GraphOrSubgraph, Subgraph } from \"@/subgraph/Subgraph\"\nimport type { ExportedSubgraphInstance } from \"@/types/serialisation\"\nimport type { IBaseWidget } from \"@/types/widgets\"\nimport type { UUID } from \"@/utils/uuid\"\n\nimport { RecursionError } from \"@/infrastructure/RecursionError\"\nimport { LGraphButton } from \"@/LGraphButton\"\nimport { LGraphCanvas } from \"@/LGraphCanvas\"\nimport { LGraphNode } from \"@/LGraphNode\"\nimport { type INodeInputSlot, type ISlotType, type NodeId } from \"@/litegraph\"\nimport { LLink, type ResolvedConnection } from \"@/LLink\"\nimport { NodeInputSlot } from \"@/node/NodeInputSlot\"\nimport { NodeOutputSlot } from \"@/node/NodeOutputSlot\"\nimport { toConcreteWidget } from \"@/widgets/widgetMap\"\n\nimport { type ExecutableLGraphNode, ExecutableNodeDTO, type ExecutionId } from \"./ExecutableNodeDTO\"\n\n/**\n * An instance of a {@link Subgraph}, displayed as a node on the containing (parent) graph.\n */\nexport class SubgraphNode extends LGraphNode implements BaseLGraph {\n declare inputs: (INodeInputSlot & Partial<ISubgraphInput>)[]\n\n override readonly type: UUID\n override readonly isVirtualNode = true as const\n\n get rootGraph(): LGraph {\n return this.graph.rootGraph\n }\n\n override get displayType(): string {\n return \"Subgraph node\"\n }\n\n override isSubgraphNode(): this is SubgraphNode {\n return true\n }\n\n override widgets: IBaseWidget[] = []\n\n /** Manages lifecycle of all subgraph event listeners */\n #eventAbortController = new AbortController()\n\n constructor(\n /** The (sub)graph that contains this subgraph instance. */\n override readonly graph: GraphOrSubgraph,\n /** The definition of this subgraph; how its nodes are configured, etc. */\n readonly subgraph: Subgraph,\n instanceData: ExportedSubgraphInstance,\n ) {\n super(subgraph.name, subgraph.id)\n\n // Update this node when the subgraph input / output slots are changed\n const subgraphEvents = this.subgraph.events\n const { signal } = this.#eventAbortController\n\n subgraphEvents.addEventListener(\"input-added\", (e) => {\n const subgraphInput = e.detail.input\n const { name, type } = subgraphInput\n if (this.inputs.some(i => i.name == name))\n return\n const input = this.addInput(name, type)\n\n this.#addSubgraphInputListeners(subgraphInput, input)\n }, { signal })\n\n subgraphEvents.addEventListener(\"removing-input\", (e) => {\n const widget = e.detail.input._widget\n if (widget) this.ensureWidgetRemoved(widget)\n\n this.removeInput(e.detail.index)\n this.setDirtyCanvas(true, true)\n }, { signal })\n\n subgraphEvents.addEventListener(\"output-added\", (e) => {\n const { name, type } = e.detail.output\n this.addOutput(name, type)\n }, { signal })\n\n subgraphEvents.addEventListener(\"removing-output\", (e) => {\n this.removeOutput(e.detail.index)\n this.setDirtyCanvas(true, true)\n }, { signal })\n\n subgraphEvents.addEventListener(\"renaming-input\", (e) => {\n const { index, newName } = e.detail\n const input = this.inputs.at(index)\n if (!input) throw new Error(\"Subgraph input not found\")\n\n input.label = newName\n }, { signal })\n\n subgraphEvents.addEventListener(\"renaming-output\", (e) => {\n const { index, newName } = e.detail\n const output = this.outputs.at(index)\n if (!output) throw new Error(\"Subgraph output not found\")\n\n output.label = newName\n }, { signal })\n\n this.type = subgraph.id\n this.configure(instanceData)\n\n this.addTitleButton({\n name: \"enter_subgraph\",\n text: \"\\uE93B\", // Unicode for pi-window-maximize\n yOffset: 0, // No vertical offset needed, button is centered\n xOffset: -10,\n fontSize: 16,\n })\n }\n\n override onTitleButtonClick(button: LGraphButton, canvas: LGraphCanvas): void {\n if (button.name === \"enter_subgraph\") {\n canvas.openSubgraph(this.subgraph)\n } else {\n super.onTitleButtonClick(button, canvas)\n }\n }\n\n #addSubgraphInputListeners(subgraphInput: SubgraphInput, input: INodeInputSlot & Partial<ISubgraphInput>) {\n input._listenerController?.abort()\n input._listenerController = new AbortController()\n const { signal } = input._listenerController\n\n subgraphInput.events.addEventListener(\n \"input-connected\",\n () => {\n if (input._widget) return\n\n const widget = subgraphInput._widget\n if (!widget) return\n\n this.#setWidget(subgraphInput, input, widget)\n },\n { signal },\n )\n\n subgraphInput.events.addEventListener(\n \"input-disconnected\",\n () => {\n // If the input is connected to more than one widget, don't remove the widget\n const connectedWidgets = subgraphInput.getConnectedWidgets()\n if (connectedWidgets.length > 0) return\n\n this.removeWidgetByName(input.name)\n\n delete input.pos\n delete input.widget\n input._widget = undefined\n },\n { signal },\n )\n }\n\n override configure(info: ExportedSubgraphInstance): void {\n for (const input of this.inputs) {\n input._listenerController?.abort()\n }\n\n this.inputs.length = 0\n this.inputs.push(\n ...this.subgraph.inputNode.slots.map(\n slot => new NodeInputSlot({ name: slot.name, localized_name: slot.localized_name, label: slot.label, type: slot.type, link: null }, this),\n ),\n )\n\n this.outputs.length = 0\n this.outputs.push(\n ...this.subgraph.outputNode.slots.map(\n slot => new NodeOutputSlot({ name: slot.name, localized_name: slot.localized_name, label: slot.label, type: slot.type, links: null }, this),\n ),\n )\n\n super.configure(info)\n }\n\n override _internalConfigureAfterSlots() {\n // Reset widgets\n this.widgets.length = 0\n\n // Check all inputs for connected widgets\n for (const input of this.inputs) {\n const subgraphInput = this.subgraph.inputNode.slots.find(slot => slot.name === input.name)\n if (!subgraphInput) throw new Error(`[SubgraphNode.configure] No subgraph input found for input ${input.name}`)\n\n this.#addSubgraphInputListeners(subgraphInput, input)\n\n // Find the first widget that this slot is connected to\n for (const linkId of subgraphInput.linkIds) {\n const link = this.subgraph.getLink(linkId)\n if (!link) {\n console.warn(`[SubgraphNode.configure] No link found for link ID ${linkId}`, this)\n continue\n }\n\n const resolved = link.resolve(this.subgraph)\n if (!resolved.input || !resolved.inputNode) {\n console.warn(\"Invalid resolved link\", resolved, this)\n continue\n }\n\n // No widget - ignore this link\n const widget = resolved.inputNode.getWidgetFromSlot(resolved.input)\n if (!widget) continue\n\n this.#setWidget(subgraphInput, input, widget)\n break\n }\n }\n }\n\n #setWidget(subgraphInput: Readonly<SubgraphInput>, input: INodeInputSlot, widget: Readonly<IBaseWidget>) {\n // Use the first matching widget\n const promotedWidget = toConcreteWidget(widget, this).createCopyForNode(this)\n\n Object.assign(promotedWidget, {\n get name() {\n return subgraphInput.name\n },\n set name(value) {\n console.warn(\"Promoted widget: setting name is not allowed\", this, value)\n },\n get localized_name() {\n return subgraphInput.localized_name\n },\n set localized_name(value) {\n console.warn(\"Promoted widget: setting localized_name is not allowed\", this, value)\n },\n get label() {\n return subgraphInput.label\n },\n set label(value) {\n console.warn(\"Promoted widget: setting label is not allowed\", this, value)\n },\n get tooltip() {\n // Preserve the original widget's tooltip for promoted widgets\n return widget.tooltip\n },\n set tooltip(value) {\n console.warn(\"Promoted widget: setting tooltip is not allowed\", this, value)\n },\n })\n\n this.widgets.push(promotedWidget)\n\n // Dispatch widget-promoted event\n this.subgraph.events.dispatch(\"widget-promoted\", { widget: promotedWidget, subgraphNode: this })\n\n input.widget = { name: subgraphInput.name }\n input._widget = promotedWidget\n }\n\n /**\n * Ensures the subgraph slot is in the params before adding the input as normal.\n * @param name The name of the input slot.\n * @param type The type of the input slot.\n * @param inputProperties Properties that are directly assigned to the created input. Default: a new, empty object.\n * @returns The new input slot.\n * @remarks Assertion is required to instantiate empty generic POJO.\n */\n override addInput<TInput extends Partial<ISubgraphInput>>(name: string, type: ISlotType, inputProperties: TInput = {} as TInput): INodeInputSlot & TInput {\n // Bypasses type narrowing on this.inputs\n return super.addInput(name, type, inputProperties)\n }\n\n override getInputLink(slot: number): LLink | null {\n // Output side: the link from inside the subgraph\n const innerLink = this.subgraph.outputNode.slots[slot].getLinks().at(0)\n if (!innerLink) {\n console.warn(`SubgraphNode.getInputLink: no inner link found for slot ${slot}`)\n return null\n }\n\n const newLink = LLink.create(innerLink)\n newLink.origin_id = `${this.id}:${innerLink.origin_id}`\n newLink.origin_slot = innerLink.origin_slot\n\n return newLink\n }\n\n /**\n * Finds the internal links connected to the given input slot inside the subgraph, and resolves the nodes / slots.\n * @param slot The slot index\n * @returns The resolved connections, or undefined if no input node is found.\n * @remarks This is used to resolve the input links when dragging a link from a subgraph input slot.\n */\n resolveSubgraphInputLinks(slot: number): ResolvedConnection[] {\n const inputSlot = this.subgraph.inputNode.slots[slot]\n const innerLinks = inputSlot.getLinks()\n if (innerLinks.length === 0) {\n console.debug(`[SubgraphNode.resolveSubgraphInputLinks] No inner links found for input slot [${slot}] ${inputSlot.name}`, this)\n return []\n }\n return innerLinks.map(link => link.resolve(this.subgraph))\n }\n\n /**\n * Finds the internal link connected to the given output slot inside the subgraph, and resolves the nodes / slots.\n * @param slot The slot index\n * @returns The output node if found, otherwise undefined.\n */\n resolveSubgraphOutputLink(slot: number): ResolvedConnection | undefined {\n const outputSlot = this.subgraph.outputNode.slots[slot]\n const innerLink = outputSlot.getLinks().at(0)\n if (innerLink) return innerLink.resolve(this.subgraph)\n\n console.debug(`[SubgraphNode.resolveSubgraphOutputLink] No inner link found for output slot [${slot}] ${outputSlot.name}`, this)\n }\n\n /** @internal Used to flatten the subgraph before execution. */\n getInnerNodes(\n /** The set of computed node DTOs for this execution. */\n executableNodes: Map<ExecutionId, ExecutableLGraphNode>,\n /** The path of subgraph node IDs. */\n subgraphNodePath: readonly NodeId[] = [],\n /** Internal recursion param. The list of nodes to add to. */\n nodes: ExecutableLGraphNode[] = [],\n /** Internal recursion param. The set of visited nodes. */\n visited = new Set<SubgraphNode>(),\n ): ExecutableLGraphNode[] {\n if (visited.has(this)) {\n const nodeInfo = `${this.id}${this.title ? ` (${this.title})` : \"\"}`\n const subgraphInfo = `'${this.subgraph.name || \"Unnamed Subgraph\"}'`\n const depth = subgraphNodePath.length\n throw new RecursionError(\n `Circular reference detected at depth ${depth} in node ${nodeInfo} of subgraph ${subgraphInfo}. ` +\n `This creates an infinite loop in the subgraph hierarchy.`,\n )\n }\n visited.add(this)\n\n const subgraphInstanceIdPath = [...subgraphNodePath, this.id]\n\n // Store the subgraph node DTO\n const parentSubgraphNode = this.graph.rootGraph.resolveSubgraphIdPath(subgraphNodePath).at(-1)\n const subgraphNodeDto = new ExecutableNodeDTO(this, subgraphNodePath, executableNodes, parentSubgraphNode)\n executableNodes.set(subgraphNodeDto.id, subgraphNodeDto)\n\n for (const node of this.subgraph.nodes) {\n if (\"getInnerNodes\" in node) {\n node.getInnerNodes(executableNodes, subgraphInstanceIdPath, nodes, new Set(visited))\n } else {\n // Create minimal DTOs rather than cloning the node\n const aVeryRealNode = new ExecutableNodeDTO(node, subgraphInstanceIdPath, executableNodes, this)\n executableNodes.set(aVeryRealNode.id, aVeryRealNode)\n nodes.push(aVeryRealNode)\n }\n }\n return nodes\n }\n\n override removeWidgetByName(name: string): void {\n const widget = this.widgets.find(w => w.name === name)\n if (widget) {\n this.subgraph.events.dispatch(\"widget-demoted\", { widget, subgraphNode: this })\n }\n super.removeWidgetByName(name)\n }\n\n override ensureWidgetRemoved(widget: IBaseWidget): void {\n if (this.widgets.includes(widget)) {\n this.subgraph.events.dispatch(\"widget-demoted\", { widget, subgraphNode: this })\n }\n super.ensureWidgetRemoved(widget)\n }\n\n override onRemoved(): void {\n // Clean up all subgraph event listeners\n this.#eventAbortController.abort()\n\n // Clean up all promoted widgets\n for (const widget of this.widgets) {\n this.subgraph.events.dispatch(\"widget-demoted\", { widget, subgraphNode: this })\n }\n\n for (const input of this.inputs) {\n input._listenerController?.abort()\n }\n }\n}\n","import type { ContextMenu } from \"./ContextMenu\"\nimport type { ConnectingLink, Point } from \"./interfaces\"\nimport type {\n IContextMenuOptions,\n INodeSlot,\n Size,\n} from \"./interfaces\"\nimport type { LGraphNode } from \"./LGraphNode\"\nimport type { CanvasEventDetail } from \"./types/events\"\nimport type { RenderShape, TitleMode } from \"./types/globalEnums\"\n\n// Must remain above LiteGraphGlobal (circular dependency due to abstract factory behaviour in `configure`)\nexport { Subgraph } from \"./subgraph/Subgraph\"\n\nimport { LiteGraphGlobal } from \"./LiteGraphGlobal\"\nimport { loadPolyfills } from \"./polyfills\"\n\nexport const LiteGraph = new LiteGraphGlobal()\n\n// Load legacy polyfills\nloadPolyfills()\n\n// Backwards compat\n\n// Type definitions for litegraph.js 0.7.0\n// Project: litegraph.js\n// Definitions by: NateScarlet <https://github.com/NateScarlet>\n/** @deprecated Use {@link Point} instead. */\nexport type Vector2 = Point\n/** @deprecated Use {@link Rect} instead. */\nexport type Vector4 = [number, number, number, number]\n\nexport interface IContextMenuItem {\n content: string\n callback?: ContextMenuEventListener\n /** Used as innerHTML for extra child element */\n title?: string\n disabled?: boolean\n has_submenu?: boolean\n submenu?: {\n options: IContextMenuItem[]\n } & IContextMenuOptions\n className?: string\n}\n\nexport type ContextMenuEventListener = (\n value: IContextMenuItem,\n options: IContextMenuOptions,\n event: MouseEvent,\n parentMenu: ContextMenu<unknown> | undefined,\n node: LGraphNode,\n) => boolean | void\n\nexport interface LinkReleaseContext {\n node_to?: LGraphNode\n node_from?: LGraphNode\n slot_from: INodeSlot\n type_filter_in?: string\n type_filter_out?: string\n}\n\nexport interface LinkReleaseContextExtended {\n links: ConnectingLink[]\n}\n\nexport interface LiteGraphCanvasEvent extends CustomEvent<CanvasEventDetail> {}\n\nexport interface LGraphNodeConstructor<T extends LGraphNode = LGraphNode> {\n new (title: string, type?: string): T\n\n title: string\n type: string\n size?: Size\n min_height?: number\n slot_start_y?: number\n widgets_info?: any\n collapsable?: boolean\n color?: string\n bgcolor?: string\n shape?: RenderShape\n title_mode?: TitleMode\n title_color?: string\n title_text_color?: string\n keepAllLinksOnBypass: boolean\n resizeHandleSize?: number\n resizeEdgeSize?: number\n}\n\n// End backwards compat\n\nexport { InputIndicators } from \"./canvas/InputIndicators\"\nexport { LinkConnector } from \"./canvas/LinkConnector\"\nexport { isOverNodeInput, isOverNodeOutput } from \"./canvas/measureSlots\"\nexport { CanvasPointer } from \"./CanvasPointer\"\nexport * as Constants from \"./constants\"\nexport { ContextMenu } from \"./ContextMenu\"\nexport { CurveEditor } from \"./CurveEditor\"\nexport { DragAndScale } from \"./DragAndScale\"\nexport { LabelPosition, SlotDirection, SlotShape, SlotType } from \"./draw\"\nexport { strokeShape } from \"./draw\"\nexport { Rectangle } from \"./infrastructure/Rectangle\"\nexport type {\n CanvasColour,\n ColorOption,\n ConnectingLink,\n Direction,\n IBoundaryNodes,\n IColorable,\n IContextMenuOptions,\n IContextMenuValue,\n IFoundSlot,\n IInputOrOutput,\n INodeFlags,\n INodeInputSlot,\n INodeOutputSlot,\n INodeSlot,\n ISlotType,\n KeysOfType,\n LinkNetwork,\n LinkSegment,\n MethodNames,\n PickByType,\n Point,\n Positionable,\n ReadonlyLinkNetwork,\n ReadOnlyPoint,\n ReadOnlyRect,\n Rect,\n Size,\n} from \"./interfaces\"\nexport { LGraph } from \"./LGraph\"\nexport { BadgePosition, LGraphBadge, type LGraphBadgeOptions } from \"./LGraphBadge\"\nexport { LGraphCanvas, type LGraphCanvasState } from \"./LGraphCanvas\"\nexport { LGraphGroup } from \"./LGraphGroup\"\nexport { LGraphNode, type NodeId } from \"./LGraphNode\"\nexport { type LinkId, LLink } from \"./LLink\"\nexport { clamp, createBounds } from \"./measure\"\nexport { Reroute, type RerouteId } from \"./Reroute\"\nexport { type ExecutableLGraphNode, ExecutableNodeDTO, type ExecutionId } from \"./subgraph/ExecutableNodeDTO\"\nexport { SubgraphNode } from \"./subgraph/SubgraphNode\"\nexport type { CanvasPointerEvent } from \"./types/events\"\nexport {\n CanvasItem,\n EaseFunction,\n LGraphEventMode,\n LinkMarkerShape,\n RenderShape,\n TitleMode,\n} from \"./types/globalEnums\"\nexport type {\n ExportedSubgraph,\n ExportedSubgraphInstance,\n ExportedSubgraphIONode,\n ISerialisedGraph,\n SerialisableGraph,\n SerialisableLLink,\n SubgraphIO,\n} from \"./types/serialisation\"\nexport type { IWidget } from \"./types/widgets\"\nexport { isColorable } from \"./utils/type\"\nexport { createUuidv4 } from \"./utils/uuid\"\nexport { BaseSteppedWidget } from \"./widgets/BaseSteppedWidget\"\nexport { BaseWidget } from \"./widgets/BaseWidget\"\nexport { BooleanWidget } from \"./widgets/BooleanWidget\"\nexport { ButtonWidget } from \"./widgets/ButtonWidget\"\nexport { ComboWidget } from \"./widgets/ComboWidget\"\nexport { KnobWidget } from \"./widgets/KnobWidget\"\nexport { LegacyWidget } from \"./widgets/LegacyWidget\"\nexport { NumberWidget } from \"./widgets/NumberWidget\"\nexport { SliderWidget } from \"./widgets/SliderWidget\"\nexport { TextWidget } from \"./widgets/TextWidget\"\nexport { isComboWidget } from \"./widgets/widgetMap\"\n"],"names":["NodeSlotType","RenderShape","CanvasItem","LinkDirection","LinkRenderType","LinkMarkerShape","TitleMode","LGraphEventMode","EaseFunction","Alignment","x","width","node","BadgePosition","SlotType","SlotShape","SlotDirection","LabelPosition","height","v","network","e","link","reroute","input","output","canvas","delta","gradient","newValue","minWidth","widgetWidth","graph","renderLink","value","prev_menu","entries","document","window","subgraph","pointer","options","str_value","name","data","y","type"],"mappings":"AA4EO,MAAM,0BAIH,YAA0D;AAAA,EAUlE,SAAmC,MAAS,QAAsB;AAChE,UAAM,QAAQ,IAAI,YAAY,MAAgB,EAAE,QAAQ,YAAY,MAAM;AAC1E,WAAO,MAAM,cAAc,KAAK;AAAA,EAClC;AAAA,EAES,iBACP,MACA,UACA,SACM;AAEN,UAAM,iBAAiB,MAAgB,UAA2B,OAAO;AAAA,EAC3E;AAAA,EAES,oBACP,MACA,UACA,SACM;AAEN,UAAM,oBAAoB,MAAgB,UAA2B,OAAO;AAAA,EAC9E;AAAA;AAAA,EAGS,cAAc,OAAuB;AAC5C,WAAO,MAAM,cAAc,KAAK;AAAA,EAClC;AACF;AC9GO,MAAM,oBAAoB;AAG1B,MAAM,qBAAqB;;;;;;ACN3B,MAAM,WAAW;AAGxB,MAAM,gBAAgB,IAAI,YAAY,EAAE;AAWjC,SAAS,eAAqB;AACnC,MAAI,OAAO,QAAQ,eAAe,WAAY,QAAO,OAAO,WAAA;AAC5D,MAAI,OAAO,QAAQ,oBAAoB,YAAY;AACjD,UAAM,SAAS,OAAO,gBAAgB,aAAa;AACnD,QAAI,IAAI;AACR,WAAO,uCAAuC,WAAW,UAAU,CAAA,OAChE,OAAO,CAAC,IAAM,OAAO,GAAG,IAAI,wBAA8B,OAAO,CAAC,IAAI,MAAQ,SAAS,EAAE,CAAC;AAAA,EAC/F;AACA,SAAO,uCAAuC,WAAW,UAAU,CAAA,OAChE,OAAO,CAAC,IAAM,KAAK,OAAA,IAAW,MAAQ,OAAO,CAAC,IAAI,MAAQ,SAAS,EAAE,CAAC;AAC3E;ACoDO,MAAM,MAA8D;AAAA,EACzE,OAAO,aAAa;AAAA;AAAA,EAGpB;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEA;AAAA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