var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(v,n,t){v!=Array.prototype&&v!=Object.prototype&&(v[n]=t.value)};$jscomp.getGlobal=function(v){return"undefined"!=typeof window&&window===v?v:"undefined"!=typeof global&&null!=global?global:v};$jscomp.global=$jscomp.getGlobal(this); $jscomp.polyfill=function(v,n,t,h){if(n){t=$jscomp.global;v=v.split(".");for(h=0;ht&&(t=Math.max(0,r+t));if(null==h||h>r)h=r;h=Number(h);0>h&&(h=Math.max(0,r+h));for(t=Number(t||0);t=w}},"es6","es3");$jscomp.findInternal=function(v,n,t){v instanceof String&&(v=String(v));for(var h=v.length,r=0;ra&&db?!0:!1}function y(a,b){var c=a[0]+a[2],d=a[1]+a[3],e=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>e||cm.width-l.width-10&&(e=m.width-l.width-10),m.height&&a>m.height-l.height-10&&(a=m.height-l.height-10));k.style.left=e+"px";k.style.top=a+"px";b.scale&&(k.style.transform="scale("+ b.scale+")")}function E(a){this.points=a;this.nearest=this.selected=-1;this.size=null;this.must_update=!0;this.margin=5}var f=v.LiteGraph={VERSION:.4,CANVAS_GRID_SIZE:10,NODE_TITLE_HEIGHT:30,NODE_TITLE_TEXT_Y:20,NODE_SLOT_HEIGHT:20,NODE_WIDGET_HEIGHT:20,NODE_WIDTH:140,NODE_MIN_WIDTH:50,NODE_COLLAPSED_RADIUS:10,NODE_COLLAPSED_WIDTH:80,NODE_TITLE_COLOR:"#999",NODE_SELECTED_TITLE_COLOR:"#FFF",NODE_TEXT_SIZE:14,NODE_TEXT_COLOR:"#AAA",NODE_SUBTEXT_SIZE:12,NODE_DEFAULT_COLOR:"#333",NODE_DEFAULT_BGCOLOR:"#353535", NODE_DEFAULT_BOXCOLOR:"#666",NODE_DEFAULT_SHAPE:"box",NODE_BOX_OUTLINE_COLOR:"#FFF",DEFAULT_SHADOW_COLOR:"rgba(0,0,0,0.5)",DEFAULT_GROUP_FONT:24,WIDGET_BGCOLOR:"#222",WIDGET_OUTLINE_COLOR:"#666",WIDGET_TEXT_COLOR:"#DDD",WIDGET_SECONDARY_TEXT_COLOR:"#999",LINK_COLOR:"#9A9",EVENT_LINK_COLOR:"#A86",CONNECTING_LINK_COLOR:"#AFA",MAX_NUMBER_OF_NODES:1E3,DEFAULT_POSITION:[100,100],VALID_SHAPES:["default","box","round","card"],BOX_SHAPE:1,ROUND_SHAPE:2,CIRCLE_SHAPE:3,CARD_SHAPE:4,ARROW_SHAPE:5,INPUT:1,OUTPUT:2, EVENT:-1,ACTION:-1,ALWAYS:0,ON_EVENT:1,NEVER:2,ON_TRIGGER:3,UP:1,DOWN:2,LEFT:3,RIGHT:4,CENTER:5,STRAIGHT_LINK:0,LINEAR_LINK:1,SPLINE_LINK:2,NORMAL_TITLE:0,NO_TITLE:1,TRANSPARENT_TITLE:2,AUTOHIDE_TITLE:3,proxy:null,node_images_path:"",debug:!1,catch_exceptions:!0,throw_errors:!0,allow_scripts:!1,registered_node_types:{},node_types_by_file_extension:{},Nodes:{},Globals:{},searchbox_extras:{},auto_sort_node_types:!1,pointerevents_method:"pointer",registerNodeType:function(a,b){if(!b.prototype)throw"Cannot register a simple object, it must be a class with a prototype"; b.type=a;f.debug&&console.log("Node registered: "+a);a.split("/");var c=b.name,d=a.lastIndexOf("/");b.category=a.substr(0,d);b.title||(b.title=c);if(b.prototype)for(var e in h.prototype)b.prototype[e]||(b.prototype[e]=h.prototype[e]);if(d=this.registered_node_types[a])console.log("replacing node type: "+a);else if(Object.hasOwnProperty(b.prototype,"shape")||Object.defineProperty(b.prototype,"shape",{set:function(a){switch(a){case "default":delete this._shape;break;case "box":this._shape=f.BOX_SHAPE; break;case "round":this._shape=f.ROUND_SHAPE;break;case "circle":this._shape=f.CIRCLE_SHAPE;break;case "card":this._shape=f.CARD_SHAPE;break;default:this._shape=a}},get:function(a){return this._shape},enumerable:!0,configurable:!0}),b.prototype.onPropertyChange&&console.warn("LiteGraph node class "+a+" has onPropertyChange method, it must be called onPropertyChanged with d at the end"),b.supported_extensions)for(e in b.supported_extensions){var k=b.supported_extensions[e];k&&k.constructor===String&& (this.node_types_by_file_extension[k.toLowerCase()]=b)}this.registered_node_types[a]=b;b.constructor.name&&(this.Nodes[c]=b);if(f.onNodeTypeRegistered)f.onNodeTypeRegistered(a,b);if(d&&f.onNodeTypeReplaced)f.onNodeTypeReplaced(a,b,d);b.prototype.onPropertyChange&&console.warn("LiteGraph node class "+a+" has onPropertyChange method, it must be called onPropertyChanged with d at the end");if(b.supported_extensions)for(e=0;em&&(m=e.size[0]),l+=e.size[1]+a+f.NODE_TITLE_HEIGHT;b+=m+a}this.setDirtyCanvas(!0,!0)};n.prototype.getTime=function(){return this.globaltime};n.prototype.getFixedTime=function(){return this.fixedtime};n.prototype.getElapsedTime=function(){return this.elapsed_time}; n.prototype.sendEventToAllNodes=function(a,b,c){c=c||f.ALWAYS;var d=this._nodes_in_order?this._nodes_in_order:this._nodes;if(d)for(var e=0,k=d.length;e=f.MAX_NUMBER_OF_NODES)throw"LiteGraph: max number of nodes in a graph reached";null==a.id||-1==a.id?a.id=++this.last_node_id:this.last_node_ida.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos},enumerable:!0});this.id=-1;this.type=null;this.inputs=[];this.outputs=[];this.connections=[];this.properties={};this.properties_info=[];this.flags={}};h.prototype.configure=function(a){this.graph&&this.graph._version++; for(var b in a)if("properties"==b)for(var c in a.properties){if(this.properties[c]=a.properties[c],this.onPropertyChanged)this.onPropertyChanged(c,a.properties[c])}else null!=a[b]&&("object"==typeof a[b]?this[b]&&this[b].configure?this[b].configure(a[b]):this[b]=f.cloneObject(a[b],this[b]):this[b]=a[b]);a.title||(this.title=this.constructor.title);if(this.onConnectionsChange){if(this.inputs)for(c=0;c=this.outputs.length)){var c=this.outputs[a];if(c&&(c._data=b,this.outputs[a].links))for(c=0;c=this.outputs.length)){var c=this.outputs[a];if(c&&(c.type=b,this.outputs[a].links))for(c=0;c=this.inputs.length||null==this.inputs[a].link)){a=this.graph.links[this.inputs[a].link];if(!a)return null;if(!b)return a.data;b=this.graph.getNodeById(a.origin_id); if(!b)return a.data;if(b.updateOutputData)b.updateOutputData(a.origin_slot);else if(b.onExecute)b.onExecute();return a.data}};h.prototype.getInputDataType=function(a){if(!this.inputs||a>=this.inputs.length||null==this.inputs[a].link)return null;a=this.graph.links[this.inputs[a].link];if(!a)return null;var b=this.graph.getNodeById(a.origin_id);return b?(a=b.outputs[a.origin_slot])?a.type:null:a.type};h.prototype.getInputDataByName=function(a,b){a=this.findInputSlot(a);return-1==a?null:this.getInputData(a, b)};h.prototype.isInputConnected=function(a){return this.inputs?a=this.inputs.length)return null;a=this.inputs[a];return a&&null!==a.link?(a=this.graph.links[a.link])? this.graph.getNodeById(a.origin_id):null:null};h.prototype.getInputOrProperty=function(a){if(!this.inputs||!this.inputs.length)return this.properties?this.properties[a]:null;for(var b=0,c=this.inputs.length;b=this.outputs.length?null:this.outputs[a]._data};h.prototype.getOutputInfo=function(a){return this.outputs? a=this.outputs.length)return null;a=this.outputs[a]; if(!a.links||0==a.links.length)return null;for(var b=[],c=0;ca&&this.pos[1]-e-cb)return!0;return!1};h.prototype.getSlotInPosition=function(a,b){var c=new Float32Array(2);if(this.inputs)for(var d=0,e=this.inputs.length;d=this.outputs.length)return f.debug&&console.log("Connect: Error, slot number not found"),null;b&& b.constructor===Number&&(b=this.graph.getNodeById(b));if(!b)throw"target node is null";if(b==this)return null;if(c.constructor===String){if(c=b.findInputSlot(c),-1==c)return f.debug&&console.log("Connect: Error, no slot of name "+c),null}else{if(c===f.EVENT)return null;if(!b.inputs||c>=b.inputs.length)return f.debug&&console.log("Connect: Error, slot number not found"),null}var d=!1;null!=b.inputs[c].link&&(this.graph.beforeChange(),b.disconnectInput(c),d=!0);var e=this.outputs[a];if(b.onConnectInput&& !1===b.onConnectInput(c,e.type,e,this,a))return null;var k=b.inputs[c],m=null;if(!f.isValidConnection(e.type,k.type))return this.setDirtyCanvas(!1,!0),d&&this.graph.connectionChange(this,m),null;d||this.graph.beforeChange();m=new t(++this.graph.last_link_id,k.type,this.id,a,b.id,c);this.graph.links[m.id]=m;null==e.links&&(e.links=[]);e.links.push(m.id);b.inputs[c].link=m.id;this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(f.OUTPUT,a,!0,m,e);if(b.onConnectionsChange)b.onConnectionsChange(f.INPUT, c,!0,m,k);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(f.INPUT,b,c,this,a),this.graph.onNodeConnectionChange(f.OUTPUT,this,a,b,c));this.setDirtyCanvas(!1,!0);this.graph.afterChange();this.graph.connectionChange(this,m);return m};h.prototype.disconnectOutput=function(a,b){if(a.constructor===String){if(a=this.findOutputSlot(a),-1==a)return f.debug&&console.log("Connect: Error, no slot of name "+a),!1}else if(!this.outputs||a>=this.outputs.length)return f.debug&& console.log("Connect: Error, slot number not found"),!1;var c=this.outputs[a];if(!c||!c.links||0==c.links.length)return!1;if(b){b.constructor===Number&&(b=this.graph.getNodeById(b));if(!b)throw"Target Node not found";for(var d=0,e=c.links.length;d=this.inputs.length)return f.debug&&console.log("Connect: Error, slot number not found"),!1;var b=this.inputs[a];if(!b)return!1;var c=this.inputs[a].link;if(null!=c){this.inputs[a].link=null;var d=this.graph.links[c];if(d){var e=this.graph.getNodeById(d.origin_id); if(!e)return!1;var k=e.outputs[d.origin_slot];if(!k||!k.links||0==k.links.length)return!1;for(var m=0,l=k.links.length;mb&&this.inputs[b].pos)return c[0]=this.pos[0]+this.inputs[b].pos[0],c[1]=this.pos[1]+this.inputs[b].pos[1],c;if(!a&&d>b&&this.outputs[b].pos)return c[0]=this.pos[0]+this.outputs[b].pos[0],c[1]=this.pos[1]+this.outputs[b].pos[1],c;if(this.horizontal)return c[0]=this.pos[0]+this.size[0]/d*(b+.5),c[1]=a?this.pos[1]-f.NODE_TITLE_HEIGHT:this.pos[1]+this.size[1],c;c[0]= a?this.pos[0]+e:this.pos[0]+this.size[0]+1-e;c[1]=this.pos[1]+(b+.7)*f.NODE_SLOT_HEIGHT+(this.constructor.slot_start_y||0);return c};h.prototype.alignToGrid=function(){this.pos[0]=f.CANVAS_GRID_SIZE*Math.round(this.pos[0]/f.CANVAS_GRID_SIZE);this.pos[1]=f.CANVAS_GRID_SIZE*Math.round(this.pos[1]/f.CANVAS_GRID_SIZE)};h.prototype.trace=function(a){this.console||(this.console=[]);this.console.push(a);this.console.length>h.MAX_CONSOLE&&this.console.shift();if(this.graph.onNodeTrace)this.graph.onNodeTrace(this, a)};h.prototype.setDirtyCanvas=function(a,b){this.graph&&this.graph.sendActionToCanvas("setDirty",[a,b])};h.prototype.loadImage=function(a){var b=new Image;b.src=f.node_images_path+a;b.ready=!1;var c=this;b.onload=function(){this.ready=!0;c.setDirtyCanvas(!0)};return b};h.prototype.captureInput=function(a){if(this.graph&&this.graph.list_of_graphcanvas)for(var b=this.graph.list_of_graphcanvas,c=0;ca.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos},enumerable:!0});Object.defineProperty(this,"size",{set:function(a){!a||2>a.length||(this._size[0]=Math.max(140,a[0]),this._size[1]=Math.max(80,a[1]))},get:function(){return this._size}, enumerable:!0})};r.prototype.configure=function(a){this.title=a.title;this._bounding.set(a.bounding);this.color=a.color;this.font=a.font};r.prototype.serialize=function(){var a=this._bounding;return{title:this.title,bounding:[Math.round(a[0]),Math.round(a[1]),Math.round(a[2]),Math.round(a[3])],color:this.color,font:this.font}};r.prototype.move=function(a,b,c){this._pos[0]+=a;this._pos[1]+=b;if(!c)for(c=0;c=this.viewport[0]&&d=this.viewport[1]&&cthis.max_scale&&(a=this.max_scale);if(a!=this.scale&&this.element){var c=this.element.getBoundingClientRect();if(c&&(b=b||[.5*c.width,.5*c.height],c=this.convertCanvasToOffset(b),this.scale=a,.01>Math.abs(this.scale-1)&&(this.scale=1),a=this.convertCanvasToOffset(b),a=[a[0]-c[0],a[1]-c[1]],this.offset[0]+=a[0],this.offset[1]+=a[1],this.onredraw))this.onredraw(this)}};w.prototype.changeDeltaScale=function(a,b){this.changeScale(this.scale*a,b)};w.prototype.reset=function(){this.scale= 1;this.offset[0]=0;this.offset[1]=0};v.LGraphCanvas=f.LGraphCanvas=g;g.DEFAULT_BACKGROUND_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII="; g.link_type_colors={"-1":f.EVENT_LINK_COLOR,number:"#AAA",node:"#DCA"};g.gradients={};g.prototype.clear=function(){this.fps=this.render_time=this.last_draw_time=this.frame=0;this.dragging_rectangle=null;this.selected_nodes={};this.selected_group=null;this.visible_nodes=[];this.connecting_node=this.node_capturing_input=this.node_over=this.node_dragged=null;this.highlighted_links={};this.dragging_canvas=!1;this.dirty_bgcanvas=this.dirty_canvas=!0;this.node_widget=this.node_in_panel=this.dirty_area= null;this.last_mouse=[0,0];this.last_mouseclick=0;this.pointer_is_double=this.pointer_is_down=!1;this.visible_area.set([0,0,0,0]);if(this.onClear)this.onClear()};g.prototype.setGraph=function(a,b){this.graph!=a&&(b||this.clear(),!a&&this.graph?this.graph.detachCanvas(this):(a.attachCanvas(this),this._graph_stack&&(this._graph_stack=null),this.setDirty(!0,!0)))};g.prototype.getTopGraph=function(){return this._graph_stack.length?this._graph_stack[0]:this.graph};g.prototype.openSubgraph=function(a){if(!a)throw"graph cannot be null"; if(this.graph==a)throw"graph cannot be the same";this.clear();this.graph&&(this._graph_stack||(this._graph_stack=[]),this._graph_stack.push(this.graph));a.attachCanvas(this);this.checkPanels();this.setDirty(!0,!0)};g.prototype.closeSubgraph=function(){if(this._graph_stack&&0!=this._graph_stack.length){var a=this.graph._subgraph_node,b=this._graph_stack.pop();this.selected_nodes={};this.highlighted_links={};b.attachCanvas(this);this.setDirty(!0,!0);a&&(this.centerOnNode(a),this.selectNodes([a]));this.ds.offset= [0,0];this.ds.scale=1}};g.prototype.getCurrentGraph=function(){return this.graph};g.prototype.setCanvas=function(a,b){if(a&&a.constructor===String&&(a=document.getElementById(a),!a))throw"Error creating LiteGraph canvas: Canvas not found";if(a!==this.canvas&&(!a&&this.canvas&&(b||this.unbindEvents()),this.canvas=a,this.ds.element=a)){a.className+=" lgraphcanvas";a.data=this;a.tabindex="1";this.bgcanvas=null;this.bgcanvas||(this.bgcanvas=document.createElement("canvas"),this.bgcanvas.width=this.canvas.width, this.bgcanvas.height=this.canvas.height);if(null==a.getContext){if("canvas"!=a.localName)throw"Element supplied for LGraphCanvas must be a element, you passed a "+a.localName;throw"This browser doesn't support Canvas";}null==(this.ctx=a.getContext("2d"))&&(a.webgl_enabled||console.warn("This canvas seems to be WebGL, enabling WebGL renderer"),this.enableWebGL());b||this.bindEvents()}};g.prototype._doNothing=function(a){a.preventDefault();return!1};g.prototype._doReturnTrue=function(a){a.preventDefault(); return!0};g.prototype.bindEvents=function(){if(this._events_binded)console.warn("LGraphCanvas: events already binded");else{var a=this.canvas,b=this.getCanvasWindow().document;this._mousedown_callback=this.processMouseDown.bind(this);this._mousewheel_callback=this.processMouseWheel.bind(this);this._mousemove_callback=this.processMouseMove.bind(this);this._mouseup_callback=this.processMouseUp.bind(this);f.pointerListenerAdd(a,"down",this._mousedown_callback,!0);a.addEventListener("mousewheel",this._mousewheel_callback, !1);f.pointerListenerAdd(a,"up",this._mouseup_callback,!0);f.pointerListenerAdd(a,"move",this._mousemove_callback);a.addEventListener("contextmenu",this._doNothing);a.addEventListener("DOMMouseScroll",this._mousewheel_callback,!1);this._key_callback=this.processKey.bind(this);a.addEventListener("keydown",this._key_callback,!0);b.addEventListener("keyup",this._key_callback,!0);this._ondrop_callback=this.processDrop.bind(this);a.addEventListener("dragover",this._doNothing,!1);a.addEventListener("dragend", this._doNothing,!1);a.addEventListener("drop",this._ondrop_callback,!1);a.addEventListener("dragenter",this._doReturnTrue,!1);this._events_binded=!0}};g.prototype.unbindEvents=function(){if(this._events_binded){var a=this.getCanvasWindow().document;f.pointerListenerRemove(this.canvas,"move",this._mousedown_callback);f.pointerListenerRemove(this.canvas,"up",this._mousedown_callback);f.pointerListenerRemove(this.canvas,"down",this._mousedown_callback);this.canvas.removeEventListener("mousewheel",this._mousewheel_callback); this.canvas.removeEventListener("DOMMouseScroll",this._mousewheel_callback);this.canvas.removeEventListener("keydown",this._key_callback);a.removeEventListener("keyup",this._key_callback);this.canvas.removeEventListener("contextmenu",this._doNothing);this.canvas.removeEventListener("drop",this._ondrop_callback);this.canvas.removeEventListener("dragenter",this._doReturnTrue);this._ondrop_callback=this._key_callback=this._mousewheel_callback=this._mousedown_callback=null;this._events_binded=!1}else console.warn("LGraphCanvas: no events binded")}; g.getFileExtension=function(a){var b=a.indexOf("?");-1!=b&&(a=a.substr(0,b));b=a.lastIndexOf(".");return-1==b?"":a.substr(b+1).toLowerCase()};g.prototype.enableWebGL=function(){this.gl=this.ctx=enableWebGLCanvas(this.canvas);this.ctx.webgl=!0;this.bgcanvas=this.canvas;this.bgctx=this.gl;this.canvas.webgl_enabled=!0};g.prototype.setDirty=function(a,b){a&&(this.dirty_canvas=!0);b&&(this.dirty_bgcanvas=!0)};g.prototype.getCanvasWindow=function(){if(!this.canvas)return window;var a=this.canvas.ownerDocument; return a.defaultView||a.parentWindow};g.prototype.startRendering=function(){function a(){this.pause_rendering||this.draw();var b=this.getCanvasWindow();this.is_rendering&&b.requestAnimationFrame(a.bind(this))}this.is_rendering||(this.is_rendering=!0,a.call(this))};g.prototype.stopRendering=function(){this.is_rendering=!1};g.prototype.blockClick=function(){this.block_click=!0;this.last_mouseclick=0};g.prototype.processMouseDown=function(a){this.set_canvas_dirty_on_mouse_event&&(this.dirty_canvas=!0); if(this.graph){this.adjustMouseEvent(a);var b=this.getCanvasWindow();g.active_canvas=this;var c=this,d=a.clientX,e=a.clientY;this.ds.viewport=this.viewport;d=!this.viewport||this.viewport&&d>=this.viewport[0]&&d=this.viewport[1]&&ef.getTime()-this.last_mouseclick&&void 0!==a.isPrimary&&a.isPrimary;this.mouse[0]=a.clientX;this.mouse[1]=a.clientY;this.graph_mouse[0]=a.canvasX;this.graph_mouse[1]=a.canvasY;this.last_click_position=[this.mouse[0],this.mouse[1]];this.pointer_is_double=this.pointer_is_down&&void 0!==a.isPrimary&&!a.isPrimary?!0:!1;this.pointer_is_down=!0;this.canvas.focus();f.closeAllContextMenus(b); if(!this.onMouse||1!=this.onMouse(a)){if(1!=a.which||this.pointer_is_double)2==a.which||3!=a.which&&!this.pointer_is_double||this.read_only||this.processContextMenu(k,a);else{a.ctrlKey&&(this.dragging_rectangle=new Float32Array(4),this.dragging_rectangle[0]=a.canvasX,this.dragging_rectangle[1]=a.canvasY,this.dragging_rectangle[2]=1,this.dragging_rectangle[3]=1,e=!0);var m=!1;if(k&&this.allow_interaction&&!e&&!this.read_only){this.live_mode||k.flags.pinned||this.bringToFront(k);if(!this.connecting_node&& !k.flags.collapsed&&!this.live_mode)if(!e&&!1!==k.resizable&&A(a.canvasX,a.canvasY,k.pos[0]+k.size[0]-5,k.pos[1]+k.size[1]-5,10,10))this.graph.beforeChange(),this.resizing_node=k,this.canvas.style.cursor="se-resize",e=!0;else{if(k.outputs)for(var l=0,q=k.outputs.length;lk.size[0]-f.NODE_TITLE_HEIGHT&&0>q[1]&&(c=this,setTimeout(function(){c.openSubgraph(k.subgraph)},10)),this.live_mode&&(l=m=!0));l||(this.allow_dragnodes&&(this.graph.beforeChange(),this.node_dragged=k),this.selected_nodes[k.id]||this.processNodeSelected(k,a));this.dirty_canvas=!0}}else{if(!this.read_only)for(l=0;lq[0]+4||a.canvasYq[1]+4)){this.showLinkMenu(m,a);this.over_link_center=null;break}this.selected_group=this.graph.getGroupOnPos(a.canvasX,a.canvasY);this.selected_group_resizing=!1;this.selected_group&&!this.read_only&&(a.ctrlKey&&(this.dragging_rectangle=null),10>B([a.canvasX,a.canvasY],[this.selected_group.pos[0]+this.selected_group.size[0],this.selected_group.pos[1]+this.selected_group.size[1]])*this.ds.scale?this.selected_group_resizing=!0:this.selected_group.recomputeInsideNodes());d&&!this.read_only&& this.allow_searchbox&&this.showSearchBox(a);m=!0}!e&&m&&this.allow_dragcanvas&&(this.dragging_canvas=!0)}this.last_mouse[0]=a.clientX;this.last_mouse[1]=a.clientY;this.last_mouseclick=f.getTime();this.last_mouse_dragging=!0;this.graph.change();(!b.document.activeElement||"input"!=b.document.activeElement.nodeName.toLowerCase()&&"textarea"!=b.document.activeElement.nodeName.toLowerCase())&&a.preventDefault();a.stopPropagation();if(this.onMouseDown)this.onMouseDown(a);return!1}}}};g.prototype.processMouseMove= function(a){this.autoresize&&this.resize();this.set_canvas_dirty_on_mouse_event&&(this.dirty_canvas=!0);if(this.graph){g.active_canvas=this;this.adjustMouseEvent(a);var b=[a.clientX,a.clientY];this.mouse[0]=b[0];this.mouse[1]=b[1];var c=[b[0]-this.last_mouse[0],b[1]-this.last_mouse[1]];this.last_mouse=b;this.graph_mouse[0]=a.canvasX;this.graph_mouse[1]=a.canvasY;if(this.block_click)return a.preventDefault(),!1;a.dragging=this.last_mouse_dragging;this.node_widget&&(this.processNodeWidgets(this.node_widget[0], this.graph_mouse,a,this.node_widget[1]),this.dirty_canvas=!0);if(this.dragging_rectangle)this.dragging_rectangle[2]=a.canvasX-this.dragging_rectangle[0],this.dragging_rectangle[3]=a.canvasY-this.dragging_rectangle[1],this.dirty_canvas=!0;else if(this.selected_group&&!this.read_only)this.selected_group_resizing?this.selected_group.size=[a.canvasX-this.selected_group.pos[0],a.canvasY-this.selected_group.pos[1]]:(this.selected_group.move(c[0]/this.ds.scale,c[1]/this.ds.scale,a.ctrlKey),this.selected_group._nodes.length&& (this.dirty_canvas=!0)),this.dirty_bgcanvas=!0;else if(this.dragging_canvas)this.ds.offset[0]+=c[0]/this.ds.scale,this.ds.offset[1]+=c[1]/this.ds.scale,this.dirty_bgcanvas=this.dirty_canvas=!0;else if(this.allow_interaction&&!this.read_only){this.connecting_node&&(this.dirty_canvas=!0);var d=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes);b=0;for(var e=this.graph._nodes.length;bm[0]+4||a.canvasY m[1]+4)){e=k;break}}e!=this.over_link_center&&(this.over_link_center=e,this.dirty_canvas=!0);this.canvas&&(this.canvas.style.cursor="")}if(this.node_capturing_input&&this.node_capturing_input!=d&&this.node_capturing_input.onMouseMove)this.node_capturing_input.onMouseMove(a,[a.canvasX-this.node_capturing_input.pos[0],a.canvasY-this.node_capturing_input.pos[1]],this);if(this.node_dragged&&!this.live_mode){for(b in this.selected_nodes)d=this.selected_nodes[b],d.pos[0]+=c[0]/this.ds.scale,d.pos[1]+=c[1]/ this.ds.scale;this.dirty_bgcanvas=this.dirty_canvas=!0}this.resizing_node&&!this.live_mode&&(c=[a.canvasX-this.resizing_node.pos[0],a.canvasY-this.resizing_node.pos[1]],b=this.resizing_node.computeSize(),c[0]=Math.max(b[0],c[0]),c[1]=Math.max(b[1],c[1]),this.resizing_node.setSize(c),this.canvas.style.cursor="se-resize",this.dirty_bgcanvas=this.dirty_canvas=!0)}a.preventDefault();return!1}};g.prototype.processMouseUp=function(a){if(void 0!==a.isPrimary&&!a.isPrimary)return!1;this.set_canvas_dirty_on_mouse_event&& (this.dirty_canvas=!0);if(this.graph){var b=this.getCanvasWindow().document;g.active_canvas=this;this.options.skip_events||(f.pointerListenerRemove(b,"move",this._mousemove_callback,!0),f.pointerListenerAdd(this.canvas,"move",this._mousemove_callback,!0),f.pointerListenerRemove(b,"up",this._mouseup_callback,!0));this.adjustMouseEvent(a);b=f.getTime();a.click_time=b-this.last_mouseclick;this.last_mouse_dragging=!1;this.last_click_position=null;this.block_click&&(this.block_click=!1);if(1==a.which)if(this.node_widget&& this.processNodeWidgets(this.node_widget[0],this.graph_mouse,a),this.node_widget=null,this.selected_group&&(this.selected_group.move(this.selected_group.pos[0]-Math.round(this.selected_group.pos[0]),this.selected_group.pos[1]-Math.round(this.selected_group.pos[1]),a.ctrlKey),this.selected_group.pos[0]=Math.round(this.selected_group.pos[0]),this.selected_group.pos[1]=Math.round(this.selected_group.pos[1]),this.selected_group._nodes.length&&(this.dirty_canvas=!0),this.selected_group=null),this.selected_group_resizing= !1,this.dragging_rectangle){if(this.graph){b=this.graph._nodes;var c=new Float32Array(4);this.deselectAllNodes();var d=Math.abs(this.dragging_rectangle[2]),e=Math.abs(this.dragging_rectangle[3]),k=0>this.dragging_rectangle[3]?this.dragging_rectangle[1]-e:this.dragging_rectangle[1];this.dragging_rectangle[0]=0>this.dragging_rectangle[2]?this.dragging_rectangle[0]-d:this.dragging_rectangle[0];this.dragging_rectangle[1]=k;this.dragging_rectangle[2]=d;this.dragging_rectangle[3]=e;e=[];for(k=0;ka.click_time&&A(a.canvasX,a.canvasY,d.pos[0],d.pos[1]-f.NODE_TITLE_HEIGHT,f.NODE_TITLE_HEIGHT,f.NODE_TITLE_HEIGHT)&&d.collapse();this.dirty_bgcanvas=this.dirty_canvas=!0;this.node_dragged.pos[0]=Math.round(this.node_dragged.pos[0]);this.node_dragged.pos[1]=Math.round(this.node_dragged.pos[1]);(this.graph.config.align_to_grid||this.align_to_grid)&&this.node_dragged.alignToGrid();if(this.onNodeMoved)this.onNodeMoved(this.node_dragged);this.graph.afterChange(this.node_dragged); this.node_dragged=null}else{d=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes);!d&&300>a.click_time&&this.deselectAllNodes();this.dirty_canvas=!0;this.dragging_canvas=!1;if(this.node_over&&this.node_over.onMouseUp)this.node_over.onMouseUp(a,[a.canvasX-this.node_over.pos[0],a.canvasY-this.node_over.pos[1]],this);if(this.node_capturing_input&&this.node_capturing_input.onMouseUp)this.node_capturing_input.onMouseUp(a,[a.canvasX-this.node_capturing_input.pos[0],a.canvasY-this.node_capturing_input.pos[1]])}else 2== a.which?(this.dirty_canvas=!0,this.dragging_canvas=!1):3==a.which&&(this.dirty_canvas=!0,this.dragging_canvas=!1);void 0!==a.isPrimary&&a.isPrimary&&(this.pointer_is_double=this.pointer_is_down=!1);this.graph.change();a.stopPropagation();a.preventDefault();return!1}};g.prototype.processMouseWheel=function(a){if(this.graph&&this.allow_dragcanvas){var b=null!=a.wheelDeltaY?a.wheelDeltaY:-60*a.detail;this.adjustMouseEvent(a);var c=a.clientX,d=a.clientY;if(!this.viewport||this.viewport&&c>=this.viewport[0]&& c=this.viewport[1]&&db&&(c*=1/1.1),this.ds.changeScale(c,[a.clientX,a.clientY]),this.graph.change(),a.preventDefault(),!1}};g.prototype.isOverNodeBox=function(a,b,c){var d=f.NODE_TITLE_HEIGHT;return A(b,c,a.pos[0]+2,a.pos[1]+2-d,d-4,d-4)?!0:!1};g.prototype.isOverNodeInput=function(a,b,c,d){if(a.inputs)for(var e=0,k=a.inputs.length;e=this.viewport[0]&&b=this.viewport[1]&&cc-this.graph._last_trigger_time)&&this.drawBackCanvas();(this.dirty_canvas||a)&&this.drawFrontCanvas();this.fps=this.render_time?1/this.render_time:0;this.frame+=1}};g.prototype.drawFrontCanvas=function(){this.dirty_canvas=!1;this.ctx||(this.ctx=this.bgcanvas.getContext("2d"));var a=this.ctx;if(a){var b=this.canvas;a.start2D&&!this.viewport&& (a.start2D(),a.restore(),a.setTransform(1,0,0,1,0,0));var c=this.viewport||this.dirty_area;c&&(a.save(),a.beginPath(),a.rect(c[0],c[1],c[2],c[3]),a.clip());this.clear_background&&(c?a.clearRect(c[0],c[1],c[2],c[3]):a.clearRect(0,0,b.width,b.height));this.bgcanvas==this.canvas?this.drawBackCanvas():a.drawImage(this.bgcanvas,0,0);if(this.onRender)this.onRender(b,a);this.show_info&&this.renderInfo(a,c?c[0]:0,c?c[1]:0);if(this.graph){a.save();this.ds.toCanvasContext(a);b=this.computeVisibleNodes(null, this.visible_nodes);for(var d=0;d> ";b.fillText(d+c.getTitle(),.5*a.width,40);b.restore()}c= !1;this.onRenderBackground&&(c=this.onRenderBackground(a,b));this.viewport||(b.restore(),b.setTransform(1,0,0,1,0,0));this.visible_links.length=0;if(this.graph){b.save();this.ds.toCanvasContext(b);if(this.background_image&&.5this.ds.scale;if(this.live_mode){if(!a.flags.collapsed&&(b.shadowColor="transparent",a.onDrawForeground))a.onDrawForeground(b,this,this.canvas)}else{var k= this.editor_alpha;b.globalAlpha=k;this.render_shadows&&!e?(b.shadowColor=f.DEFAULT_SHADOW_COLOR,b.shadowOffsetX=2*this.ds.scale,b.shadowOffsetY=2*this.ds.scale,b.shadowBlur=3*this.ds.scale):b.shadowColor="transparent";if(!a.flags.collapsed||!a.onDrawCollapsed||1!=a.onDrawCollapsed(b,this)){var m=a._shape||f.BOX_SHAPE;G.set(a.size);var l=a.horizontal;if(a.flags.collapsed){b.font=this.inner_text_font;var q=a.getTitle?a.getTitle():a.title;null!=q&&(a._collapsed_width=Math.min(a.size[0],b.measureText(q).width+ 2*f.NODE_TITLE_HEIGHT),G[0]=a._collapsed_width,G[1]=0)}a.clip_area&&(b.save(),b.beginPath(),m==f.BOX_SHAPE?b.rect(0,0,G[0],G[1]):m==f.ROUND_SHAPE?b.roundRect(0,0,G[0],G[1],[10]):m==f.CIRCLE_SHAPE&&b.arc(.5*G[0],.5*G[1],.5*G[0],0,2*Math.PI),b.clip());a.has_errors&&(d="red");this.drawNodeShape(a,b,G,c,d,a.is_selected,a.mouseOver);b.shadowColor="transparent";if(a.onDrawForeground)a.onDrawForeground(b,this,this.canvas);b.textAlign=l?"center":"left";b.font=this.inner_text_font;d=!e;m=this.connecting_output; b.lineWidth=1;q=0;var u=new Float32Array(2);if(!a.flags.collapsed){if(a.inputs)for(c=0;cthis.ds.scale,q=a._shape||a.constructor.shape||f.ROUND_SHAPE,u=a.constructor.title_mode,h=!0;u==f.TRANSPARENT_TITLE||u==f.NO_TITLE?h=!1:u==f.AUTOHIDE_TITLE&&m&&(h=!0);z[0]= 0;z[1]=h?-e:0;z[2]=c[0]+1;z[3]=h?c[1]+e:c[1];m=b.globalAlpha;b.beginPath();q==f.BOX_SHAPE||l?b.fillRect(z[0],z[1],z[2],z[3]):q==f.ROUND_SHAPE||q==f.CARD_SHAPE?b.roundRect(z[0],z[1],z[2],z[3],q==f.CARD_SHAPE?[this.round_radius,this.round_radius,0,0]:[this.round_radius]):q==f.CIRCLE_SHAPE&&b.arc(.5*c[0],.5*c[1],.5*c[0],0,2*Math.PI);b.fill();!a.flags.collapsed&&h&&(b.shadowColor="transparent",b.fillStyle="rgba(0,0,0,0.2)",b.fillRect(0,-1,z[2],2));b.shadowColor="transparent";if(a.onDrawBackground)a.onDrawBackground(b, this,this.canvas,this.graph_mouse);if(h||u==f.TRANSPARENT_TITLE){if(a.onDrawTitleBar)a.onDrawTitleBar(b,e,c,this.ds.scale,d);else if(u!=f.TRANSPARENT_TITLE&&(a.constructor.title_color||this.render_title_colored)){h=a.constructor.title_color||d;a.flags.collapsed&&(b.shadowColor=f.DEFAULT_SHADOW_COLOR);if(this.use_gradients){var p=g.gradients[h];p||(p=g.gradients[h]=b.createLinearGradient(0,0,400,0),p.addColorStop(0,h),p.addColorStop(1,"#000"));b.fillStyle=p}else b.fillStyle=h;b.beginPath();q==f.BOX_SHAPE|| l?b.rect(0,-e,c[0]+1,e):(q==f.ROUND_SHAPE||q==f.CARD_SHAPE)&&b.roundRect(0,-e,c[0]+1,e,a.flags.collapsed?[this.round_radius]:[this.round_radius,this.round_radius,0,0]);b.fill();b.shadowColor="transparent"}if(a.onDrawTitleBox)a.onDrawTitleBox(b,e,c,this.ds.scale);else q==f.ROUND_SHAPE||q==f.CIRCLE_SHAPE||q==f.CARD_SHAPE?(l&&(b.fillStyle="black",b.beginPath(),b.arc(.5*e,-.5*e,6,0,2*Math.PI),b.fill()),b.fillStyle=a.boxcolor||f.NODE_DEFAULT_BOXCOLOR,l?b.fillRect(.5*e-5,-.5*e-5,10,10):(b.beginPath(),b.arc(.5* e,-.5*e,5,0,2*Math.PI),b.fill())):(l&&(b.fillStyle="black",b.fillRect(.5*(e-10)-1,-.5*(e+10)-1,12,12)),b.fillStyle=a.boxcolor||f.NODE_DEFAULT_BOXCOLOR,b.fillRect(.5*(e-10),-.5*(e+10),10,10));b.globalAlpha=m;if(a.onDrawTitleText)a.onDrawTitleText(b,e,c,this.ds.scale,this.title_text_font,k);!l&&(b.font=this.title_text_font,m=String(a.getTitle()))&&(b.fillStyle=k?f.NODE_SELECTED_TITLE_COLOR:a.constructor.title_text_color||this.node_title_color,a.flags.collapsed?(b.textAlign="left",b.measureText(m),b.fillText(m.substr(0, 20),e,f.NODE_TITLE_TEXT_Y-e),b.textAlign="left"):(b.textAlign="left",b.fillText(m,e,f.NODE_TITLE_TEXT_Y-e)));a.flags.collapsed||!a.subgraph||a.skip_subgraph_button||(m=f.NODE_TITLE_HEIGHT,h=a.size[0]-m,p=f.isInsideRectangle(this.graph_mouse[0]-a.pos[0],this.graph_mouse[1]-a.pos[1],h+2,-m+2,m-4,m-4),b.fillStyle=p?"#888":"#555",q==f.BOX_SHAPE||l?b.fillRect(h+2,-m+2,m-4,m-4):(b.beginPath(),b.roundRect(h+2,-m+2,m-4,m-4,[4]),b.fill()),b.fillStyle="#333",b.beginPath(),b.moveTo(h+.2*m,.6*-m),b.lineTo(h+ .8*m,.6*-m),b.lineTo(h+.5*m,.3*-m),b.fill());if(a.onDrawTitle)a.onDrawTitle(b)}if(k){if(a.onBounding)a.onBounding(z);u==f.TRANSPARENT_TITLE&&(z[1]-=e,z[3]+=e);b.lineWidth=1;b.globalAlpha=.8;b.beginPath();q==f.BOX_SHAPE?b.rect(-6+z[0],-6+z[1],12+z[2],12+z[3]):q==f.ROUND_SHAPE||q==f.CARD_SHAPE&&a.flags.collapsed?b.roundRect(-6+z[0],-6+z[1],12+z[2],12+z[3],[2*this.round_radius]):q==f.CARD_SHAPE?b.roundRect(-6+z[0],-6+z[1],12+z[2],12+z[3],[2*this.round_radius,2,2*this.round_radius,2]):q==f.CIRCLE_SHAPE&& b.arc(.5*c[0],.5*c[1],.5*c[0]+6,0,2*Math.PI);b.strokeStyle=f.NODE_BOX_OUTLINE_COLOR;b.stroke();b.strokeStyle=d;b.globalAlpha=1}};var I=new Float32Array(4),D=new Float32Array(4),H=new Float32Array(2),F=new Float32Array(2);g.prototype.drawConnections=function(a){var b=f.getTime(),c=this.visible_area;I[0]=c[0]-20;I[1]=c[1]-20;I[2]=c[2]+40;I[3]=c[3]+40;a.lineWidth=this.connections_width;a.fillStyle="#AAA";a.strokeStyle="#AAA";a.globalAlpha=this.editor_alpha;c=this.graph._nodes;for(var d=0,e=c.length;d< e;++d){var k=c[d];if(k.inputs&&k.inputs.length)for(var m=0;mD[2]&&(D[0]+=D[2],D[2]=Math.abs(D[2]));0>D[3]&&(D[1]+=D[3],D[3]=Math.abs(D[3]));if(y(D,I)){var x=q.outputs[u];u=k.inputs[m];if(x&& u&&(q=x.dir||(q.horizontal?f.DOWN:f.RIGHT),u=u.dir||(k.horizontal?f.UP:f.LEFT),this.renderLink(a,g,p,l,!1,0,null,q,u),l&&l._last_time&&1E3>b-l._last_time)){x=2-.002*(b-l._last_time);var h=a.globalAlpha;a.globalAlpha=h*x;this.renderLink(a,g,p,l,!0,x,"white",q,u);a.globalAlpha=h}}}}}}a.globalAlpha=1};g.prototype.renderLink=function(a,b,c,d,e,k,m,l,q,u){d&&this.visible_links.push(d);!m&&d&&(m=d.color||g.link_type_colors[d.type]);m||(m=this.default_link_color);null!=d&&this.highlighted_links[d.id]&&(m= "#FFF");l=l||f.RIGHT;q=q||f.LEFT;var h=B(b,c);this.render_connections_border&&.6b[1]?0:Math.PI,a.save(),a.translate(p[0],p[1]),a.rotate(h),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore(),a.save(),a.translate(d[0],d[1]),a.rotate(u),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0, 7),a.lineTo(5,-3),a.fill(),a.restore()),a.beginPath(),a.arc(e[0],e[1],5,0,2*Math.PI),a.fill());if(k)for(a.fillStyle=m,p=0;5>p;++p)k=(.001*f.getTime()+.2*p)%1,e=this.computeConnectionPoint(b,c,k,l,q),a.beginPath(),a.arc(e[0],e[1],5,0,2*Math.PI),a.fill()};g.prototype.computeConnectionPoint=function(a,b,c,d,e){d=d||f.RIGHT;e=e||f.LEFT;var k=B(a,b),m=[a[0],a[1]],l=[b[0],b[1]];switch(d){case f.LEFT:m[0]+=-.25*k;break;case f.RIGHT:m[0]+=.25*k;break;case f.UP:m[1]+=-.25*k;break;case f.DOWN:m[1]+=.25*k}switch(e){case f.LEFT:l[0]+= -.25*k;break;case f.RIGHT:l[0]+=.25*k;break;case f.UP:l[1]+=-.25*k;break;case f.DOWN:l[1]+=.25*k}d=(1-c)*(1-c)*(1-c);e=3*(1-c)*(1-c)*c;k=3*(1-c)*c*c;c*=c*c;return[d*a[0]+e*m[0]+k*l[0]+c*b[0],d*a[1]+e*m[1]+k*l[1]+c*b[1]]};g.prototype.drawExecutionOrder=function(a){a.shadowColor="transparent";a.globalAlpha=.25;a.textAlign="center";a.strokeStyle="white";a.globalAlpha=.75;for(var b=this.visible_nodes,c=0;ck||k>h-12||mp.last_y+x||void 0===p.last_y)){d=p.value;switch(p.type){case "button":c.type===f.pointerevents_method+"down"&&(p.callback&&setTimeout(function(){p.callback(p,q,a,b,c)},20),this.dirty_canvas=p.clicked=!0);break;case "slider":u=Math.clamp((k-15)/(h-30),0,1);p.value=p.options.min+(p.options.max-p.options.min)*u;p.callback&&setTimeout(function(){e(p,p.value)},20);this.dirty_canvas=!0;break;case "number":case "combo":d= p.value;if(c.type==f.pointerevents_method+"move"&&"number"==p.type)p.value+=.1*c.deltaX*(p.options.step||1),null!=p.options.min&&p.valuep.options.max&&(p.value=p.options.max);else if(c.type==f.pointerevents_method+"down"){var r=p.options.values;r&&r.constructor===Function&&(r=p.options.values(p,a));var n=null;"number"!=p.type&&(n=r.constructor===Array?r:Object.keys(r));k=40>k?-1:k>h-40?1:0;if("number"==p.type)p.value+=.1*k*(p.options.step|| 1),null!=p.options.min&&p.valuep.options.max&&(p.value=p.options.max);else if(k)u=-1,this.last_mouseclick=0,u=r.constructor===Object?n.indexOf(String(p.value))+k:n.indexOf(p.value)+k,u>=n.length&&(u=n.length-1),0>u&&(u=0),p.value=r.constructor===Array?r[u]:u;else{var t=r!=n?Object.values(r):r;new f.ContextMenu(t,{scale:Math.max(1,this.ds.scale),event:c,className:"dark",callback:function(a,b,c){r!=n&&(a=t.indexOf(a));this.value=a; e(this,a);q.dirty_canvas=!0;return!1}.bind(p)},u)}}else c.type==f.pointerevents_method+"up"&&"number"==p.type&&(k=40>k?-1:k>h-40?1:0,200>c.click_time&&0==k&&this.prompt("Value",p.value,function(a){this.value=Number(a);e(this,this.value)}.bind(p),c));d!=p.value&&setTimeout(function(){e(this,this.value)}.bind(p),20);this.dirty_canvas=!0;break;case "toggle":c.type==f.pointerevents_method+"down"&&(p.value=!p.value,setTimeout(function(){e(p,p.value)},20));break;case "string":case "text":c.type==f.pointerevents_method+ "down"&&this.prompt("Value",p.value,function(a){this.value=a;e(this,a)}.bind(p),c,p.options?p.options.multiline:!1);break;default:p.mouse&&(this.dirty_canvas=p.mouse(c,[k,m],a))}if(d!=p.value){if(a.onWidgetChanged)a.onWidgetChanged(p.name,p.value,d,p);a.graph._version++}return p}}}return null};g.prototype.drawGroups=function(a,b){if(this.graph){a=this.graph._groups;b.save();b.globalAlpha=.5*this.editor_alpha;for(var c=0;cc&&.01>b.editor_alpha&&(clearInterval(d),1>c&&(b.live_mode=!0));1"+(q.label?q.label:l)+""+a+"", value:l})}if(m.length)return new f.ContextMenu(m,{event:c,callback:function(a,b,c,d){e&&(b=this.getBoundingClientRect(),k.showEditPropertyValue(e,a.value,{position:[b.left,b.top]}))},parentMenu:d,allow_html:!0,node:e},b),!1}};g.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};g.onResizeNode=function(a,b,c,d,e){if(e){e.size=e.computeSize();if(e.onResize)e.onResize(e.size);e.setDirtyCanvas(!0,!0)}};g.prototype.showLinkMenu=function(a,b){var c=this;console.log(a); var d=new f.ContextMenu(["Add Node",null,"Delete"],{event:b,title:null!=a.data?a.data.constructor.name:null,callback:function(b,f,m){switch(b){case "Add Node":g.onMenuAdd(null,null,m,d,function(b){console.log("node autoconnect");var d=c.graph.getNodeById(a.origin_id),e=c.graph.getNodeById(a.target_id);b.inputs&&b.inputs.length&&b.outputs&&b.outputs.length&&d.outputs[a.origin_slot].type==b.inputs[0].type&&b.outputs[0].type==e.inputs[0].type&&(d.connect(a.origin_slot,b,0),b.connect(0,e,a.target_slot), b.pos[0]-=.5*b.size[0])});break;case "Delete":c.graph.removeLink(a.id)}}});return!1};g.onShowPropertyEditor=function(a,b,c,d,e){function f(){var b=q.value;"Number"==a.type?b=Number(b):"Boolean"==a.type&&(b=!!b);e[m]=b;l.parentNode&&l.parentNode.removeChild(l);e.setDirtyCanvas(!0,!0)}var m=a.property||"title";b=e[m];var l=document.createElement("div");l.className="graphdialog";l.innerHTML="";l.querySelector(".name").innerText= m;var q=l.querySelector(".value");q&&(q.value=b,q.addEventListener("blur",function(a){this.focus()}),q.addEventListener("keydown",function(a){if(13==a.keyCode||"textarea"==a.target.localName)f(),a.preventDefault(),a.stopPropagation()}));b=g.active_canvas.canvas;c=b.getBoundingClientRect();var u=d=-20;c&&(d-=c.left,u-=c.top);event?(l.style.left=event.clientX+d+"px",l.style.top=event.clientY+u+"px"):(l.style.left=.5*b.width+d+"px",l.style.top=.5*b.height+u+"px");l.querySelector("button").addEventListener("click", f);b.parentNode.appendChild(l)};g.prototype.prompt=function(a,b,c,d,e){var k=this;a=a||"";var m=!1,l=document.createElement("div");l.className="graphdialog rounded";l.innerHTML=e?" ":" ";l.close=function(){k.prompt_box=null;l.parentNode&&l.parentNode.removeChild(l)};1g.search_limit)break}}u=null;if(Array.prototype.filter)u=Object.keys(f.registered_node_types).filter(d);else for(q in u=[],f.registered_node_types)d(q)&&u.push(q);for(q=0;qg.search_limit);q++);}}var e=this,k=g.active_canvas,m=k.canvas,l=m.ownerDocument||document,q=document.createElement("div");q.className="litegraph litesearchbox graphdialog rounded";q.innerHTML="Search
"; q.close=function(){e.search_box=null;l.body.focus();l.body.style.overflow="";setTimeout(function(){e.canvas.focus()},20);q.parentNode&&q.parentNode.removeChild(q)};var u=null;1m.height-200&&(h.style.maxHeight=m.height-a.layerY-20+"px");n.focus();return q};g.prototype.showEditPropertyValue=function(a,b,c){function d(){e(p.value)}function e(d){f&&f.values&&f.values.constructor===Object&&void 0!=f.values[d]&&(d=f.values[d]);"number"==typeof a.properties[b]&&(d=Number(d));if("array"==m||"object"==m)d=JSON.parse(d);a.properties[b]= d;a.graph&&a.graph._version++;if(a.onPropertyChanged)a.onPropertyChanged(b,d);if(c.onclose)c.onclose();h.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){c=c||{};var f=a.getPropertyInfo(b),m=f.type,l="";if("string"==m||"number"==m||"array"==m||"object"==m)l="";else if("enum"!=m&&"combo"!=m||!f.values)if("boolean"==m)l="";else{console.warn("unknown type: "+m); return}else{l=""}var h=this.createDialog(""+(f.label?f.label:b)+""+l+"",c);if("enum"!=m&&"combo"!=m||!f.values)if("boolean"==m)(p=h.querySelector("input"))&&p.addEventListener("click",function(a){e(!!p.checked)});else{if(p=h.querySelector("input"))p.addEventListener("blur", function(a){this.focus()}),g=void 0!==a.properties[b]?a.properties[b]:"","string"!==m&&(g=JSON.stringify(g)),p.value=g,p.addEventListener("keydown",function(a){13==a.keyCode&&(d(),a.preventDefault(),a.stopPropagation())})}else{var p=h.querySelector("select");p.addEventListener("change",function(a){e(a.target.value)})}h.querySelector("button").addEventListener("click",d);return h}};g.prototype.createDialog=function(a,b){b=b||{};var c=document.createElement("div");c.className="graphdialog";c.innerHTML= a;a=this.canvas.getBoundingClientRect();var d=-20,e=-20;a&&(d-=a.left,e-=a.top);b.position?(d+=b.position[0],e+=b.position[1]):b.event?(d+=b.event.clientX,e+=b.event.clientY):(d+=.5*this.canvas.width,e+=.5*this.canvas.height);c.style.left=d+"px";c.style.top=e+"px";this.canvas.parentNode.appendChild(c);c.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return c};g.prototype.createPanel=function(a,b){b=b||{};var c=b.window||window,d=document.createElement("div");d.className="litegraph dialog"; d.innerHTML="
";d.header=d.querySelector(".dialog-header");b.width&&(d.style.width=b.width+(b.width.constructor===Number?"px":""));b.height&&(d.style.height=b.height+(b.height.constructor===Number?"px":""));b.closable&&(b=document.createElement("span"),b.innerHTML="✕",b.classList.add("close"),b.addEventListener("click",function(){d.close()}),d.header.appendChild(b)); d.title_element=d.querySelector(".dialog-title");d.title_element.innerText=a;d.content=d.querySelector(".dialog-content");d.footer=d.querySelector(".dialog-footer");d.close=function(){this.parentNode&&this.parentNode.removeChild(this)};d.clear=function(){this.content.innerHTML=""};d.addHTML=function(a,b,c){var e=document.createElement("div");b&&(e.className=b);e.innerHTML=a;c?d.footer.appendChild(e):d.content.appendChild(e);return e};d.addButton=function(a,b,c){var e=document.createElement("button"); e.innerText=a;e.options=c;e.classList.add("btn");e.addEventListener("click",b);d.footer.appendChild(e);return e};d.addSeparator=function(){var a=document.createElement("div");a.className="separator";d.content.appendChild(a)};d.addWidget=function(a,b,m,l,q){function e(a,b){console.log("change",a,b);l.callback&&l.callback(a,b);q&&q(a,b)}l=l||{};var k=String(m);a=a.toLowerCase();"number"==a&&(k=m.toFixed(3));var h=document.createElement("div");h.className="property";h.innerHTML=""; h.querySelector(".property_name").innerText=l.label||b;var x=h.querySelector(".property_value");x.innerText=k;h.dataset.property=b;h.dataset.type=l.type||a;h.options=l;h.value=m;if("boolean"==a)h.classList.add("boolean"),m&&h.classList.add("bool-on"),h.addEventListener("click",function(){var a=this.dataset.property;this.value=!this.value;this.classList.toggle("bool-on");this.querySelector(".property_value").innerText=this.value?"true":"false";e(a,this.value)});else if("string"==a||"number"==a)x.setAttribute("contenteditable", !0),x.addEventListener("keydown",function(a){"Enter"==a.code&&(a.preventDefault(),this.blur())}),x.addEventListener("blur",function(){var a=this.innerText,b=this.parentNode.dataset.property;"number"==this.parentNode.dataset.type&&(a=Number(a));e(b,a)});else if("enum"==a||"combo"==a)k=g.getPropertyPrintableValue(m,l.values),x.innerText=k,x.addEventListener("click",function(a){var b=this.parentNode.dataset.property,d=this;new f.ContextMenu(l.values||[],{event:a,className:"dark",callback:function(a, c,f){d.innerText=a;e(b,a);return!1}},c)});d.content.appendChild(h);return h};return d};g.getPropertyPrintableValue=function(a,b){if(!b||b.constructor===Array)return String(a);if(b.constructor===Object){var c="",d;for(d in b)if(b[d]==a){c=d;break}return String(a)+" ("+c+")"}};g.prototype.showShowNodePanel=function(a){window.SELECTED_NODE=a;var b=document.querySelector("#node-panel");b&&b.close();var c=this.getCanvasWindow();b=this.createPanel(a.title||"",{closable:!0,window:c});b.id="node-panel";b.node= a;b.classList.add("settings");var d=this;(function(){b.content.innerHTML="";b.addHTML(""+a.type+""+(a.constructor.desc||"")+"");b.addHTML("

Properties

");for(var c in a.properties){var f=a.properties[c],m=a.getPropertyInfo(c);a.onAddPropertyToPanel&&a.onAddPropertyToPanel(c,b)||b.addWidget(m.widget||m.type,c,f,m,function(b,c){d.graph.beforeChange(a);a.setProperty(b,c);d.graph.afterChange();d.dirty_canvas= !0})}b.addSeparator();if(a.onShowCustomPanelInfo)a.onShowCustomPanelInfo(b);b.addButton("Delete",function(){a.block_delete||(a.graph.remove(a),b.close())}).classList.add("delete")})();this.canvas.parentNode.appendChild(b)};g.prototype.showSubgraphPropertiesDialog=function(a){function b(){d.clear();if(a.inputs)for(var c=0;c", "subgraph_property");m.dataset.name=f.name;m.dataset.slot=c;m.querySelector(".name").innerText=f.name;m.querySelector(".type").innerText=f.type;m.querySelector("button").addEventListener("click",function(c){a.removeInput(Number(this.parentNode.dataset.slot));b()})}}}console.log("showing subgraph properties dialog");var c=this.canvas.parentNode.querySelector(".subgraph_dialog");c&&c.close();var d=this.createPanel("Subgraph Inputs",{closable:!0,width:500});d.node=a;d.classList.add("subgraph_dialog"); d.addHTML(" + NameType","subgraph_property extra",!0).querySelector("button").addEventListener("click",function(c){c=this.parentNode;var d=c.querySelector(".name").value,e=c.querySelector(".type").value;d&&-1==a.findInputSlot(d)&&(a.addInput(d,e),c.querySelector(".name").value="",c.querySelector(".type").value="",b())});b();this.canvas.parentNode.appendChild(d);return d};g.prototype.showSubgraphPropertiesDialogRight= function(a){function b(){e.clear();if(a.outputs)for(var c=0;c","subgraph_property");f.dataset.name=d.name;f.dataset.slot=c;f.querySelector(".name").innerText=d.name;f.querySelector(".type").innerText=d.type;f.querySelector("button").addEventListener("click",function(c){a.removeOutput(Number(this.parentNode.dataset.slot)); b()})}}}function c(){var c=this.parentNode,d=c.querySelector(".name").value,e=c.querySelector(".type").value;d&&-1==a.findOutputSlot(d)&&(a.addOutput(d,e),c.querySelector(".name").value="",c.querySelector(".type").value="",b())}var d=this.canvas.parentNode.querySelector(".subgraph_dialog");d&&d.close();var e=this.createPanel("Subgraph Outputs",{closable:!0,width:500});e.node=a;e.classList.add("subgraph_dialog");d=e.addHTML(" + NameType", "subgraph_property extra",!0);d.querySelector(".name").addEventListener("keydown",function(a){13==a.keyCode&&c.apply(this)});d.querySelector("button").addEventListener("click",function(a){c.apply(this)});b();this.canvas.parentNode.appendChild(e);return e};g.prototype.checkPanels=function(){if(this.canvas)for(var a=this.canvas.parentNode.querySelectorAll(".litegraph.dialog"),b=0;bNo color"});for(var k in g.node_colors)a=g.node_colors[k],a={value:k,content:""+k+""},b.push(a);new f.ContextMenu(b,{event:c,callback:function(a){e&&((a=a.value?g.node_colors[a.value]:null)?e.constructor===f.LGraphGroup?e.color=a.groupcolor:(e.color=a.color,e.bgcolor=a.bgcolor): (delete e.color,delete e.bgcolor),e.setDirtyCanvas(!0,!0))},parentMenu:d,node:e});return!1};g.onMenuNodeShapes=function(a,b,c,d,e){if(!e)throw"no node passed";new f.ContextMenu(f.VALID_SHAPES,{event:c,callback:function(a){e&&(e.graph.beforeChange(e),e.shape=a,e.graph.afterChange(e),e.setDirtyCanvas(!0))},parentMenu:d,node:e});return!1};g.onMenuNodeRemove=function(a,b,c,d,e){if(!e)throw"no node passed";!1!==e.removable&&(a=e.graph,a.beforeChange(),a.remove(e),a.afterChange(),e.setDirtyCanvas(!0,!0))}; g.onMenuNodeToSubgraph=function(a,b,c,d,e){a=e.graph;if(b=g.active_canvas)c=Object.values(b.selected_nodes||{}),c.length||(c=[e]),d=f.createNode("graph/subgraph"),d.pos=e.pos.concat(),a.add(d),d.buildFromNodes(c),b.deselectAllNodes(),e.setDirtyCanvas(!0,!0)};g.onMenuNodeClone=function(a,b,c,d,e){0!=e.clonable&&(a=e.clone())&&(a.pos=[e.pos[0]+5,e.pos[1]+5],e.graph.beforeChange(),e.graph.add(a),e.graph.afterChange(),e.setDirtyCanvas(!0,!0))};g.node_colors={red:{color:"#322",bgcolor:"#533",groupcolor:"#A88"}, brown:{color:"#332922",bgcolor:"#593930",groupcolor:"#b06634"},green:{color:"#232",bgcolor:"#353",groupcolor:"#8A8"},blue:{color:"#223",bgcolor:"#335",groupcolor:"#88A"},pale_blue:{color:"#2a363b",bgcolor:"#3f5159",groupcolor:"#3f789e"},cyan:{color:"#233",bgcolor:"#355",groupcolor:"#8AA"},purple:{color:"#323",bgcolor:"#535",groupcolor:"#a1309b"},yellow:{color:"#432",bgcolor:"#653",groupcolor:"#b58b2a"},black:{color:"#222",bgcolor:"#000",groupcolor:"#444"}};g.prototype.getCanvasMenuOptions=function(){if(this.getMenuOptions)var a= this.getMenuOptions();else a=[{content:"Add Node",has_submenu:!0,callback:g.onMenuAdd},{content:"Add Group",callback:g.onGroupAdd}],this._graph_stack&&0Name",d),k=q.querySelector("input");k&&f&&(k.value=f.label||"");q.querySelector("button").addEventListener("click",function(a){k.value&& (f&&(f.label=k.value),c.setDirty(!0));q.close()})}},extra:a};a&&(k.title=a.type);var m=null;a&&(m=a.getSlotInPosition(b.canvasX,b.canvasY),g.active_node=a);m?(e=[],a.getSlotMenuOptions?e=a.getSlotMenuOptions(m):(m&&m.output&&m.output.links&&m.output.links.length&&e.push({content:"Disconnect Links",slot:m}),b=m.input||m.output,e.push(b.locked||!b.removable?"Cannot remove":{content:"Remove Slot",slot:m}),e.push(b.nameLocked?"Cannot rename":{content:"Rename Slot",slot:m})),k.title=(m.input?m.input.type: m.output.type)||"*",m.input&&m.input.type==f.ACTION&&(k.title="Action"),m.output&&m.output.type==f.EVENT&&(k.title="Event")):a?e=this.getNodeMenuOptions(a):(e=this.getCanvasMenuOptions(),(m=this.graph.getGroupOnPos(b.canvasX,b.canvasY))&&e.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:m,options:this.getGroupMenuOptions(m)}}));e&&new f.ContextMenu(e,k,d)};"undefined"!=typeof window&&window.CanvasRenderingContext2D&&!window.CanvasRenderingContext2D.prototype.roundRect&& (window.CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e,f){var k,g;if(0===e)this.rect(a,b,c,d);else{void 0===f&&(f=e);if(null!=e&&e.constructor===Array)if(1==e.length)var q=k=g=f=e[0];else if(2==e.length)q=f=e[0],k=g=e[1];else if(4==e.length)q=e[0],k=e[1],g=e[2],f=e[3];else return;else q=e||0,k=e||0,g=f||0,f=f||0;this.moveTo(a+q,b);this.lineTo(a+c-k,b);this.quadraticCurveTo(a+c,b,a+c,b+k);this.lineTo(a+c,b+d-f);this.quadraticCurveTo(a+c,b+d,a+c-f,b+d);this.lineTo(a+f,b+d);this.quadraticCurveTo(a, b+d,a,b+d-g);this.lineTo(a,b+g);this.quadraticCurveTo(a,b,a+q,b)}});f.compareObjects=function(a,b){for(var c in a)if(a[c]!=b[c])return!1;return!0};f.distance=B;f.colorToString=function(a){return"rgba("+Math.round(255*a[0]).toFixed()+","+Math.round(255*a[1]).toFixed()+","+Math.round(255*a[2]).toFixed()+","+(4==a.length?a[3].toFixed(2):"1.0")+")"};f.isInsideRectangle=A;f.growBounding=function(a,b,c){ba[2]&&(a[2]=b);ca[3]&&(a[3]=c)};f.isInsideBounding=function(a,b){return a[0]< b[0][0]||a[1]b[1][0]||a[1]>b[1][1]?!1:!0};f.overlapBounding=y;f.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),c=0,d,e,f=0;6>f;f+=2)d="0123456789ABCDEF".indexOf(a.charAt(f)),e="0123456789ABCDEF".indexOf(a.charAt(f+1)),b[c]=16*d+e,c++;return b};f.num2hex=function(a){for(var b="#",c,d,e=0;3>e;e++)c=a[e]/16,d=a[e]%16,b+="0123456789ABCDEF".charAt(c)+"0123456789ABCDEF".charAt(d);return b};C.prototype.addItem=function(a,b,c){function d(a){var b= this.value;b&&b.has_submenu&&e.call(this,a)}function e(a){var b=this.value,d=!0;k.current_submenu&&k.current_submenu.close(a);if(c.callback){var e=c.callback.call(this,b,c,a,k,c.node);!0===e&&(d=!1)}if(b&&(b.callback&&!c.ignore_item_callbacks&&!0!==b.disabled&&(e=b.callback.call(this,b,c,a,k,c.extra),!0===e&&(d=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";new k.constructor(b.submenu.options,{callback:b.submenu.callback,event:a,parentMenu:k,ignore_item_callbacks:b.submenu.ignore_item_callbacks, title:b.submenu.title,extra:b.submenu.extra,autoopen:c.autoopen});d=!1}d&&!k.lock&&k.close()}var k=this;c=c||{};var g=document.createElement("div");g.className="litemenu-entry submenu";var l=!1;if(null===b)g.classList.add("separator");else{g.innerHTML=b&&b.title?b.title:a;if(g.value=b)b.disabled&&(l=!0,g.classList.add("disabled")),(b.submenu||b.has_submenu)&&g.classList.add("has_submenu");"function"==typeof b?(g.dataset.value=a,g.onclick_callback=b):g.dataset.value=b;b.className&&(g.className+=" "+ b.className)}this.root.appendChild(g);l||g.addEventListener("click",e);c.autoopen&&f.pointerListenerAdd(g,"enter",d);return g};C.prototype.close=function(a,b){this.root.parentNode&&this.root.parentNode.removeChild(this.root);this.parentMenu&&!b&&(this.parentMenu.lock=!1,this.parentMenu.current_submenu=null,void 0===a?this.parentMenu.close():a&&!C.isCursorOverElement(a,this.parentMenu.root)&&C.trigger(this.parentMenu.root,f.pointerevents_method+"leave",a));this.current_submenu&&this.current_submenu.close(a, !0);this.root.closing_timer&&clearTimeout(this.root.closing_timer)};C.trigger=function(a,b,c,d){var e=document.createEvent("CustomEvent");e.initCustomEvent(b,!0,!0,c);e.srcElement=d;a.dispatchEvent?a.dispatchEvent(e):a.__events&&a.__events.dispatchEvent(e);return e};C.prototype.getTopMenu=function(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this};C.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event}; C.isCursorOverElement=function(a,b){var c=a.clientX;a=a.clientY;return(b=b.getBoundingClientRect())?a>b.top&&ab.left&&cMath.abs(b))return d[1];a=(a-d[0])/b;return d[1]*(1- a)+e[1]*a}}return 0}};E.prototype.draw=function(a,b,c,d,e,f){if(c=this.points){this.size=b;var k=b[0]-2*this.margin;b=b[1]-2*this.margin;e=e||"#666";a.save();a.translate(this.margin,this.margin);d&&(a.fillStyle="#111",a.fillRect(0,0,k,b),a.fillStyle="#222",a.fillRect(.5*k,0,1,b),a.strokeStyle="#333",a.strokeRect(0,0,k,b));a.strokeStyle=e;f&&(a.globalAlpha=.5);a.beginPath();for(d=0;da[1])){var d=this.size[0]-2*this.margin,e=this.size[1]-2*this.margin,f=a[0]-this.margin;a=a[1]-this.margin;this.selected=this.getCloserPoint([f,a],30/b.ds.scale);-1==this.selected&&(b=[f/d,1-a/e],c.push(b),c.sort(function(a,b){return a[0]-b[0]}),this.selected=c.indexOf(b),this.must_update=!0);if(-1!=this.selected)return!0}}; E.prototype.onMouseMove=function(a,b){var c=this.points;if(c){var d=this.selected;if(!(0>d)){var e=(a[0]-this.margin)/(this.size[0]-2*this.margin),f=(a[1]-this.margin)/(this.size[1]-2*this.margin);this._nearest=this.getCloserPoint([a[0]-this.margin,a[1]-this.margin],30/b.ds.scale);if(b=c[d]){var g=0==d||d==c.length-1;!g&&(-10>a[0]||a[0]>this.size[0]+10||-10>a[1]||a[1]>this.size[1]+10)?(c.splice(d,1),this.selected=-1):(b[0]=g?0==d?0:1:Math.clamp(e,0,1),b[1]=1-Math.clamp(f,0,1),c.sort(function(a,b){return a[0]- b[0]}),this.selected=c.indexOf(b),this.must_update=!0)}}}};E.prototype.onMouseUp=function(a,b){this.selected=-1;return!1};E.prototype.getCloserPoint=function(a,b){var c=this.points;if(!c)return-1;b=b||30;for(var d=this.size[0]-2*this.margin,e=this.size[1]-2*this.margin,f=c.length,g=[0,0],h=1E6,q=-1,u=0;uh||r>b||(q=u,h=r)}return q};f.CurveEditor=E;f.getParameterNames=function(a){return(a+"").replace(/[/][/].*$/gm,"").replace(/\s+/g, "").replace(/[/][*][^/*]*[*][/]/g,"").split("){",1)[0].replace(/^[^(]*[(]/,"").replace(/=[^,]+/g,"").split(",").filter(Boolean)};f.pointerListenerAdd=function(a,b,c,d){d=void 0===d?!1:d;if(a&&a.addEventListener&&b&&"function"===typeof c)switch(b){case "down":case "up":case "move":case "over":case "out":case "enter":a.addEventListener(f.pointerevents_method+b,c,d);case "leave":case "cancel":case "gotpointercapture":case "lostpointercapture":if("mouse"!=f.pointerevents_method)return a.addEventListener(f.pointerevents_method+ b,c,d);default:return a.addEventListener(b,c,d)}else console.log("cant pointerListenerAdd "+a+", "+b+", "+c)};f.pointerListenerRemove=function(a,b,c,d){d=void 0===d?!1:d;if(a&&a.removeEventListener&&b&&"function"===typeof c)switch(b){case "down":case "up":case "move":case "over":case "out":case "enter":a.removeEventListener(f.pointerevents_method+b,c,d);case "leave":case "cancel":case "gotpointercapture":case "lostpointercapture":if("mouse"!=f.pointerevents_method)return a.removeEventListener(f.pointerevents_method+ b,c,d);default:return a.removeEventListener(b,c,d)}else console.log("cant pointerListenerRemove "+a+", "+b+", "+c)};Math.clamp=function(a,b,c){return b>a?b:ca&&(b[0]=f?this.trigger(null,g):this._pending.push([f,g])};A.prototype.onExecute=function(){var f=1E3*this.graph.elapsed_time;this.isInputConnected(1)&&(this.properties.time_in_ms=this.getInputData(1)); for(var g=0;gr?h.xbox.axes.lx:0,this._left_axis[1]=Math.abs(h.xbox.axes.ly)>r?h.xbox.axes.ly:0,this._right_axis[0]=Math.abs(h.xbox.axes.rx)>r?h.xbox.axes.rx:0,this._right_axis[1]=Math.abs(h.xbox.axes.ry)>r?h.xbox.axes.ry:0,this._triggers[0]=Math.abs(h.xbox.axes.ltrigger)>r?h.xbox.axes.ltrigger: 0,this._triggers[1]=Math.abs(h.xbox.axes.rtrigger)>r?h.xbox.axes.rtrigger:0);if(this.outputs)for(r=0;rr;r++)if(h[r]){h=h[r];r=this.xbox_mapping;r||(r=this.xbox_mapping={axes:[], buttons:{},hat:"",hatmap:n.CENTER});r.axes.lx=h.axes[0];r.axes.ly=h.axes[1];r.axes.rx=h.axes[2];r.axes.ry=h.axes[3];r.axes.ltrigger=h.buttons[6].value;r.axes.rtrigger=h.buttons[7].value;r.hat="";r.hatmap=n.CENTER;for(var t=0;tt)r.buttons[n.mapping_array[t]]=h.buttons[t].pressed,h.buttons[t].was_pressed&&this.trigger(n.mapping_array[t]+"_button_event");else switch(t){case 12:h.buttons[t].pressed&&(r.hat+="up",r.hatmap|=n.UP); break;case 13:h.buttons[t].pressed&&(r.hat+="down",r.hatmap|=n.DOWN);break;case 14:h.buttons[t].pressed&&(r.hat+="left",r.hatmap|=n.LEFT);break;case 15:h.buttons[t].pressed&&(r.hat+="right",r.hatmap|=n.RIGHT);break;case 16:r.buttons.home=h.buttons[t].pressed}h.xbox=r;return h}};n.prototype.onDrawBackground=function(h){if(!this.flags.collapsed){var r=this._left_axis,n=this._right_axis;h.strokeStyle="#88A";h.strokeRect(.5*(r[0]+1)*this.size[0]-4,.5*(r[1]+1)*this.size[1]-4,8,8);h.strokeStyle="#8A8"; h.strokeRect(.5*(n[0]+1)*this.size[0]-4,.5*(n[1]+1)*this.size[1]-4,8,8);r=this.size[1]/this._current_buttons.length;h.fillStyle="#AEB";for(n=0;n","enum",{values:a.values});this.addWidget("combo", "Cond.",this.properties.OP,{property:"OP",values:a.values});this.size=[80,60]}function b(){this.addInput("in","");this.addInput("cond","boolean");this.addOutput("true","");this.addOutput("false","");this.size=[80,60]}function c(){this.addInput("inc","number");this.addOutput("total","number");this.addProperty("increment",1);this.addProperty("value",0)}function d(){this.addInput("v","number");this.addOutput("sin","number");this.addProperty("amplitude",1);this.addProperty("offset",0);this.bgImageUrl= "nodes/imgs/icon-sin.png"}function e(){this.addInput("x","number");this.addInput("y","number");this.addOutput("","number");this.properties={x:1,y:1,formula:"x+y"};this.code_widget=this.addWidget("text","F(x,y)",this.properties.formula,function(a,b,c){c.properties.formula=a});this.addWidget("toggle","allow",p.allow_scripts,function(a){p.allow_scripts=a});this._func=null}function k(){this.addInput("vec2","vec2");this.addOutput("x","number");this.addOutput("y","number")}function m(){this.addInputs([["x", "number"],["y","number"]]);this.addOutput("vec2","vec2");this.properties={x:0,y:0};this._data=new Float32Array(2)}function l(){this.addInput("vec3","vec3");this.addOutput("x","number");this.addOutput("y","number");this.addOutput("z","number")}function q(){this.addInputs([["x","number"],["y","number"],["z","number"]]);this.addOutput("vec3","vec3");this.properties={x:0,y:0,z:0};this._data=new Float32Array(3)}function u(){this.addInput("vec4","vec4");this.addOutput("x","number");this.addOutput("y","number"); this.addOutput("z","number");this.addOutput("w","number")}function J(){this.addInputs([["x","number"],["y","number"],["z","number"],["w","number"]]);this.addOutput("vec4","vec4");this.properties={x:0,y:0,z:0,w:0};this._data=new Float32Array(4)}var p=v.LiteGraph;n.title="Converter";n.desc="type A to type B";n.prototype.onExecute=function(){var a=this.getInputData(0);if(null!=a&&this.outputs)for(var b=0;ba&&(a+=1024);var d=Math.floor(a);a-=d;c=g.data[d];d=g.data[1023==d?0:d+1];b&&(a=a*a*a*(a*(6*a-15)+10));return c*(1-a)+d*a};g.prototype.onExecute=function(){var a= this.getInputData(0)||0,b=this.properties.octaves||1,c=0,d=1;a+=this.properties.seed||0;for(var e=this.properties.speed||1,f=0,k=0;kd);++k);a=this.properties.min;this._last_v=c/f*(this.properties.max-a)+a;this.setOutputData(0,this._last_v)};g.prototype.onDrawBackground=function(a){this.outputs[0].label=(this._last_v||0).toFixed(3)};p.registerNodeType("math/noise",g);B.title="Spikes";B.desc="spike every random time"; B.prototype.onExecute=function(){var a=this.graph.elapsed_time;this._remaining_time-=a;this._blink_time-=a;a=0;0this._remaining_time?(this._remaining_time=Math.random()*(this.properties.max_time-this.properties.min_time)+this.properties.min_time,this._blink_time=this.properties.duration,this.boxcolor="#FFF"):this.boxcolor="#000";this.setOutputData(0,a)};p.registerNodeType("math/spikes",B);A.title="Clamp";A.desc= "Clamp number between min and max";A.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&(a=Math.max(this.properties.min,a),a=Math.min(this.properties.max,a),this.setOutputData(0,a))};A.prototype.getCode=function(a){a="";this.isInputConnected(0)&&(a+="clamp({{0}},"+this.properties.min+","+this.properties.max+")");return a};p.registerNodeType("math/clamp",A);y.title="Lerp";y.desc="Linear Interpolation";y.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=0);var b= this.getInputData(1);null==b&&(b=0);var c=this.properties.f,d=this.getInputData(2);void 0!==d&&(c=d);this.setOutputData(0,a*(1-c)+b*c)};y.prototype.onGetInputs=function(){return[["f","number"]]};p.registerNodeType("math/lerp",y);C.title="Abs";C.desc="Absolute";C.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,Math.abs(a))};p.registerNodeType("math/abs",C);E.title="Floor";E.desc="Floor number to remove fractional part";E.prototype.onExecute=function(){var a= this.getInputData(0);null!=a&&this.setOutputData(0,Math.floor(a))};p.registerNodeType("math/floor",E);f.title="Frac";f.desc="Returns fractional part";f.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,a%1)};p.registerNodeType("math/frac",f);L.title="Smoothstep";L.desc="Smoothstep";L.prototype.onExecute=function(){var a=this.getInputData(0);if(void 0!==a){var b=this.properties.A;a=Math.clamp((a-b)/(this.properties.B-b),0,1);this.setOutputData(0,a*a*(3-2*a))}}; p.registerNodeType("math/smoothstep",L);G.title="Scale";G.desc="v * factor";G.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,a*this.properties.factor)};p.registerNodeType("math/scale",G);z.title="Gate";z.desc="if v is true, then outputs A, otherwise B";z.prototype.onExecute=function(){var a=this.getInputData(0);this.setOutputData(0,this.getInputData(a?1:2))};p.registerNodeType("math/gate",z);I.title="Average";I.desc="Average Filter";I.prototype.onExecute=function(){var a= this.getInputData(0);null==a&&(a=0);var b=this._values.length;this._values[this._current%b]=a;this._current+=1;this._current>b&&(this._current=0);for(var c=a=0;cb&&(b=1);this.properties.samples=Math.round(b);a=this._values;this._values=new Float32Array(this.properties.samples);a.length<=this._values.length?this._values.set(a):this._values.set(a.subarray(0,this._values.length))};p.registerNodeType("math/average", I);D.title="TendTo";D.desc="moves the output value always closer to the input";D.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=0);var b=this.properties.factor;this._value=null==this._value?a:this._value*(1-b)+a*b;this.setOutputData(0,this._value)};p.registerNodeType("math/tendTo",D);H.values="+ - * / % ^ max min".split(" ");H.title="Operation";H.desc="Easy math operators";H["@OP"]={type:"enum",title:"operation",values:H.values};H.size=[100,60];H.prototype.getTitle=function(){return"max"== this.properties.OP||"min"==this.properties.OP?this.properties.OP+"(A,B)":"A "+this.properties.OP+" B"};H.prototype.setValue=function(a){"string"==typeof a&&(a=parseFloat(a));this.properties.value=a};H.prototype.onPropertyChanged=function(a,b){if("OP"==a)switch(this.properties.OP){case "+":this._func=function(a,b){return a+b};break;case "-":this._func=function(a,b){return a-b};break;case "x":case "X":case "*":this._func=function(a,b){return a*b};break;case "/":this._func=function(a,b){return a/b}; break;case "%":this._func=function(a,b){return a%b};break;case "^":this._func=function(a,b){return Math.pow(a,b)};break;case "max":this._func=function(a,b){return Math.max(a,b)};break;case "min":this._func=function(a,b){return Math.min(a,b)};break;default:console.warn("Unknown operation: "+this.properties.OP),this._func=function(a){return a}}};H.prototype.onExecute=function(){var a=this.getInputData(0),b=this.getInputData(1);null!=a?a.constructor===Number&&(this.properties.A=a):a=this.properties.A; null!=b?this.properties.B=b:b=this.properties.B;if(a.constructor===Number)var c=this._func(a,b);else if(a.constructor===Array){c=this._result;c.length=a.length;for(var d=0;dB":f=a>b;break;case "A=B":f=a>=b}this.setOutputData(c,f)}}};F.prototype.onGetOutputs=function(){return[["A==B","boolean"],["A!=B","boolean"],["A>B","boolean"],["A=B","boolean"],["A<=B","boolean"]]};p.registerNodeType("math/compare",F);p.registerSearchboxExtra("math/compare","==",{outputs:[["A==B","boolean"]],title:"A==B"}); p.registerSearchboxExtra("math/compare","!=",{outputs:[["A!=B","boolean"]],title:"A!=B"});p.registerSearchboxExtra("math/compare",">",{outputs:[["A>B","boolean"]],title:"A>B"});p.registerSearchboxExtra("math/compare","<",{outputs:[["A=",{outputs:[["A>=B","boolean"]],title:"A>=B"});p.registerSearchboxExtra("math/compare","<=",{outputs:[["A<=B","boolean"]],title:"A<=B"});a.values="> < == != <= >= || &&".split(" ");a["@OP"]={type:"enum", title:"operation",values:a.values};a.title="Condition";a.desc="evaluates condition between A and B";a.prototype.getTitle=function(){return"A "+this.properties.OP+" B"};a.prototype.onExecute=function(){var a=this.getInputData(0);void 0===a?a=this.properties.A:this.properties.A=a;var b=this.getInputData(1);void 0===b?b=this.properties.B:this.properties.B=b;var c=!0;switch(this.properties.OP){case ">":c=a>b;break;case "<":c=a=":c=a>=b;break;case "||":c=a||b;break;case "&&":c=a&&b}this.setOutputData(0,c);this.setOutputData(1,!c)};p.registerNodeType("math/condition",a);b.title="Branch";b.desc="If condition is true, outputs IN in true, otherwise in false";b.prototype.onExecute=function(){var a=this.getInputData(0);this.getInputData(1)?(this.setOutputData(0,a),this.setOutputData(1,null)):(this.setOutputData(0,null),this.setOutputData(1,a))};p.registerNodeType("math/branch",b);c.title="Accumulate";c.desc="Increments a value every time"; c.prototype.onExecute=function(){null===this.properties.value&&(this.properties.value=0);var a=this.getInputData(0);this.properties.value=null!==a?this.properties.value+a:this.properties.value+this.properties.increment;this.setOutputData(0,this.properties.value)};p.registerNodeType("math/accumulate",c);d.title="Trigonometry";d.desc="Sin Cos Tan";d.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=0);var b=this.properties.amplitude,c=this.findInputSlot("amplitude");-1!=c&&(b=this.getInputData(c)); var d=this.properties.offset;c=this.findInputSlot("offset");-1!=c&&(d=this.getInputData(c));c=0;for(var e=this.outputs.length;cXY";k.desc="vector 2 to components";k.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]))};p.registerNodeType("math3d/vec2-to-xy", k);m.title="XY->Vec2";m.desc="components to vector2";m.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=this.properties.x);var b=this.getInputData(1);null==b&&(b=this.properties.y);var c=this._data;c[0]=a;c[1]=b;this.setOutputData(0,c)};p.registerNodeType("math3d/xy-to-vec2",m);l.title="Vec3->XYZ";l.desc="vector 3 to components";l.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]),this.setOutputData(2,a[2]))}; p.registerNodeType("math3d/vec3-to-xyz",l);q.title="XYZ->Vec3";q.desc="components to vector3";q.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=this.properties.x);var b=this.getInputData(1);null==b&&(b=this.properties.y);var c=this.getInputData(2);null==c&&(c=this.properties.z);var d=this._data;d[0]=a;d[1]=b;d[2]=c;this.setOutputData(0,d)};p.registerNodeType("math3d/xyz-to-vec3",q);u.title="Vec4->XYZW";u.desc="vector 4 to components";u.prototype.onExecute=function(){var a=this.getInputData(0); null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]),this.setOutputData(2,a[2]),this.setOutputData(3,a[3]))};p.registerNodeType("math3d/vec4-to-xyzw",u);J.title="XYZW->Vec4";J.desc="components to vector4";J.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=this.properties.x);var b=this.getInputData(1);null==b&&(b=this.properties.y);var c=this.getInputData(2);null==c&&(c=this.properties.z);var d=this.getInputData(3);null==d&&(d=this.properties.w);var e=this._data;e[0]= a;e[1]=b;e[2]=c;e[3]=d;this.setOutputData(0,e)};p.registerNodeType("math3d/xyzw-to-vec4",J)})(this); (function(v){function n(){this.addInput("","string");this.addOutput("table","table");this.addOutput("rows","number");this.addProperty("value","");this.addProperty("separator",",");this._table=null}v=v.LiteGraph;v.wrapFunctionAsNode("string/toString",function(n){if(n&&n.constructor===Object)try{return JSON.stringify(n)}catch(h){}return String(n)},[""],"String");v.wrapFunctionAsNode("string/compare",function(n,h){return n==h},["string","string"],"boolean");v.wrapFunctionAsNode("string/concatenate", function(n,h){return void 0===n?h:void 0===h?n:n+h},["string","string"],"string");v.wrapFunctionAsNode("string/contains",function(n,h){return void 0===n||void 0===h?!1:-1!=n.indexOf(h)},["string","string"],"boolean");v.wrapFunctionAsNode("string/toUpperCase",function(n){return null!=n&&n.constructor===String?n.toUpperCase():n},["string"],"string");v.wrapFunctionAsNode("string/split",function(n,h){null==h&&(h=this.properties.separator);if(null==n)return[];if(n.constructor===String)return n.split(h|| " ");if(n.constructor===Array){for(var r=[],t=0;t