diff --git a/build/litegraph.core.js b/build/litegraph.core.js index 8fe3cd26a..e322732f0 100644 --- a/build/litegraph.core.js +++ b/build/litegraph.core.js @@ -2532,7 +2532,7 @@ var w = this.widgets[i]; if(!w) continue; - if(w.options && w.options.property && this.properties[ w.options.property ]) + if(w.options && w.options.property && (this.properties[ w.options.property ] != undefined)) w.value = JSON.parse( JSON.stringify( this.properties[ w.options.property ] ) ); } if (info.widgets_values) { @@ -3775,16 +3775,42 @@ /** * returns the bounding of the object, used for rendering purposes - * bounding is: [topleft_cornerx, topleft_cornery, width, height] * @method getBounding - * @return {Float32Array[4]} the total size + * @param out {Float32Array[4]?} [optional] a place to store the output, to free garbage + * @param compute_outer {boolean?} [optional] set to true to include the shadow and connection points in the bounding calculation + * @return {Float32Array[4]} the bounding box in format of [topleft_cornerx, topleft_cornery, width, height] */ - LGraphNode.prototype.getBounding = function(out) { + LGraphNode.prototype.getBounding = function(out, compute_outer) { out = out || new Float32Array(4); - out[0] = this.pos[0] - 4; - out[1] = this.pos[1] - LiteGraph.NODE_TITLE_HEIGHT; - out[2] = this.size[0] + 4; - out[3] = this.flags.collapsed ? LiteGraph.NODE_TITLE_HEIGHT : this.size[1] + LiteGraph.NODE_TITLE_HEIGHT; + const nodePos = this.pos; + const isCollapsed = this.flags.collapsed; + const nodeSize = this.size; + + let left_offset = 0; + // 1 offset due to how nodes are rendered + let right_offset = 1 ; + let top_offset = 0; + let bottom_offset = 0; + + if (compute_outer) { + // 4 offset for collapsed node connection points + left_offset = 4; + // 6 offset for right shadow and collapsed node connection points + right_offset = 6 + left_offset; + // 4 offset for collapsed nodes top connection points + top_offset = 4; + // 5 offset for bottom shadow and collapsed node connection points + bottom_offset = 5 + top_offset; + } + + out[0] = nodePos[0] - left_offset; + out[1] = nodePos[1] - LiteGraph.NODE_TITLE_HEIGHT - top_offset; + out[2] = isCollapsed ? + (this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH) + right_offset : + nodeSize[0] + right_offset; + out[3] = isCollapsed ? + LiteGraph.NODE_TITLE_HEIGHT + bottom_offset : + nodeSize[1] + LiteGraph.NODE_TITLE_HEIGHT + bottom_offset; if (this.onBounding) { this.onBounding(out); @@ -7673,7 +7699,7 @@ LGraphNode.prototype.executeAction = function(action) continue; } - if (!overlapBounding(this.visible_area, n.getBounding(temp))) { + if (!overlapBounding(this.visible_area, n.getBounding(temp, true))) { continue; } //out of the visible area @@ -9975,6 +10001,7 @@ LGraphNode.prototype.executeAction = function(action) var x = pos[0] - node.pos[0]; var y = pos[1] - node.pos[1]; var width = node.size[0]; + var deltaX = event.deltaX || event.deltax || 0; var that = this; var ref_window = this.getCanvasWindow(); @@ -10021,8 +10048,8 @@ LGraphNode.prototype.executeAction = function(action) case "combo": var old_value = w.value; if (event.type == LiteGraph.pointerevents_method+"move" && w.type == "number") { - if(event.deltaX) - w.value += event.deltaX * 0.1 * (w.options.step || 1); + if(deltaX) + w.value += deltaX * 0.1 * (w.options.step || 1); if ( w.options.min != null && w.value < w.options.min ) { w.value = w.options.min; } @@ -11499,7 +11526,8 @@ LGraphNode.prototype.executeAction = function(action) var input = dialog.querySelector("input"); if (input) { input.addEventListener("blur", function(e) { - this.focus(); + if(that.search_box) + this.focus(); }); input.addEventListener("keydown", function(e) { if (e.keyCode == 38) { diff --git a/build/litegraph.core.min.js b/build/litegraph.core.min.js index c51912729..61708287d 100644 --- a/build/litegraph.core.min.js +++ b/build/litegraph.core.min.js @@ -1,353 +1,353 @@ -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(l,u,w){l!=Array.prototype&&l!=Object.prototype&&(l[u]=w.value)};$jscomp.getGlobal=function(l){return"undefined"!=typeof window&&window===l?l:"undefined"!=typeof global&&null!=global?global:l};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_"; -$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var l=0;return function(u){return $jscomp.SYMBOL_PREFIX+(u||"")+l++}}(); -$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var l=$jscomp.global.Symbol.iterator;l||(l=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[l]&&$jscomp.defineProperty(Array.prototype,l,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(l){var u=0;return $jscomp.iteratorPrototype(function(){return ul&&(l=Math.max(0,w+l));if(null==q||q>w)q=w;q=Number(q);0>q&&(q=Math.max(0,w+q));for(l=Number(l||0);l=y}},"es6","es3");$jscomp.findInternal=function(l,u,w){l instanceof String&&(l=String(l));for(var q=l.length,z=0;zt&&(t=Math.max(0,w+t));if(null==m||m>w)m=w;m=Number(m);0>m&&(m=Math.max(0,w+m));for(t=Number(t||0);t=y}},"es6","es3");$jscomp.findInternal=function(t,r,w){t instanceof String&&(t=String(t));for(var m=t.length,B=0;Ba&&eb?!0:!1}function G(a,b){var c=a[0]+a[2],e=a[1]+a[3],d=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>d||ca&&eb?!0:!1}function H(a,b){var c=a[0]+a[2],e=a[1]+a[3],d=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>d||ch.width-k.width-10&&(d=h.width-k.width-10),h.height&&a>h.height-k.height-10&&(a=h.height-k.height-10));f.style.left=d+"px";f.style.top=a+"px";b.scale&&(f.style.transform="scale("+b.scale+")")}function F(a){this.points=a;this.nearest=this.selected=-1;this.size=null;this.must_update=!0;this.margin=5}function J(a,b,c){return b>a?b:ch.width-k.width-10&&(d=h.width-k.width-10),h.height&&a>h.height-k.height-10&&(a=h.height-k.height-10));f.style.left=d+"px";f.style.top=a+"px";b.scale&&(f.style.transform="scale("+b.scale+")")}function G(a){this.points=a;this.nearest=this.selected=-1;this.size=null;this.must_update=!0;this.margin=5}function K(a,b,c){return b>a?b:c>a/4).toString(16)})},isValidConnection:function(a, b){if(""==a||"*"===a)a=0;if(""==b||"*"===b)b=0;if(!a||!b||a==b||a==g.EVENT&&b==g.ACTION)return!0;a=String(a);b=String(b);a=a.toLowerCase();b=b.toLowerCase();if(-1==a.indexOf(",")&&-1==b.indexOf(","))return a==b;a=a.split(",");b=b.split(",");for(var c=0;ch&&(h=n.size[t]);k+=n.size[b==g.VERTICAL_LAYOUT?0:1]+a+g.NODE_TITLE_HEIGHT}c+=h+a}this.setDirtyCanvas(!0,!0)};u.prototype.getTime=function(){return this.globaltime};u.prototype.getFixedTime=function(){return this.fixedtime};u.prototype.getElapsedTime=function(){return this.elapsed_time};u.prototype.sendEventToAllNodes=function(a, -b,c){c=c||g.ALWAYS;var e=this._nodes_in_order?this._nodes_in_order:this._nodes;if(e)for(var d=0,f=e.length;d=g.MAX_NUMBER_OF_NODES)throw"LiteGraph: max number of nodes in a graph reached";if(g.use_uuids){if(null==a.id||-1==a.id)a.id=g.uuidv4()}else null==a.id||-1==a.id? -a.id=++this.last_node_id:this.last_node_idh&&(h=n.size[p]);k+=n.size[b==g.VERTICAL_LAYOUT?0:1]+a+g.NODE_TITLE_HEIGHT}c+=h+a}this.setDirtyCanvas(!0,!0)};r.prototype.getTime=function(){return this.globaltime};r.prototype.getFixedTime=function(){return this.fixedtime};r.prototype.getElapsedTime=function(){return this.elapsed_time};r.prototype.sendEventToAllNodes=function(a, +b,c){c=c||g.ALWAYS;var e=this._nodes_in_order?this._nodes_in_order:this._nodes;if(e)for(var d=0,f=e.length;d=g.MAX_NUMBER_OF_NODES)throw"LiteGraph: max number of nodes in a graph reached";if(g.use_uuids){if(null==a.id||-1==a.id)a.id=g.uuidv4()}else 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=g.use_uuids?g.uuidv4():-1;this.type=null;this.inputs=[];this.outputs=[];this.connections=[];this.properties={};this.properties_info=[];this.flags={}};q.prototype.configure=function(a){this.graph&& +c.node_dragged==a&&(c.node_dragged=null);b=this._nodes.indexOf(a);-1!=b&&this._nodes.splice(b,1);delete this._nodes_by_id[a.id];if(this.onNodeRemoved)this.onNodeRemoved(a);this.sendActionToCanvas("checkPanels");this.setDirtyCanvas(!0,!0);this.afterChange();this.change();this.updateExecutionOrder()}};r.prototype.getNodeById=function(a){return null==a?null:this._nodes_by_id[a]};r.prototype.findNodesByClass=function(a,b){b=b||[];for(var c=b.length=0,e=this._nodes.length;ca.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos},enumerable:!0});this.id=g.use_uuids?g.uuidv4():-1;this.type=null;this.inputs=[];this.outputs=[];this.connections=[];this.properties={};this.properties_info=[];this.flags={}};m.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]=g.cloneObject(a[b],this[b]):this[b]=a[b]);a.title||(this.title=this.constructor.title);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}};q.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};q.prototype.getInputDataByName=function(a,b){a=this.findInputSlot(a);return-1==a?null:this.getInputData(a,b)};q.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};q.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};q.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]-d-cb)return!0;return!1};q.prototype.getSlotInPosition=function(a,b){var c=new Float32Array(2);if(this.inputs)for(var e=0,d=this.inputs.length;e=this.outputs.length)return g.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 g.debug&&console.log("Connect: Error, no slot of name "+c),null}else if(c===g.EVENT)if(g.do_add_triggers_slots)b.changeMode(g.ON_TRIGGER),c=b.findInputSlot("onTrigger");else return null;else if(!b.inputs||c>=b.inputs.length)return g.debug&&console.log("Connect: Error, slot number not found"),null;var e=b.inputs[c],d=this.outputs[a];if(!this.outputs[a])return null;b.onBeforeConnectInput&&(c=b.onBeforeConnectInput(c)); -if(!1===c||null===c||!g.isValidConnection(d.type,e.type))return this.setDirtyCanvas(!1,!0),null;if(b.onConnectInput&&!1===b.onConnectInput(c,d.type,d,this,a)||this.onConnectOutput&&!1===this.onConnectOutput(a,e.type,e,b,c))return null;b.inputs[c]&&null!=b.inputs[c].link&&(this.graph.beforeChange(),b.disconnectInput(c,{doProcessChange:!1}));if(null!==d.links&&d.links.length)switch(d.type){case g.EVENT:g.allow_multi_output_for_events||(this.graph.beforeChange(),this.disconnectOutput(a,!1,{doProcessChange:!1}))}var f= -g.use_uuids?g.uuidv4():++this.graph.last_link_id;f=new w(f,e.type||d.type,this.id,a,b.id,c);this.graph.links[f.id]=f;null==d.links&&(d.links=[]);d.links.push(f.id);b.inputs[c].link=f.id;this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(g.OUTPUT,a,!0,f,d);if(b.onConnectionsChange)b.onConnectionsChange(g.INPUT,c,!0,f,e);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(g.INPUT,b,c,this,a),this.graph.onNodeConnectionChange(g.OUTPUT, -this,a,b,c));this.setDirtyCanvas(!1,!0);this.graph.afterChange();this.graph.connectionChange(this,f);return f};q.prototype.disconnectOutput=function(a,b){if(a.constructor===String){if(a=this.findOutputSlot(a),-1==a)return g.debug&&console.log("Connect: Error, no slot of name "+a),!1}else if(!this.outputs||a>=this.outputs.length)return g.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 e=0,d=c.links.length;e=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}};m.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};m.prototype.getInputDataByName=function(a,b){a=this.findInputSlot(a);return-1==a?null:this.getInputData(a,b)};m.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};m.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};m.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]-d-cb)return!0;return!1};m.prototype.getSlotInPosition=function(a,b){var c=new Float32Array(2);if(this.inputs)for(var e=0,d=this.inputs.length;e=this.outputs.length)return g.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 g.debug&&console.log("Connect: Error, no slot of name "+c),null}else if(c===g.EVENT)if(g.do_add_triggers_slots)b.changeMode(g.ON_TRIGGER),c=b.findInputSlot("onTrigger");else return null;else if(!b.inputs||c>=b.inputs.length)return g.debug&&console.log("Connect: Error, slot number not found"),null;var e=b.inputs[c],d=this.outputs[a];if(!this.outputs[a])return null; +b.onBeforeConnectInput&&(c=b.onBeforeConnectInput(c));if(!1===c||null===c||!g.isValidConnection(d.type,e.type))return this.setDirtyCanvas(!1,!0),null;if(b.onConnectInput&&!1===b.onConnectInput(c,d.type,d,this,a)||this.onConnectOutput&&!1===this.onConnectOutput(a,e.type,e,b,c))return null;b.inputs[c]&&null!=b.inputs[c].link&&(this.graph.beforeChange(),b.disconnectInput(c,{doProcessChange:!1}));if(null!==d.links&&d.links.length)switch(d.type){case g.EVENT:g.allow_multi_output_for_events||(this.graph.beforeChange(), +this.disconnectOutput(a,!1,{doProcessChange:!1}))}var f=g.use_uuids?g.uuidv4():++this.graph.last_link_id;f=new w(f,e.type||d.type,this.id,a,b.id,c);this.graph.links[f.id]=f;null==d.links&&(d.links=[]);d.links.push(f.id);b.inputs[c].link=f.id;this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(g.OUTPUT,a,!0,f,d);if(b.onConnectionsChange)b.onConnectionsChange(g.INPUT,c,!0,f,e);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(g.INPUT, +b,c,this,a),this.graph.onNodeConnectionChange(g.OUTPUT,this,a,b,c));this.setDirtyCanvas(!1,!0);this.graph.afterChange();this.graph.connectionChange(this,f);return f};m.prototype.disconnectOutput=function(a,b){if(a.constructor===String){if(a=this.findOutputSlot(a),-1==a)return g.debug&&console.log("Connect: Error, no slot of name "+a),!1}else if(!this.outputs||a>=this.outputs.length)return g.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 e=0,d=c.links.length;e=this.inputs.length)return g.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 e=this.graph.links[c];if(e){var d=this.graph.getNodeById(e.origin_id);if(!d)return!1;var f=d.outputs[e.origin_slot];if(!f||!f.links||0==f.links.length)return!1;for(var h=0,k=f.links.length;hb&&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&&e>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]/e*(b+.5),c[1]=a?this.pos[1]-g.NODE_TITLE_HEIGHT:this.pos[1]+this.size[1],c;c[0]=a?this.pos[0]+d:this.pos[0]+this.size[0]+1-d;c[1]=this.pos[1]+(b+.7)*g.NODE_SLOT_HEIGHT+(this.constructor.slot_start_y||0);return c};q.prototype.alignToGrid=function(){this.pos[0]=g.CANVAS_GRID_SIZE*Math.round(this.pos[0]/ -g.CANVAS_GRID_SIZE);this.pos[1]=g.CANVAS_GRID_SIZE*Math.round(this.pos[1]/g.CANVAS_GRID_SIZE)};q.prototype.trace=function(a){this.console||(this.console=[]);this.console.push(a);this.console.length>q.MAX_CONSOLE&&this.console.shift();if(this.graph.onNodeTrace)this.graph.onNodeTrace(this,a)};q.prototype.setDirtyCanvas=function(a,b){this.graph&&this.graph.sendActionToCanvas("setDirty",[a,b])};q.prototype.loadImage=function(a){var b=new Image;b.src=g.node_images_path+a;b.ready=!1;var c=this;b.onload= -function(){this.ready=!0;c.setDirtyCanvas(!0)};return b};q.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})};z.prototype.configure=function(a){this.title=a.title;this._bounding.set(a.bounding);this.color=a.color;this.font_size=a.font_size};z.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_size:this.font_size}};z.prototype.move=function(a,b,c){this._pos[0]+=a;this._pos[1]+=b;if(!c)for(c=0;cb&&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]/e*(b+.5),c[1]=a?this.pos[1]-g.NODE_TITLE_HEIGHT:this.pos[1]+this.size[1],c;c[0]=a?this.pos[0]+d:this.pos[0]+this.size[0]+1-d;c[1]=this.pos[1]+(b+.7)*g.NODE_SLOT_HEIGHT+(this.constructor.slot_start_y||0);return c};m.prototype.alignToGrid=function(){this.pos[0]=g.CANVAS_GRID_SIZE*Math.round(this.pos[0]/ +g.CANVAS_GRID_SIZE);this.pos[1]=g.CANVAS_GRID_SIZE*Math.round(this.pos[1]/g.CANVAS_GRID_SIZE)};m.prototype.trace=function(a){this.console||(this.console=[]);this.console.push(a);this.console.length>m.MAX_CONSOLE&&this.console.shift();if(this.graph.onNodeTrace)this.graph.onNodeTrace(this,a)};m.prototype.setDirtyCanvas=function(a,b){this.graph&&this.graph.sendActionToCanvas("setDirty",[a,b])};m.prototype.loadImage=function(a){var b=new Image;b.src=g.node_images_path+a;b.ready=!1;var c=this;b.onload= +function(){this.ready=!0;c.setDirtyCanvas(!0)};return b};m.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})};B.prototype.configure=function(a){this.title=a.title;this._bounding.set(a.bounding);this.color=a.color;this.font_size=a.font_size};B.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_size:this.font_size}};B.prototype.move=function(a,b,c){this._pos[0]+=a;this._pos[1]+=b;if(!c)for(c=0;c=this.viewport[0]&&e=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)}};y.prototype.changeDeltaScale=function(a,b){this.changeScale(this.scale*a,b)};y.prototype.reset=function(){this.scale=1;this.offset[0]=0;this.offset[1]=0};l.LGraphCanvas=g.LGraphCanvas=m;m.DEFAULT_BACKGROUND_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII="; -m.link_type_colors={"-1":g.EVENT_LINK_COLOR,number:"#AAA",node:"#DCA"};m.gradients={};m.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()};m.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)))};m.prototype.getTopGraph=function(){return this._graph_stack.length?this._graph_stack[0]:this.graph};m.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)};m.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}};m.prototype.getCurrentGraph=function(){return this.graph};m.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()}};m.prototype._doNothing=function(a){a.preventDefault();return!1};m.prototype._doReturnTrue=function(a){a.preventDefault(); -return!0};m.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);g.pointerListenerAdd(a,"down",this._mousedown_callback,!0);a.addEventListener("mousewheel",this._mousewheel_callback, +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)}};y.prototype.changeDeltaScale=function(a,b){this.changeScale(this.scale*a,b)};y.prototype.reset=function(){this.scale=1;this.offset[0]=0;this.offset[1]=0};t.LGraphCanvas=g.LGraphCanvas=l;l.DEFAULT_BACKGROUND_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII="; +l.link_type_colors={"-1":g.EVENT_LINK_COLOR,number:"#AAA",node:"#DCA"};l.gradients={};l.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()};l.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)))};l.prototype.getTopGraph=function(){return this._graph_stack.length?this._graph_stack[0]:this.graph};l.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)};l.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}};l.prototype.getCurrentGraph=function(){return this.graph};l.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()}};l.prototype._doNothing=function(a){a.preventDefault();return!1};l.prototype._doReturnTrue=function(a){a.preventDefault(); +return!0};l.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);g.pointerListenerAdd(a,"down",this._mousedown_callback,!0);a.addEventListener("mousewheel",this._mousewheel_callback, !1);g.pointerListenerAdd(a,"up",this._mouseup_callback,!0);g.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}};m.prototype.unbindEvents=function(){if(this._events_binded){var a=this.getCanvasWindow().document;g.pointerListenerRemove(this.canvas,"move",this._mousedown_callback);g.pointerListenerRemove(this.canvas,"up",this._mousedown_callback);g.pointerListenerRemove(this.canvas,"down",this._mousedown_callback);this.canvas.removeEventListener("mousewheel",this._mousewheel_callback); +this._doNothing,!1);a.addEventListener("drop",this._ondrop_callback,!1);a.addEventListener("dragenter",this._doReturnTrue,!1);this._events_binded=!0}};l.prototype.unbindEvents=function(){if(this._events_binded){var a=this.getCanvasWindow().document;g.pointerListenerRemove(this.canvas,"move",this._mousedown_callback);g.pointerListenerRemove(this.canvas,"up",this._mousedown_callback);g.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")}; -m.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()};m.prototype.enableWebGL=function(){if("undefined"===typeof GL)throw"litegl.js must be included to use a WebGL canvas";if("undefined"===typeof enableWebGLCanvas)throw"webglCanvas.js must be included to use this feature";this.gl=this.ctx=enableWebGLCanvas(this.canvas);this.ctx.webgl=!0;this.bgcanvas=this.canvas;this.bgctx=this.gl;this.canvas.webgl_enabled=!0}; -m.prototype.setDirty=function(a,b){a&&(this.dirty_canvas=!0);b&&(this.dirty_bgcanvas=!0)};m.prototype.getCanvasWindow=function(){if(!this.canvas)return window;var a=this.canvas.ownerDocument;return a.defaultView||a.parentWindow};m.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))};m.prototype.stopRendering=function(){this.is_rendering= -!1};m.prototype.blockClick=function(){this.block_click=!0;this.last_mouseclick=0};m.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();m.active_canvas=this;var c=this,e=a.clientX,d=a.clientY;this.ds.viewport=this.viewport;e=!this.viewport||this.viewport&&e>=this.viewport[0]&&e=this.viewport[1]&&d=this.viewport[0]&&e=this.viewport[1]&&dd-this.last_mouseclick&&h;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&&h?!0:!1;this.pointer_is_down=!0;this.canvas.focus();g.closeAllContextMenus(b);if(!this.onMouse||1!=this.onMouse(a)){if(1!=a.which||this.pointer_is_double)if(2==a.which)if(g.middle_click_slot_add_default_node){if(f&&this.allow_interaction&&!e&&!this.read_only&&!this.connecting_node&&!f.flags.collapsed&&!this.live_mode){d=e=h=!1;if(f.outputs)for(t=0,k=f.outputs.length;tf.size[0]-g.NODE_TITLE_HEIGHT&& -0>k[1]&&(c=this,setTimeout(function(){c.openSubgraph(f.subgraph)},10)),this.live_mode&&(t=h=!0));t?f.is_selected||this.processNodeSelected(f,a):(this.allow_dragnodes&&(this.graph.beforeChange(),this.node_dragged=f),this.processNodeSelected(f,a));this.dirty_canvas=!0}}else if(!e){if(!this.read_only)for(t=0;tk[0]+4||a.canvasYk[1]+4)){this.showLinkMenu(h,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>I([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),a.preventDefault(),a.stopPropagation()); -h=!0}!e&&h&&this.allow_dragcanvas&&(this.dragging_canvas=!0)}this.last_mouse[0]=a.clientX;this.last_mouse[1]=a.clientY;this.last_mouseclick=g.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}}}};m.prototype.processMouseMove=function(a){this.autoresize&&this.resize(); -this.set_canvas_dirty_on_mouse_event&&(this.dirty_canvas=!0);if(this.graph){m.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]), +1,this.dragging_rectangle[3]=1,e=!0);g.alt_drag_do_clone_nodes&&a.altKey&&f&&this.allow_interaction&&!e&&!this.read_only&&(cloned=f.clone())&&(cloned.pos[0]+=5,cloned.pos[1]+=5,this.graph.add(cloned,!1,{doCalcSize:!1}),f=cloned,e=!0,p||(this.allow_dragnodes&&(this.graph.beforeChange(),this.node_dragged=f),this.selected_nodes[f.id]||this.processNodeSelected(f,a)));h=!1;if(f&&(this.allow_interaction||f.flags.allow_interaction)&&!e&&!this.read_only){this.live_mode||f.flags.pinned||this.bringToFront(f); +if(this.allow_interaction&&!this.connecting_node&&!f.flags.collapsed&&!this.live_mode)if(!e&&!1!==f.resizable&&C(a.canvasX,a.canvasY,f.pos[0]+f.size[0]-5,f.pos[1]+f.size[1]-5,10,10))this.graph.beforeChange(),this.resizing_node=f,this.canvas.style.cursor="se-resize",e=!0;else{if(f.outputs){p=0;for(var k=f.outputs.length;pf.size[0]-g.NODE_TITLE_HEIGHT&& +0>k[1]&&(c=this,setTimeout(function(){c.openSubgraph(f.subgraph)},10)),this.live_mode&&(p=h=!0));p?f.is_selected||this.processNodeSelected(f,a):(this.allow_dragnodes&&(this.graph.beforeChange(),this.node_dragged=f),this.processNodeSelected(f,a));this.dirty_canvas=!0}}else if(!e){if(!this.read_only)for(p=0;pk[0]+4||a.canvasYk[1]+4)){this.showLinkMenu(h,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>J([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),a.preventDefault(),a.stopPropagation()); +h=!0}!e&&h&&this.allow_dragcanvas&&(this.dragging_canvas=!0)}this.last_mouse[0]=a.clientX;this.last_mouse[1]=a.clientY;this.last_mouseclick=g.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}}}};l.prototype.processMouseMove=function(a){this.autoresize&&this.resize(); +this.set_canvas_dirty_on_mouse_event&&(this.dirty_canvas=!0);if(this.graph){l.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);var e=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes);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||e&&e.flags.allow_interaction)&&!this.read_only){this.connecting_node&&(this.dirty_canvas=!0);b=0;for(var d=this.graph._nodes.length;bh[0]+4||a.canvasYh[1]+4)){d=f;break}d!=this.over_link_center&&(this.over_link_center=d,this.dirty_canvas=!0);this.canvas&&(this.canvas.style.cursor="")}if(this.node_capturing_input&& +d)):this._highlight_output=null));this.canvas&&(C(a.canvasX,a.canvasY,e.pos[0]+e.size[0]-5,e.pos[1]+e.size[1]-5,5,5)?this.canvas.style.cursor="se-resize":this.canvas.style.cursor="crosshair")}else{d=null;for(b=0;bh[0]+4||a.canvasYh[1]+4)){d=f;break}d!=this.over_link_center&&(this.over_link_center=d,this.dirty_canvas=!0);this.canvas&&(this.canvas.style.cursor="")}if(this.node_capturing_input&& this.node_capturing_input!=e&&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)e=this.selected_nodes[b],e.pos[0]+=c[0]/this.ds.scale,e.pos[1]+=c[1]/this.ds.scale,e.is_selected||this.processNodeSelected(e,a);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}};m.prototype.processMouseUp=function(a){var b=void 0===a.isPrimary||a.isPrimary;if(!b)return!1;this.set_canvas_dirty_on_mouse_event&&(this.dirty_canvas=!0);if(this.graph){var c=this.getCanvasWindow().document;m.active_canvas=this;this.options.skip_events|| +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}};l.prototype.processMouseUp=function(a){var b=void 0===a.isPrimary||a.isPrimary;if(!b)return!1;this.set_canvas_dirty_on_mouse_event&&(this.dirty_canvas=!0);if(this.graph){var c=this.getCanvasWindow().document;l.active_canvas=this;this.options.skip_events|| (g.pointerListenerRemove(c,"move",this._mousemove_callback,!0),g.pointerListenerAdd(this.canvas,"move",this._mousemove_callback,!0),g.pointerListenerRemove(c,"up",this._mouseup_callback,!0));this.adjustMouseEvent(a);c=g.getTime();a.click_time=c-this.last_mouseclick;this.last_mouse_dragging=!1;this.last_click_position=null;this.block_click&&(this.block_click=!1);if(1==a.which){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;var e=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes);if(this.dragging_rectangle){if(this.graph){c= -this.graph._nodes;var d=new Float32Array(4),f=Math.abs(this.dragging_rectangle[2]),h=Math.abs(this.dragging_rectangle[3]),k=0>this.dragging_rectangle[3]?this.dragging_rectangle[1]-h:this.dragging_rectangle[1];this.dragging_rectangle[0]=0>this.dragging_rectangle[2]?this.dragging_rectangle[0]-f:this.dragging_rectangle[0];this.dragging_rectangle[1]=k;this.dragging_rectangle[2]=f;this.dragging_rectangle[3]=h;if(!e||10this.dragging_rectangle[3]?this.dragging_rectangle[1]-h:this.dragging_rectangle[1];this.dragging_rectangle[0]=0>this.dragging_rectangle[2]?this.dragging_rectangle[0]-f:this.dragging_rectangle[0];this.dragging_rectangle[1]=k;this.dragging_rectangle[2]=f;this.dragging_rectangle[3]=h;if(!e||10a.click_time&&A(a.canvasX,a.canvasY,e.pos[0],e.pos[1]-g.NODE_TITLE_HEIGHT,g.NODE_TITLE_HEIGHT,g.NODE_TITLE_HEIGHT)&&e.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)&&300>a.click_time&&C(a.canvasX,a.canvasY,e.pos[0],e.pos[1]-g.NODE_TITLE_HEIGHT,g.NODE_TITLE_HEIGHT,g.NODE_TITLE_HEIGHT)&&e.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{e=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes);!e&&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);b&&(this.pointer_is_double=this.pointer_is_down=!1);this.graph.change();a.stopPropagation();a.preventDefault();return!1}};m.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,e=a.clientY;if(!this.viewport||this.viewport&&c>=this.viewport[0]&&c=this.viewport[1]&&eb&&(c*=1/1.1),this.ds.changeScale(c,[a.clientX,a.clientY]),this.graph.change(),a.preventDefault(),!1}};m.prototype.isOverNodeBox=function(a,b,c){var e=g.NODE_TITLE_HEIGHT;return A(b,c,a.pos[0]+2,a.pos[1]+2-e,e-4,e-4)?!0:!1};m.prototype.isOverNodeInput=function(a,b,c,e){if(a.inputs)for(var d=0,f=a.inputs.length;d=this.viewport[0]&&c=this.viewport[1]&&eb&&(c*=1/1.1),this.ds.changeScale(c,[a.clientX,a.clientY]),this.graph.change(),a.preventDefault(),!1}};l.prototype.isOverNodeBox=function(a,b,c){var e=g.NODE_TITLE_HEIGHT;return C(b,c,a.pos[0]+2,a.pos[1]+2-e,e-4,e-4)?!0:!1};l.prototype.isOverNodeInput=function(a,b,c,e){if(a.inputs)for(var d=0,f=a.inputs.length;db.nodes[d].pos[0]&&(c[0]=b.nodes[d].pos[0],e[0]=d),c[1]>b.nodes[d].pos[1]&&(c[1]=b.nodes[d].pos[1],e[1]=d)):(c=[b.nodes[d].pos[0],b.nodes[d].pos[1]],e=[d,d]);e=[];for(d=0;d=this.viewport[0]&&b=this.viewport[1]&&c=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}};m.prototype.drawFrontCanvas= +l.prototype.deselectNode=function(a){if(a.is_selected){if(a.onDeselected)a.onDeselected();a.is_selected=!1;if(this.onNodeDeselected)this.onNodeDeselected(a);if(a.inputs)for(var b=0;bc-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}};l.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 e=0;e> ";b.fillText(e+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);1.5>this.ds.scale&&!c&&this.clear_background_color&& (b.fillStyle=this.clear_background_color,b.fillRect(this.visible_area[0],this.visible_area[1],this.visible_area[2],this.visible_area[3]));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 f=this.editor_alpha;b.globalAlpha=f;this.render_shadows&&!d?(b.shadowColor=g.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 h=a._shape||g.BOX_SHAPE;C.set(a.size);var k=a.horizontal;if(a.flags.collapsed){b.font=this.inner_text_font;var p=a.getTitle?a.getTitle():a.title;null!=p&&(a._collapsed_width=Math.min(a.size[0],b.measureText(p).width+2*g.NODE_TITLE_HEIGHT),C[0]=a._collapsed_width,C[1]=0)}a.clip_area&&(b.save(),b.beginPath(),h==g.BOX_SHAPE?b.rect(0,0, -C[0],C[1]):h==g.ROUND_SHAPE?b.roundRect(0,0,C[0],C[1],[10]):h==g.CIRCLE_SHAPE&&b.arc(.5*C[0],.5*C[1],.5*C[0],0,2*Math.PI),b.clip());a.has_errors&&(e="red");this.drawNodeShape(a,b,C,c,e,a.is_selected,a.mouseOver);b.shadowColor="transparent";if(a.onDrawForeground)a.onDrawForeground(b,this,this.canvas);b.textAlign=k?"center":"left";b.font=this.inner_text_font;e=!d;var n=this.connecting_output;h=this.connecting_input;b.lineWidth=1;p=0;var t=new Float32Array(2);if(!a.flags.collapsed){if(a.inputs)for(c= -0;cthis.ds.scale;if(this.live_mode){if(!a.flags.collapsed&&(b.shadowColor="transparent",a.onDrawForeground))a.onDrawForeground(b,this,this.canvas)}else{var f=this.editor_alpha;b.globalAlpha=f;this.render_shadows&&!d?(b.shadowColor=g.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 h=a._shape||g.BOX_SHAPE;D.set(a.size);var k=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*g.NODE_TITLE_HEIGHT),D[0]=a._collapsed_width,D[1]=0)}a.clip_area&&(b.save(),b.beginPath(),h==g.BOX_SHAPE?b.rect(0,0, +D[0],D[1]):h==g.ROUND_SHAPE?b.roundRect(0,0,D[0],D[1],[10]):h==g.CIRCLE_SHAPE&&b.arc(.5*D[0],.5*D[1],.5*D[0],0,2*Math.PI),b.clip());a.has_errors&&(e="red");this.drawNodeShape(a,b,D,c,e,a.is_selected,a.mouseOver);b.shadowColor="transparent";if(a.onDrawForeground)a.onDrawForeground(b,this,this.canvas);b.textAlign=k?"center":"left";b.font=this.inner_text_font;e=!d;var n=this.connecting_output;h=this.connecting_input;b.lineWidth=1;q=0;var p=new Float32Array(2);if(!a.flags.collapsed){if(a.inputs)for(c= +0;cthis.ds.scale,p=a._shape||a.constructor.shape||g.ROUND_SHAPE,n=a.constructor.title_mode,t=!0;n==g.TRANSPARENT_TITLE||n==g.NO_TITLE?t=!1:n==g.AUTOHIDE_TITLE&&h&&(t=!0);x[0]=0;x[1]=t?-d:0;x[2]=c[0]+1;x[3]=t?c[1]+d:c[1];h=b.globalAlpha;b.beginPath();p==g.BOX_SHAPE||k?b.fillRect(x[0],x[1],x[2],x[3]):p==g.ROUND_SHAPE||p==g.CARD_SHAPE?b.roundRect(x[0],x[1],x[2],x[3],p==g.CARD_SHAPE?[this.round_radius, -this.round_radius,0,0]:[this.round_radius]):p==g.CIRCLE_SHAPE&&b.arc(.5*c[0],.5*c[1],.5*c[0],0,2*Math.PI);b.fill();!a.flags.collapsed&&t&&(b.shadowColor="transparent",b.fillStyle="rgba(0,0,0,0.2)",b.fillRect(0,-1,x[2],2));b.shadowColor="transparent";if(a.onDrawBackground)a.onDrawBackground(b,this,this.canvas,this.graph_mouse);if(t||n==g.TRANSPARENT_TITLE){if(a.onDrawTitleBar)a.onDrawTitleBar(b,d,c,this.ds.scale,e);else if(n!=g.TRANSPARENT_TITLE&&(a.constructor.title_color||this.render_title_colored)){t= -a.constructor.title_color||e;a.flags.collapsed&&(b.shadowColor=g.DEFAULT_SHADOW_COLOR);if(this.use_gradients){var r=m.gradients[t];r||(r=m.gradients[t]=b.createLinearGradient(0,0,400,0),r.addColorStop(0,t),r.addColorStop(1,"#000"));b.fillStyle=r}else b.fillStyle=t;b.beginPath();p==g.BOX_SHAPE||k?b.rect(0,-d,c[0]+1,d):(p==g.ROUND_SHAPE||p==g.CARD_SHAPE)&&b.roundRect(0,-d,c[0]+1,d,a.flags.collapsed?[this.round_radius]:[this.round_radius,this.round_radius,0,0]);b.fill();b.shadowColor="transparent"}t= -!1;g.node_box_coloured_by_mode&&g.NODE_MODES_COLORS[a.mode]&&(t=g.NODE_MODES_COLORS[a.mode]);g.node_box_coloured_when_on&&(t=a.action_triggered?"#FFF":a.execute_triggered?"#AAA":t);if(a.onDrawTitleBox)a.onDrawTitleBox(b,d,c,this.ds.scale);else p==g.ROUND_SHAPE||p==g.CIRCLE_SHAPE||p==g.CARD_SHAPE?(k&&(b.fillStyle="black",b.beginPath(),b.arc(.5*d,-.5*d,6,0,2*Math.PI),b.fill()),b.fillStyle=a.boxcolor||t||g.NODE_DEFAULT_BOXCOLOR,k?b.fillRect(.5*d-5,-.5*d-5,10,10):(b.beginPath(),b.arc(.5*d,-.5*d,5,0,2* -Math.PI),b.fill())):(k&&(b.fillStyle="black",b.fillRect(.5*(d-10)-1,-.5*(d+10)-1,12,12)),b.fillStyle=a.boxcolor||t||g.NODE_DEFAULT_BOXCOLOR,b.fillRect(.5*(d-10),-.5*(d+10),10,10));b.globalAlpha=h;if(a.onDrawTitleText)a.onDrawTitleText(b,d,c,this.ds.scale,this.title_text_font,f);!k&&(b.font=this.title_text_font,h=String(a.getTitle()))&&(b.fillStyle=f?g.NODE_SELECTED_TITLE_COLOR:a.constructor.title_text_color||this.node_title_color,a.flags.collapsed?(b.textAlign="left",b.measureText(h),b.fillText(h.substr(0, -20),d,g.NODE_TITLE_TEXT_Y-d),b.textAlign="left"):(b.textAlign="left",b.fillText(h,d,g.NODE_TITLE_TEXT_Y-d)));a.flags.collapsed||!a.subgraph||a.skip_subgraph_button||(h=g.NODE_TITLE_HEIGHT,t=a.size[0]-h,r=g.isInsideRectangle(this.graph_mouse[0]-a.pos[0],this.graph_mouse[1]-a.pos[1],t+2,-h+2,h-4,h-4),b.fillStyle=r?"#888":"#555",p==g.BOX_SHAPE||k?b.fillRect(t+2,-h+2,h-4,h-4):(b.beginPath(),b.roundRect(t+2,-h+2,h-4,h-4,[4]),b.fill()),b.fillStyle="#333",b.beginPath(),b.moveTo(t+.2*h,.6*-h),b.lineTo(t+ -.8*h,.6*-h),b.lineTo(t+.5*h,.3*-h),b.fill());if(a.onDrawTitle)a.onDrawTitle(b)}if(f){if(a.onBounding)a.onBounding(x);n==g.TRANSPARENT_TITLE&&(x[1]-=d,x[3]+=d);b.lineWidth=1;b.globalAlpha=.8;b.beginPath();p==g.BOX_SHAPE?b.rect(-6+x[0],-6+x[1],12+x[2],12+x[3]):p==g.ROUND_SHAPE||p==g.CARD_SHAPE&&a.flags.collapsed?b.roundRect(-6+x[0],-6+x[1],12+x[2],12+x[3],[2*this.round_radius]):p==g.CARD_SHAPE?b.roundRect(-6+x[0],-6+x[1],12+x[2],12+x[3],[2*this.round_radius,2,2*this.round_radius,2]):p==g.CIRCLE_SHAPE&& -b.arc(.5*c[0],.5*c[1],.5*c[0]+6,0,2*Math.PI);b.strokeStyle=g.NODE_BOX_OUTLINE_COLOR;b.stroke();b.strokeStyle=e;b.globalAlpha=1}0D[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(G(D,H)){var m=p.outputs[n];n=f.inputs[h];if(m&&n&&(p=m.dir||(p.horizontal?g.DOWN:g.RIGHT),n=n.dir||(f.horizontal?g.UP:g.LEFT),this.renderLink(a,t,r,k,!1,0,null,p,n),k&&k._last_time&&1E3>b-k._last_time)){m=2-.002*(b-k._last_time);var l=a.globalAlpha;a.globalAlpha=l*m;this.renderLink(a,t,r,k,!0,m,"white",p,n);a.globalAlpha=l}}}}}}a.globalAlpha=1};m.prototype.renderLink=function(a,b,c,e,d,f,h,k,p,n){e&&this.visible_links.push(e);!h&&e&&(h=e.color||m.link_type_colors[e.type]); -h||(h=this.default_link_color);null!=e&&this.highlighted_links[e.id]&&(h="#FFF");k=k||g.RIGHT;p=p||g.LEFT;var t=I(b,c);this.render_connections_border&&.6b[1]?0:Math.PI,a.save(),a.translate(r[0],r[1]),a.rotate(t),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5, --3),a.fill(),a.restore(),a.save(),a.translate(e[0],e[1]),a.rotate(n),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore()),a.beginPath(),a.arc(d[0],d[1],5,0,2*Math.PI),a.fill());if(f)for(a.fillStyle=h,r=0;5>r;++r)f=(.001*g.getTime()+.2*r)%1,d=this.computeConnectionPoint(b,c,f,k,p),a.beginPath(),a.arc(d[0],d[1],5,0,2*Math.PI),a.fill()};m.prototype.computeConnectionPoint=function(a,b,c,e,d){e=e||g.RIGHT;d=d||g.LEFT;var f=I(a,b),h=[a[0],a[1]],k=[b[0],b[1]];switch(e){case g.LEFT:h[0]+= --.25*f;break;case g.RIGHT:h[0]+=.25*f;break;case g.UP:h[1]+=-.25*f;break;case g.DOWN:h[1]+=.25*f}switch(d){case g.LEFT:k[0]+=-.25*f;break;case g.RIGHT:k[0]+=.25*f;break;case g.UP:k[1]+=-.25*f;break;case g.DOWN:k[1]+=.25*f}e=(1-c)*(1-c)*(1-c);d=3*(1-c)*(1-c)*c;f=3*(1-c)*c*c;c*=c*c;return[e*a[0]+d*h[0]+f*k[0]+c*b[0],e*a[1]+d*h[1]+f*k[1]+c*b[1]]};m.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;cB&&(B=0);1u&&(u=0),1f||f>l-12||hr.last_y+m||void 0===r.last_y)){e=r.value;switch(r.type){case "button":c.type===g.pointerevents_method+"down"&&(r.callback&&setTimeout(function(){r.callback(r,p,a,b,c)},20),this.dirty_canvas=r.clicked=!0);break;case "slider":e=r.value;n=J((f-15)/(l-30),0,1);if(r.options.read_only)break;r.value=r.options.min+(r.options.max-r.options.min)*n;e!=r.value&&setTimeout(function(){d(r,r.value)},20);this.dirty_canvas=!0;break;case "number":case "combo":e= -r.value;if(c.type==g.pointerevents_method+"move"&&"number"==r.type)c.deltaX&&(r.value+=.1*c.deltaX*(r.options.step||1)),null!=r.options.min&&r.valuer.options.max&&(r.value=r.options.max);else if(c.type==g.pointerevents_method+"down"){var v=r.options.values;v&&v.constructor===Function&&(v=r.options.values(r,a));var q=null;"number"!=r.type&&(q=v.constructor===Array?v:Object.keys(v));f=40>f?-1:f>l-40?1:0;if("number"==r.type)r.value+= -.1*f*(r.options.step||1),null!=r.options.min&&r.valuer.options.max&&(r.value=r.options.max);else if(f)n=-1,this.last_mouseclick=0,n=v.constructor===Object?q.indexOf(String(r.value))+f:q.indexOf(r.value)+f,n>=q.length&&(n=q.length-1),0>n&&(n=0),r.value=v.constructor===Array?v[n]:n;else{var u=v!=q?Object.values(v):v;new g.ContextMenu(u,{scale:Math.max(1,this.ds.scale),event:c,className:"dark",callback:function(a,b,c){v!=q&&(a=u.indexOf(a)); -this.value=a;d(this,a);p.dirty_canvas=!0;return!1}.bind(r)},n)}}else c.type==g.pointerevents_method+"up"&&"number"==r.type&&(f=40>f?-1:f>l-40?1:0,200>c.click_time&&0==f&&this.prompt("Value",r.value,function(a){if(/^[0-9+\-*/()\s]+|\d+\.\d+$/.test(a))try{a=eval(a)}catch(N){}this.value=Number(a);d(this,this.value)}.bind(r),c));e!=r.value&&setTimeout(function(){d(this,this.value)}.bind(r),20);this.dirty_canvas=!0;break;case "toggle":c.type==g.pointerevents_method+"down"&&(r.value=!r.value,setTimeout(function(){d(r, -r.value)},20));break;case "string":case "text":c.type==g.pointerevents_method+"down"&&this.prompt("Value",r.value,function(a){d(this,a)}.bind(r),c,r.options?r.options.multiline:!1);break;default:r.mouse&&(this.dirty_canvas=r.mouse(c,[f,h],a))}if(e!=r.value){if(a.onWidgetChanged)a.onWidgetChanged(r.name,r.value,e,r);a.graph._version++}return r}}}return null};m.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(e),1>c&&(b.live_mode=!0));1c.pos[0]+c.size[0])c=h;if(null===e||g+n>e.pos[1]+e.size[1])e=h;if(null===d||p"+(p.label?p.label:k)+""+a+"",value:k})}if(h.length)return new g.ContextMenu(h,{event:c,callback:function(a,b,c,e){d&&(b=this.getBoundingClientRect(),f.showEditPropertyValue(d,a.value,{position:[b.left,b.top]}))},parentMenu:e,allow_html:!0, -node:d},b),!1}};m.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};m.onMenuResizeNode=function(a,b,c,e,d){if(d){a=function(a){a.size=a.computeSize();if(a.onResize)a.onResize(a.size)};b=m.active_canvas;if(!b.selected_nodes||1>=Object.keys(b.selected_nodes).length)a(d);else for(var f in b.selected_nodes)a(b.selected_nodes[f]);d.setDirtyCanvas(!0,!0)}};m.prototype.showLinkMenu=function(a,b){var c=this,e=c.graph.getNodeById(a.origin_id),d=c.graph.getNodeById(a.target_id), -f=!1;e&&e.outputs&&e.outputs[a.origin_slot]&&(f=e.outputs[a.origin_slot].type);var h=!1;d&&d.outputs&&d.outputs[a.target_slot]&&(h=d.inputs[a.target_slot].type);var k=new g.ContextMenu(["Add Node",null,"Delete",null],{event:b,title:null!=a.data?a.data.constructor.name:null,callback:function(b,g,t){switch(b){case "Add Node":m.onMenuAdd(null,null,t,k,function(b){b.inputs&&b.inputs.length&&b.outputs&&b.outputs.length&&e.connectByType(a.origin_slot,b,f)&&(b.connectByType(a.target_slot,d,h),b.pos[0]-= -.5*b.size[0])});break;case "Delete":c.graph.removeLink(a.id)}}});return!1};m.prototype.createDefaultNodeForSlot=function(a){a=a||{};a=Object.assign({nodeFrom:null,slotFrom:null,nodeTo:null,slotTo:null,position:[],nodeType:null,posAdd:[0,0],posSizeFix:[0,0]},a);var b=a.nodeFrom&&null!==a.slotFrom,c=!b&&a.nodeTo&&null!==a.slotTo;if(!b&&!c)return console.warn("No data passed to createDefaultNodeForSlot "+a.nodeFrom+" "+a.slotFrom+" "+a.nodeTo+" "+a.slotTo),!1;if(!a.nodeType)return console.warn("No type to createDefaultNodeForSlot"), +l.prototype.drawNodeShape=function(a,b,c,e,d,f,h){b.strokeStyle=e;b.fillStyle=d;d=g.NODE_TITLE_HEIGHT;var k=.5>this.ds.scale,q=a._shape||a.constructor.shape||g.ROUND_SHAPE,n=a.constructor.title_mode,p=!0;n==g.TRANSPARENT_TITLE||n==g.NO_TITLE?p=!1:n==g.AUTOHIDE_TITLE&&h&&(p=!0);x[0]=0;x[1]=p?-d:0;x[2]=c[0]+1;x[3]=p?c[1]+d:c[1];h=b.globalAlpha;b.beginPath();q==g.BOX_SHAPE||k?b.fillRect(x[0],x[1],x[2],x[3]):q==g.ROUND_SHAPE||q==g.CARD_SHAPE?b.roundRect(x[0],x[1],x[2],x[3],q==g.CARD_SHAPE?[this.round_radius, +this.round_radius,0,0]:[this.round_radius]):q==g.CIRCLE_SHAPE&&b.arc(.5*c[0],.5*c[1],.5*c[0],0,2*Math.PI);b.fill();!a.flags.collapsed&&p&&(b.shadowColor="transparent",b.fillStyle="rgba(0,0,0,0.2)",b.fillRect(0,-1,x[2],2));b.shadowColor="transparent";if(a.onDrawBackground)a.onDrawBackground(b,this,this.canvas,this.graph_mouse);if(p||n==g.TRANSPARENT_TITLE){if(a.onDrawTitleBar)a.onDrawTitleBar(b,d,c,this.ds.scale,e);else if(n!=g.TRANSPARENT_TITLE&&(a.constructor.title_color||this.render_title_colored)){p= +a.constructor.title_color||e;a.flags.collapsed&&(b.shadowColor=g.DEFAULT_SHADOW_COLOR);if(this.use_gradients){var A=l.gradients[p];A||(A=l.gradients[p]=b.createLinearGradient(0,0,400,0),A.addColorStop(0,p),A.addColorStop(1,"#000"));b.fillStyle=A}else b.fillStyle=p;b.beginPath();q==g.BOX_SHAPE||k?b.rect(0,-d,c[0]+1,d):(q==g.ROUND_SHAPE||q==g.CARD_SHAPE)&&b.roundRect(0,-d,c[0]+1,d,a.flags.collapsed?[this.round_radius]:[this.round_radius,this.round_radius,0,0]);b.fill();b.shadowColor="transparent"}p= +!1;g.node_box_coloured_by_mode&&g.NODE_MODES_COLORS[a.mode]&&(p=g.NODE_MODES_COLORS[a.mode]);g.node_box_coloured_when_on&&(p=a.action_triggered?"#FFF":a.execute_triggered?"#AAA":p);if(a.onDrawTitleBox)a.onDrawTitleBox(b,d,c,this.ds.scale);else q==g.ROUND_SHAPE||q==g.CIRCLE_SHAPE||q==g.CARD_SHAPE?(k&&(b.fillStyle="black",b.beginPath(),b.arc(.5*d,-.5*d,6,0,2*Math.PI),b.fill()),b.fillStyle=a.boxcolor||p||g.NODE_DEFAULT_BOXCOLOR,k?b.fillRect(.5*d-5,-.5*d-5,10,10):(b.beginPath(),b.arc(.5*d,-.5*d,5,0,2* +Math.PI),b.fill())):(k&&(b.fillStyle="black",b.fillRect(.5*(d-10)-1,-.5*(d+10)-1,12,12)),b.fillStyle=a.boxcolor||p||g.NODE_DEFAULT_BOXCOLOR,b.fillRect(.5*(d-10),-.5*(d+10),10,10));b.globalAlpha=h;if(a.onDrawTitleText)a.onDrawTitleText(b,d,c,this.ds.scale,this.title_text_font,f);!k&&(b.font=this.title_text_font,h=String(a.getTitle()))&&(b.fillStyle=f?g.NODE_SELECTED_TITLE_COLOR:a.constructor.title_text_color||this.node_title_color,a.flags.collapsed?(b.textAlign="left",b.measureText(h),b.fillText(h.substr(0, +20),d,g.NODE_TITLE_TEXT_Y-d),b.textAlign="left"):(b.textAlign="left",b.fillText(h,d,g.NODE_TITLE_TEXT_Y-d)));a.flags.collapsed||!a.subgraph||a.skip_subgraph_button||(h=g.NODE_TITLE_HEIGHT,p=a.size[0]-h,A=g.isInsideRectangle(this.graph_mouse[0]-a.pos[0],this.graph_mouse[1]-a.pos[1],p+2,-h+2,h-4,h-4),b.fillStyle=A?"#888":"#555",q==g.BOX_SHAPE||k?b.fillRect(p+2,-h+2,h-4,h-4):(b.beginPath(),b.roundRect(p+2,-h+2,h-4,h-4,[4]),b.fill()),b.fillStyle="#333",b.beginPath(),b.moveTo(p+.2*h,.6*-h),b.lineTo(p+ +.8*h,.6*-h),b.lineTo(p+.5*h,.3*-h),b.fill());if(a.onDrawTitle)a.onDrawTitle(b)}if(f){if(a.onBounding)a.onBounding(x);n==g.TRANSPARENT_TITLE&&(x[1]-=d,x[3]+=d);b.lineWidth=1;b.globalAlpha=.8;b.beginPath();q==g.BOX_SHAPE?b.rect(-6+x[0],-6+x[1],12+x[2],12+x[3]):q==g.ROUND_SHAPE||q==g.CARD_SHAPE&&a.flags.collapsed?b.roundRect(-6+x[0],-6+x[1],12+x[2],12+x[3],[2*this.round_radius]):q==g.CARD_SHAPE?b.roundRect(-6+x[0],-6+x[1],12+x[2],12+x[3],[2*this.round_radius,2,2*this.round_radius,2]):q==g.CIRCLE_SHAPE&& +b.arc(.5*c[0],.5*c[1],.5*c[0]+6,0,2*Math.PI);b.strokeStyle=g.NODE_BOX_OUTLINE_COLOR;b.stroke();b.strokeStyle=e;b.globalAlpha=1}0E[2]&&(E[0]+=E[2],E[2]=Math.abs(E[2]));0>E[3]&& +(E[1]+=E[3],E[3]=Math.abs(E[3]));if(H(E,I)){var v=q.outputs[n];n=f.inputs[h];if(v&&n&&(q=v.dir||(q.horizontal?g.DOWN:g.RIGHT),n=n.dir||(f.horizontal?g.UP:g.LEFT),this.renderLink(a,p,l,k,!1,0,null,q,n),k&&k._last_time&&1E3>b-k._last_time)){v=2-.002*(b-k._last_time);var t=a.globalAlpha;a.globalAlpha=t*v;this.renderLink(a,p,l,k,!0,v,"white",q,n);a.globalAlpha=t}}}}}}a.globalAlpha=1};l.prototype.renderLink=function(a,b,c,e,d,f,h,k,q,n){e&&this.visible_links.push(e);!h&&e&&(h=e.color||l.link_type_colors[e.type]); +h||(h=this.default_link_color);null!=e&&this.highlighted_links[e.id]&&(h="#FFF");k=k||g.RIGHT;q=q||g.LEFT;var p=J(b,c);this.render_connections_border&&.6b[1]?0:Math.PI,a.save(),a.translate(A[0],A[1]),a.rotate(p),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5, +-3),a.fill(),a.restore(),a.save(),a.translate(e[0],e[1]),a.rotate(n),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore()),a.beginPath(),a.arc(d[0],d[1],5,0,2*Math.PI),a.fill());if(f)for(a.fillStyle=h,A=0;5>A;++A)f=(.001*g.getTime()+.2*A)%1,d=this.computeConnectionPoint(b,c,f,k,q),a.beginPath(),a.arc(d[0],d[1],5,0,2*Math.PI),a.fill()};l.prototype.computeConnectionPoint=function(a,b,c,e,d){e=e||g.RIGHT;d=d||g.LEFT;var f=J(a,b),h=[a[0],a[1]],k=[b[0],b[1]];switch(e){case g.LEFT:h[0]+= +-.25*f;break;case g.RIGHT:h[0]+=.25*f;break;case g.UP:h[1]+=-.25*f;break;case g.DOWN:h[1]+=.25*f}switch(d){case g.LEFT:k[0]+=-.25*f;break;case g.RIGHT:k[0]+=.25*f;break;case g.UP:k[1]+=-.25*f;break;case g.DOWN:k[1]+=.25*f}e=(1-c)*(1-c)*(1-c);d=3*(1-c)*(1-c)*c;f=3*(1-c)*c*c;c*=c*c;return[e*a[0]+d*h[0]+f*k[0]+c*b[0],e*a[1]+d*h[1]+f*k[1]+c*b[1]]};l.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;cz&&(z=0);1w&&(w=0),1f||f>u-12||hv.last_y+t||void 0===v.last_y)){e=v.value;switch(v.type){case "button":c.type===g.pointerevents_method+"down"&&(v.callback&&setTimeout(function(){v.callback(v,n,a,b,c)},20),this.dirty_canvas=v.clicked=!0);break;case "slider":e=v.value;p=K((f-15)/(u-30),0,1);if(v.options.read_only)break;v.value=v.options.min+(v.options.max-v.options.min)*p;e!=v.value&&setTimeout(function(){d(v,v.value)},20);this.dirty_canvas= +!0;break;case "number":case "combo":e=v.value;if(c.type==g.pointerevents_method+"move"&&"number"==v.type)l&&(v.value+=.1*l*(v.options.step||1)),null!=v.options.min&&v.valuev.options.max&&(v.value=v.options.max);else if(c.type==g.pointerevents_method+"down"){var r=v.options.values;r&&r.constructor===Function&&(r=v.options.values(v,a));var w=null;"number"!=v.type&&(w=r.constructor===Array?r:Object.keys(r));f=40>f?-1:f>u-40?1:0;if("number"== +v.type)v.value+=.1*f*(v.options.step||1),null!=v.options.min&&v.valuev.options.max&&(v.value=v.options.max);else if(f)p=-1,this.last_mouseclick=0,p=r.constructor===Object?w.indexOf(String(v.value))+f:w.indexOf(v.value)+f,p>=w.length&&(p=w.length-1),0>p&&(p=0),v.value=r.constructor===Array?r[p]:p;else{var z=r!=w?Object.values(r):r;new g.ContextMenu(z,{scale:Math.max(1,this.ds.scale),event:c,className:"dark",callback:function(a,b, +c){r!=w&&(a=z.indexOf(a));this.value=a;d(this,a);n.dirty_canvas=!0;return!1}.bind(v)},p)}}else c.type==g.pointerevents_method+"up"&&"number"==v.type&&(f=40>f?-1:f>u-40?1:0,200>c.click_time&&0==f&&this.prompt("Value",v.value,function(a){if(/^[0-9+\-*/()\s]+|\d+\.\d+$/.test(a))try{a=eval(a)}catch(O){}this.value=Number(a);d(this,this.value)}.bind(v),c));e!=v.value&&setTimeout(function(){d(this,this.value)}.bind(v),20);this.dirty_canvas=!0;break;case "toggle":c.type==g.pointerevents_method+"down"&&(v.value= +!v.value,setTimeout(function(){d(v,v.value)},20));break;case "string":case "text":c.type==g.pointerevents_method+"down"&&this.prompt("Value",v.value,function(a){d(this,a)}.bind(v),c,v.options?v.options.multiline:!1);break;default:v.mouse&&(this.dirty_canvas=v.mouse(c,[f,h],a))}if(e!=v.value){if(a.onWidgetChanged)a.onWidgetChanged(v.name,v.value,e,v);a.graph._version++}return v}}}return null};l.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(e),1>c&&(b.live_mode=!0));1c.pos[0]+c.size[0])c=h;if(null===e||g+n>e.pos[1]+e.size[1])e=h;if(null===d||l"+(q.label?q.label:k)+""+a+"",value:k})}if(h.length)return new g.ContextMenu(h,{event:c,callback:function(a,b,c,e){d&&(b=this.getBoundingClientRect(),f.showEditPropertyValue(d,a.value,{position:[b.left,b.top]}))},parentMenu:e,allow_html:!0, +node:d},b),!1}};l.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};l.onMenuResizeNode=function(a,b,c,e,d){if(d){a=function(a){a.size=a.computeSize();if(a.onResize)a.onResize(a.size)};b=l.active_canvas;if(!b.selected_nodes||1>=Object.keys(b.selected_nodes).length)a(d);else for(var f in b.selected_nodes)a(b.selected_nodes[f]);d.setDirtyCanvas(!0,!0)}};l.prototype.showLinkMenu=function(a,b){var c=this,e=c.graph.getNodeById(a.origin_id),d=c.graph.getNodeById(a.target_id), +f=!1;e&&e.outputs&&e.outputs[a.origin_slot]&&(f=e.outputs[a.origin_slot].type);var h=!1;d&&d.outputs&&d.outputs[a.target_slot]&&(h=d.inputs[a.target_slot].type);var k=new g.ContextMenu(["Add Node",null,"Delete",null],{event:b,title:null!=a.data?a.data.constructor.name:null,callback:function(b,g,p){switch(b){case "Add Node":l.onMenuAdd(null,null,p,k,function(b){b.inputs&&b.inputs.length&&b.outputs&&b.outputs.length&&e.connectByType(a.origin_slot,b,f)&&(b.connectByType(a.target_slot,d,h),b.pos[0]-= +.5*b.size[0])});break;case "Delete":c.graph.removeLink(a.id)}}});return!1};l.prototype.createDefaultNodeForSlot=function(a){a=a||{};a=Object.assign({nodeFrom:null,slotFrom:null,nodeTo:null,slotTo:null,position:[],nodeType:null,posAdd:[0,0],posSizeFix:[0,0]},a);var b=a.nodeFrom&&null!==a.slotFrom,c=!b&&a.nodeTo&&null!==a.slotTo;if(!b&&!c)return console.warn("No data passed to createDefaultNodeForSlot "+a.nodeFrom+" "+a.slotFrom+" "+a.nodeTo+" "+a.slotTo),!1;if(!a.nodeType)return console.warn("No type to createDefaultNodeForSlot"), !1;var e=b?a.nodeFrom:a.nodeTo,d=b?a.slotFrom:a.slotTo;switch(typeof d){case "string":c=b?e.findOutputSlot(d,!1):e.findInputSlot(d,!1);d=b?e.outputs[d]:e.inputs[d];break;case "object":c=b?e.findOutputSlot(d.name):e.findInputSlot(d.name);break;case "number":c=d;d=b?e.outputs[d]:e.inputs[d];break;default:return console.warn("Cant get slot information "+d),!1}!1!==d&&!1!==c||console.warn("createDefaultNodeForSlot bad slotX "+d+" "+c);e=d.type==g.EVENT?"_event_":d.type;if((d=b?g.slot_types_default_out: g.slot_types_default_in)&&d[e]){nodeNewType=!1;if("object"==typeof d[e]||"array"==typeof d[e])for(var f in d[e]){if(a.nodeType==d[e][f]||"AUTO"==a.nodeType){nodeNewType=d[e][f];break}}else if(a.nodeType==d[e]||"AUTO"==a.nodeType)nodeNewType=d[e];if(nodeNewType){f=!1;"object"==typeof nodeNewType&&nodeNewType.node&&(f=nodeNewType,nodeNewType=nodeNewType.node);if(d=g.createNode(nodeNewType)){if(f){if(f.properties)for(var h in f.properties)d.addProperty(h,f.properties[h]);if(f.inputs)for(h in d.inputs= [],f.inputs)d.addOutput(f.inputs[h][0],f.inputs[h][1]);if(f.outputs)for(h in d.outputs=[],f.outputs)d.addOutput(f.outputs[h][0],f.outputs[h][1]);f.title&&(d.title=f.title);f.json&&d.configure(f.json)}this.graph.add(d);d.pos=[a.position[0]+a.posAdd[0]+(a.posSizeFix[0]?a.posSizeFix[0]*d.size[0]:0),a.position[1]+a.posAdd[1]+(a.posSizeFix[1]?a.posSizeFix[1]*d.size[1]:0)];b?a.nodeFrom.connectByType(c,d,e):a.nodeTo.connectByTypeOutput(c,d,e);return!0}console.log("failed creating "+nodeNewType)}}return!1}; -m.prototype.showConnectionMenu=function(a){a=a||{};var b=Object.assign({nodeFrom:null,slotFrom:null,nodeTo:null,slotTo:null,e:null},a),c=this,e=b.nodeFrom&&b.slotFrom;a=!e&&b.nodeTo&&b.slotTo;if(!e&&!a)return console.warn("No data passed to showConnectionMenu"),!1;a=e?b.nodeFrom:b.nodeTo;var d=e?b.slotFrom:b.slotTo,f=!1;switch(typeof d){case "string":f=e?a.findOutputSlot(d,!1):a.findInputSlot(d,!1);d=e?a.outputs[d]:a.inputs[d];break;case "object":f=e?a.findOutputSlot(d.name):a.findInputSlot(d.name); -break;case "number":f=d;d=e?a.outputs[d]:a.inputs[d];break;default:return console.warn("Cant get slot information "+d),!1}a=["Add Node",null];c.allow_searchbox&&(a.push("Search"),a.push(null));var h=d.type==g.EVENT?"_event_":d.type,k=e?g.slot_types_default_out:g.slot_types_default_in;if(k&&k[h])if("object"==typeof k[h]||"array"==typeof k[h])for(var p in k[h])a.push(k[h][p]);else a.push(k[h]);var n=new g.ContextMenu(a,{event:b.e,title:(d&&""!=d.name?d.name+(h?" | ":""):"")+(d&&h?h:""),callback:function(a, -g,k){switch(a){case "Add Node":m.onMenuAdd(null,null,k,n,function(a){e?b.nodeFrom.connectByType(f,a,h):b.nodeTo.connectByTypeOutput(f,a,h)});break;case "Search":e?c.showSearchBox(k,{node_from:b.nodeFrom,slot_from:d,type_filter_in:h}):c.showSearchBox(k,{node_to:b.nodeTo,slot_from:d,type_filter_out:h});break;default:c.createDefaultNodeForSlot(Object.assign(b,{position:[b.e.canvasX,b.e.canvasY],nodeType:a}))}}});return!1};m.onShowPropertyEditor=function(a,b,c,e,d){function f(){if(p){var b=p.value;"Number"== -a.type?b=Number(b):"Boolean"==a.type&&(b=!!b);d[h]=b;k.parentNode&&k.parentNode.removeChild(k);d.setDirtyCanvas(!0,!0)}}var h=a.property||"title";b=d[h];var k=document.createElement("div");k.is_modified=!1;k.className="graphdialog";k.innerHTML="";k.close=function(){k.parentNode&&k.parentNode.removeChild(k)};k.querySelector(".name").innerText=h;var p=k.querySelector(".value");p&&(p.value=b,p.addEventListener("blur", -function(a){this.focus()}),p.addEventListener("keydown",function(a){k.is_modified=!0;if(27==a.keyCode)k.close();else if(13==a.keyCode)f();else if(13!=a.keyCode&&"textarea"!=a.target.localName)return;a.preventDefault();a.stopPropagation()}));b=m.active_canvas.canvas;c=b.getBoundingClientRect();var n=e=-20;c&&(e-=c.left,n-=c.top);event?(k.style.left=event.clientX+e+"px",k.style.top=event.clientY+n+"px"):(k.style.left=.5*b.width+e+"px",k.style.top=.5*b.height+n+"px");k.querySelector("button").addEventListener("click", -f);b.parentNode.appendChild(k);p&&p.focus();var t=null;k.addEventListener("mouseleave",function(a){g.dialog_close_on_mouse_leave&&!k.is_modified&&g.dialog_close_on_mouse_leave&&(t=setTimeout(k.close,g.dialog_close_on_mouse_leave_delay))});k.addEventListener("mouseenter",function(a){g.dialog_close_on_mouse_leave&&t&&clearTimeout(t)})};m.prototype.prompt=function(a,b,c,e,d){var f=this;a=a||"";var h=document.createElement("div");h.is_modified=!1;h.className="graphdialog rounded";h.innerHTML=d?" ": -" ";h.close=function(){f.prompt_box=null;h.parentNode&&h.parentNode.removeChild(h)};d=m.active_canvas.canvas;d.parentNode.appendChild(h);1";k.close=function(){k.parentNode&&k.parentNode.removeChild(k)};k.querySelector(".name").innerText=h;var q=k.querySelector(".value");q&&(q.value=b,q.addEventListener("blur", +function(a){this.focus()}),q.addEventListener("keydown",function(a){k.is_modified=!0;if(27==a.keyCode)k.close();else if(13==a.keyCode)f();else if(13!=a.keyCode&&"textarea"!=a.target.localName)return;a.preventDefault();a.stopPropagation()}));b=l.active_canvas.canvas;c=b.getBoundingClientRect();var n=e=-20;c&&(e-=c.left,n-=c.top);event?(k.style.left=event.clientX+e+"px",k.style.top=event.clientY+n+"px"):(k.style.left=.5*b.width+e+"px",k.style.top=.5*b.height+n+"px");k.querySelector("button").addEventListener("click", +f);b.parentNode.appendChild(k);q&&q.focus();var p=null;k.addEventListener("mouseleave",function(a){g.dialog_close_on_mouse_leave&&!k.is_modified&&g.dialog_close_on_mouse_leave&&(p=setTimeout(k.close,g.dialog_close_on_mouse_leave_delay))});k.addEventListener("mouseenter",function(a){g.dialog_close_on_mouse_leave&&p&&clearTimeout(p)})};l.prototype.prompt=function(a,b,c,e,d){var f=this;a=a||"";var h=document.createElement("div");h.is_modified=!1;h.className="graphdialog rounded";h.innerHTML=d?" ": +" ";h.close=function(){f.prompt_box=null;h.parentNode&&h.parentNode.removeChild(h)};d=l.active_canvas.canvas;d.parentNode.appendChild(h);1m.search_limit))break}}r=null;if(Array.prototype.filter)r=Object.keys(g.registered_node_types).filter(e);else for(k in r=[],g.registered_node_types)e(k)&&r.push(k);for(k=0;km.search_limit);k++);if(b.show_general_after_typefiltered&&(l.value|| -t.value)){filtered_extra=[];for(k in g.registered_node_types)e(k,{inTypeOverride:l&&l.value?"*":!1,outTypeOverride:t&&t.value?"*":!1})&&filtered_extra.push(k);for(k=0;km.search_limit);k++);}if((l.value||t.value)&&0==v.childNodes.length&&b.show_general_if_none_on_typefilter){filtered_extra=[];for(k in g.registered_node_types)e(k,{skipFilter:!0})&&filtered_extra.push(k);for(k=0;km.search_limit);k++);}}}b=Object.assign({slot_from:null,node_from:null,node_to:null,do_type_filter:g.search_filter_enabled,type_filter_in:!1,type_filter_out:!1,show_general_if_none_on_typefilter:!0,show_general_after_typefiltered:!0,hide_on_mouse_leave:g.search_hide_on_mouse_leave,show_all_if_empty:!0,show_all_on_open:g.search_show_all_on_open},b||{});var f=this,h=m.active_canvas,k=h.canvas,p=k.ownerDocument||document,n=document.createElement("div");n.className= -"litegraph litesearchbox graphdialog rounded";n.innerHTML="Search ";b.do_type_filter&&(n.innerHTML+="",n.innerHTML+="");n.innerHTML+="
";p.fullscreenElement?p.fullscreenElement.appendChild(n):(p.body.appendChild(n),p.body.style.overflow="hidden");if(b.do_type_filter)var t= -n.querySelector(".slot_in_type_filter"),l=n.querySelector(".slot_out_type_filter");n.close=function(){f.search_box=null;this.blur();k.focus();p.body.style.overflow="";setTimeout(function(){f.canvas.focus()},20);n.parentNode&&n.parentNode.removeChild(n)};1t.height-200&&(v.style.maxHeight=t.height-a.layerY-20+"px");z.focus();b.show_all_on_open&&d();return n};m.prototype.showEditPropertyValue=function(a,b,c){function e(){d(m.value)}function d(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"==h||"object"== -h)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();l.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){c=c||{};var f=a.getPropertyInfo(b),h=f.type,g="";if("string"==h||"number"==h||"array"==h||"object"==h)g="";else if("enum"!=h&&"combo"!=h||!f.values)if("boolean"==h||"toggle"==h)g="";else{console.warn("unknown type: "+h);return}else{g=""}var l=this.createDialog(""+(f.label?f.label:b)+""+g+"",c),m=!1;if("enum"!=h&&"combo"!=h||!f.values)if("boolean"==h||"toggle"==h)(m=l.querySelector("input"))&&m.addEventListener("click", -function(a){l.modified();d(!!m.checked)});else{if(m=l.querySelector("input"))m.addEventListener("blur",function(a){this.focus()}),n=void 0!==a.properties[b]?a.properties[b]:"","string"!==h&&(n=JSON.stringify(n)),m.value=n,m.addEventListener("keydown",function(a){if(27==a.keyCode)l.close();else if(13==a.keyCode)e();else if(13!=a.keyCode){l.modified();return}a.preventDefault();a.stopPropagation()})}else m=l.querySelector("select"),m.addEventListener("change",function(a){l.modified();d(a.target.value)}); -m&&m.focus();l.querySelector("button").addEventListener("click",e);return l}};m.prototype.createDialog=function(a,b){b=Object.assign({checkForInput:!1,closeOnLeave:!0,closeOnLeave_checkModified:!0},b||{});var c=document.createElement("div");c.className="graphdialog";c.innerHTML=a;c.is_modified=!1;a=this.canvas.getBoundingClientRect();var e=-20,d=-20;a&&(e-=a.left,d-=a.top);b.position?(e+=b.position[0],d+=b.position[1]):b.event?(e+=b.event.clientX,d+=b.event.clientY):(e+=.5*this.canvas.width,d+=.5* -this.canvas.height);c.style.left=e+"px";c.style.top=d+"px";this.canvas.parentNode.appendChild(c);b.checkForInput&&(a=[],(a=c.querySelectorAll("input"))&&a.forEach(function(a){a.addEventListener("keydown",function(a){c.modified();if(27==a.keyCode)c.close();else if(13!=a.keyCode)return;a.preventDefault();a.stopPropagation()});a.focus()}));c.modified=function(){c.is_modified=!0};c.close=function(){c.parentNode&&c.parentNode.removeChild(c)};var f=null,h=!1;c.addEventListener("mouseleave",function(a){h|| -(b.closeOnLeave||g.dialog_close_on_mouse_leave)&&!c.is_modified&&g.dialog_close_on_mouse_leave&&(f=setTimeout(c.close,g.dialog_close_on_mouse_leave_delay))});c.addEventListener("mouseenter",function(a){(b.closeOnLeave||g.dialog_close_on_mouse_leave)&&f&&clearTimeout(f)});(a=c.querySelectorAll("select"))&&a.forEach(function(a){a.addEventListener("click",function(a){h++});a.addEventListener("blur",function(a){h=0});a.addEventListener("change",function(a){h=-1})});return c};m.prototype.createPanel=function(a, +z;z&&z.classList.remove("selected");z?(z=a?z.nextSibling:z.previousSibling)||(z=b):z=a?u.childNodes[0]:u.childNodes[u.childNodes.length];z&&(z.classList.add("selected"),z.scrollIntoView({block:"end",behavior:"smooth"}))}function d(){function a(a,b){var d=document.createElement("div");w||(w=a);d.innerText=a;d.dataset.type=escape(a);d.className="litegraph lite-search-item";b&&(d.className+=" "+b);d.addEventListener("click",function(a){c(unescape(this.dataset.type))});u.appendChild(d)}x=null;var d=B.value; +w=null;u.innerHTML="";if(d||b.show_all_if_empty)if(f.onSearchBox){var e=f.onSearchBox(u,d,h);if(e)for(var k=0;kl.search_limit))break}}r=null;if(Array.prototype.filter)r=Object.keys(g.registered_node_types).filter(e);else for(k in r=[],g.registered_node_types)e(k)&&r.push(k);for(k=0;kl.search_limit);k++);if(b.show_general_after_typefiltered&&(p.value|| +m.value)){filtered_extra=[];for(k in g.registered_node_types)e(k,{inTypeOverride:p&&p.value?"*":!1,outTypeOverride:m&&m.value?"*":!1})&&filtered_extra.push(k);for(k=0;kl.search_limit);k++);}if((p.value||m.value)&&0==u.childNodes.length&&b.show_general_if_none_on_typefilter){filtered_extra=[];for(k in g.registered_node_types)e(k,{skipFilter:!0})&&filtered_extra.push(k);for(k=0;kl.search_limit);k++);}}}b=Object.assign({slot_from:null,node_from:null,node_to:null,do_type_filter:g.search_filter_enabled,type_filter_in:!1,type_filter_out:!1,show_general_if_none_on_typefilter:!0,show_general_after_typefiltered:!0,hide_on_mouse_leave:g.search_hide_on_mouse_leave,show_all_if_empty:!0,show_all_on_open:g.search_show_all_on_open},b||{});var f=this,h=l.active_canvas,k=h.canvas,q=k.ownerDocument||document,n=document.createElement("div");n.className= +"litegraph litesearchbox graphdialog rounded";n.innerHTML="Search ";b.do_type_filter&&(n.innerHTML+="",n.innerHTML+="");n.innerHTML+="
";q.fullscreenElement?q.fullscreenElement.appendChild(n):(q.body.appendChild(n),q.body.style.overflow="hidden");if(b.do_type_filter)var p= +n.querySelector(".slot_in_type_filter"),m=n.querySelector(".slot_out_type_filter");n.close=function(){f.search_box=null;this.blur();k.focus();q.body.style.overflow="";setTimeout(function(){f.canvas.focus()},20);n.parentNode&&n.parentNode.removeChild(n)};1p.height-200&&(u.style.maxHeight=p.height-a.layerY-20+"px");B.focus();b.show_all_on_open&&d();return n};l.prototype.showEditPropertyValue=function(a,b,c){function e(){d(m.value)}function d(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"==h||"object"==h)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();p.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){c=c||{};var f=a.getPropertyInfo(b),h=f.type,g="";if("string"==h||"number"==h||"array"==h||"object"==h)g="";else if("enum"!=h&&"combo"!=h||!f.values)if("boolean"==h||"toggle"==h)g="";else{console.warn("unknown type: "+h);return}else{g=""}var p=this.createDialog(""+(f.label?f.label:b)+""+g+"",c),m=!1;if("enum"!=h&&"combo"!=h||!f.values)if("boolean"==h||"toggle"==h)(m=p.querySelector("input"))&& +m.addEventListener("click",function(a){p.modified();d(!!m.checked)});else{if(m=p.querySelector("input"))m.addEventListener("blur",function(a){this.focus()}),n=void 0!==a.properties[b]?a.properties[b]:"","string"!==h&&(n=JSON.stringify(n)),m.value=n,m.addEventListener("keydown",function(a){if(27==a.keyCode)p.close();else if(13==a.keyCode)e();else if(13!=a.keyCode){p.modified();return}a.preventDefault();a.stopPropagation()})}else m=p.querySelector("select"),m.addEventListener("change",function(a){p.modified(); +d(a.target.value)});m&&m.focus();p.querySelector("button").addEventListener("click",e);return p}};l.prototype.createDialog=function(a,b){b=Object.assign({checkForInput:!1,closeOnLeave:!0,closeOnLeave_checkModified:!0},b||{});var c=document.createElement("div");c.className="graphdialog";c.innerHTML=a;c.is_modified=!1;a=this.canvas.getBoundingClientRect();var e=-20,d=-20;a&&(e-=a.left,d-=a.top);b.position?(e+=b.position[0],d+=b.position[1]):b.event?(e+=b.event.clientX,d+=b.event.clientY):(e+=.5*this.canvas.width, +d+=.5*this.canvas.height);c.style.left=e+"px";c.style.top=d+"px";this.canvas.parentNode.appendChild(c);b.checkForInput&&(a=[],(a=c.querySelectorAll("input"))&&a.forEach(function(a){a.addEventListener("keydown",function(a){c.modified();if(27==a.keyCode)c.close();else if(13!=a.keyCode)return;a.preventDefault();a.stopPropagation()});a.focus()}));c.modified=function(){c.is_modified=!0};c.close=function(){c.parentNode&&c.parentNode.removeChild(c)};var f=null,h=!1;c.addEventListener("mouseleave",function(a){h|| +(b.closeOnLeave||g.dialog_close_on_mouse_leave)&&!c.is_modified&&g.dialog_close_on_mouse_leave&&(f=setTimeout(c.close,g.dialog_close_on_mouse_leave_delay))});c.addEventListener("mouseenter",function(a){(b.closeOnLeave||g.dialog_close_on_mouse_leave)&&f&&clearTimeout(f)});(a=c.querySelectorAll("select"))&&a.forEach(function(a){a.addEventListener("click",function(a){h++});a.addEventListener("blur",function(a){h=0});a.addEventListener("change",function(a){h=-1})});return c};l.prototype.createPanel=function(a, b){b=b||{};var c=b.window||window,e=document.createElement("div");e.className="litegraph dialog";e.innerHTML="
";e.header=e.querySelector(".dialog-header");b.width&&(e.style.width=b.width+(b.width.constructor===Number?"px":""));b.height&&(e.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(){e.close()}),e.header.appendChild(b));e.title_element=e.querySelector(".dialog-title");e.title_element.innerText=a;e.content=e.querySelector(".dialog-content");e.alt_content=e.querySelector(".dialog-alt-content");e.footer=e.querySelector(".dialog-footer");e.close=function(){if(e.onClose&&"function"==typeof e.onClose)e.onClose();e.parentNode&&e.parentNode.removeChild(e);this.parentNode&& this.parentNode.removeChild(this)};e.toggleAltContent=function(a){if("undefined"!=typeof a){var b=a?"block":"none";a=a?"none":"block"}else b="block"!=e.alt_content.style.display?"block":"none",a="block"!=e.alt_content.style.display?"none":"block";e.alt_content.style.display=b;e.content.style.display=a};e.toggleFooterVisibility=function(a){e.footer.style.display="undefined"!=typeof a?a?"block":"none":"block"!=e.footer.style.display?"block":"none"};e.clear=function(){this.content.innerHTML=""};e.addHTML= -function(a,b,c){var d=document.createElement("div");b&&(d.className=b);d.innerHTML=a;c?e.footer.appendChild(d):e.content.appendChild(d);return d};e.addButton=function(a,b,c){var d=document.createElement("button");d.innerText=a;d.options=c;d.classList.add("btn");d.addEventListener("click",b);e.footer.appendChild(d);return d};e.addSeparator=function(){var a=document.createElement("div");a.className="separator";e.content.appendChild(a)};e.addWidget=function(a,b,h,k,l){function d(a,b){k.callback&&k.callback(a, -b,k);l&&l(a,b,k)}k=k||{};var f=String(h);a=a.toLowerCase();"number"==a&&(f=h.toFixed(3));var p=document.createElement("div");p.className="property";p.innerHTML="";p.querySelector(".property_name").innerText=k.label||b;var q=p.querySelector(".property_value");q.innerText=f;p.dataset.property=b;p.dataset.type=k.type||a;p.options=k;p.value=h;if("code"==a)p.addEventListener("click",function(a){e.inner_showCodePad(this.dataset.property)}); -else if("boolean"==a)p.classList.add("boolean"),h&&p.classList.add("bool-on"),p.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";d(a,this.value)});else if("string"==a||"number"==a)q.setAttribute("contenteditable",!0),q.addEventListener("keydown",function(b){"Enter"!=b.code||"string"==a&&b.shiftKey||(b.preventDefault(),this.blur())}),q.addEventListener("blur", -function(){var a=this.innerText,b=this.parentNode.dataset.property;"number"==this.parentNode.dataset.type&&(a=Number(a));d(b,a)});else if("enum"==a||"combo"==a)f=m.getPropertyPrintableValue(h,k.values),q.innerText=f,q.addEventListener("click",function(a){var b=this.parentNode.dataset.property,e=this;new g.ContextMenu(k.values||[],{event:a,className:"dark",callback:function(a,c,f){e.innerText=a;d(b,a);return!1}},c)});e.content.appendChild(p);return p};if(e.onOpen&&"function"==typeof e.onOpen)e.onOpen(); -return e};m.getPropertyPrintableValue=function(a,b){if(!b||b.constructor===Array)return String(a);if(b.constructor===Object){var c="",e;for(e in b)if(b[e]==a){c=e;break}return String(a)+" ("+c+")"}};m.prototype.closePanels=function(){var a=document.querySelector("#node-panel");a&&a.close();(a=document.querySelector("#option-panel"))&&a.close()};m.prototype.showShowGraphOptionsPanel=function(a,b,c,e){if(this.constructor&&"HTMLDivElement"==this.constructor.name){if(!(b&&b.event&&b.event.target&&b.event.target.lgraphcanvas)){console.warn("Canvas not found"); +function(a,b,c){var d=document.createElement("div");b&&(d.className=b);d.innerHTML=a;c?e.footer.appendChild(d):e.content.appendChild(d);return d};e.addButton=function(a,b,c){var d=document.createElement("button");d.innerText=a;d.options=c;d.classList.add("btn");d.addEventListener("click",b);e.footer.appendChild(d);return d};e.addSeparator=function(){var a=document.createElement("div");a.className="separator";e.content.appendChild(a)};e.addWidget=function(a,b,h,k,m){function d(a,b){k.callback&&k.callback(a, +b,k);m&&m(a,b,k)}k=k||{};var f=String(h);a=a.toLowerCase();"number"==a&&(f=h.toFixed(3));var q=document.createElement("div");q.className="property";q.innerHTML="";q.querySelector(".property_name").innerText=k.label||b;var r=q.querySelector(".property_value");r.innerText=f;q.dataset.property=b;q.dataset.type=k.type||a;q.options=k;q.value=h;if("code"==a)q.addEventListener("click",function(a){e.inner_showCodePad(this.dataset.property)}); +else if("boolean"==a)q.classList.add("boolean"),h&&q.classList.add("bool-on"),q.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";d(a,this.value)});else if("string"==a||"number"==a)r.setAttribute("contenteditable",!0),r.addEventListener("keydown",function(b){"Enter"!=b.code||"string"==a&&b.shiftKey||(b.preventDefault(),this.blur())}),r.addEventListener("blur", +function(){var a=this.innerText,b=this.parentNode.dataset.property;"number"==this.parentNode.dataset.type&&(a=Number(a));d(b,a)});else if("enum"==a||"combo"==a)f=l.getPropertyPrintableValue(h,k.values),r.innerText=f,r.addEventListener("click",function(a){var b=this.parentNode.dataset.property,e=this;new g.ContextMenu(k.values||[],{event:a,className:"dark",callback:function(a,c,f){e.innerText=a;d(b,a);return!1}},c)});e.content.appendChild(q);return q};if(e.onOpen&&"function"==typeof e.onOpen)e.onOpen(); +return e};l.getPropertyPrintableValue=function(a,b){if(!b||b.constructor===Array)return String(a);if(b.constructor===Object){var c="",e;for(e in b)if(b[e]==a){c=e;break}return String(a)+" ("+c+")"}};l.prototype.closePanels=function(){var a=document.querySelector("#node-panel");a&&a.close();(a=document.querySelector("#option-panel"))&&a.close()};l.prototype.showShowGraphOptionsPanel=function(a,b,c,e){if(this.constructor&&"HTMLDivElement"==this.constructor.name){if(!(b&&b.event&&b.event.target&&b.event.target.lgraphcanvas)){console.warn("Canvas not found"); return}var d=b.event.target.lgraphcanvas}else d=this;d.closePanels();a=d.getCanvasWindow();panel=d.createPanel("Options",{closable:!0,window:a,onOpen:function(){d.OPTIONPANEL_IS_OPEN=!0},onClose:function(){d.OPTIONPANEL_IS_OPEN=!1;d.options_panel=null}});d.options_panel=panel;panel.id="option-panel";panel.classList.add("settings");(function(){panel.content.innerHTML="";var a=function(a,b,c){c&&c.key&&(a=c.key);c.values&&(b=Object.values(c.values).indexOf(b));d[a]=b},b=g.availableCanvasOptions;b.sort(); -for(var c in b){var e=b[c];panel.addWidget("boolean",e,d[e],{key:e,on:"True",off:"False"},a)}panel.addWidget("combo","Render mode",g.LINK_RENDER_MODES[d.links_render_mode],{key:"links_render_mode",values:g.LINK_RENDER_MODES},a);panel.addSeparator();panel.footer.innerHTML=""})();d.canvas.parentNode.appendChild(panel)};m.prototype.showShowNodePanel=function(a){function b(){d.content.innerHTML="";d.addHTML(""+a.type+""+(a.constructor.desc||"")+""); -d.addHTML("

Properties

");var b=function(b,c){e.graph.beforeChange(a);switch(b){case "Title":a.title=c;break;case "Mode":b=Object.values(g.NODE_MODES).indexOf(c);0<=b&&g.NODE_MODES[b]?a.changeMode(b):console.warn("unexpected mode: "+c);break;case "Color":m.node_colors[c]?(a.color=m.node_colors[c].color,a.bgcolor=m.node_colors[c].bgcolor):console.warn("unexpected color: "+c);break;default:a.setProperty(b,c)}e.graph.afterChange();e.dirty_canvas=!0};d.addWidget("string","Title",a.title,{},b); -d.addWidget("combo","Mode",g.NODE_MODES[a.mode],{values:g.NODE_MODES},b);var c="";void 0!==a.color&&(c=Object.keys(m.node_colors).filter(function(b){return m.node_colors[b].color==a.color}));d.addWidget("combo","Color",c,{values:Object.keys(m.node_colors)},b);for(var k in a.properties){c=a.properties[k];var l=a.getPropertyInfo(k);a.onAddPropertyToPanel&&a.onAddPropertyToPanel(k,d)||d.addWidget(l.widget||l.type,k,c,l,b)}d.addSeparator();if(a.onShowCustomPanelInfo)a.onShowCustomPanelInfo(d);d.footer.innerHTML= +for(var c in b){var e=b[c];panel.addWidget("boolean",e,d[e],{key:e,on:"True",off:"False"},a)}panel.addWidget("combo","Render mode",g.LINK_RENDER_MODES[d.links_render_mode],{key:"links_render_mode",values:g.LINK_RENDER_MODES},a);panel.addSeparator();panel.footer.innerHTML=""})();d.canvas.parentNode.appendChild(panel)};l.prototype.showShowNodePanel=function(a){function b(){d.content.innerHTML="";d.addHTML(""+a.type+""+(a.constructor.desc||"")+""); +d.addHTML("

Properties

");var b=function(b,c){e.graph.beforeChange(a);switch(b){case "Title":a.title=c;break;case "Mode":b=Object.values(g.NODE_MODES).indexOf(c);0<=b&&g.NODE_MODES[b]?a.changeMode(b):console.warn("unexpected mode: "+c);break;case "Color":l.node_colors[c]?(a.color=l.node_colors[c].color,a.bgcolor=l.node_colors[c].bgcolor):console.warn("unexpected color: "+c);break;default:a.setProperty(b,c)}e.graph.afterChange();e.dirty_canvas=!0};d.addWidget("string","Title",a.title,{},b); +d.addWidget("combo","Mode",g.NODE_MODES[a.mode],{values:g.NODE_MODES},b);var c="";void 0!==a.color&&(c=Object.keys(l.node_colors).filter(function(b){return l.node_colors[b].color==a.color}));d.addWidget("combo","Color",c,{values:Object.keys(l.node_colors)},b);for(var k in a.properties){c=a.properties[k];var m=a.getPropertyInfo(k);a.onAddPropertyToPanel&&a.onAddPropertyToPanel(k,d)||d.addWidget(m.widget||m.type,k,c,m,b)}d.addSeparator();if(a.onShowCustomPanelInfo)a.onShowCustomPanelInfo(d);d.footer.innerHTML= "";d.addButton("Delete",function(){a.block_delete||(a.graph.remove(a),d.close())}).classList.add("delete")}this.SELECTED_NODE=a;this.closePanels();var c=this.getCanvasWindow(),e=this,d=this.createPanel(a.title||"",{closable:!0,window:c,onOpen:function(){e.NODEPANEL_IS_OPEN=!0},onClose:function(){e.NODEPANEL_IS_OPEN=!1;e.node_panel=null}});e.node_panel=d;d.id="node-panel";d.node=a;d.classList.add("settings");d.inner_showCodePad=function(c){d.classList.remove("settings");d.classList.add("centered"); d.alt_content.innerHTML="";var e=d.alt_content.querySelector("textarea"),f=function(){d.toggleAltContent(!1);d.toggleFooterVisibility(!0);e.parentNode.removeChild(e);d.classList.add("settings");d.classList.remove("centered");b()};e.value=a.properties[c];e.addEventListener("keydown",function(b){"Enter"==b.code&&b.ctrlKey&&(a.setProperty(c,e.value),f())});d.toggleAltContent(!0);d.toggleFooterVisibility(!1);e.style.height="calc(100% - 40px)";var g=d.addButton("Assign", -function(){a.setProperty(c,e.value);f()});d.alt_content.appendChild(g);g=d.addButton("Close",f);g.style.float="right";d.alt_content.appendChild(g)};b();this.canvas.parentNode.appendChild(d)};m.prototype.showSubgraphPropertiesDialog=function(a){function b(){e.clear();if(a.inputs)for(var c=0;c","subgraph_property"); +function(){a.setProperty(c,e.value);f()});d.alt_content.appendChild(g);g=d.addButton("Close",f);g.style.float="right";d.alt_content.appendChild(g)};b();this.canvas.parentNode.appendChild(d)};l.prototype.showSubgraphPropertiesDialog=function(a){function b(){e.clear();if(a.inputs)for(var c=0;c","subgraph_property"); g.dataset.name=f.name;g.dataset.slot=c;g.querySelector(".name").innerText=f.name;g.querySelector(".type").innerText=f.type;g.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 e=this.createPanel("Subgraph Inputs",{closable:!0,width:500});e.node=a;e.classList.add("subgraph_dialog");e.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(e);return e};m.prototype.showSubgraphPropertiesDialogRight=function(a){function b(){d.clear();if(a.outputs)for(var c=0;c","subgraph_property");g.dataset.name=e.name;g.dataset.slot=c;g.querySelector(".name").innerText=e.name;g.querySelector(".type").innerText=e.type;g.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 e=this.canvas.parentNode.querySelector(".subgraph_dialog");e&&e.close();var d=this.createPanel("Subgraph Outputs",{closable:!0,width:500});d.node=a;d.classList.add("subgraph_dialog");e=d.addHTML(" + NameType","subgraph_property extra",!0);e.querySelector(".name").addEventListener("keydown", -function(a){13==a.keyCode&&c.apply(this)});e.querySelector("button").addEventListener("click",function(a){c.apply(this)});b();this.canvas.parentNode.appendChild(d);return d};m.prototype.checkPanels=function(){if(this.canvas)for(var a=this.canvas.parentNode.querySelectorAll(".litegraph.dialog"),b=0;b=Object.keys(a.selected_nodes).length)d.collapse(); -else for(var f in a.selected_nodes)a.selected_nodes[f].collapse();d.graph.afterChange()};m.onMenuNodePin=function(a,b,c,e,d){d.pin()};m.onMenuNodeMode=function(a,b,c,e,d){new g.ContextMenu(g.NODE_MODES,{event:c,callback:function(a){if(d){var b=Object.values(g.NODE_MODES).indexOf(a),c=function(c){0<=b&&g.NODE_MODES[b]?c.changeMode(b):(console.warn("unexpected mode: "+a),c.changeMode(g.ALWAYS))},e=m.active_canvas;if(!e.selected_nodes||1>=Object.keys(e.selected_nodes).length)c(d);else for(var f in e.selected_nodes)c(e.selected_nodes[f])}}, -parentMenu:e,node:d});return!1};m.onMenuNodeColors=function(a,b,c,e,d){if(!d)throw"no node for color";b=[];b.push({value:null,content:"No color"});for(var f in m.node_colors)a=m.node_colors[f],a={value:f,content:""+f+""},b.push(a);new g.ContextMenu(b,{event:c,callback:function(a){if(d){var b=a.value?m.node_colors[a.value]: -null;a=function(a){b?a.constructor===g.LGraphGroup?a.color=b.groupcolor:(a.color=b.color,a.bgcolor=b.bgcolor):(delete a.color,delete a.bgcolor)};var c=m.active_canvas;if(!c.selected_nodes||1>=Object.keys(c.selected_nodes).length)a(d);else for(var e in c.selected_nodes)a(c.selected_nodes[e]);d.setDirtyCanvas(!0,!0)}},parentMenu:e,node:d});return!1};m.onMenuNodeShapes=function(a,b,c,e,d){if(!d)throw"no node passed";new g.ContextMenu(g.VALID_SHAPES,{event:c,callback:function(a){if(d){d.graph.beforeChange(); -var b=m.active_canvas;if(!b.selected_nodes||1>=Object.keys(b.selected_nodes).length)d.shape=a;else for(var c in b.selected_nodes)b.selected_nodes[c].shape=a;d.graph.afterChange();d.setDirtyCanvas(!0)}},parentMenu:e,node:d});return!1};m.onMenuNodeRemove=function(a,b,c,e,d){if(!d)throw"no node passed";a=d.graph;a.beforeChange();b=m.active_canvas;if(!b.selected_nodes||1>=Object.keys(b.selected_nodes).length)!1!==d.removable&&a.remove(d);else for(var f in b.selected_nodes)c=b.selected_nodes[f],!1!==c.removable&& -a.remove(c);a.afterChange();d.setDirtyCanvas(!0,!0)};m.onMenuNodeToSubgraph=function(a,b,c,e,d){a=d.graph;if(b=m.active_canvas)c=Object.values(b.selected_nodes||{}),c.length||(c=[d]),e=g.createNode("graph/subgraph"),e.pos=d.pos.concat(),a.add(e),e.buildFromNodes(c),b.deselectAllNodes(),d.setDirtyCanvas(!0,!0)};m.onMenuNodeClone=function(a,b,c,e,d){d.graph.beforeChange();var f={};a=function(a){if(!1!==a.clonable){var b=a.clone();b&&(b.pos=[a.pos[0]+5,a.pos[1]+5],a.graph.add(b),f[b.id]=b)}};b=m.active_canvas; -if(!b.selected_nodes||1>=Object.keys(b.selected_nodes).length)a(d);else for(var g in b.selected_nodes)a(b.selected_nodes[g]);Object.keys(f).length&&b.selectNodes(f);d.graph.afterChange();d.setDirtyCanvas(!0,!0)};m.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"}};m.prototype.getCanvasMenuOptions=function(){if(this.getMenuOptions)var a=this.getMenuOptions();else a=[{content:"Add Node",has_submenu:!0,callback:m.onMenuAdd},{content:"Add Group",callback:m.onGroupAdd}],1=Object.keys(a.selected_nodes).length)d.collapse(); +else for(var f in a.selected_nodes)a.selected_nodes[f].collapse();d.graph.afterChange()};l.onMenuNodePin=function(a,b,c,e,d){d.pin()};l.onMenuNodeMode=function(a,b,c,e,d){new g.ContextMenu(g.NODE_MODES,{event:c,callback:function(a){if(d){var b=Object.values(g.NODE_MODES).indexOf(a),c=function(c){0<=b&&g.NODE_MODES[b]?c.changeMode(b):(console.warn("unexpected mode: "+a),c.changeMode(g.ALWAYS))},e=l.active_canvas;if(!e.selected_nodes||1>=Object.keys(e.selected_nodes).length)c(d);else for(var f in e.selected_nodes)c(e.selected_nodes[f])}}, +parentMenu:e,node:d});return!1};l.onMenuNodeColors=function(a,b,c,e,d){if(!d)throw"no node for color";b=[];b.push({value:null,content:"No color"});for(var f in l.node_colors)a=l.node_colors[f],a={value:f,content:""+f+""},b.push(a);new g.ContextMenu(b,{event:c,callback:function(a){if(d){var b=a.value?l.node_colors[a.value]: +null;a=function(a){b?a.constructor===g.LGraphGroup?a.color=b.groupcolor:(a.color=b.color,a.bgcolor=b.bgcolor):(delete a.color,delete a.bgcolor)};var c=l.active_canvas;if(!c.selected_nodes||1>=Object.keys(c.selected_nodes).length)a(d);else for(var e in c.selected_nodes)a(c.selected_nodes[e]);d.setDirtyCanvas(!0,!0)}},parentMenu:e,node:d});return!1};l.onMenuNodeShapes=function(a,b,c,e,d){if(!d)throw"no node passed";new g.ContextMenu(g.VALID_SHAPES,{event:c,callback:function(a){if(d){d.graph.beforeChange(); +var b=l.active_canvas;if(!b.selected_nodes||1>=Object.keys(b.selected_nodes).length)d.shape=a;else for(var c in b.selected_nodes)b.selected_nodes[c].shape=a;d.graph.afterChange();d.setDirtyCanvas(!0)}},parentMenu:e,node:d});return!1};l.onMenuNodeRemove=function(a,b,c,e,d){if(!d)throw"no node passed";a=d.graph;a.beforeChange();b=l.active_canvas;if(!b.selected_nodes||1>=Object.keys(b.selected_nodes).length)!1!==d.removable&&a.remove(d);else for(var f in b.selected_nodes)c=b.selected_nodes[f],!1!==c.removable&& +a.remove(c);a.afterChange();d.setDirtyCanvas(!0,!0)};l.onMenuNodeToSubgraph=function(a,b,c,e,d){a=d.graph;if(b=l.active_canvas)c=Object.values(b.selected_nodes||{}),c.length||(c=[d]),e=g.createNode("graph/subgraph"),e.pos=d.pos.concat(),a.add(e),e.buildFromNodes(c),b.deselectAllNodes(),d.setDirtyCanvas(!0,!0)};l.onMenuNodeClone=function(a,b,c,e,d){d.graph.beforeChange();var f={};a=function(a){if(!1!==a.clonable){var b=a.clone();b&&(b.pos=[a.pos[0]+5,a.pos[1]+5],a.graph.add(b),f[b.id]=b)}};b=l.active_canvas; +if(!b.selected_nodes||1>=Object.keys(b.selected_nodes).length)a(d);else for(var g in b.selected_nodes)a(b.selected_nodes[g]);Object.keys(f).length&&b.selectNodes(f);d.graph.afterChange();d.setDirtyCanvas(!0,!0)};l.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"}};l.prototype.getCanvasMenuOptions=function(){if(this.getMenuOptions)var a=this.getMenuOptions();else a=[{content:"Add Node",has_submenu:!0,callback:l.onMenuAdd},{content:"Add Group",callback:l.onGroupAdd}],1Name", d),h=g.querySelector("input");h&&f&&(h.value=f.label||"");var k=function(){a.graph.beforeChange();h.value&&(f&&(f.label=h.value),c.setDirty(!0));g.close();a.graph.afterChange()};g.querySelector("button").addEventListener("click",k);h.addEventListener("keydown",function(a){g.is_modified=!0;if(27==a.keyCode)g.close();else if(13==a.keyCode)k();else if(13!=a.keyCode&&"textarea"!=a.target.localName)return;a.preventDefault();a.stopPropagation()});h.focus()}},extra:a};a&&(f.title=a.type);var h=null;a&&(h= -a.getSlotInPosition(b.canvasX,b.canvasY),m.active_node=a);h?(d=[],a.getSlotMenuOptions?d=a.getSlotMenuOptions(h):(h&&h.output&&h.output.links&&h.output.links.length&&d.push({content:"Disconnect Links",slot:h}),b=h.input||h.output,b.removable&&d.push(b.locked?"Cannot remove":{content:"Remove Slot",slot:h}),b.nameLocked||d.push({content:"Rename Slot",slot:h})),f.title=(h.input?h.input.type:h.output.type)||"*",h.input&&h.input.type==g.ACTION&&(f.title="Action"),h.output&&h.output.type==g.EVENT&&(f.title= -"Event")):a?d=this.getNodeMenuOptions(a):(d=this.getCanvasMenuOptions(),(h=this.graph.getGroupOnPos(b.canvasX,b.canvasY))&&d.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:h,options:this.getGroupMenuOptions(h)}}));d&&new g.ContextMenu(d,f,e)};g.compareObjects=function(a,b){for(var c in a)if(a[c]!=b[c])return!1;return!0};g.distance=I;g.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")+")"};g.isInsideRectangle=A;g.growBounding=function(a,b,c){ba[2]&&(a[2]=b);ca[3]&&(a[3]=c)};g.isInsideBounding=function(a,b){return a[0]b[1][0]||a[1]>b[1][1]?!1:!0};g.overlapBounding=G;g.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),c=0,e,d,f=0;6>f;f+=2)e="0123456789ABCDEF".indexOf(a.charAt(f)),d="0123456789ABCDEF".indexOf(a.charAt(f+1)),b[c]=16*e+d,c++;return b}; -g.num2hex=function(a){for(var b="#",c,e,d=0;3>d;d++)c=a[d]/16,e=a[d]%16,b+="0123456789ABCDEF".charAt(c)+"0123456789ABCDEF".charAt(e);return b};E.prototype.addItem=function(a,b,c){function e(a){var b=this.value;b&&b.has_submenu&&d.call(this,a)}function d(a){var b=this.value,d=!0;f.current_submenu&&f.current_submenu.close(a);if(c.callback){var e=c.callback.call(this,b,c,a,f,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,f,c.extra), +a.getSlotInPosition(b.canvasX,b.canvasY),l.active_node=a);h?(d=[],a.getSlotMenuOptions?d=a.getSlotMenuOptions(h):(h&&h.output&&h.output.links&&h.output.links.length&&d.push({content:"Disconnect Links",slot:h}),b=h.input||h.output,b.removable&&d.push(b.locked?"Cannot remove":{content:"Remove Slot",slot:h}),b.nameLocked||d.push({content:"Rename Slot",slot:h})),f.title=(h.input?h.input.type:h.output.type)||"*",h.input&&h.input.type==g.ACTION&&(f.title="Action"),h.output&&h.output.type==g.EVENT&&(f.title= +"Event")):a?d=this.getNodeMenuOptions(a):(d=this.getCanvasMenuOptions(),(h=this.graph.getGroupOnPos(b.canvasX,b.canvasY))&&d.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:h,options:this.getGroupMenuOptions(h)}}));d&&new g.ContextMenu(d,f,e)};g.compareObjects=function(a,b){for(var c in a)if(a[c]!=b[c])return!1;return!0};g.distance=J;g.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")+")"};g.isInsideRectangle=C;g.growBounding=function(a,b,c){ba[2]&&(a[2]=b);ca[3]&&(a[3]=c)};g.isInsideBounding=function(a,b){return a[0]b[1][0]||a[1]>b[1][1]?!1:!0};g.overlapBounding=H;g.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),c=0,e,d,f=0;6>f;f+=2)e="0123456789ABCDEF".indexOf(a.charAt(f)),d="0123456789ABCDEF".indexOf(a.charAt(f+1)),b[c]=16*e+d,c++;return b}; +g.num2hex=function(a){for(var b="#",c,e,d=0;3>d;d++)c=a[d]/16,e=a[d]%16,b+="0123456789ABCDEF".charAt(c)+"0123456789ABCDEF".charAt(e);return b};F.prototype.addItem=function(a,b,c){function e(a){var b=this.value;b&&b.has_submenu&&d.call(this,a)}function d(a){var b=this.value,d=!0;f.current_submenu&&f.current_submenu.close(a);if(c.callback){var e=c.callback.call(this,b,c,a,f,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,f,c.extra), !0===e&&(d=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";new f.constructor(b.submenu.options,{callback:b.submenu.callback,event:a,parentMenu:f,ignore_item_callbacks:b.submenu.ignore_item_callbacks,title:b.submenu.title,extra:b.submenu.extra,autoopen:c.autoopen});d=!1}d&&!f.lock&&f.close()}var f=this;c=c||{};var h=document.createElement("div");h.className="litemenu-entry submenu";var k=!1;if(null===b)h.classList.add("separator");else{h.innerHTML=b&&b.title?b.title: -a;if(h.value=b)b.disabled&&(k=!0,h.classList.add("disabled")),(b.submenu||b.has_submenu)&&h.classList.add("has_submenu");"function"==typeof b?(h.dataset.value=a,h.onclick_callback=b):h.dataset.value=b;b.className&&(h.className+=" "+b.className)}this.root.appendChild(h);k||h.addEventListener("click",d);!k&&c.autoopen&&g.pointerListenerAdd(h,"enter",e);return h};E.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&&!E.isCursorOverElement(a,this.parentMenu.root)&&E.trigger(this.parentMenu.root,g.pointerevents_method+"leave",a));this.current_submenu&&this.current_submenu.close(a,!0);this.root.closing_timer&&clearTimeout(this.root.closing_timer)};E.trigger=function(a,b,c,e){var d=document.createEvent("CustomEvent");d.initCustomEvent(b,!0,!0,c);d.srcElement=e;a.dispatchEvent?a.dispatchEvent(d):a.__events&&a.__events.dispatchEvent(d);return d}; -E.prototype.getTopMenu=function(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this};E.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event};E.isCursorOverElement=function(a,b){var c=a.clientX;a=a.clientY;return(b=b.getBoundingClientRect())?a>b.top&&ab.left&&cb.top&&ab.left&&cMath.abs(b))return e[1];a=(a-e[0])/b;return e[1]*(1-a)+d[1]*a}}return 0}};F.prototype.draw=function(a,b,c,e,d,f){if(c=this.points){this.size=b;var g=b[0]-2*this.margin;b=b[1]-2*this.margin;d=d||"#666";a.save();a.translate(this.margin,this.margin);e&&(a.fillStyle="#111",a.fillRect(0,0,g,b),a.fillStyle="#222",a.fillRect(.5*g,0,1,b),a.strokeStyle="#333", -a.strokeRect(0,0,g,b));a.strokeStyle=d;f&&(a.globalAlpha=.5);a.beginPath();for(e=0;ea[1])){var e=this.size[0]-2*this.margin,d=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/e,1-a/d],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}};F.prototype.onMouseMove=function(a,b){var c=this.points;if(c){var e=this.selected;if(!(0>e)){var d=(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[e]){var g=0==e||e==c.length-1;!g&&(-10>a[0]||a[0]>this.size[0]+10||-10>a[1]||a[1]>this.size[1]+10)?(c.splice(e,1),this.selected=-1):(b[0]=g?0==e?0:1:J(d,0,1),b[1]=1-J(f,0,1),c.sort(function(a,b){return a[0]-b[0]}),this.selected=c.indexOf(b),this.must_update=!0)}}}};F.prototype.onMouseUp=function(a,b){this.selected=-1;return!1};F.prototype.getCloserPoint=function(a,b){var c=this.points;if(!c)return-1;b=b||30;for(var e=this.size[0]-2*this.margin,d=this.size[1]-2*this.margin,f=c.length,g=[0,0], -k=1E6,l=-1,m=0;mk||q>b||(l=m,k=q)}return l};g.CurveEditor=F;g.getParameterNames=function(a){return(a+"").replace(/[/][/].*$/gm,"").replace(/\s+/g,"").replace(/[/][*][^/*]*[*][/]/g,"").split("){",1)[0].replace(/^[^(]*[(]/,"").replace(/=[^,]+/g,"").split(",").filter(Boolean)};g.pointerListenerAdd=function(a,b,c,e){e=void 0===e?!1:e;if(a&&a.addEventListener&&b&&"function"===typeof c){var d=g.pointerevents_method;if("pointer"==d&&!window.PointerEvent)switch(console.warn("sMethod=='pointer' && !window.PointerEvent"), +b.prototype.__lookupSetter__(c)))};G.sampleCurve=function(a,b){if(b){for(var c=0;cMath.abs(b))return e[1];a=(a-e[0])/b;return e[1]*(1-a)+d[1]*a}}return 0}};G.prototype.draw=function(a,b,c,e,d,f){if(c=this.points){this.size=b;var g=b[0]-2*this.margin;b=b[1]-2*this.margin;d=d||"#666";a.save();a.translate(this.margin,this.margin);e&&(a.fillStyle="#111",a.fillRect(0,0,g,b),a.fillStyle="#222",a.fillRect(.5*g,0,1,b),a.strokeStyle="#333", +a.strokeRect(0,0,g,b));a.strokeStyle=d;f&&(a.globalAlpha=.5);a.beginPath();for(e=0;ea[1])){var e=this.size[0]-2*this.margin,d=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/e,1-a/d],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}};G.prototype.onMouseMove=function(a,b){var c=this.points;if(c){var e=this.selected;if(!(0>e)){var d=(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[e]){var g=0==e||e==c.length-1;!g&&(-10>a[0]||a[0]>this.size[0]+10||-10>a[1]||a[1]>this.size[1]+10)?(c.splice(e,1),this.selected=-1):(b[0]=g?0==e?0:1:K(d,0,1),b[1]=1-K(f,0,1),c.sort(function(a,b){return a[0]-b[0]}),this.selected=c.indexOf(b),this.must_update=!0)}}}};G.prototype.onMouseUp=function(a,b){this.selected=-1;return!1};G.prototype.getCloserPoint=function(a,b){var c=this.points;if(!c)return-1;b=b||30;for(var e=this.size[0]-2*this.margin,d=this.size[1]-2*this.margin,f=c.length,g=[0,0], +k=1E6,l=-1,m=0;mk||p>b||(l=m,k=p)}return l};g.CurveEditor=G;g.getParameterNames=function(a){return(a+"").replace(/[/][/].*$/gm,"").replace(/\s+/g,"").replace(/[/][*][^/*]*[*][/]/g,"").split("){",1)[0].replace(/^[^(]*[(]/,"").replace(/=[^,]+/g,"").split(",").filter(Boolean)};g.pointerListenerAdd=function(a,b,c,e){e=void 0===e?!1:e;if(a&&a.addEventListener&&b&&"function"===typeof c){var d=g.pointerevents_method;if("pointer"==d&&!window.PointerEvent)switch(console.warn("sMethod=='pointer' && !window.PointerEvent"), console.log("Converting pointer["+b+"] : down move up cancel enter TO touchstart touchmove touchend, etc .."),b){case "down":d="touch";b="start";break;case "move":d="touch";break;case "up":d="touch";b="end";break;case "cancel":d="touch";break;case "enter":console.log("debug: Should I send a move event?");break;default:console.warn("PointerEvent not available in this browser ? The event "+b+" would not be called")}switch(b){case "down":case "up":case "move":case "over":case "out":case "enter":a.addEventListener(d+ b,c,e);case "leave":case "cancel":case "gotpointercapture":case "lostpointercapture":if("mouse"!=d)return a.addEventListener(d+b,c,e);default:return a.addEventListener(b,c,e)}}};g.pointerListenerRemove=function(a,b,c,e){e=void 0===e?!1:e;if(a&&a.removeEventListener&&b&&"function"===typeof c)switch(b){case "down":case "up":case "move":case "over":case "out":case "enter":"pointer"!=g.pointerevents_method&&"mouse"!=g.pointerevents_method||a.removeEventListener(g.pointerevents_method+b,c,e);case "leave":case "cancel":case "gotpointercapture":case "lostpointercapture":if("pointer"== -g.pointerevents_method)return a.removeEventListener(g.pointerevents_method+b,c,e);default:return a.removeEventListener(b,c,e)}};l.clamp=J;"undefined"==typeof window||window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)})})(this); +g.pointerevents_method)return a.removeEventListener(g.pointerevents_method+b,c,e);default:return a.removeEventListener(b,c,e)}};t.clamp=K;"undefined"==typeof window||window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)})})(this); "undefined"!=typeof exports&&(exports.LiteGraph=this.LiteGraph,exports.LGraph=this.LGraph,exports.LLink=this.LLink,exports.LGraphNode=this.LGraphNode,exports.LGraphGroup=this.LGraphGroup,exports.DragAndScale=this.DragAndScale,exports.LGraphCanvas=this.LGraphCanvas,exports.ContextMenu=this.ContextMenu); diff --git a/build/litegraph.js b/build/litegraph.js index 17f3fce10..e45fee519 100644 --- a/build/litegraph.js +++ b/build/litegraph.js @@ -2532,7 +2532,7 @@ var w = this.widgets[i]; if(!w) continue; - if(w.options && w.options.property && this.properties[ w.options.property ]) + if(w.options && w.options.property && (this.properties[ w.options.property ] != undefined)) w.value = JSON.parse( JSON.stringify( this.properties[ w.options.property ] ) ); } if (info.widgets_values) { @@ -3775,16 +3775,42 @@ /** * returns the bounding of the object, used for rendering purposes - * bounding is: [topleft_cornerx, topleft_cornery, width, height] * @method getBounding - * @return {Float32Array[4]} the total size + * @param out {Float32Array[4]?} [optional] a place to store the output, to free garbage + * @param compute_outer {boolean?} [optional] set to true to include the shadow and connection points in the bounding calculation + * @return {Float32Array[4]} the bounding box in format of [topleft_cornerx, topleft_cornery, width, height] */ - LGraphNode.prototype.getBounding = function(out) { + LGraphNode.prototype.getBounding = function(out, compute_outer) { out = out || new Float32Array(4); - out[0] = this.pos[0] - 4; - out[1] = this.pos[1] - LiteGraph.NODE_TITLE_HEIGHT; - out[2] = this.size[0] + 4; - out[3] = this.flags.collapsed ? LiteGraph.NODE_TITLE_HEIGHT : this.size[1] + LiteGraph.NODE_TITLE_HEIGHT; + const nodePos = this.pos; + const isCollapsed = this.flags.collapsed; + const nodeSize = this.size; + + let left_offset = 0; + // 1 offset due to how nodes are rendered + let right_offset = 1 ; + let top_offset = 0; + let bottom_offset = 0; + + if (compute_outer) { + // 4 offset for collapsed node connection points + left_offset = 4; + // 6 offset for right shadow and collapsed node connection points + right_offset = 6 + left_offset; + // 4 offset for collapsed nodes top connection points + top_offset = 4; + // 5 offset for bottom shadow and collapsed node connection points + bottom_offset = 5 + top_offset; + } + + out[0] = nodePos[0] - left_offset; + out[1] = nodePos[1] - LiteGraph.NODE_TITLE_HEIGHT - top_offset; + out[2] = isCollapsed ? + (this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH) + right_offset : + nodeSize[0] + right_offset; + out[3] = isCollapsed ? + LiteGraph.NODE_TITLE_HEIGHT + bottom_offset : + nodeSize[1] + LiteGraph.NODE_TITLE_HEIGHT + bottom_offset; if (this.onBounding) { this.onBounding(out); @@ -7673,7 +7699,7 @@ LGraphNode.prototype.executeAction = function(action) continue; } - if (!overlapBounding(this.visible_area, n.getBounding(temp))) { + if (!overlapBounding(this.visible_area, n.getBounding(temp, true))) { continue; } //out of the visible area @@ -9975,6 +10001,7 @@ LGraphNode.prototype.executeAction = function(action) var x = pos[0] - node.pos[0]; var y = pos[1] - node.pos[1]; var width = node.size[0]; + var deltaX = event.deltaX || event.deltax || 0; var that = this; var ref_window = this.getCanvasWindow(); @@ -10021,8 +10048,8 @@ LGraphNode.prototype.executeAction = function(action) case "combo": var old_value = w.value; if (event.type == LiteGraph.pointerevents_method+"move" && w.type == "number") { - if(event.deltaX) - w.value += event.deltaX * 0.1 * (w.options.step || 1); + if(deltaX) + w.value += deltaX * 0.1 * (w.options.step || 1); if ( w.options.min != null && w.value < w.options.min ) { w.value = w.options.min; } @@ -11499,7 +11526,8 @@ LGraphNode.prototype.executeAction = function(action) var input = dialog.querySelector("input"); if (input) { input.addEventListener("blur", function(e) { - this.focus(); + if(that.search_box) + this.focus(); }); input.addEventListener("keydown", function(e) { if (e.keyCode == 38) { @@ -14826,7 +14854,8 @@ if (typeof exports != "undefined") { GraphInput.title = "Input"; GraphInput.desc = "Input of the graph"; - GraphInput.prototype.onConfigure = function() + GraphInput.prototype.onConfigure = function() + { this.updateType(); } @@ -15280,6 +15309,48 @@ if (typeof exports != "undefined") { LiteGraph.registerNodeType("basic/file", ConstantFile); + +//to store json objects +function JSONParse() { + this.addInput("parse", LiteGraph.ACTION); + this.addInput("json", "string"); + this.addOutput("done", LiteGraph.EVENT); + this.addOutput("object", "object"); + this.widget = this.addWidget("button","parse","",this.parse.bind(this)); + this._str = null; + this._obj = null; +} + +JSONParse.title = "JSON Parse"; +JSONParse.desc = "Parses JSON String into object"; + +JSONParse.prototype.parse = function() +{ + if(!this._str) + return; + + try { + this._str = this.getInputData(1); + this._obj = JSON.parse(this._str); + this.boxcolor = "#AEA"; + this.triggerSlot(0); + } catch (err) { + this.boxcolor = "red"; + } +} + +JSONParse.prototype.onExecute = function() { + this._str = this.getInputData(1); + this.setOutputData(1, this._obj); +}; + +JSONParse.prototype.onAction = function(name) { + if(name == "parse") + this.parse(); +} + +LiteGraph.registerNodeType("basic/jsonparse", JSONParse); + //to store json objects function ConstantData() { this.addOutput("data", "object"); @@ -34276,5 +34347,68 @@ LiteGraph.registerNodeType("audio/waveShaper", LGAudioWaveShaper); }; LiteGraph.registerNodeType("network/sillyclient", LGSillyClient); + +//HTTP Request +function HTTPRequestNode() { + var that = this; + this.addInput("request", LiteGraph.ACTION); + this.addInput("url", "string"); + this.addProperty("url", ""); + this.addOutput("ready", LiteGraph.EVENT); + this.addOutput("data", "string"); + this.addWidget("button", "Fetch", null, this.fetch.bind(this)); + this._data = null; + this._fetching = null; +} + +HTTPRequestNode.title = "HTTP Request"; +HTTPRequestNode.desc = "Fetch data through HTTP"; + +HTTPRequestNode.prototype.fetch = function() +{ + var url = this.properties.url; + if(!url) + return; + + this.boxcolor = "#FF0"; + var that = this; + this._fetching = fetch(url) + .then(resp=>{ + if(!resp.ok) + { + this.boxcolor = "#F00"; + that.trigger("error"); + } + else + { + this.boxcolor = "#0F0"; + return resp.text(); + } + }) + .then(data=>{ + that._data = data; + that._fetching = null; + that.trigger("ready"); + }); +} + +HTTPRequestNode.prototype.onAction = function(evt) +{ + if(evt == "request") + this.fetch(); +} + +HTTPRequestNode.prototype.onExecute = function() { + this.setOutputData(1, this._data); +}; + +HTTPRequestNode.prototype.onGetOutputs = function() { + return [["error",LiteGraph.EVENT]]; +} + +LiteGraph.registerNodeType("network/httprequest", HTTPRequestNode); + + + })(this); diff --git a/build/litegraph.min.js b/build/litegraph.min.js index 210473881..3cdfbb345 100644 --- a/build/litegraph.min.js +++ b/build/litegraph.min.js @@ -1,56 +1,56 @@ -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(B,c,k){B!=Array.prototype&&B!=Object.prototype&&(B[c]=k.value)};$jscomp.getGlobal=function(B){return"undefined"!=typeof window&&window===B?B:"undefined"!=typeof global&&null!=global?global:B};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_"; -$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var B=0;return function(c){return $jscomp.SYMBOL_PREFIX+(c||"")+B++}}(); -$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var B=$jscomp.global.Symbol.iterator;B||(B=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[B]&&$jscomp.defineProperty(Array.prototype,B,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(B){var c=0;return $jscomp.iteratorPrototype(function(){return ck&&(k=Math.max(0,r+k));if(null==q||q>r)q=r;q=Number(q);0>q&&(q=Math.max(0,r+q));for(k=Number(k||0);k=w}},"es6","es3");$jscomp.findInternal=function(B,c,k){B instanceof String&&(B=String(B));for(var q=B.length,r=0;rc?-k:k}},"es6","es3"); -(function(B){function c(a){e.debug&&console.log("Graph created");this.list_of_graphcanvas=null;this.clear();a&&this.configure(a)}function k(a,b,d,f,g,e){this.id=a;this.type=b;this.origin_id=d;this.origin_slot=f;this.target_id=g;this.target_slot=e;this._data=null;this._pos=new Float32Array(2)}function q(a){this._ctor(a)}function r(a){this._ctor(a)}function w(a,b){this.offset=new Float32Array([0,0]);this.scale=1;this.max_scale=10;this.min_scale=.1;this.onredraw=null;this.enabled=!0;this.last_mouse= -[0,0];this.element=null;this.visible_area=new Float32Array(4);a&&(this.element=a,b||this.bindEvents(a))}function h(a,b,d){this.options=d=d||{};this.background_image=h.DEFAULT_BACKGROUND_IMAGE;a&&a.constructor===String&&(a=document.querySelector(a));this.ds=new w;this.zoom_modify_alpha=!0;this.title_text_font=""+e.NODE_TEXT_SIZE+"px Arial";this.inner_text_font="normal "+e.NODE_SUBTEXT_SIZE+"px Arial";this.node_title_color=e.NODE_TITLE_COLOR;this.default_link_color=e.LINK_COLOR;this.default_connection_color= +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(y,c,k){y!=Array.prototype&&y!=Object.prototype&&(y[c]=k.value)};$jscomp.getGlobal=function(y){return"undefined"!=typeof window&&window===y?y:"undefined"!=typeof global&&null!=global?global:y};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_"; +$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var y=0;return function(c){return $jscomp.SYMBOL_PREFIX+(c||"")+y++}}(); +$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var y=$jscomp.global.Symbol.iterator;y||(y=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[y]&&$jscomp.defineProperty(Array.prototype,y,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(y){var c=0;return $jscomp.iteratorPrototype(function(){return ck&&(k=Math.max(0,r+k));if(null==n||n>r)n=r;n=Number(n);0>n&&(n=Math.max(0,r+n));for(k=Number(k||0);k=u}},"es6","es3");$jscomp.findInternal=function(y,c,k){y instanceof String&&(y=String(y));for(var n=y.length,r=0;rc?-k:k}},"es6","es3"); +(function(y){function c(a){e.debug&&console.log("Graph created");this.list_of_graphcanvas=null;this.clear();a&&this.configure(a)}function k(a,b,d,f,g,e){this.id=a;this.type=b;this.origin_id=d;this.origin_slot=f;this.target_id=g;this.target_slot=e;this._data=null;this._pos=new Float32Array(2)}function n(a){this._ctor(a)}function r(a){this._ctor(a)}function u(a,b){this.offset=new Float32Array([0,0]);this.scale=1;this.max_scale=10;this.min_scale=.1;this.onredraw=null;this.enabled=!0;this.last_mouse= +[0,0];this.element=null;this.visible_area=new Float32Array(4);a&&(this.element=a,b||this.bindEvents(a))}function h(a,b,d){this.options=d=d||{};this.background_image=h.DEFAULT_BACKGROUND_IMAGE;a&&a.constructor===String&&(a=document.querySelector(a));this.ds=new u;this.zoom_modify_alpha=!0;this.title_text_font=""+e.NODE_TEXT_SIZE+"px Arial";this.inner_text_font="normal "+e.NODE_SUBTEXT_SIZE+"px Arial";this.node_title_color=e.NODE_TITLE_COLOR;this.default_link_color=e.LINK_COLOR;this.default_connection_color= {input_off:"#778",input_on:"#7F7",output_off:"#778",output_on:"#7F7"};this.default_connection_color_byType={};this.default_connection_color_byTypeOff={};this.highquality_render=!0;this.use_gradients=!1;this.editor_alpha=1;this.pause_rendering=!1;this.clear_background=!0;this.clear_background_color="#222";this.read_only=!1;this.render_only_selected=!0;this.live_mode=!1;this.allow_interaction=this.allow_dragnodes=this.allow_dragcanvas=this.show_info=!0;this.multi_select=!1;this.allow_reconnect_links= this.allow_searchbox=!0;this.drag_mode=this.align_to_grid=!1;this.filter=this.dragging_rectangle=null;this.set_canvas_dirty_on_mouse_event=!0;this.always_render_background=!1;this.render_canvas_border=this.render_shadows=!0;this.render_connections_shadows=!1;this.render_connections_border=!0;this.render_connection_arrows=this.render_curved_connections=!1;this.render_collapsed_slots=!0;this.render_execution_order=!1;this.render_link_tooltip=this.render_title_colored=!0;this.links_render_mode=e.SPLINE_LINK; this.mouse=[0,0];this.canvas_mouse=this.graph_mouse=[0,0];this.onAfterChange=this.onBeforeChange=this.onConnectingChange=this.onSelectionChange=this.onNodeMoved=this.onDrawLinkTooltip=this.onDrawOverlay=this.onDrawForeground=this.onDrawBackground=this.onMouse=this.onSearchBoxSelection=this.onSearchBox=null;this.connections_width=3;this.round_radius=8;this.over_link_center=this.node_widget=this.current_node=null;this.last_mouse_position=[0,0];this.visible_area=this.ds.visible_area;this.visible_links= -[];this.viewport=d.viewport||null;b&&b.attachCanvas(this);this.setCanvas(a,d.skip_events);this.clear();d.skip_render||this.startRendering();this.autoresize=d.autoresize}function I(a,b){return Math.sqrt((b[0]-a[0])*(b[0]-a[0])+(b[1]-a[1])*(b[1]-a[1]))}function E(a,b,d,f,g,e){return da&&fb?!0:!1}function H(a,b){var d=a[0]+a[2],f=a[1]+a[3],g=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>g||da&&fb?!0:!1}function J(a,b){var d=a[0]+a[2],f=a[1]+a[3],g=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>g||dt.width-c.width-10&&(g=t.width-c.width-10),t.height&&a>t.height-c.height-10&&(a=t.height-c.height-10));n.style.left=g+"px";n.style.top=a+"px";b.scale&&(n.style.transform="scale("+b.scale+")")}function J(a){this.points=a;this.nearest=this.selected=-1;this.size=null;this.must_update=!0;this.margin=5}function G(a,b,d){return b>a?b:dz.width-c.width-10&&(g=z.width-c.width-10),z.height&&a>z.height-c.height-10&&(a=z.height-c.height-10));q.style.left=g+"px";q.style.top=a+"px";b.scale&&(q.style.transform="scale("+b.scale+")")}function H(a){this.points=a;this.nearest=this.selected=-1;this.size=null;this.must_update=!0;this.margin=5}function F(a,b,d){return b>a?b:d>a/4).toString(16)})},isValidConnection:function(a, +d?this.slot_types_out.includes(g.toLowerCase())||(this.slot_types_out.push(g.toLowerCase()),this.slot_types_out.sort()):this.slot_types_in.includes(g.toLowerCase())||(this.slot_types_in.push(g.toLowerCase()),this.slot_types_in.sort())}},wrapFunctionAsNode:function(a,b,d,f,g){for(var q=Array(b.length),z="",c=e.getParameterNames(b),l=0;l>a/4).toString(16)})},isValidConnection:function(a, b){if(""==a||"*"===a)a=0;if(""==b||"*"===b)b=0;if(!a||!b||a==b||a==e.EVENT&&b==e.ACTION)return!0;a=String(a);b=String(b);a=a.toLowerCase();b=b.toLowerCase();if(-1==a.indexOf(",")&&-1==b.indexOf(","))return a==b;a=a.split(",");b=b.split(",");for(var d=0;dt&&(t=u.size[C]);c+=u.size[b==e.VERTICAL_LAYOUT?0:1]+a+e.NODE_TITLE_HEIGHT}d+=t+a}this.setDirtyCanvas(!0,!0)};c.prototype.getTime=function(){return this.globaltime};c.prototype.getFixedTime=function(){return this.fixedtime};c.prototype.getElapsedTime=function(){return this.elapsed_time};c.prototype.sendEventToAllNodes=function(a, -b,d){d=d||e.ALWAYS;var f=this._nodes_in_order?this._nodes_in_order:this._nodes;if(f)for(var g=0,n=f.length;gz&&(z=t.size[v]);c+=t.size[b==e.VERTICAL_LAYOUT?0:1]+a+e.NODE_TITLE_HEIGHT}d+=z+a}this.setDirtyCanvas(!0,!0)};c.prototype.getTime=function(){return this.globaltime};c.prototype.getFixedTime=function(){return this.fixedtime};c.prototype.getElapsedTime=function(){return this.elapsed_time};c.prototype.sendEventToAllNodes=function(a, +b,d){d=d||e.ALWAYS;var f=this._nodes_in_order?this._nodes_in_order:this._nodes;if(f)for(var g=0,q=f.length;g=e.MAX_NUMBER_OF_NODES)throw"LiteGraph: max number of nodes in a graph reached";if(e.use_uuids){if(null==a.id||-1==a.id)a.id=e.uuidv4()}else 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=e.use_uuids?e.uuidv4():-1;this.type=null;this.inputs=[];this.outputs=[];this.connections=[];this.properties={};this.properties_info=[];this.flags={}};q.prototype.configure=function(a){this.graph&& +y.LGraphNode=e.LGraphNode=n;n.prototype._ctor=function(a){this.title=a||"Unnamed";this.size=[e.NODE_WIDTH,60];this.graph=null;this._pos=new Float32Array(10,10);Object.defineProperty(this,"pos",{set:function(a){!a||2>a.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos},enumerable:!0});this.id=e.use_uuids?e.uuidv4():-1;this.type=null;this.inputs=[];this.outputs=[];this.connections=[];this.properties={};this.properties_info=[];this.flags={}};n.prototype.configure=function(a){this.graph&& this.graph._version++;for(var b in a)if("properties"==b)for(var d in a.properties){if(this.properties[d]=a.properties[d],this.onPropertyChanged)this.onPropertyChanged(d,a.properties[d])}else null!=a[b]&&("object"==typeof a[b]?this[b]&&this[b].configure?this[b].configure(a[b]):this[b]=e.cloneObject(a[b],this[b]):this[b]=a[b]);a.title||(this.title=this.constructor.title);if(this.inputs)for(d=0;d=this.outputs.length)){var d=this.outputs[a];if(d&&(d._data=b,this.outputs[a].links))for(d=0;d=this.outputs.length)){var d=this.outputs[a];if(d&&(d.type=b,this.outputs[a].links))for(d=0;d=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}};q.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};q.prototype.getInputDataByName=function(a,b){a=this.findInputSlot(a);return-1==a?null:this.getInputData(a,b)};q.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};q.prototype.getInputOrProperty=function(a){if(!this.inputs||!this.inputs.length)return this.properties?this.properties[a]:null;for(var b=0,d=this.inputs.length;b=this.outputs.length?null:this.outputs[a]._data};q.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=[],d=0;da&&this.pos[1]-g-db)return!0;return!1};q.prototype.getSlotInPosition=function(a,b){var d=new Float32Array(2);if(this.inputs)for(var f=0,g=this.inputs.length;f=this.outputs.length)return e.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(d.constructor===String){if(d=b.findInputSlot(d),-1==d)return e.debug&&console.log("Connect: Error, no slot of name "+d),null}else if(d===e.EVENT)if(e.do_add_triggers_slots)b.changeMode(e.ON_TRIGGER),d=b.findInputSlot("onTrigger");else return null;else if(!b.inputs||d>=b.inputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),null;var f=b.inputs[d],g=this.outputs[a];if(!this.outputs[a])return null;b.onBeforeConnectInput&&(d=b.onBeforeConnectInput(d)); -if(!1===d||null===d||!e.isValidConnection(g.type,f.type))return this.setDirtyCanvas(!1,!0),null;if(b.onConnectInput&&!1===b.onConnectInput(d,g.type,g,this,a)||this.onConnectOutput&&!1===this.onConnectOutput(a,f.type,f,b,d))return null;b.inputs[d]&&null!=b.inputs[d].link&&(this.graph.beforeChange(),b.disconnectInput(d,{doProcessChange:!1}));if(null!==g.links&&g.links.length)switch(g.type){case e.EVENT:e.allow_multi_output_for_events||(this.graph.beforeChange(),this.disconnectOutput(a,!1,{doProcessChange:!1}))}var n= -e.use_uuids?e.uuidv4():++this.graph.last_link_id;n=new k(n,f.type||g.type,this.id,a,b.id,d);this.graph.links[n.id]=n;null==g.links&&(g.links=[]);g.links.push(n.id);b.inputs[d].link=n.id;this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(e.OUTPUT,a,!0,n,g);if(b.onConnectionsChange)b.onConnectionsChange(e.INPUT,d,!0,n,f);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(e.INPUT,b,d,this,a),this.graph.onNodeConnectionChange(e.OUTPUT, -this,a,b,d));this.setDirtyCanvas(!1,!0);this.graph.afterChange();this.graph.connectionChange(this,n);return n};q.prototype.disconnectOutput=function(a,b){if(a.constructor===String){if(a=this.findOutputSlot(a),-1==a)return e.debug&&console.log("Connect: Error, no slot of name "+a),!1}else if(!this.outputs||a>=this.outputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),!1;var d=this.outputs[a];if(!d||!d.links||0==d.links.length)return!1;if(b){b.constructor===Number&&(b= -this.graph.getNodeById(b));if(!b)throw"Target Node not found";for(var f=0,g=d.links.length;f=this.inputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),!1;var b=this.inputs[a];if(!b)return!1;var d=this.inputs[a].link;if(null!=d){this.inputs[a].link=null;var f=this.graph.links[d];if(f){var g=this.graph.getNodeById(f.origin_id);if(!g)return!1;var n=g.outputs[f.origin_slot];if(!n||!n.links||0==n.links.length)return!1;for(var c=0,z=n.links.length;c=this.outputs.length)){var d=this.outputs[a];if(d&&(d._data=b,this.outputs[a].links))for(d=0;d=this.outputs.length)){var d=this.outputs[a];if(d&&(d.type=b,this.outputs[a].links))for(d=0;d=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}};n.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};n.prototype.getInputDataByName=function(a,b){a=this.findInputSlot(a);return-1==a?null:this.getInputData(a,b)};n.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};n.prototype.getInputOrProperty=function(a){if(!this.inputs||!this.inputs.length)return this.properties?this.properties[a]:null;for(var b=0,d=this.inputs.length;b=this.outputs.length?null:this.outputs[a]._data};n.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=[],d=0;da&&this.pos[1]-g-db)return!0;return!1};n.prototype.getSlotInPosition=function(a,b){var d=new Float32Array(2);if(this.inputs)for(var f=0,g=this.inputs.length;f=this.outputs.length)return e.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(d.constructor===String){if(d=b.findInputSlot(d),-1==d)return e.debug&&console.log("Connect: Error, no slot of name "+d),null}else if(d===e.EVENT)if(e.do_add_triggers_slots)b.changeMode(e.ON_TRIGGER),d=b.findInputSlot("onTrigger");else return null;else if(!b.inputs||d>=b.inputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),null;var f=b.inputs[d],g=this.outputs[a];if(!this.outputs[a])return null; +b.onBeforeConnectInput&&(d=b.onBeforeConnectInput(d));if(!1===d||null===d||!e.isValidConnection(g.type,f.type))return this.setDirtyCanvas(!1,!0),null;if(b.onConnectInput&&!1===b.onConnectInput(d,g.type,g,this,a)||this.onConnectOutput&&!1===this.onConnectOutput(a,f.type,f,b,d))return null;b.inputs[d]&&null!=b.inputs[d].link&&(this.graph.beforeChange(),b.disconnectInput(d,{doProcessChange:!1}));if(null!==g.links&&g.links.length)switch(g.type){case e.EVENT:e.allow_multi_output_for_events||(this.graph.beforeChange(), +this.disconnectOutput(a,!1,{doProcessChange:!1}))}var q=e.use_uuids?e.uuidv4():++this.graph.last_link_id;q=new k(q,f.type||g.type,this.id,a,b.id,d);this.graph.links[q.id]=q;null==g.links&&(g.links=[]);g.links.push(q.id);b.inputs[d].link=q.id;this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(e.OUTPUT,a,!0,q,g);if(b.onConnectionsChange)b.onConnectionsChange(e.INPUT,d,!0,q,f);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(e.INPUT, +b,d,this,a),this.graph.onNodeConnectionChange(e.OUTPUT,this,a,b,d));this.setDirtyCanvas(!1,!0);this.graph.afterChange();this.graph.connectionChange(this,q);return q};n.prototype.disconnectOutput=function(a,b){if(a.constructor===String){if(a=this.findOutputSlot(a),-1==a)return e.debug&&console.log("Connect: Error, no slot of name "+a),!1}else if(!this.outputs||a>=this.outputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),!1;var d=this.outputs[a];if(!d||!d.links||0==d.links.length)return!1; +if(b){b.constructor===Number&&(b=this.graph.getNodeById(b));if(!b)throw"Target Node not found";for(var f=0,g=d.links.length;f=this.inputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),!1;var b=this.inputs[a];if(!b)return!1;var d=this.inputs[a].link;if(null!=d){this.inputs[a].link=null;var f=this.graph.links[d];if(f){var g=this.graph.getNodeById(f.origin_id);if(!g)return!1;var q=g.outputs[f.origin_slot];if(!q||!q.links||0==q.links.length)return!1;for(var c=0,l=q.links.length;cb&&this.inputs[b].pos)return d[0]=this.pos[0]+this.inputs[b].pos[0],d[1]=this.pos[1]+ -this.inputs[b].pos[1],d;if(!a&&f>b&&this.outputs[b].pos)return d[0]=this.pos[0]+this.outputs[b].pos[0],d[1]=this.pos[1]+this.outputs[b].pos[1],d;if(this.horizontal)return d[0]=this.pos[0]+this.size[0]/f*(b+.5),d[1]=a?this.pos[1]-e.NODE_TITLE_HEIGHT:this.pos[1]+this.size[1],d;d[0]=a?this.pos[0]+g:this.pos[0]+this.size[0]+1-g;d[1]=this.pos[1]+(b+.7)*e.NODE_SLOT_HEIGHT+(this.constructor.slot_start_y||0);return d};q.prototype.alignToGrid=function(){this.pos[0]=e.CANVAS_GRID_SIZE*Math.round(this.pos[0]/ -e.CANVAS_GRID_SIZE);this.pos[1]=e.CANVAS_GRID_SIZE*Math.round(this.pos[1]/e.CANVAS_GRID_SIZE)};q.prototype.trace=function(a){this.console||(this.console=[]);this.console.push(a);this.console.length>q.MAX_CONSOLE&&this.console.shift();if(this.graph.onNodeTrace)this.graph.onNodeTrace(this,a)};q.prototype.setDirtyCanvas=function(a,b){this.graph&&this.graph.sendActionToCanvas("setDirty",[a,b])};q.prototype.loadImage=function(a){var b=new Image;b.src=e.node_images_path+a;b.ready=!1;var d=this;b.onload= -function(){this.ready=!0;d.setDirtyCanvas(!0)};return b};q.prototype.captureInput=function(a){if(this.graph&&this.graph.list_of_graphcanvas)for(var b=this.graph.list_of_graphcanvas,d=0;db&&this.outputs[b].pos)return d[0]=this.pos[0]+this.outputs[b].pos[0],d[1]=this.pos[1]+this.outputs[b].pos[1],d;if(this.horizontal)return d[0]=this.pos[0]+this.size[0]/f*(b+.5),d[1]=a?this.pos[1]-e.NODE_TITLE_HEIGHT:this.pos[1]+this.size[1],d;d[0]=a?this.pos[0]+g:this.pos[0]+this.size[0]+1-g;d[1]=this.pos[1]+(b+.7)*e.NODE_SLOT_HEIGHT+(this.constructor.slot_start_y||0);return d};n.prototype.alignToGrid=function(){this.pos[0]=e.CANVAS_GRID_SIZE*Math.round(this.pos[0]/ +e.CANVAS_GRID_SIZE);this.pos[1]=e.CANVAS_GRID_SIZE*Math.round(this.pos[1]/e.CANVAS_GRID_SIZE)};n.prototype.trace=function(a){this.console||(this.console=[]);this.console.push(a);this.console.length>n.MAX_CONSOLE&&this.console.shift();if(this.graph.onNodeTrace)this.graph.onNodeTrace(this,a)};n.prototype.setDirtyCanvas=function(a,b){this.graph&&this.graph.sendActionToCanvas("setDirty",[a,b])};n.prototype.loadImage=function(a){var b=new Image;b.src=e.node_images_path+a;b.ready=!1;var d=this;b.onload= +function(){this.ready=!0;d.setDirtyCanvas(!0)};return b};n.prototype.captureInput=function(a){if(this.graph&&this.graph.list_of_graphcanvas)for(var b=this.graph.list_of_graphcanvas,d=0;da.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_size=a.font_size};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_size:this.font_size}};r.prototype.move=function(a,b,d){this._pos[0]+=a;this._pos[1]+=b;if(!d)for(d=0;d=this.viewport[0]&&f=this.viewport[1]&&dthis.max_scale&&(a=this.max_scale);if(a!=this.scale&&this.element){var d=this.element.getBoundingClientRect();if(d&&(b= -b||[.5*d.width,.5*d.height],d=this.convertCanvasToOffset(b),this.scale=a,.01>Math.abs(this.scale-1)&&(this.scale=1),a=this.convertCanvasToOffset(b),a=[a[0]-d[0],a[1]-d[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};B.LGraphCanvas=e.LGraphCanvas=h;h.DEFAULT_BACKGROUND_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII="; +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_size:this.font_size}};r.prototype.move=function(a,b,d){this._pos[0]+=a;this._pos[1]+=b;if(!d)for(d=0;d=this.viewport[0]&&f=this.viewport[1]&&dthis.max_scale&&(a=this.max_scale);if(a!=this.scale&&this.element){var d=this.element.getBoundingClientRect();if(d&&(b= +b||[.5*d.width,.5*d.height],d=this.convertCanvasToOffset(b),this.scale=a,.01>Math.abs(this.scale-1)&&(this.scale=1),a=this.convertCanvasToOffset(b),a=[a[0]-d[0],a[1]-d[1]],this.offset[0]+=a[0],this.offset[1]+=a[1],this.onredraw))this.onredraw(this)}};u.prototype.changeDeltaScale=function(a,b){this.changeScale(this.scale*a,b)};u.prototype.reset=function(){this.scale=1;this.offset[0]=0;this.offset[1]=0};y.LGraphCanvas=e.LGraphCanvas=h;h.DEFAULT_BACKGROUND_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII="; h.link_type_colors={"-1":e.EVENT_LINK_COLOR,number:"#AAA",node:"#DCA"};h.gradients={};h.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()};h.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)))};h.prototype.getTopGraph=function(){return this._graph_stack.length?this._graph_stack[0]:this.graph};h.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)};h.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= @@ -143,43 +143,43 @@ this.canvas.removeEventListener("DOMMouseScroll",this._mousewheel_callback);this h.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()};h.prototype.enableWebGL=function(){if("undefined"===typeof GL)throw"litegl.js must be included to use a WebGL canvas";if("undefined"===typeof enableWebGLCanvas)throw"webglCanvas.js must be included to use this feature";this.gl=this.ctx=enableWebGLCanvas(this.canvas);this.ctx.webgl=!0;this.bgcanvas=this.canvas;this.bgctx=this.gl;this.canvas.webgl_enabled=!0}; h.prototype.setDirty=function(a,b){a&&(this.dirty_canvas=!0);b&&(this.dirty_bgcanvas=!0)};h.prototype.getCanvasWindow=function(){if(!this.canvas)return window;var a=this.canvas.ownerDocument;return a.defaultView||a.parentWindow};h.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))};h.prototype.stopRendering=function(){this.is_rendering= !1};h.prototype.blockClick=function(){this.block_click=!0;this.last_mouseclick=0};h.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();h.active_canvas=this;var d=this,f=a.clientX,g=a.clientY;this.ds.viewport=this.viewport;f=!this.viewport||this.viewport&&f>=this.viewport[0]&&f=this.viewport[1]&&gg-this.last_mouseclick&&c;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&&c?!0:!1;this.pointer_is_down=!0;this.canvas.focus();e.closeAllContextMenus(b);if(!this.onMouse||1!=this.onMouse(a)){if(1!=a.which||this.pointer_is_double)if(2==a.which)if(e.middle_click_slot_add_default_node){if(n&&this.allow_interaction&&!f&&!this.read_only&&!this.connecting_node&&!n.flags.collapsed&&!this.live_mode){g=f=c=!1;if(n.outputs)for(C=0,z=n.outputs.length;Cn.size[0]-e.NODE_TITLE_HEIGHT&& -0>z[1]&&(d=this,setTimeout(function(){d.openSubgraph(n.subgraph)},10)),this.live_mode&&(C=c=!0));C?n.is_selected||this.processNodeSelected(n,a):(this.allow_dragnodes&&(this.graph.beforeChange(),this.node_dragged=n),this.processNodeSelected(n,a));this.dirty_canvas=!0}}else if(!f){if(!this.read_only)for(C=0;Cz[0]+4||a.canvasYz[1]+4)){this.showLinkMenu(c,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>I([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());g&&!this.read_only&&this.allow_searchbox&&(this.showSearchBox(a),a.preventDefault(),a.stopPropagation()); +(e.pointerListenerRemove(this.canvas,"move",this._mousemove_callback),e.pointerListenerAdd(b.document,"move",this._mousemove_callback,!0),e.pointerListenerAdd(b.document,"up",this._mouseup_callback,!0));if(f){var q=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes,5);f=!1;g=e.getTime();var c=void 0===a.isPrimary||!a.isPrimary;g=300>g-this.last_mouseclick&&c;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&&c?!0:!1;this.pointer_is_down=!0;this.canvas.focus();e.closeAllContextMenus(b);if(!this.onMouse||1!=this.onMouse(a)){if(1!=a.which||this.pointer_is_double)if(2==a.which)if(e.middle_click_slot_add_default_node){if(q&&this.allow_interaction&&!f&&!this.read_only&&!this.connecting_node&&!q.flags.collapsed&&!this.live_mode){g=f=c=!1;if(q.outputs)for(v=0,l=q.outputs.length;vq.size[0]-e.NODE_TITLE_HEIGHT&& +0>l[1]&&(d=this,setTimeout(function(){d.openSubgraph(q.subgraph)},10)),this.live_mode&&(v=c=!0));v?q.is_selected||this.processNodeSelected(q,a):(this.allow_dragnodes&&(this.graph.beforeChange(),this.node_dragged=q),this.processNodeSelected(q,a));this.dirty_canvas=!0}}else if(!f){if(!this.read_only)for(v=0;vl[0]+4||a.canvasYl[1]+4)){this.showLinkMenu(c,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>E([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());g&&!this.read_only&&this.allow_searchbox&&(this.showSearchBox(a),a.preventDefault(),a.stopPropagation()); c=!0}!f&&c&&this.allow_dragcanvas&&(this.dragging_canvas=!0)}this.last_mouse[0]=a.clientX;this.last_mouse[1]=a.clientY;this.last_mouseclick=e.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}}}};h.prototype.processMouseMove=function(a){this.autoresize&&this.resize(); this.set_canvas_dirty_on_mouse_event&&(this.dirty_canvas=!0);if(this.graph){h.active_canvas=this;this.adjustMouseEvent(a);var b=[a.clientX,a.clientY];this.mouse[0]=b[0];this.mouse[1]=b[1];var d=[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);var f=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes);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(d[0]/this.ds.scale,d[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]+=d[0]/this.ds.scale,this.ds.offset[1]+=d[1]/this.ds.scale,this.dirty_bgcanvas=this.dirty_canvas=!0;else if((this.allow_interaction||f&&f.flags.allow_interaction)&&!this.read_only){this.connecting_node&&(this.dirty_canvas=!0);b=0;for(var g=this.graph._nodes.length;bc[0]+4||a.canvasYc[1]+4)){g=n;break}g!=this.over_link_center&&(this.over_link_center=g,this.dirty_canvas=!0);this.canvas&&(this.canvas.style.cursor="")}if(this.node_capturing_input&& +!1;if(this.node_over&&this.node_over.onMouseLeave)this.node_over.onMouseLeave(a);this.node_over=null;this.dirty_canvas=!0}if(f){f.redraw_on_mouse&&(this.dirty_canvas=!0);if(!f.mouseOver&&(f.mouseOver=!0,this.node_over=f,this.dirty_canvas=!0,f.onMouseEnter))f.onMouseEnter(a);if(f.onMouseMove)f.onMouseMove(a,[a.canvasX-f.pos[0],a.canvasY-f.pos[1]],this);if(this.connecting_node)if(this.connecting_output){if(g=this._highlight_input||[0,0],!this.isOverNodeBox(f,a.canvasX,a.canvasY)){var q=this.isOverNodeInput(f, +a.canvasX,a.canvasY,g);if(-1!=q&&f.inputs[q]){var c=f.inputs[q].type;e.isValidConnection(this.connecting_output.type,c)&&(this._highlight_input=g,this._highlight_input_slot=f.inputs[q])}else this._highlight_input_slot=this._highlight_input=null}}else this.connecting_input&&(g=this._highlight_output||[0,0],this.isOverNodeBox(f,a.canvasX,a.canvasY)||(q=this.isOverNodeOutput(f,a.canvasX,a.canvasY,g),-1!=q&&f.outputs[q]?(c=f.outputs[q].type,e.isValidConnection(this.connecting_input.type,c)&&(this._highlight_output= +g)):this._highlight_output=null));this.canvas&&(D(a.canvasX,a.canvasY,f.pos[0]+f.size[0]-5,f.pos[1]+f.size[1]-5,5,5)?this.canvas.style.cursor="se-resize":this.canvas.style.cursor="crosshair")}else{g=null;for(b=0;bc[0]+4||a.canvasYc[1]+4)){g=q;break}g!=this.over_link_center&&(this.over_link_center=g,this.dirty_canvas=!0);this.canvas&&(this.canvas.style.cursor="")}if(this.node_capturing_input&& this.node_capturing_input!=f&&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)f=this.selected_nodes[b],f.pos[0]+=d[0]/this.ds.scale,f.pos[1]+=d[1]/this.ds.scale,f.is_selected||this.processNodeSelected(f,a);this.dirty_bgcanvas=this.dirty_canvas=!0}this.resizing_node&&!this.live_mode&&(d=[a.canvasX-this.resizing_node.pos[0], a.canvasY-this.resizing_node.pos[1]],b=this.resizing_node.computeSize(),d[0]=Math.max(b[0],d[0]),d[1]=Math.max(b[1],d[1]),this.resizing_node.setSize(d),this.canvas.style.cursor="se-resize",this.dirty_bgcanvas=this.dirty_canvas=!0)}a.preventDefault();return!1}};h.prototype.processMouseUp=function(a){var b=void 0===a.isPrimary||a.isPrimary;if(!b)return!1;this.set_canvas_dirty_on_mouse_event&&(this.dirty_canvas=!0);if(this.graph){var d=this.getCanvasWindow().document;h.active_canvas=this;this.options.skip_events|| (e.pointerListenerRemove(d,"move",this._mousemove_callback,!0),e.pointerListenerAdd(this.canvas,"move",this._mousemove_callback,!0),e.pointerListenerRemove(d,"up",this._mouseup_callback,!0));this.adjustMouseEvent(a);d=e.getTime();a.click_time=d-this.last_mouseclick;this.last_mouse_dragging=!1;this.last_click_position=null;this.block_click&&(this.block_click=!1);if(1==a.which){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;var f=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes);if(this.dragging_rectangle){if(this.graph){d= -this.graph._nodes;var g=new Float32Array(4),n=Math.abs(this.dragging_rectangle[2]),c=Math.abs(this.dragging_rectangle[3]),z=0>this.dragging_rectangle[3]?this.dragging_rectangle[1]-c:this.dragging_rectangle[1];this.dragging_rectangle[0]=0>this.dragging_rectangle[2]?this.dragging_rectangle[0]-n:this.dragging_rectangle[0];this.dragging_rectangle[1]=z;this.dragging_rectangle[2]=n;this.dragging_rectangle[3]=c;if(!f||10this.dragging_rectangle[3]?this.dragging_rectangle[1]-c:this.dragging_rectangle[1];this.dragging_rectangle[0]=0>this.dragging_rectangle[2]?this.dragging_rectangle[0]-q:this.dragging_rectangle[0];this.dragging_rectangle[1]=l;this.dragging_rectangle[2]=q;this.dragging_rectangle[3]=c;if(!f||10a.click_time&&E(a.canvasX,a.canvasY,f.pos[0],f.pos[1]-e.NODE_TITLE_HEIGHT,e.NODE_TITLE_HEIGHT,e.NODE_TITLE_HEIGHT)&&f.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)&&300>a.click_time&&D(a.canvasX,a.canvasY,f.pos[0],f.pos[1]-e.NODE_TITLE_HEIGHT,e.NODE_TITLE_HEIGHT,e.NODE_TITLE_HEIGHT)&&f.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{f=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes);!f&&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);b&&(this.pointer_is_double=this.pointer_is_down=!1);this.graph.change();a.stopPropagation();a.preventDefault();return!1}};h.prototype.processMouseWheel=function(a){if(this.graph&&this.allow_dragcanvas){var b=null!=a.wheelDeltaY?a.wheelDeltaY:-60*a.detail;this.adjustMouseEvent(a);var d=a.clientX,f=a.clientY;if(!this.viewport||this.viewport&&d>=this.viewport[0]&&d=this.viewport[1]&&fb&&(d*=1/1.1),this.ds.changeScale(d,[a.clientX,a.clientY]),this.graph.change(),a.preventDefault(),!1}};h.prototype.isOverNodeBox=function(a,b,d){var f=e.NODE_TITLE_HEIGHT;return E(b,d,a.pos[0]+2,a.pos[1]+2-f,f-4,f-4)?!0:!1};h.prototype.isOverNodeInput=function(a,b,d,f){if(a.inputs)for(var g=0,e=a.inputs.length;g=this.viewport[1]&&fb&&(d*=1/1.1),this.ds.changeScale(d,[a.clientX,a.clientY]),this.graph.change(),a.preventDefault(),!1}};h.prototype.isOverNodeBox=function(a,b,d){var f=e.NODE_TITLE_HEIGHT;return D(b,d,a.pos[0]+2,a.pos[1]+2-f,f-4,f-4)?!0:!1};h.prototype.isOverNodeInput=function(a,b,d,f){if(a.inputs)for(var g=0,e=a.inputs.length;gb.nodes[g].pos[0]&&(d[0]=b.nodes[g].pos[0],f[0]=g),d[1]>b.nodes[g].pos[1]&&(d[1]=b.nodes[g].pos[1],f[1]=g)):(d=[b.nodes[g].pos[0],b.nodes[g].pos[1]],f=[g,g]);f=[];for(g=0;g=this.viewport[0]&&b=this.viewport[1]&&db.nodes[g].pos[0]&&(d[0]=b.nodes[g].pos[0],f[0]=g),d[1]>b.nodes[g].pos[1]&&(d[1]=b.nodes[g].pos[1],f[1]=g)):(d=[b.nodes[g].pos[0],b.nodes[g].pos[1]],f=[g,g]);f=[];for(g=0;g=this.viewport[0]&&b=this.viewport[1]&&dd-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}};h.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 d=this.viewport||this.dirty_area;d&&(a.save(),a.beginPath(),a.rect(d[0],d[1],d[2],d[3]),a.clip());this.clear_background&&(d?a.clearRect(d[0],d[1],d[2],d[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,d?d[0]:0,d?d[1]:0);if(this.graph){a.save();this.ds.toCanvasContext(a);b=this.computeVisibleNodes(null,this.visible_nodes);for(var f=0;f> ";b.fillText(f+d.getTitle(),.5*a.width,40);b.restore()}d=!1;this.onRenderBackground&&(d=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);1.5>this.ds.scale&&!d&&this.clear_background_color&& (b.fillStyle=this.clear_background_color,b.fillRect(this.visible_area[0],this.visible_area[1],this.visible_area[2],this.visible_area[3]));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 c=this.editor_alpha;b.globalAlpha=c;this.render_shadows&&!g?(b.shadowColor=e.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 t=a._shape||e.BOX_SHAPE;D.set(a.size);var z=a.horizontal;if(a.flags.collapsed){b.font=this.inner_text_font;var v=a.getTitle?a.getTitle():a.title;null!=v&&(a._collapsed_width=Math.min(a.size[0],b.measureText(v).width+2*e.NODE_TITLE_HEIGHT),D[0]=a._collapsed_width,D[1]=0)}a.clip_area&&(b.save(),b.beginPath(),t==e.BOX_SHAPE?b.rect(0,0, -D[0],D[1]):t==e.ROUND_SHAPE?b.roundRect(0,0,D[0],D[1],[10]):t==e.CIRCLE_SHAPE&&b.arc(.5*D[0],.5*D[1],.5*D[0],0,2*Math.PI),b.clip());a.has_errors&&(f="red");this.drawNodeShape(a,b,D,d,f,a.is_selected,a.mouseOver);b.shadowColor="transparent";if(a.onDrawForeground)a.onDrawForeground(b,this,this.canvas);b.textAlign=z?"center":"left";b.font=this.inner_text_font;f=!g;var u=this.connecting_output;t=this.connecting_input;b.lineWidth=1;v=0;var C=new Float32Array(2);if(!a.flags.collapsed){if(a.inputs)for(d= -0;dthis.ds.scale;if(this.live_mode){if(!a.flags.collapsed&&(b.shadowColor="transparent",a.onDrawForeground))a.onDrawForeground(b,this,this.canvas)}else{var c=this.editor_alpha;b.globalAlpha=c;this.render_shadows&&!g?(b.shadowColor=e.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 l=a._shape||e.BOX_SHAPE;B.set(a.size);var m=a.horizontal;if(a.flags.collapsed){b.font=this.inner_text_font;var h=a.getTitle?a.getTitle():a.title;null!=h&&(a._collapsed_width=Math.min(a.size[0],b.measureText(h).width+2*e.NODE_TITLE_HEIGHT),B[0]=a._collapsed_width,B[1]=0)}a.clip_area&&(b.save(),b.beginPath(),l==e.BOX_SHAPE?b.rect(0,0, +B[0],B[1]):l==e.ROUND_SHAPE?b.roundRect(0,0,B[0],B[1],[10]):l==e.CIRCLE_SHAPE&&b.arc(.5*B[0],.5*B[1],.5*B[0],0,2*Math.PI),b.clip());a.has_errors&&(f="red");this.drawNodeShape(a,b,B,d,f,a.is_selected,a.mouseOver);b.shadowColor="transparent";if(a.onDrawForeground)a.onDrawForeground(b,this,this.canvas);b.textAlign=m?"center":"left";b.font=this.inner_text_font;f=!g;var t=this.connecting_output;l=this.connecting_input;b.lineWidth=1;h=0;var v=new Float32Array(2);if(!a.flags.collapsed){if(a.inputs)for(d= +0;dthis.ds.scale,v=a._shape||a.constructor.shape||e.ROUND_SHAPE,u=a.constructor.title_mode,C=!0;u==e.TRANSPARENT_TITLE||u==e.NO_TITLE?C=!1:u==e.AUTOHIDE_TITLE&&t&&(C=!0);M[0]=0;M[1]=C?-g:0;M[2]=d[0]+1;M[3]=C?d[1]+g:d[1];t=b.globalAlpha;b.beginPath();v==e.BOX_SHAPE||n?b.fillRect(M[0],M[1],M[2],M[3]):v==e.ROUND_SHAPE||v==e.CARD_SHAPE?b.roundRect(M[0],M[1],M[2],M[3],v==e.CARD_SHAPE?[this.round_radius, -this.round_radius,0,0]:[this.round_radius]):v==e.CIRCLE_SHAPE&&b.arc(.5*d[0],.5*d[1],.5*d[0],0,2*Math.PI);b.fill();!a.flags.collapsed&&C&&(b.shadowColor="transparent",b.fillStyle="rgba(0,0,0,0.2)",b.fillRect(0,-1,M[2],2));b.shadowColor="transparent";if(a.onDrawBackground)a.onDrawBackground(b,this,this.canvas,this.graph_mouse);if(C||u==e.TRANSPARENT_TITLE){if(a.onDrawTitleBar)a.onDrawTitleBar(b,g,d,this.ds.scale,f);else if(u!=e.TRANSPARENT_TITLE&&(a.constructor.title_color||this.render_title_colored)){C= -a.constructor.title_color||f;a.flags.collapsed&&(b.shadowColor=e.DEFAULT_SHADOW_COLOR);if(this.use_gradients){var x=h.gradients[C];x||(x=h.gradients[C]=b.createLinearGradient(0,0,400,0),x.addColorStop(0,C),x.addColorStop(1,"#000"));b.fillStyle=x}else b.fillStyle=C;b.beginPath();v==e.BOX_SHAPE||n?b.rect(0,-g,d[0]+1,g):(v==e.ROUND_SHAPE||v==e.CARD_SHAPE)&&b.roundRect(0,-g,d[0]+1,g,a.flags.collapsed?[this.round_radius]:[this.round_radius,this.round_radius,0,0]);b.fill();b.shadowColor="transparent"}C= -!1;e.node_box_coloured_by_mode&&e.NODE_MODES_COLORS[a.mode]&&(C=e.NODE_MODES_COLORS[a.mode]);e.node_box_coloured_when_on&&(C=a.action_triggered?"#FFF":a.execute_triggered?"#AAA":C);if(a.onDrawTitleBox)a.onDrawTitleBox(b,g,d,this.ds.scale);else v==e.ROUND_SHAPE||v==e.CIRCLE_SHAPE||v==e.CARD_SHAPE?(n&&(b.fillStyle="black",b.beginPath(),b.arc(.5*g,-.5*g,6,0,2*Math.PI),b.fill()),b.fillStyle=a.boxcolor||C||e.NODE_DEFAULT_BOXCOLOR,n?b.fillRect(.5*g-5,-.5*g-5,10,10):(b.beginPath(),b.arc(.5*g,-.5*g,5,0,2* -Math.PI),b.fill())):(n&&(b.fillStyle="black",b.fillRect(.5*(g-10)-1,-.5*(g+10)-1,12,12)),b.fillStyle=a.boxcolor||C||e.NODE_DEFAULT_BOXCOLOR,b.fillRect(.5*(g-10),-.5*(g+10),10,10));b.globalAlpha=t;if(a.onDrawTitleText)a.onDrawTitleText(b,g,d,this.ds.scale,this.title_text_font,c);!n&&(b.font=this.title_text_font,t=String(a.getTitle()))&&(b.fillStyle=c?e.NODE_SELECTED_TITLE_COLOR:a.constructor.title_text_color||this.node_title_color,a.flags.collapsed?(b.textAlign="left",b.measureText(t),b.fillText(t.substr(0, -20),g,e.NODE_TITLE_TEXT_Y-g),b.textAlign="left"):(b.textAlign="left",b.fillText(t,g,e.NODE_TITLE_TEXT_Y-g)));a.flags.collapsed||!a.subgraph||a.skip_subgraph_button||(t=e.NODE_TITLE_HEIGHT,C=a.size[0]-t,x=e.isInsideRectangle(this.graph_mouse[0]-a.pos[0],this.graph_mouse[1]-a.pos[1],C+2,-t+2,t-4,t-4),b.fillStyle=x?"#888":"#555",v==e.BOX_SHAPE||n?b.fillRect(C+2,-t+2,t-4,t-4):(b.beginPath(),b.roundRect(C+2,-t+2,t-4,t-4,[4]),b.fill()),b.fillStyle="#333",b.beginPath(),b.moveTo(C+.2*t,.6*-t),b.lineTo(C+ -.8*t,.6*-t),b.lineTo(C+.5*t,.3*-t),b.fill());if(a.onDrawTitle)a.onDrawTitle(b)}if(c){if(a.onBounding)a.onBounding(M);u==e.TRANSPARENT_TITLE&&(M[1]-=g,M[3]+=g);b.lineWidth=1;b.globalAlpha=.8;b.beginPath();v==e.BOX_SHAPE?b.rect(-6+M[0],-6+M[1],12+M[2],12+M[3]):v==e.ROUND_SHAPE||v==e.CARD_SHAPE&&a.flags.collapsed?b.roundRect(-6+M[0],-6+M[1],12+M[2],12+M[3],[2*this.round_radius]):v==e.CARD_SHAPE?b.roundRect(-6+M[0],-6+M[1],12+M[2],12+M[3],[2*this.round_radius,2,2*this.round_radius,2]):v==e.CIRCLE_SHAPE&& -b.arc(.5*d[0],.5*d[1],.5*d[0]+6,0,2*Math.PI);b.strokeStyle=e.NODE_BOX_OUTLINE_COLOR;b.stroke();b.strokeStyle=f;b.globalAlpha=1}0l[2]&&(l[0]+=l[2],l[2]=Math.abs(l[2]));0>l[3]&& -(l[1]+=l[3],l[3]=Math.abs(l[3]));if(H(l,m)){var N=v.outputs[u];u=c.inputs[t];if(N&&u&&(v=N.dir||(v.horizontal?e.DOWN:e.RIGHT),u=u.dir||(c.horizontal?e.UP:e.LEFT),this.renderLink(a,C,x,z,!1,0,null,v,u),z&&z._last_time&&1E3>b-z._last_time)){N=2-.002*(b-z._last_time);var F=a.globalAlpha;a.globalAlpha=F*N;this.renderLink(a,C,x,z,!0,N,"white",v,u);a.globalAlpha=F}}}}}}a.globalAlpha=1};h.prototype.renderLink=function(a,b,d,f,g,c,t,z,v,u){f&&this.visible_links.push(f);!t&&f&&(t=f.color||h.link_type_colors[f.type]); -t||(t=this.default_link_color);null!=f&&this.highlighted_links[f.id]&&(t="#FFF");z=z||e.RIGHT;v=v||e.LEFT;var n=I(b,d);this.render_connections_border&&.6b[1]?0:Math.PI,a.save(),a.translate(x[0],x[1]),a.rotate(n),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5, --3),a.fill(),a.restore(),a.save(),a.translate(f[0],f[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(g[0],g[1],5,0,2*Math.PI),a.fill());if(c)for(a.fillStyle=t,x=0;5>x;++x)c=(.001*e.getTime()+.2*x)%1,g=this.computeConnectionPoint(b,d,c,z,v),a.beginPath(),a.arc(g[0],g[1],5,0,2*Math.PI),a.fill()};h.prototype.computeConnectionPoint=function(a,b,d,f,g){f=f||e.RIGHT;g=g||e.LEFT;var c=I(a,b),t=[a[0],a[1]],z=[b[0],b[1]];switch(f){case e.LEFT:t[0]+= --.25*c;break;case e.RIGHT:t[0]+=.25*c;break;case e.UP:t[1]+=-.25*c;break;case e.DOWN:t[1]+=.25*c}switch(g){case e.LEFT:z[0]+=-.25*c;break;case e.RIGHT:z[0]+=.25*c;break;case e.UP:z[1]+=-.25*c;break;case e.DOWN:z[1]+=.25*c}f=(1-d)*(1-d)*(1-d);g=3*(1-d)*(1-d)*d;c=3*(1-d)*d*d;d*=d*d;return[f*a[0]+g*t[0]+c*z[0]+d*b[0],f*a[1]+g*t[1]+c*z[1]+d*b[1]]};h.prototype.drawExecutionOrder=function(a){a.shadowColor="transparent";a.globalAlpha=.25;a.textAlign="center";a.strokeStyle="white";a.globalAlpha=.75;for(var b= +h.prototype.drawNodeShape=function(a,b,d,f,g,c,l){b.strokeStyle=f;b.fillStyle=g;g=e.NODE_TITLE_HEIGHT;var q=.5>this.ds.scale,z=a._shape||a.constructor.shape||e.ROUND_SHAPE,t=a.constructor.title_mode,v=!0;t==e.TRANSPARENT_TITLE||t==e.NO_TITLE?v=!1:t==e.AUTOHIDE_TITLE&&l&&(v=!0);M[0]=0;M[1]=v?-g:0;M[2]=d[0]+1;M[3]=v?d[1]+g:d[1];l=b.globalAlpha;b.beginPath();z==e.BOX_SHAPE||q?b.fillRect(M[0],M[1],M[2],M[3]):z==e.ROUND_SHAPE||z==e.CARD_SHAPE?b.roundRect(M[0],M[1],M[2],M[3],z==e.CARD_SHAPE?[this.round_radius, +this.round_radius,0,0]:[this.round_radius]):z==e.CIRCLE_SHAPE&&b.arc(.5*d[0],.5*d[1],.5*d[0],0,2*Math.PI);b.fill();!a.flags.collapsed&&v&&(b.shadowColor="transparent",b.fillStyle="rgba(0,0,0,0.2)",b.fillRect(0,-1,M[2],2));b.shadowColor="transparent";if(a.onDrawBackground)a.onDrawBackground(b,this,this.canvas,this.graph_mouse);if(v||t==e.TRANSPARENT_TITLE){if(a.onDrawTitleBar)a.onDrawTitleBar(b,g,d,this.ds.scale,f);else if(t!=e.TRANSPARENT_TITLE&&(a.constructor.title_color||this.render_title_colored)){v= +a.constructor.title_color||f;a.flags.collapsed&&(b.shadowColor=e.DEFAULT_SHADOW_COLOR);if(this.use_gradients){var C=h.gradients[v];C||(C=h.gradients[v]=b.createLinearGradient(0,0,400,0),C.addColorStop(0,v),C.addColorStop(1,"#000"));b.fillStyle=C}else b.fillStyle=v;b.beginPath();z==e.BOX_SHAPE||q?b.rect(0,-g,d[0]+1,g):(z==e.ROUND_SHAPE||z==e.CARD_SHAPE)&&b.roundRect(0,-g,d[0]+1,g,a.flags.collapsed?[this.round_radius]:[this.round_radius,this.round_radius,0,0]);b.fill();b.shadowColor="transparent"}v= +!1;e.node_box_coloured_by_mode&&e.NODE_MODES_COLORS[a.mode]&&(v=e.NODE_MODES_COLORS[a.mode]);e.node_box_coloured_when_on&&(v=a.action_triggered?"#FFF":a.execute_triggered?"#AAA":v);if(a.onDrawTitleBox)a.onDrawTitleBox(b,g,d,this.ds.scale);else z==e.ROUND_SHAPE||z==e.CIRCLE_SHAPE||z==e.CARD_SHAPE?(q&&(b.fillStyle="black",b.beginPath(),b.arc(.5*g,-.5*g,6,0,2*Math.PI),b.fill()),b.fillStyle=a.boxcolor||v||e.NODE_DEFAULT_BOXCOLOR,q?b.fillRect(.5*g-5,-.5*g-5,10,10):(b.beginPath(),b.arc(.5*g,-.5*g,5,0,2* +Math.PI),b.fill())):(q&&(b.fillStyle="black",b.fillRect(.5*(g-10)-1,-.5*(g+10)-1,12,12)),b.fillStyle=a.boxcolor||v||e.NODE_DEFAULT_BOXCOLOR,b.fillRect(.5*(g-10),-.5*(g+10),10,10));b.globalAlpha=l;if(a.onDrawTitleText)a.onDrawTitleText(b,g,d,this.ds.scale,this.title_text_font,c);!q&&(b.font=this.title_text_font,l=String(a.getTitle()))&&(b.fillStyle=c?e.NODE_SELECTED_TITLE_COLOR:a.constructor.title_text_color||this.node_title_color,a.flags.collapsed?(b.textAlign="left",b.measureText(l),b.fillText(l.substr(0, +20),g,e.NODE_TITLE_TEXT_Y-g),b.textAlign="left"):(b.textAlign="left",b.fillText(l,g,e.NODE_TITLE_TEXT_Y-g)));a.flags.collapsed||!a.subgraph||a.skip_subgraph_button||(l=e.NODE_TITLE_HEIGHT,v=a.size[0]-l,C=e.isInsideRectangle(this.graph_mouse[0]-a.pos[0],this.graph_mouse[1]-a.pos[1],v+2,-l+2,l-4,l-4),b.fillStyle=C?"#888":"#555",z==e.BOX_SHAPE||q?b.fillRect(v+2,-l+2,l-4,l-4):(b.beginPath(),b.roundRect(v+2,-l+2,l-4,l-4,[4]),b.fill()),b.fillStyle="#333",b.beginPath(),b.moveTo(v+.2*l,.6*-l),b.lineTo(v+ +.8*l,.6*-l),b.lineTo(v+.5*l,.3*-l),b.fill());if(a.onDrawTitle)a.onDrawTitle(b)}if(c){if(a.onBounding)a.onBounding(M);t==e.TRANSPARENT_TITLE&&(M[1]-=g,M[3]+=g);b.lineWidth=1;b.globalAlpha=.8;b.beginPath();z==e.BOX_SHAPE?b.rect(-6+M[0],-6+M[1],12+M[2],12+M[3]):z==e.ROUND_SHAPE||z==e.CARD_SHAPE&&a.flags.collapsed?b.roundRect(-6+M[0],-6+M[1],12+M[2],12+M[3],[2*this.round_radius]):z==e.CARD_SHAPE?b.roundRect(-6+M[0],-6+M[1],12+M[2],12+M[3],[2*this.round_radius,2,2*this.round_radius,2]):z==e.CIRCLE_SHAPE&& +b.arc(.5*d[0],.5*d[1],.5*d[0]+6,0,2*Math.PI);b.strokeStyle=e.NODE_BOX_OUTLINE_COLOR;b.stroke();b.strokeStyle=f;b.globalAlpha=1}0m[2]&&(m[0]+=m[2],m[2]=Math.abs(m[2]));0>m[3]&& +(m[1]+=m[3],m[3]=Math.abs(m[3]));if(J(m,l)){var x=k.outputs[t];t=c.inputs[z];if(x&&t&&(k=x.dir||(k.horizontal?e.DOWN:e.RIGHT),t=t.dir||(c.horizontal?e.UP:e.LEFT),this.renderLink(a,v,C,h,!1,0,null,k,t),h&&h._last_time&&1E3>b-h._last_time)){x=2-.002*(b-h._last_time);var G=a.globalAlpha;a.globalAlpha=G*x;this.renderLink(a,v,C,h,!0,x,"white",k,t);a.globalAlpha=G}}}}}}a.globalAlpha=1};h.prototype.renderLink=function(a,b,d,f,g,c,l,m,w,t){f&&this.visible_links.push(f);!l&&f&&(l=f.color||h.link_type_colors[f.type]); +l||(l=this.default_link_color);null!=f&&this.highlighted_links[f.id]&&(l="#FFF");m=m||e.RIGHT;w=w||e.LEFT;var q=E(b,d);this.render_connections_border&&.6b[1]?0:Math.PI,a.save(),a.translate(C[0],C[1]),a.rotate(q),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5, +-3),a.fill(),a.restore(),a.save(),a.translate(f[0],f[1]),a.rotate(t),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore()),a.beginPath(),a.arc(g[0],g[1],5,0,2*Math.PI),a.fill());if(c)for(a.fillStyle=l,C=0;5>C;++C)c=(.001*e.getTime()+.2*C)%1,g=this.computeConnectionPoint(b,d,c,m,w),a.beginPath(),a.arc(g[0],g[1],5,0,2*Math.PI),a.fill()};h.prototype.computeConnectionPoint=function(a,b,d,f,g){f=f||e.RIGHT;g=g||e.LEFT;var c=E(a,b),l=[a[0],a[1]],m=[b[0],b[1]];switch(f){case e.LEFT:l[0]+= +-.25*c;break;case e.RIGHT:l[0]+=.25*c;break;case e.UP:l[1]+=-.25*c;break;case e.DOWN:l[1]+=.25*c}switch(g){case e.LEFT:m[0]+=-.25*c;break;case e.RIGHT:m[0]+=.25*c;break;case e.UP:m[1]+=-.25*c;break;case e.DOWN:m[1]+=.25*c}f=(1-d)*(1-d)*(1-d);g=3*(1-d)*(1-d)*d;c=3*(1-d)*d*d;d*=d*d;return[f*a[0]+g*l[0]+c*m[0]+d*b[0],f*a[1]+g*l[1]+c*m[1]+d*b[1]]};h.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,d=0;dh&&(h=0);1A&&(A=0),1c||c>F-12||tx.last_y+N||void 0===x.last_y)){f=x.value;switch(x.type){case "button":d.type===e.pointerevents_method+"down"&&(x.callback&&setTimeout(function(){x.callback(x,v,a,b,d)},20),this.dirty_canvas=x.clicked=!0);break;case "slider":f=x.value;u=G((c-15)/(F-30),0,1);if(x.options.read_only)break;x.value=x.options.min+(x.options.max-x.options.min)*u;f!=x.value&&setTimeout(function(){g(x,x.value)},20);this.dirty_canvas=!0;break;case "number":case "combo":f= -x.value;if(d.type==e.pointerevents_method+"move"&&"number"==x.type)d.deltaX&&(x.value+=.1*d.deltaX*(x.options.step||1)),null!=x.options.min&&x.valuex.options.max&&(x.value=x.options.max);else if(d.type==e.pointerevents_method+"down"){var y=x.options.values;y&&y.constructor===Function&&(y=x.options.values(x,a));var A=null;"number"!=x.type&&(A=y.constructor===Array?y:Object.keys(y));c=40>c?-1:c>F-40?1:0;if("number"==x.type)x.value+= -.1*c*(x.options.step||1),null!=x.options.min&&x.valuex.options.max&&(x.value=x.options.max);else if(c)u=-1,this.last_mouseclick=0,u=y.constructor===Object?A.indexOf(String(x.value))+c:A.indexOf(x.value)+c,u>=A.length&&(u=A.length-1),0>u&&(u=0),x.value=y.constructor===Array?y[u]:u;else{var h=y!=A?Object.values(y):y;new e.ContextMenu(h,{scale:Math.max(1,this.ds.scale),event:d,className:"dark",callback:function(a,b,d){y!=A&&(a=h.indexOf(a)); -this.value=a;g(this,a);v.dirty_canvas=!0;return!1}.bind(x)},u)}}else d.type==e.pointerevents_method+"up"&&"number"==x.type&&(c=40>c?-1:c>F-40?1:0,200>d.click_time&&0==c&&this.prompt("Value",x.value,function(a){if(/^[0-9+\-*/()\s]+|\d+\.\d+$/.test(a))try{a=eval(a)}catch(U){}this.value=Number(a);g(this,this.value)}.bind(x),d));f!=x.value&&setTimeout(function(){g(this,this.value)}.bind(x),20);this.dirty_canvas=!0;break;case "toggle":d.type==e.pointerevents_method+"down"&&(x.value=!x.value,setTimeout(function(){g(x, -x.value)},20));break;case "string":case "text":d.type==e.pointerevents_method+"down"&&this.prompt("Value",x.value,function(a){g(this,a)}.bind(x),d,x.options?x.options.multiline:!1);break;default:x.mouse&&(this.dirty_canvas=x.mouse(d,[c,t],a))}if(f!=x.value){if(a.onWidgetChanged)a.onWidgetChanged(x.name,x.value,f,x);a.graph._version++}return x}}}return null};h.prototype.drawGroups=function(a,b){if(this.graph){a=this.graph._groups;b.save();b.globalAlpha=.5*this.editor_alpha;for(var d=0;dd&&.01>b.editor_alpha&&(clearInterval(f),1>d&&(b.live_mode=!0));1d.pos[0]+d.size[0])d=c;if(null===f||m+u>f.pos[1]+f.size[1])f=c;if(null===g||vn&&(n=0);1k&&(k=0),1c||c>A-12||lx.last_y+G||void 0===x.last_y)){f=x.value;switch(x.type){case "button":d.type===e.pointerevents_method+"down"&&(x.callback&&setTimeout(function(){x.callback(x,t,a,b,d)},20),this.dirty_canvas=x.clicked=!0);break;case "slider":f=x.value;v=F((c-15)/(A-30),0,1);if(x.options.read_only)break;x.value=x.options.min+(x.options.max-x.options.min)*v;f!=x.value&&setTimeout(function(){g(x,x.value)},20);this.dirty_canvas= +!0;break;case "number":case "combo":f=x.value;if(d.type==e.pointerevents_method+"move"&&"number"==x.type)h&&(x.value+=.1*h*(x.options.step||1)),null!=x.options.min&&x.valuex.options.max&&(x.value=x.options.max);else if(d.type==e.pointerevents_method+"down"){var w=x.options.values;w&&w.constructor===Function&&(w=x.options.values(x,a));var k=null;"number"!=x.type&&(k=w.constructor===Array?w:Object.keys(w));c=40>c?-1:c>A-40?1:0;if("number"== +x.type)x.value+=.1*c*(x.options.step||1),null!=x.options.min&&x.valuex.options.max&&(x.value=x.options.max);else if(c)v=-1,this.last_mouseclick=0,v=w.constructor===Object?k.indexOf(String(x.value))+c:k.indexOf(x.value)+c,v>=k.length&&(v=k.length-1),0>v&&(v=0),x.value=w.constructor===Array?w[v]:v;else{var n=w!=k?Object.values(w):w;new e.ContextMenu(n,{scale:Math.max(1,this.ds.scale),event:d,className:"dark",callback:function(a,b, +d){w!=k&&(a=n.indexOf(a));this.value=a;g(this,a);t.dirty_canvas=!0;return!1}.bind(x)},v)}}else d.type==e.pointerevents_method+"up"&&"number"==x.type&&(c=40>c?-1:c>A-40?1:0,200>d.click_time&&0==c&&this.prompt("Value",x.value,function(a){if(/^[0-9+\-*/()\s]+|\d+\.\d+$/.test(a))try{a=eval(a)}catch(V){}this.value=Number(a);g(this,this.value)}.bind(x),d));f!=x.value&&setTimeout(function(){g(this,this.value)}.bind(x),20);this.dirty_canvas=!0;break;case "toggle":d.type==e.pointerevents_method+"down"&&(x.value= +!x.value,setTimeout(function(){g(x,x.value)},20));break;case "string":case "text":d.type==e.pointerevents_method+"down"&&this.prompt("Value",x.value,function(a){g(this,a)}.bind(x),d,x.options?x.options.multiline:!1);break;default:x.mouse&&(this.dirty_canvas=x.mouse(d,[c,l],a))}if(f!=x.value){if(a.onWidgetChanged)a.onWidgetChanged(x.name,x.value,f,x);a.graph._version++}return x}}}return null};h.prototype.drawGroups=function(a,b){if(this.graph){a=this.graph._groups;b.save();b.globalAlpha=.5*this.editor_alpha; +for(var d=0;dd&&.01>b.editor_alpha&&(clearInterval(f),1>d&&(b.live_mode=!0));1d.pos[0]+d.size[0])d=c;if(null===f||l+t>f.pos[1]+f.size[1])f=c;if(null===g||m"+(v.label?v.label:m)+""+a+"",value:m})}if(t.length)return new e.ContextMenu(t,{event:d,callback:function(a,b,d,f){g&&(b=this.getBoundingClientRect(),c.showEditPropertyValue(g,a.value,{position:[b.left,b.top]}))},parentMenu:f,allow_html:!0, +!0;f.dirty_bgcanvas=!0}};h.onNodeAlign=function(a,b,d,f,g){new e.ContextMenu(["Top","Bottom","Left","Right"],{event:d,callback:function(a){h.alignNodes(h.active_canvas.selected_nodes,a.toLowerCase(),g)},parentMenu:f})};h.onGroupAlign=function(a,b,d,f){new e.ContextMenu(["Top","Bottom","Left","Right"],{event:d,callback:function(a){h.alignNodes(h.active_canvas.selected_nodes,a.toLowerCase())},parentMenu:f})};h.onMenuAdd=function(a,b,d,f,g){function c(a,b){var f=[];e.getNodeTypesCategories(l.filter|| +w.filter).filter(function(b){return b.startsWith(a)}).map(function(b){if(b){b=b.replace(new RegExp("^("+a+")"),"").split("/")[0];var d=""===a?b+"/":a+b+"/";-1!=b.indexOf("::")&&(b=b.split("::")[1]);-1===f.findIndex(function(a){return a.value===d})&&f.push({value:d,content:b,has_submenu:!0,callback:function(a,b,d,f){c(a.value,f)}})}});e.getNodeTypesInCategory(a.slice(0,-1),l.filter||w.filter).map(function(a){a.skip_list||f.push({value:a.type,content:a.title,has_submenu:!1,callback:function(a,b,d,f){b= +f.getFirstEvent();l.graph.beforeChange();if(a=e.createNode(a.value))a.pos=l.convertEventToCanvasOffset(b),l.graph.add(a);g&&g(a);l.graph.afterChange()}})});new e.ContextMenu(f,{event:d,parentMenu:b},m)}var l=h.active_canvas,m=l.getCanvasWindow(),w=l.graph;if(w)return c("",f),!1};h.onMenuCollapseAll=function(){};h.onMenuNodeEdit=function(){};h.showMenuNodeOptionalInputs=function(a,b,d,f,g){if(g){var c=this;a=h.active_canvas.getCanvasWindow();b=g.optional_inputs;g.onGetInputs&&(b=g.onGetInputs());var l= +[];if(b)for(var m=0;m"+(w.label?w.label:m)+""+a+"",value:m})}if(l.length)return new e.ContextMenu(l,{event:d,callback:function(a,b,d,f){g&&(b=this.getBoundingClientRect(),c.showEditPropertyValue(g,a.value,{position:[b.left,b.top]}))},parentMenu:f,allow_html:!0, node:g},b),!1}};h.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};h.onMenuResizeNode=function(a,b,d,f,g){if(g){a=function(a){a.size=a.computeSize();if(a.onResize)a.onResize(a.size)};b=h.active_canvas;if(!b.selected_nodes||1>=Object.keys(b.selected_nodes).length)a(g);else for(var e in b.selected_nodes)a(b.selected_nodes[e]);g.setDirtyCanvas(!0,!0)}};h.prototype.showLinkMenu=function(a,b){var d=this,f=d.graph.getNodeById(a.origin_id),g=d.graph.getNodeById(a.target_id), -c=!1;f&&f.outputs&&f.outputs[a.origin_slot]&&(c=f.outputs[a.origin_slot].type);var t=!1;g&&g.outputs&&g.outputs[a.target_slot]&&(t=g.inputs[a.target_slot].type);var m=new e.ContextMenu(["Add Node",null,"Delete",null],{event:b,title:null!=a.data?a.data.constructor.name:null,callback:function(b,e,n){switch(b){case "Add Node":h.onMenuAdd(null,null,n,m,function(b){b.inputs&&b.inputs.length&&b.outputs&&b.outputs.length&&f.connectByType(a.origin_slot,b,c)&&(b.connectByType(a.target_slot,g,t),b.pos[0]-= +c=!1;f&&f.outputs&&f.outputs[a.origin_slot]&&(c=f.outputs[a.origin_slot].type);var l=!1;g&&g.outputs&&g.outputs[a.target_slot]&&(l=g.inputs[a.target_slot].type);var m=new e.ContextMenu(["Add Node",null,"Delete",null],{event:b,title:null!=a.data?a.data.constructor.name:null,callback:function(b,e,q){switch(b){case "Add Node":h.onMenuAdd(null,null,q,m,function(b){b.inputs&&b.inputs.length&&b.outputs&&b.outputs.length&&f.connectByType(a.origin_slot,b,c)&&(b.connectByType(a.target_slot,g,l),b.pos[0]-= .5*b.size[0])});break;case "Delete":d.graph.removeLink(a.id)}}});return!1};h.prototype.createDefaultNodeForSlot=function(a){a=a||{};a=Object.assign({nodeFrom:null,slotFrom:null,nodeTo:null,slotTo:null,position:[],nodeType:null,posAdd:[0,0],posSizeFix:[0,0]},a);var b=a.nodeFrom&&null!==a.slotFrom,d=!b&&a.nodeTo&&null!==a.slotTo;if(!b&&!d)return console.warn("No data passed to createDefaultNodeForSlot "+a.nodeFrom+" "+a.slotFrom+" "+a.nodeTo+" "+a.slotTo),!1;if(!a.nodeType)return console.warn("No type to createDefaultNodeForSlot"), !1;var f=b?a.nodeFrom:a.nodeTo,g=b?a.slotFrom:a.slotTo;switch(typeof g){case "string":d=b?f.findOutputSlot(g,!1):f.findInputSlot(g,!1);g=b?f.outputs[g]:f.inputs[g];break;case "object":d=b?f.findOutputSlot(g.name):f.findInputSlot(g.name);break;case "number":d=g;g=b?f.outputs[g]:f.inputs[g];break;default:return console.warn("Cant get slot information "+g),!1}!1!==g&&!1!==d||console.warn("createDefaultNodeForSlot bad slotX "+g+" "+d);f=g.type==e.EVENT?"_event_":g.type;if((g=b?e.slot_types_default_out: -e.slot_types_default_in)&&g[f]){nodeNewType=!1;if("object"==typeof g[f]||"array"==typeof g[f])for(var c in g[f]){if(a.nodeType==g[f][c]||"AUTO"==a.nodeType){nodeNewType=g[f][c];break}}else if(a.nodeType==g[f]||"AUTO"==a.nodeType)nodeNewType=g[f];if(nodeNewType){c=!1;"object"==typeof nodeNewType&&nodeNewType.node&&(c=nodeNewType,nodeNewType=nodeNewType.node);if(g=e.createNode(nodeNewType)){if(c){if(c.properties)for(var t in c.properties)g.addProperty(t,c.properties[t]);if(c.inputs)for(t in g.inputs= -[],c.inputs)g.addOutput(c.inputs[t][0],c.inputs[t][1]);if(c.outputs)for(t in g.outputs=[],c.outputs)g.addOutput(c.outputs[t][0],c.outputs[t][1]);c.title&&(g.title=c.title);c.json&&g.configure(c.json)}this.graph.add(g);g.pos=[a.position[0]+a.posAdd[0]+(a.posSizeFix[0]?a.posSizeFix[0]*g.size[0]:0),a.position[1]+a.posAdd[1]+(a.posSizeFix[1]?a.posSizeFix[1]*g.size[1]:0)];b?a.nodeFrom.connectByType(d,g,f):a.nodeTo.connectByTypeOutput(d,g,f);return!0}console.log("failed creating "+nodeNewType)}}return!1}; +e.slot_types_default_in)&&g[f]){nodeNewType=!1;if("object"==typeof g[f]||"array"==typeof g[f])for(var c in g[f]){if(a.nodeType==g[f][c]||"AUTO"==a.nodeType){nodeNewType=g[f][c];break}}else if(a.nodeType==g[f]||"AUTO"==a.nodeType)nodeNewType=g[f];if(nodeNewType){c=!1;"object"==typeof nodeNewType&&nodeNewType.node&&(c=nodeNewType,nodeNewType=nodeNewType.node);if(g=e.createNode(nodeNewType)){if(c){if(c.properties)for(var l in c.properties)g.addProperty(l,c.properties[l]);if(c.inputs)for(l in g.inputs= +[],c.inputs)g.addOutput(c.inputs[l][0],c.inputs[l][1]);if(c.outputs)for(l in g.outputs=[],c.outputs)g.addOutput(c.outputs[l][0],c.outputs[l][1]);c.title&&(g.title=c.title);c.json&&g.configure(c.json)}this.graph.add(g);g.pos=[a.position[0]+a.posAdd[0]+(a.posSizeFix[0]?a.posSizeFix[0]*g.size[0]:0),a.position[1]+a.posAdd[1]+(a.posSizeFix[1]?a.posSizeFix[1]*g.size[1]:0)];b?a.nodeFrom.connectByType(d,g,f):a.nodeTo.connectByTypeOutput(d,g,f);return!0}console.log("failed creating "+nodeNewType)}}return!1}; h.prototype.showConnectionMenu=function(a){a=a||{};var b=Object.assign({nodeFrom:null,slotFrom:null,nodeTo:null,slotTo:null,e:null},a),d=this,f=b.nodeFrom&&b.slotFrom;a=!f&&b.nodeTo&&b.slotTo;if(!f&&!a)return console.warn("No data passed to showConnectionMenu"),!1;a=f?b.nodeFrom:b.nodeTo;var g=f?b.slotFrom:b.slotTo,c=!1;switch(typeof g){case "string":c=f?a.findOutputSlot(g,!1):a.findInputSlot(g,!1);g=f?a.outputs[g]:a.inputs[g];break;case "object":c=f?a.findOutputSlot(g.name):a.findInputSlot(g.name); -break;case "number":c=g;g=f?a.outputs[g]:a.inputs[g];break;default:return console.warn("Cant get slot information "+g),!1}a=["Add Node",null];d.allow_searchbox&&(a.push("Search"),a.push(null));var t=g.type==e.EVENT?"_event_":g.type,m=f?e.slot_types_default_out:e.slot_types_default_in;if(m&&m[t])if("object"==typeof m[t]||"array"==typeof m[t])for(var v in m[t])a.push(m[t][v]);else a.push(m[t]);var u=new e.ContextMenu(a,{event:b.e,title:(g&&""!=g.name?g.name+(t?" | ":""):"")+(g&&t?t:""),callback:function(a, -e,v){switch(a){case "Add Node":h.onMenuAdd(null,null,v,u,function(a){f?b.nodeFrom.connectByType(c,a,t):b.nodeTo.connectByTypeOutput(c,a,t)});break;case "Search":f?d.showSearchBox(v,{node_from:b.nodeFrom,slot_from:g,type_filter_in:t}):d.showSearchBox(v,{node_to:b.nodeTo,slot_from:g,type_filter_out:t});break;default:d.createDefaultNodeForSlot(Object.assign(b,{position:[b.e.canvasX,b.e.canvasY],nodeType:a}))}}});return!1};h.onShowPropertyEditor=function(a,b,d,f,g){function c(){if(v){var b=v.value;"Number"== -a.type?b=Number(b):"Boolean"==a.type&&(b=!!b);g[m]=b;l.parentNode&&l.parentNode.removeChild(l);g.setDirtyCanvas(!0,!0)}}var m=a.property||"title";b=g[m];var l=document.createElement("div");l.is_modified=!1;l.className="graphdialog";l.innerHTML="";l.close=function(){l.parentNode&&l.parentNode.removeChild(l)};l.querySelector(".name").innerText=m;var v=l.querySelector(".value");v&&(v.value=b,v.addEventListener("blur", -function(a){this.focus()}),v.addEventListener("keydown",function(a){l.is_modified=!0;if(27==a.keyCode)l.close();else if(13==a.keyCode)c();else if(13!=a.keyCode&&"textarea"!=a.target.localName)return;a.preventDefault();a.stopPropagation()}));b=h.active_canvas.canvas;d=b.getBoundingClientRect();var u=f=-20;d&&(f-=d.left,u-=d.top);event?(l.style.left=event.clientX+f+"px",l.style.top=event.clientY+u+"px"):(l.style.left=.5*b.width+f+"px",l.style.top=.5*b.height+u+"px");l.querySelector("button").addEventListener("click", -c);b.parentNode.appendChild(l);v&&v.focus();var A=null;l.addEventListener("mouseleave",function(a){e.dialog_close_on_mouse_leave&&!l.is_modified&&e.dialog_close_on_mouse_leave&&(A=setTimeout(l.close,e.dialog_close_on_mouse_leave_delay))});l.addEventListener("mouseenter",function(a){e.dialog_close_on_mouse_leave&&A&&clearTimeout(A)})};h.prototype.prompt=function(a,b,d,f,g){var c=this;a=a||"";var m=document.createElement("div");m.is_modified=!1;m.className="graphdialog rounded";m.innerHTML=g?" ": -" ";m.close=function(){c.prompt_box=null;m.parentNode&&m.parentNode.removeChild(m)};g=h.active_canvas.canvas;g.parentNode.appendChild(m);1";m.close=function(){m.parentNode&&m.parentNode.removeChild(m)};m.querySelector(".name").innerText=l;var w=m.querySelector(".value");w&&(w.value=b,w.addEventListener("blur", +function(a){this.focus()}),w.addEventListener("keydown",function(a){m.is_modified=!0;if(27==a.keyCode)m.close();else if(13==a.keyCode)c();else if(13!=a.keyCode&&"textarea"!=a.target.localName)return;a.preventDefault();a.stopPropagation()}));b=h.active_canvas.canvas;d=b.getBoundingClientRect();var t=f=-20;d&&(f-=d.left,t-=d.top);event?(m.style.left=event.clientX+f+"px",m.style.top=event.clientY+t+"px"):(m.style.left=.5*b.width+f+"px",m.style.top=.5*b.height+t+"px");m.querySelector("button").addEventListener("click", +c);b.parentNode.appendChild(m);w&&w.focus();var v=null;m.addEventListener("mouseleave",function(a){e.dialog_close_on_mouse_leave&&!m.is_modified&&e.dialog_close_on_mouse_leave&&(v=setTimeout(m.close,e.dialog_close_on_mouse_leave_delay))});m.addEventListener("mouseenter",function(a){e.dialog_close_on_mouse_leave&&v&&clearTimeout(v)})};h.prototype.prompt=function(a,b,d,f,g){var c=this;a=a||"";var l=document.createElement("div");l.is_modified=!1;l.className="graphdialog rounded";l.innerHTML=g?" ": +" ";l.close=function(){c.prompt_box=null;l.parentNode&&l.parentNode.removeChild(l)};g=h.active_canvas.canvas;g.parentNode.appendChild(l);1h.search_limit))break}}u=null;if(Array.prototype.filter)u=Object.keys(e.registered_node_types).filter(g);else for(v in u=[],e.registered_node_types)g(v)&&u.push(v);for(v=0;vh.search_limit);v++);if(b.show_general_after_typefiltered&&(Q.value|| -n.value)){filtered_extra=[];for(v in e.registered_node_types)g(v,{inTypeOverride:Q&&Q.value?"*":!1,outTypeOverride:n&&n.value?"*":!1})&&filtered_extra.push(v);for(v=0;vh.search_limit);v++);}if((Q.value||n.value)&&0==y.childNodes.length&&b.show_general_if_none_on_typefilter){filtered_extra=[];for(v in e.registered_node_types)g(v,{skipFilter:!0})&&filtered_extra.push(v);for(v=0;vh.search_limit);v++);}}}b=Object.assign({slot_from:null,node_from:null,node_to:null,do_type_filter:e.search_filter_enabled,type_filter_in:!1,type_filter_out:!1,show_general_if_none_on_typefilter:!0,show_general_after_typefiltered:!0,hide_on_mouse_leave:e.search_hide_on_mouse_leave,show_all_if_empty:!0,show_all_on_open:e.search_show_all_on_open},b||{});var c=this,m=h.active_canvas,l=m.canvas,v=l.ownerDocument||document,u=document.createElement("div");u.className= -"litegraph litesearchbox graphdialog rounded";u.innerHTML="Search ";b.do_type_filter&&(u.innerHTML+="",u.innerHTML+="");u.innerHTML+="
";v.fullscreenElement?v.fullscreenElement.appendChild(u):(v.body.appendChild(u),v.body.style.overflow="hidden");if(b.do_type_filter)var A= -u.querySelector(".slot_in_type_filter"),x=u.querySelector(".slot_out_type_filter");u.close=function(){c.search_box=null;this.blur();l.focus();v.body.style.overflow="";setTimeout(function(){c.canvas.focus()},20);u.parentNode&&u.parentNode.removeChild(u)};1A.height-200&&(y.style.maxHeight=A.height-a.layerY-20+"px");G.focus();b.show_all_on_open&&g();return u};h.prototype.showEditPropertyValue=function(a,b,d){function f(){g(x.value)}function g(f){e&&e.values&&e.values.constructor===Object&&void 0!=e.values[f]&&(f=e.values[f]);"number"==typeof a.properties[b]&&(f=Number(f));if("array"==c||"object"== -c)f=JSON.parse(f);a.properties[b]=f;a.graph&&a.graph._version++;if(a.onPropertyChanged)a.onPropertyChanged(b,f);if(d.onclose)d.onclose();l.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){d=d||{};var e=a.getPropertyInfo(b),c=e.type,m="";if("string"==c||"number"==c||"array"==c||"object"==c)m="";else if("enum"!=c&&"combo"!=c||!e.values)if("boolean"==c||"toggle"==c)m="";else{console.warn("unknown type: "+c);return}else{m=""}var l=this.createDialog(""+(e.label?e.label:b)+""+m+"",d),x=!1;if("enum"!=c&&"combo"!=c||!e.values)if("boolean"==c||"toggle"==c)(x=l.querySelector("input"))&&x.addEventListener("click", -function(a){l.modified();g(!!x.checked)});else{if(x=l.querySelector("input"))x.addEventListener("blur",function(a){this.focus()}),u=void 0!==a.properties[b]?a.properties[b]:"","string"!==c&&(u=JSON.stringify(u)),x.value=u,x.addEventListener("keydown",function(a){if(27==a.keyCode)l.close();else if(13==a.keyCode)f();else if(13!=a.keyCode){l.modified();return}a.preventDefault();a.stopPropagation()})}else x=l.querySelector("select"),x.addEventListener("change",function(a){l.modified();g(a.target.value)}); -x&&x.focus();l.querySelector("button").addEventListener("click",f);return l}};h.prototype.createDialog=function(a,b){b=Object.assign({checkForInput:!1,closeOnLeave:!0,closeOnLeave_checkModified:!0},b||{});var d=document.createElement("div");d.className="graphdialog";d.innerHTML=a;d.is_modified=!1;a=this.canvas.getBoundingClientRect();var f=-20,g=-20;a&&(f-=a.left,g-=a.top);b.position?(f+=b.position[0],g+=b.position[1]):b.event?(f+=b.event.clientX,g+=b.event.clientY):(f+=.5*this.canvas.width,g+=.5* -this.canvas.height);d.style.left=f+"px";d.style.top=g+"px";this.canvas.parentNode.appendChild(d);b.checkForInput&&(a=[],(a=d.querySelectorAll("input"))&&a.forEach(function(a){a.addEventListener("keydown",function(a){d.modified();if(27==a.keyCode)d.close();else if(13!=a.keyCode)return;a.preventDefault();a.stopPropagation()});a.focus()}));d.modified=function(){d.is_modified=!0};d.close=function(){d.parentNode&&d.parentNode.removeChild(d)};var c=null,m=!1;d.addEventListener("mouseleave",function(a){m|| -(b.closeOnLeave||e.dialog_close_on_mouse_leave)&&!d.is_modified&&e.dialog_close_on_mouse_leave&&(c=setTimeout(d.close,e.dialog_close_on_mouse_leave_delay))});d.addEventListener("mouseenter",function(a){(b.closeOnLeave||e.dialog_close_on_mouse_leave)&&c&&clearTimeout(c)});(a=d.querySelectorAll("select"))&&a.forEach(function(a){a.addEventListener("click",function(a){m++});a.addEventListener("blur",function(a){m=0});a.addEventListener("change",function(a){m=-1})});return d};h.prototype.createPanel=function(a, +d,b.node_from.outputs[f].type)}if(b.node_to){switch(typeof b.slot_from){case "string":f=b.node_to.findInputSlot(b.slot_from);break;case "object":f=b.slot_from.name?b.node_to.findInputSlot(b.slot_from.name):-1;-1==f&&"undefined"!==typeof b.slot_from.slot_index&&(f=b.slot_from.slot_index);break;case "number":f=b.slot_from;break;default:f=0}"undefined"!==typeof b.node_to.inputs[f]&&!1!==f&&-1h.search_limit))break}}q=null;if(Array.prototype.filter)q=Object.keys(e.registered_node_types).filter(g);else for(x in q=[],e.registered_node_types)g(x)&&q.push(x);for(x=0;xh.search_limit);x++);if(b.show_general_after_typefiltered&&(G.value|| +Q.value)){filtered_extra=[];for(x in e.registered_node_types)g(x,{inTypeOverride:G&&G.value?"*":!1,outTypeOverride:Q&&Q.value?"*":!1})&&filtered_extra.push(x);for(x=0;xh.search_limit);x++);}if((G.value||Q.value)&&0==A.childNodes.length&&b.show_general_if_none_on_typefilter){filtered_extra=[];for(x in e.registered_node_types)g(x,{skipFilter:!0})&&filtered_extra.push(x);for(x=0;xh.search_limit);x++);}}}b=Object.assign({slot_from:null,node_from:null,node_to:null,do_type_filter:e.search_filter_enabled,type_filter_in:!1,type_filter_out:!1,show_general_if_none_on_typefilter:!0,show_general_after_typefiltered:!0,hide_on_mouse_leave:e.search_hide_on_mouse_leave,show_all_if_empty:!0,show_all_on_open:e.search_show_all_on_open},b||{});var c=this,l=h.active_canvas,m=l.canvas,w=m.ownerDocument||document,t=document.createElement("div");t.className= +"litegraph litesearchbox graphdialog rounded";t.innerHTML="Search ";b.do_type_filter&&(t.innerHTML+="",t.innerHTML+="");t.innerHTML+="
";w.fullscreenElement?w.fullscreenElement.appendChild(t):(w.body.appendChild(t),w.body.style.overflow="hidden");if(b.do_type_filter)var v= +t.querySelector(".slot_in_type_filter"),C=t.querySelector(".slot_out_type_filter");t.close=function(){c.search_box=null;this.blur();m.focus();w.body.style.overflow="";setTimeout(function(){c.canvas.focus()},20);t.parentNode&&t.parentNode.removeChild(t)};1v.height-200&&(A.style.maxHeight=v.height-a.layerY-20+"px");K.focus();b.show_all_on_open&&g();return t};h.prototype.showEditPropertyValue=function(a,b,d){function f(){g(C.value)}function g(f){e&&e.values&&e.values.constructor===Object&&void 0!=e.values[f]&&(f=e.values[f]);"number"==typeof a.properties[b]&& +(f=Number(f));if("array"==c||"object"==c)f=JSON.parse(f);a.properties[b]=f;a.graph&&a.graph._version++;if(a.onPropertyChanged)a.onPropertyChanged(b,f);if(d.onclose)d.onclose();v.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){d=d||{};var e=a.getPropertyInfo(b),c=e.type,l="";if("string"==c||"number"==c||"array"==c||"object"==c)l="";else if("enum"!=c&&"combo"!=c||!e.values)if("boolean"==c||"toggle"==c)l="";else{console.warn("unknown type: "+c);return}else{l=""}var v=this.createDialog(""+(e.label?e.label:b)+""+l+"",d),C=!1;if("enum"!=c&&"combo"!=c||!e.values)if("boolean"==c||"toggle"==c)(C=v.querySelector("input"))&& +C.addEventListener("click",function(a){v.modified();g(!!C.checked)});else{if(C=v.querySelector("input"))C.addEventListener("blur",function(a){this.focus()}),t=void 0!==a.properties[b]?a.properties[b]:"","string"!==c&&(t=JSON.stringify(t)),C.value=t,C.addEventListener("keydown",function(a){if(27==a.keyCode)v.close();else if(13==a.keyCode)f();else if(13!=a.keyCode){v.modified();return}a.preventDefault();a.stopPropagation()})}else C=v.querySelector("select"),C.addEventListener("change",function(a){v.modified(); +g(a.target.value)});C&&C.focus();v.querySelector("button").addEventListener("click",f);return v}};h.prototype.createDialog=function(a,b){b=Object.assign({checkForInput:!1,closeOnLeave:!0,closeOnLeave_checkModified:!0},b||{});var d=document.createElement("div");d.className="graphdialog";d.innerHTML=a;d.is_modified=!1;a=this.canvas.getBoundingClientRect();var f=-20,g=-20;a&&(f-=a.left,g-=a.top);b.position?(f+=b.position[0],g+=b.position[1]):b.event?(f+=b.event.clientX,g+=b.event.clientY):(f+=.5*this.canvas.width, +g+=.5*this.canvas.height);d.style.left=f+"px";d.style.top=g+"px";this.canvas.parentNode.appendChild(d);b.checkForInput&&(a=[],(a=d.querySelectorAll("input"))&&a.forEach(function(a){a.addEventListener("keydown",function(a){d.modified();if(27==a.keyCode)d.close();else if(13!=a.keyCode)return;a.preventDefault();a.stopPropagation()});a.focus()}));d.modified=function(){d.is_modified=!0};d.close=function(){d.parentNode&&d.parentNode.removeChild(d)};var c=null,l=!1;d.addEventListener("mouseleave",function(a){l|| +(b.closeOnLeave||e.dialog_close_on_mouse_leave)&&!d.is_modified&&e.dialog_close_on_mouse_leave&&(c=setTimeout(d.close,e.dialog_close_on_mouse_leave_delay))});d.addEventListener("mouseenter",function(a){(b.closeOnLeave||e.dialog_close_on_mouse_leave)&&c&&clearTimeout(c)});(a=d.querySelectorAll("select"))&&a.forEach(function(a){a.addEventListener("click",function(a){l++});a.addEventListener("blur",function(a){l=0});a.addEventListener("change",function(a){l=-1})});return d};h.prototype.createPanel=function(a, b){b=b||{};var d=b.window||window,f=document.createElement("div");f.className="litegraph dialog";f.innerHTML="
";f.header=f.querySelector(".dialog-header");b.width&&(f.style.width=b.width+(b.width.constructor===Number?"px":""));b.height&&(f.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(){f.close()}),f.header.appendChild(b));f.title_element=f.querySelector(".dialog-title");f.title_element.innerText=a;f.content=f.querySelector(".dialog-content");f.alt_content=f.querySelector(".dialog-alt-content");f.footer=f.querySelector(".dialog-footer");f.close=function(){if(f.onClose&&"function"==typeof f.onClose)f.onClose();f.parentNode&&f.parentNode.removeChild(f);this.parentNode&& this.parentNode.removeChild(this)};f.toggleAltContent=function(a){if("undefined"!=typeof a){var b=a?"block":"none";a=a?"none":"block"}else b="block"!=f.alt_content.style.display?"block":"none",a="block"!=f.alt_content.style.display?"none":"block";f.alt_content.style.display=b;f.content.style.display=a};f.toggleFooterVisibility=function(a){f.footer.style.display="undefined"!=typeof a?a?"block":"none":"block"!=f.footer.style.display?"block":"none"};f.clear=function(){this.content.innerHTML=""};f.addHTML= -function(a,b,d){var g=document.createElement("div");b&&(g.className=b);g.innerHTML=a;d?f.footer.appendChild(g):f.content.appendChild(g);return g};f.addButton=function(a,b,d){var g=document.createElement("button");g.innerText=a;g.options=d;g.classList.add("btn");g.addEventListener("click",b);f.footer.appendChild(g);return g};f.addSeparator=function(){var a=document.createElement("div");a.className="separator";f.content.appendChild(a)};f.addWidget=function(a,b,c,m,v){function g(a,b){m.callback&&m.callback(a, -b,m);v&&v(a,b,m)}m=m||{};var n=String(c);a=a.toLowerCase();"number"==a&&(n=c.toFixed(3));var x=document.createElement("div");x.className="property";x.innerHTML="";x.querySelector(".property_name").innerText=m.label||b;var l=x.querySelector(".property_value");l.innerText=n;x.dataset.property=b;x.dataset.type=m.type||a;x.options=m;x.value=c;if("code"==a)x.addEventListener("click",function(a){f.inner_showCodePad(this.dataset.property)}); -else if("boolean"==a)x.classList.add("boolean"),c&&x.classList.add("bool-on"),x.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";g(a,this.value)});else if("string"==a||"number"==a)l.setAttribute("contenteditable",!0),l.addEventListener("keydown",function(b){"Enter"!=b.code||"string"==a&&b.shiftKey||(b.preventDefault(),this.blur())}),l.addEventListener("blur", -function(){var a=this.innerText,b=this.parentNode.dataset.property;"number"==this.parentNode.dataset.type&&(a=Number(a));g(b,a)});else if("enum"==a||"combo"==a)n=h.getPropertyPrintableValue(c,m.values),l.innerText=n,l.addEventListener("click",function(a){var b=this.parentNode.dataset.property,f=this;new e.ContextMenu(m.values||[],{event:a,className:"dark",callback:function(a,d,e){f.innerText=a;g(b,a);return!1}},d)});f.content.appendChild(x);return x};if(f.onOpen&&"function"==typeof f.onOpen)f.onOpen(); +function(a,b,d){var g=document.createElement("div");b&&(g.className=b);g.innerHTML=a;d?f.footer.appendChild(g):f.content.appendChild(g);return g};f.addButton=function(a,b,d){var g=document.createElement("button");g.innerText=a;g.options=d;g.classList.add("btn");g.addEventListener("click",b);f.footer.appendChild(g);return g};f.addSeparator=function(){var a=document.createElement("div");a.className="separator";f.content.appendChild(a)};f.addWidget=function(a,b,c,l,m){function g(a,b){l.callback&&l.callback(a, +b,l);m&&m(a,b,l)}l=l||{};var q=String(c);a=a.toLowerCase();"number"==a&&(q=c.toFixed(3));var C=document.createElement("div");C.className="property";C.innerHTML="";C.querySelector(".property_name").innerText=l.label||b;var x=C.querySelector(".property_value");x.innerText=q;C.dataset.property=b;C.dataset.type=l.type||a;C.options=l;C.value=c;if("code"==a)C.addEventListener("click",function(a){f.inner_showCodePad(this.dataset.property)}); +else if("boolean"==a)C.classList.add("boolean"),c&&C.classList.add("bool-on"),C.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";g(a,this.value)});else if("string"==a||"number"==a)x.setAttribute("contenteditable",!0),x.addEventListener("keydown",function(b){"Enter"!=b.code||"string"==a&&b.shiftKey||(b.preventDefault(),this.blur())}),x.addEventListener("blur", +function(){var a=this.innerText,b=this.parentNode.dataset.property;"number"==this.parentNode.dataset.type&&(a=Number(a));g(b,a)});else if("enum"==a||"combo"==a)q=h.getPropertyPrintableValue(c,l.values),x.innerText=q,x.addEventListener("click",function(a){var b=this.parentNode.dataset.property,f=this;new e.ContextMenu(l.values||[],{event:a,className:"dark",callback:function(a,d,c){f.innerText=a;g(b,a);return!1}},d)});f.content.appendChild(C);return C};if(f.onOpen&&"function"==typeof f.onOpen)f.onOpen(); return f};h.getPropertyPrintableValue=function(a,b){if(!b||b.constructor===Array)return String(a);if(b.constructor===Object){var d="",f;for(f in b)if(b[f]==a){d=f;break}return String(a)+" ("+d+")"}};h.prototype.closePanels=function(){var a=document.querySelector("#node-panel");a&&a.close();(a=document.querySelector("#option-panel"))&&a.close()};h.prototype.showShowGraphOptionsPanel=function(a,b,d,f){if(this.constructor&&"HTMLDivElement"==this.constructor.name){if(!(b&&b.event&&b.event.target&&b.event.target.lgraphcanvas)){console.warn("Canvas not found"); return}var g=b.event.target.lgraphcanvas}else g=this;g.closePanels();a=g.getCanvasWindow();panel=g.createPanel("Options",{closable:!0,window:a,onOpen:function(){g.OPTIONPANEL_IS_OPEN=!0},onClose:function(){g.OPTIONPANEL_IS_OPEN=!1;g.options_panel=null}});g.options_panel=panel;panel.id="option-panel";panel.classList.add("settings");(function(){panel.content.innerHTML="";var a=function(a,b,d){d&&d.key&&(a=d.key);d.values&&(b=Object.values(d.values).indexOf(b));g[a]=b},b=e.availableCanvasOptions;b.sort(); for(var d in b){var f=b[d];panel.addWidget("boolean",f,g[f],{key:f,on:"True",off:"False"},a)}panel.addWidget("combo","Render mode",e.LINK_RENDER_MODES[g.links_render_mode],{key:"links_render_mode",values:e.LINK_RENDER_MODES},a);panel.addSeparator();panel.footer.innerHTML=""})();g.canvas.parentNode.appendChild(panel)};h.prototype.showShowNodePanel=function(a){function b(){g.content.innerHTML="";g.addHTML(""+a.type+""+(a.constructor.desc||"")+""); g.addHTML("

Properties

");var b=function(b,d){f.graph.beforeChange(a);switch(b){case "Title":a.title=d;break;case "Mode":b=Object.values(e.NODE_MODES).indexOf(d);0<=b&&e.NODE_MODES[b]?a.changeMode(b):console.warn("unexpected mode: "+d);break;case "Color":h.node_colors[d]?(a.color=h.node_colors[d].color,a.bgcolor=h.node_colors[d].bgcolor):console.warn("unexpected color: "+d);break;default:a.setProperty(b,d)}f.graph.afterChange();f.dirty_canvas=!0};g.addWidget("string","Title",a.title,{},b); -g.addWidget("combo","Mode",e.NODE_MODES[a.mode],{values:e.NODE_MODES},b);var d="";void 0!==a.color&&(d=Object.keys(h.node_colors).filter(function(b){return h.node_colors[b].color==a.color}));g.addWidget("combo","Color",d,{values:Object.keys(h.node_colors)},b);for(var c in a.properties){d=a.properties[c];var v=a.getPropertyInfo(c);a.onAddPropertyToPanel&&a.onAddPropertyToPanel(c,g)||g.addWidget(v.widget||v.type,c,d,v,b)}g.addSeparator();if(a.onShowCustomPanelInfo)a.onShowCustomPanelInfo(g);g.footer.innerHTML= +g.addWidget("combo","Mode",e.NODE_MODES[a.mode],{values:e.NODE_MODES},b);var d="";void 0!==a.color&&(d=Object.keys(h.node_colors).filter(function(b){return h.node_colors[b].color==a.color}));g.addWidget("combo","Color",d,{values:Object.keys(h.node_colors)},b);for(var c in a.properties){d=a.properties[c];var l=a.getPropertyInfo(c);a.onAddPropertyToPanel&&a.onAddPropertyToPanel(c,g)||g.addWidget(l.widget||l.type,c,d,l,b)}g.addSeparator();if(a.onShowCustomPanelInfo)a.onShowCustomPanelInfo(g);g.footer.innerHTML= "";g.addButton("Delete",function(){a.block_delete||(a.graph.remove(a),g.close())}).classList.add("delete")}this.SELECTED_NODE=a;this.closePanels();var d=this.getCanvasWindow(),f=this,g=this.createPanel(a.title||"",{closable:!0,window:d,onOpen:function(){f.NODEPANEL_IS_OPEN=!0},onClose:function(){f.NODEPANEL_IS_OPEN=!1;f.node_panel=null}});f.node_panel=g;g.id="node-panel";g.node=a;g.classList.add("settings");g.inner_showCodePad=function(d){g.classList.remove("settings");g.classList.add("centered"); g.alt_content.innerHTML="";var f=g.alt_content.querySelector("textarea"),c=function(){g.toggleAltContent(!1);g.toggleFooterVisibility(!0);f.parentNode.removeChild(f);g.classList.add("settings");g.classList.remove("centered");b()};f.value=a.properties[d];f.addEventListener("keydown",function(b){"Enter"==b.code&&b.ctrlKey&&(a.setProperty(d,f.value),c())});g.toggleAltContent(!0);g.toggleFooterVisibility(!1);f.style.height="calc(100% - 40px)";var e=g.addButton("Assign", function(){a.setProperty(d,f.value);c()});g.alt_content.appendChild(e);e=g.addButton("Close",c);e.style.float="right";g.alt_content.appendChild(e)};b();this.canvas.parentNode.appendChild(g)};h.prototype.showSubgraphPropertiesDialog=function(a){function b(){f.clear();if(a.inputs)for(var d=0;d","subgraph_property"); @@ -332,243 +332,244 @@ null,{content:"Properties",has_submenu:!0,callback:h.onShowMenuNodeProperties},n a.onGetInputs();d&&d.length&&(b[0].disabled=!1)}a.onGetOutputs&&(d=a.onGetOutputs())&&d.length&&(b[1].disabled=!1);a.getExtraMenuOptions&&(d=a.getExtraMenuOptions(this,b))&&(d.push(null),b=d.concat(b));!1!==a.clonable&&b.push({content:"Clone",callback:h.onMenuNodeClone});1Name", -f),m=e.querySelector("input");m&&c&&(m.value=c.label||"");var v=function(){a.graph.beforeChange();m.value&&(c&&(c.label=m.value),d.setDirty(!0));e.close();a.graph.afterChange()};e.querySelector("button").addEventListener("click",v);m.addEventListener("keydown",function(a){e.is_modified=!0;if(27==a.keyCode)e.close();else if(13==a.keyCode)v();else if(13!=a.keyCode&&"textarea"!=a.target.localName)return;a.preventDefault();a.stopPropagation()});m.focus()}},extra:a};a&&(c.title=a.type);var m=null;a&&(m= -a.getSlotInPosition(b.canvasX,b.canvasY),h.active_node=a);m?(g=[],a.getSlotMenuOptions?g=a.getSlotMenuOptions(m):(m&&m.output&&m.output.links&&m.output.links.length&&g.push({content:"Disconnect Links",slot:m}),b=m.input||m.output,b.removable&&g.push(b.locked?"Cannot remove":{content:"Remove Slot",slot:m}),b.nameLocked||g.push({content:"Rename Slot",slot:m})),c.title=(m.input?m.input.type:m.output.type)||"*",m.input&&m.input.type==e.ACTION&&(c.title="Action"),m.output&&m.output.type==e.EVENT&&(c.title= -"Event")):a?g=this.getNodeMenuOptions(a):(g=this.getCanvasMenuOptions(),(m=this.graph.getGroupOnPos(b.canvasX,b.canvasY))&&g.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:m,options:this.getGroupMenuOptions(m)}}));g&&new e.ContextMenu(g,c,f)};e.compareObjects=function(a,b){for(var d in a)if(a[d]!=b[d])return!1;return!0};e.distance=I;e.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")+")"};e.isInsideRectangle=E;e.growBounding=function(a,b,d){ba[2]&&(a[2]=b);da[3]&&(a[3]=d)};e.isInsideBounding=function(a,b){return a[0]b[1][0]||a[1]>b[1][1]?!1:!0};e.overlapBounding=H;e.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),d=0,f,g,c=0;6>c;c+=2)f="0123456789ABCDEF".indexOf(a.charAt(c)),g="0123456789ABCDEF".indexOf(a.charAt(c+1)),b[d]=16*f+g,d++;return b}; +f),l=e.querySelector("input");l&&c&&(l.value=c.label||"");var t=function(){a.graph.beforeChange();l.value&&(c&&(c.label=l.value),d.setDirty(!0));e.close();a.graph.afterChange()};e.querySelector("button").addEventListener("click",t);l.addEventListener("keydown",function(a){e.is_modified=!0;if(27==a.keyCode)e.close();else if(13==a.keyCode)t();else if(13!=a.keyCode&&"textarea"!=a.target.localName)return;a.preventDefault();a.stopPropagation()});l.focus()}},extra:a};a&&(c.title=a.type);var l=null;a&&(l= +a.getSlotInPosition(b.canvasX,b.canvasY),h.active_node=a);l?(g=[],a.getSlotMenuOptions?g=a.getSlotMenuOptions(l):(l&&l.output&&l.output.links&&l.output.links.length&&g.push({content:"Disconnect Links",slot:l}),b=l.input||l.output,b.removable&&g.push(b.locked?"Cannot remove":{content:"Remove Slot",slot:l}),b.nameLocked||g.push({content:"Rename Slot",slot:l})),c.title=(l.input?l.input.type:l.output.type)||"*",l.input&&l.input.type==e.ACTION&&(c.title="Action"),l.output&&l.output.type==e.EVENT&&(c.title= +"Event")):a?g=this.getNodeMenuOptions(a):(g=this.getCanvasMenuOptions(),(l=this.graph.getGroupOnPos(b.canvasX,b.canvasY))&&g.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:l,options:this.getGroupMenuOptions(l)}}));g&&new e.ContextMenu(g,c,f)};e.compareObjects=function(a,b){for(var d in a)if(a[d]!=b[d])return!1;return!0};e.distance=E;e.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")+")"};e.isInsideRectangle=D;e.growBounding=function(a,b,d){ba[2]&&(a[2]=b);da[3]&&(a[3]=d)};e.isInsideBounding=function(a,b){return a[0]b[1][0]||a[1]>b[1][1]?!1:!0};e.overlapBounding=J;e.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),d=0,f,g,c=0;6>c;c+=2)f="0123456789ABCDEF".indexOf(a.charAt(c)),g="0123456789ABCDEF".indexOf(a.charAt(c+1)),b[d]=16*f+g,d++;return b}; e.num2hex=function(a){for(var b="#",d,f,g=0;3>g;g++)d=a[g]/16,f=a[g]%16,b+="0123456789ABCDEF".charAt(d)+"0123456789ABCDEF".charAt(f);return b};L.prototype.addItem=function(a,b,d){function f(a){var b=this.value;b&&b.has_submenu&&g.call(this,a)}function g(a){var b=this.value,f=!0;c.current_submenu&&c.current_submenu.close(a);if(d.callback){var g=d.callback.call(this,b,d,a,c,d.node);!0===g&&(f=!1)}if(b&&(b.callback&&!d.ignore_item_callbacks&&!0!==b.disabled&&(g=b.callback.call(this,b,d,a,c,d.extra), -!0===g&&(f=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";new c.constructor(b.submenu.options,{callback:b.submenu.callback,event:a,parentMenu:c,ignore_item_callbacks:b.submenu.ignore_item_callbacks,title:b.submenu.title,extra:b.submenu.extra,autoopen:d.autoopen});f=!1}f&&!c.lock&&c.close()}var c=this;d=d||{};var m=document.createElement("div");m.className="litemenu-entry submenu";var l=!1;if(null===b)m.classList.add("separator");else{m.innerHTML=b&&b.title?b.title: -a;if(m.value=b)b.disabled&&(l=!0,m.classList.add("disabled")),(b.submenu||b.has_submenu)&&m.classList.add("has_submenu");"function"==typeof b?(m.dataset.value=a,m.onclick_callback=b):m.dataset.value=b;b.className&&(m.className+=" "+b.className)}this.root.appendChild(m);l||m.addEventListener("click",g);!l&&d.autoopen&&e.pointerListenerAdd(m,"enter",f);return m};L.prototype.close=function(a,b){this.root.parentNode&&this.root.parentNode.removeChild(this.root);this.parentMenu&&!b&&(this.parentMenu.lock= +!0===g&&(f=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";new c.constructor(b.submenu.options,{callback:b.submenu.callback,event:a,parentMenu:c,ignore_item_callbacks:b.submenu.ignore_item_callbacks,title:b.submenu.title,extra:b.submenu.extra,autoopen:d.autoopen});f=!1}f&&!c.lock&&c.close()}var c=this;d=d||{};var l=document.createElement("div");l.className="litemenu-entry submenu";var m=!1;if(null===b)l.classList.add("separator");else{l.innerHTML=b&&b.title?b.title: +a;if(l.value=b)b.disabled&&(m=!0,l.classList.add("disabled")),(b.submenu||b.has_submenu)&&l.classList.add("has_submenu");"function"==typeof b?(l.dataset.value=a,l.onclick_callback=b):l.dataset.value=b;b.className&&(l.className+=" "+b.className)}this.root.appendChild(l);m||l.addEventListener("click",g);!m&&d.autoopen&&e.pointerListenerAdd(l,"enter",f);return l};L.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&&!L.isCursorOverElement(a,this.parentMenu.root)&&L.trigger(this.parentMenu.root,e.pointerevents_method+"leave",a));this.current_submenu&&this.current_submenu.close(a,!0);this.root.closing_timer&&clearTimeout(this.root.closing_timer)};L.trigger=function(a,b,d,f){var g=document.createEvent("CustomEvent");g.initCustomEvent(b,!0,!0,d);g.srcElement=f;a.dispatchEvent?a.dispatchEvent(g):a.__events&&a.__events.dispatchEvent(g);return g}; L.prototype.getTopMenu=function(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this};L.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event};L.isCursorOverElement=function(a,b){var d=a.clientX;a=a.clientY;return(b=b.getBoundingClientRect())?a>b.top&&ab.left&&dMath.abs(b))return f[1];a=(a-f[0])/b;return f[1]*(1-a)+g[1]*a}}return 0}};J.prototype.draw=function(a,b,d,f,g,c){if(d=this.points){this.size=b;var e=b[0]-2*this.margin;b=b[1]-2*this.margin;g=g||"#666";a.save();a.translate(this.margin,this.margin);f&&(a.fillStyle="#111",a.fillRect(0,0,e,b),a.fillStyle="#222",a.fillRect(.5*e,0,1,b),a.strokeStyle="#333", -a.strokeRect(0,0,e,b));a.strokeStyle=g;c&&(a.globalAlpha=.5);a.beginPath();for(f=0;fa[1])){var f=this.size[0]-2*this.margin,g=this.size[1]-2*this.margin,c=a[0]-this.margin;a=a[1]-this.margin; -this.selected=this.getCloserPoint([c,a],30/b.ds.scale);-1==this.selected&&(b=[c/f,1-a/g],d.push(b),d.sort(function(a,b){return a[0]-b[0]}),this.selected=d.indexOf(b),this.must_update=!0);if(-1!=this.selected)return!0}};J.prototype.onMouseMove=function(a,b){var d=this.points;if(d){var f=this.selected;if(!(0>f)){var g=(a[0]-this.margin)/(this.size[0]-2*this.margin),c=(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=d[f]){var e=0==f||f==d.length-1;!e&&(-10>a[0]||a[0]>this.size[0]+10||-10>a[1]||a[1]>this.size[1]+10)?(d.splice(f,1),this.selected=-1):(b[0]=e?0==f?0:1:G(g,0,1),b[1]=1-G(c,0,1),d.sort(function(a,b){return a[0]-b[0]}),this.selected=d.indexOf(b),this.must_update=!0)}}}};J.prototype.onMouseUp=function(a,b){this.selected=-1;return!1};J.prototype.getCloserPoint=function(a,b){var d=this.points;if(!d)return-1;b=b||30;for(var f=this.size[0]-2*this.margin,g=this.size[1]-2*this.margin,c=d.length,e=[0,0], -m=1E6,v=-1,l=0;lm||A>b||(v=l,m=A)}return v};e.CurveEditor=J;e.getParameterNames=function(a){return(a+"").replace(/[/][/].*$/gm,"").replace(/\s+/g,"").replace(/[/][*][^/*]*[*][/]/g,"").split("){",1)[0].replace(/^[^(]*[(]/,"").replace(/=[^,]+/g,"").split(",").filter(Boolean)};e.pointerListenerAdd=function(a,b,d,f){f=void 0===f?!1:f;if(a&&a.addEventListener&&b&&"function"===typeof d){var g=e.pointerevents_method;if("pointer"==g&&!window.PointerEvent)switch(console.warn("sMethod=='pointer' && !window.PointerEvent"), +b.prototype.__lookupSetter__(d)))};H.sampleCurve=function(a,b){if(b){for(var d=0;dMath.abs(b))return f[1];a=(a-f[0])/b;return f[1]*(1-a)+g[1]*a}}return 0}};H.prototype.draw=function(a,b,d,f,g,c){if(d=this.points){this.size=b;var e=b[0]-2*this.margin;b=b[1]-2*this.margin;g=g||"#666";a.save();a.translate(this.margin,this.margin);f&&(a.fillStyle="#111",a.fillRect(0,0,e,b),a.fillStyle="#222",a.fillRect(.5*e,0,1,b),a.strokeStyle="#333", +a.strokeRect(0,0,e,b));a.strokeStyle=g;c&&(a.globalAlpha=.5);a.beginPath();for(f=0;fa[1])){var f=this.size[0]-2*this.margin,g=this.size[1]-2*this.margin,c=a[0]-this.margin;a=a[1]-this.margin; +this.selected=this.getCloserPoint([c,a],30/b.ds.scale);-1==this.selected&&(b=[c/f,1-a/g],d.push(b),d.sort(function(a,b){return a[0]-b[0]}),this.selected=d.indexOf(b),this.must_update=!0);if(-1!=this.selected)return!0}};H.prototype.onMouseMove=function(a,b){var d=this.points;if(d){var f=this.selected;if(!(0>f)){var g=(a[0]-this.margin)/(this.size[0]-2*this.margin),c=(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=d[f]){var e=0==f||f==d.length-1;!e&&(-10>a[0]||a[0]>this.size[0]+10||-10>a[1]||a[1]>this.size[1]+10)?(d.splice(f,1),this.selected=-1):(b[0]=e?0==f?0:1:F(g,0,1),b[1]=1-F(c,0,1),d.sort(function(a,b){return a[0]-b[0]}),this.selected=d.indexOf(b),this.must_update=!0)}}}};H.prototype.onMouseUp=function(a,b){this.selected=-1;return!1};H.prototype.getCloserPoint=function(a,b){var d=this.points;if(!d)return-1;b=b||30;for(var f=this.size[0]-2*this.margin,g=this.size[1]-2*this.margin,c=d.length,e=[0,0], +l=1E6,m=-1,t=0;tl||w>b||(m=t,l=w)}return m};e.CurveEditor=H;e.getParameterNames=function(a){return(a+"").replace(/[/][/].*$/gm,"").replace(/\s+/g,"").replace(/[/][*][^/*]*[*][/]/g,"").split("){",1)[0].replace(/^[^(]*[(]/,"").replace(/=[^,]+/g,"").split(",").filter(Boolean)};e.pointerListenerAdd=function(a,b,d,f){f=void 0===f?!1:f;if(a&&a.addEventListener&&b&&"function"===typeof d){var g=e.pointerevents_method;if("pointer"==g&&!window.PointerEvent)switch(console.warn("sMethod=='pointer' && !window.PointerEvent"), console.log("Converting pointer["+b+"] : down move up cancel enter TO touchstart touchmove touchend, etc .."),b){case "down":g="touch";b="start";break;case "move":g="touch";break;case "up":g="touch";b="end";break;case "cancel":g="touch";break;case "enter":console.log("debug: Should I send a move event?");break;default:console.warn("PointerEvent not available in this browser ? The event "+b+" would not be called")}switch(b){case "down":case "up":case "move":case "over":case "out":case "enter":a.addEventListener(g+ b,d,f);case "leave":case "cancel":case "gotpointercapture":case "lostpointercapture":if("mouse"!=g)return a.addEventListener(g+b,d,f);default:return a.addEventListener(b,d,f)}}};e.pointerListenerRemove=function(a,b,d,f){f=void 0===f?!1:f;if(a&&a.removeEventListener&&b&&"function"===typeof d)switch(b){case "down":case "up":case "move":case "over":case "out":case "enter":"pointer"!=e.pointerevents_method&&"mouse"!=e.pointerevents_method||a.removeEventListener(e.pointerevents_method+b,d,f);case "leave":case "cancel":case "gotpointercapture":case "lostpointercapture":if("pointer"== -e.pointerevents_method)return a.removeEventListener(e.pointerevents_method+b,d,f);default:return a.removeEventListener(b,d,f)}};B.clamp=G;"undefined"==typeof window||window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)})})(this); +e.pointerevents_method)return a.removeEventListener(e.pointerevents_method+b,d,f);default:return a.removeEventListener(b,d,f)}};y.clamp=F;"undefined"==typeof window||window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)})})(this); "undefined"!=typeof exports&&(exports.LiteGraph=this.LiteGraph,exports.LGraph=this.LGraph,exports.LLink=this.LLink,exports.LGraphNode=this.LGraphNode,exports.LGraphGroup=this.LGraphGroup,exports.DragAndScale=this.DragAndScale,exports.LGraphCanvas=this.LGraphCanvas,exports.ContextMenu=this.ContextMenu); -(function(B){function c(){this.addOutput("in ms","number");this.addOutput("in sec","number")}function k(){this.size=[140,80];this.properties={enabled:!0};this.enabled=!0;this.subgraph=new z.LGraph;this.subgraph._subgraph_node=this;this.subgraph._is_subgraph=!0;this.subgraph.onTrigger=this.onSubgraphTrigger.bind(this);this.subgraph.onInputAdded=this.onSubgraphNewInput.bind(this);this.subgraph.onInputRenamed=this.onSubgraphRenamedInput.bind(this);this.subgraph.onInputTypeChanged=this.onSubgraphTypeChangeInput.bind(this); -this.subgraph.onInputRemoved=this.onSubgraphRemovedInput.bind(this);this.subgraph.onOutputAdded=this.onSubgraphNewOutput.bind(this);this.subgraph.onOutputRenamed=this.onSubgraphRenamedOutput.bind(this);this.subgraph.onOutputTypeChanged=this.onSubgraphTypeChangeOutput.bind(this);this.subgraph.onOutputRemoved=this.onSubgraphRemovedOutput.bind(this)}function q(){this.addOutput("","number");this.name_in_graph="";this.properties={name:"",type:"number",value:0};var a=this;this.name_widget=this.addWidget("text", +(function(y){function c(){this.addOutput("in ms","number");this.addOutput("in sec","number")}function k(){this.size=[140,80];this.properties={enabled:!0};this.enabled=!0;this.subgraph=new I.LGraph;this.subgraph._subgraph_node=this;this.subgraph._is_subgraph=!0;this.subgraph.onTrigger=this.onSubgraphTrigger.bind(this);this.subgraph.onInputAdded=this.onSubgraphNewInput.bind(this);this.subgraph.onInputRenamed=this.onSubgraphRenamedInput.bind(this);this.subgraph.onInputTypeChanged=this.onSubgraphTypeChangeInput.bind(this); +this.subgraph.onInputRemoved=this.onSubgraphRemovedInput.bind(this);this.subgraph.onOutputAdded=this.onSubgraphNewOutput.bind(this);this.subgraph.onOutputRenamed=this.onSubgraphRenamedOutput.bind(this);this.subgraph.onOutputTypeChanged=this.onSubgraphTypeChangeOutput.bind(this);this.subgraph.onOutputRemoved=this.onSubgraphRemovedOutput.bind(this)}function n(){this.addOutput("","number");this.name_in_graph="";this.properties={name:"",type:"number",value:0};var a=this;this.name_widget=this.addWidget("text", "Name",this.properties.name,function(b){b&&a.setProperty("name",b)});this.type_widget=this.addWidget("text","Type",this.properties.type,function(b){a.setProperty("type",b)});this.value_widget=this.addWidget("number","Value",this.properties.value,function(b){a.setProperty("value",b)});this.widgets_up=!0;this.size=[180,90]}function r(){this.addInput("","");this.name_in_graph="";this.properties={name:"",type:""};this.name_widget=this.addWidget("text","Name",this.properties.name,"name");this.type_widget= -this.addWidget("text","Type",this.properties.type,"type");this.widgets_up=!0;this.size=[180,60]}function w(){this.addOutput("value","number");this.addProperty("value",1);this.widget=this.addWidget("number","value",1,"value");this.widgets_up=!0;this.size=[180,30]}function h(){this.addOutput("bool","boolean");this.addProperty("value",!0);this.widget=this.addWidget("toggle","value",!0,"value");this.widgets_up=this.serialize_widgets=!0;this.size=[140,30]}function I(){this.addOutput("string","string"); -this.addProperty("value","");this.widget=this.addWidget("text","value","","value");this.widgets_up=!0;this.size=[180,30]}function E(){this.addOutput("obj","object");this.size=[120,30];this._object={}}function H(){this.addInput("url","string");this.addOutput("file","string");this.addProperty("url","");this.addProperty("type","text");this.widget=this.addWidget("text","url","","url");this._data=null}function L(){this.addOutput("data","object");this.addProperty("value","");this.widget=this.addWidget("text", -"json","","value");this.widgets_up=!0;this.size=[140,30];this._value=null}function J(){this._value=[];this.addInput("json","");this.addOutput("arrayOut","array");this.addOutput("length","number");this.addProperty("value","[]");this.widget=this.addWidget("text","array",this.properties.value,"value");this.widgets_up=!0;this.size=[140,50]}function G(){this.addInput("arr","array");this.addInput("value","");this.addOutput("arr","array");this.properties={index:0};this.widget=this.addWidget("number","i", -this.properties.index,"index",{precision:0,step:10,min:0})}function e(){this.addInput("array","array,table,string");this.addInput("index","number");this.addOutput("value","");this.addProperty("index",0)}function K(){this.addInput("table","table");this.addInput("row","number");this.addInput("col","number");this.addOutput("value","");this.addProperty("row",0);this.addProperty("column",0)}function D(){this.addInput("obj","object");this.addOutput("property",0);this.addProperty("value",0);this.widget= -this.addWidget("text","prop.","",this.setValue.bind(this));this.widgets_up=!0;this.size=[140,30];this._value=null}function M(){this.addInput("obj","");this.addOutput("keys","array");this.size=[140,30]}function m(){this.addInput("obj","");this.addInput("value","");this.addOutput("obj","");this.properties={property:""};this.name_widget=this.addWidget("text","prop.",this.properties.property,"property")}function l(){this.addInput("A","object");this.addInput("B","object");this.addOutput("out","object"); -this._result={};var a=this;this.addWidget("button","clear","",function(){a._result={}});this.size=this.computeSize()}function A(){this.size=[60,30];this.addInput("in");this.addOutput("out");this.properties={varname:"myname",container:A.LITEGRAPH};this.value=null}function O(a){return a&&null!=a.length?Number(a.length):0}function O(a){return a&&null!=a.length?Number(a.length):0}function a(){this.size=[60,30];this.addInput("data",0);this.addInput("download",z.ACTION);this.properties={filename:"data.json"}; -this.value=null;var a=this;this.addWidget("button","Download","",function(b){a.value&&a.downloadAsFile()})}function b(){this.size=[60,30];this.addInput("value",0,{label:""});this.value=0}function d(){this.addInput("in",0);this.addOutput("out",0);this.size=[40,30]}function f(){this.mode=z.ON_EVENT;this.size=[80,30];this.addProperty("msg","");this.addInput("log",z.EVENT);this.addInput("msg",0)}function g(){this.mode=z.ON_EVENT;this.addProperty("msg","");this.addInput("",z.EVENT);this.widget=this.addWidget("text", -"Text","","msg");this.widgets_up=!0;this.size=[200,30]}function n(){this.size=[60,30];this.addProperty("onExecute","return A;");this.addInput("A",0);this.addInput("B",0);this.addOutput("out",0);this._func=null;this.data={}}function t(){this.addInput("A",0);this.addInput("B",0);this.addOutput("true","boolean");this.addOutput("false","boolean");this.addProperty("A",1);this.addProperty("B",1);this.addProperty("OP","==","enum",{values:t.values});this.addWidget("combo","Op.",this.properties.OP,{property:"OP", -values:t.values});this.size=[80,60]}var z=B.LiteGraph;c.title="Time";c.desc="Time";c.prototype.onExecute=function(){this.setOutputData(0,1E3*this.graph.globaltime);this.setOutputData(1,this.graph.globaltime)};z.registerNodeType("basic/time",c);k.title="Subgraph";k.desc="Graph inside a node";k.title_color="#334";k.prototype.onGetInputs=function(){return[["enabled","boolean"]]};k.prototype.onDblClick=function(a,b,d){var f=this;setTimeout(function(){d.openSubgraph(f.subgraph)},10)};k.prototype.onAction= -function(a,b){this.subgraph.onAction(a,b)};k.prototype.onExecute=function(){if(this.enabled=this.getInputOrProperty("enabled")){if(this.inputs)for(var a=0;aa&&(b[0]a&&(b[0]=c?this.trigger(null,e,h):this._pending.push([c,e])};E.prototype.onExecute= -function(c,e){c=1E3*this.graph.elapsed_time;this.isInputConnected(1)&&(this.properties.time_in_ms=this.getInputData(1));for(var h=0;h=c?this.trigger(null,e,h):this._pending.push([c,e])};D.prototype.onExecute= +function(c,e){c=1E3*this.graph.elapsed_time;this.isInputConnected(1)&&(this.properties.time_in_ms=this.getInputData(1));for(var h=0;he[1]))return this.old_y=c.canvasY,this.captureInput(!0),this.mouse_captured=!0};q.prototype.onMouseMove=function(c){if(this.mouse_captured){var e=this.old_y-c.canvasY;c.shiftKey&&(e*=10);if(c.metaKey||c.altKey)e*=.1;this.old_y=c.canvasY;c=this._remainder+e/q.pixels_threshold;this._remainder=c%1;c=clamp(this.properties.value+ -(c|0)*this.properties.step,this.properties.min,this.properties.max);this.properties.value=c;this.graph._version++;this.setDirtyCanvas(!0)}};q.prototype.onMouseUp=function(c,e){200>c.click_time&&(this.properties.value=clamp(this.properties.value+(e[1]>.5*this.size[1]?-1:1)*this.properties.step,this.properties.min,this.properties.max),this.graph._version++,this.setDirtyCanvas(!0));this.mouse_captured&&(this.mouse_captured=!1,this.captureInput(!1))};J.registerNodeType("widget/number",q);r.title="Combo"; -r.desc="Widget to select from a list";r.prototype.onExecute=function(){this.setOutputData(0,this.properties.value)};r.prototype.onPropertyChanged=function(c,e){"values"==c?(this._values=e.split(";"),this.widget.options.values=this._values):"value"==c&&(this.widget.value=e)};J.registerNodeType("widget/combo",r);w.title="Knob";w.desc="Circular controller";w.size=[80,100];w.prototype.onDrawForeground=function(c){if(!this.flags.collapsed){-1==this.value&&(this.value=(this.properties.value-this.properties.min)/ +function(){var c=this.getInputData(0);null!=c&&(this.properties.value=c);this.setOutputData(0,this.properties.value)};k.prototype.onMouseDown=function(c,e){if(1e[1]))return this.old_y=c.canvasY,this.captureInput(!0),this.mouse_captured=!0};n.prototype.onMouseMove=function(c){if(this.mouse_captured){var e=this.old_y-c.canvasY;c.shiftKey&&(e*=10);if(c.metaKey||c.altKey)e*=.1;this.old_y=c.canvasY;c=this._remainder+e/n.pixels_threshold;this._remainder=c%1;c=clamp(this.properties.value+ +(c|0)*this.properties.step,this.properties.min,this.properties.max);this.properties.value=c;this.graph._version++;this.setDirtyCanvas(!0)}};n.prototype.onMouseUp=function(c,e){200>c.click_time&&(this.properties.value=clamp(this.properties.value+(e[1]>.5*this.size[1]?-1:1)*this.properties.step,this.properties.min,this.properties.max),this.graph._version++,this.setDirtyCanvas(!0));this.mouse_captured&&(this.mouse_captured=!1,this.captureInput(!1))};H.registerNodeType("widget/number",n);r.title="Combo"; +r.desc="Widget to select from a list";r.prototype.onExecute=function(){this.setOutputData(0,this.properties.value)};r.prototype.onPropertyChanged=function(c,e){"values"==c?(this._values=e.split(";"),this.widget.options.values=this._values):"value"==c&&(this.widget.value=e)};H.registerNodeType("widget/combo",r);u.title="Knob";u.desc="Circular controller";u.size=[80,100];u.prototype.onDrawForeground=function(c){if(!this.flags.collapsed){-1==this.value&&(this.value=(this.properties.value-this.properties.min)/ (this.properties.max-this.properties.min));var e=.5*this.size[0],h=.5*this.size[1],k=.5*Math.min(this.size[0],this.size[1])-5;c.globalAlpha=1;c.save();c.translate(e,h);c.rotate(.75*Math.PI);c.fillStyle="rgba(0,0,0,0.5)";c.beginPath();c.moveTo(0,0);c.arc(0,0,k,0,1.5*Math.PI);c.fill();c.strokeStyle="black";c.fillStyle=this.properties.color;c.lineWidth=2;c.beginPath();c.moveTo(0,0);c.arc(0,0,k-4,0,1.5*Math.PI*Math.max(.01,this.value));c.closePath();c.fill();c.lineWidth=1;c.globalAlpha=1;c.restore(); -c.fillStyle="black";c.beginPath();c.arc(e,h,.75*k,0,2*Math.PI,!0);c.fill();c.fillStyle=this.mouseOver?"white":this.properties.color;c.beginPath();var q=this.value*Math.PI*1.5+.75*Math.PI;c.arc(e+Math.cos(q)*k*.65,h+Math.sin(q)*k*.65,.05*k,0,2*Math.PI,!0);c.fill();c.fillStyle=this.mouseOver?"white":"#AAA";c.font=Math.floor(.5*k)+"px Arial";c.textAlign="center";c.fillText(this.properties.value.toFixed(this.properties.precision),e,h+.15*k)}};w.prototype.onExecute=function(){this.setOutputData(0,this.properties.value); -this.boxcolor=J.colorToString([this.value,this.value,this.value])};w.prototype.onMouseDown=function(c){this.center=[.5*this.size[0],.5*this.size[1]+20];this.radius=.5*this.size[0];if(20>c.canvasY-this.pos[1]||J.distance([c.canvasX,c.canvasY],[this.pos[0]+this.center[0],this.pos[1]+this.center[1]])>this.radius)return!1;this.oldmouse=[c.canvasX-this.pos[0],c.canvasY-this.pos[1]];this.captureInput(!0);return!0};w.prototype.onMouseMove=function(c){if(this.oldmouse){c=[c.canvasX-this.pos[0],c.canvasY- -this.pos[1]];var e=this.value;e-=.01*(c[1]-this.oldmouse[1]);1e&&(e=0);this.value=e;this.properties.value=this.properties.min+(this.properties.max-this.properties.min)*this.value;this.oldmouse=c;this.setDirtyCanvas(!0)}};w.prototype.onMouseUp=function(c){this.oldmouse&&(this.oldmouse=null,this.captureInput(!1))};w.prototype.onPropertyChanged=function(c,e){if("min"==c||"max"==c||"value"==c)return this.properties[c]=parseFloat(e),!0};J.registerNodeType("widget/knob",w);h.title="Inner Slider"; -h.prototype.onPropertyChanged=function(c,e){"value"==c&&(this.slider.value=e)};h.prototype.onExecute=function(){this.setOutputData(0,this.properties.value)};J.registerNodeType("widget/internal_slider",h);I.title="H.Slider";I.desc="Linear slider controller";I.prototype.onDrawForeground=function(c){-1==this.value&&(this.value=(this.properties.value-this.properties.min)/(this.properties.max-this.properties.min));c.globalAlpha=1;c.lineWidth=1;c.fillStyle="#000";c.fillRect(2,2,this.size[0]-4,this.size[1]- -4);c.fillStyle=this.properties.color;c.beginPath();c.rect(4,4,(this.size[0]-8)*this.value,this.size[1]-8);c.fill()};I.prototype.onExecute=function(){this.properties.value=this.properties.min+(this.properties.max-this.properties.min)*this.value;this.setOutputData(0,this.properties.value);this.boxcolor=J.colorToString([this.value,this.value,this.value])};I.prototype.onMouseDown=function(c){if(0>c.canvasY-this.pos[1])return!1;this.oldmouse=[c.canvasX-this.pos[0],c.canvasY-this.pos[1]];this.captureInput(!0); -return!0};I.prototype.onMouseMove=function(c){if(this.oldmouse){c=[c.canvasX-this.pos[0],c.canvasY-this.pos[1]];var e=this.value;e+=(c[0]-this.oldmouse[0])/this.size[0];1e&&(e=0);this.value=e;this.oldmouse=c;this.setDirtyCanvas(!0)}};I.prototype.onMouseUp=function(c){this.oldmouse=null;this.captureInput(!1)};I.prototype.onMouseLeave=function(c){};J.registerNodeType("widget/hslider",I);E.title="Progress";E.desc="Shows data in linear progress";E.prototype.onExecute=function(){var c=this.getInputData(0); -void 0!=c&&(this.properties.value=c)};E.prototype.onDrawForeground=function(c){c.lineWidth=1;c.fillStyle=this.properties.color;var e=(this.properties.value-this.properties.min)/(this.properties.max-this.properties.min);e=Math.min(1,e);e=Math.max(0,e);c.fillRect(2,2,(this.size[0]-4)*e,this.size[1]-4)};J.registerNodeType("widget/progress",E);H.title="Text";H.desc="Shows the input value";H.widgets=[{name:"resize",text:"Resize box",type:"button"},{name:"led_text",text:"LED",type:"minibutton"},{name:"normal_text", -text:"Normal",type:"minibutton"}];H.prototype.onDrawForeground=function(c){c.fillStyle=this.properties.color;var e=this.properties.value;this.properties.glowSize?(c.shadowColor=this.properties.color,c.shadowOffsetX=0,c.shadowOffsetY=0,c.shadowBlur=this.properties.glowSize):c.shadowColor="transparent";var h=this.properties.fontsize;c.textAlign=this.properties.align;c.font=h.toString()+"px "+this.properties.font;this.str="number"==typeof e?e.toFixed(this.properties.decimals):e;if("string"==typeof this.str){e= -this.str.replace(/[\r\n]/g,"\\n").split("\\n");for(var k=0;kc.canvasY-this.pos[1]||H.distance([c.canvasX,c.canvasY],[this.pos[0]+this.center[0],this.pos[1]+this.center[1]])>this.radius)return!1;this.oldmouse=[c.canvasX-this.pos[0],c.canvasY-this.pos[1]];this.captureInput(!0);return!0};u.prototype.onMouseMove=function(c){if(this.oldmouse){c=[c.canvasX-this.pos[0],c.canvasY- +this.pos[1]];var e=this.value;e-=.01*(c[1]-this.oldmouse[1]);1e&&(e=0);this.value=e;this.properties.value=this.properties.min+(this.properties.max-this.properties.min)*this.value;this.oldmouse=c;this.setDirtyCanvas(!0)}};u.prototype.onMouseUp=function(c){this.oldmouse&&(this.oldmouse=null,this.captureInput(!1))};u.prototype.onPropertyChanged=function(c,e){if("min"==c||"max"==c||"value"==c)return this.properties[c]=parseFloat(e),!0};H.registerNodeType("widget/knob",u);h.title="Inner Slider"; +h.prototype.onPropertyChanged=function(c,e){"value"==c&&(this.slider.value=e)};h.prototype.onExecute=function(){this.setOutputData(0,this.properties.value)};H.registerNodeType("widget/internal_slider",h);E.title="H.Slider";E.desc="Linear slider controller";E.prototype.onDrawForeground=function(c){-1==this.value&&(this.value=(this.properties.value-this.properties.min)/(this.properties.max-this.properties.min));c.globalAlpha=1;c.lineWidth=1;c.fillStyle="#000";c.fillRect(2,2,this.size[0]-4,this.size[1]- +4);c.fillStyle=this.properties.color;c.beginPath();c.rect(4,4,(this.size[0]-8)*this.value,this.size[1]-8);c.fill()};E.prototype.onExecute=function(){this.properties.value=this.properties.min+(this.properties.max-this.properties.min)*this.value;this.setOutputData(0,this.properties.value);this.boxcolor=H.colorToString([this.value,this.value,this.value])};E.prototype.onMouseDown=function(c){if(0>c.canvasY-this.pos[1])return!1;this.oldmouse=[c.canvasX-this.pos[0],c.canvasY-this.pos[1]];this.captureInput(!0); +return!0};E.prototype.onMouseMove=function(c){if(this.oldmouse){c=[c.canvasX-this.pos[0],c.canvasY-this.pos[1]];var e=this.value;e+=(c[0]-this.oldmouse[0])/this.size[0];1e&&(e=0);this.value=e;this.oldmouse=c;this.setDirtyCanvas(!0)}};E.prototype.onMouseUp=function(c){this.oldmouse=null;this.captureInput(!1)};E.prototype.onMouseLeave=function(c){};H.registerNodeType("widget/hslider",E);D.title="Progress";D.desc="Shows data in linear progress";D.prototype.onExecute=function(){var c=this.getInputData(0); +void 0!=c&&(this.properties.value=c)};D.prototype.onDrawForeground=function(c){c.lineWidth=1;c.fillStyle=this.properties.color;var e=(this.properties.value-this.properties.min)/(this.properties.max-this.properties.min);e=Math.min(1,e);e=Math.max(0,e);c.fillRect(2,2,(this.size[0]-4)*e,this.size[1]-4)};H.registerNodeType("widget/progress",D);J.title="Text";J.desc="Shows the input value";J.widgets=[{name:"resize",text:"Resize box",type:"button"},{name:"led_text",text:"LED",type:"minibutton"},{name:"normal_text", +text:"Normal",type:"minibutton"}];J.prototype.onDrawForeground=function(c){c.fillStyle=this.properties.color;var e=this.properties.value;this.properties.glowSize?(c.shadowColor=this.properties.color,c.shadowOffsetX=0,c.shadowOffsetY=0,c.shadowBlur=this.properties.glowSize):c.shadowColor="transparent";var h=this.properties.fontsize;c.textAlign=this.properties.align;c.font=h.toString()+"px "+this.properties.font;this.str="number"==typeof e?e.toFixed(this.properties.decimals):e;if("string"==typeof this.str){e= +this.str.replace(/[\r\n]/g,"\\n").split("\\n");for(var k=0;kr?k.xbox.axes.lx:0,this._left_axis[1]=Math.abs(k.xbox.axes.ly)>r?k.xbox.axes.ly:0,this._right_axis[0]=Math.abs(k.xbox.axes.rx)>r?k.xbox.axes.rx:0,this._right_axis[1]=Math.abs(k.xbox.axes.ry)>r?k.xbox.axes.ry:0,this._triggers[0]=Math.abs(k.xbox.axes.ltrigger)>r?k.xbox.axes.ltrigger: -0,this._triggers[1]=Math.abs(k.xbox.axes.rtrigger)>r?k.xbox.axes.rtrigger:0);if(this.outputs)for(r=0;rr?k.xbox.axes.rtrigger:0);if(this.outputs)for(r=0;rr;r++)if(k[r]){k=k[r];r=this.xbox_mapping;r||(r=this.xbox_mapping={axes:[], -buttons:{},hat:"",hatmap:c.CENTER});r.axes.lx=k.axes[0];r.axes.ly=k.axes[1];r.axes.rx=k.axes[2];r.axes.ry=k.axes[3];r.axes.ltrigger=k.buttons[6].value;r.axes.rtrigger=k.buttons[7].value;r.hat="";r.hatmap=c.CENTER;for(var w=0;ww)r.buttons[c.mapping_array[w]]=k.buttons[w].pressed,k.buttons[w].was_pressed&&this.trigger(c.mapping_array[w]+"_button_event");else switch(w){case 12:k.buttons[w].pressed&&(r.hat+="up",r.hatmap|=c.UP); -break;case 13:k.buttons[w].pressed&&(r.hat+="down",r.hatmap|=c.DOWN);break;case 14:k.buttons[w].pressed&&(r.hat+="left",r.hatmap|=c.LEFT);break;case 15:k.buttons[w].pressed&&(r.hat+="right",r.hatmap|=c.RIGHT);break;case 16:r.buttons.home=k.buttons[w].pressed}k.xbox=r;return k}};c.prototype.onDrawBackground=function(c){if(!this.flags.collapsed){var k=this._left_axis,q=this._right_axis;c.strokeStyle="#88A";c.strokeRect(.5*(k[0]+1)*this.size[0]-4,.5*(k[1]+1)*this.size[1]-4,8,8);c.strokeStyle="#8A8"; -c.strokeRect(.5*(q[0]+1)*this.size[0]-4,.5*(q[1]+1)*this.size[1]-4,8,8);k=this.size[1]/this._current_buttons.length;c.fillStyle="#AEB";for(q=0;qu)r.buttons[c.mapping_array[u]]=k.buttons[u].pressed,k.buttons[u].was_pressed&&this.trigger(c.mapping_array[u]+"_button_event");else switch(u){case 12:k.buttons[u].pressed&&(r.hat+="up",r.hatmap|=c.UP); +break;case 13:k.buttons[u].pressed&&(r.hat+="down",r.hatmap|=c.DOWN);break;case 14:k.buttons[u].pressed&&(r.hat+="left",r.hatmap|=c.LEFT);break;case 15:k.buttons[u].pressed&&(r.hat+="right",r.hatmap|=c.RIGHT);break;case 16:r.buttons.home=k.buttons[u].pressed}k.xbox=r;return k}};c.prototype.onDrawBackground=function(c){if(!this.flags.collapsed){var k=this._left_axis,n=this._right_axis;c.strokeStyle="#88A";c.strokeRect(.5*(k[0]+1)*this.size[0]-4,.5*(k[1]+1)*this.size[1]-4,8,8);c.strokeStyle="#8A8"; +c.strokeRect(.5*(n[0]+1)*this.size[0]-4,.5*(n[1]+1)*this.size[1]-4,8,8);k=this.size[1]/this._current_buttons.length;c.fillStyle="#AEB";for(n=0;n","enum",{values:O.values});this.addWidget("combo", -"Cond.",this.properties.OP,{property:"OP",values:O.values});this.size=[80,60]}function a(){this.addInput("in",0);this.addInput("cond","boolean");this.addOutput("true",0);this.addOutput("false",0);this.size=[80,60]}function b(){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 f(){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,d){d.properties.formula=a});this.addWidget("toggle","allow",C.allow_scripts,function(a){C.allow_scripts=a});this._func=null}function g(){this.addInput("vec2","vec2");this.addOutput("x","number");this.addOutput("y","number")}function n(){this.addInputs([["x","number"],["y","number"]]); -this.addOutput("vec2","vec2");this.properties={x:0,y:0};this._data=new Float32Array(2)}function t(){this.addInput("vec3","vec3");this.addOutput("x","number");this.addOutput("y","number");this.addOutput("z","number")}function z(){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 v(){this.addInput("vec4","vec4");this.addOutput("x","number");this.addOutput("y","number");this.addOutput("z", -"number");this.addOutput("w","number")}function u(){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 C=B.LiteGraph;c.title="Converter";c.desc="type A to type B";c.prototype.onExecute=function(){var a=this.getInputData(0);if(null!=a&&this.outputs)for(var b=0;b","enum",{values:N.values});this.addWidget("combo", +"Cond.",this.properties.OP,{property:"OP",values:N.values});this.size=[80,60]}function a(){this.addInput("in",0);this.addInput("cond","boolean");this.addOutput("true",0);this.addOutput("false",0);this.size=[80,60]}function b(){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 f(){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,d){d.properties.formula=a});this.addWidget("toggle","allow",v.allow_scripts,function(a){v.allow_scripts=a});this._func=null}function g(){this.addInput("vec2","vec2");this.addOutput("x","number");this.addOutput("y","number")}function q(){this.addInputs([["x","number"],["y","number"]]); +this.addOutput("vec2","vec2");this.properties={x:0,y:0};this._data=new Float32Array(2)}function z(){this.addInput("vec3","vec3");this.addOutput("x","number");this.addOutput("y","number");this.addOutput("z","number")}function P(){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 I(){this.addInput("vec4","vec4");this.addOutput("x","number");this.addOutput("y","number");this.addOutput("z", +"number");this.addOutput("w","number")}function t(){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 v=y.LiteGraph;c.title="Converter";c.desc="type A to type B";c.prototype.onExecute=function(){var a=this.getInputData(0);if(null!=a&&this.outputs)for(var b=0;ba&&(a+=1024);var c=Math.floor(a);a-=c;d=h.data[c];c=h.data[1023==c?0:c+1];b&&(a=a*a*a*(a*(6*a-15)+10));return d*(1-a)+c*a};h.prototype.onExecute=function(){var a=this.getInputData(0)|| -0,b=this.properties.octaves||1,d=0,c=1;a+=this.properties.seed||0;for(var f=this.properties.speed||1,g=0,e=0;ec);++e);a=this.properties.min;this._last_v=d/g*(this.properties.max-a)+a;this.setOutputData(0,this._last_v)};h.prototype.onDrawBackground=function(a){this.outputs[0].label=(this._last_v||0).toFixed(3)};C.registerNodeType("math/noise",h);I.title="Spikes";I.desc="spike every random time";I.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)};C.registerNodeType("math/spikes",I);E.title="Clamp";E.desc="Clamp number between min and max"; -E.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))};E.prototype.getCode=function(a){a="";this.isInputConnected(0)&&(a+="clamp({{0}},"+this.properties.min+","+this.properties.max+")");return a};C.registerNodeType("math/clamp",E);H.title="Lerp";H.desc="Linear Interpolation";H.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=0);var b=this.getInputData(1);null==b&&(b=0); -var d=this.properties.f,c=this.getInputData(2);void 0!==c&&(d=c);this.setOutputData(0,a*(1-d)+b*d)};H.prototype.onGetInputs=function(){return[["f","number"]]};C.registerNodeType("math/lerp",H);L.title="Abs";L.desc="Absolute";L.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,Math.abs(a))};C.registerNodeType("math/abs",L);J.title="Floor";J.desc="Floor number to remove fractional part";J.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0, -Math.floor(a))};C.registerNodeType("math/floor",J);G.title="Frac";G.desc="Returns fractional part";G.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,a%1)};C.registerNodeType("math/frac",G);e.title="Smoothstep";e.desc="Smoothstep";e.prototype.onExecute=function(){var a=this.getInputData(0);if(void 0!==a){var b=this.properties.A;a=clamp((a-b)/(this.properties.B-b),0,1);this.setOutputData(0,a*a*(3-2*a))}};C.registerNodeType("math/smoothstep",e);K.title="Scale"; -K.desc="v * factor";K.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,a*this.properties.factor)};C.registerNodeType("math/scale",K);D.title="Gate";D.desc="if v is true, then outputs A, otherwise B";D.prototype.onExecute=function(){var a=this.getInputData(0);this.setOutputData(0,this.getInputData(a?1:2))};C.registerNodeType("math/gate",D);M.title="Average";M.desc="Average Filter";M.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 d=a=0;db&&(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))};C.registerNodeType("math/average",M);m.title="TendTo";m.desc="moves the output value always closer to the input"; -m.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)};C.registerNodeType("math/tendTo",m);l.values="+ - * / % ^ max min".split(" ");l.funcs={"+":function(a,b){return a+b},"-":function(a,b){return a-b},x:function(a,b){return a*b},X:function(a,b){return a*b},"*":function(a,b){return a*b},"/":function(a,b){return a/b},"%":function(a,b){return a%b},"^":function(a, -b){return Math.pow(a,b)},max:function(a,b){return Math.max(a,b)},min:function(a,b){return Math.min(a,b)}};l.title="Operation";l.desc="Easy math operators";l["@OP"]={type:"enum",title:"operation",values:l.values};l.size=[100,60];l.prototype.getTitle=function(){return"max"==this.properties.OP||"min"==this.properties.OP?this.properties.OP+"(A,B)":"A "+this.properties.OP+" B"};l.prototype.setValue=function(a){"string"==typeof a&&(a=parseFloat(a));this.properties.value=a};l.prototype.onPropertyChanged= -function(a,b){"OP"==a&&(this._func=l.funcs[this.properties.OP],this._func||(console.warn("Unknown operation: "+this.properties.OP),this._func=function(a){return a}))};l.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;var d=l.funcs[this.properties.OP];if(a.constructor===Number)var c=d(a,b);else if(a.constructor===Array){c=this._result;c.length=a.length; -for(var f=0;fB":g=a>b;break;case "A=B":g=a>=b}this.setOutputData(d,g)}}};A.prototype.onGetOutputs=function(){return[["A==B","boolean"],["A!=B","boolean"],["A>B","boolean"],["A=B","boolean"],["A<=B","boolean"]]};C.registerNodeType("math/compare",A);C.registerSearchboxExtra("math/compare","==",{outputs:[["A==B","boolean"]],title:"A==B"});C.registerSearchboxExtra("math/compare","!=",{outputs:[["A!=B","boolean"]],title:"A!=B"});C.registerSearchboxExtra("math/compare",">",{outputs:[["A>B","boolean"]], -title:"A>B"});C.registerSearchboxExtra("math/compare","<",{outputs:[["A=",{outputs:[["A>=B","boolean"]],title:"A>=B"});C.registerSearchboxExtra("math/compare","<=",{outputs:[["A<=B","boolean"]],title:"A<=B"});O.values="> < == != <= >= || &&".split(" ");O["@OP"]={type:"enum",title:"operation",values:O.values};O.title="Condition";O.desc="evaluates condition between A and B";O.prototype.getTitle=function(){return"A "+this.properties.OP+ -" B"};O.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 d=!0;switch(this.properties.OP){case ">":d=a>b;break;case "<":d=a=":d=a>=b;break;case "||":d=a||b;break;case "&&":d=a&&b}this.setOutputData(0,d);this.setOutputData(1,!d)};C.registerNodeType("math/condition",O);a.title= -"Branch";a.desc="If condition is true, outputs IN in true, otherwise in false";a.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))};C.registerNodeType("math/branch",a);b.title="Accumulate";b.desc="Increments a value every time";b.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)};C.registerNodeType("math/accumulate",b);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,d=this.findInputSlot("amplitude");-1!=d&&(b=this.getInputData(d));var c=this.properties.offset;d=this.findInputSlot("offset");-1!=d&&(c=this.getInputData(d));d=0;for(var f=this.outputs.length;d< +"number"],["in_max","number"],["out_min","number"],["out_max","number"]]};v.registerNodeType("math/range",r);u.title="Rand";u.desc="Random number";u.prototype.onExecute=function(){if(this.inputs)for(var a=0;aa&&(a+=1024);var c=Math.floor(a);a-=c;d=h.data[c];c=h.data[1023==c?0:c+1];b&&(a=a*a*a*(a*(6*a-15)+10));return d*(1-a)+c*a};h.prototype.onExecute=function(){var a=this.getInputData(0)|| +0,b=this.properties.octaves||1,d=0,c=1;a+=this.properties.seed||0;for(var f=this.properties.speed||1,g=0,e=0;ec);++e);a=this.properties.min;this._last_v=d/g*(this.properties.max-a)+a;this.setOutputData(0,this._last_v)};h.prototype.onDrawBackground=function(a){this.outputs[0].label=(this._last_v||0).toFixed(3)};v.registerNodeType("math/noise",h);E.title="Spikes";E.desc="spike every random time";E.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)};v.registerNodeType("math/spikes",E);D.title="Clamp";D.desc="Clamp number between min and max"; +D.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))};D.prototype.getCode=function(a){a="";this.isInputConnected(0)&&(a+="clamp({{0}},"+this.properties.min+","+this.properties.max+")");return a};v.registerNodeType("math/clamp",D);J.title="Lerp";J.desc="Linear Interpolation";J.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=0);var b=this.getInputData(1);null==b&&(b=0); +var d=this.properties.f,c=this.getInputData(2);void 0!==c&&(d=c);this.setOutputData(0,a*(1-d)+b*d)};J.prototype.onGetInputs=function(){return[["f","number"]]};v.registerNodeType("math/lerp",J);L.title="Abs";L.desc="Absolute";L.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,Math.abs(a))};v.registerNodeType("math/abs",L);H.title="Floor";H.desc="Floor number to remove fractional part";H.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0, +Math.floor(a))};v.registerNodeType("math/floor",H);F.title="Frac";F.desc="Returns fractional part";F.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,a%1)};v.registerNodeType("math/frac",F);e.title="Smoothstep";e.desc="Smoothstep";e.prototype.onExecute=function(){var a=this.getInputData(0);if(void 0!==a){var b=this.properties.A;a=clamp((a-b)/(this.properties.B-b),0,1);this.setOutputData(0,a*a*(3-2*a))}};v.registerNodeType("math/smoothstep",e);K.title="Scale"; +K.desc="v * factor";K.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,a*this.properties.factor)};v.registerNodeType("math/scale",K);B.title="Gate";B.desc="if v is true, then outputs A, otherwise B";B.prototype.onExecute=function(){var a=this.getInputData(0);this.setOutputData(0,this.getInputData(a?1:2))};v.registerNodeType("math/gate",B);M.title="Average";M.desc="Average Filter";M.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 d=a=0;db&&(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))};v.registerNodeType("math/average",M);l.title="TendTo";l.desc="moves the output value always closer to the input"; +l.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)};v.registerNodeType("math/tendTo",l);m.values="+ - * / % ^ max min".split(" ");m.funcs={"+":function(a,b){return a+b},"-":function(a,b){return a-b},x:function(a,b){return a*b},X:function(a,b){return a*b},"*":function(a,b){return a*b},"/":function(a,b){return a/b},"%":function(a,b){return a%b},"^":function(a, +b){return Math.pow(a,b)},max:function(a,b){return Math.max(a,b)},min:function(a,b){return Math.min(a,b)}};m.title="Operation";m.desc="Easy math operators";m["@OP"]={type:"enum",title:"operation",values:m.values};m.size=[100,60];m.prototype.getTitle=function(){return"max"==this.properties.OP||"min"==this.properties.OP?this.properties.OP+"(A,B)":"A "+this.properties.OP+" B"};m.prototype.setValue=function(a){"string"==typeof a&&(a=parseFloat(a));this.properties.value=a};m.prototype.onPropertyChanged= +function(a,b){"OP"==a&&(this._func=m.funcs[this.properties.OP],this._func||(console.warn("Unknown operation: "+this.properties.OP),this._func=function(a){return a}))};m.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;var d=m.funcs[this.properties.OP];if(a.constructor===Number)var c=d(a,b);else if(a.constructor===Array){c=this._result;c.length=a.length; +for(var f=0;fB":g=a>b;break;case "A=B":g=a>=b}this.setOutputData(d,g)}}};w.prototype.onGetOutputs=function(){return[["A==B","boolean"],["A!=B","boolean"],["A>B","boolean"],["A=B","boolean"],["A<=B","boolean"]]};v.registerNodeType("math/compare",w);v.registerSearchboxExtra("math/compare","==",{outputs:[["A==B","boolean"]],title:"A==B"});v.registerSearchboxExtra("math/compare","!=",{outputs:[["A!=B","boolean"]],title:"A!=B"});v.registerSearchboxExtra("math/compare",">",{outputs:[["A>B","boolean"]], +title:"A>B"});v.registerSearchboxExtra("math/compare","<",{outputs:[["A=",{outputs:[["A>=B","boolean"]],title:"A>=B"});v.registerSearchboxExtra("math/compare","<=",{outputs:[["A<=B","boolean"]],title:"A<=B"});N.values="> < == != <= >= || &&".split(" ");N["@OP"]={type:"enum",title:"operation",values:N.values};N.title="Condition";N.desc="evaluates condition between A and B";N.prototype.getTitle=function(){return"A "+this.properties.OP+ +" B"};N.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 d=!0;switch(this.properties.OP){case ">":d=a>b;break;case "<":d=a=":d=a>=b;break;case "||":d=a||b;break;case "&&":d=a&&b}this.setOutputData(0,d);this.setOutputData(1,!d)};v.registerNodeType("math/condition",N);a.title= +"Branch";a.desc="If condition is true, outputs IN in true, otherwise in false";a.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))};v.registerNodeType("math/branch",a);b.title="Accumulate";b.desc="Increments a value every time";b.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)};v.registerNodeType("math/accumulate",b);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,d=this.findInputSlot("amplitude");-1!=d&&(b=this.getInputData(d));var c=this.properties.offset;d=this.findInputSlot("offset");-1!=d&&(c=this.getInputData(d));d=0;for(var f=this.outputs.length;d< f;++d){switch(this.outputs[d].name){case "sin":var g=Math.sin(a);break;case "cos":g=Math.cos(a);break;case "tan":g=Math.tan(a);break;case "asin":g=Math.asin(a);break;case "acos":g=Math.acos(a);break;case "atan":g=Math.atan(a)}this.setOutputData(d,b*g+c)}};d.prototype.onGetInputs=function(){return[["v","number"],["amplitude","number"],["offset","number"]]};d.prototype.onGetOutputs=function(){return[["sin","number"],["cos","number"],["tan","number"],["asin","number"],["acos","number"],["atan","number"]]}; -C.registerNodeType("math/trigonometry",d);C.registerSearchboxExtra("math/trigonometry","SIN()",{outputs:[["sin","number"]],title:"SIN()"});C.registerSearchboxExtra("math/trigonometry","COS()",{outputs:[["cos","number"]],title:"COS()"});C.registerSearchboxExtra("math/trigonometry","TAN()",{outputs:[["tan","number"]],title:"TAN()"});f.title="Formula";f.desc="Compute formula";f.size=[160,100];M.prototype.onPropertyChanged=function(a,b){"formula"==a&&(this.code_widget.value=b)};f.prototype.onExecute= -function(){if(C.allow_scripts){var a=this.getInputData(0),b=this.getInputData(1);null!=a?this.properties.x=a:a=this.properties.x;null!=b?this.properties.y=b:b=this.properties.y;try{this._func&&this._func_code==this.properties.formula||(this._func=new Function("x","y","TIME","return "+this.properties.formula),this._func_code=this.properties.formula);var d=this._func(a,b,this.graph.globaltime);this.boxcolor=null}catch(y){this.boxcolor="red"}this.setOutputData(0,d)}};f.prototype.getTitle=function(){return this._func_code|| -"Formula"};f.prototype.onDrawBackground=function(){var a=this.properties.formula;this.outputs&&this.outputs.length&&(this.outputs[0].label=a)};C.registerNodeType("math/formula",f);g.title="Vec2->XY";g.desc="vector 2 to components";g.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]))};C.registerNodeType("math3d/vec2-to-xy",g);n.title="XY->Vec2";n.desc="components to vector2";n.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 d=this._data;d[0]=a;d[1]=b;this.setOutputData(0,d)};C.registerNodeType("math3d/xy-to-vec2",n);t.title="Vec3->XYZ";t.desc="vector 3 to components";t.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]))};C.registerNodeType("math3d/vec3-to-xyz",t);z.title="XYZ->Vec3";z.desc="components to vector3";z.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 d=this.getInputData(2);null==d&&(d=this.properties.z);var c=this._data;c[0]=a;c[1]=b;c[2]=d;this.setOutputData(0,c)};C.registerNodeType("math3d/xyz-to-vec3",z);v.title="Vec4->XYZW";v.desc="vector 4 to components";v.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]))};C.registerNodeType("math3d/vec4-to-xyzw",v);u.title="XYZW->Vec4";u.desc="components to vector4";u.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 d=this.getInputData(2);null==d&&(d=this.properties.z);var c=this.getInputData(3);null==c&&(c=this.properties.w);var f=this._data;f[0]=a;f[1]=b;f[2]=d;f[3]=c;this.setOutputData(0,f)};C.registerNodeType("math3d/xyzw-to-vec4",u)})(this); -(function(B){function c(){this.addInput("T","vec3");this.addInput("R","vec3");this.addInput("S","vec3");this.addOutput("mat4","mat4");this.properties={T:[0,0,0],R:[0,0,0],S:[1,1,1],R_in_degrees:!0};this._result=mat4.create();this._must_update=!0}function k(){this.addInput("A","number,vec3");this.addInput("B","number,vec3");this.addOutput("=","number,vec3");this.addProperty("OP","+","enum",{values:k.values});this._result=vec3.create()}function q(){this.addInput("in","vec3");this.addInput("f","number"); -this.addOutput("out","vec3");this.properties={f:1};this._data=new Float32Array(3)}function r(){this.addInput("in","vec3");this.addOutput("out","number")}function w(){this.addInput("in","vec3");this.addOutput("out","vec3");this._data=new Float32Array(3)}function h(){this.addInput("A","vec3");this.addInput("B","vec3");this.addInput("f","vec3");this.addOutput("out","vec3");this.properties={f:.5};this._data=new Float32Array(3)}function I(){this.addInput("A","vec3");this.addInput("B","vec3");this.addOutput("out", -"number")}var E=B.LiteGraph;c.title="mat4";c.temp_quat=new Float32Array([0,0,0,1]);c.temp_mat4=new Float32Array(16);c.temp_vec3=new Float32Array(3);c.prototype.onPropertyChanged=function(c,e){this._must_update=!0};c.prototype.onExecute=function(){var e=this._result,m=c.temp_quat,l=c.temp_mat4,h=c.temp_vec3,k=this.getInputData(0),a=this.getInputData(1),b=this.getInputData(2);if(this._must_update||k||a||b)k=k||this.properties.T,a=a||this.properties.R,b=b||this.properties.S,mat4.identity(e),mat4.translate(e, -e,k),this.properties.R_in_degrees?(h.set(a),vec3.scale(h,h,DEG2RAD),quat.fromEuler(m,h)):quat.fromEuler(m,a),mat4.fromQuat(l,m),mat4.multiply(e,e,l),mat4.scale(e,e,b);this.setOutputData(0,e)};E.registerNodeType("math3d/mat4",c);k.values="+ - * / % ^ max min dot cross".split(" ");E.registerSearchboxExtra("math3d/operation","CROSS()",{properties:{OP:"cross"},title:"CROSS()"});E.registerSearchboxExtra("math3d/operation","DOT()",{properties:{OP:"dot"},title:"DOT()"});k.title="Operation";k.desc="Easy math 3D operators"; -k["@OP"]={type:"enum",title:"operation",values:k.values};k.size=[100,60];k.prototype.getTitle=function(){return"max"==this.properties.OP||"min"==this.properties.OP?this.properties.OP+"(A,B)":"A "+this.properties.OP+" B"};k.prototype.onExecute=function(){var c=this.getInputData(0),e=this.getInputData(1);if(null!=c&&null!=e){c.constructor===Number&&(c=[c,c,c]);e.constructor===Number&&(e=[e,e,e]);var l=this._result;switch(this.properties.OP){case "+":l=vec3.add(l,c,e);break;case "-":l=vec3.sub(l,c,e); -break;case "x":case "X":case "*":l=vec3.mul(l,c,e);break;case "/":l=vec3.div(l,c,e);break;case "%":l[0]=c[0]%e[0];l[1]=c[1]%e[1];l[2]=c[2]%e[2];break;case "^":l[0]=Math.pow(c[0],e[0]);l[1]=Math.pow(c[1],e[1]);l[2]=Math.pow(c[2],e[2]);break;case "max":l[0]=Math.max(c[0],e[0]);l[1]=Math.max(c[1],e[1]);l[2]=Math.max(c[2],e[2]);break;case "min":l[0]=Math.min(c[0],e[0]),l[1]=Math.min(c[1],e[1]),l[2]=Math.min(c[2],e[2]);case "dot":l=vec3.dot(c,e);break;case "cross":vec3.cross(l,c,e);break;default:console.warn("Unknown operation: "+ -this.properties.OP)}this.setOutputData(0,l)}};k.prototype.onDrawBackground=function(c){this.flags.collapsed||(c.font="40px Arial",c.fillStyle="#666",c.textAlign="center",c.fillText(this.properties.OP,.5*this.size[0],.5*(this.size[1]+E.NODE_TITLE_HEIGHT)),c.textAlign="left")};E.registerNodeType("math3d/operation",k);q.title="vec3_scale";q.desc="scales the components of a vec3";q.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var e=this.getInputData(1);null==e&&(e=this.properties.f); -var l=this._data;l[0]=c[0]*e;l[1]=c[1]*e;l[2]=c[2]*e;this.setOutputData(0,l)}};E.registerNodeType("math3d/vec3-scale",q);r.title="vec3_length";r.desc="returns the module of a vector";r.prototype.onExecute=function(){var c=this.getInputData(0);null!=c&&this.setOutputData(0,Math.sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]))};E.registerNodeType("math3d/vec3-length",r);w.title="vec3_normalize";w.desc="returns the vector normalized";w.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var e= -Math.sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]),l=this._data;l[0]=c[0]/e;l[1]=c[1]/e;l[2]=c[2]/e;this.setOutputData(0,l)}};E.registerNodeType("math3d/vec3-normalize",w);h.title="vec3_lerp";h.desc="returns the interpolated vector";h.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var e=this.getInputData(1);if(null!=e){var l=this.getInputOrProperty("f"),h=this._data;h[0]=c[0]*(1-l)+e[0]*l;h[1]=c[1]*(1-l)+e[1]*l;h[2]=c[2]*(1-l)+e[2]*l;this.setOutputData(0,h)}}};E.registerNodeType("math3d/vec3-lerp", -h);I.title="vec3_dot";I.desc="returns the dot product";I.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var e=this.getInputData(1);null!=e&&this.setOutputData(0,c[0]*e[0]+c[1]*e[1]+c[2]*e[2])}};E.registerNodeType("math3d/vec3-dot",I);if(B.glMatrix){B=function(){this.addInput("vec3","vec3");this.addOutput("remap","vec3");this.addOutput("clamped","vec3");this.properties={clamp:!0,range_min:[-1,-1,0],range_max:[1,1,0],target_min:[-1,-1,0],target_max:[1,1,0]};this._value=vec3.create(); -this._clamped=vec3.create()};var H=function(){this.addInputs([["A","quat"],["B","quat"],["factor","number"]]);this.addOutput("slerp","quat");this.addProperty("factor",.5);this._value=quat.create()},L=function(){this.addInputs([["A","quat"],["B","quat"]]);this.addOutput("A*B","quat");this._value=quat.create()},J=function(){this.addInputs([["vec3","vec3"],["quat","quat"]]);this.addOutput("result","vec3");this.properties={vec:[0,0,1]}},G=function(){this.addInput(["quat","quat"]);this.addOutput("euler", -"vec3");this._value=vec3.create()},e=function(){this.addInput("euler","vec3");this.addOutput("quat","quat");this.properties={euler:[0,0,0],use_yaw_pitch_roll:!1};this._degs=vec3.create();this._value=quat.create()},K=function(){this.addInputs([["degrees","number"],["axis","vec3"]]);this.addOutput("quat","quat");this.properties={angle:90,axis:vec3.fromValues(0,1,0)};this._value=quat.create()},D=function(){this.addOutput("quat","quat");this.properties={x:0,y:0,z:0,w:1,normalize:!1};this._value=quat.create()}; -D.title="Quaternion";D.desc="quaternion";D.prototype.onExecute=function(){this._value[0]=this.getInputOrProperty("x");this._value[1]=this.getInputOrProperty("y");this._value[2]=this.getInputOrProperty("z");this._value[3]=this.getInputOrProperty("w");this.properties.normalize&&quat.normalize(this._value,this._value);this.setOutputData(0,this._value)};D.prototype.onGetInputs=function(){return[["x","number"],["y","number"],["z","number"],["w","number"]]};E.registerNodeType("math3d/quaternion",D);K.title= -"Rotation";K.desc="quaternion rotation";K.prototype.onExecute=function(){var c=this.getInputData(0);null==c&&(c=this.properties.angle);var e=this.getInputData(1);null==e&&(e=this.properties.axis);c=quat.setAxisAngle(this._value,e,.0174532925*c);this.setOutputData(0,c)};E.registerNodeType("math3d/rotation",K);e.title="Euler->Quat";e.desc="Converts euler angles (in degrees) to quaternion";e.prototype.onExecute=function(){var c=this.getInputData(0);null==c&&(c=this.properties.euler);vec3.scale(this._degs, -c,DEG2RAD);this.properties.use_yaw_pitch_roll&&(this._degs=[this._degs[2],this._degs[0],this._degs[1]]);c=quat.fromEuler(this._value,this._degs);this.setOutputData(0,c)};E.registerNodeType("math3d/euler_to_quat",e);G.title="Euler->Quat";G.desc="Converts rotX,rotY,rotZ in degrees to quat";G.prototype.onExecute=function(){var c=this.getInputData(0);c&&(quat.toEuler(this._value,c),vec3.scale(this._value,this._value,DEG2RAD),this.setOutputData(0,this._value))};E.registerNodeType("math3d/quat_to_euler", -G);J.title="Rot. Vec3";J.desc="rotate a point";J.prototype.onExecute=function(){var c=this.getInputData(0);null==c&&(c=this.properties.vec);var e=this.getInputData(1);null==e?this.setOutputData(c):this.setOutputData(0,vec3.transformQuat(vec3.create(),c,e))};E.registerNodeType("math3d/rotate_vec3",J);L.title="Mult. Quat";L.desc="rotate quaternion";L.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var e=this.getInputData(1);null!=e&&(c=quat.multiply(this._value,c,e),this.setOutputData(0, -c))}};E.registerNodeType("math3d/mult-quat",L);H.title="Quat Slerp";H.desc="quaternion spherical interpolation";H.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var e=this.getInputData(1);if(null!=e){var l=this.properties.factor;null!=this.getInputData(2)&&(l=this.getInputData(2));c=quat.slerp(this._value,c,e,l);this.setOutputData(0,c)}}};E.registerNodeType("math3d/quat-slerp",H);B.title="Remap Range";B.desc="remap a 3D range";B.prototype.onExecute=function(){var c=this.getInputData(0); -c&&this._value.set(c);c=this.properties.range_min;for(var e=this.properties.range_max,l=this.properties.target_min,h=this.properties.target_max,k=0;3>k;++k){var a=e[k]-c[k];this._clamped[k]=clamp(this._value[k],c[k],e[k]);0==a?this._value[k]=.5*(l[k]+h[k]):(a=(this._value[k]-c[k])/a,this.properties.clamp&&(a=clamp(a,0,1)),this._value[k]=l[k]+a*(h[k]-l[k]))}this.setOutputData(0,this._value);this.setOutputData(1,this._clamped)};E.registerNodeType("math3d/remap_range",B)}else E.debug&&console.warn("No glmatrix found, some Math3D nodes may not work")})(this); -(function(B){function c(){this.addInput("","string");this.addOutput("table","table");this.addOutput("rows","number");this.addProperty("value","");this.addProperty("separator",",");this._table=null}B=B.LiteGraph;B.wrapFunctionAsNode("string/toString",function(c){if(c&&c.constructor===Object)try{return JSON.stringify(c)}catch(q){}return String(c)},[""],"string");B.wrapFunctionAsNode("string/compare",function(c,q){return c==q},["string","string"],"boolean");B.wrapFunctionAsNode("string/concatenate", -function(c,q){return void 0===c?q:void 0===q?c:c+q},["string","string"],"string");B.wrapFunctionAsNode("string/contains",function(c,q){return void 0===c||void 0===q?!1:-1!=c.indexOf(q)},["string","string"],"boolean");B.wrapFunctionAsNode("string/toUpperCase",function(c){return null!=c&&c.constructor===String?c.toUpperCase():c},["string"],"string");B.wrapFunctionAsNode("string/split",function(c,q){null==q&&(q=this.properties.separator);if(null==c)return[];if(c.constructor===String)return c.split(q|| -" ");if(c.constructor===Array){for(var k=[],w=0;we;++e){var h=this.getInputData(e);if(null!=h){var k=this.values[e];k.push(h);k.length>c[0]&&k.shift()}}}};c.prototype.onDrawBackground=function(e){if(!this.flags.collapsed){var h= -this.size,k=.5*h[1]/this.properties.scale,r=c.colors,m=.5*h[1];e.fillStyle="#000";e.fillRect(0,0,h[0],h[1]);e.strokeStyle="#555";e.beginPath();e.moveTo(0,m);e.lineTo(h[0],m);e.stroke();if(this.inputs)for(var l=0;4>l;++l){var A=this.values[l];if(this.inputs[l]&&this.inputs[l].link){e.strokeStyle=r[l];e.beginPath();var q=A[0]*k*-1+m;e.moveTo(0,clamp(q,0,h[1]));for(var a=1;aXY";g.desc="vector 2 to components";g.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]))};v.registerNodeType("math3d/vec2-to-xy",g);q.title="XY->Vec2";q.desc="components to vector2";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 d=this._data;d[0]=a;d[1]=b;this.setOutputData(0,d)};v.registerNodeType("math3d/xy-to-vec2",q);z.title="Vec3->XYZ";z.desc="vector 3 to components";z.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]))};v.registerNodeType("math3d/vec3-to-xyz",z);P.title="XYZ->Vec3";P.desc="components to vector3";P.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 d=this.getInputData(2);null==d&&(d=this.properties.z);var c=this._data;c[0]=a;c[1]=b;c[2]=d;this.setOutputData(0,c)};v.registerNodeType("math3d/xyz-to-vec3",P);I.title="Vec4->XYZW";I.desc="vector 4 to components";I.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]))};v.registerNodeType("math3d/vec4-to-xyzw",I);t.title="XYZW->Vec4";t.desc="components to vector4";t.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 d=this.getInputData(2);null==d&&(d=this.properties.z);var c=this.getInputData(3);null==c&&(c=this.properties.w);var f=this._data;f[0]=a;f[1]=b;f[2]=d;f[3]=c;this.setOutputData(0,f)};v.registerNodeType("math3d/xyzw-to-vec4",t)})(this); +(function(y){function c(){this.addInput("T","vec3");this.addInput("R","vec3");this.addInput("S","vec3");this.addOutput("mat4","mat4");this.properties={T:[0,0,0],R:[0,0,0],S:[1,1,1],R_in_degrees:!0};this._result=mat4.create();this._must_update=!0}function k(){this.addInput("A","number,vec3");this.addInput("B","number,vec3");this.addOutput("=","number,vec3");this.addProperty("OP","+","enum",{values:k.values});this._result=vec3.create()}function n(){this.addInput("in","vec3");this.addInput("f","number"); +this.addOutput("out","vec3");this.properties={f:1};this._data=new Float32Array(3)}function r(){this.addInput("in","vec3");this.addOutput("out","number")}function u(){this.addInput("in","vec3");this.addOutput("out","vec3");this._data=new Float32Array(3)}function h(){this.addInput("A","vec3");this.addInput("B","vec3");this.addInput("f","vec3");this.addOutput("out","vec3");this.properties={f:.5};this._data=new Float32Array(3)}function E(){this.addInput("A","vec3");this.addInput("B","vec3");this.addOutput("out", +"number")}var D=y.LiteGraph;c.title="mat4";c.temp_quat=new Float32Array([0,0,0,1]);c.temp_mat4=new Float32Array(16);c.temp_vec3=new Float32Array(3);c.prototype.onPropertyChanged=function(c,e){this._must_update=!0};c.prototype.onExecute=function(){var e=this._result,l=c.temp_quat,m=c.temp_mat4,h=c.temp_vec3,k=this.getInputData(0),a=this.getInputData(1),b=this.getInputData(2);if(this._must_update||k||a||b)k=k||this.properties.T,a=a||this.properties.R,b=b||this.properties.S,mat4.identity(e),mat4.translate(e, +e,k),this.properties.R_in_degrees?(h.set(a),vec3.scale(h,h,DEG2RAD),quat.fromEuler(l,h)):quat.fromEuler(l,a),mat4.fromQuat(m,l),mat4.multiply(e,e,m),mat4.scale(e,e,b);this.setOutputData(0,e)};D.registerNodeType("math3d/mat4",c);k.values="+ - * / % ^ max min dot cross".split(" ");D.registerSearchboxExtra("math3d/operation","CROSS()",{properties:{OP:"cross"},title:"CROSS()"});D.registerSearchboxExtra("math3d/operation","DOT()",{properties:{OP:"dot"},title:"DOT()"});k.title="Operation";k.desc="Easy math 3D operators"; +k["@OP"]={type:"enum",title:"operation",values:k.values};k.size=[100,60];k.prototype.getTitle=function(){return"max"==this.properties.OP||"min"==this.properties.OP?this.properties.OP+"(A,B)":"A "+this.properties.OP+" B"};k.prototype.onExecute=function(){var c=this.getInputData(0),e=this.getInputData(1);if(null!=c&&null!=e){c.constructor===Number&&(c=[c,c,c]);e.constructor===Number&&(e=[e,e,e]);var m=this._result;switch(this.properties.OP){case "+":m=vec3.add(m,c,e);break;case "-":m=vec3.sub(m,c,e); +break;case "x":case "X":case "*":m=vec3.mul(m,c,e);break;case "/":m=vec3.div(m,c,e);break;case "%":m[0]=c[0]%e[0];m[1]=c[1]%e[1];m[2]=c[2]%e[2];break;case "^":m[0]=Math.pow(c[0],e[0]);m[1]=Math.pow(c[1],e[1]);m[2]=Math.pow(c[2],e[2]);break;case "max":m[0]=Math.max(c[0],e[0]);m[1]=Math.max(c[1],e[1]);m[2]=Math.max(c[2],e[2]);break;case "min":m[0]=Math.min(c[0],e[0]),m[1]=Math.min(c[1],e[1]),m[2]=Math.min(c[2],e[2]);case "dot":m=vec3.dot(c,e);break;case "cross":vec3.cross(m,c,e);break;default:console.warn("Unknown operation: "+ +this.properties.OP)}this.setOutputData(0,m)}};k.prototype.onDrawBackground=function(c){this.flags.collapsed||(c.font="40px Arial",c.fillStyle="#666",c.textAlign="center",c.fillText(this.properties.OP,.5*this.size[0],.5*(this.size[1]+D.NODE_TITLE_HEIGHT)),c.textAlign="left")};D.registerNodeType("math3d/operation",k);n.title="vec3_scale";n.desc="scales the components of a vec3";n.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var e=this.getInputData(1);null==e&&(e=this.properties.f); +var m=this._data;m[0]=c[0]*e;m[1]=c[1]*e;m[2]=c[2]*e;this.setOutputData(0,m)}};D.registerNodeType("math3d/vec3-scale",n);r.title="vec3_length";r.desc="returns the module of a vector";r.prototype.onExecute=function(){var c=this.getInputData(0);null!=c&&this.setOutputData(0,Math.sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]))};D.registerNodeType("math3d/vec3-length",r);u.title="vec3_normalize";u.desc="returns the vector normalized";u.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var e= +Math.sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]),m=this._data;m[0]=c[0]/e;m[1]=c[1]/e;m[2]=c[2]/e;this.setOutputData(0,m)}};D.registerNodeType("math3d/vec3-normalize",u);h.title="vec3_lerp";h.desc="returns the interpolated vector";h.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var e=this.getInputData(1);if(null!=e){var m=this.getInputOrProperty("f"),h=this._data;h[0]=c[0]*(1-m)+e[0]*m;h[1]=c[1]*(1-m)+e[1]*m;h[2]=c[2]*(1-m)+e[2]*m;this.setOutputData(0,h)}}};D.registerNodeType("math3d/vec3-lerp", +h);E.title="vec3_dot";E.desc="returns the dot product";E.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var e=this.getInputData(1);null!=e&&this.setOutputData(0,c[0]*e[0]+c[1]*e[1]+c[2]*e[2])}};D.registerNodeType("math3d/vec3-dot",E);if(y.glMatrix){y=function(){this.addInput("vec3","vec3");this.addOutput("remap","vec3");this.addOutput("clamped","vec3");this.properties={clamp:!0,range_min:[-1,-1,0],range_max:[1,1,0],target_min:[-1,-1,0],target_max:[1,1,0]};this._value=vec3.create(); +this._clamped=vec3.create()};var J=function(){this.addInputs([["A","quat"],["B","quat"],["factor","number"]]);this.addOutput("slerp","quat");this.addProperty("factor",.5);this._value=quat.create()},L=function(){this.addInputs([["A","quat"],["B","quat"]]);this.addOutput("A*B","quat");this._value=quat.create()},H=function(){this.addInputs([["vec3","vec3"],["quat","quat"]]);this.addOutput("result","vec3");this.properties={vec:[0,0,1]}},F=function(){this.addInput(["quat","quat"]);this.addOutput("euler", +"vec3");this._value=vec3.create()},e=function(){this.addInput("euler","vec3");this.addOutput("quat","quat");this.properties={euler:[0,0,0],use_yaw_pitch_roll:!1};this._degs=vec3.create();this._value=quat.create()},K=function(){this.addInputs([["degrees","number"],["axis","vec3"]]);this.addOutput("quat","quat");this.properties={angle:90,axis:vec3.fromValues(0,1,0)};this._value=quat.create()},B=function(){this.addOutput("quat","quat");this.properties={x:0,y:0,z:0,w:1,normalize:!1};this._value=quat.create()}; +B.title="Quaternion";B.desc="quaternion";B.prototype.onExecute=function(){this._value[0]=this.getInputOrProperty("x");this._value[1]=this.getInputOrProperty("y");this._value[2]=this.getInputOrProperty("z");this._value[3]=this.getInputOrProperty("w");this.properties.normalize&&quat.normalize(this._value,this._value);this.setOutputData(0,this._value)};B.prototype.onGetInputs=function(){return[["x","number"],["y","number"],["z","number"],["w","number"]]};D.registerNodeType("math3d/quaternion",B);K.title= +"Rotation";K.desc="quaternion rotation";K.prototype.onExecute=function(){var c=this.getInputData(0);null==c&&(c=this.properties.angle);var e=this.getInputData(1);null==e&&(e=this.properties.axis);c=quat.setAxisAngle(this._value,e,.0174532925*c);this.setOutputData(0,c)};D.registerNodeType("math3d/rotation",K);e.title="Euler->Quat";e.desc="Converts euler angles (in degrees) to quaternion";e.prototype.onExecute=function(){var c=this.getInputData(0);null==c&&(c=this.properties.euler);vec3.scale(this._degs, +c,DEG2RAD);this.properties.use_yaw_pitch_roll&&(this._degs=[this._degs[2],this._degs[0],this._degs[1]]);c=quat.fromEuler(this._value,this._degs);this.setOutputData(0,c)};D.registerNodeType("math3d/euler_to_quat",e);F.title="Euler->Quat";F.desc="Converts rotX,rotY,rotZ in degrees to quat";F.prototype.onExecute=function(){var c=this.getInputData(0);c&&(quat.toEuler(this._value,c),vec3.scale(this._value,this._value,DEG2RAD),this.setOutputData(0,this._value))};D.registerNodeType("math3d/quat_to_euler", +F);H.title="Rot. Vec3";H.desc="rotate a point";H.prototype.onExecute=function(){var c=this.getInputData(0);null==c&&(c=this.properties.vec);var e=this.getInputData(1);null==e?this.setOutputData(c):this.setOutputData(0,vec3.transformQuat(vec3.create(),c,e))};D.registerNodeType("math3d/rotate_vec3",H);L.title="Mult. Quat";L.desc="rotate quaternion";L.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var e=this.getInputData(1);null!=e&&(c=quat.multiply(this._value,c,e),this.setOutputData(0, +c))}};D.registerNodeType("math3d/mult-quat",L);J.title="Quat Slerp";J.desc="quaternion spherical interpolation";J.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var e=this.getInputData(1);if(null!=e){var m=this.properties.factor;null!=this.getInputData(2)&&(m=this.getInputData(2));c=quat.slerp(this._value,c,e,m);this.setOutputData(0,c)}}};D.registerNodeType("math3d/quat-slerp",J);y.title="Remap Range";y.desc="remap a 3D range";y.prototype.onExecute=function(){var c=this.getInputData(0); +c&&this._value.set(c);c=this.properties.range_min;for(var e=this.properties.range_max,m=this.properties.target_min,h=this.properties.target_max,k=0;3>k;++k){var a=e[k]-c[k];this._clamped[k]=clamp(this._value[k],c[k],e[k]);0==a?this._value[k]=.5*(m[k]+h[k]):(a=(this._value[k]-c[k])/a,this.properties.clamp&&(a=clamp(a,0,1)),this._value[k]=m[k]+a*(h[k]-m[k]))}this.setOutputData(0,this._value);this.setOutputData(1,this._clamped)};D.registerNodeType("math3d/remap_range",y)}else D.debug&&console.warn("No glmatrix found, some Math3D nodes may not work")})(this); +(function(y){function c(){this.addInput("","string");this.addOutput("table","table");this.addOutput("rows","number");this.addProperty("value","");this.addProperty("separator",",");this._table=null}y=y.LiteGraph;y.wrapFunctionAsNode("string/toString",function(c){if(c&&c.constructor===Object)try{return JSON.stringify(c)}catch(n){}return String(c)},[""],"string");y.wrapFunctionAsNode("string/compare",function(c,n){return c==n},["string","string"],"boolean");y.wrapFunctionAsNode("string/concatenate", +function(c,n){return void 0===c?n:void 0===n?c:c+n},["string","string"],"string");y.wrapFunctionAsNode("string/contains",function(c,n){return void 0===c||void 0===n?!1:-1!=c.indexOf(n)},["string","string"],"boolean");y.wrapFunctionAsNode("string/toUpperCase",function(c){return null!=c&&c.constructor===String?c.toUpperCase():c},["string"],"string");y.wrapFunctionAsNode("string/split",function(c,n){null==n&&(n=this.properties.separator);if(null==c)return[];if(c.constructor===String)return c.split(n|| +" ");if(c.constructor===Array){for(var k=[],u=0;ue;++e){var h=this.getInputData(e);if(null!=h){var k=this.values[e];k.push(h);k.length>c[0]&&k.shift()}}}};c.prototype.onDrawBackground=function(e){if(!this.flags.collapsed){var h= +this.size,k=.5*h[1]/this.properties.scale,n=c.colors,l=.5*h[1];e.fillStyle="#000";e.fillRect(0,0,h[0],h[1]);e.strokeStyle="#555";e.beginPath();e.moveTo(0,l);e.lineTo(h[0],l);e.stroke();if(this.inputs)for(var m=0;4>m;++m){var w=this.values[m];if(this.inputs[m]&&this.inputs[m].link){e.strokeStyle=n[m];e.beginPath();var r=w[0]*k*-1+l;e.moveTo(0,clamp(r,0,h[1]));for(var a=1;ah&&(h=0);if(0!=c.length){var k=[0,0,0];if(0==h)k=c[0];else if(1==h)k=c[c.length-1];else{var r= -(c.length-1)*h;h=c[Math.floor(r)];c=c[Math.floor(r)+1];r-=Math.floor(r);k[0]=h[0]*(1-r)+c[0]*r;k[1]=h[1]*(1-r)+c[1]*r;k[2]=h[2]*(1-r)+c[2]*r}for(h=0;hh&&(h=0);if(0!=c.length){var k=[0,0,0];if(0==h)k=c[0];else if(1==h)k=c[c.length-1];else{var n= +(c.length-1)*h;h=c[Math.floor(n)];c=c[Math.floor(n)+1];n-=Math.floor(n);k[0]=h[0]*(1-n)+c[0]*n;k[1]=h[1]*(1-n)+c[1]*n;k[2]=h[2]*(1-n)+c[2]*n}for(h=0;h=c&&(this._video.currentTime=c*this._video.duration,this._video.pause()); -this._video.dirty=!0;this.setOutputData(0,this._video);this.setOutputData(1,this._video.currentTime);this.setOutputData(2,this._video.duration);this.setDirtyCanvas(!0)}};L.prototype.onStart=function(){this.play()};L.prototype.onStop=function(){this.stop()};L.prototype.loadVideo=function(c){this._video_url=c;var e=c.substr(0,10).indexOf(":"),h="";-1!=e&&(h=c.substr(0,e));e="";h&&(e=c.substr(0,c.indexOf("/",h.length+3)),e=e.substr(h.length+3));this.properties.use_proxy&&h&&G.proxy&&e!=location.host&& -(c=G.proxy+c.substr(c.indexOf(":")+3));this._video=document.createElement("video");this._video.src=c;this._video.type="type=video/mp4";this._video.muted=!0;this._video.autoplay=!0;var k=this;this._video.addEventListener("loadedmetadata",function(c){console.log("Duration: "+this.duration+" seconds");console.log("Size: "+this.videoWidth+","+this.videoHeight);k.setDirtyCanvas(!0);this.width=this.videoWidth;this.height=this.videoHeight});this._video.addEventListener("progress",function(c){console.log("video loading...")}); +function(c){this.flags.collapsed||this.canvas&&c.drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,0,0,this.size[0],this.size[1])};h.prototype.onPropertyChanged=function(c,h){this.properties[c]=h;"scale"==c?(this.properties[c]=parseFloat(h),0==this.properties[c]&&(console.error("Error in scale"),this.properties[c]=1)):this.properties[c]=parseInt(h);this.createCanvas();return!0};F.registerNodeType("graphics/cropImage",h);E.title="Canvas";E.desc="Canvas to render stuff";E.prototype.onExecute= +function(){var c=this.canvas,h=this.properties.width|0,k=this.properties.height|0;c.width!=h&&(c.width=h);c.height!=k&&(c.height=k);this.properties.autoclear&&this.ctx.clearRect(0,0,c.width,c.height);this.setOutputData(0,c)};E.prototype.onAction=function(c,h){"clear"==c&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)};F.registerNodeType("graphics/canvas",E);D.title="DrawImage";D.desc="Draws image into a canvas";D.prototype.onExecute=function(){var c=this.getInputData(0);if(c){var h= +this.getInputOrProperty("img");if(h){var k=this.getInputOrProperty("x"),n=this.getInputOrProperty("y");c.getContext("2d").drawImage(h,k,n)}}};F.registerNodeType("graphics/drawImage",D);J.title="DrawRectangle";J.desc="Draws rectangle in canvas";J.prototype.onExecute=function(){var c=this.getInputData(0);if(c){var h=this.getInputOrProperty("x"),k=this.getInputOrProperty("y"),n=this.getInputOrProperty("w"),l=this.getInputOrProperty("h");c.getContext("2d").fillRect(h,k,n,l)}};F.registerNodeType("graphics/drawRectangle", +J);L.title="Video";L.desc="Video playback";L.widgets=[{name:"play",text:"PLAY",type:"minibutton"},{name:"stop",text:"STOP",type:"minibutton"},{name:"demo",text:"Demo video",type:"button"},{name:"mute",text:"Mute video",type:"button"}];L.prototype.onExecute=function(){if(this.properties.url&&(this.properties.url!=this._video_url&&this.loadVideo(this.properties.url),this._video&&0!=this._video.width)){var c=this.getInputData(0);c&&0<=c&&1>=c&&(this._video.currentTime=c*this._video.duration,this._video.pause()); +this._video.dirty=!0;this.setOutputData(0,this._video);this.setOutputData(1,this._video.currentTime);this.setOutputData(2,this._video.duration);this.setDirtyCanvas(!0)}};L.prototype.onStart=function(){this.play()};L.prototype.onStop=function(){this.stop()};L.prototype.loadVideo=function(c){this._video_url=c;var e=c.substr(0,10).indexOf(":"),h="";-1!=e&&(h=c.substr(0,e));e="";h&&(e=c.substr(0,c.indexOf("/",h.length+3)),e=e.substr(h.length+3));this.properties.use_proxy&&h&&F.proxy&&e!=location.host&& +(c=F.proxy+c.substr(c.indexOf(":")+3));this._video=document.createElement("video");this._video.src=c;this._video.type="type=video/mp4";this._video.muted=!0;this._video.autoplay=!0;var k=this;this._video.addEventListener("loadedmetadata",function(c){console.log("Duration: "+this.duration+" seconds");console.log("Size: "+this.videoWidth+","+this.videoHeight);k.setDirtyCanvas(!0);this.width=this.videoWidth;this.height=this.videoHeight});this._video.addEventListener("progress",function(c){console.log("video loading...")}); this._video.addEventListener("error",function(c){console.error("Error loading video: "+this.src);if(this.error)switch(this.error.code){case this.error.MEDIA_ERR_ABORTED:console.error("You stopped the video.");break;case this.error.MEDIA_ERR_NETWORK:console.error("Network error - please try again later.");break;case this.error.MEDIA_ERR_DECODE:console.error("Video is broken..");break;case this.error.MEDIA_ERR_SRC_NOT_SUPPORTED:console.error("Sorry, your browser can't play this video.")}});this._video.addEventListener("ended", function(c){console.log("Video Ended.");this.play()})};L.prototype.onPropertyChanged=function(c,h){this.properties[c]=h;"url"==c&&""!=h&&this.loadVideo(h);return!0};L.prototype.play=function(){this._video&&this._video.videoWidth&&this._video.play()};L.prototype.playPause=function(){this._video&&(this._video.paused?this.play():this.pause())};L.prototype.stop=function(){this._video&&(this._video.pause(),this._video.currentTime=0)};L.prototype.pause=function(){this._video&&(console.log("Video paused"), -this._video.pause())};L.prototype.onWidget=function(c,h){};G.registerNodeType("graphics/video",L);J.title="Webcam";J.desc="Webcam image";J.is_webcam_open=!1;J.prototype.openStream=function(){if(navigator.mediaDevices.getUserMedia){this._waiting_confirmation=!0;navigator.mediaDevices.getUserMedia({audio:!1,video:this.properties.filterFacingMode?{facingMode:this.properties.facingMode}:!0}).then(this.streamReady.bind(this)).catch(function(e){console.log("Webcam rejected",e);c._webcam_stream=!1;J.is_webcam_open= -!1;c.boxcolor="red";c.trigger("stream_error")});var c=this}else console.log("getUserMedia() is not supported in your browser, use chrome and enable WebRTC from about://flags")};J.prototype.closeStream=function(){if(this._webcam_stream){var c=this._webcam_stream.getTracks();if(c.length)for(var h=0;h=this.size[1]||!this.properties.show||!this._video||(c.save(),c.drawImage(this._video,0,0,this.size[0],this.size[1]),c.restore())};J.prototype.onGetOutputs=function(){return[["width","number"],["height","number"],["stream_ready",G.EVENT],["stream_closed",G.EVENT],["stream_error",G.EVENT]]};G.registerNodeType("graphics/webcam",J)})(this); -(function(B){function c(){this.addOutput("tex","Texture");this.addOutput("name","string");this.properties={name:"",filter:!0};this.size=[c.image_preview_size,c.image_preview_size]}function k(){this.addInput("Texture","Texture");this.properties={flipY:!1};this.size=[c.image_preview_size,c.image_preview_size]}function q(){this.addInput("Texture","Texture");this.addOutput("tex","Texture");this.addOutput("name","string");this.properties={name:"",generate_mipmaps:!1}}function r(){this.addInput("Texture", +this._video.pause())};L.prototype.onWidget=function(c,h){};F.registerNodeType("graphics/video",L);H.title="Webcam";H.desc="Webcam image";H.is_webcam_open=!1;H.prototype.openStream=function(){if(navigator.mediaDevices.getUserMedia){this._waiting_confirmation=!0;navigator.mediaDevices.getUserMedia({audio:!1,video:this.properties.filterFacingMode?{facingMode:this.properties.facingMode}:!0}).then(this.streamReady.bind(this)).catch(function(e){console.log("Webcam rejected",e);c._webcam_stream=!1;H.is_webcam_open= +!1;c.boxcolor="red";c.trigger("stream_error")});var c=this}else console.log("getUserMedia() is not supported in your browser, use chrome and enable WebRTC from about://flags")};H.prototype.closeStream=function(){if(this._webcam_stream){var c=this._webcam_stream.getTracks();if(c.length)for(var h=0;h=this.size[1]||!this.properties.show||!this._video||(c.save(),c.drawImage(this._video,0,0,this.size[0],this.size[1]),c.restore())};H.prototype.onGetOutputs=function(){return[["width","number"],["height","number"],["stream_ready",F.EVENT],["stream_closed",F.EVENT],["stream_error",F.EVENT]]};F.registerNodeType("graphics/webcam",H)})(this); +(function(y){function c(){this.addOutput("tex","Texture");this.addOutput("name","string");this.properties={name:"",filter:!0};this.size=[c.image_preview_size,c.image_preview_size]}function k(){this.addInput("Texture","Texture");this.properties={flipY:!1};this.size=[c.image_preview_size,c.image_preview_size]}function n(){this.addInput("Texture","Texture");this.addOutput("tex","Texture");this.addOutput("name","string");this.properties={name:"",generate_mipmaps:!1}}function r(){this.addInput("Texture", "Texture");this.addInput("TextureB","Texture");this.addInput("value","number");this.addOutput("Texture","Texture");this.help="

pixelcode must be vec3, uvcode must be vec2, is optional

\t\t

uv: tex. coords

color: texture colorB: textureB

time: scene time value: input value

For multiline you must type: result = ...

";this.properties={value:1,pixelcode:"color + colorB * value",uvcode:"",precision:c.DEFAULT}; -this.has_error=!1}function w(){this.addOutput("out","Texture");this.properties={code:"",u_value:1,u_color:[1,1,1,1],width:512,height:512,precision:c.DEFAULT};this.properties.code=w.pixel_shader;this._uniforms={u_value:1,u_color:vec4.create(),in_texture:0,texSize:vec4.create(),time:0}}function h(){this.addInput("in","Texture");this.addInput("scale","vec2");this.addInput("offset","vec2");this.addOutput("out","Texture");this.properties={offset:vec2.fromValues(0,0),scale:vec2.fromValues(1,1),precision:c.DEFAULT}} -function I(){this.addInput("in","Texture");this.addInput("warp","Texture");this.addInput("factor","number");this.addOutput("out","Texture");this.properties={factor:.01,scale:[1,1],offset:[0,0],precision:c.DEFAULT};this._uniforms={u_texture:0,u_textureB:1,u_factor:1,u_scale:vec2.create(),u_offset:vec2.create()}}function E(){this.addInput("Texture","Texture");this.properties={additive:!1,antialiasing:!1,filter:!0,disable_alpha:!1,gamma:1,viewport:[0,0,1,1]};this.size[0]=130}function H(){this.addInput("Texture", -"Texture");this.addOutput("","Texture");this.properties={size:0,generate_mipmaps:!1,precision:c.DEFAULT}}function L(){this.addInput("Texture","Texture");this.addOutput("","Texture");this.properties={iterations:1,generate_mipmaps:!1,precision:c.DEFAULT}}function J(){this.addInput("Texture","Texture");this.addOutput("","Texture");this.properties={size:[512,512],generate_mipmaps:!1,precision:c.DEFAULT}}function G(){this.addInput("Texture","Texture");this.addOutput("tex","Texture");this.addOutput("avg", +this.has_error=!1}function u(){this.addOutput("out","Texture");this.properties={code:"",u_value:1,u_color:[1,1,1,1],width:512,height:512,precision:c.DEFAULT};this.properties.code=u.pixel_shader;this._uniforms={u_value:1,u_color:vec4.create(),in_texture:0,texSize:vec4.create(),time:0}}function h(){this.addInput("in","Texture");this.addInput("scale","vec2");this.addInput("offset","vec2");this.addOutput("out","Texture");this.properties={offset:vec2.fromValues(0,0),scale:vec2.fromValues(1,1),precision:c.DEFAULT}} +function E(){this.addInput("in","Texture");this.addInput("warp","Texture");this.addInput("factor","number");this.addOutput("out","Texture");this.properties={factor:.01,scale:[1,1],offset:[0,0],precision:c.DEFAULT};this._uniforms={u_texture:0,u_textureB:1,u_factor:1,u_scale:vec2.create(),u_offset:vec2.create()}}function D(){this.addInput("Texture","Texture");this.properties={additive:!1,antialiasing:!1,filter:!0,disable_alpha:!1,gamma:1,viewport:[0,0,1,1]};this.size[0]=130}function J(){this.addInput("Texture", +"Texture");this.addOutput("","Texture");this.properties={size:0,generate_mipmaps:!1,precision:c.DEFAULT}}function L(){this.addInput("Texture","Texture");this.addOutput("","Texture");this.properties={iterations:1,generate_mipmaps:!1,precision:c.DEFAULT}}function H(){this.addInput("Texture","Texture");this.addOutput("","Texture");this.properties={size:[512,512],generate_mipmaps:!1,precision:c.DEFAULT}}function F(){this.addInput("Texture","Texture");this.addOutput("tex","Texture");this.addOutput("avg", "vec4");this.addOutput("lum","number");this.properties={use_previous_frame:!0,high_quality:!1};this._uniforms={u_texture:0,u_mipmap_offset:0};this._luminance=new Float32Array(4)}function e(){this.addInput("in","Texture");this.addInput("factor","Number");this.addOutput("out","Texture");this.properties={factor:.5};this._uniforms={u_texture:0,u_textureB:1,u_factor:this.properties.factor}}function K(){this.addInput("in","Texture");this.addOutput("avg","Texture");this.addOutput("array","Texture");this.properties= -{samples:64,frames_interval:1};this._uniforms={u_texture:0,u_textureB:1,u_samples:this.properties.samples,u_isamples:1/this.properties.samples};this.frame=0}function D(){this.addInput("Image","image");this.addOutput("","Texture");this.properties={}}function M(){this.addInput("Texture","Texture");this.addInput("LUT","Texture");this.addInput("Intensity","number");this.addOutput("","Texture");this.properties={enabled:!0,intensity:1,precision:c.DEFAULT,texture:null};M._shader||(M._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER, -M.pixel_shader))}function m(){this.addInput("Texture","Texture");this.addInput("Atlas","Texture");this.addOutput("","Texture");this.properties={enabled:!0,num_row_symbols:4,symbol_size:16,brightness:1,colorize:!1,filter:!1,invert:!1,precision:c.DEFAULT,generate_mipmaps:!1,texture:null};m._shader||(m._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,m.pixel_shader));this._uniforms={u_texture:0,u_textureB:1,u_row_simbols:4,u_simbol_size:16,u_res:vec2.create()}}function l(){this.addInput("Texture","Texture"); -this.addOutput("R","Texture");this.addOutput("G","Texture");this.addOutput("B","Texture");this.addOutput("A","Texture");l._shader||(l._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,l.pixel_shader))}function A(){this.addInput("R","Texture");this.addInput("G","Texture");this.addInput("B","Texture");this.addInput("A","Texture");this.addOutput("Texture","Texture");this.properties={precision:c.DEFAULT,R:1,G:1,B:1,A:1};this._color=vec4.create();this._uniforms={u_textureR:0,u_textureG:1,u_textureB:2, -u_textureA:3,u_color:this._color}}function O(){this.addOutput("Texture","Texture");this._tex_color=vec4.create();this.properties={color:vec4.create(),precision:c.DEFAULT}}function a(){this.addInput("A","color");this.addInput("B","color");this.addOutput("Texture","Texture");this.properties={angle:0,scale:1,A:[0,0,0],B:[1,1,1],texture_size:32};a._shader||(a._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,a.pixel_shader));this._uniforms={u_angle:0,u_colorA:vec3.create(),u_colorB:vec3.create()}}function b(){this.addInput("A", +{samples:64,frames_interval:1};this._uniforms={u_texture:0,u_textureB:1,u_samples:this.properties.samples,u_isamples:1/this.properties.samples};this.frame=0}function B(){this.addInput("Image","image");this.addOutput("","Texture");this.properties={}}function M(){this.addInput("Texture","Texture");this.addInput("LUT","Texture");this.addInput("Intensity","number");this.addOutput("","Texture");this.properties={enabled:!0,intensity:1,precision:c.DEFAULT,texture:null};M._shader||(M._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER, +M.pixel_shader))}function l(){this.addInput("Texture","Texture");this.addInput("Atlas","Texture");this.addOutput("","Texture");this.properties={enabled:!0,num_row_symbols:4,symbol_size:16,brightness:1,colorize:!1,filter:!1,invert:!1,precision:c.DEFAULT,generate_mipmaps:!1,texture:null};l._shader||(l._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,l.pixel_shader));this._uniforms={u_texture:0,u_textureB:1,u_row_simbols:4,u_simbol_size:16,u_res:vec2.create()}}function m(){this.addInput("Texture","Texture"); +this.addOutput("R","Texture");this.addOutput("G","Texture");this.addOutput("B","Texture");this.addOutput("A","Texture");m._shader||(m._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,m.pixel_shader))}function w(){this.addInput("R","Texture");this.addInput("G","Texture");this.addInput("B","Texture");this.addInput("A","Texture");this.addOutput("Texture","Texture");this.properties={precision:c.DEFAULT,R:1,G:1,B:1,A:1};this._color=vec4.create();this._uniforms={u_textureR:0,u_textureG:1,u_textureB:2, +u_textureA:3,u_color:this._color}}function N(){this.addOutput("Texture","Texture");this._tex_color=vec4.create();this.properties={color:vec4.create(),precision:c.DEFAULT}}function a(){this.addInput("A","color");this.addInput("B","color");this.addOutput("Texture","Texture");this.properties={angle:0,scale:1,A:[0,0,0],B:[1,1,1],texture_size:32};a._shader||(a._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,a.pixel_shader));this._uniforms={u_angle:0,u_colorA:vec3.create(),u_colorB:vec3.create()}}function b(){this.addInput("A", "Texture");this.addInput("B","Texture");this.addInput("Mixer","Texture");this.addOutput("Texture","Texture");this.properties={factor:.5,size_from_biggest:!0,invert:!1,precision:c.DEFAULT};this._uniforms={u_textureA:0,u_textureB:1,u_textureMix:2,u_mix:vec4.create()}}function d(){this.addInput("Tex.","Texture");this.addOutput("Edges","Texture");this.properties={invert:!0,threshold:!1,factor:1,precision:c.DEFAULT};d._shader||(d._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,d.pixel_shader))}function f(){this.addInput("Texture", -"Texture");this.addInput("Distance","number");this.addInput("Range","number");this.addOutput("Texture","Texture");this.properties={distance:100,range:50,only_depth:!1,high_precision:!1};this._uniforms={u_texture:0,u_distance:100,u_range:50,u_camera_planes:null}}function g(){this.addInput("Texture","Texture");this.addOutput("Texture","Texture");this.properties={precision:c.DEFAULT,invert:!1};this._uniforms={u_texture:0,u_camera_planes:null,u_ires:vec2.create()}}function n(){this.addInput("Texture", -"Texture");this.addInput("Iterations","number");this.addInput("Intensity","number");this.addOutput("Blurred","Texture");this.properties={intensity:1,iterations:1,preserve_aspect:!1,scale:[1,1],precision:c.DEFAULT}}function t(){this.intensity=.5;this.persistence=.6;this.iterations=8;this.threshold=.8;this.scale=1;this.dirt_texture=null;this.dirt_factor=.5;this._textures=[];this._uniforms={u_intensity:1,u_texture:0,u_glow_texture:1,u_threshold:0,u_texel_size:vec2.create()}}function z(){this.addInput("in", -"Texture");this.addInput("dirt","Texture");this.addOutput("out","Texture");this.addOutput("glow","Texture");this.properties={enabled:!0,intensity:1,persistence:.99,iterations:16,threshold:0,scale:1,dirt_factor:.5,precision:c.DEFAULT};this.fx=new t}function v(){this.addInput("Texture","Texture");this.addOutput("Filtered","Texture");this.properties={intensity:1,radius:5}}function u(){this.addInput("Texture","Texture");this.addOutput("Filtered","Texture");this.properties={sigma:1.4,k:1.6,p:21.7,epsilon:79, -phi:.017}}function C(){this.addOutput("Webcam","Texture");this.properties={texture_name:"",facingMode:"user"};this.boxcolor="black";this.version=0}function x(){this.addInput("in","Texture");this.addInput("f","number");this.addOutput("out","Texture");this.properties={enabled:!0,factor:1,precision:c.LOW};this._uniforms={u_texture:0,u_factor:1}}function N(){this.addInput("in","");this.properties={precision:c.LOW,width:0,height:0,channels:1};this.addOutput("out","Texture")}function F(){this.addInput("in", +"Texture");this.addInput("Distance","number");this.addInput("Range","number");this.addOutput("Texture","Texture");this.properties={distance:100,range:50,only_depth:!1,high_precision:!1};this._uniforms={u_texture:0,u_distance:100,u_range:50,u_camera_planes:null}}function g(){this.addInput("Texture","Texture");this.addOutput("Texture","Texture");this.properties={precision:c.DEFAULT,invert:!1};this._uniforms={u_texture:0,u_camera_planes:null,u_ires:vec2.create()}}function q(){this.addInput("Texture", +"Texture");this.addInput("Iterations","number");this.addInput("Intensity","number");this.addOutput("Blurred","Texture");this.properties={intensity:1,iterations:1,preserve_aspect:!1,scale:[1,1],precision:c.DEFAULT}}function z(){this.intensity=.5;this.persistence=.6;this.iterations=8;this.threshold=.8;this.scale=1;this.dirt_texture=null;this.dirt_factor=.5;this._textures=[];this._uniforms={u_intensity:1,u_texture:0,u_glow_texture:1,u_threshold:0,u_texel_size:vec2.create()}}function P(){this.addInput("in", +"Texture");this.addInput("dirt","Texture");this.addOutput("out","Texture");this.addOutput("glow","Texture");this.properties={enabled:!0,intensity:1,persistence:.99,iterations:16,threshold:0,scale:1,dirt_factor:.5,precision:c.DEFAULT};this.fx=new z}function I(){this.addInput("Texture","Texture");this.addOutput("Filtered","Texture");this.properties={intensity:1,radius:5}}function t(){this.addInput("Texture","Texture");this.addOutput("Filtered","Texture");this.properties={sigma:1.4,k:1.6,p:21.7,epsilon:79, +phi:.017}}function v(){this.addOutput("Webcam","Texture");this.properties={texture_name:"",facingMode:"user"};this.boxcolor="black";this.version=0}function C(){this.addInput("in","Texture");this.addInput("f","number");this.addOutput("out","Texture");this.properties={enabled:!0,factor:1,precision:c.LOW};this._uniforms={u_texture:0,u_factor:1}}function x(){this.addInput("in","");this.properties={precision:c.LOW,width:0,height:0,channels:1};this.addOutput("out","Texture")}function G(){this.addInput("in", "Texture");this.addOutput("out","Texture");this.properties={precision:c.LOW,split_channels:!1};this._values=new Uint8Array(1024);this._values.fill(255);this._curve_texture=null;this._uniforms={u_texture:0,u_curve:1,u_range:1};this._must_update=!0;this._points={RGB:[[0,0],[1,1]],R:[[0,0],[1,1]],G:[[0,0],[1,1]],B:[[0,0],[1,1]]};this.curve_editor=null;this.addWidget("toggle","Split Channels",!1,"split_channels");this.addWidget("combo","Channel","RGB",{values:["RGB","R","G","B"]});this.curve_offset=68; -this.size=[240,160]}function y(){this.addInput("in","Texture");this.addInput("exp","number");this.addOutput("out","Texture");this.properties={exposition:1,precision:c.LOW};this._uniforms={u_texture:0,u_exposition:1}}function R(){this.addInput("in","Texture");this.addInput("avg","number,Texture");this.addOutput("out","Texture");this.properties={enabled:!0,scale:1,gamma:1,average_lum:1,lum_white:1,precision:c.LOW};this._uniforms={u_texture:0,u_lumwhite2:1,u_igamma:1,u_scale:1,u_average_lum:1}}function T(){this.addOutput("out", +this.size=[240,160]}function A(){this.addInput("in","Texture");this.addInput("exp","number");this.addOutput("out","Texture");this.properties={exposition:1,precision:c.LOW};this._uniforms={u_texture:0,u_exposition:1}}function R(){this.addInput("in","Texture");this.addInput("avg","number,Texture");this.addOutput("out","Texture");this.properties={enabled:!0,scale:1,gamma:1,average_lum:1,lum_white:1,precision:c.LOW};this._uniforms={u_texture:0,u_lumwhite2:1,u_igamma:1,u_scale:1,u_average_lum:1}}function T(){this.addOutput("out", "Texture");this.properties={width:512,height:512,seed:0,persistence:.1,octaves:8,scale:1,offset:[0,0],amplitude:1,precision:c.DEFAULT};this._key=0;this._texture=null;this._uniforms={u_persistence:.1,u_seed:0,u_offset:vec2.create(),u_scale:1,u_viewport:vec2.create()}}function S(){this.addInput("v");this.addOutput("out","Texture");this.properties={code:S.default_code,width:512,height:512,clear:!0,precision:c.DEFAULT,use_html_canvas:!1};this._temp_texture=this._func=null;this.compileCode()}function U(){this.addInput("in", -"Texture");this.addOutput("out","Texture");this.properties={key_color:vec3.fromValues(0,1,0),threshold:.8,slope:.2,precision:c.DEFAULT}}function V(){this.addInput("in","texture");this.addInput("yaw","number");this.addOutput("out","texture");this.properties={yaw:0}}var P=B.LiteGraph,aa=B.LGraphCanvas;B.LGraphTexture=null;"undefined"!=typeof GL&&(aa.link_type_colors.Texture="#987",B.LGraphTexture=c,c.title="Texture",c.desc="Texture",c.widgets_info={name:{widget:"texture"},filter:{widget:"checkbox"}}, -c.loadTextureCallback=null,c.image_preview_size=256,c.UNDEFINED=0,c.PASS_THROUGH=1,c.COPY=2,c.LOW=3,c.HIGH=4,c.REUSE=5,c.DEFAULT=2,c.MODE_VALUES={undefined:c.UNDEFINED,"pass through":c.PASS_THROUGH,copy:c.COPY,low:c.LOW,high:c.HIGH,reuse:c.REUSE,default:c.DEFAULT},c.getTexturesContainer=function(){return gl.textures},c.loadTexture=function(a,b){b=b||{};var d=a;"http://"==d.substr(0,7)&&P.proxy&&(d=P.proxy+d.substr(7));return c.getTexturesContainer()[a]=GL.Texture.fromURL(d,b)},c.getTexture=function(a){var b= +"Texture");this.addOutput("out","Texture");this.properties={key_color:vec3.fromValues(0,1,0),threshold:.8,slope:.2,precision:c.DEFAULT}}function V(){this.addInput("in","texture");this.addInput("yaw","number");this.addOutput("out","texture");this.properties={yaw:0}}var O=y.LiteGraph,aa=y.LGraphCanvas;y.LGraphTexture=null;"undefined"!=typeof GL&&(aa.link_type_colors.Texture="#987",y.LGraphTexture=c,c.title="Texture",c.desc="Texture",c.widgets_info={name:{widget:"texture"},filter:{widget:"checkbox"}}, +c.loadTextureCallback=null,c.image_preview_size=256,c.UNDEFINED=0,c.PASS_THROUGH=1,c.COPY=2,c.LOW=3,c.HIGH=4,c.REUSE=5,c.DEFAULT=2,c.MODE_VALUES={undefined:c.UNDEFINED,"pass through":c.PASS_THROUGH,copy:c.COPY,low:c.LOW,high:c.HIGH,reuse:c.REUSE,default:c.DEFAULT},c.getTexturesContainer=function(){return gl.textures},c.loadTexture=function(a,b){b=b||{};var d=a;"http://"==d.substr(0,7)&&O.proxy&&(d=O.proxy+d.substr(7));return c.getTexturesContainer()[a]=GL.Texture.fromURL(d,b)},c.getTexture=function(a){var b= this.getTexturesContainer();if(!b)throw"Cannot load texture, container of textures not found";b=b[a];return!b&&a&&":"!=a[0]?this.loadTexture(a):b},c.getTargetTexture=function(a,b,d){if(!a)throw"LGraphTexture.getTargetTexture expects a reference texture";switch(d){case c.LOW:d=gl.UNSIGNED_BYTE;break;case c.HIGH:d=gl.HIGH_PRECISION_FORMAT;break;case c.REUSE:return a;default:d=a?a.type:gl.UNSIGNED_BYTE}b&&b.width==a.width&&b.height==a.height&&b.type==d&&b.format==a.format||(b=new GL.Texture(a.width, a.height,{type:d,format:a.format,filter:gl.LINEAR}));return b},c.getTextureType=function(a,b){b=b?b.type:gl.UNSIGNED_BYTE;switch(a){case c.HIGH:b=gl.HIGH_PRECISION_FORMAT;break;case c.LOW:b=gl.UNSIGNED_BYTE}return b},c.getWhiteTexture=function(){return this._white_texture?this._white_texture:this._white_texture=GL.Texture.fromMemory(1,1,[255,255,255,255],{format:gl.RGBA,wrap:gl.REPEAT,filter:gl.NEAREST})},c.getNoiseTexture=function(){if(this._noise_texture)return this._noise_texture;for(var a=new Uint8Array(1048576), b=0;1048576>b;++b)a[b]=255*Math.random();return this._noise_texture=a=GL.Texture.fromMemory(512,512,a,{format:gl.RGBA,wrap:gl.REPEAT,filter:gl.NEAREST})},c.prototype.onDropFile=function(a,b,c){a?("string"==typeof a?a=GL.Texture.fromURL(a):-1!=b.toLowerCase().indexOf(".dds")?a=GL.Texture.fromDDSInMemory(a):(a=new Blob([c]),a=URL.createObjectURL(a),a=GL.Texture.fromURL(a)),this._drop_texture=a,this.properties.name=b):(this._drop_texture=null,this.properties.name="")},c.prototype.getExtraMenuOptions= @@ -576,337 +577,339 @@ function(a){var b=this;if(this._drop_texture)return[{content:"Clear",callback:fu a);this.setOutputData(1,a.fullpath||a.filename);for(var b=2;b=this.size[1]))if(this._drop_texture&& a.webgl)a.drawImage(this._drop_texture,0,0,this.size[0],this.size[1]);else{if(this._last_preview_tex!=this._last_tex)if(a.webgl)this._canvas=this._last_tex;else{var b=c.generateLowResTexturePreview(this._last_tex);if(!b)return;this._last_preview_tex=this._last_tex;this._canvas=cloneCanvas(b)}this._canvas&&(a.save(),a.webgl||(a.translate(0,this.size[1]),a.scale(1,-1)),a.drawImage(this._canvas,0,0,this.size[0],this.size[1]),a.restore())}},c.generateLowResTexturePreview=function(a){if(!a)return null; var b=c.image_preview_size,d=a;if(a.format==gl.DEPTH_COMPONENT)return null;if(a.width>b||a.height>b)d=this._preview_temp_tex,this._preview_temp_tex||(this._preview_temp_tex=d=new GL.Texture(b,b,{minFilter:gl.NEAREST})),a.copyTo(d);a=this._preview_canvas;a||(this._preview_canvas=a=createCanvas(b,b));d&&d.toCanvas(a);return a},c.prototype.getResources=function(a){this.properties.name&&(a[this.properties.name]=GL.Texture);return a},c.prototype.onGetInputs=function(){return[["in","Texture"]]},c.prototype.onGetOutputs= -function(){return[["width","number"],["height","number"],["aspect","number"]]},c.replaceCode=function(a,b){return a.replace(/\{\{[a-zA-Z0-9_]*\}\}/g,function(a){a=a.replace(/[\{\}]/g,"");return b[a]||""})},P.registerNodeType("texture/texture",c),k.title="Preview",k.desc="Show a texture in the graph canvas",k.allow_preview=!1,k.prototype.onDrawBackground=function(a){if(!this.flags.collapsed&&(a.webgl||k.allow_preview)){var b=this.getInputData(0);b&&(b=!b.handle&&a.webgl?b:c.generateLowResTexturePreview(b), -a.save(),this.properties.flipY&&(a.translate(0,this.size[1]),a.scale(1,-1)),a.drawImage(b,0,0,this.size[0],this.size[1]),a.restore())}},P.registerNodeType("texture/preview",k),q.title="Save",q.desc="Save a texture in the repository",q.prototype.getPreviewTexture=function(){return this._texture},q.prototype.onExecute=function(){var a=this.getInputData(0);a&&(this.properties.generate_mipmaps&&(a.bind(0),a.setParameter(gl.TEXTURE_MIN_FILTER,gl.LINEAR_MIPMAP_LINEAR),gl.generateMipmap(a.texture_type), -a.unbind(0)),this.properties.name&&(c.storeTexture?c.storeTexture(this.properties.name,a):c.getTexturesContainer()[this.properties.name]=a),this._texture=a,this.setOutputData(0,a),this.setOutputData(1,this.properties.name))},P.registerNodeType("texture/save",q),r.widgets_info={uvcode:{widget:"code"},pixelcode:{widget:"code"},precision:{widget:"combo",values:c.MODE_VALUES}},r.title="Operation",r.desc="Texture shader operation",r.presets={},r.prototype.getExtraMenuOptions=function(a){var b=this;return[{content:b.properties.show? +function(){return[["width","number"],["height","number"],["aspect","number"]]},c.replaceCode=function(a,b){return a.replace(/\{\{[a-zA-Z0-9_]*\}\}/g,function(a){a=a.replace(/[\{\}]/g,"");return b[a]||""})},O.registerNodeType("texture/texture",c),k.title="Preview",k.desc="Show a texture in the graph canvas",k.allow_preview=!1,k.prototype.onDrawBackground=function(a){if(!this.flags.collapsed&&(a.webgl||k.allow_preview)){var b=this.getInputData(0);b&&(b=!b.handle&&a.webgl?b:c.generateLowResTexturePreview(b), +a.save(),this.properties.flipY&&(a.translate(0,this.size[1]),a.scale(1,-1)),a.drawImage(b,0,0,this.size[0],this.size[1]),a.restore())}},O.registerNodeType("texture/preview",k),n.title="Save",n.desc="Save a texture in the repository",n.prototype.getPreviewTexture=function(){return this._texture},n.prototype.onExecute=function(){var a=this.getInputData(0);a&&(this.properties.generate_mipmaps&&(a.bind(0),a.setParameter(gl.TEXTURE_MIN_FILTER,gl.LINEAR_MIPMAP_LINEAR),gl.generateMipmap(a.texture_type), +a.unbind(0)),this.properties.name&&(c.storeTexture?c.storeTexture(this.properties.name,a):c.getTexturesContainer()[this.properties.name]=a),this._texture=a,this.setOutputData(0,a),this.setOutputData(1,this.properties.name))},O.registerNodeType("texture/save",n),r.widgets_info={uvcode:{widget:"code"},pixelcode:{widget:"code"},precision:{widget:"combo",values:c.MODE_VALUES}},r.title="Operation",r.desc="Texture shader operation",r.presets={},r.prototype.getExtraMenuOptions=function(a){var b=this;return[{content:b.properties.show? "Hide Texture":"Show Texture",callback:function(){b.properties.show=!b.properties.show}}]},r.prototype.onPropertyChanged=function(){this.has_error=!1},r.prototype.onDrawBackground=function(a){this.flags.collapsed||20>=this.size[1]||!this.properties.show||!this._tex||this._tex.gl!=a||(a.save(),a.drawImage(this._tex,0,0,this.size[0],this.size[1]),a.restore())},r.prototype.onExecute=function(){var a=this.getInputData(0);if(this.isOutputConnected(0))if(this.properties.precision===c.PASS_THROUGH)this.setOutputData(0, a);else{var b=this.getInputData(1);if(this.properties.uvcode||this.properties.pixelcode){var d=512,f=512;a?(d=a.width,f=a.height):b&&(d=b.width,f=b.height);b||(b=GL.Texture.getWhiteTexture());var g=c.getTextureType(this.properties.precision,a);this._tex=a||this._tex?c.getTargetTexture(a||this._tex,this._tex,this.properties.precision):new GL.Texture(d,f,{type:g,format:gl.RGBA,filter:gl.LINEAR});g="";this.properties.uvcode&&(g="uv = "+this.properties.uvcode,-1!=this.properties.uvcode.indexOf(";")&& -(g=this.properties.uvcode));var e="";this.properties.pixelcode&&(e="result = "+this.properties.pixelcode,-1!=this.properties.pixelcode.indexOf(";")&&(e=this.properties.pixelcode));var h=this._shader;if(!(this.has_error||h&&this._shader_code==g+"|"+e)){var m=c.replaceCode(r.pixel_shader,{UV_CODE:g,PIXEL_CODE:e});try{h=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,m),this.boxcolor="#00FF00"}catch(Z){GL.Shader.dumpErrorToConsole(Z,Shader.SCREEN_VERTEX_SHADER,m);this.boxcolor="#FF0000";this.has_error=!0; -return}this._shader=h;this._shader_code=g+"|"+e}if(this._shader){var l=this.getInputData(2);null!=l?this.properties.value=l:l=parseFloat(this.properties.value);var k=this.graph.getTime();this._tex.drawTo(function(){gl.disable(gl.DEPTH_TEST);gl.disable(gl.CULL_FACE);gl.disable(gl.BLEND);a&&a.bind(0);b&&b.bind(1);var c=Mesh.getScreenQuad();h.uniforms({u_texture:0,u_textureB:1,value:l,texSize:[d,f,1/d,1/f],time:k}).draw(c)});this.setOutputData(0,this._tex)}}}},r.pixel_shader="precision highp float;\n\t\t\n\t\tuniform sampler2D u_texture;\n\t\tuniform sampler2D u_textureB;\n\t\tvarying vec2 v_coord;\n\t\tuniform vec4 texSize;\n\t\tuniform float time;\n\t\tuniform float value;\n\t\t\n\t\tvoid main() {\n\t\t\tvec2 uv = v_coord;\n\t\t\t{{UV_CODE}};\n\t\t\tvec4 color4 = texture2D(u_texture, uv);\n\t\t\tvec3 color = color4.rgb;\n\t\t\tvec4 color4B = texture2D(u_textureB, uv);\n\t\t\tvec3 colorB = color4B.rgb;\n\t\t\tvec3 result = color;\n\t\t\tfloat alpha = 1.0;\n\t\t\t{{PIXEL_CODE}};\n\t\t\tgl_FragColor = vec4(result, alpha);\n\t\t}\n\t\t", +(g=this.properties.uvcode));var e="";this.properties.pixelcode&&(e="result = "+this.properties.pixelcode,-1!=this.properties.pixelcode.indexOf(";")&&(e=this.properties.pixelcode));var l=this._shader;if(!(this.has_error||l&&this._shader_code==g+"|"+e)){var h=c.replaceCode(r.pixel_shader,{UV_CODE:g,PIXEL_CODE:e});try{l=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,h),this.boxcolor="#00FF00"}catch(Z){GL.Shader.dumpErrorToConsole(Z,Shader.SCREEN_VERTEX_SHADER,h);this.boxcolor="#FF0000";this.has_error=!0; +return}this._shader=l;this._shader_code=g+"|"+e}if(this._shader){var m=this.getInputData(2);null!=m?this.properties.value=m:m=parseFloat(this.properties.value);var k=this.graph.getTime();this._tex.drawTo(function(){gl.disable(gl.DEPTH_TEST);gl.disable(gl.CULL_FACE);gl.disable(gl.BLEND);a&&a.bind(0);b&&b.bind(1);var c=Mesh.getScreenQuad();l.uniforms({u_texture:0,u_textureB:1,value:m,texSize:[d,f,1/d,1/f],time:k}).draw(c)});this.setOutputData(0,this._tex)}}}},r.pixel_shader="precision highp float;\n\t\t\n\t\tuniform sampler2D u_texture;\n\t\tuniform sampler2D u_textureB;\n\t\tvarying vec2 v_coord;\n\t\tuniform vec4 texSize;\n\t\tuniform float time;\n\t\tuniform float value;\n\t\t\n\t\tvoid main() {\n\t\t\tvec2 uv = v_coord;\n\t\t\t{{UV_CODE}};\n\t\t\tvec4 color4 = texture2D(u_texture, uv);\n\t\t\tvec3 color = color4.rgb;\n\t\t\tvec4 color4B = texture2D(u_textureB, uv);\n\t\t\tvec3 colorB = color4B.rgb;\n\t\t\tvec3 result = color;\n\t\t\tfloat alpha = 1.0;\n\t\t\t{{PIXEL_CODE}};\n\t\t\tgl_FragColor = vec4(result, alpha);\n\t\t}\n\t\t", r.registerPreset=function(a,b){r.presets[a]=b},r.registerPreset("",""),r.registerPreset("bypass","color"),r.registerPreset("add","color + colorB * value"),r.registerPreset("substract","(color - colorB) * value"),r.registerPreset("mate","mix( color, colorB, color4B.a * value)"),r.registerPreset("invert","vec3(1.0) - color"),r.registerPreset("multiply","color * colorB * value"),r.registerPreset("divide","(color / colorB) / value"),r.registerPreset("difference","abs(color - colorB) * value"),r.registerPreset("max", "max(color, colorB) * value"),r.registerPreset("min","min(color, colorB) * value"),r.registerPreset("displace","texture2D(u_texture, uv + (colorB.xy - vec2(0.5)) * value).xyz"),r.registerPreset("grayscale","vec3(color.x + color.y + color.z) * value / 3.0"),r.registerPreset("saturation","mix( vec3(color.x + color.y + color.z) / 3.0, color, value )"),r.registerPreset("normalmap","\n\t\tfloat z0 = texture2D(u_texture, uv + vec2(-texSize.z, -texSize.w) ).x;\n\t\tfloat z1 = texture2D(u_texture, uv + vec2(0.0, -texSize.w) ).x;\n\t\tfloat z2 = texture2D(u_texture, uv + vec2(texSize.z, -texSize.w) ).x;\n\t\tfloat z3 = texture2D(u_texture, uv + vec2(-texSize.z, 0.0) ).x;\n\t\tfloat z4 = color.x;\n\t\tfloat z5 = texture2D(u_texture, uv + vec2(texSize.z, 0.0) ).x;\n\t\tfloat z6 = texture2D(u_texture, uv + vec2(-texSize.z, texSize.w) ).x;\n\t\tfloat z7 = texture2D(u_texture, uv + vec2(0.0, texSize.w) ).x;\n\t\tfloat z8 = texture2D(u_texture, uv + vec2(texSize.z, texSize.w) ).x;\n\t\tvec3 normal = vec3( z2 + 2.0*z4 + z7 - z0 - 2.0*z3 - z5, z5 + 2.0*z6 + z7 -z0 - 2.0*z1 - z2, 1.0 );\n\t\tnormal.xy *= value;\n\t\tresult.xyz = normalize(normal) * 0.5 + vec3(0.5);\n\t"), -r.registerPreset("threshold","vec3(color.x > colorB.x * value ? 1.0 : 0.0,color.y > colorB.y * value ? 1.0 : 0.0,color.z > colorB.z * value ? 1.0 : 0.0)"),r.prototype.onInspect=function(a){var b=this;a.addCombo("Presets","",{values:Object.keys(r.presets),callback:function(d){var c=r.presets[d];c&&(b.setProperty("pixelcode",c),b.title=d,a.refresh())}})},P.registerNodeType("texture/operation",r),w.title="Shader",w.desc="Texture shader",w.widgets_info={code:{type:"code",lang:"glsl"},precision:{widget:"combo", -values:c.MODE_VALUES}},w.prototype.onPropertyChanged=function(a,b){if("code"==a&&(a=this.getShader())){b=a.uniformInfo;if(this.inputs)for(var d={},c=0;c=this.size[1])){var b=this.getInputData(0);b&&a.drawImage(a==gl?b:gl.canvas,10,30,this.size[0]-20,this.size[1]-40)}},E.prototype.onExecute=function(){var a=this.getInputData(0);if(a){this.properties.disable_alpha?gl.disable(gl.BLEND):(gl.enable(gl.BLEND),this.properties.additive?gl.blendFunc(gl.SRC_ALPHA, -gl.ONE):gl.blendFunc(gl.SRC_ALPHA,gl.ONE_MINUS_SRC_ALPHA));gl.disable(gl.DEPTH_TEST);var b=this.properties.gamma||1;this.isInputConnected(1)&&(b=this.getInputData(1));a.setParameter(gl.TEXTURE_MAG_FILTER,this.properties.filter?gl.LINEAR:gl.NEAREST);var d=E._prev_viewport;d.set(gl.viewport_data);var c=this.properties.viewport;gl.viewport(d[0]+d[2]*c[0],d[1]+d[3]*c[1],d[2]*c[2],d[3]*c[3]);gl.getViewport();this.properties.antialiasing?(E._shader||(E._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER, -E.aa_pixel_shader)),c=Mesh.getScreenQuad(),a.bind(0),E._shader.uniforms({u_texture:0,uViewportSize:[a.width,a.height],u_igamma:1/b,inverseVP:[1/a.width,1/a.height]}).draw(c)):1!=b?(E._gamma_shader||(E._gamma_shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,E.gamma_pixel_shader)),a.toViewport(E._gamma_shader,{u_texture:0,u_igamma:1/b})):a.toViewport();gl.viewport(d[0],d[1],d[2],d[3])}},E.prototype.onGetInputs=function(){return[["gamma","number"]]},E.aa_pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec2 uViewportSize;\n\t\tuniform vec2 inverseVP;\n\t\tuniform float u_igamma;\n\t\t#define FXAA_REDUCE_MIN (1.0/ 128.0)\n\t\t#define FXAA_REDUCE_MUL (1.0 / 8.0)\n\t\t#define FXAA_SPAN_MAX 8.0\n\t\t\n\t\t/* from mitsuhiko/webgl-meincraft based on the code on geeks3d.com */\n\t\tvec4 applyFXAA(sampler2D tex, vec2 fragCoord)\n\t\t{\n\t\t\tvec4 color = vec4(0.0);\n\t\t\t/*vec2 inverseVP = vec2(1.0 / uViewportSize.x, 1.0 / uViewportSize.y);*/\n\t\t\tvec3 rgbNW = texture2D(tex, (fragCoord + vec2(-1.0, -1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbNE = texture2D(tex, (fragCoord + vec2(1.0, -1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbSW = texture2D(tex, (fragCoord + vec2(-1.0, 1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbSE = texture2D(tex, (fragCoord + vec2(1.0, 1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbM = texture2D(tex, fragCoord * inverseVP).xyz;\n\t\t\tvec3 luma = vec3(0.299, 0.587, 0.114);\n\t\t\tfloat lumaNW = dot(rgbNW, luma);\n\t\t\tfloat lumaNE = dot(rgbNE, luma);\n\t\t\tfloat lumaSW = dot(rgbSW, luma);\n\t\t\tfloat lumaSE = dot(rgbSE, luma);\n\t\t\tfloat lumaM = dot(rgbM, luma);\n\t\t\tfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n\t\t\tfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\t\t\t\n\t\t\tvec2 dir;\n\t\t\tdir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n\t\t\tdir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\t\t\t\n\t\t\tfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\t\t\t\n\t\t\tfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n\t\t\tdir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * inverseVP;\n\t\t\t\n\t\t\tvec3 rgbA = 0.5 * (texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz + \n\t\t\t\ttexture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n\t\t\tvec3 rgbB = rgbA * 0.5 + 0.25 * (texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz + \n\t\t\t\ttexture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n\t\t\t\n\t\t\t//return vec4(rgbA,1.0);\n\t\t\tfloat lumaB = dot(rgbB, luma);\n\t\t\tif ((lumaB < lumaMin) || (lumaB > lumaMax))\n\t\t\t\tcolor = vec4(rgbA, 1.0);\n\t\t\telse\n\t\t\t\tcolor = vec4(rgbB, 1.0);\n\t\t\tif(u_igamma != 1.0)\n\t\t\t\tcolor.xyz = pow( color.xyz, vec3(u_igamma) );\n\t\t\treturn color;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t gl_FragColor = applyFXAA( u_texture, v_coord * uViewportSize) ;\n\t\t}\n\t\t", -E.gamma_pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform float u_igamma;\n\t\tvoid main() {\n\t\t\tvec4 color = texture2D( u_texture, v_coord);\n\t\t\tcolor.xyz = pow(color.xyz, vec3(u_igamma) );\n\t\t gl_FragColor = color;\n\t\t}\n\t\t",P.registerNodeType("texture/toviewport",E),H.title="Copy",H.desc="Copy Texture",H.widgets_info={size:{widget:"combo",values:[0,32,64,128,256,512,1024,2048]},precision:{widget:"combo", -values:c.MODE_VALUES}},H.prototype.onExecute=function(){var a=this.getInputData(0);if((a||this._temp_texture)&&this.isOutputConnected(0)){if(a){var b=a.width,d=a.height;0!=this.properties.size&&(d=b=this.properties.size);var f=this._temp_texture,g=a.type;this.properties.precision===c.LOW?g=gl.UNSIGNED_BYTE:this.properties.precision===c.HIGH&&(g=gl.HIGH_PRECISION_FORMAT);f&&f.width==b&&f.height==d&&f.type==g||(f=gl.LINEAR,this.properties.generate_mipmaps&&isPowerOfTwo(b)&&isPowerOfTwo(d)&&(f=gl.LINEAR_MIPMAP_LINEAR), -this._temp_texture=new GL.Texture(b,d,{type:g,format:gl.RGBA,minFilter:f,magFilter:gl.LINEAR}));a.copyTo(this._temp_texture);this.properties.generate_mipmaps&&(this._temp_texture.bind(0),gl.generateMipmap(this._temp_texture.texture_type),this._temp_texture.unbind(0))}this.setOutputData(0,this._temp_texture)}},P.registerNodeType("texture/copy",H),L.title="Downsample",L.desc="Downsample Texture",L.widgets_info={iterations:{type:"number",step:1,precision:0,min:0},precision:{widget:"combo",values:c.MODE_VALUES}}, -L.prototype.onExecute=function(){var a=this.getInputData(0);if((a||this._temp_texture)&&this.isOutputConnected(0)&&a&&a.texture_type===GL.TEXTURE_2D)if(1>this.properties.iterations)this.setOutputData(0,a);else{var b=L._shader;b||(L._shader=b=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,L.pixel_shader));var d=a.width|0,f=a.height|0,g=a.type;this.properties.precision===c.LOW?g=gl.UNSIGNED_BYTE:this.properties.precision===c.HIGH&&(g=gl.HIGH_PRECISION_FORMAT);var e=this.properties.iterations||1,h=a,m= -[];g={type:g,format:a.format};var l=vec2.create(),k={u_offset:l};this._texture&&GL.Texture.releaseTemporary(this._texture);for(var A=0;A>1||0;f=f>>1||0;a=GL.Texture.getTemporary(d,f,g);m.push(a);h.setParameter(GL.TEXTURE_MAG_FILTER,GL.NEAREST);h.copyTo(a,b,k);if(1==d&&1==f)break;h=a}this._texture=m.pop();for(A=0;A colorB.x * value ? 1.0 : 0.0,color.y > colorB.y * value ? 1.0 : 0.0,color.z > colorB.z * value ? 1.0 : 0.0)"),r.prototype.onInspect=function(a){var b=this;a.addCombo("Presets","",{values:Object.keys(r.presets),callback:function(d){var c=r.presets[d];c&&(b.setProperty("pixelcode",c),b.title=d,a.refresh())}})},O.registerNodeType("texture/operation",r),u.title="Shader",u.desc="Texture shader",u.widgets_info={code:{type:"code",lang:"glsl"},precision:{widget:"combo", +values:c.MODE_VALUES}},u.prototype.onPropertyChanged=function(a,b){if("code"==a&&(a=this.getShader())){b=a.uniformInfo;if(this.inputs)for(var d={},c=0;c=this.size[1])){var b=this.getInputData(0);b&&a.drawImage(a==gl?b:gl.canvas,10,30,this.size[0]-20,this.size[1]-40)}},D.prototype.onExecute=function(){var a=this.getInputData(0);if(a){this.properties.disable_alpha?gl.disable(gl.BLEND):(gl.enable(gl.BLEND),this.properties.additive?gl.blendFunc(gl.SRC_ALPHA, +gl.ONE):gl.blendFunc(gl.SRC_ALPHA,gl.ONE_MINUS_SRC_ALPHA));gl.disable(gl.DEPTH_TEST);var b=this.properties.gamma||1;this.isInputConnected(1)&&(b=this.getInputData(1));a.setParameter(gl.TEXTURE_MAG_FILTER,this.properties.filter?gl.LINEAR:gl.NEAREST);var d=D._prev_viewport;d.set(gl.viewport_data);var c=this.properties.viewport;gl.viewport(d[0]+d[2]*c[0],d[1]+d[3]*c[1],d[2]*c[2],d[3]*c[3]);gl.getViewport();this.properties.antialiasing?(D._shader||(D._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER, +D.aa_pixel_shader)),c=Mesh.getScreenQuad(),a.bind(0),D._shader.uniforms({u_texture:0,uViewportSize:[a.width,a.height],u_igamma:1/b,inverseVP:[1/a.width,1/a.height]}).draw(c)):1!=b?(D._gamma_shader||(D._gamma_shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,D.gamma_pixel_shader)),a.toViewport(D._gamma_shader,{u_texture:0,u_igamma:1/b})):a.toViewport();gl.viewport(d[0],d[1],d[2],d[3])}},D.prototype.onGetInputs=function(){return[["gamma","number"]]},D.aa_pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec2 uViewportSize;\n\t\tuniform vec2 inverseVP;\n\t\tuniform float u_igamma;\n\t\t#define FXAA_REDUCE_MIN (1.0/ 128.0)\n\t\t#define FXAA_REDUCE_MUL (1.0 / 8.0)\n\t\t#define FXAA_SPAN_MAX 8.0\n\t\t\n\t\t/* from mitsuhiko/webgl-meincraft based on the code on geeks3d.com */\n\t\tvec4 applyFXAA(sampler2D tex, vec2 fragCoord)\n\t\t{\n\t\t\tvec4 color = vec4(0.0);\n\t\t\t/*vec2 inverseVP = vec2(1.0 / uViewportSize.x, 1.0 / uViewportSize.y);*/\n\t\t\tvec3 rgbNW = texture2D(tex, (fragCoord + vec2(-1.0, -1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbNE = texture2D(tex, (fragCoord + vec2(1.0, -1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbSW = texture2D(tex, (fragCoord + vec2(-1.0, 1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbSE = texture2D(tex, (fragCoord + vec2(1.0, 1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbM = texture2D(tex, fragCoord * inverseVP).xyz;\n\t\t\tvec3 luma = vec3(0.299, 0.587, 0.114);\n\t\t\tfloat lumaNW = dot(rgbNW, luma);\n\t\t\tfloat lumaNE = dot(rgbNE, luma);\n\t\t\tfloat lumaSW = dot(rgbSW, luma);\n\t\t\tfloat lumaSE = dot(rgbSE, luma);\n\t\t\tfloat lumaM = dot(rgbM, luma);\n\t\t\tfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n\t\t\tfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\t\t\t\n\t\t\tvec2 dir;\n\t\t\tdir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n\t\t\tdir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\t\t\t\n\t\t\tfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\t\t\t\n\t\t\tfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n\t\t\tdir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * inverseVP;\n\t\t\t\n\t\t\tvec3 rgbA = 0.5 * (texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz + \n\t\t\t\ttexture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n\t\t\tvec3 rgbB = rgbA * 0.5 + 0.25 * (texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz + \n\t\t\t\ttexture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n\t\t\t\n\t\t\t//return vec4(rgbA,1.0);\n\t\t\tfloat lumaB = dot(rgbB, luma);\n\t\t\tif ((lumaB < lumaMin) || (lumaB > lumaMax))\n\t\t\t\tcolor = vec4(rgbA, 1.0);\n\t\t\telse\n\t\t\t\tcolor = vec4(rgbB, 1.0);\n\t\t\tif(u_igamma != 1.0)\n\t\t\t\tcolor.xyz = pow( color.xyz, vec3(u_igamma) );\n\t\t\treturn color;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t gl_FragColor = applyFXAA( u_texture, v_coord * uViewportSize) ;\n\t\t}\n\t\t", +D.gamma_pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform float u_igamma;\n\t\tvoid main() {\n\t\t\tvec4 color = texture2D( u_texture, v_coord);\n\t\t\tcolor.xyz = pow(color.xyz, vec3(u_igamma) );\n\t\t gl_FragColor = color;\n\t\t}\n\t\t",O.registerNodeType("texture/toviewport",D),J.title="Copy",J.desc="Copy Texture",J.widgets_info={size:{widget:"combo",values:[0,32,64,128,256,512,1024,2048]},precision:{widget:"combo", +values:c.MODE_VALUES}},J.prototype.onExecute=function(){var a=this.getInputData(0);if((a||this._temp_texture)&&this.isOutputConnected(0)){if(a){var b=a.width,d=a.height;0!=this.properties.size&&(d=b=this.properties.size);var f=this._temp_texture,g=a.type;this.properties.precision===c.LOW?g=gl.UNSIGNED_BYTE:this.properties.precision===c.HIGH&&(g=gl.HIGH_PRECISION_FORMAT);f&&f.width==b&&f.height==d&&f.type==g||(f=gl.LINEAR,this.properties.generate_mipmaps&&isPowerOfTwo(b)&&isPowerOfTwo(d)&&(f=gl.LINEAR_MIPMAP_LINEAR), +this._temp_texture=new GL.Texture(b,d,{type:g,format:gl.RGBA,minFilter:f,magFilter:gl.LINEAR}));a.copyTo(this._temp_texture);this.properties.generate_mipmaps&&(this._temp_texture.bind(0),gl.generateMipmap(this._temp_texture.texture_type),this._temp_texture.unbind(0))}this.setOutputData(0,this._temp_texture)}},O.registerNodeType("texture/copy",J),L.title="Downsample",L.desc="Downsample Texture",L.widgets_info={iterations:{type:"number",step:1,precision:0,min:0},precision:{widget:"combo",values:c.MODE_VALUES}}, +L.prototype.onExecute=function(){var a=this.getInputData(0);if((a||this._temp_texture)&&this.isOutputConnected(0)&&a&&a.texture_type===GL.TEXTURE_2D)if(1>this.properties.iterations)this.setOutputData(0,a);else{var b=L._shader;b||(L._shader=b=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,L.pixel_shader));var d=a.width|0,f=a.height|0,g=a.type;this.properties.precision===c.LOW?g=gl.UNSIGNED_BYTE:this.properties.precision===c.HIGH&&(g=gl.HIGH_PRECISION_FORMAT);var e=this.properties.iterations||1,l=a,h= +[];g={type:g,format:a.format};var m=vec2.create(),k={u_offset:m};this._texture&&GL.Texture.releaseTemporary(this._texture);for(var w=0;w>1||0;f=f>>1||0;a=GL.Texture.getTemporary(d,f,g);h.push(a);l.setParameter(GL.TEXTURE_MAG_FILTER,GL.NEAREST);l.copyTo(a,b,k);if(1==d&&1==f)break;l=a}this._texture=h.pop();for(w=0;wc;c++)this.isOutputConnected(c)?(this._channels[c]&&this._channels[c].width==a.width&&this._channels[c].height==a.height&&this._channels[c].type==a.type&&this._channels[c].format==b||(this._channels[c]=new GL.Texture(a.width,a.height,{type:a.type,format:b,filter:gl.LINEAR})), -d++):this._channels[c]=null;if(d){gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var f=Mesh.getScreenQuad(),g=l._shader,e=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];for(c=0;4>c;c++)this._channels[c]&&(this._channels[c].drawTo(function(){a.bind(0);g.uniforms({u_texture:0,u_mask:e[c]}).draw(f)}),this.setOutputData(c,this._channels[c]))}}},l.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec4 u_mask;\n\t\t\n\t\tvoid main() {\n\t\t gl_FragColor = vec4( vec3( length( texture2D(u_texture, v_coord) * u_mask )), 1.0 );\n\t\t}\n\t\t", -P.registerNodeType("texture/textureChannels",l),A.title="Channels to Texture",A.desc="Split texture channels",A.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},A.prototype.onExecute=function(){var a=c.getWhiteTexture(),b=this.getInputData(0)||a,d=this.getInputData(1)||a,f=this.getInputData(2)||a,g=this.getInputData(3)||a;gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var e=Mesh.getScreenQuad();A._shader||(A._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,A.pixel_shader));var h=A._shader; -a=Math.max(b.width,d.width,f.width,g.width);var m=Math.max(b.height,d.height,f.height,g.height),l=this.properties.precision==c.HIGH?c.HIGH_PRECISION_FORMAT:gl.UNSIGNED_BYTE;this._texture&&this._texture.width==a&&this._texture.height==m&&this._texture.type==l||(this._texture=new GL.Texture(a,m,{type:l,format:gl.RGBA,filter:gl.LINEAR}));a=this._color;a[0]=this.properties.R;a[1]=this.properties.G;a[2]=this.properties.B;a[3]=this.properties.A;var k=this._uniforms;this._texture.drawTo(function(){b.bind(0); -d.bind(1);f.bind(2);g.bind(3);h.uniforms(k).draw(e)});this.setOutputData(0,this._texture)},A.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_textureR;\n\t\tuniform sampler2D u_textureG;\n\t\tuniform sampler2D u_textureB;\n\t\tuniform sampler2D u_textureA;\n\t\tuniform vec4 u_color;\n\t\t\n\t\tvoid main() {\n\t\t gl_FragColor = u_color * vec4( \t\t\t\t\ttexture2D(u_textureR, v_coord).r,\t\t\t\t\ttexture2D(u_textureG, v_coord).r,\t\t\t\t\ttexture2D(u_textureB, v_coord).r,\t\t\t\t\ttexture2D(u_textureA, v_coord).r);\n\t\t}\n\t\t", -P.registerNodeType("texture/channelsTexture",A),O.title="Color",O.desc="Generates a 1x1 texture with a constant color",O.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},O.prototype.onDrawBackground=function(a){var b=this.properties.color;a.fillStyle="rgb("+Math.floor(255*clamp(b[0],0,1))+","+Math.floor(255*clamp(b[1],0,1))+","+Math.floor(255*clamp(b[2],0,1))+")";this.flags.collapsed?this.boxcolor=a.fillStyle:a.fillRect(0,0,this.size[0],this.size[1])},O.prototype.onExecute=function(){var a= +d.u_invert=this.properties.invert?1:0;d.u_colorize=this.properties.colorize?1:0;this._tex=c.getTargetTexture(a,this._tex,this.properties.precision);d.u_res[0]=this._tex.width;d.u_res[1]=this._tex.height;this._tex.bind(0);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST);this._tex.drawTo(function(){b.bind(1);a.toViewport(l._shader,d)});this.properties.generate_mipmaps&&(this._tex.bind(0),gl.generateMipmap(this._tex.texture_type), +this._tex.unbind(0));this.setOutputData(0,this._tex)}else this.setOutputData(0,a)}}},l.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform sampler2D u_textureB;\n\t\tuniform float u_row_simbols;\n\t\tuniform float u_symbol_size;\n\t\tuniform float u_brightness;\n\t\tuniform float u_invert;\n\t\tuniform float u_colorize;\n\t\tuniform vec2 u_res;\n\t\t\n\t\tvoid main() {\n\t\t\tvec2 total_symbols = u_res / u_symbol_size;\n\t\t\tvec2 uv = floor(v_coord * total_symbols) / total_symbols; //pixelate \n\t\t\tvec2 local_uv = mod(v_coord * u_res, u_symbol_size) / u_symbol_size;\n\t\t\tlowp vec4 textureColor = texture2D(u_texture, uv );\n\t\t\tfloat lum = clamp(u_brightness * (textureColor.x + textureColor.y + textureColor.z)/3.0,0.0,1.0);\n\t\t\tif( u_invert == 1.0 ) lum = 1.0 - lum;\n\t\t\tfloat index = floor( lum * (u_row_simbols * u_row_simbols - 1.0));\n\t\t\tfloat col = mod( index, u_row_simbols );\n\t\t\tfloat row = u_row_simbols - floor( index / u_row_simbols ) - 1.0;\n\t\t\tvec2 simbol_uv = ( vec2( col, row ) + local_uv ) / u_row_simbols;\n\t\t\tvec4 color = texture2D( u_textureB, simbol_uv );\n\t\t\tif(u_colorize == 1.0)\n\t\t\t\tcolor *= textureColor;\n\t\t\tgl_FragColor = color;\n\t\t}\n\t\t", +O.registerNodeType("texture/encode",l),m.title="Texture to Channels",m.desc="Split texture channels",m.prototype.onExecute=function(){var a=this.getInputData(0);if(a){this._channels||(this._channels=Array(4));for(var b=gl.RGB,d=0,c=0;4>c;c++)this.isOutputConnected(c)?(this._channels[c]&&this._channels[c].width==a.width&&this._channels[c].height==a.height&&this._channels[c].type==a.type&&this._channels[c].format==b||(this._channels[c]=new GL.Texture(a.width,a.height,{type:a.type,format:b,filter:gl.LINEAR})), +d++):this._channels[c]=null;if(d){gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var f=Mesh.getScreenQuad(),g=m._shader,e=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];for(c=0;4>c;c++)this._channels[c]&&(this._channels[c].drawTo(function(){a.bind(0);g.uniforms({u_texture:0,u_mask:e[c]}).draw(f)}),this.setOutputData(c,this._channels[c]))}}},m.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec4 u_mask;\n\t\t\n\t\tvoid main() {\n\t\t gl_FragColor = vec4( vec3( length( texture2D(u_texture, v_coord) * u_mask )), 1.0 );\n\t\t}\n\t\t", +O.registerNodeType("texture/textureChannels",m),w.title="Channels to Texture",w.desc="Split texture channels",w.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},w.prototype.onExecute=function(){var a=c.getWhiteTexture(),b=this.getInputData(0)||a,d=this.getInputData(1)||a,f=this.getInputData(2)||a,g=this.getInputData(3)||a;gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var e=Mesh.getScreenQuad();w._shader||(w._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,w.pixel_shader));var l=w._shader; +a=Math.max(b.width,d.width,f.width,g.width);var h=Math.max(b.height,d.height,f.height,g.height),m=this.properties.precision==c.HIGH?c.HIGH_PRECISION_FORMAT:gl.UNSIGNED_BYTE;this._texture&&this._texture.width==a&&this._texture.height==h&&this._texture.type==m||(this._texture=new GL.Texture(a,h,{type:m,format:gl.RGBA,filter:gl.LINEAR}));a=this._color;a[0]=this.properties.R;a[1]=this.properties.G;a[2]=this.properties.B;a[3]=this.properties.A;var k=this._uniforms;this._texture.drawTo(function(){b.bind(0); +d.bind(1);f.bind(2);g.bind(3);l.uniforms(k).draw(e)});this.setOutputData(0,this._texture)},w.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_textureR;\n\t\tuniform sampler2D u_textureG;\n\t\tuniform sampler2D u_textureB;\n\t\tuniform sampler2D u_textureA;\n\t\tuniform vec4 u_color;\n\t\t\n\t\tvoid main() {\n\t\t gl_FragColor = u_color * vec4( \t\t\t\t\ttexture2D(u_textureR, v_coord).r,\t\t\t\t\ttexture2D(u_textureG, v_coord).r,\t\t\t\t\ttexture2D(u_textureB, v_coord).r,\t\t\t\t\ttexture2D(u_textureA, v_coord).r);\n\t\t}\n\t\t", +O.registerNodeType("texture/channelsTexture",w),N.title="Color",N.desc="Generates a 1x1 texture with a constant color",N.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},N.prototype.onDrawBackground=function(a){var b=this.properties.color;a.fillStyle="rgb("+Math.floor(255*clamp(b[0],0,1))+","+Math.floor(255*clamp(b[1],0,1))+","+Math.floor(255*clamp(b[2],0,1))+")";this.flags.collapsed?this.boxcolor=a.fillStyle:a.fillRect(0,0,this.size[0],this.size[1])},N.prototype.onExecute=function(){var a= this.properties.precision==c.HIGH?c.HIGH_PRECISION_FORMAT:gl.UNSIGNED_BYTE;this._tex&&this._tex.type==a||(this._tex=new GL.Texture(1,1,{format:gl.RGBA,type:a,minFilter:gl.NEAREST}));a=this.properties.color;if(this.inputs)for(var b=0;ba.width?d: -a,this._tex,this.properties.precision);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var e=Mesh.getScreenQuad(),h=null,m=this._uniforms;f?(h=b._shader_tex,h||(h=b._shader_tex=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,b.pixel_shader,{MIX_TEX:""}))):(h=b._shader_factor,h||(h=b._shader_factor=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,b.pixel_shader)),g=null==g?this.properties.factor:g,m.u_mix.set([g,g,g,g]));var l=this.properties.invert;this._tex.drawTo(function(){a.bind(l?1:0);d.bind(l?0:1);f&&f.bind(2); -h.uniforms(m).draw(e)});this.setOutputData(0,this._tex)}}},b.prototype.onGetInputs=function(){return[["factor","number"]]},b.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_textureA;\n\t\tuniform sampler2D u_textureB;\n\t\t#ifdef MIX_TEX\n\t\t\tuniform sampler2D u_textureMix;\n\t\t#else\n\t\t\tuniform vec4 u_mix;\n\t\t#endif\n\t\t\n\t\tvoid main() {\n\t\t\t#ifdef MIX_TEX\n\t\t\t vec4 f = texture2D(u_textureMix, v_coord);\n\t\t\t#else\n\t\t\t vec4 f = u_mix;\n\t\t\t#endif\n\t\t gl_FragColor = mix( texture2D(u_textureA, v_coord), texture2D(u_textureB, v_coord), f );\n\t\t}\n\t\t", -P.registerNodeType("texture/mix",b),d.title="Edges",d.desc="Detects edges",d.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},d.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(this.properties.precision===c.PASS_THROUGH)this.setOutputData(0,a);else if(a){this._tex=c.getTargetTexture(a,this._tex,this.properties.precision);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var b=Mesh.getScreenQuad(),f=d._shader,g=this.properties.invert,e=this.properties.factor, -h=this.properties.threshold?1:0;this._tex.drawTo(function(){a.bind(0);f.uniforms({u_texture:0,u_isize:[1/a.width,1/a.height],u_factor:e,u_threshold:h,u_invert:g?1:0}).draw(b)});this.setOutputData(0,this._tex)}}},d.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec2 u_isize;\n\t\tuniform int u_invert;\n\t\tuniform float u_factor;\n\t\tuniform float u_threshold;\n\t\t\n\t\tvoid main() {\n\t\t\tvec4 center = texture2D(u_texture, v_coord);\n\t\t\tvec4 up = texture2D(u_texture, v_coord + u_isize * vec2(0.0,1.0) );\n\t\t\tvec4 down = texture2D(u_texture, v_coord + u_isize * vec2(0.0,-1.0) );\n\t\t\tvec4 left = texture2D(u_texture, v_coord + u_isize * vec2(1.0,0.0) );\n\t\t\tvec4 right = texture2D(u_texture, v_coord + u_isize * vec2(-1.0,0.0) );\n\t\t\tvec4 diff = abs(center - up) + abs(center - down) + abs(center - left) + abs(center - right);\n\t\t\tdiff *= u_factor;\n\t\t\tif(u_invert == 1)\n\t\t\t\tdiff.xyz = vec3(1.0) - diff.xyz;\n\t\t\tif( u_threshold == 0.0 )\n\t\t\t\tgl_FragColor = vec4( diff.xyz, center.a );\n\t\t\telse\n\t\t\t\tgl_FragColor = vec4( diff.x > 0.5 ? 1.0 : 0.0, diff.y > 0.5 ? 1.0 : 0.0, diff.z > 0.5 ? 1.0 : 0.0, center.a );\n\t\t}\n\t\t", -P.registerNodeType("texture/edges",d),f.title="Depth Range",f.desc="Generates a texture with a depth range",f.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(a){var b=gl.UNSIGNED_BYTE;this.properties.high_precision&&(b=gl.half_float_ext?gl.HALF_FLOAT_OES:gl.FLOAT);this._temp_texture&&this._temp_texture.type==b&&this._temp_texture.width==a.width&&this._temp_texture.height==a.height||(this._temp_texture=new GL.Texture(a.width,a.height,{type:b,format:gl.RGBA, +this._tex.fill(a));this.setOutputData(0,this._tex)},N.prototype.onGetInputs=function(){return[["RGB","vec3"],["RGBA","vec4"],["R","number"],["G","number"],["B","number"],["A","number"]]},O.registerNodeType("texture/color",N),a.title="Gradient",a.desc="Generates a gradient",a["@A"]={type:"color"},a["@B"]={type:"color"},a["@texture_size"]={type:"enum",values:[32,64,128,256,512]},a.prototype.onExecute=function(){gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var b=GL.Mesh.getScreenQuad(),d=a._shader, +c=this.getInputData(0);c||(c=this.properties.A);var f=this.getInputData(1);f||(f=this.properties.B);for(var g=2;ga.width?d: +a,this._tex,this.properties.precision);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var e=Mesh.getScreenQuad(),l=null,h=this._uniforms;f?(l=b._shader_tex,l||(l=b._shader_tex=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,b.pixel_shader,{MIX_TEX:""}))):(l=b._shader_factor,l||(l=b._shader_factor=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,b.pixel_shader)),g=null==g?this.properties.factor:g,h.u_mix.set([g,g,g,g]));var m=this.properties.invert;this._tex.drawTo(function(){a.bind(m?1:0);d.bind(m?0:1);f&&f.bind(2); +l.uniforms(h).draw(e)});this.setOutputData(0,this._tex)}}},b.prototype.onGetInputs=function(){return[["factor","number"]]},b.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_textureA;\n\t\tuniform sampler2D u_textureB;\n\t\t#ifdef MIX_TEX\n\t\t\tuniform sampler2D u_textureMix;\n\t\t#else\n\t\t\tuniform vec4 u_mix;\n\t\t#endif\n\t\t\n\t\tvoid main() {\n\t\t\t#ifdef MIX_TEX\n\t\t\t vec4 f = texture2D(u_textureMix, v_coord);\n\t\t\t#else\n\t\t\t vec4 f = u_mix;\n\t\t\t#endif\n\t\t gl_FragColor = mix( texture2D(u_textureA, v_coord), texture2D(u_textureB, v_coord), f );\n\t\t}\n\t\t", +O.registerNodeType("texture/mix",b),d.title="Edges",d.desc="Detects edges",d.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},d.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(this.properties.precision===c.PASS_THROUGH)this.setOutputData(0,a);else if(a){this._tex=c.getTargetTexture(a,this._tex,this.properties.precision);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var b=Mesh.getScreenQuad(),f=d._shader,g=this.properties.invert,e=this.properties.factor, +l=this.properties.threshold?1:0;this._tex.drawTo(function(){a.bind(0);f.uniforms({u_texture:0,u_isize:[1/a.width,1/a.height],u_factor:e,u_threshold:l,u_invert:g?1:0}).draw(b)});this.setOutputData(0,this._tex)}}},d.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec2 u_isize;\n\t\tuniform int u_invert;\n\t\tuniform float u_factor;\n\t\tuniform float u_threshold;\n\t\t\n\t\tvoid main() {\n\t\t\tvec4 center = texture2D(u_texture, v_coord);\n\t\t\tvec4 up = texture2D(u_texture, v_coord + u_isize * vec2(0.0,1.0) );\n\t\t\tvec4 down = texture2D(u_texture, v_coord + u_isize * vec2(0.0,-1.0) );\n\t\t\tvec4 left = texture2D(u_texture, v_coord + u_isize * vec2(1.0,0.0) );\n\t\t\tvec4 right = texture2D(u_texture, v_coord + u_isize * vec2(-1.0,0.0) );\n\t\t\tvec4 diff = abs(center - up) + abs(center - down) + abs(center - left) + abs(center - right);\n\t\t\tdiff *= u_factor;\n\t\t\tif(u_invert == 1)\n\t\t\t\tdiff.xyz = vec3(1.0) - diff.xyz;\n\t\t\tif( u_threshold == 0.0 )\n\t\t\t\tgl_FragColor = vec4( diff.xyz, center.a );\n\t\t\telse\n\t\t\t\tgl_FragColor = vec4( diff.x > 0.5 ? 1.0 : 0.0, diff.y > 0.5 ? 1.0 : 0.0, diff.z > 0.5 ? 1.0 : 0.0, center.a );\n\t\t}\n\t\t", +O.registerNodeType("texture/edges",d),f.title="Depth Range",f.desc="Generates a texture with a depth range",f.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(a){var b=gl.UNSIGNED_BYTE;this.properties.high_precision&&(b=gl.half_float_ext?gl.HALF_FLOAT_OES:gl.FLOAT);this._temp_texture&&this._temp_texture.type==b&&this._temp_texture.width==a.width&&this._temp_texture.height==a.height||(this._temp_texture=new GL.Texture(a.width,a.height,{type:b,format:gl.RGBA, filter:gl.LINEAR}));var d=this._uniforms;b=this.properties.distance;this.isInputConnected(1)&&(b=this.getInputData(1),this.properties.distance=b);var c=this.properties.range;this.isInputConnected(2)&&(c=this.getInputData(2),this.properties.range=c);d.u_distance=b;d.u_range=c;gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var g=Mesh.getScreenQuad();f._shader||(f._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,f.pixel_shader),f._shader_onlydepth=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,f.pixel_shader, {ONLY_DEPTH:""}));var e=this.properties.only_depth?f._shader_onlydepth:f._shader;b=null;b=a.near_far_planes?a.near_far_planes:window.LS&&LS.Renderer._main_camera?LS.Renderer._main_camera._uniforms.u_camera_planes:[.1,1E3];d.u_camera_planes=b;this._temp_texture.drawTo(function(){a.bind(0);e.uniforms(d).draw(g)});this._temp_texture.near_far_planes=b;this.setOutputData(0,this._temp_texture)}}},f.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec2 u_camera_planes;\n\t\tuniform float u_distance;\n\t\tuniform float u_range;\n\t\t\n\t\tfloat LinearDepth()\n\t\t{\n\t\t\tfloat zNear = u_camera_planes.x;\n\t\t\tfloat zFar = u_camera_planes.y;\n\t\t\tfloat depth = texture2D(u_texture, v_coord).x;\n\t\t\tdepth = depth * 2.0 - 1.0;\n\t\t\treturn zNear * (depth + 1.0) / (zFar + zNear - depth * (zFar - zNear));\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = LinearDepth();\n\t\t\t#ifdef ONLY_DEPTH\n\t\t\t gl_FragColor = vec4(depth);\n\t\t\t#else\n\t\t\t\tfloat diff = abs(depth * u_camera_planes.y - u_distance);\n\t\t\t\tfloat dof = 1.0;\n\t\t\t\tif(diff <= u_range)\n\t\t\t\t\tdof = diff / u_range;\n\t\t\t gl_FragColor = vec4(dof);\n\t\t\t#endif\n\t\t}\n\t\t", -P.registerNodeType("texture/depth_range",f),g.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},g.title="Linear Depth",g.desc="Creates a color texture with linear depth",g.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(a&&(a.format==gl.DEPTH_COMPONENT||a.format==gl.DEPTH_STENCIL)){var b=this.properties.precision==c.HIGH?gl.HIGH_PRECISION_FORMAT:gl.UNSIGNED_BYTE;this._temp_texture&&this._temp_texture.type==b&&this._temp_texture.width==a.width&& +O.registerNodeType("texture/depth_range",f),g.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},g.title="Linear Depth",g.desc="Creates a color texture with linear depth",g.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(a&&(a.format==gl.DEPTH_COMPONENT||a.format==gl.DEPTH_STENCIL)){var b=this.properties.precision==c.HIGH?gl.HIGH_PRECISION_FORMAT:gl.UNSIGNED_BYTE;this._temp_texture&&this._temp_texture.type==b&&this._temp_texture.width==a.width&& this._temp_texture.height==a.height||(this._temp_texture=new GL.Texture(a.width,a.height,{type:b,format:gl.RGB,filter:gl.LINEAR}));var d=this._uniforms;d.u_invert=this.properties.invert?1:0;gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var f=Mesh.getScreenQuad();g._shader||(g._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,g.pixel_shader));var e=g._shader;b=null;b=a.near_far_planes?a.near_far_planes:window.LS&&LS.Renderer._main_camera?LS.Renderer._main_camera._uniforms.u_camera_planes:[.1,1E3]; d.u_camera_planes=b;d.u_ires.set([0,0]);this._temp_texture.drawTo(function(){a.bind(0);e.uniforms(d).draw(f)});this._temp_texture.near_far_planes=b;this.setOutputData(0,this._temp_texture)}}},g.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec2 u_camera_planes;\n\t\tuniform int u_invert;\n\t\tuniform vec2 u_ires;\n\t\t\n\t\tvoid main() {\n\t\t\tfloat zNear = u_camera_planes.x;\n\t\t\tfloat zFar = u_camera_planes.y;\n\t\t\tfloat depth = texture2D(u_texture, v_coord + u_ires*0.5).x * 2.0 - 1.0;\n\t\t\tfloat f = zNear * (depth + 1.0) / (zFar + zNear - depth * (zFar - zNear));\n\t\t\tif( u_invert == 1 )\n\t\t\t\tf = 1.0 - f;\n\t\t\tgl_FragColor = vec4(vec3(f),1.0);\n\t\t}\n\t\t", -P.registerNodeType("texture/linear_depth",g),n.title="Blur",n.desc="Blur a texture",n.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},n.max_iterations=20,n.prototype.onExecute=function(){var a=this.getInputData(0);if(a&&this.isOutputConnected(0)){var b=this._final_texture;b&&b.width==a.width&&b.height==a.height&&b.type==a.type||(b=this._final_texture=new GL.Texture(a.width,a.height,{type:a.type,format:gl.RGBA,filter:gl.LINEAR}));var d=this.properties.iterations;this.isInputConnected(1)&& -(d=this.getInputData(1),this.properties.iterations=d);d=Math.min(Math.floor(d),n.max_iterations);if(0==d)this.setOutputData(0,a);else{var c=this.properties.intensity;this.isInputConnected(2)&&(c=this.getInputData(2),this.properties.intensity=c);var f=P.camera_aspect;f||void 0===window.gl||(f=gl.canvas.height/gl.canvas.width);f||(f=1);f=this.properties.preserve_aspect?f:1;var g=this.properties.scale||[1,1];a.applyBlur(f*g[0],g[1],c,b);for(a=1;a>=1;1<(g|0)&&(g>>=1);if(2>f)break;k=m[N]=GL.Texture.getTemporary(f,g,e);F[0]=1/A.width;F[1]=1/A.height;A.blit(k,l.uniforms(h));A=k}c&&(F[0]=1/A.width,F[1]=1/A.height,h.u_intensity=y,h.u_delta=1,A.blit(c,l.uniforms(h)));gl.enable(gl.BLEND);gl.blendFunc(gl.ONE,gl.ONE);h.u_intensity=this.persistence; -h.u_delta=.5;for(N-=2;0<=N;N--)k=m[N],m[N]=null,F[0]=1/A.width,F[1]=1/A.height,A.blit(k,l.uniforms(h)),GL.Texture.releaseTemporary(A),A=k;gl.disable(gl.BLEND);d&&A.blit(d);if(b){var r=this.dirt_texture,u=this.dirt_factor;h.u_intensity=y;l=r?t._dirt_final_shader:t._final_shader;l||(l=r?t._dirt_final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,t.final_pixel_shader,{USE_DIRT:""}):t._final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,t.final_pixel_shader));b.drawTo(function(){a.bind(0); -A.bind(1);r&&(l.setUniform("u_dirt_factor",u),l.setUniform("u_dirt_texture",r.bind(2)));l.toViewport(h)})}GL.Texture.releaseTemporary(A)},t.cut_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform float u_threshold;\n\tvoid main() {\n\t\tgl_FragColor = max( texture2D( u_texture, v_coord ) - vec4( u_threshold ), vec4(0.0) );\n\t}",t.scale_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform vec2 u_texel_size;\n\tuniform float u_delta;\n\tuniform float u_intensity;\n\t\n\tvec4 sampleBox(vec2 uv) {\n\t\tvec4 o = u_texel_size.xyxy * vec2(-u_delta, u_delta).xxyy;\n\t\tvec4 s = texture2D( u_texture, uv + o.xy ) + texture2D( u_texture, uv + o.zy) + texture2D( u_texture, uv + o.xw) + texture2D( u_texture, uv + o.zw);\n\t\treturn s * 0.25;\n\t}\n\tvoid main() {\n\t\tgl_FragColor = u_intensity * sampleBox( v_coord );\n\t}", -t.final_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform sampler2D u_glow_texture;\n\t#ifdef USE_DIRT\n\t\tuniform sampler2D u_dirt_texture;\n\t#endif\n\tuniform vec2 u_texel_size;\n\tuniform float u_delta;\n\tuniform float u_intensity;\n\tuniform float u_dirt_factor;\n\t\n\tvec4 sampleBox(vec2 uv) {\n\t\tvec4 o = u_texel_size.xyxy * vec2(-u_delta, u_delta).xxyy;\n\t\tvec4 s = texture2D( u_glow_texture, uv + o.xy ) + texture2D( u_glow_texture, uv + o.zy) + texture2D( u_glow_texture, uv + o.xw) + texture2D( u_glow_texture, uv + o.zw);\n\t\treturn s * 0.25;\n\t}\n\tvoid main() {\n\t\tvec4 glow = sampleBox( v_coord );\n\t\t#ifdef USE_DIRT\n\t\t\tglow = mix( glow, glow * texture2D( u_dirt_texture, v_coord ), u_dirt_factor );\n\t\t#endif\n\t\tgl_FragColor = texture2D( u_texture, v_coord ) + u_intensity * glow;\n\t}", -z.title="Glow",z.desc="Filters a texture giving it a glow effect",z.widgets_info={iterations:{type:"number",min:0,max:16,step:1,precision:0},threshold:{type:"number",min:0,max:10,step:.01,precision:2},precision:{widget:"combo",values:c.MODE_VALUES}},z.prototype.onGetInputs=function(){return[["enabled","boolean"],["threshold","number"],["intensity","number"],["persistence","number"],["iterations","number"],["dirt_factor","number"]]},z.prototype.onGetOutputs=function(){return[["average","Texture"]]}, -z.prototype.onExecute=function(){var a=this.getInputData(0);if(a&&this.isAnyOutputConnected())if(this.properties.precision===c.PASS_THROUGH||!1===this.getInputOrProperty("enabled"))this.setOutputData(0,a);else{var b=this.fx;b.threshold=this.getInputOrProperty("threshold");b.iterations=this.getInputOrProperty("iterations");b.intensity=this.getInputOrProperty("intensity");b.persistence=this.getInputOrProperty("persistence");b.dirt_texture=this.getInputData(1);b.dirt_factor=this.getInputOrProperty("dirt_factor"); +O.registerNodeType("texture/linear_depth",g),q.title="Blur",q.desc="Blur a texture",q.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},q.max_iterations=20,q.prototype.onExecute=function(){var a=this.getInputData(0);if(a&&this.isOutputConnected(0)){var b=this._final_texture;b&&b.width==a.width&&b.height==a.height&&b.type==a.type||(b=this._final_texture=new GL.Texture(a.width,a.height,{type:a.type,format:gl.RGBA,filter:gl.LINEAR}));var d=this.properties.iterations;this.isInputConnected(1)&& +(d=this.getInputData(1),this.properties.iterations=d);d=Math.min(Math.floor(d),q.max_iterations);if(0==d)this.setOutputData(0,a);else{var c=this.properties.intensity;this.isInputConnected(2)&&(c=this.getInputData(2),this.properties.intensity=c);var f=O.camera_aspect;f||void 0===window.gl||(f=gl.canvas.height/gl.canvas.width);f||(f=1);f=this.properties.preserve_aspect?f:1;var g=this.properties.scale||[1,1];a.applyBlur(f*g[0],g[1],c,b);for(a=1;a>=1;1<(g|0)&&(g>>=1);if(2>f)break;k=h[A]=GL.Texture.getTemporary(f,g,e);q[0]=1/w.width;q[1]=1/w.height;w.blit(k,m.uniforms(l));w=k}c&&(q[0]=1/w.width,q[1]=1/w.height,l.u_intensity=G,l.u_delta=1,w.blit(c,m.uniforms(l)));gl.enable(gl.BLEND);gl.blendFunc(gl.ONE,gl.ONE);l.u_intensity=this.persistence; +l.u_delta=.5;for(A-=2;0<=A;A--)k=h[A],h[A]=null,q[0]=1/w.width,q[1]=1/w.height,w.blit(k,m.uniforms(l)),GL.Texture.releaseTemporary(w),w=k;gl.disable(gl.BLEND);d&&w.blit(d);if(b){var n=this.dirt_texture,t=this.dirt_factor;l.u_intensity=G;m=n?z._dirt_final_shader:z._final_shader;m||(m=n?z._dirt_final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,z.final_pixel_shader,{USE_DIRT:""}):z._final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,z.final_pixel_shader));b.drawTo(function(){a.bind(0); +w.bind(1);n&&(m.setUniform("u_dirt_factor",t),m.setUniform("u_dirt_texture",n.bind(2)));m.toViewport(l)})}GL.Texture.releaseTemporary(w)},z.cut_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform float u_threshold;\n\tvoid main() {\n\t\tgl_FragColor = max( texture2D( u_texture, v_coord ) - vec4( u_threshold ), vec4(0.0) );\n\t}",z.scale_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform vec2 u_texel_size;\n\tuniform float u_delta;\n\tuniform float u_intensity;\n\t\n\tvec4 sampleBox(vec2 uv) {\n\t\tvec4 o = u_texel_size.xyxy * vec2(-u_delta, u_delta).xxyy;\n\t\tvec4 s = texture2D( u_texture, uv + o.xy ) + texture2D( u_texture, uv + o.zy) + texture2D( u_texture, uv + o.xw) + texture2D( u_texture, uv + o.zw);\n\t\treturn s * 0.25;\n\t}\n\tvoid main() {\n\t\tgl_FragColor = u_intensity * sampleBox( v_coord );\n\t}", +z.final_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform sampler2D u_glow_texture;\n\t#ifdef USE_DIRT\n\t\tuniform sampler2D u_dirt_texture;\n\t#endif\n\tuniform vec2 u_texel_size;\n\tuniform float u_delta;\n\tuniform float u_intensity;\n\tuniform float u_dirt_factor;\n\t\n\tvec4 sampleBox(vec2 uv) {\n\t\tvec4 o = u_texel_size.xyxy * vec2(-u_delta, u_delta).xxyy;\n\t\tvec4 s = texture2D( u_glow_texture, uv + o.xy ) + texture2D( u_glow_texture, uv + o.zy) + texture2D( u_glow_texture, uv + o.xw) + texture2D( u_glow_texture, uv + o.zw);\n\t\treturn s * 0.25;\n\t}\n\tvoid main() {\n\t\tvec4 glow = sampleBox( v_coord );\n\t\t#ifdef USE_DIRT\n\t\t\tglow = mix( glow, glow * texture2D( u_dirt_texture, v_coord ), u_dirt_factor );\n\t\t#endif\n\t\tgl_FragColor = texture2D( u_texture, v_coord ) + u_intensity * glow;\n\t}", +P.title="Glow",P.desc="Filters a texture giving it a glow effect",P.widgets_info={iterations:{type:"number",min:0,max:16,step:1,precision:0},threshold:{type:"number",min:0,max:10,step:.01,precision:2},precision:{widget:"combo",values:c.MODE_VALUES}},P.prototype.onGetInputs=function(){return[["enabled","boolean"],["threshold","number"],["intensity","number"],["persistence","number"],["iterations","number"],["dirt_factor","number"]]},P.prototype.onGetOutputs=function(){return[["average","Texture"]]}, +P.prototype.onExecute=function(){var a=this.getInputData(0);if(a&&this.isAnyOutputConnected())if(this.properties.precision===c.PASS_THROUGH||!1===this.getInputOrProperty("enabled"))this.setOutputData(0,a);else{var b=this.fx;b.threshold=this.getInputOrProperty("threshold");b.iterations=this.getInputOrProperty("iterations");b.intensity=this.getInputOrProperty("intensity");b.persistence=this.getInputOrProperty("persistence");b.dirt_texture=this.getInputData(1);b.dirt_factor=this.getInputOrProperty("dirt_factor"); b.scale=this.properties.scale;var d=c.getTextureType(this.properties.precision,a),f=null;this.isOutputConnected(2)&&(f=this._average_texture,f&&f.type==a.type&&f.format==a.format||(f=this._average_texture=new GL.Texture(1,1,{type:a.type,format:a.format,filter:gl.LINEAR})));var g=null;this.isOutputConnected(1)&&(g=this._glow_texture,g&&g.width==a.width&&g.height==a.height&&g.type==d&&g.format==a.format||(g=this._glow_texture=new GL.Texture(a.width,a.height,{type:d,format:a.format,filter:gl.LINEAR}))); -var e=null;this.isOutputConnected(0)&&(e=this._final_texture,e&&e.width==a.width&&e.height==a.height&&e.type==d&&e.format==a.format||(e=this._final_texture=new GL.Texture(a.width,a.height,{type:d,format:a.format,filter:gl.LINEAR})));b.applyFX(a,e,g,f);this.isOutputConnected(0)&&this.setOutputData(0,e);this.isOutputConnected(1)&&this.setOutputData(1,f);this.isOutputConnected(2)&&this.setOutputData(2,g)}},P.registerNodeType("texture/glow",z),v.title="Kuwahara Filter",v.desc="Filters a texture giving an artistic oil canvas painting", -v.max_radius=10,v._shaders=[],v.prototype.onExecute=function(){var a=this.getInputData(0);if(a&&this.isOutputConnected(0)){var b=this._temp_texture;b&&b.width==a.width&&b.height==a.height&&b.type==a.type||(this._temp_texture=new GL.Texture(a.width,a.height,{type:a.type,format:gl.RGBA,filter:gl.LINEAR}));b=this.properties.radius;b=Math.min(Math.floor(b),v.max_radius);if(0==b)this.setOutputData(0,a);else{var d=this.properties.intensity,c=P.camera_aspect;c||void 0===window.gl||(c=gl.canvas.height/gl.canvas.width); -c||(c=1);c=this.properties.preserve_aspect?c:1;v._shaders[b]||(v._shaders[b]=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,v.pixel_shader,{RADIUS:b.toFixed(0)}));var f=v._shaders[b],g=GL.Mesh.getScreenQuad();a.bind(0);this._temp_texture.drawTo(function(){f.uniforms({u_texture:0,u_intensity:d,u_resolution:[a.width,a.height],u_iResolution:[1/a.width,1/a.height]}).draw(g)});this.setOutputData(0,this._temp_texture)}}},v.pixel_shader="\nprecision highp float;\nvarying vec2 v_coord;\nuniform sampler2D u_texture;\nuniform float u_intensity;\nuniform vec2 u_resolution;\nuniform vec2 u_iResolution;\n#ifndef RADIUS\n\t#define RADIUS 7\n#endif\nvoid main() {\n\n\tconst int radius = RADIUS;\n\tvec2 fragCoord = v_coord;\n\tvec2 src_size = u_iResolution;\n\tvec2 uv = v_coord;\n\tfloat n = float((radius + 1) * (radius + 1));\n\tint i;\n\tint j;\n\tvec3 m0 = vec3(0.0); vec3 m1 = vec3(0.0); vec3 m2 = vec3(0.0); vec3 m3 = vec3(0.0);\n\tvec3 s0 = vec3(0.0); vec3 s1 = vec3(0.0); vec3 s2 = vec3(0.0); vec3 s3 = vec3(0.0);\n\tvec3 c;\n\t\n\tfor (int j = -radius; j <= 0; ++j) {\n\t\tfor (int i = -radius; i <= 0; ++i) {\n\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\tm0 += c;\n\t\t\ts0 += c * c;\n\t\t}\n\t}\n\t\n\tfor (int j = -radius; j <= 0; ++j) {\n\t\tfor (int i = 0; i <= radius; ++i) {\n\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\tm1 += c;\n\t\t\ts1 += c * c;\n\t\t}\n\t}\n\t\n\tfor (int j = 0; j <= radius; ++j) {\n\t\tfor (int i = 0; i <= radius; ++i) {\n\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\tm2 += c;\n\t\t\ts2 += c * c;\n\t\t}\n\t}\n\t\n\tfor (int j = 0; j <= radius; ++j) {\n\t\tfor (int i = -radius; i <= 0; ++i) {\n\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\tm3 += c;\n\t\t\ts3 += c * c;\n\t\t}\n\t}\n\t\n\tfloat min_sigma2 = 1e+2;\n\tm0 /= n;\n\ts0 = abs(s0 / n - m0 * m0);\n\t\n\tfloat sigma2 = s0.r + s0.g + s0.b;\n\tif (sigma2 < min_sigma2) {\n\t\tmin_sigma2 = sigma2;\n\t\tgl_FragColor = vec4(m0, 1.0);\n\t}\n\t\n\tm1 /= n;\n\ts1 = abs(s1 / n - m1 * m1);\n\t\n\tsigma2 = s1.r + s1.g + s1.b;\n\tif (sigma2 < min_sigma2) {\n\t\tmin_sigma2 = sigma2;\n\t\tgl_FragColor = vec4(m1, 1.0);\n\t}\n\t\n\tm2 /= n;\n\ts2 = abs(s2 / n - m2 * m2);\n\t\n\tsigma2 = s2.r + s2.g + s2.b;\n\tif (sigma2 < min_sigma2) {\n\t\tmin_sigma2 = sigma2;\n\t\tgl_FragColor = vec4(m2, 1.0);\n\t}\n\t\n\tm3 /= n;\n\ts3 = abs(s3 / n - m3 * m3);\n\t\n\tsigma2 = s3.r + s3.g + s3.b;\n\tif (sigma2 < min_sigma2) {\n\t\tmin_sigma2 = sigma2;\n\t\tgl_FragColor = vec4(m3, 1.0);\n\t}\n}\n", -P.registerNodeType("texture/kuwahara",v),u.title="XDoG Filter",u.desc="Filters a texture giving an artistic ink style",u.max_radius=10,u._shaders=[],u.prototype.onExecute=function(){var a=this.getInputData(0);if(a&&this.isOutputConnected(0)){var b=this._temp_texture;b&&b.width==a.width&&b.height==a.height&&b.type==a.type||(this._temp_texture=new GL.Texture(a.width,a.height,{type:a.type,format:gl.RGBA,filter:gl.LINEAR}));u._xdog_shader||(u._xdog_shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,u.xdog_pixel_shader)); -var d=u._xdog_shader,c=GL.Mesh.getScreenQuad(),f=this.properties.sigma,g=this.properties.k,e=this.properties.p,h=this.properties.epsilon,m=this.properties.phi;a.bind(0);this._temp_texture.drawTo(function(){d.uniforms({src:0,sigma:f,k:g,p:e,epsilon:h,phi:m,cvsWidth:a.width,cvsHeight:a.height}).draw(c)});this.setOutputData(0,this._temp_texture)}},u.xdog_pixel_shader="\nprecision highp float;\nuniform sampler2D src;\n\nuniform float cvsHeight;\nuniform float cvsWidth;\n\nuniform float sigma;\nuniform float k;\nuniform float p;\nuniform float epsilon;\nuniform float phi;\nvarying vec2 v_coord;\n\nfloat cosh(float val)\n{\n\tfloat tmp = exp(val);\n\tfloat cosH = (tmp + 1.0 / tmp) / 2.0;\n\treturn cosH;\n}\n\nfloat tanh(float val)\n{\n\tfloat tmp = exp(val);\n\tfloat tanH = (tmp - 1.0 / tmp) / (tmp + 1.0 / tmp);\n\treturn tanH;\n}\n\nfloat sinh(float val)\n{\n\tfloat tmp = exp(val);\n\tfloat sinH = (tmp - 1.0 / tmp) / 2.0;\n\treturn sinH;\n}\n\nvoid main(void){\n\tvec3 destColor = vec3(0.0);\n\tfloat tFrag = 1.0 / cvsHeight;\n\tfloat sFrag = 1.0 / cvsWidth;\n\tvec2 Frag = vec2(sFrag,tFrag);\n\tvec2 uv = gl_FragCoord.st;\n\tfloat twoSigmaESquared = 2.0 * sigma * sigma;\n\tfloat twoSigmaRSquared = twoSigmaESquared * k * k;\n\tint halfWidth = int(ceil( 1.0 * sigma * k ));\n\n\tconst int MAX_NUM_ITERATION = 99999;\n\tvec2 sum = vec2(0.0);\n\tvec2 norm = vec2(0.0);\n\n\tfor(int cnt=0;cnt (2*halfWidth+1)*(2*halfWidth+1)){break;}\n\t\tint i = int(cnt / (2*halfWidth+1)) - halfWidth;\n\t\tint j = cnt - halfWidth - int(cnt / (2*halfWidth+1)) * (2*halfWidth+1);\n\n\t\tfloat d = length(vec2(i,j));\n\t\tvec2 kernel = vec2( exp( -d * d / twoSigmaESquared ), \n\t\t\t\t\t\t\texp( -d * d / twoSigmaRSquared ));\n\n\t\tvec2 L = texture2D(src, (uv + vec2(i,j)) * Frag).xx;\n\n\t\tnorm += kernel;\n\t\tsum += kernel * L;\n\t}\n\n\tsum /= norm;\n\n\tfloat H = 100.0 * ((1.0 + p) * sum.x - p * sum.y);\n\tfloat edge = ( H > epsilon )? 1.0 : 1.0 + tanh( phi * (H - epsilon));\n\tdestColor = vec3(edge);\n\tgl_FragColor = vec4(destColor, 1.0);\n}", -P.registerNodeType("texture/xDoG",u),C.title="Webcam",C.desc="Webcam texture",C.is_webcam_open=!1,C.prototype.openStream=function(){if(navigator.getUserMedia){this._waiting_confirmation=!0;navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:this.properties.facingMode}}).then(this.streamReady.bind(this)).catch(function(b){C.is_webcam_open=!1;console.log("Webcam rejected",b);a._webcam_stream=!1;a.boxcolor="red";a.trigger("stream_error")});var a=this}},C.prototype.closeStream=function(){if(this._webcam_stream){var a= -this._webcam_stream.getTracks();if(a.length)for(var b=0;b=this.size[1]||!this._video||(a.save(),a.webgl?this._video_texture&&a.drawImage(this._video_texture,0,0,this.size[0],this.size[1]):a.drawImage(this._video, -0,0,this.size[0],this.size[1]),a.restore())},C.prototype.onExecute=function(){null!=this._webcam_stream||this._waiting_confirmation||this.openStream();if(this._video&&this._video.videoWidth){var a=this._video.videoWidth,b=this._video.videoHeight,d=this._video_texture;d&&d.width==a&&d.height==b||(this._video_texture=new GL.Texture(a,b,{format:gl.RGB,filter:gl.LINEAR}));this._video_texture.uploadImage(this._video);this._video_texture.version=++this.version;this.properties.texture_name&&(c.getTexturesContainer()[this.properties.texture_name]= -this._video_texture);this.setOutputData(0,this._video_texture);for(a=1;aMath.abs(b))return c[1];a=(a-c[0])/b;return c[1]*(1-a)+f[1]*a}}return 0}},F.prototype.updateCurve=function(){for(var a=this._values,b=a.length/4,d=this.properties.split_channels,c=0;c (2*halfWidth+1)*(2*halfWidth+1)){break;}\n\t\tint i = int(cnt / (2*halfWidth+1)) - halfWidth;\n\t\tint j = cnt - halfWidth - int(cnt / (2*halfWidth+1)) * (2*halfWidth+1);\n\n\t\tfloat d = length(vec2(i,j));\n\t\tvec2 kernel = vec2( exp( -d * d / twoSigmaESquared ), \n\t\t\t\t\t\t\texp( -d * d / twoSigmaRSquared ));\n\n\t\tvec2 L = texture2D(src, (uv + vec2(i,j)) * Frag).xx;\n\n\t\tnorm += kernel;\n\t\tsum += kernel * L;\n\t}\n\n\tsum /= norm;\n\n\tfloat H = 100.0 * ((1.0 + p) * sum.x - p * sum.y);\n\tfloat edge = ( H > epsilon )? 1.0 : 1.0 + tanh( phi * (H - epsilon));\n\tdestColor = vec3(edge);\n\tgl_FragColor = vec4(destColor, 1.0);\n}", +O.registerNodeType("texture/xDoG",t),v.title="Webcam",v.desc="Webcam texture",v.is_webcam_open=!1,v.prototype.openStream=function(){if(navigator.getUserMedia){this._waiting_confirmation=!0;navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:this.properties.facingMode}}).then(this.streamReady.bind(this)).catch(function(b){v.is_webcam_open=!1;console.log("Webcam rejected",b);a._webcam_stream=!1;a.boxcolor="red";a.trigger("stream_error")});var a=this}},v.prototype.closeStream=function(){if(this._webcam_stream){var a= +this._webcam_stream.getTracks();if(a.length)for(var b=0;b=this.size[1]||!this._video||(a.save(),a.webgl?this._video_texture&&a.drawImage(this._video_texture,0,0,this.size[0],this.size[1]):a.drawImage(this._video, +0,0,this.size[0],this.size[1]),a.restore())},v.prototype.onExecute=function(){null!=this._webcam_stream||this._waiting_confirmation||this.openStream();if(this._video&&this._video.videoWidth){var a=this._video.videoWidth,b=this._video.videoHeight,d=this._video_texture;d&&d.width==a&&d.height==b||(this._video_texture=new GL.Texture(a,b,{format:gl.RGB,filter:gl.LINEAR}));this._video_texture.uploadImage(this._video);this._video_texture.version=++this.version;this.properties.texture_name&&(c.getTexturesContainer()[this.properties.texture_name]= +this._video_texture);this.setOutputData(0,this._video_texture);for(a=1;aMath.abs(b))return c[1];a=(a-c[0])/b;return c[1]*(1-a)+f[1]*a}}return 0}},G.prototype.updateCurve=function(){for(var a=this._values,b=a.length/4,d=this.properties.split_channels,c=0;cd+f.NODE_TITLE_HEIGHT&&a.drawImage(b,10,g,this.size[0]-20,this.size[1]-d-f.NODE_TITLE_HEIGHT);var g=this.size[1]-f.NODE_TITLE_HEIGHT+.5;c=f.isInsideRectangle(c[0],c[1],this.pos[0],this.pos[1]+g,this.size[0],f.NODE_TITLE_HEIGHT);a.fillStyle=c?"#555":"#222";a.beginPath();this._shape==f.BOX_SHAPE?a.rect(0,g,this.size[0]+1,f.NODE_TITLE_HEIGHT):a.roundRect(0,g,this.size[0]+1,f.NODE_TITLE_HEIGHT,0,8);a.fill();a.textAlign="center";a.font="24px Arial";a.fillStyle= -c?"#DDD":"#999";a.fillText("+",.5*this.size[0],g+24)}};I.prototype.onMouseDown=function(a,b,d){b[1]>this.size[1]-f.NODE_TITLE_HEIGHT+.5&&d.showSubgraphPropertiesDialog(this)};I.prototype.onDrawSubgraphBackground=function(a){};I.prototype.getExtraMenuOptions=function(a){var b=this;return[{content:"Print Code",callback:function(){var a=b._context.computeShaderCode();console.log(a.vs_code,a.fs_code)}}]};f.registerNodeType("texture/shaderGraph",I);E.title="Uniform";E.desc="Input data for the shader"; -E.prototype.getTitle=function(){return this.properties.name&&this.flags.collapsed?this.properties.type+" "+this.properties.name:"Uniform"};E.prototype.onPropertyChanged=function(a,b){this.outputs[0].name=this.properties.type+" "+this.properties.name};E.prototype.onGetCode=function(a){if(this.shader_destination){var b=this.properties.type;if(!b){if(!a.onGetPropertyInfo)return;b=a.onGetPropertyInfo(this.property.name);if(!b)return;b=b.type}"number"==b?b="float":"texture"==b&&(b="sampler2D");-1!=g.GLSL_types.indexOf(b)&& -(a.addUniform("u_"+this.properties.name,b),this.setOutputData(0,b))}};E.prototype.getOutputVarName=function(a){return"u_"+this.properties.name};k("input/uniform",E);H.title="Attribute";H.desc="Input data from mesh attribute";H.prototype.getTitle=function(){return"att. "+this.properties.name};H.prototype.onGetCode=function(a){if(this.shader_destination){var b=this.properties.type;b&&-1!=g.GLSL_types.indexOf(b)&&("number"==b&&(b="float"),"coord"!=this.properties.name&&a.addCode("varying"," varying "+ -b+" v_"+this.properties.name+";"),this.setOutputData(0,b))}};H.prototype.getOutputVarName=function(a){return"v_"+this.properties.name};k("input/attribute",H);L.title="Sampler2D";L.desc="Reads a pixel from a texture";L.prototype.onGetCode=function(a){if(this.shader_destination){var b=r(this,0),d=q(this),c="vec4 "+d+" = vec4(0.0);\n";if(b){var f=r(this,1)||a.buffer_names.uvs;c+=d+" = texture2D("+b+","+f+");\n"}w(this,0)&&(c+="vec4 "+w(this,0)+" = "+d+";\n");w(this,1)&&(c+="vec3 "+w(this,1)+" = "+d+ -".xyz;\n");a.addCode("code",c,this.shader_destination);this.setOutputData(0,"vec4");this.setOutputData(1,"vec3")}};k("texture/sampler2D",L);J.title="const";J.prototype.getTitle=function(){return this.flags.collapsed?u(this.properties.value,this.properties.type,2):"Const"};J.prototype.onPropertyChanged=function(a,b){"type"==a&&(this.outputs[0].type!=b&&(this.disconnectOutput(0),this.outputs[0].type=b),this.widgets.length=1,this.updateWidgets());"value"==a&&(b.length?(this.widgets[1].value=b[1],2this.size[1]-f.NODE_TITLE_HEIGHT+.5&&d.showSubgraphPropertiesDialog(this)};E.prototype.onDrawSubgraphBackground=function(a){};E.prototype.getExtraMenuOptions=function(a){var b=this;return[{content:"Print Code",callback:function(){var a=b._context.computeShaderCode();console.log(a.vs_code,a.fs_code)}}]};f.registerNodeType("texture/shaderGraph",E);D.title="Uniform";D.desc="Input data for the shader"; +D.prototype.getTitle=function(){return this.properties.name&&this.flags.collapsed?this.properties.type+" "+this.properties.name:"Uniform"};D.prototype.onPropertyChanged=function(a,b){this.outputs[0].name=this.properties.type+" "+this.properties.name};D.prototype.onGetCode=function(a){if(this.shader_destination){var b=this.properties.type;if(!b){if(!a.onGetPropertyInfo)return;b=a.onGetPropertyInfo(this.property.name);if(!b)return;b=b.type}"number"==b?b="float":"texture"==b&&(b="sampler2D");-1!=g.GLSL_types.indexOf(b)&& +(a.addUniform("u_"+this.properties.name,b),this.setOutputData(0,b))}};D.prototype.getOutputVarName=function(a){return"u_"+this.properties.name};k("input/uniform",D);J.title="Attribute";J.desc="Input data from mesh attribute";J.prototype.getTitle=function(){return"att. "+this.properties.name};J.prototype.onGetCode=function(a){if(this.shader_destination){var b=this.properties.type;b&&-1!=g.GLSL_types.indexOf(b)&&("number"==b&&(b="float"),"coord"!=this.properties.name&&a.addCode("varying"," varying "+ +b+" v_"+this.properties.name+";"),this.setOutputData(0,b))}};J.prototype.getOutputVarName=function(a){return"v_"+this.properties.name};k("input/attribute",J);L.title="Sampler2D";L.desc="Reads a pixel from a texture";L.prototype.onGetCode=function(a){if(this.shader_destination){var b=r(this,0),d=n(this),c="vec4 "+d+" = vec4(0.0);\n";if(b){var f=r(this,1)||a.buffer_names.uvs;c+=d+" = texture2D("+b+","+f+");\n"}u(this,0)&&(c+="vec4 "+u(this,0)+" = "+d+";\n");u(this,1)&&(c+="vec3 "+u(this,1)+" = "+d+ +".xyz;\n");a.addCode("code",c,this.shader_destination);this.setOutputData(0,"vec4");this.setOutputData(1,"vec3")}};k("texture/sampler2D",L);H.title="const";H.prototype.getTitle=function(){return this.flags.collapsed?t(this.properties.value,this.properties.type,2):"Const"};H.prototype.onPropertyChanged=function(a,b){"type"==a&&(this.outputs[0].type!=b&&(this.disconnectOutput(0),this.outputs[0].type=b),this.widgets.length=1,this.updateWidgets());"value"==a&&(b.length?(this.widgets[1].value=b[1],2d;++d)b.push({name:r(this,d),type:this.getInputData(d)||"float"});var c=w(this,0);if(c){var f=b[0].type,g=this.properties.operation, -e=[];for(d=0;2>d;++d){var h=b[d].name;null==h&&(h=null!=p.value?p.value:"(1.0)",b[d].type="float");b[d].type!=f&&("float"!=b[d].type||"*"!=g&&"/"!=g)&&(h=x(h,b[d].type,f));e.push(h)}a.addCode("code",f+" "+c+" = "+e[0]+g+e[1]+";",this.shader_destination);this.setOutputData(0,f)}}};k("math/operation",M);m.title="Func";m.prototype.onPropertyChanged=function(a,b){this.graph&&this.graph._version++;if("func"==a&&(a=z[b])){for(b=a.params.length;bd;++d)b.push({name:r(this,d),type:this.getInputData(d)||"float"});var c=w(this,0);if(c){var f=z[this.properties.func];if(f){var g=b[0].type,e=f.return_type;"T"==e&&(e=g);var h=[];for(d= -0;dd;++d)b.push({name:r(this,d),type:this.getInputData(d)||"float"});var c=u(this,0);if(c){var f=b[0].type,g=this.properties.operation, +e=[];for(d=0;2>d;++d){var l=b[d].name;null==l&&(l=null!=p.value?p.value:"(1.0)",b[d].type="float");b[d].type!=f&&("float"!=b[d].type||"*"!=g&&"/"!=g)&&(l=C(l,b[d].type,f));e.push(l)}a.addCode("code",f+" "+c+" = "+e[0]+g+e[1]+";",this.shader_destination);this.setOutputData(0,f)}}};k("math/operation",M);l.title="Func";l.prototype.onPropertyChanged=function(a,b){this.graph&&this.graph._version++;if("func"==a&&(a=P[b])){for(b=a.params.length;bd;++d)b.push({name:r(this,d),type:this.getInputData(d)||"float"});var c=u(this,0);if(c){var f=P[this.properties.func];if(f){var g=b[0].type,e=f.return_type;"T"==e&&(e=g);var l=[];for(d= +0;d=c;){g=.5*(e+c)|0;d=a[g];if(d==b)break;if(c==e-1)return c;d=c;){g=.5*(e+c)|0;d=a[g];if(d==b)break;if(c==e-1)return c;da&&(a=1);this.points&&this.points.length==3*a||(this.points=new Float32Array(3*a));this.properties.generate_normals?this.normals&&this.normals.length==this.points.length||(this.normals=new Float32Array(this.points.length)):this.normals=null;var b=this._last_radius||this.properties.radius,d=this.properties.mode,c=this.getInputData(0);this._old_obj_version=c?c._version:null;this.points=k.generatePoints(b,a,d,this.points,this.normals, -this.properties.regular,c);this.version++};k.generatePoints=function(a,b,d,c,g,e,h){var f=3*b;c&&c.length==f||(c=new Float32Array(f));var m=new Float32Array(3),l=new Float32Array([0,1,0]);if(e)if(d==k.RECTANGLE){f=Math.floor(Math.sqrt(b));for(b=0;bg||we&&eh))break}this.geometry.indices=this.indices=new Uint32Array(m)}this.indices&&this.indices.length?(this.geometry.indices=this.indices,this.setOutputData(0,this.geometry)):this.setOutputData(0,null)}};D.registerNodeType("geometry/connectPoints",H);"undefined"!=typeof GL&&(L.title="to geometry",L.desc="converts a mesh to geometry",L.prototype.onExecute=function(){var a=this.getInputData(0);if(a){if(a!=this.last_mesh){this.last_mesh=a;for(i in a.vertexBuffers)this.geometry[i]= -a.vertexBuffers[i].data;a.indexBuffers.triangles&&(this.geometry.indices=a.indexBuffers.triangles.data);this.geometry._id=c();this.geometry._version=0}this.setOutputData(0,this.geometry);this.geometry&&this.setOutputData(1,this.geometry.vertices)}},D.registerNodeType("geometry/toGeometry",L),J.title="Geo to Mesh",J.prototype.updateMesh=function(a){this.mesh||(this.mesh=new GL.Mesh);for(var b in a)if("_"!=b[0]){var d=a[b],c=GL.Mesh.common_buffers[b];if(c||"indices"==b){c=c?c.spacing:3;var g=this.mesh.vertexBuffers[b]; +0;cg||ue&&el))break}this.geometry.indices=this.indices=new Uint32Array(h)}this.indices&&this.indices.length?(this.geometry.indices=this.indices,this.setOutputData(0,this.geometry)):this.setOutputData(0,null)}};B.registerNodeType("geometry/connectPoints",J);"undefined"!=typeof GL&&(L.title="to geometry",L.desc="converts a mesh to geometry",L.prototype.onExecute=function(){var a=this.getInputData(0);if(a){if(a!=this.last_mesh){this.last_mesh=a;for(i in a.vertexBuffers)this.geometry[i]= +a.vertexBuffers[i].data;a.indexBuffers.triangles&&(this.geometry.indices=a.indexBuffers.triangles.data);this.geometry._id=c();this.geometry._version=0}this.setOutputData(0,this.geometry);this.geometry&&this.setOutputData(1,this.geometry.vertices)}},B.registerNodeType("geometry/toGeometry",L),H.title="Geo to Mesh",H.prototype.updateMesh=function(a){this.mesh||(this.mesh=new GL.Mesh);for(var b in a)if("_"!=b[0]){var d=a[b],c=GL.Mesh.common_buffers[b];if(c||"indices"==b){c=c?c.spacing:3;var g=this.mesh.vertexBuffers[b]; g&&g.data.length==d.length?(g.data.set(d),g.upload(GL.DYNAMIC_DRAW)):g=new GL.Buffer("indices"==b?GL.ELEMENT_ARRAY_BUFFER:GL.ARRAY_BUFFER,d,c,GL.DYNAMIC_DRAW);this.mesh.addBuffer(b,g)}}if(this.mesh.vertexBuffers.normals&&this.mesh.vertexBuffers.normals.data.length!=this.mesh.vertexBuffers.vertices.data.length){d=new Float32Array([0,1,0]);c=new Float32Array(this.mesh.vertexBuffers.vertices.data.length);for(b=0;b=c.NOTEON||h<=c.NOTEOFF)this.channel=e&15};Object.defineProperty(c.prototype,"velocity",{get:function(){return this.cmd==c.NOTEON?this.data[2]:-1},set:function(c){this.data[2]=c},enumerable:!0});c.notes="A A# B C C# D D# E F F# G G#".split(" ");c.note_to_index={A:0,"A#":1,B:2,C:3,"C#":4,D:5,"D#":6,E:7,F:8,"F#":9,G:10,"G#":11};Object.defineProperty(c.prototype,"note",{get:function(){return this.cmd!= +r.pixel_shader_gamma="precision highp float;\n\r\n\t\t\tvarying vec2 v_coord;\n\r\n\t\t\tuniform sampler2D u_texture;\n\r\n\t\t\tuniform float u_value1;\n\r\n\t\t\t\n\r\n\t\t\tvoid main() {\n\r\n\t\t\t\tvec4 color = texture2D(u_texture, v_coord);\n\r\n\t\t\t\tfloat gamma = 1.0 / u_value1;\n\r\n\t\t\t\tgl_FragColor = vec4( pow( color.xyz, vec3(gamma) ), color.a );\n\r\n\t\t\t}\n";c.registerNodeType("fx/generic",r);y.LGraphFXGeneric=r;n.title="Vigneting";n.desc="Vigneting";n.widgets_info={precision:{widget:"combo", +values:k.MODE_VALUES}};n.prototype.onExecute=function(){var c=this.getInputData(0);if(this.properties.precision===k.PASS_THROUGH)this.setOutputData(0,c);else if(c){this._tex=k.getTargetTexture(c,this._tex,this.properties.precision);var h=this.properties.intensity;this.isInputConnected(1)&&(h=this.getInputData(1),this.properties.intensity=h);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var r=Mesh.getScreenQuad(),u=n._shader,y=this.properties.invert;this._tex.drawTo(function(){c.bind(0);u.uniforms({u_texture:0, +u_intensity:h,u_isize:[1/c.width,1/c.height],u_invert:y?1:0}).draw(r)});this.setOutputData(0,this._tex)}};n.pixel_shader="precision highp float;\n\r\n\t\t\tprecision highp float;\n\r\n\t\t\tvarying vec2 v_coord;\n\r\n\t\t\tuniform sampler2D u_texture;\n\r\n\t\t\tuniform float u_intensity;\n\r\n\t\t\tuniform int u_invert;\n\r\n\t\t\t\n\r\n\t\t\tvoid main() {\n\r\n\t\t\t\tfloat luminance = 1.0 - length( v_coord - vec2(0.5) ) * 1.414;\n\r\n\t\t\t\tvec4 color = texture2D(u_texture, v_coord);\n\r\n\t\t\t\tif(u_invert == 1)\n\r\n\t\t\t\t\tluminance = 1.0 - luminance;\n\r\n\t\t\t\tluminance = mix(1.0, luminance, u_intensity);\n\r\n\t\t\t gl_FragColor = vec4( luminance * color.xyz, color.a);\n\r\n\t\t\t}\n\r\n\t\t\t"; +c.registerNodeType("fx/vigneting",n);y.LGraphFXVigneting=n}})(this); +(function(y){function c(c){this.cmd=this.channel=0;this.data=new Uint32Array(3);c&&this.setup(c)}function k(c,e){navigator.requestMIDIAccess?(this.on_ready=c,this.state={note:[],cc:[]},this.input_ports=null,this.input_ports_info=[],this.output_ports=null,this.output_ports_info=[],navigator.requestMIDIAccess().then(this.onMIDISuccess.bind(this),this.onMIDIFailure.bind(this))):(this.error="not suppoorted",e?e("Not supported"):console.error("MIDI NOT SUPPORTED, enable by chrome://flags"))}function n(){this.addOutput("on_midi", +B.EVENT);this.addOutput("out","midi");this.properties={port:0};this._current_midi_event=this._last_midi_event=null;this.boxcolor="#AAA";this._last_time=0;var c=this;new k(function(e){c._midi=e;if(c._waiting)c.onStart();c._waiting=!1})}function r(){this.addInput("send",B.EVENT);this.properties={port:0};var c=this;new k(function(e){c._midi=e;c.widget.options.values=c.getMIDIOutputs()});this.widget=this.addWidget("combo","Device",this.properties.port,{property:"port",values:this.getMIDIOutputs.bind(this)}); +this.size=[340,60]}function u(){this.addInput("on_midi",B.EVENT);this._str="";this.size=[200,40]}function h(){this.properties={channel:-1,cmd:-1,min_value:-1,max_value:-1};var c=this;this._learning=!1;this.addWidget("button","Learn","",function(){c._learning=!0;c.boxcolor="#FA3"});this.addInput("in",B.EVENT);this.addOutput("on_midi",B.EVENT);this.boxcolor="#AAA"}function E(){this.properties={channel:0,cmd:144,value1:1,value2:1};this.addInput("send",B.EVENT);this.addInput("assign",B.EVENT);this.addOutput("on_midi", +B.EVENT);this.midi_event=new c;this.gate=!1}function D(){this.properties={cc:1,value:0};this.addOutput("value","number")}function J(){this.addInput("generate",B.ACTION);this.addInput("scale","string");this.addInput("octave","number");this.addOutput("note",B.EVENT);this.properties={notes:"A,A#,B,C,C#,D,D#,E,F,F#,G,G#",octave:2,duration:.5,mode:"sequence"};this.notes_pitches=J.processScale(this.properties.notes);this.sequence_index=0}function L(){this.properties={amount:0};this.addInput("in",B.ACTION); +this.addInput("amount","number");this.addOutput("out",B.EVENT);this.midi_event=new c}function H(){this.properties={scale:"A,A#,B,C,C#,D,D#,E,F,F#,G,G#"};this.addInput("note",B.ACTION);this.addInput("scale","string");this.addOutput("out",B.EVENT);this.valid_notes=Array(12);this.offset_notes=Array(12);this.processScale(this.properties.scale)}function F(){this.properties={url:"",autoplay:!0};this.addInput("play",B.ACTION);this.addInput("pause",B.ACTION);this.addOutput("note",B.EVENT);this._midi=null; +this._current_time=0;this._playing=!1;"undefined"==typeof MidiParser&&(console.error("midi-parser.js not included, LGMidiPlay requires that library: https://raw.githubusercontent.com/colxi/midi-parser-js/master/src/main.js"),this.boxcolor="red")}function e(){this.properties={volume:.5,duration:1};this.addInput("note",B.ACTION);this.addInput("volume","number");this.addInput("duration","number");this.addOutput("note",B.EVENT);"undefined"==typeof AudioSynth?(console.error("Audiosynth.js not included, LGMidiPlay requires that library"), +this.boxcolor="red"):this.instrument=(this.synth=new AudioSynth).createInstrument("piano")}function K(){this.properties={num_octaves:2,start_octave:2};this.addInput("note",B.ACTION);this.addInput("reset",B.ACTION);this.addOutput("note",B.EVENT);this.size=[400,100];this.keys=[];this._last_key=-1}var B=y.LiteGraph;B.MIDIEvent=c;c.prototype.fromJSON=function(c){this.setup(c.data)};c.prototype.setup=function(e){var l=e;e.constructor===Object&&(l=e.data);this.data.set(l);this.status=e=l[0];l=e&240;this.cmd= +240<=e?e:l;this.cmd==c.NOTEON&&0==this.velocity&&(this.cmd=c.NOTEOFF);this.cmd_str=c.commands[this.cmd]||"";if(l>=c.NOTEON||l<=c.NOTEOFF)this.channel=e&15};Object.defineProperty(c.prototype,"velocity",{get:function(){return this.cmd==c.NOTEON?this.data[2]:-1},set:function(c){this.data[2]=c},enumerable:!0});c.notes="A A# B C C# D D# E F F# G G#".split(" ");c.note_to_index={A:0,"A#":1,B:2,C:3,"C#":4,D:5,"D#":6,E:7,F:8,"F#":9,G:10,"G#":11};Object.defineProperty(c.prototype,"note",{get:function(){return this.cmd!= c.NOTEON?-1:c.toNoteString(this.data[1],!0)},set:function(c){throw"notes cannot be assigned this way, must modify the data[1]";},enumerable:!0});Object.defineProperty(c.prototype,"octave",{get:function(){return this.cmd!=c.NOTEON?-1:Math.floor((this.data[1]-24)/12+1)},set:function(c){throw"octave cannot be assigned this way, must modify the data[1]";},enumerable:!0});c.prototype.getPitch=function(){return 440*Math.pow(2,(this.data[1]-69)/12)};c.computePitch=function(c){return 440*Math.pow(2,(c-69)/ 12)};c.prototype.getCC=function(){return this.data[1]};c.prototype.getCCValue=function(){return this.data[2]};c.prototype.getPitchBend=function(){return this.data[1]+(this.data[2]<<7)-8192};c.computePitchBend=function(c,e){return c+(e<<7)-8192};c.prototype.setCommandFromString=function(e){this.cmd=c.computeCommandFromString(e)};c.computeCommandFromString=function(e){if(!e)return 0;if(e&&e.constructor===Number)return e;e=e.toUpperCase();switch(e){case "NOTE ON":case "NOTEON":return c.NOTEON;case "NOTE OFF":case "NOTEOFF":return c.NOTEON; case "KEY PRESSURE":case "KEYPRESSURE":return c.KEYPRESSURE;case "CONTROLLER CHANGE":case "CONTROLLERCHANGE":case "CC":return c.CONTROLLERCHANGE;case "PROGRAM CHANGE":case "PROGRAMCHANGE":case "PC":return c.PROGRAMCHANGE;case "CHANNEL PRESSURE":case "CHANNELPRESSURE":return c.CHANNELPRESSURE;case "PITCH BEND":case "PITCHBEND":return c.PITCHBEND;case "TIME TICK":case "TIMETICK":return c.TIMETICK;default:return Number(e)}};c.toNoteString=function(e,h){e=Math.round(e);var l=Math.floor((e-24)/12+1);e= -(e-21)%12;0>e&&(e=12+e);return c.notes[e]+(h?"":l)};c.NoteStringToPitch=function(e){e=e.toUpperCase();var h=e[0],m=4;"#"==e[1]?(h+="#",2e&&(e=12+e);return c.notes[e]+(h?"":l)};c.NoteStringToPitch=function(e){e=e.toUpperCase();var l=e[0],h=4;"#"==e[1]?(l+="#",2this.properties.max_value)return;this.trigger("on_midi",h)}};D.registerNodeType("midi/filter",h);I.title="MIDIEvent";I.desc="Create a MIDI Event";I.color="#243";I.prototype.onAction=function(e,h){"assign"==e?(this.properties.channel=h.channel,this.properties.cmd=h.cmd,this.properties.value1=h.data[1],this.properties.value2=h.data[2],h.cmd== -c.NOTEON?this.gate=!0:h.cmd==c.NOTEOFF&&(this.gate=!1)):(h=this.midi_event,h.channel=this.properties.channel,this.properties.cmd&&this.properties.cmd.constructor===String?h.setCommandFromString(this.properties.cmd):h.cmd=this.properties.cmd,h.data[0]=h.cmd|h.channel,h.data[1]=Number(this.properties.value1),h.data[2]=Number(this.properties.value2),this.trigger("on_midi",h))};I.prototype.onExecute=function(){var e=this.properties;if(this.inputs)for(var h=0;hthis.properties.max_value)return;this.trigger("on_midi",h)}};B.registerNodeType("midi/filter",h);E.title="MIDIEvent";E.desc="Create a MIDI Event";E.color="#243";E.prototype.onAction=function(e,h){"assign"==e?(this.properties.channel=h.channel,this.properties.cmd=h.cmd,this.properties.value1=h.data[1],this.properties.value2=h.data[2],h.cmd== +c.NOTEON?this.gate=!0:h.cmd==c.NOTEOFF&&(this.gate=!1)):(h=this.midi_event,h.channel=this.properties.channel,this.properties.cmd&&this.properties.cmd.constructor===String?h.setCommandFromString(this.properties.cmd):h.cmd=this.properties.cmd,h.data[0]=h.cmd|h.channel,h.data[1]=Number(this.properties.value1),h.data[2]=Number(this.properties.value2),this.trigger("on_midi",h))};E.prototype.onExecute=function(){var e=this.properties;if(this.inputs)for(var h=0;hc;++c)this.valid_notes[c]=-1!=this.notes_pitches.indexOf(c);for(c=0;12>c;++c)if(this.valid_notes[c])this.offset_notes[c]=0;else for(var e=1;12>e;++e){if(this.valid_notes[(c-e)%12]){this.offset_notes[c]=-e;break}if(this.valid_notes[(c+e)%12]){this.offset_notes[c]=e;break}}};J.prototype.onAction=function(e,h){h&&h.constructor===c&&(h.data[0]==c.NOTEON||h.data[0]==c.NOTEOFF?(this.midi_event=new c,this.midi_event.setup(h.data),this.midi_event.data[1]+=this.offset_notes[c.note_to_index[h.note]], -this.trigger("out",this.midi_event)):this.trigger("out",h))};J.prototype.onExecute=function(){var c=this.getInputData(1);null!=c&&c!=this._current_scale&&this.processScale(c)};D.registerNodeType("midi/quantize",J);G.title="MIDI fromFile";G.desc="Plays a MIDI file";G.color="#243";G.prototype.onAction=function(c){"play"==c?this.play():"pause"==c&&(this._playing=!this._playing)};G.prototype.onPropertyChanged=function(c,e){"url"==c&&this.loadMIDIFile(e)};G.prototype.onExecute=function(){if(this._midi&& -this._playing){this._current_time+=this.graph.elapsed_time;for(var e=100*this._current_time,h=0;ha;a++)for(var b=0;bd+f||c[1]>b))return a}}return-1};K.prototype.onAction=function(e,h){if("reset"==e)for(h=0;hc;++c)this.valid_notes[c]=-1!=this.notes_pitches.indexOf(c);for(c=0;12>c;++c)if(this.valid_notes[c])this.offset_notes[c]=0;else for(var e=1;12>e;++e){if(this.valid_notes[(c-e)%12]){this.offset_notes[c]=-e;break}if(this.valid_notes[(c+e)%12]){this.offset_notes[c]=e;break}}};H.prototype.onAction=function(e,h){h&&h.constructor===c&&(h.data[0]==c.NOTEON||h.data[0]==c.NOTEOFF?(this.midi_event=new c,this.midi_event.setup(h.data),this.midi_event.data[1]+=this.offset_notes[c.note_to_index[h.note]], +this.trigger("out",this.midi_event)):this.trigger("out",h))};H.prototype.onExecute=function(){var c=this.getInputData(1);null!=c&&c!=this._current_scale&&this.processScale(c)};B.registerNodeType("midi/quantize",H);F.title="MIDI fromFile";F.desc="Plays a MIDI file";F.color="#243";F.prototype.onAction=function(c){"play"==c?this.play():"pause"==c&&(this._playing=!this._playing)};F.prototype.onPropertyChanged=function(c,e){"url"==c&&this.loadMIDIFile(e)};F.prototype.onExecute=function(){if(this._midi&& +this._playing){this._current_time+=this.graph.elapsed_time;for(var e=100*this._current_time,h=0;ha;a++)for(var b=0;bd+f||c[1]>b))return a}}return-1};K.prototype.onAction=function(e,h){if("reset"==e)for(h=0;hh[1]))return e=this.getKeyIndex(h),this.keys[e]=!0,this._last_key=e,e=12*(this.properties.start_octave-1)+29+e,h=new c,h.setup([c.NOTEON,e,100]),this.trigger("note",h),!0};K.prototype.onMouseMove=function(e,h){if(!(0>h[1]||-1==this._last_key)){this.setDirtyCanvas(!0); e=this.getKeyIndex(h);if(this._last_key==e)return!0;this.keys[this._last_key]=!1;h=12*(this.properties.start_octave-1)+29+this._last_key;var k=new c;k.setup([c.NOTEOFF,h,100]);this.trigger("note",k);this.keys[e]=!0;h=12*(this.properties.start_octave-1)+29+e;k=new c;k.setup([c.NOTEON,h,100]);this.trigger("note",k);this._last_key=e;return!0}};K.prototype.onMouseUp=function(e,h){if(!(0>h[1]))return e=this.getKeyIndex(h),this.keys[e]=!1,this._last_key=-1,e=12*(this.properties.start_octave-1)+29+e,h=new c, -h.setup([c.NOTEOFF,e,100]),this.trigger("note",h),!0};D.registerNodeType("midi/keys",K)})(this); -(function(B){function c(){this.properties={src:"",gain:.5,loop:!0,autoplay:!0,playbackRate:1};this._loading_audio=!1;this._audiobuffer=null;this._audionodes=[];this._last_sourcenode=null;this.addOutput("out","audio");this.addInput("gain","number");this.audionode=l.getAudioContext().createGain();this.audionode.graphnode=this;this.audionode.gain.value=this.properties.gain;this.properties.src&&this.loadSound(this.properties.src)}function k(){this.properties={gain:.5};this._audionodes=[];this._media_stream= -null;this.addOutput("out","audio");this.addInput("gain","number");this.audionode=l.getAudioContext().createGain();this.audionode.graphnode=this;this.audionode.gain.value=this.properties.gain}function q(){this.properties={fftSize:2048,minDecibels:-100,maxDecibels:-10,smoothingTimeConstant:.5};this.audionode=l.getAudioContext().createAnalyser();this.audionode.graphnode=this;this.audionode.fftSize=this.properties.fftSize;this.audionode.minDecibels=this.properties.minDecibels;this.audionode.maxDecibels= -this.properties.maxDecibels;this.audionode.smoothingTimeConstant=this.properties.smoothingTimeConstant;this.addInput("in","audio");this.addOutput("freqs","array");this.addOutput("samples","array");this._time_bin=this._freq_bin=null}function r(){this.properties={gain:1};this.audionode=l.getAudioContext().createGain();this.addInput("in","audio");this.addInput("gain","number");this.addOutput("out","audio")}function w(){this.properties={impulse_src:"",normalize:!0};this.audionode=l.getAudioContext().createConvolver(); -this.addInput("in","audio");this.addOutput("out","audio")}function h(){this.properties={threshold:-50,knee:40,ratio:12,reduction:-20,attack:0,release:.25};this.audionode=l.getAudioContext().createDynamicsCompressor();this.addInput("in","audio");this.addOutput("out","audio")}function I(){this.properties={};this.audionode=l.getAudioContext().createWaveShaper();this.addInput("in","audio");this.addInput("shape","waveshape");this.addOutput("out","audio")}function E(){this.properties={gain1:.5,gain2:.5}; -this.audionode=l.getAudioContext().createGain();this.audionode1=l.getAudioContext().createGain();this.audionode1.gain.value=this.properties.gain1;this.audionode2=l.getAudioContext().createGain();this.audionode2.gain.value=this.properties.gain2;this.audionode1.connect(this.audionode);this.audionode2.connect(this.audionode);this.addInput("in1","audio");this.addInput("in1 gain","number");this.addInput("in2","audio");this.addInput("in2 gain","number");this.addOutput("out","audio")}function H(){this.properties= -{A:.1,D:.1,S:.1,R:.1};this.audionode=l.getAudioContext().createGain();this.audionode.gain.value=0;this.addInput("in","audio");this.addInput("gate","boolean");this.addOutput("out","audio");this.gate=!1}function L(){this.properties={delayTime:.5};this.audionode=l.getAudioContext().createDelay(10);this.audionode.delayTime.value=this.properties.delayTime;this.addInput("in","audio");this.addInput("time","number");this.addOutput("out","audio")}function J(){this.properties={frequency:350,detune:0,Q:1};this.addProperty("type", -"lowpass","enum",{values:"lowpass highpass bandpass lowshelf highshelf peaking notch allpass".split(" ")});this.audionode=l.getAudioContext().createBiquadFilter();this.addInput("in","audio");this.addOutput("out","audio")}function G(){this.properties={frequency:440,detune:0,type:"sine"};this.addProperty("type","sine","enum",{values:["sine","square","sawtooth","triangle","custom"]});this.audionode=l.getAudioContext().createOscillator();this.addOutput("out","audio")}function e(){this.properties={continuous:!0, -mark:-1};this.addInput("data","array");this.addInput("mark","number");this.size=[300,200];this._last_buffer=null}function K(){this.properties={band:440,amplitude:1};this.addInput("freqs","array");this.addOutput("signal","number")}function D(){if(!D.default_code){var c=D.default_function.toString(),e=c.indexOf("{")+1,a=c.lastIndexOf("}");D.default_code=c.substr(e,a-e)}this.properties={code:D.default_code};c=l.getAudioContext();c.createScriptProcessor?this.audionode=c.createScriptProcessor(4096,1,1): -(console.warn("ScriptProcessorNode deprecated"),this.audionode=c.createGain());this.processCode();D._bypass_function||(D._bypass_function=this.audionode.onaudioprocess);this.addInput("in","audio");this.addOutput("out","audio")}function M(){this.audionode=l.getAudioContext().destination;this.addInput("in","audio")}var m=B.LiteGraph,l={};B.LGAudio=l;l.getAudioContext=function(){if(!this._audio_context){window.AudioContext=window.AudioContext||window.webkitAudioContext;if(!window.AudioContext)return console.error("AudioContext not supported by browser"), -null;this._audio_context=new AudioContext;this._audio_context.onmessage=function(c){console.log("msg",c)};this._audio_context.onended=function(c){console.log("ended",c)};this._audio_context.oncomplete=function(c){console.log("complete",c)}}return this._audio_context};l.connect=function(c,e){try{c.connect(e)}catch(a){console.warn("LGraphAudio:",a)}};l.disconnect=function(c,e){try{c.disconnect(e)}catch(a){console.warn("LGraphAudio:",a)}};l.changeAllAudiosConnections=function(c,e){if(c.inputs)for(var a= -0;a=this.size[0]&&(d=this.size[0]-1),c.strokeStyle= -"red",c.beginPath(),c.moveTo(d,b),c.lineTo(d,0),c.stroke())}};e.title="Visualization";e.desc="Audio Visualization";m.registerNodeType("audio/visualization",e);K.prototype.onExecute=function(){if(this._freqs=this.getInputData(0)){var c=this.properties.band,e=this.getInputData(1);void 0!==e&&(c=e);e=l.getAudioContext().sampleRate/this._freqs.length;e=c/e*2;e>=this._freqs.length?e=this._freqs[this._freqs.length-1]:(c=e|0,e-=c,e=this._freqs[c]*(1-e)+this._freqs[c+1]*e);this.setOutputData(0,e/255*this.properties.amplitude)}}; -K.prototype.onGetInputs=function(){return[["band","number"]]};K.title="Signal";K.desc="extract the signal of some frequency";m.registerNodeType("audio/signal",K);D.prototype.onAdded=function(c){c.status==LGraph.STATUS_RUNNING&&(this.audionode.onaudioprocess=this._callback)};D["@code"]={widget:"code",type:"code"};D.prototype.onStart=function(){this.audionode.onaudioprocess=this._callback};D.prototype.onStop=function(){this.audionode.onaudioprocess=D._bypass_function};D.prototype.onPause=function(){this.audionode.onaudioprocess= -D._bypass_function};D.prototype.onUnpause=function(){this.audionode.onaudioprocess=this._callback};D.prototype.onExecute=function(){};D.prototype.onRemoved=function(){this.audionode.onaudioprocess=D._bypass_function};D.prototype.processCode=function(){try{this._script=new (new Function("properties",this.properties.code))(this.properties),this._old_code=this.properties.code,this._callback=this._script.onaudioprocess}catch(A){console.error("Error in onaudioprocess code",A),this._callback=D._bypass_function, -this.audionode.onaudioprocess=this._callback}};D.prototype.onPropertyChanged=function(c,e){"code"==c&&(this.properties.code=e,this.processCode(),this.graph&&this.graph.status==LGraph.STATUS_RUNNING&&(this.audionode.onaudioprocess=this._callback))};D.default_function=function(){this.onaudioprocess=function(c){var e=c.inputBuffer;c=c.outputBuffer;for(var a=0;a=this.size[0]&&(d=this.size[0]-1),c.strokeStyle= +"red",c.beginPath(),c.moveTo(d,b),c.lineTo(d,0),c.stroke())}};e.title="Visualization";e.desc="Audio Visualization";l.registerNodeType("audio/visualization",e);K.prototype.onExecute=function(){if(this._freqs=this.getInputData(0)){var c=this.properties.band,e=this.getInputData(1);void 0!==e&&(c=e);e=m.getAudioContext().sampleRate/this._freqs.length;e=c/e*2;e>=this._freqs.length?e=this._freqs[this._freqs.length-1]:(c=e|0,e-=c,e=this._freqs[c]*(1-e)+this._freqs[c+1]*e);this.setOutputData(0,e/255*this.properties.amplitude)}}; +K.prototype.onGetInputs=function(){return[["band","number"]]};K.title="Signal";K.desc="extract the signal of some frequency";l.registerNodeType("audio/signal",K);B.prototype.onAdded=function(c){c.status==LGraph.STATUS_RUNNING&&(this.audionode.onaudioprocess=this._callback)};B["@code"]={widget:"code",type:"code"};B.prototype.onStart=function(){this.audionode.onaudioprocess=this._callback};B.prototype.onStop=function(){this.audionode.onaudioprocess=B._bypass_function};B.prototype.onPause=function(){this.audionode.onaudioprocess= +B._bypass_function};B.prototype.onUnpause=function(){this.audionode.onaudioprocess=this._callback};B.prototype.onExecute=function(){};B.prototype.onRemoved=function(){this.audionode.onaudioprocess=B._bypass_function};B.prototype.processCode=function(){try{this._script=new (new Function("properties",this.properties.code))(this.properties),this._old_code=this.properties.code,this._callback=this._script.onaudioprocess}catch(w){console.error("Error in onaudioprocess code",w),this._callback=B._bypass_function, +this.audionode.onaudioprocess=this._callback}};B.prototype.onPropertyChanged=function(c,e){"code"==c&&(this.properties.code=e,this.processCode(),this.graph&&this.graph.status==LGraph.STATUS_RUNNING&&(this.audionode.onaudioprocess=this._callback))};B.default_function=function(){this.onaudioprocess=function(c){var e=c.inputBuffer;c=c.outputBuffer;for(var a=0;a{ + if(!resp.ok) + { + this.boxcolor = "#F00"; + that.trigger("error"); + } + else + { + this.boxcolor = "#0F0"; + return resp.text(); + } + }) + .then(data=>{ + that._data = data; + that._fetching = null; + that.trigger("ready"); + }); +} + +HTTPRequestNode.prototype.onAction = function(evt) +{ + if(evt == "request") + this.fetch(); +} + +HTTPRequestNode.prototype.onExecute = function() { + this.setOutputData(1, this._data); +}; + +HTTPRequestNode.prototype.onGetOutputs = function() { + return [["error",LiteGraph.EVENT]]; +} + +LiteGraph.registerNodeType("network/httprequest", HTTPRequestNode); + + + })(this); diff --git a/build/litegraph_mini.min.js b/build/litegraph_mini.min.js index cccc4de16..67b223fa8 100644 --- a/build/litegraph_mini.min.js +++ b/build/litegraph_mini.min.js @@ -1,27 +1,27 @@ -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(x,n,t){x!=Array.prototype&&x!=Object.prototype&&(x[n]=t.value)};$jscomp.getGlobal=function(x){return"undefined"!=typeof window&&window===x?x:"undefined"!=typeof global&&null!=global?global:x};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_"; -$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.Symbol=function(){var x=0;return function(n){return $jscomp.SYMBOL_PREFIX+(n||"")+x++}}(); -$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var x=$jscomp.global.Symbol.iterator;x||(x=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[x]&&$jscomp.defineProperty(Array.prototype,x,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(x){var n=0;return $jscomp.iteratorPrototype(function(){return nt&&(t=Math.max(0,w+t));if(null==h||h>w)h=w;h=Number(h);0>h&&(h=Math.max(0,w+h));for(t=Number(t||0);t=y}},"es6","es3");$jscomp.findInternal=function(x,n,t){x instanceof String&&(x=String(x));for(var h=x.length,w=0;wr&&(r=Math.max(0,y+r));if(null==h||h>y)h=y;h=Number(h);0>h&&(h=Math.max(0,y+h));for(r=Number(r||0);r=z}},"es6","es3");$jscomp.findInternal=function(w,m,r){w instanceof String&&(w=String(w));for(var h=w.length,y=0;ya&&eb?!0:!1}function z(a,b){var c=a[0]+a[2],e=a[1]+a[3],d=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>d||ca&&eb?!0:!1}function D(a,b){var c=a[0]+a[2],e=a[1]+a[3],d=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>d||ck.width-m.width-10&&(d=k.width-m.width-10),k.height&&a>k.height-m.height-10&&(a=k.height-m.height-10));g.style.left=d+"px";g.style.top=a+"px";b.scale&&(g.style.transform="scale("+b.scale+")")}function G(a){this.points=a;this.nearest=this.selected=-1;this.size=null;this.must_update=!0;this.margin=5}function J(a,b,c){return b>a?b:ck.width-n.width-10&&(d=k.width-n.width-10),k.height&&a>k.height-n.height-10&&(a=k.height-n.height-10));g.style.left=d+"px";g.style.top=a+"px";b.scale&&(g.style.transform="scale("+b.scale+")")}function H(a){this.points=a;this.nearest=this.selected=-1;this.size=null;this.must_update=!0;this.margin=5}function I(a,b,c){return b>a?b:c>a/4).toString(16)})},isValidConnection:function(a, b){if(""==a||"*"===a)a=0;if(""==b||"*"===b)b=0;if(!a||!b||a==b||a==f.EVENT&&b==f.ACTION)return!0;a=String(a);b=String(b);a=a.toLowerCase();b=b.toLowerCase();if(-1==a.indexOf(",")&&-1==b.indexOf(","))return a==b;a=a.split(",");b=b.split(",");for(var c=0;ck&&(k=p.size[r]);m+=p.size[b==f.VERTICAL_LAYOUT?0:1]+a+f.NODE_TITLE_HEIGHT}c+=k+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 e=this._nodes_in_order?this._nodes_in_order:this._nodes;if(e)for(var d=0,g=e.length;d=f.MAX_NUMBER_OF_NODES)throw"LiteGraph: max number of nodes in a graph reached";if(f.use_uuids){if(null==a.id||-1==a.id)a.id=f.uuidv4()}else null==a.id||-1==a.id? -a.id=++this.last_node_id:this.last_node_idk&&(k=p.size[q]);n+=p.size[b==f.VERTICAL_LAYOUT?0:1]+a+f.NODE_TITLE_HEIGHT}c+=k+a}this.setDirtyCanvas(!0,!0)};m.prototype.getTime=function(){return this.globaltime};m.prototype.getFixedTime=function(){return this.fixedtime};m.prototype.getElapsedTime=function(){return this.elapsed_time};m.prototype.sendEventToAllNodes=function(a, +b,c){c=c||f.ALWAYS;var e=this._nodes_in_order?this._nodes_in_order:this._nodes;if(e)for(var d=0,g=e.length;d=f.MAX_NUMBER_OF_NODES)throw"LiteGraph: max number of nodes in a graph reached";if(f.use_uuids){if(null==a.id||-1==a.id)a.id=f.uuidv4()}else 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=f.use_uuids?f.uuidv4():-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._version++;this.setDirtyCanvas(!0,!0);return c}};m.prototype.load=function(a,b){var c=this;if(a.constructor===File||a.constructor===Blob){var e=new FileReader;e.addEventListener("load",function(a){a=JSON.parse(a.target.result);c.configure(a);b&&b()});e.readAsText(a)}else{var d=new XMLHttpRequest;d.open("GET",a,!0);d.send(null);d.onload=function(a){200!==d.status?console.error("Error loading graph:",d.status,d.response):(a=JSON.parse(d.response),c.configure(a),b&&b())};d.onerror=function(a){console.error("Error loading graph:", +a)}}};m.prototype.onNodeTrace=function(a,b,c){};r.prototype.configure=function(a){a.constructor===Array?(this.id=a[0],this.origin_id=a[1],this.origin_slot=a[2],this.target_id=a[3],this.target_slot=a[4],this.type=a[5]):(this.id=a.id,this.type=a.type,this.origin_id=a.origin_id,this.origin_slot=a.origin_slot,this.target_id=a.target_id,this.target_slot=a.target_slot)};r.prototype.serialize=function(){return[this.id,this.origin_id,this.origin_slot,this.target_id,this.target_slot,this.type]};f.LLink=r; +w.LGraphNode=f.LGraphNode=h;h.prototype._ctor=function(a){this.title=a||"Unnamed";this.size=[f.NODE_WIDTH,60];this.graph=null;this._pos=new Float32Array(10,10);Object.defineProperty(this,"pos",{set:function(a){!a||2>a.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos},enumerable:!0});this.id=f.use_uuids?f.uuidv4():-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.inputs)for(c=0;ca&&this.pos[1]-d-cb)return!0;return!1};h.prototype.getSlotInPosition=function(a,b){var c=new Float32Array(2);if(this.inputs)for(var e=0,d=this.inputs.length;e=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)if(f.do_add_triggers_slots)b.changeMode(f.ON_TRIGGER),c=b.findInputSlot("onTrigger");else return null;else if(!b.inputs||c>=b.inputs.length)return f.debug&&console.log("Connect: Error, slot number not found"),null;var e=b.inputs[c],d=this.outputs[a];if(!this.outputs[a])return null;b.onBeforeConnectInput&&(c=b.onBeforeConnectInput(c)); -if(!1===c||null===c||!f.isValidConnection(d.type,e.type))return this.setDirtyCanvas(!1,!0),null;if(b.onConnectInput&&!1===b.onConnectInput(c,d.type,d,this,a)||this.onConnectOutput&&!1===this.onConnectOutput(a,e.type,e,b,c))return null;b.inputs[c]&&null!=b.inputs[c].link&&(this.graph.beforeChange(),b.disconnectInput(c,{doProcessChange:!1}));if(null!==d.links&&d.links.length)switch(d.type){case f.EVENT:f.allow_multi_output_for_events||(this.graph.beforeChange(),this.disconnectOutput(a,!1,{doProcessChange:!1}))}var g= -f.use_uuids?f.uuidv4():++this.graph.last_link_id;g=new t(g,e.type||d.type,this.id,a,b.id,c);this.graph.links[g.id]=g;null==d.links&&(d.links=[]);d.links.push(g.id);b.inputs[c].link=g.id;this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(f.OUTPUT,a,!0,g,d);if(b.onConnectionsChange)b.onConnectionsChange(f.INPUT,c,!0,g,e);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,g);return g};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 e=0,d=c.links.length;ea&&this.pos[1]-d-cb)return!0;return!1};h.prototype.getSlotInPosition=function(a,b){var c=new Float32Array(2);if(this.inputs)for(var e=0,d=this.inputs.length;e=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)if(f.do_add_triggers_slots)b.changeMode(f.ON_TRIGGER),c=b.findInputSlot("onTrigger");else return null;else if(!b.inputs||c>=b.inputs.length)return f.debug&&console.log("Connect: Error, slot number not found"),null;var e=b.inputs[c],d=this.outputs[a];if(!this.outputs[a])return null; +b.onBeforeConnectInput&&(c=b.onBeforeConnectInput(c));if(!1===c||null===c||!f.isValidConnection(d.type,e.type))return this.setDirtyCanvas(!1,!0),null;if(b.onConnectInput&&!1===b.onConnectInput(c,d.type,d,this,a)||this.onConnectOutput&&!1===this.onConnectOutput(a,e.type,e,b,c))return null;b.inputs[c]&&null!=b.inputs[c].link&&(this.graph.beforeChange(),b.disconnectInput(c,{doProcessChange:!1}));if(null!==d.links&&d.links.length)switch(d.type){case f.EVENT:f.allow_multi_output_for_events||(this.graph.beforeChange(), +this.disconnectOutput(a,!1,{doProcessChange:!1}))}var g=f.use_uuids?f.uuidv4():++this.graph.last_link_id;g=new r(g,e.type||d.type,this.id,a,b.id,c);this.graph.links[g.id]=g;null==d.links&&(d.links=[]);d.links.push(g.id);b.inputs[c].link=g.id;this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(f.OUTPUT,a,!0,g,d);if(b.onConnectionsChange)b.onConnectionsChange(f.INPUT,c,!0,g,e);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,g);return g};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 e=0,d=c.links.length;e=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 e=this.graph.links[c];if(e){var d=this.graph.getNodeById(e.origin_id);if(!d)return!1;var g=d.outputs[e.origin_slot];if(!g||!g.links||0==g.links.length)return!1;for(var k=0,m=g.links.length;k=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 e=this.graph.links[c];if(e){var d=this.graph.getNodeById(e.origin_id);if(!d)return!1;var g=d.outputs[e.origin_slot];if(!g||!g.links||0==g.links.length)return!1;for(var k=0,n=g.links.length;kb&&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&&e>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]/e*(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]+d:this.pos[0]+this.size[0]+1-d;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})};w.prototype.configure=function(a){this.title=a.title;this._bounding.set(a.bounding);this.color=a.color;this.font_size=a.font_size};w.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_size:this.font_size}};w.prototype.move=function(a,b,c){this._pos[0]+=a;this._pos[1]+=b;if(!c)for(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})};y.prototype.configure=function(a){this.title=a.title;this._bounding.set(a.bounding);this.color=a.color;this.font_size=a.font_size};y.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_size:this.font_size}};y.prototype.move=function(a,b,c){this._pos[0]+=a;this._pos[1]+=b;if(!c)for(c=0;c=this.viewport[0]&&e=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)}};y.prototype.changeDeltaScale=function(a,b){this.changeScale(this.scale*a,b)};y.prototype.reset=function(){this.scale=1;this.offset[0]=0;this.offset[1]=0};x.LGraphCanvas=f.LGraphCanvas=l;l.DEFAULT_BACKGROUND_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII="; +(a.eventType="mousewheel",a.wheel="wheel"==a.type?-a.deltaY:null!=a.wheelDeltaY?a.wheelDeltaY:-60*a.detail,a.delta=a.wheelDelta?a.wheelDelta/40:a.deltaY?-a.deltaY/3:0,this.changeDeltaScale(1+.05*a.delta));this.last_mouse[0]=e;this.last_mouse[1]=c;if(d)return a.preventDefault(),a.stopPropagation(),!1}};z.prototype.toCanvasContext=function(a){a.scale(this.scale,this.scale);a.translate(this.offset[0],this.offset[1])};z.prototype.convertOffsetToCanvas=function(a){return[(a[0]+this.offset[0])*this.scale, +(a[1]+this.offset[1])*this.scale]};z.prototype.convertCanvasToOffset=function(a,b){b=b||[0,0];b[0]=a[0]/this.scale-this.offset[0];b[1]=a[1]/this.scale-this.offset[1];return b};z.prototype.mouseDrag=function(a,b){this.offset[0]+=a/this.scale;this.offset[1]+=b/this.scale;if(this.onredraw)this.onredraw(this)};z.prototype.changeScale=function(a,b){athis.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)}};z.prototype.changeDeltaScale=function(a,b){this.changeScale(this.scale*a,b)};z.prototype.reset=function(){this.scale=1;this.offset[0]=0;this.offset[1]=0};w.LGraphCanvas=f.LGraphCanvas=l;l.DEFAULT_BACKGROUND_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII="; l.link_type_colors={"-1":f.EVENT_LINK_COLOR,number:"#AAA",node:"#DCA"};l.gradients={};l.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()};l.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)))};l.prototype.getTopGraph=function(){return this._graph_stack.length?this._graph_stack[0]:this.graph};l.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)};l.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= @@ -144,16 +144,16 @@ l.getFileExtension=function(a){var b=a.indexOf("?");-1!=b&&(a=a.substr(0,b));b=a l.prototype.setDirty=function(a,b){a&&(this.dirty_canvas=!0);b&&(this.dirty_bgcanvas=!0)};l.prototype.getCanvasWindow=function(){if(!this.canvas)return window;var a=this.canvas.ownerDocument;return a.defaultView||a.parentWindow};l.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))};l.prototype.stopRendering=function(){this.is_rendering= !1};l.prototype.blockClick=function(){this.block_click=!0;this.last_mouseclick=0};l.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();l.active_canvas=this;var c=this,e=a.clientX,d=a.clientY;this.ds.viewport=this.viewport;e=!this.viewport||this.viewport&&e>=this.viewport[0]&&e=this.viewport[1]&&dd-this.last_mouseclick&&k;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&&k?!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)if(2==a.which)if(f.middle_click_slot_add_default_node){if(g&&this.allow_interaction&&!e&&!this.read_only&&!this.connecting_node&&!g.flags.collapsed&&!this.live_mode){d=e=k=!1;if(g.outputs)for(r=0,m=g.outputs.length;rg.size[0]-f.NODE_TITLE_HEIGHT&& -0>m[1]&&(c=this,setTimeout(function(){c.openSubgraph(g.subgraph)},10)),this.live_mode&&(r=k=!0));r?g.is_selected||this.processNodeSelected(g,a):(this.allow_dragnodes&&(this.graph.beforeChange(),this.node_dragged=g),this.processNodeSelected(g,a));this.dirty_canvas=!0}}else if(!e){if(!this.read_only)for(r=0;rm[0]+4||a.canvasYm[1]+4)){this.showLinkMenu(k,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>E([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),a.preventDefault(),a.stopPropagation()); +1,this.dragging_rectangle[3]=1,e=!0);f.alt_drag_do_clone_nodes&&a.altKey&&g&&this.allow_interaction&&!e&&!this.read_only&&(cloned=g.clone())&&(cloned.pos[0]+=5,cloned.pos[1]+=5,this.graph.add(cloned,!1,{doCalcSize:!1}),g=cloned,e=!0,q||(this.allow_dragnodes&&(this.graph.beforeChange(),this.node_dragged=g),this.selected_nodes[g.id]||this.processNodeSelected(g,a)));k=!1;if(g&&(this.allow_interaction||g.flags.allow_interaction)&&!e&&!this.read_only){this.live_mode||g.flags.pinned||this.bringToFront(g); +if(this.allow_interaction&&!this.connecting_node&&!g.flags.collapsed&&!this.live_mode)if(!e&&!1!==g.resizable&&B(a.canvasX,a.canvasY,g.pos[0]+g.size[0]-5,g.pos[1]+g.size[1]-5,10,10))this.graph.beforeChange(),this.resizing_node=g,this.canvas.style.cursor="se-resize",e=!0;else{if(g.outputs){q=0;for(var n=g.outputs.length;qg.size[0]-f.NODE_TITLE_HEIGHT&& +0>n[1]&&(c=this,setTimeout(function(){c.openSubgraph(g.subgraph)},10)),this.live_mode&&(q=k=!0));q?g.is_selected||this.processNodeSelected(g,a):(this.allow_dragnodes&&(this.graph.beforeChange(),this.node_dragged=g),this.processNodeSelected(g,a));this.dirty_canvas=!0}}else if(!e){if(!this.read_only)for(q=0;qn[0]+4||a.canvasYn[1]+4)){this.showLinkMenu(k,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>C([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),a.preventDefault(),a.stopPropagation()); k=!0}!e&&k&&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}}}};l.prototype.processMouseMove=function(a){this.autoresize&&this.resize(); this.set_canvas_dirty_on_mouse_event&&(this.dirty_canvas=!0);if(this.graph){l.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);var e=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes);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, @@ -165,7 +165,7 @@ this.node_capturing_input!=e&&this.node_capturing_input.onMouseMove)this.node_ca 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}};l.prototype.processMouseUp=function(a){var b=void 0===a.isPrimary||a.isPrimary;if(!b)return!1;this.set_canvas_dirty_on_mouse_event&&(this.dirty_canvas=!0);if(this.graph){var c=this.getCanvasWindow().document;l.active_canvas=this;this.options.skip_events|| (f.pointerListenerRemove(c,"move",this._mousemove_callback,!0),f.pointerListenerAdd(this.canvas,"move",this._mousemove_callback,!0),f.pointerListenerRemove(c,"up",this._mouseup_callback,!0));this.adjustMouseEvent(a);c=f.getTime();a.click_time=c-this.last_mouseclick;this.last_mouse_dragging=!1;this.last_click_position=null;this.block_click&&(this.block_click=!1);if(1==a.which){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;var e=this.graph.getNodeOnPos(a.canvasX,a.canvasY,this.visible_nodes);if(this.dragging_rectangle){if(this.graph){c= -this.graph._nodes;var d=new Float32Array(4),g=Math.abs(this.dragging_rectangle[2]),k=Math.abs(this.dragging_rectangle[3]),m=0>this.dragging_rectangle[3]?this.dragging_rectangle[1]-k:this.dragging_rectangle[1];this.dragging_rectangle[0]=0>this.dragging_rectangle[2]?this.dragging_rectangle[0]-g:this.dragging_rectangle[0];this.dragging_rectangle[1]=m;this.dragging_rectangle[2]=g;this.dragging_rectangle[3]=k;if(!e||10this.dragging_rectangle[3]?this.dragging_rectangle[1]-k:this.dragging_rectangle[1];this.dragging_rectangle[0]=0>this.dragging_rectangle[2]?this.dragging_rectangle[0]-g:this.dragging_rectangle[0];this.dragging_rectangle[1]=n;this.dragging_rectangle[2]=g;this.dragging_rectangle[3]=k;if(!e||10b.nodes[d].pos[0]&&(c[0]=b.nodes[d].pos[0],e[0]=d),c[1]>b.nodes[d].pos[1]&&(c[1]=b.nodes[d].pos[1],e[1]=d)):(c=[b.nodes[d].pos[0],b.nodes[d].pos[1]],e=[d,d]);e=[];for(d=0;d=this.viewport[0]&&b=this.viewport[1]&&c=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}};l.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 e=0;e> ";b.fillText(e+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);1.5>this.ds.scale&&!c&&this.clear_background_color&& (b.fillStyle=this.clear_background_color,b.fillRect(this.visible_area[0],this.visible_area[1],this.visible_area[2],this.visible_area[3]));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 g=this.editor_alpha;b.globalAlpha=g;this.render_shadows&&!d?(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 k=a._shape||f.BOX_SHAPE;D.set(a.size);var m=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),D[0]=a._collapsed_width,D[1]=0)}a.clip_area&&(b.save(),b.beginPath(),k==f.BOX_SHAPE?b.rect(0,0, -D[0],D[1]):k==f.ROUND_SHAPE?b.roundRect(0,0,D[0],D[1],[10]):k==f.CIRCLE_SHAPE&&b.arc(.5*D[0],.5*D[1],.5*D[0],0,2*Math.PI),b.clip());a.has_errors&&(e="red");this.drawNodeShape(a,b,D,c,e,a.is_selected,a.mouseOver);b.shadowColor="transparent";if(a.onDrawForeground)a.onDrawForeground(b,this,this.canvas);b.textAlign=m?"center":"left";b.font=this.inner_text_font;e=!d;var p=this.connecting_output;k=this.connecting_input;b.lineWidth=1;q=0;var r=new Float32Array(2);if(!a.flags.collapsed){if(a.inputs)for(c= -0;cthis.ds.scale;if(this.live_mode){if(!a.flags.collapsed&&(b.shadowColor="transparent",a.onDrawForeground))a.onDrawForeground(b,this,this.canvas)}else{var g=this.editor_alpha;b.globalAlpha=g;this.render_shadows&&!d?(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 k=a._shape||f.BOX_SHAPE;K.set(a.size);var n=a.horizontal;if(a.flags.collapsed){b.font=this.inner_text_font;var t=a.getTitle?a.getTitle():a.title;null!=t&&(a._collapsed_width=Math.min(a.size[0],b.measureText(t).width+2*f.NODE_TITLE_HEIGHT),K[0]=a._collapsed_width,K[1]=0)}a.clip_area&&(b.save(),b.beginPath(),k==f.BOX_SHAPE?b.rect(0,0, +K[0],K[1]):k==f.ROUND_SHAPE?b.roundRect(0,0,K[0],K[1],[10]):k==f.CIRCLE_SHAPE&&b.arc(.5*K[0],.5*K[1],.5*K[0],0,2*Math.PI),b.clip());a.has_errors&&(e="red");this.drawNodeShape(a,b,K,c,e,a.is_selected,a.mouseOver);b.shadowColor="transparent";if(a.onDrawForeground)a.onDrawForeground(b,this,this.canvas);b.textAlign=n?"center":"left";b.font=this.inner_text_font;e=!d;var p=this.connecting_output;k=this.connecting_input;b.lineWidth=1;t=0;var q=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,p=a.constructor.title_mode,r=!0;p==f.TRANSPARENT_TITLE||p==f.NO_TITLE?r=!1:p==f.AUTOHIDE_TITLE&&k&&(r=!0);A[0]=0;A[1]=r?-d:0;A[2]=c[0]+1;A[3]=r?c[1]+d:c[1];k=b.globalAlpha;b.beginPath();q==f.BOX_SHAPE||m?b.fillRect(A[0],A[1],A[2],A[3]):q==f.ROUND_SHAPE||q==f.CARD_SHAPE?b.roundRect(A[0],A[1],A[2],A[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&&r&&(b.shadowColor="transparent",b.fillStyle="rgba(0,0,0,0.2)",b.fillRect(0,-1,A[2],2));b.shadowColor="transparent";if(a.onDrawBackground)a.onDrawBackground(b,this,this.canvas,this.graph_mouse);if(r||p==f.TRANSPARENT_TITLE){if(a.onDrawTitleBar)a.onDrawTitleBar(b,d,c,this.ds.scale,e);else if(p!=f.TRANSPARENT_TITLE&&(a.constructor.title_color||this.render_title_colored)){r= -a.constructor.title_color||e;a.flags.collapsed&&(b.shadowColor=f.DEFAULT_SHADOW_COLOR);if(this.use_gradients){var u=l.gradients[r];u||(u=l.gradients[r]=b.createLinearGradient(0,0,400,0),u.addColorStop(0,r),u.addColorStop(1,"#000"));b.fillStyle=u}else b.fillStyle=r;b.beginPath();q==f.BOX_SHAPE||m?b.rect(0,-d,c[0]+1,d):(q==f.ROUND_SHAPE||q==f.CARD_SHAPE)&&b.roundRect(0,-d,c[0]+1,d,a.flags.collapsed?[this.round_radius]:[this.round_radius,this.round_radius,0,0]);b.fill();b.shadowColor="transparent"}r= -!1;f.node_box_coloured_by_mode&&f.NODE_MODES_COLORS[a.mode]&&(r=f.NODE_MODES_COLORS[a.mode]);f.node_box_coloured_when_on&&(r=a.action_triggered?"#FFF":a.execute_triggered?"#AAA":r);if(a.onDrawTitleBox)a.onDrawTitleBox(b,d,c,this.ds.scale);else q==f.ROUND_SHAPE||q==f.CIRCLE_SHAPE||q==f.CARD_SHAPE?(m&&(b.fillStyle="black",b.beginPath(),b.arc(.5*d,-.5*d,6,0,2*Math.PI),b.fill()),b.fillStyle=a.boxcolor||r||f.NODE_DEFAULT_BOXCOLOR,m?b.fillRect(.5*d-5,-.5*d-5,10,10):(b.beginPath(),b.arc(.5*d,-.5*d,5,0,2* -Math.PI),b.fill())):(m&&(b.fillStyle="black",b.fillRect(.5*(d-10)-1,-.5*(d+10)-1,12,12)),b.fillStyle=a.boxcolor||r||f.NODE_DEFAULT_BOXCOLOR,b.fillRect(.5*(d-10),-.5*(d+10),10,10));b.globalAlpha=k;if(a.onDrawTitleText)a.onDrawTitleText(b,d,c,this.ds.scale,this.title_text_font,g);!m&&(b.font=this.title_text_font,k=String(a.getTitle()))&&(b.fillStyle=g?f.NODE_SELECTED_TITLE_COLOR:a.constructor.title_text_color||this.node_title_color,a.flags.collapsed?(b.textAlign="left",b.measureText(k),b.fillText(k.substr(0, -20),d,f.NODE_TITLE_TEXT_Y-d),b.textAlign="left"):(b.textAlign="left",b.fillText(k,d,f.NODE_TITLE_TEXT_Y-d)));a.flags.collapsed||!a.subgraph||a.skip_subgraph_button||(k=f.NODE_TITLE_HEIGHT,r=a.size[0]-k,u=f.isInsideRectangle(this.graph_mouse[0]-a.pos[0],this.graph_mouse[1]-a.pos[1],r+2,-k+2,k-4,k-4),b.fillStyle=u?"#888":"#555",q==f.BOX_SHAPE||m?b.fillRect(r+2,-k+2,k-4,k-4):(b.beginPath(),b.roundRect(r+2,-k+2,k-4,k-4,[4]),b.fill()),b.fillStyle="#333",b.beginPath(),b.moveTo(r+.2*k,.6*-k),b.lineTo(r+ -.8*k,.6*-k),b.lineTo(r+.5*k,.3*-k),b.fill());if(a.onDrawTitle)a.onDrawTitle(b)}if(g){if(a.onBounding)a.onBounding(A);p==f.TRANSPARENT_TITLE&&(A[1]-=d,A[3]+=d);b.lineWidth=1;b.globalAlpha=.8;b.beginPath();q==f.BOX_SHAPE?b.rect(-6+A[0],-6+A[1],12+A[2],12+A[3]):q==f.ROUND_SHAPE||q==f.CARD_SHAPE&&a.flags.collapsed?b.roundRect(-6+A[0],-6+A[1],12+A[2],12+A[3],[2*this.round_radius]):q==f.CARD_SHAPE?b.roundRect(-6+A[0],-6+A[1],12+A[2],12+A[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=e;b.globalAlpha=1}0C[2]&&(C[0]+=C[2],C[2]=Math.abs(C[2]));0>C[3]&& -(C[1]+=C[3],C[3]=Math.abs(C[3]));if(z(C,M)){var l=q.outputs[p];p=g.inputs[k];if(l&&p&&(q=l.dir||(q.horizontal?f.DOWN:f.RIGHT),p=p.dir||(g.horizontal?f.UP:f.LEFT),this.renderLink(a,r,u,m,!1,0,null,q,p),m&&m._last_time&&1E3>b-m._last_time)){l=2-.002*(b-m._last_time);var I=a.globalAlpha;a.globalAlpha=I*l;this.renderLink(a,r,u,m,!0,l,"white",q,p);a.globalAlpha=I}}}}}}a.globalAlpha=1};l.prototype.renderLink=function(a,b,c,e,d,g,k,m,q,p){e&&this.visible_links.push(e);!k&&e&&(k=e.color||l.link_type_colors[e.type]); -k||(k=this.default_link_color);null!=e&&this.highlighted_links[e.id]&&(k="#FFF");m=m||f.RIGHT;q=q||f.LEFT;var r=E(b,c);this.render_connections_border&&.6b[1]?0:Math.PI,a.save(),a.translate(u[0],u[1]),a.rotate(r),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5, --3),a.fill(),a.restore(),a.save(),a.translate(e[0],e[1]),a.rotate(p),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore()),a.beginPath(),a.arc(d[0],d[1],5,0,2*Math.PI),a.fill());if(g)for(a.fillStyle=k,u=0;5>u;++u)g=(.001*f.getTime()+.2*u)%1,d=this.computeConnectionPoint(b,c,g,m,q),a.beginPath(),a.arc(d[0],d[1],5,0,2*Math.PI),a.fill()};l.prototype.computeConnectionPoint=function(a,b,c,e,d){e=e||f.RIGHT;d=d||f.LEFT;var g=E(a,b),k=[a[0],a[1]],m=[b[0],b[1]];switch(e){case f.LEFT:k[0]+= --.25*g;break;case f.RIGHT:k[0]+=.25*g;break;case f.UP:k[1]+=-.25*g;break;case f.DOWN:k[1]+=.25*g}switch(d){case f.LEFT:m[0]+=-.25*g;break;case f.RIGHT:m[0]+=.25*g;break;case f.UP:m[1]+=-.25*g;break;case f.DOWN:m[1]+=.25*g}e=(1-c)*(1-c)*(1-c);d=3*(1-c)*(1-c)*c;g=3*(1-c)*c*c;c*=c*c;return[e*a[0]+d*k[0]+g*m[0]+c*b[0],e*a[1]+d*k[1]+g*m[1]+c*b[1]]};l.prototype.drawExecutionOrder=function(a){a.shadowColor="transparent";a.globalAlpha=.25;a.textAlign="center";a.strokeStyle="white";a.globalAlpha=.75;for(var b= +l.prototype.drawNodeShape=function(a,b,c,e,d,g,k){b.strokeStyle=e;b.fillStyle=d;d=f.NODE_TITLE_HEIGHT;var n=.5>this.ds.scale,t=a._shape||a.constructor.shape||f.ROUND_SHAPE,p=a.constructor.title_mode,q=!0;p==f.TRANSPARENT_TITLE||p==f.NO_TITLE?q=!1:p==f.AUTOHIDE_TITLE&&k&&(q=!0);A[0]=0;A[1]=q?-d:0;A[2]=c[0]+1;A[3]=q?c[1]+d:c[1];k=b.globalAlpha;b.beginPath();t==f.BOX_SHAPE||n?b.fillRect(A[0],A[1],A[2],A[3]):t==f.ROUND_SHAPE||t==f.CARD_SHAPE?b.roundRect(A[0],A[1],A[2],A[3],t==f.CARD_SHAPE?[this.round_radius, +this.round_radius,0,0]:[this.round_radius]):t==f.CIRCLE_SHAPE&&b.arc(.5*c[0],.5*c[1],.5*c[0],0,2*Math.PI);b.fill();!a.flags.collapsed&&q&&(b.shadowColor="transparent",b.fillStyle="rgba(0,0,0,0.2)",b.fillRect(0,-1,A[2],2));b.shadowColor="transparent";if(a.onDrawBackground)a.onDrawBackground(b,this,this.canvas,this.graph_mouse);if(q||p==f.TRANSPARENT_TITLE){if(a.onDrawTitleBar)a.onDrawTitleBar(b,d,c,this.ds.scale,e);else if(p!=f.TRANSPARENT_TITLE&&(a.constructor.title_color||this.render_title_colored)){q= +a.constructor.title_color||e;a.flags.collapsed&&(b.shadowColor=f.DEFAULT_SHADOW_COLOR);if(this.use_gradients){var x=l.gradients[q];x||(x=l.gradients[q]=b.createLinearGradient(0,0,400,0),x.addColorStop(0,q),x.addColorStop(1,"#000"));b.fillStyle=x}else b.fillStyle=q;b.beginPath();t==f.BOX_SHAPE||n?b.rect(0,-d,c[0]+1,d):(t==f.ROUND_SHAPE||t==f.CARD_SHAPE)&&b.roundRect(0,-d,c[0]+1,d,a.flags.collapsed?[this.round_radius]:[this.round_radius,this.round_radius,0,0]);b.fill();b.shadowColor="transparent"}q= +!1;f.node_box_coloured_by_mode&&f.NODE_MODES_COLORS[a.mode]&&(q=f.NODE_MODES_COLORS[a.mode]);f.node_box_coloured_when_on&&(q=a.action_triggered?"#FFF":a.execute_triggered?"#AAA":q);if(a.onDrawTitleBox)a.onDrawTitleBox(b,d,c,this.ds.scale);else t==f.ROUND_SHAPE||t==f.CIRCLE_SHAPE||t==f.CARD_SHAPE?(n&&(b.fillStyle="black",b.beginPath(),b.arc(.5*d,-.5*d,6,0,2*Math.PI),b.fill()),b.fillStyle=a.boxcolor||q||f.NODE_DEFAULT_BOXCOLOR,n?b.fillRect(.5*d-5,-.5*d-5,10,10):(b.beginPath(),b.arc(.5*d,-.5*d,5,0,2* +Math.PI),b.fill())):(n&&(b.fillStyle="black",b.fillRect(.5*(d-10)-1,-.5*(d+10)-1,12,12)),b.fillStyle=a.boxcolor||q||f.NODE_DEFAULT_BOXCOLOR,b.fillRect(.5*(d-10),-.5*(d+10),10,10));b.globalAlpha=k;if(a.onDrawTitleText)a.onDrawTitleText(b,d,c,this.ds.scale,this.title_text_font,g);!n&&(b.font=this.title_text_font,k=String(a.getTitle()))&&(b.fillStyle=g?f.NODE_SELECTED_TITLE_COLOR:a.constructor.title_text_color||this.node_title_color,a.flags.collapsed?(b.textAlign="left",b.measureText(k),b.fillText(k.substr(0, +20),d,f.NODE_TITLE_TEXT_Y-d),b.textAlign="left"):(b.textAlign="left",b.fillText(k,d,f.NODE_TITLE_TEXT_Y-d)));a.flags.collapsed||!a.subgraph||a.skip_subgraph_button||(k=f.NODE_TITLE_HEIGHT,q=a.size[0]-k,x=f.isInsideRectangle(this.graph_mouse[0]-a.pos[0],this.graph_mouse[1]-a.pos[1],q+2,-k+2,k-4,k-4),b.fillStyle=x?"#888":"#555",t==f.BOX_SHAPE||n?b.fillRect(q+2,-k+2,k-4,k-4):(b.beginPath(),b.roundRect(q+2,-k+2,k-4,k-4,[4]),b.fill()),b.fillStyle="#333",b.beginPath(),b.moveTo(q+.2*k,.6*-k),b.lineTo(q+ +.8*k,.6*-k),b.lineTo(q+.5*k,.3*-k),b.fill());if(a.onDrawTitle)a.onDrawTitle(b)}if(g){if(a.onBounding)a.onBounding(A);p==f.TRANSPARENT_TITLE&&(A[1]-=d,A[3]+=d);b.lineWidth=1;b.globalAlpha=.8;b.beginPath();t==f.BOX_SHAPE?b.rect(-6+A[0],-6+A[1],12+A[2],12+A[3]):t==f.ROUND_SHAPE||t==f.CARD_SHAPE&&a.flags.collapsed?b.roundRect(-6+A[0],-6+A[1],12+A[2],12+A[3],[2*this.round_radius]):t==f.CARD_SHAPE?b.roundRect(-6+A[0],-6+A[1],12+A[2],12+A[3],[2*this.round_radius,2,2*this.round_radius,2]):t==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=e;b.globalAlpha=1}0E[2]&&(E[0]+=E[2],E[2]=Math.abs(E[2]));0>E[3]&& +(E[1]+=E[3],E[3]=Math.abs(E[3]));if(D(E,L)){var u=t.outputs[p];p=g.inputs[k];if(u&&p&&(t=u.dir||(t.horizontal?f.DOWN:f.RIGHT),p=p.dir||(g.horizontal?f.UP:f.LEFT),this.renderLink(a,q,x,n,!1,0,null,t,p),n&&n._last_time&&1E3>b-n._last_time)){u=2-.002*(b-n._last_time);var l=a.globalAlpha;a.globalAlpha=l*u;this.renderLink(a,q,x,n,!0,u,"white",t,p);a.globalAlpha=l}}}}}}a.globalAlpha=1};l.prototype.renderLink=function(a,b,c,e,d,g,k,n,t,p){e&&this.visible_links.push(e);!k&&e&&(k=e.color||l.link_type_colors[e.type]); +k||(k=this.default_link_color);null!=e&&this.highlighted_links[e.id]&&(k="#FFF");n=n||f.RIGHT;t=t||f.LEFT;var q=C(b,c);this.render_connections_border&&.6b[1]?0:Math.PI,a.save(),a.translate(x[0],x[1]),a.rotate(q),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5, +-3),a.fill(),a.restore(),a.save(),a.translate(e[0],e[1]),a.rotate(p),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore()),a.beginPath(),a.arc(d[0],d[1],5,0,2*Math.PI),a.fill());if(g)for(a.fillStyle=k,x=0;5>x;++x)g=(.001*f.getTime()+.2*x)%1,d=this.computeConnectionPoint(b,c,g,n,t),a.beginPath(),a.arc(d[0],d[1],5,0,2*Math.PI),a.fill()};l.prototype.computeConnectionPoint=function(a,b,c,e,d){e=e||f.RIGHT;d=d||f.LEFT;var g=C(a,b),k=[a[0],a[1]],n=[b[0],b[1]];switch(e){case f.LEFT:k[0]+= +-.25*g;break;case f.RIGHT:k[0]+=.25*g;break;case f.UP:k[1]+=-.25*g;break;case f.DOWN:k[1]+=.25*g}switch(d){case f.LEFT:n[0]+=-.25*g;break;case f.RIGHT:n[0]+=.25*g;break;case f.UP:n[1]+=-.25*g;break;case f.DOWN:n[1]+=.25*g}e=(1-c)*(1-c)*(1-c);d=3*(1-c)*(1-c)*c;g=3*(1-c)*c*c;c*=c*c;return[e*a[0]+d*k[0]+g*n[0]+c*b[0],e*a[1]+d*k[1]+g*n[1]+c*b[1]]};l.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;ct&&(t=0);1w&&(w=0),1g||g>h-12||ku.last_y+l||void 0===u.last_y)){e=u.value;switch(u.type){case "button":c.type===f.pointerevents_method+"down"&&(u.callback&&setTimeout(function(){u.callback(u,q,a,b,c)},20),this.dirty_canvas=u.clicked=!0);break;case "slider":e=u.value;p=J((g-15)/(h-30),0,1);if(u.options.read_only)break;u.value=u.options.min+(u.options.max-u.options.min)*p;e!=u.value&&setTimeout(function(){d(u,u.value)},20);this.dirty_canvas=!0;break;case "number":case "combo":e= -u.value;if(c.type==f.pointerevents_method+"move"&&"number"==u.type)c.deltaX&&(u.value+=.1*c.deltaX*(u.options.step||1)),null!=u.options.min&&u.valueu.options.max&&(u.value=u.options.max);else if(c.type==f.pointerevents_method+"down"){var v=u.options.values;v&&v.constructor===Function&&(v=u.options.values(u,a));var n=null;"number"!=u.type&&(n=v.constructor===Array?v:Object.keys(v));g=40>g?-1:g>h-40?1:0;if("number"==u.type)u.value+= -.1*g*(u.options.step||1),null!=u.options.min&&u.valueu.options.max&&(u.value=u.options.max);else if(g)p=-1,this.last_mouseclick=0,p=v.constructor===Object?n.indexOf(String(u.value))+g:n.indexOf(u.value)+g,p>=n.length&&(p=n.length-1),0>p&&(p=0),u.value=v.constructor===Array?v[p]:p;else{var w=v!=n?Object.values(v):v;new f.ContextMenu(w,{scale:Math.max(1,this.ds.scale),event:c,className:"dark",callback:function(a,b,c){v!=n&&(a=w.indexOf(a)); -this.value=a;d(this,a);q.dirty_canvas=!0;return!1}.bind(u)},p)}}else c.type==f.pointerevents_method+"up"&&"number"==u.type&&(g=40>g?-1:g>h-40?1:0,200>c.click_time&&0==g&&this.prompt("Value",u.value,function(a){if(/^[0-9+\-*/()\s]+|\d+\.\d+$/.test(a))try{a=eval(a)}catch(O){}this.value=Number(a);d(this,this.value)}.bind(u),c));e!=u.value&&setTimeout(function(){d(this,this.value)}.bind(u),20);this.dirty_canvas=!0;break;case "toggle":c.type==f.pointerevents_method+"down"&&(u.value=!u.value,setTimeout(function(){d(u, -u.value)},20));break;case "string":case "text":c.type==f.pointerevents_method+"down"&&this.prompt("Value",u.value,function(a){d(this,a)}.bind(u),c,u.options?u.options.multiline:!1);break;default:u.mouse&&(this.dirty_canvas=u.mouse(c,[g,k],a))}if(e!=u.value){if(a.onWidgetChanged)a.onWidgetChanged(u.name,u.value,e,u);a.graph._version++}return u}}}return null};l.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(e),1>c&&(b.live_mode=!0));1c.pos[0]+c.size[0])c=f;if(null===e||m+p>e.pos[1]+e.size[1])e=f;if(null===d||qz&&(z=0);1r&&(r=0),1g||g>v-12||ku.last_y+h||void 0===u.last_y)){e=u.value;switch(u.type){case "button":c.type===f.pointerevents_method+"down"&&(u.callback&&setTimeout(function(){u.callback(u,p,a,b,c)},20),this.dirty_canvas=u.clicked=!0);break;case "slider":e=u.value;q=I((g-15)/(v-30),0,1);if(u.options.read_only)break;u.value=u.options.min+(u.options.max-u.options.min)*q;e!=u.value&&setTimeout(function(){d(u,u.value)},20);this.dirty_canvas= +!0;break;case "number":case "combo":e=u.value;if(c.type==f.pointerevents_method+"move"&&"number"==u.type)l&&(u.value+=.1*l*(u.options.step||1)),null!=u.options.min&&u.valueu.options.max&&(u.value=u.options.max);else if(c.type==f.pointerevents_method+"down"){var m=u.options.values;m&&m.constructor===Function&&(m=u.options.values(u,a));var r=null;"number"!=u.type&&(r=m.constructor===Array?m:Object.keys(m));g=40>g?-1:g>v-40?1:0;if("number"== +u.type)u.value+=.1*g*(u.options.step||1),null!=u.options.min&&u.valueu.options.max&&(u.value=u.options.max);else if(g)q=-1,this.last_mouseclick=0,q=m.constructor===Object?r.indexOf(String(u.value))+g:r.indexOf(u.value)+g,q>=r.length&&(q=r.length-1),0>q&&(q=0),u.value=m.constructor===Array?m[q]:q;else{var z=m!=r?Object.values(m):m;new f.ContextMenu(z,{scale:Math.max(1,this.ds.scale),event:c,className:"dark",callback:function(a,b, +c){m!=r&&(a=z.indexOf(a));this.value=a;d(this,a);p.dirty_canvas=!0;return!1}.bind(u)},q)}}else c.type==f.pointerevents_method+"up"&&"number"==u.type&&(g=40>g?-1:g>v-40?1:0,200>c.click_time&&0==g&&this.prompt("Value",u.value,function(a){if(/^[0-9+\-*/()\s]+|\d+\.\d+$/.test(a))try{a=eval(a)}catch(O){}this.value=Number(a);d(this,this.value)}.bind(u),c));e!=u.value&&setTimeout(function(){d(this,this.value)}.bind(u),20);this.dirty_canvas=!0;break;case "toggle":c.type==f.pointerevents_method+"down"&&(u.value= +!u.value,setTimeout(function(){d(u,u.value)},20));break;case "string":case "text":c.type==f.pointerevents_method+"down"&&this.prompt("Value",u.value,function(a){d(this,a)}.bind(u),c,u.options?u.options.multiline:!1);break;default:u.mouse&&(this.dirty_canvas=u.mouse(c,[g,k],a))}if(e!=u.value){if(a.onWidgetChanged)a.onWidgetChanged(u.name,u.value,e,u);a.graph._version++}return u}}}return null};l.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(e),1>c&&(b.live_mode=!0));1c.pos[0]+c.size[0])c=f;if(null===e||n+p>e.pos[1]+e.size[1])e=f;if(null===d||l"+(q.label?q.label:m)+""+a+"",value:m})}if(k.length)return new f.ContextMenu(k,{event:c,callback:function(a,b,c,e){d&&(b=this.getBoundingClientRect(),g.showEditPropertyValue(d,a.value,{position:[b.left,b.top]}))},parentMenu:e,allow_html:!0, +h.filter).filter(function(b){return b.startsWith(a)}).map(function(b){if(b){b=b.replace(new RegExp("^("+a+")"),"").split("/")[0];var c=""===a?b+"/":a+b+"/";-1!=b.indexOf("::")&&(b=b.split("::")[1]);-1===e.findIndex(function(a){return a.value===c})&&e.push({value:c,content:b,has_submenu:!0,callback:function(a,b,c,d){g(a.value,d)}})}});f.getNodeTypesInCategory(a.slice(0,-1),k.filter||h.filter).map(function(a){a.skip_list||e.push({value:a.type,content:a.title,has_submenu:!1,callback:function(a,b,c,e){b= +e.getFirstEvent();k.graph.beforeChange();if(a=f.createNode(a.value))a.pos=k.convertEventToCanvasOffset(b),k.graph.add(a);d&&d(a);k.graph.afterChange()}})});new f.ContextMenu(e,{event:c,parentMenu:b},n)}var k=l.active_canvas,n=k.getCanvasWindow(),h=k.graph;if(h)return g("",e),!1};l.onMenuCollapseAll=function(){};l.onMenuNodeEdit=function(){};l.showMenuNodeOptionalInputs=function(a,b,c,e,d){if(d){var g=this;a=l.active_canvas.getCanvasWindow();b=d.optional_inputs;d.onGetInputs&&(b=d.onGetInputs());var k= +[];if(b)for(var n=0;n"+(h.label?h.label:n)+""+a+"",value:n})}if(k.length)return new f.ContextMenu(k,{event:c,callback:function(a,b,c,e){d&&(b=this.getBoundingClientRect(),g.showEditPropertyValue(d,a.value,{position:[b.left,b.top]}))},parentMenu:e,allow_html:!0, node:d},b),!1}};l.decodeHTML=function(a){var b=document.createElement("div");b.innerText=a;return b.innerHTML};l.onMenuResizeNode=function(a,b,c,e,d){if(d){a=function(a){a.size=a.computeSize();if(a.onResize)a.onResize(a.size)};b=l.active_canvas;if(!b.selected_nodes||1>=Object.keys(b.selected_nodes).length)a(d);else for(var g in b.selected_nodes)a(b.selected_nodes[g]);d.setDirtyCanvas(!0,!0)}};l.prototype.showLinkMenu=function(a,b){var c=this,e=c.graph.getNodeById(a.origin_id),d=c.graph.getNodeById(a.target_id), -g=!1;e&&e.outputs&&e.outputs[a.origin_slot]&&(g=e.outputs[a.origin_slot].type);var k=!1;d&&d.outputs&&d.outputs[a.target_slot]&&(k=d.inputs[a.target_slot].type);var m=new f.ContextMenu(["Add Node",null,"Delete",null],{event:b,title:null!=a.data?a.data.constructor.name:null,callback:function(b,f,r){switch(b){case "Add Node":l.onMenuAdd(null,null,r,m,function(b){b.inputs&&b.inputs.length&&b.outputs&&b.outputs.length&&e.connectByType(a.origin_slot,b,g)&&(b.connectByType(a.target_slot,d,k),b.pos[0]-= +g=!1;e&&e.outputs&&e.outputs[a.origin_slot]&&(g=e.outputs[a.origin_slot].type);var k=!1;d&&d.outputs&&d.outputs[a.target_slot]&&(k=d.inputs[a.target_slot].type);var n=new f.ContextMenu(["Add Node",null,"Delete",null],{event:b,title:null!=a.data?a.data.constructor.name:null,callback:function(b,f,q){switch(b){case "Add Node":l.onMenuAdd(null,null,q,n,function(b){b.inputs&&b.inputs.length&&b.outputs&&b.outputs.length&&e.connectByType(a.origin_slot,b,g)&&(b.connectByType(a.target_slot,d,k),b.pos[0]-= .5*b.size[0])});break;case "Delete":c.graph.removeLink(a.id)}}});return!1};l.prototype.createDefaultNodeForSlot=function(a){a=a||{};a=Object.assign({nodeFrom:null,slotFrom:null,nodeTo:null,slotTo:null,position:[],nodeType:null,posAdd:[0,0],posSizeFix:[0,0]},a);var b=a.nodeFrom&&null!==a.slotFrom,c=!b&&a.nodeTo&&null!==a.slotTo;if(!b&&!c)return console.warn("No data passed to createDefaultNodeForSlot "+a.nodeFrom+" "+a.slotFrom+" "+a.nodeTo+" "+a.slotTo),!1;if(!a.nodeType)return console.warn("No type to createDefaultNodeForSlot"), !1;var e=b?a.nodeFrom:a.nodeTo,d=b?a.slotFrom:a.slotTo;switch(typeof d){case "string":c=b?e.findOutputSlot(d,!1):e.findInputSlot(d,!1);d=b?e.outputs[d]:e.inputs[d];break;case "object":c=b?e.findOutputSlot(d.name):e.findInputSlot(d.name);break;case "number":c=d;d=b?e.outputs[d]:e.inputs[d];break;default:return console.warn("Cant get slot information "+d),!1}!1!==d&&!1!==c||console.warn("createDefaultNodeForSlot bad slotX "+d+" "+c);e=d.type==f.EVENT?"_event_":d.type;if((d=b?f.slot_types_default_out: f.slot_types_default_in)&&d[e]){nodeNewType=!1;if("object"==typeof d[e]||"array"==typeof d[e])for(var g in d[e]){if(a.nodeType==d[e][g]||"AUTO"==a.nodeType){nodeNewType=d[e][g];break}}else if(a.nodeType==d[e]||"AUTO"==a.nodeType)nodeNewType=d[e];if(nodeNewType){g=!1;"object"==typeof nodeNewType&&nodeNewType.node&&(g=nodeNewType,nodeNewType=nodeNewType.node);if(d=f.createNode(nodeNewType)){if(g){if(g.properties)for(var k in g.properties)d.addProperty(k,g.properties[k]);if(g.inputs)for(k in d.inputs= [],g.inputs)d.addOutput(g.inputs[k][0],g.inputs[k][1]);if(g.outputs)for(k in d.outputs=[],g.outputs)d.addOutput(g.outputs[k][0],g.outputs[k][1]);g.title&&(d.title=g.title);g.json&&d.configure(g.json)}this.graph.add(d);d.pos=[a.position[0]+a.posAdd[0]+(a.posSizeFix[0]?a.posSizeFix[0]*d.size[0]:0),a.position[1]+a.posAdd[1]+(a.posSizeFix[1]?a.posSizeFix[1]*d.size[1]:0)];b?a.nodeFrom.connectByType(c,d,e):a.nodeTo.connectByTypeOutput(c,d,e);return!0}console.log("failed creating "+nodeNewType)}}return!1}; l.prototype.showConnectionMenu=function(a){a=a||{};var b=Object.assign({nodeFrom:null,slotFrom:null,nodeTo:null,slotTo:null,e:null},a),c=this,e=b.nodeFrom&&b.slotFrom;a=!e&&b.nodeTo&&b.slotTo;if(!e&&!a)return console.warn("No data passed to showConnectionMenu"),!1;a=e?b.nodeFrom:b.nodeTo;var d=e?b.slotFrom:b.slotTo,g=!1;switch(typeof d){case "string":g=e?a.findOutputSlot(d,!1):a.findInputSlot(d,!1);d=e?a.outputs[d]:a.inputs[d];break;case "object":g=e?a.findOutputSlot(d.name):a.findInputSlot(d.name); -break;case "number":g=d;d=e?a.outputs[d]:a.inputs[d];break;default:return console.warn("Cant get slot information "+d),!1}a=["Add Node",null];c.allow_searchbox&&(a.push("Search"),a.push(null));var k=d.type==f.EVENT?"_event_":d.type,m=e?f.slot_types_default_out:f.slot_types_default_in;if(m&&m[k])if("object"==typeof m[k]||"array"==typeof m[k])for(var q in m[k])a.push(m[k][q]);else a.push(m[k]);var p=new f.ContextMenu(a,{event:b.e,title:(d&&""!=d.name?d.name+(k?" | ":""):"")+(d&&k?k:""),callback:function(a, -f,q){switch(a){case "Add Node":l.onMenuAdd(null,null,q,p,function(a){e?b.nodeFrom.connectByType(g,a,k):b.nodeTo.connectByTypeOutput(g,a,k)});break;case "Search":e?c.showSearchBox(q,{node_from:b.nodeFrom,slot_from:d,type_filter_in:k}):c.showSearchBox(q,{node_to:b.nodeTo,slot_from:d,type_filter_out:k});break;default:c.createDefaultNodeForSlot(Object.assign(b,{position:[b.e.canvasX,b.e.canvasY],nodeType:a}))}}});return!1};l.onShowPropertyEditor=function(a,b,c,e,d){function g(){if(q){var b=q.value;"Number"== -a.type?b=Number(b):"Boolean"==a.type&&(b=!!b);d[k]=b;m.parentNode&&m.parentNode.removeChild(m);d.setDirtyCanvas(!0,!0)}}var k=a.property||"title";b=d[k];var m=document.createElement("div");m.is_modified=!1;m.className="graphdialog";m.innerHTML="";m.close=function(){m.parentNode&&m.parentNode.removeChild(m)};m.querySelector(".name").innerText=k;var q=m.querySelector(".value");q&&(q.value=b,q.addEventListener("blur", -function(a){this.focus()}),q.addEventListener("keydown",function(a){m.is_modified=!0;if(27==a.keyCode)m.close();else if(13==a.keyCode)g();else if(13!=a.keyCode&&"textarea"!=a.target.localName)return;a.preventDefault();a.stopPropagation()}));b=l.active_canvas.canvas;c=b.getBoundingClientRect();var p=e=-20;c&&(e-=c.left,p-=c.top);event?(m.style.left=event.clientX+e+"px",m.style.top=event.clientY+p+"px"):(m.style.left=.5*b.width+e+"px",m.style.top=.5*b.height+p+"px");m.querySelector("button").addEventListener("click", -g);b.parentNode.appendChild(m);q&&q.focus();var r=null;m.addEventListener("mouseleave",function(a){f.dialog_close_on_mouse_leave&&!m.is_modified&&f.dialog_close_on_mouse_leave&&(r=setTimeout(m.close,f.dialog_close_on_mouse_leave_delay))});m.addEventListener("mouseenter",function(a){f.dialog_close_on_mouse_leave&&r&&clearTimeout(r)})};l.prototype.prompt=function(a,b,c,e,d){var g=this;a=a||"";var k=document.createElement("div");k.is_modified=!1;k.className="graphdialog rounded";k.innerHTML=d?" ": -" ";k.close=function(){g.prompt_box=null;k.parentNode&&k.parentNode.removeChild(k)};d=l.active_canvas.canvas;d.parentNode.appendChild(k);1";n.close=function(){n.parentNode&&n.parentNode.removeChild(n)};n.querySelector(".name").innerText=k;var h=n.querySelector(".value");h&&(h.value=b,h.addEventListener("blur", +function(a){this.focus()}),h.addEventListener("keydown",function(a){n.is_modified=!0;if(27==a.keyCode)n.close();else if(13==a.keyCode)g();else if(13!=a.keyCode&&"textarea"!=a.target.localName)return;a.preventDefault();a.stopPropagation()}));b=l.active_canvas.canvas;c=b.getBoundingClientRect();var p=e=-20;c&&(e-=c.left,p-=c.top);event?(n.style.left=event.clientX+e+"px",n.style.top=event.clientY+p+"px"):(n.style.left=.5*b.width+e+"px",n.style.top=.5*b.height+p+"px");n.querySelector("button").addEventListener("click", +g);b.parentNode.appendChild(n);h&&h.focus();var q=null;n.addEventListener("mouseleave",function(a){f.dialog_close_on_mouse_leave&&!n.is_modified&&f.dialog_close_on_mouse_leave&&(q=setTimeout(n.close,f.dialog_close_on_mouse_leave_delay))});n.addEventListener("mouseenter",function(a){f.dialog_close_on_mouse_leave&&q&&clearTimeout(q)})};l.prototype.prompt=function(a,b,c,e,d){var g=this;a=a||"";var k=document.createElement("div");k.is_modified=!1;k.className="graphdialog rounded";k.innerHTML=d?" ": +" ";k.close=function(){g.prompt_box=null;k.parentNode&&k.parentNode.removeChild(k)};d=l.active_canvas.canvas;d.parentNode.appendChild(k);1l.search_limit))break}}h=null;if(Array.prototype.filter)h=Object.keys(f.registered_node_types).filter(e);else for(q in h=[],f.registered_node_types)e(q)&&h.push(q);for(q=0;ql.search_limit);q++);if(b.show_general_after_typefiltered&&(p.value|| -r.value)){filtered_extra=[];for(q in f.registered_node_types)e(q,{inTypeOverride:p&&p.value?"*":!1,outTypeOverride:r&&r.value?"*":!1})&&filtered_extra.push(q);for(q=0;ql.search_limit);q++);}if((p.value||r.value)&&0==v.childNodes.length&&b.show_general_if_none_on_typefilter){filtered_extra=[];for(q in f.registered_node_types)e(q,{skipFilter:!0})&&filtered_extra.push(q);for(q=0;ql.search_limit);q++);}}}b=Object.assign({slot_from:null,node_from:null,node_to:null,do_type_filter:f.search_filter_enabled,type_filter_in:!1,type_filter_out:!1,show_general_if_none_on_typefilter:!0,show_general_after_typefiltered:!0,hide_on_mouse_leave:f.search_hide_on_mouse_leave,show_all_if_empty:!0,show_all_on_open:f.search_show_all_on_open},b||{});var g=this,k=l.active_canvas,m=k.canvas,q=m.ownerDocument||document,p=document.createElement("div");p.className= -"litegraph litesearchbox graphdialog rounded";p.innerHTML="Search ";b.do_type_filter&&(p.innerHTML+="",p.innerHTML+="");p.innerHTML+="
";q.fullscreenElement?q.fullscreenElement.appendChild(p):(q.body.appendChild(p),q.body.style.overflow="hidden");if(b.do_type_filter)var r= -p.querySelector(".slot_in_type_filter"),u=p.querySelector(".slot_out_type_filter");p.close=function(){g.search_box=null;this.blur();m.focus();q.body.style.overflow="";setTimeout(function(){g.canvas.focus()},20);p.parentNode&&p.parentNode.removeChild(p)};1r.height-200&&(v.style.maxHeight=r.height-a.layerY-20+"px");x.focus();b.show_all_on_open&&d();return p};l.prototype.showEditPropertyValue=function(a,b,c){function e(){d(u.value)}function d(d){g&&g.values&&g.values.constructor===Object&&void 0!=g.values[d]&&(d=g.values[d]);"number"==typeof a.properties[b]&&(d=Number(d));if("array"==f||"object"== -f)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();r.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){c=c||{};var g=a.getPropertyInfo(b),f=g.type,m="";if("string"==f||"number"==f||"array"==f||"object"==f)m="";else if("enum"!=f&&"combo"!=f||!g.values)if("boolean"==f||"toggle"==f)m="";else{console.warn("unknown type: "+f);return}else{m=""}var r=this.createDialog(""+(g.label?g.label:b)+""+m+"",c),u=!1;if("enum"!=f&&"combo"!=f||!g.values)if("boolean"==f||"toggle"==f)(u=r.querySelector("input"))&&u.addEventListener("click", -function(a){r.modified();d(!!u.checked)});else{if(u=r.querySelector("input"))u.addEventListener("blur",function(a){this.focus()}),p=void 0!==a.properties[b]?a.properties[b]:"","string"!==f&&(p=JSON.stringify(p)),u.value=p,u.addEventListener("keydown",function(a){if(27==a.keyCode)r.close();else if(13==a.keyCode)e();else if(13!=a.keyCode){r.modified();return}a.preventDefault();a.stopPropagation()})}else u=r.querySelector("select"),u.addEventListener("change",function(a){r.modified();d(a.target.value)}); -u&&u.focus();r.querySelector("button").addEventListener("click",e);return r}};l.prototype.createDialog=function(a,b){b=Object.assign({checkForInput:!1,closeOnLeave:!0,closeOnLeave_checkModified:!0},b||{});var c=document.createElement("div");c.className="graphdialog";c.innerHTML=a;c.is_modified=!1;a=this.canvas.getBoundingClientRect();var e=-20,d=-20;a&&(e-=a.left,d-=a.top);b.position?(e+=b.position[0],d+=b.position[1]):b.event?(e+=b.event.clientX,d+=b.event.clientY):(e+=.5*this.canvas.width,d+=.5* -this.canvas.height);c.style.left=e+"px";c.style.top=d+"px";this.canvas.parentNode.appendChild(c);b.checkForInput&&(a=[],(a=c.querySelectorAll("input"))&&a.forEach(function(a){a.addEventListener("keydown",function(a){c.modified();if(27==a.keyCode)c.close();else if(13!=a.keyCode)return;a.preventDefault();a.stopPropagation()});a.focus()}));c.modified=function(){c.is_modified=!0};c.close=function(){c.parentNode&&c.parentNode.removeChild(c)};var g=null,k=!1;c.addEventListener("mouseleave",function(a){k|| +y;y&&y.classList.remove("selected");y?(y=a?y.nextSibling:y.previousSibling)||(y=b):y=a?v.childNodes[0]:v.childNodes[v.childNodes.length];y&&(y.classList.add("selected"),y.scrollIntoView({block:"end",behavior:"smooth"}))}function d(){function a(a,b){var d=document.createElement("div");r||(r=a);d.innerText=a;d.dataset.type=escape(a);d.className="litegraph lite-search-item";b&&(d.className+=" "+b);d.addEventListener("click",function(a){c(unescape(this.dataset.type))});v.appendChild(d)}z=null;var d=w.value; +r=null;v.innerHTML="";if(d||b.show_all_if_empty)if(g.onSearchBox){var e=g.onSearchBox(v,d,k);if(e)for(var p=0;pl.search_limit))break}}u=null;if(Array.prototype.filter)u=Object.keys(f.registered_node_types).filter(e);else for(p in u=[],f.registered_node_types)e(p)&&u.push(p);for(p=0;pl.search_limit);p++);if(b.show_general_after_typefiltered&&(n.value|| +h.value)){filtered_extra=[];for(p in f.registered_node_types)e(p,{inTypeOverride:n&&n.value?"*":!1,outTypeOverride:h&&h.value?"*":!1})&&filtered_extra.push(p);for(p=0;pl.search_limit);p++);}if((n.value||h.value)&&0==v.childNodes.length&&b.show_general_if_none_on_typefilter){filtered_extra=[];for(p in f.registered_node_types)e(p,{skipFilter:!0})&&filtered_extra.push(p);for(p=0;pl.search_limit);p++);}}}b=Object.assign({slot_from:null,node_from:null,node_to:null,do_type_filter:f.search_filter_enabled,type_filter_in:!1,type_filter_out:!1,show_general_if_none_on_typefilter:!0,show_general_after_typefiltered:!0,hide_on_mouse_leave:f.search_hide_on_mouse_leave,show_all_if_empty:!0,show_all_on_open:f.search_show_all_on_open},b||{});var g=this,k=l.active_canvas,n=k.canvas,h=n.ownerDocument||document,p=document.createElement("div");p.className= +"litegraph litesearchbox graphdialog rounded";p.innerHTML="Search ";b.do_type_filter&&(p.innerHTML+="",p.innerHTML+="");p.innerHTML+="
";h.fullscreenElement?h.fullscreenElement.appendChild(p):(h.body.appendChild(p),h.body.style.overflow="hidden");if(b.do_type_filter)var q= +p.querySelector(".slot_in_type_filter"),x=p.querySelector(".slot_out_type_filter");p.close=function(){g.search_box=null;this.blur();n.focus();h.body.style.overflow="";setTimeout(function(){g.canvas.focus()},20);p.parentNode&&p.parentNode.removeChild(p)};1q.height-200&&(v.style.maxHeight=q.height-a.layerY-20+"px");w.focus();b.show_all_on_open&&d();return p};l.prototype.showEditPropertyValue=function(a,b,c){function e(){d(x.value)}function d(d){g&&g.values&&g.values.constructor===Object&&void 0!=g.values[d]&&(d=g.values[d]);"number"==typeof a.properties[b]&& +(d=Number(d));if("array"==f||"object"==f)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();q.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){c=c||{};var g=a.getPropertyInfo(b),f=g.type,n="";if("string"==f||"number"==f||"array"==f||"object"==f)n="";else if("enum"!=f&&"combo"!=f||!g.values)if("boolean"==f||"toggle"==f)n="";else{console.warn("unknown type: "+f);return}else{n=""}var q=this.createDialog(""+(g.label?g.label:b)+""+n+"",c),x=!1;if("enum"!=f&&"combo"!=f||!g.values)if("boolean"==f||"toggle"==f)(x=q.querySelector("input"))&& +x.addEventListener("click",function(a){q.modified();d(!!x.checked)});else{if(x=q.querySelector("input"))x.addEventListener("blur",function(a){this.focus()}),p=void 0!==a.properties[b]?a.properties[b]:"","string"!==f&&(p=JSON.stringify(p)),x.value=p,x.addEventListener("keydown",function(a){if(27==a.keyCode)q.close();else if(13==a.keyCode)e();else if(13!=a.keyCode){q.modified();return}a.preventDefault();a.stopPropagation()})}else x=q.querySelector("select"),x.addEventListener("change",function(a){q.modified(); +d(a.target.value)});x&&x.focus();q.querySelector("button").addEventListener("click",e);return q}};l.prototype.createDialog=function(a,b){b=Object.assign({checkForInput:!1,closeOnLeave:!0,closeOnLeave_checkModified:!0},b||{});var c=document.createElement("div");c.className="graphdialog";c.innerHTML=a;c.is_modified=!1;a=this.canvas.getBoundingClientRect();var e=-20,d=-20;a&&(e-=a.left,d-=a.top);b.position?(e+=b.position[0],d+=b.position[1]):b.event?(e+=b.event.clientX,d+=b.event.clientY):(e+=.5*this.canvas.width, +d+=.5*this.canvas.height);c.style.left=e+"px";c.style.top=d+"px";this.canvas.parentNode.appendChild(c);b.checkForInput&&(a=[],(a=c.querySelectorAll("input"))&&a.forEach(function(a){a.addEventListener("keydown",function(a){c.modified();if(27==a.keyCode)c.close();else if(13!=a.keyCode)return;a.preventDefault();a.stopPropagation()});a.focus()}));c.modified=function(){c.is_modified=!0};c.close=function(){c.parentNode&&c.parentNode.removeChild(c)};var g=null,k=!1;c.addEventListener("mouseleave",function(a){k|| (b.closeOnLeave||f.dialog_close_on_mouse_leave)&&!c.is_modified&&f.dialog_close_on_mouse_leave&&(g=setTimeout(c.close,f.dialog_close_on_mouse_leave_delay))});c.addEventListener("mouseenter",function(a){(b.closeOnLeave||f.dialog_close_on_mouse_leave)&&g&&clearTimeout(g)});(a=c.querySelectorAll("select"))&&a.forEach(function(a){a.addEventListener("click",function(a){k++});a.addEventListener("blur",function(a){k=0});a.addEventListener("change",function(a){k=-1})});return c};l.prototype.createPanel=function(a, b){b=b||{};var c=b.window||window,e=document.createElement("div");e.className="litegraph dialog";e.innerHTML="
";e.header=e.querySelector(".dialog-header");b.width&&(e.style.width=b.width+(b.width.constructor===Number?"px":""));b.height&&(e.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(){e.close()}),e.header.appendChild(b));e.title_element=e.querySelector(".dialog-title");e.title_element.innerText=a;e.content=e.querySelector(".dialog-content");e.alt_content=e.querySelector(".dialog-alt-content");e.footer=e.querySelector(".dialog-footer");e.close=function(){if(e.onClose&&"function"==typeof e.onClose)e.onClose();e.parentNode&&e.parentNode.removeChild(e);this.parentNode&& this.parentNode.removeChild(this)};e.toggleAltContent=function(a){if("undefined"!=typeof a){var b=a?"block":"none";a=a?"none":"block"}else b="block"!=e.alt_content.style.display?"block":"none",a="block"!=e.alt_content.style.display?"none":"block";e.alt_content.style.display=b;e.content.style.display=a};e.toggleFooterVisibility=function(a){e.footer.style.display="undefined"!=typeof a?a?"block":"none":"block"!=e.footer.style.display?"block":"none"};e.clear=function(){this.content.innerHTML=""};e.addHTML= -function(a,b,c){var d=document.createElement("div");b&&(d.className=b);d.innerHTML=a;c?e.footer.appendChild(d):e.content.appendChild(d);return d};e.addButton=function(a,b,c){var d=document.createElement("button");d.innerText=a;d.options=c;d.classList.add("btn");d.addEventListener("click",b);e.footer.appendChild(d);return d};e.addSeparator=function(){var a=document.createElement("div");a.className="separator";e.content.appendChild(a)};e.addWidget=function(a,b,k,m,q){function d(a,b){m.callback&&m.callback(a, -b,m);q&&q(a,b,m)}m=m||{};var g=String(k);a=a.toLowerCase();"number"==a&&(g=k.toFixed(3));var u=document.createElement("div");u.className="property";u.innerHTML="";u.querySelector(".property_name").innerText=m.label||b;var h=u.querySelector(".property_value");h.innerText=g;u.dataset.property=b;u.dataset.type=m.type||a;u.options=m;u.value=k;if("code"==a)u.addEventListener("click",function(a){e.inner_showCodePad(this.dataset.property)}); -else if("boolean"==a)u.classList.add("boolean"),k&&u.classList.add("bool-on"),u.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";d(a,this.value)});else if("string"==a||"number"==a)h.setAttribute("contenteditable",!0),h.addEventListener("keydown",function(b){"Enter"!=b.code||"string"==a&&b.shiftKey||(b.preventDefault(),this.blur())}),h.addEventListener("blur", -function(){var a=this.innerText,b=this.parentNode.dataset.property;"number"==this.parentNode.dataset.type&&(a=Number(a));d(b,a)});else if("enum"==a||"combo"==a)g=l.getPropertyPrintableValue(k,m.values),h.innerText=g,h.addEventListener("click",function(a){var b=this.parentNode.dataset.property,e=this;new f.ContextMenu(m.values||[],{event:a,className:"dark",callback:function(a,c,f){e.innerText=a;d(b,a);return!1}},c)});e.content.appendChild(u);return u};if(e.onOpen&&"function"==typeof e.onOpen)e.onOpen(); +function(a,b,c){var d=document.createElement("div");b&&(d.className=b);d.innerHTML=a;c?e.footer.appendChild(d):e.content.appendChild(d);return d};e.addButton=function(a,b,c){var d=document.createElement("button");d.innerText=a;d.options=c;d.classList.add("btn");d.addEventListener("click",b);e.footer.appendChild(d);return d};e.addSeparator=function(){var a=document.createElement("div");a.className="separator";e.content.appendChild(a)};e.addWidget=function(a,b,k,n,h){function d(a,b){n.callback&&n.callback(a, +b,n);h&&h(a,b,n)}n=n||{};var g=String(k);a=a.toLowerCase();"number"==a&&(g=k.toFixed(3));var x=document.createElement("div");x.className="property";x.innerHTML="";x.querySelector(".property_name").innerText=n.label||b;var u=x.querySelector(".property_value");u.innerText=g;x.dataset.property=b;x.dataset.type=n.type||a;x.options=n;x.value=k;if("code"==a)x.addEventListener("click",function(a){e.inner_showCodePad(this.dataset.property)}); +else if("boolean"==a)x.classList.add("boolean"),k&&x.classList.add("bool-on"),x.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";d(a,this.value)});else if("string"==a||"number"==a)u.setAttribute("contenteditable",!0),u.addEventListener("keydown",function(b){"Enter"!=b.code||"string"==a&&b.shiftKey||(b.preventDefault(),this.blur())}),u.addEventListener("blur", +function(){var a=this.innerText,b=this.parentNode.dataset.property;"number"==this.parentNode.dataset.type&&(a=Number(a));d(b,a)});else if("enum"==a||"combo"==a)g=l.getPropertyPrintableValue(k,n.values),u.innerText=g,u.addEventListener("click",function(a){var b=this.parentNode.dataset.property,e=this;new f.ContextMenu(n.values||[],{event:a,className:"dark",callback:function(a,c,f){e.innerText=a;d(b,a);return!1}},c)});e.content.appendChild(x);return x};if(e.onOpen&&"function"==typeof e.onOpen)e.onOpen(); return e};l.getPropertyPrintableValue=function(a,b){if(!b||b.constructor===Array)return String(a);if(b.constructor===Object){var c="",e;for(e in b)if(b[e]==a){c=e;break}return String(a)+" ("+c+")"}};l.prototype.closePanels=function(){var a=document.querySelector("#node-panel");a&&a.close();(a=document.querySelector("#option-panel"))&&a.close()};l.prototype.showShowGraphOptionsPanel=function(a,b,c,e){if(this.constructor&&"HTMLDivElement"==this.constructor.name){if(!(b&&b.event&&b.event.target&&b.event.target.lgraphcanvas)){console.warn("Canvas not found"); return}var d=b.event.target.lgraphcanvas}else d=this;d.closePanels();a=d.getCanvasWindow();panel=d.createPanel("Options",{closable:!0,window:a,onOpen:function(){d.OPTIONPANEL_IS_OPEN=!0},onClose:function(){d.OPTIONPANEL_IS_OPEN=!1;d.options_panel=null}});d.options_panel=panel;panel.id="option-panel";panel.classList.add("settings");(function(){panel.content.innerHTML="";var a=function(a,b,c){c&&c.key&&(a=c.key);c.values&&(b=Object.values(c.values).indexOf(b));d[a]=b},b=f.availableCanvasOptions;b.sort(); for(var c in b){var e=b[c];panel.addWidget("boolean",e,d[e],{key:e,on:"True",off:"False"},a)}panel.addWidget("combo","Render mode",f.LINK_RENDER_MODES[d.links_render_mode],{key:"links_render_mode",values:f.LINK_RENDER_MODES},a);panel.addSeparator();panel.footer.innerHTML=""})();d.canvas.parentNode.appendChild(panel)};l.prototype.showShowNodePanel=function(a){function b(){d.content.innerHTML="";d.addHTML(""+a.type+""+(a.constructor.desc||"")+""); d.addHTML("

Properties

");var b=function(b,c){e.graph.beforeChange(a);switch(b){case "Title":a.title=c;break;case "Mode":b=Object.values(f.NODE_MODES).indexOf(c);0<=b&&f.NODE_MODES[b]?a.changeMode(b):console.warn("unexpected mode: "+c);break;case "Color":l.node_colors[c]?(a.color=l.node_colors[c].color,a.bgcolor=l.node_colors[c].bgcolor):console.warn("unexpected color: "+c);break;default:a.setProperty(b,c)}e.graph.afterChange();e.dirty_canvas=!0};d.addWidget("string","Title",a.title,{},b); -d.addWidget("combo","Mode",f.NODE_MODES[a.mode],{values:f.NODE_MODES},b);var c="";void 0!==a.color&&(c=Object.keys(l.node_colors).filter(function(b){return l.node_colors[b].color==a.color}));d.addWidget("combo","Color",c,{values:Object.keys(l.node_colors)},b);for(var m in a.properties){c=a.properties[m];var q=a.getPropertyInfo(m);a.onAddPropertyToPanel&&a.onAddPropertyToPanel(m,d)||d.addWidget(q.widget||q.type,m,c,q,b)}d.addSeparator();if(a.onShowCustomPanelInfo)a.onShowCustomPanelInfo(d);d.footer.innerHTML= +d.addWidget("combo","Mode",f.NODE_MODES[a.mode],{values:f.NODE_MODES},b);var c="";void 0!==a.color&&(c=Object.keys(l.node_colors).filter(function(b){return l.node_colors[b].color==a.color}));d.addWidget("combo","Color",c,{values:Object.keys(l.node_colors)},b);for(var n in a.properties){c=a.properties[n];var h=a.getPropertyInfo(n);a.onAddPropertyToPanel&&a.onAddPropertyToPanel(n,d)||d.addWidget(h.widget||h.type,n,c,h,b)}d.addSeparator();if(a.onShowCustomPanelInfo)a.onShowCustomPanelInfo(d);d.footer.innerHTML= "";d.addButton("Delete",function(){a.block_delete||(a.graph.remove(a),d.close())}).classList.add("delete")}this.SELECTED_NODE=a;this.closePanels();var c=this.getCanvasWindow(),e=this,d=this.createPanel(a.title||"",{closable:!0,window:c,onOpen:function(){e.NODEPANEL_IS_OPEN=!0},onClose:function(){e.NODEPANEL_IS_OPEN=!1;e.node_panel=null}});e.node_panel=d;d.id="node-panel";d.node=a;d.classList.add("settings");d.inner_showCodePad=function(c){d.classList.remove("settings");d.classList.add("centered"); d.alt_content.innerHTML="";var e=d.alt_content.querySelector("textarea"),f=function(){d.toggleAltContent(!1);d.toggleFooterVisibility(!0);e.parentNode.removeChild(e);d.classList.add("settings");d.classList.remove("centered");b()};e.value=a.properties[c];e.addEventListener("keydown",function(b){"Enter"==b.code&&b.ctrlKey&&(a.setProperty(c,e.value),f())});d.toggleAltContent(!0);d.toggleFooterVisibility(!1);e.style.height="calc(100% - 40px)";var g=d.addButton("Assign", function(){a.setProperty(c,e.value);f()});d.alt_content.appendChild(g);g=d.addButton("Close",f);g.style.float="right";d.alt_content.appendChild(g)};b();this.canvas.parentNode.appendChild(d)};l.prototype.showSubgraphPropertiesDialog=function(a){function b(){e.clear();if(a.inputs)for(var c=0;c","subgraph_property"); @@ -332,161 +332,164 @@ null,{content:"Properties",has_submenu:!0,callback:l.onShowMenuNodeProperties},n a.onGetInputs();c&&c.length&&(b[0].disabled=!1)}a.onGetOutputs&&(c=a.onGetOutputs())&&c.length&&(b[1].disabled=!1);a.getExtraMenuOptions&&(c=a.getExtraMenuOptions(this,b))&&(c.push(null),b=c.concat(b));!1!==a.clonable&&b.push({content:"Clone",callback:l.onMenuNodeClone});1Name", -d),q=g.querySelector("input");q&&f&&(q.value=f.label||"");var p=function(){a.graph.beforeChange();q.value&&(f&&(f.label=q.value),c.setDirty(!0));g.close();a.graph.afterChange()};g.querySelector("button").addEventListener("click",p);q.addEventListener("keydown",function(a){g.is_modified=!0;if(27==a.keyCode)g.close();else if(13==a.keyCode)p();else if(13!=a.keyCode&&"textarea"!=a.target.localName)return;a.preventDefault();a.stopPropagation()});q.focus()}},extra:a};a&&(g.title=a.type);var k=null;a&&(k= +d),p=g.querySelector("input");p&&f&&(p.value=f.label||"");var k=function(){a.graph.beforeChange();p.value&&(f&&(f.label=p.value),c.setDirty(!0));g.close();a.graph.afterChange()};g.querySelector("button").addEventListener("click",k);p.addEventListener("keydown",function(a){g.is_modified=!0;if(27==a.keyCode)g.close();else if(13==a.keyCode)k();else if(13!=a.keyCode&&"textarea"!=a.target.localName)return;a.preventDefault();a.stopPropagation()});p.focus()}},extra:a};a&&(g.title=a.type);var k=null;a&&(k= a.getSlotInPosition(b.canvasX,b.canvasY),l.active_node=a);k?(d=[],a.getSlotMenuOptions?d=a.getSlotMenuOptions(k):(k&&k.output&&k.output.links&&k.output.links.length&&d.push({content:"Disconnect Links",slot:k}),b=k.input||k.output,b.removable&&d.push(b.locked?"Cannot remove":{content:"Remove Slot",slot:k}),b.nameLocked||d.push({content:"Rename Slot",slot:k})),g.title=(k.input?k.input.type:k.output.type)||"*",k.input&&k.input.type==f.ACTION&&(g.title="Action"),k.output&&k.output.type==f.EVENT&&(g.title= -"Event")):a?d=this.getNodeMenuOptions(a):(d=this.getCanvasMenuOptions(),(k=this.graph.getGroupOnPos(b.canvasX,b.canvasY))&&d.push(null,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:k,options:this.getGroupMenuOptions(k)}}));d&&new f.ContextMenu(d,g,e)};f.compareObjects=function(a,b){for(var c in a)if(a[c]!=b[c])return!1;return!0};f.distance=E;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=B;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[1][0]||a[1]>b[1][1]?!1:!0};f.overlapBounding=z;f.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),c=0,e,d,f=0;6>f;f+=2)e="0123456789ABCDEF".indexOf(a.charAt(f)),d="0123456789ABCDEF".indexOf(a.charAt(f+1)),b[c]=16*e+d,c++;return b}; -f.num2hex=function(a){for(var b="#",c,e,d=0;3>d;d++)c=a[d]/16,e=a[d]%16,b+="0123456789ABCDEF".charAt(c)+"0123456789ABCDEF".charAt(e);return b};F.prototype.addItem=function(a,b,c){function e(a){var b=this.value;b&&b.has_submenu&&d.call(this,a)}function d(a){var b=this.value,d=!0;g.current_submenu&&g.current_submenu.close(a);if(c.callback){var e=c.callback.call(this,b,c,a,g,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,g,c.extra), -!0===e&&(d=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";new g.constructor(b.submenu.options,{callback:b.submenu.callback,event:a,parentMenu:g,ignore_item_callbacks:b.submenu.ignore_item_callbacks,title:b.submenu.title,extra:b.submenu.extra,autoopen:c.autoopen});d=!1}d&&!g.lock&&g.close()}var g=this;c=c||{};var k=document.createElement("div");k.className="litemenu-entry submenu";var m=!1;if(null===b)k.classList.add("separator");else{k.innerHTML=b&&b.title?b.title: -a;if(k.value=b)b.disabled&&(m=!0,k.classList.add("disabled")),(b.submenu||b.has_submenu)&&k.classList.add("has_submenu");"function"==typeof b?(k.dataset.value=a,k.onclick_callback=b):k.dataset.value=b;b.className&&(k.className+=" "+b.className)}this.root.appendChild(k);m||k.addEventListener("click",d);!m&&c.autoopen&&f.pointerListenerAdd(k,"enter",e);return k};F.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&&!F.isCursorOverElement(a,this.parentMenu.root)&&F.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)};F.trigger=function(a,b,c,e){var d=document.createEvent("CustomEvent");d.initCustomEvent(b,!0,!0,c);d.srcElement=e;a.dispatchEvent?a.dispatchEvent(d):a.__events&&a.__events.dispatchEvent(d);return d}; -F.prototype.getTopMenu=function(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this};F.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event};F.isCursorOverElement=function(a,b){var c=a.clientX;a=a.clientY;return(b=b.getBoundingClientRect())?a>b.top&&ab.left&&ca[2]&&(a[2]=b);ca[3]&&(a[3]=c)};f.isInsideBounding=function(a,b){return a[0]b[1][0]||a[1]>b[1][1]?!1:!0};f.overlapBounding=D;f.hex2num=function(a){"#"==a.charAt(0)&&(a=a.slice(1));a=a.toUpperCase();for(var b=Array(3),c=0,e,d,f=0;6>f;f+=2)e="0123456789ABCDEF".indexOf(a.charAt(f)),d="0123456789ABCDEF".indexOf(a.charAt(f+1)),b[c]=16*e+d,c++;return b}; +f.num2hex=function(a){for(var b="#",c,e,d=0;3>d;d++)c=a[d]/16,e=a[d]%16,b+="0123456789ABCDEF".charAt(c)+"0123456789ABCDEF".charAt(e);return b};G.prototype.addItem=function(a,b,c){function e(a){var b=this.value;b&&b.has_submenu&&d.call(this,a)}function d(a){var b=this.value,d=!0;g.current_submenu&&g.current_submenu.close(a);if(c.callback){var e=c.callback.call(this,b,c,a,g,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,g,c.extra), +!0===e&&(d=!1)),b.submenu)){if(!b.submenu.options)throw"ContextMenu submenu needs options";new g.constructor(b.submenu.options,{callback:b.submenu.callback,event:a,parentMenu:g,ignore_item_callbacks:b.submenu.ignore_item_callbacks,title:b.submenu.title,extra:b.submenu.extra,autoopen:c.autoopen});d=!1}d&&!g.lock&&g.close()}var g=this;c=c||{};var k=document.createElement("div");k.className="litemenu-entry submenu";var h=!1;if(null===b)k.classList.add("separator");else{k.innerHTML=b&&b.title?b.title: +a;if(k.value=b)b.disabled&&(h=!0,k.classList.add("disabled")),(b.submenu||b.has_submenu)&&k.classList.add("has_submenu");"function"==typeof b?(k.dataset.value=a,k.onclick_callback=b):k.dataset.value=b;b.className&&(k.className+=" "+b.className)}this.root.appendChild(k);h||k.addEventListener("click",d);!h&&c.autoopen&&f.pointerListenerAdd(k,"enter",e);return k};G.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&&!G.isCursorOverElement(a,this.parentMenu.root)&&G.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)};G.trigger=function(a,b,c,e){var d=document.createEvent("CustomEvent");d.initCustomEvent(b,!0,!0,c);d.srcElement=e;a.dispatchEvent?a.dispatchEvent(d):a.__events&&a.__events.dispatchEvent(d);return d}; +G.prototype.getTopMenu=function(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this};G.prototype.getFirstEvent=function(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event};G.isCursorOverElement=function(a,b){var c=a.clientX;a=a.clientY;return(b=b.getBoundingClientRect())?a>b.top&&ab.left&&cMath.abs(b))return e[1];a=(a-e[0])/b;return e[1]*(1-a)+d[1]*a}}return 0}};G.prototype.draw=function(a,b,c,e,d,f){if(c=this.points){this.size=b;var g=b[0]-2*this.margin;b=b[1]-2*this.margin;d=d||"#666";a.save();a.translate(this.margin,this.margin);e&&(a.fillStyle="#111",a.fillRect(0,0,g,b),a.fillStyle="#222",a.fillRect(.5*g,0,1,b),a.strokeStyle="#333", -a.strokeRect(0,0,g,b));a.strokeStyle=d;f&&(a.globalAlpha=.5);a.beginPath();for(e=0;ea[1])){var e=this.size[0]-2*this.margin,d=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/e,1-a/d],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}};G.prototype.onMouseMove=function(a,b){var c=this.points;if(c){var e=this.selected;if(!(0>e)){var d=(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[e]){var k=0==e||e==c.length-1;!k&&(-10>a[0]||a[0]>this.size[0]+10||-10>a[1]||a[1]>this.size[1]+10)?(c.splice(e,1),this.selected=-1):(b[0]=k?0==e?0:1:J(d,0,1),b[1]=1-J(f,0,1),c.sort(function(a,b){return a[0]-b[0]}),this.selected=c.indexOf(b),this.must_update=!0)}}}};G.prototype.onMouseUp=function(a,b){this.selected=-1;return!1};G.prototype.getCloserPoint=function(a,b){var c=this.points;if(!c)return-1;b=b||30;for(var e=this.size[0]-2*this.margin,d=this.size[1]-2*this.margin,f=c.length,k=[0,0], -m=1E6,q=-1,p=0;pm||h>b||(q=p,m=h)}return q};f.CurveEditor=G;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,e){e=void 0===e?!1:e;if(a&&a.addEventListener&&b&&"function"===typeof c){var d=f.pointerevents_method;if("pointer"==d&&!window.PointerEvent)switch(console.warn("sMethod=='pointer' && !window.PointerEvent"), +b.prototype.__lookupSetter__(c)))};H.sampleCurve=function(a,b){if(b){for(var c=0;cMath.abs(b))return e[1];a=(a-e[0])/b;return e[1]*(1-a)+d[1]*a}}return 0}};H.prototype.draw=function(a,b,c,e,d,f){if(c=this.points){this.size=b;var g=b[0]-2*this.margin;b=b[1]-2*this.margin;d=d||"#666";a.save();a.translate(this.margin,this.margin);e&&(a.fillStyle="#111",a.fillRect(0,0,g,b),a.fillStyle="#222",a.fillRect(.5*g,0,1,b),a.strokeStyle="#333", +a.strokeRect(0,0,g,b));a.strokeStyle=d;f&&(a.globalAlpha=.5);a.beginPath();for(e=0;ea[1])){var e=this.size[0]-2*this.margin,d=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/e,1-a/d],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}};H.prototype.onMouseMove=function(a,b){var c=this.points;if(c){var e=this.selected;if(!(0>e)){var d=(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[e]){var k=0==e||e==c.length-1;!k&&(-10>a[0]||a[0]>this.size[0]+10||-10>a[1]||a[1]>this.size[1]+10)?(c.splice(e,1),this.selected=-1):(b[0]=k?0==e?0:1:I(d,0,1),b[1]=1-I(f,0,1),c.sort(function(a,b){return a[0]-b[0]}),this.selected=c.indexOf(b),this.must_update=!0)}}}};H.prototype.onMouseUp=function(a,b){this.selected=-1;return!1};H.prototype.getCloserPoint=function(a,b){var c=this.points;if(!c)return-1;b=b||30;for(var e=this.size[0]-2*this.margin,d=this.size[1]-2*this.margin,f=c.length,k=[0,0], +h=1E6,l=-1,p=0;ph||q>b||(l=p,h=q)}return l};f.CurveEditor=H;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,e){e=void 0===e?!1:e;if(a&&a.addEventListener&&b&&"function"===typeof c){var d=f.pointerevents_method;if("pointer"==d&&!window.PointerEvent)switch(console.warn("sMethod=='pointer' && !window.PointerEvent"), console.log("Converting pointer["+b+"] : down move up cancel enter TO touchstart touchmove touchend, etc .."),b){case "down":d="touch";b="start";break;case "move":d="touch";break;case "up":d="touch";b="end";break;case "cancel":d="touch";break;case "enter":console.log("debug: Should I send a move event?");break;default:console.warn("PointerEvent not available in this browser ? The event "+b+" would not be called")}switch(b){case "down":case "up":case "move":case "over":case "out":case "enter":a.addEventListener(d+ b,c,e);case "leave":case "cancel":case "gotpointercapture":case "lostpointercapture":if("mouse"!=d)return a.addEventListener(d+b,c,e);default:return a.addEventListener(b,c,e)}}};f.pointerListenerRemove=function(a,b,c,e){e=void 0===e?!1:e;if(a&&a.removeEventListener&&b&&"function"===typeof c)switch(b){case "down":case "up":case "move":case "over":case "out":case "enter":"pointer"!=f.pointerevents_method&&"mouse"!=f.pointerevents_method||a.removeEventListener(f.pointerevents_method+b,c,e);case "leave":case "cancel":case "gotpointercapture":case "lostpointercapture":if("pointer"== -f.pointerevents_method)return a.removeEventListener(f.pointerevents_method+b,c,e);default:return a.removeEventListener(b,c,e)}};x.clamp=J;"undefined"==typeof window||window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)})})(this); +f.pointerevents_method)return a.removeEventListener(f.pointerevents_method+b,c,e);default:return a.removeEventListener(b,c,e)}};w.clamp=I;"undefined"==typeof window||window.requestAnimationFrame||(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)})})(this); "undefined"!=typeof exports&&(exports.LiteGraph=this.LiteGraph,exports.LGraph=this.LGraph,exports.LLink=this.LLink,exports.LGraphNode=this.LGraphNode,exports.LGraphGroup=this.LGraphGroup,exports.DragAndScale=this.DragAndScale,exports.LGraphCanvas=this.LGraphCanvas,exports.ContextMenu=this.ContextMenu); -(function(x){function n(){this.addOutput("in ms","number");this.addOutput("in sec","number")}function t(){this.size=[140,80];this.properties={enabled:!0};this.enabled=!0;this.subgraph=new m.LGraph;this.subgraph._subgraph_node=this;this.subgraph._is_subgraph=!0;this.subgraph.onTrigger=this.onSubgraphTrigger.bind(this);this.subgraph.onInputAdded=this.onSubgraphNewInput.bind(this);this.subgraph.onInputRenamed=this.onSubgraphRenamedInput.bind(this);this.subgraph.onInputTypeChanged=this.onSubgraphTypeChangeInput.bind(this); +(function(w){function m(){this.addOutput("in ms","number");this.addOutput("in sec","number")}function r(){this.size=[140,80];this.properties={enabled:!0};this.enabled=!0;this.subgraph=new t.LGraph;this.subgraph._subgraph_node=this;this.subgraph._is_subgraph=!0;this.subgraph.onTrigger=this.onSubgraphTrigger.bind(this);this.subgraph.onInputAdded=this.onSubgraphNewInput.bind(this);this.subgraph.onInputRenamed=this.onSubgraphRenamedInput.bind(this);this.subgraph.onInputTypeChanged=this.onSubgraphTypeChangeInput.bind(this); this.subgraph.onInputRemoved=this.onSubgraphRemovedInput.bind(this);this.subgraph.onOutputAdded=this.onSubgraphNewOutput.bind(this);this.subgraph.onOutputRenamed=this.onSubgraphRenamedOutput.bind(this);this.subgraph.onOutputTypeChanged=this.onSubgraphTypeChangeOutput.bind(this);this.subgraph.onOutputRemoved=this.onSubgraphRemovedOutput.bind(this)}function h(){this.addOutput("","number");this.name_in_graph="";this.properties={name:"",type:"number",value:0};var a=this;this.name_widget=this.addWidget("text", -"Name",this.properties.name,function(b){b&&a.setProperty("name",b)});this.type_widget=this.addWidget("text","Type",this.properties.type,function(b){a.setProperty("type",b)});this.value_widget=this.addWidget("number","Value",this.properties.value,function(b){a.setProperty("value",b)});this.widgets_up=!0;this.size=[180,90]}function w(){this.addInput("","");this.name_in_graph="";this.properties={name:"",type:""};this.name_widget=this.addWidget("text","Name",this.properties.name,"name");this.type_widget= -this.addWidget("text","Type",this.properties.type,"type");this.widgets_up=!0;this.size=[180,60]}function y(){this.addOutput("value","number");this.addProperty("value",1);this.widget=this.addWidget("number","value",1,"value");this.widgets_up=!0;this.size=[180,30]}function l(){this.addOutput("bool","boolean");this.addProperty("value",!0);this.widget=this.addWidget("toggle","value",!0,"value");this.widgets_up=this.serialize_widgets=!0;this.size=[140,30]}function E(){this.addOutput("string","string"); -this.addProperty("value","");this.widget=this.addWidget("text","value","","value");this.widgets_up=!0;this.size=[180,30]}function B(){this.addOutput("obj","object");this.size=[120,30];this._object={}}function z(){this.addInput("url","string");this.addOutput("file","string");this.addProperty("url","");this.addProperty("type","text");this.widget=this.addWidget("text","url","","url");this._data=null}function F(){this.addOutput("data","object");this.addProperty("value","");this.widget=this.addWidget("text", -"json","","value");this.widgets_up=!0;this.size=[140,30];this._value=null}function G(){this._value=[];this.addInput("json","");this.addOutput("arrayOut","array");this.addOutput("length","number");this.addProperty("value","[]");this.widget=this.addWidget("text","array",this.properties.value,"value");this.widgets_up=!0;this.size=[140,50]}function J(){this.addInput("arr","array");this.addInput("value","");this.addOutput("arr","array");this.properties={index:0};this.widget=this.addWidget("number","i", -this.properties.index,"index",{precision:0,step:10,min:0})}function f(){this.addInput("array","array,table,string");this.addInput("index","number");this.addOutput("value","");this.addProperty("index",0)}function L(){this.addInput("table","table");this.addInput("row","number");this.addInput("col","number");this.addOutput("value","");this.addProperty("row",0);this.addProperty("column",0)}function D(){this.addInput("obj","object");this.addOutput("property",0);this.addProperty("value",0);this.widget= -this.addWidget("text","prop.","",this.setValue.bind(this));this.widgets_up=!0;this.size=[140,30];this._value=null}function A(){this.addInput("obj","");this.addOutput("keys","array");this.size=[140,30]}function M(){this.addInput("obj","");this.addInput("value","");this.addOutput("obj","");this.properties={property:""};this.name_widget=this.addWidget("text","prop.",this.properties.property,"property")}function C(){this.addInput("A","object");this.addInput("B","object");this.addOutput("out","object"); -this._result={};var a=this;this.addWidget("button","clear","",function(){a._result={}});this.size=this.computeSize()}function H(){this.size=[60,30];this.addInput("in");this.addOutput("out");this.properties={varname:"myname",container:H.LITEGRAPH};this.value=null}function N(a){return a&&null!=a.length?Number(a.length):0}function N(a){return a&&null!=a.length?Number(a.length):0}function a(){this.size=[60,30];this.addInput("data",0);this.addInput("download",m.ACTION);this.properties={filename:"data.json"}; -this.value=null;var a=this;this.addWidget("button","Download","",function(b){a.value&&a.downloadAsFile()})}function b(){this.size=[60,30];this.addInput("value",0,{label:""});this.value=0}function c(){this.addInput("in",0);this.addOutput("out",0);this.size=[40,30]}function e(){this.mode=m.ON_EVENT;this.size=[80,30];this.addProperty("msg","");this.addInput("log",m.EVENT);this.addInput("msg",0)}function d(){this.mode=m.ON_EVENT;this.addProperty("msg","");this.addInput("",m.EVENT);this.widget=this.addWidget("text", -"Text","","msg");this.widgets_up=!0;this.size=[200,30]}function g(){this.size=[60,30];this.addProperty("onExecute","return A;");this.addInput("A",0);this.addInput("B",0);this.addOutput("out",0);this._func=null;this.data={}}function k(){this.addInput("A",0);this.addInput("B",0);this.addOutput("true","boolean");this.addOutput("false","boolean");this.addProperty("A",1);this.addProperty("B",1);this.addProperty("OP","==","enum",{values:k.values});this.addWidget("combo","Op.",this.properties.OP,{property:"OP", -values:k.values});this.size=[80,60]}var m=x.LiteGraph;n.title="Time";n.desc="Time";n.prototype.onExecute=function(){this.setOutputData(0,1E3*this.graph.globaltime);this.setOutputData(1,this.graph.globaltime)};m.registerNodeType("basic/time",n);t.title="Subgraph";t.desc="Graph inside a node";t.title_color="#334";t.prototype.onGetInputs=function(){return[["enabled","boolean"]]};t.prototype.onDblClick=function(a,b,c){var d=this;setTimeout(function(){c.openSubgraph(d.subgraph)},10)};t.prototype.onAction= -function(a,b){this.subgraph.onAction(a,b)};t.prototype.onExecute=function(){if(this.enabled=this.getInputOrProperty("enabled")){if(this.inputs)for(var a=0;aa&&(b[0]=f?this.trigger(null,h,l):this._pending.push([f,h])};B.prototype.onExecute= -function(f,h){f=1E3*this.graph.elapsed_time;this.isInputConnected(1)&&(this.properties.time_in_ms=this.getInputData(1));for(var l=0;lw?h.xbox.axes.lx:0,this._left_axis[1]=Math.abs(h.xbox.axes.ly)>w?h.xbox.axes.ly:0,this._right_axis[0]=Math.abs(h.xbox.axes.rx)>w?h.xbox.axes.rx:0,this._right_axis[1]=Math.abs(h.xbox.axes.ry)>w?h.xbox.axes.ry:0,this._triggers[0]=Math.abs(h.xbox.axes.ltrigger)>w?h.xbox.axes.ltrigger: -0,this._triggers[1]=Math.abs(h.xbox.axes.rtrigger)>w?h.xbox.axes.rtrigger:0);if(this.outputs)for(w=0;ww;w++)if(h[w]){h=h[w];w=this.xbox_mapping;w||(w=this.xbox_mapping={axes:[], -buttons:{},hat:"",hatmap:n.CENTER});w.axes.lx=h.axes[0];w.axes.ly=h.axes[1];w.axes.rx=h.axes[2];w.axes.ry=h.axes[3];w.axes.ltrigger=h.buttons[6].value;w.axes.rtrigger=h.buttons[7].value;w.hat="";w.hatmap=n.CENTER;for(var t=0;tt)w.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&&(w.hat+="up",w.hatmap|=n.UP); -break;case 13:h.buttons[t].pressed&&(w.hat+="down",w.hatmap|=n.DOWN);break;case 14:h.buttons[t].pressed&&(w.hat+="left",w.hatmap|=n.LEFT);break;case 15:h.buttons[t].pressed&&(w.hat+="right",w.hatmap|=n.RIGHT);break;case 16:w.buttons.home=h.buttons[t].pressed}h.xbox=w;return h}};n.prototype.onDrawBackground=function(h){if(!this.flags.collapsed){var n=this._left_axis,t=this._right_axis;h.strokeStyle="#88A";h.strokeRect(.5*(n[0]+1)*this.size[0]-4,.5*(n[1]+1)*this.size[1]-4,8,8);h.strokeStyle="#8A8"; -h.strokeRect(.5*(t[0]+1)*this.size[0]-4,.5*(t[1]+1)*this.size[1]-4,8,8);n=this.size[1]/this._current_buttons.length;h.fillStyle="#AEB";for(t=0;t","enum",{values:N.values});this.addWidget("combo", -"Cond.",this.properties.OP,{property:"OP",values:N.values});this.size=[80,60]}function a(){this.addInput("in",0);this.addInput("cond","boolean");this.addOutput("true",0);this.addOutput("false",0);this.size=[80,60]}function b(){this.addInput("inc","number");this.addOutput("total","number");this.addProperty("increment",1);this.addProperty("value",0)}function c(){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",r.allow_scripts,function(a){r.allow_scripts=a});this._func=null}function d(){this.addInput("vec2","vec2");this.addOutput("x","number");this.addOutput("y","number")}function g(){this.addInputs([["x","number"],["y","number"]]); -this.addOutput("vec2","vec2");this.properties={x:0,y:0};this._data=new Float32Array(2)}function k(){this.addInput("vec3","vec3");this.addOutput("x","number");this.addOutput("y","number");this.addOutput("z","number")}function m(){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 q(){this.addInput("vec4","vec4");this.addOutput("x","number");this.addOutput("y","number");this.addOutput("z", -"number");this.addOutput("w","number")}function p(){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 r=x.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=l.data[d];d=l.data[1023==d?0:d+1];b&&(a=a*a*a*(a*(6*a-15)+10));return c*(1-a)+d*a};l.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,g=0;gd);++g);a=this.properties.min;this._last_v=c/f*(this.properties.max-a)+a;this.setOutputData(0,this._last_v)};l.prototype.onDrawBackground=function(a){this.outputs[0].label=(this._last_v||0).toFixed(3)};r.registerNodeType("math/noise",l);E.title="Spikes";E.desc="spike every random time";E.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)};r.registerNodeType("math/spikes",E);B.title="Clamp";B.desc="Clamp number between min and max"; -B.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))};B.prototype.getCode=function(a){a="";this.isInputConnected(0)&&(a+="clamp({{0}},"+this.properties.min+","+this.properties.max+")");return a};r.registerNodeType("math/clamp",B);z.title="Lerp";z.desc="Linear Interpolation";z.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)};z.prototype.onGetInputs=function(){return[["f","number"]]};r.registerNodeType("math/lerp",z);F.title="Abs";F.desc="Absolute";F.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,Math.abs(a))};r.registerNodeType("math/abs",F);G.title="Floor";G.desc="Floor number to remove fractional part";G.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0, -Math.floor(a))};r.registerNodeType("math/floor",G);J.title="Frac";J.desc="Returns fractional part";J.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,a%1)};r.registerNodeType("math/frac",J);f.title="Smoothstep";f.desc="Smoothstep";f.prototype.onExecute=function(){var a=this.getInputData(0);if(void 0!==a){var b=this.properties.A;a=clamp((a-b)/(this.properties.B-b),0,1);this.setOutputData(0,a*a*(3-2*a))}};r.registerNodeType("math/smoothstep",f);L.title="Scale"; -L.desc="v * factor";L.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,a*this.properties.factor)};r.registerNodeType("math/scale",L);D.title="Gate";D.desc="if v is true, then outputs A, otherwise B";D.prototype.onExecute=function(){var a=this.getInputData(0);this.setOutputData(0,this.getInputData(a?1:2))};r.registerNodeType("math/gate",D);A.title="Average";A.desc="Average Filter";A.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))};r.registerNodeType("math/average",A);M.title="TendTo";M.desc="moves the output value always closer to the input"; -M.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)};r.registerNodeType("math/tendTo",M);C.values="+ - * / % ^ max min".split(" ");C.funcs={"+":function(a,b){return a+b},"-":function(a,b){return a-b},x:function(a,b){return a*b},X:function(a,b){return a*b},"*":function(a,b){return a*b},"/":function(a,b){return a/b},"%":function(a,b){return a%b},"^":function(a, -b){return Math.pow(a,b)},max:function(a,b){return Math.max(a,b)},min:function(a,b){return Math.min(a,b)}};C.title="Operation";C.desc="Easy math operators";C["@OP"]={type:"enum",title:"operation",values:C.values};C.size=[100,60];C.prototype.getTitle=function(){return"max"==this.properties.OP||"min"==this.properties.OP?this.properties.OP+"(A,B)":"A "+this.properties.OP+" B"};C.prototype.setValue=function(a){"string"==typeof a&&(a=parseFloat(a));this.properties.value=a};C.prototype.onPropertyChanged= -function(a,b){"OP"==a&&(this._func=C.funcs[this.properties.OP],this._func||(console.warn("Unknown operation: "+this.properties.OP),this._func=function(a){return a}))};C.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;var c=C.funcs[this.properties.OP];if(a.constructor===Number)var d=c(a,b);else if(a.constructor===Array){d=this._result;d.length=a.length; -for(var e=0;eB":f=a>b;break;case "A=B":f=a>=b}this.setOutputData(c,f)}}};H.prototype.onGetOutputs=function(){return[["A==B","boolean"],["A!=B","boolean"],["A>B","boolean"],["A=B","boolean"],["A<=B","boolean"]]};r.registerNodeType("math/compare",H);r.registerSearchboxExtra("math/compare","==",{outputs:[["A==B","boolean"]],title:"A==B"});r.registerSearchboxExtra("math/compare","!=",{outputs:[["A!=B","boolean"]],title:"A!=B"});r.registerSearchboxExtra("math/compare",">",{outputs:[["A>B","boolean"]], -title:"A>B"});r.registerSearchboxExtra("math/compare","<",{outputs:[["A=",{outputs:[["A>=B","boolean"]],title:"A>=B"});r.registerSearchboxExtra("math/compare","<=",{outputs:[["A<=B","boolean"]],title:"A<=B"});N.values="> < == != <= >= || &&".split(" ");N["@OP"]={type:"enum",title:"operation",values:N.values};N.title="Condition";N.desc="evaluates condition between A and B";N.prototype.getTitle=function(){return"A "+this.properties.OP+ -" B"};N.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)};r.registerNodeType("math/condition",N);a.title= -"Branch";a.desc="If condition is true, outputs IN in true, otherwise in false";a.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))};r.registerNodeType("math/branch",a);b.title="Accumulate";b.desc="Increments a value every time";b.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)};r.registerNodeType("math/accumulate",b);c.title="Trigonometry";c.desc="Sin Cos Tan";c.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;c< +"Name",this.properties.name,function(b){b&&a.setProperty("name",b)});this.type_widget=this.addWidget("text","Type",this.properties.type,function(b){a.setProperty("type",b)});this.value_widget=this.addWidget("number","Value",this.properties.value,function(b){a.setProperty("value",b)});this.widgets_up=!0;this.size=[180,90]}function y(){this.addInput("","");this.name_in_graph="";this.properties={name:"",type:""};this.name_widget=this.addWidget("text","Name",this.properties.name,"name");this.type_widget= +this.addWidget("text","Type",this.properties.type,"type");this.widgets_up=!0;this.size=[180,60]}function z(){this.addOutput("value","number");this.addProperty("value",1);this.widget=this.addWidget("number","value",1,"value");this.widgets_up=!0;this.size=[180,30]}function l(){this.addOutput("bool","boolean");this.addProperty("value",!0);this.widget=this.addWidget("toggle","value",!0,"value");this.widgets_up=this.serialize_widgets=!0;this.size=[140,30]}function C(){this.addOutput("string","string"); +this.addProperty("value","");this.widget=this.addWidget("text","value","","value");this.widgets_up=!0;this.size=[180,30]}function B(){this.addOutput("obj","object");this.size=[120,30];this._object={}}function D(){this.addInput("url","string");this.addOutput("file","string");this.addProperty("url","");this.addProperty("type","text");this.widget=this.addWidget("text","url","","url");this._data=null}function G(){this.addInput("parse",t.ACTION);this.addInput("json","string");this.addOutput("done",t.EVENT); +this.addOutput("object","object");this.widget=this.addWidget("button","parse","",this.parse.bind(this));this._obj=this._str=null}function H(){this.addOutput("data","object");this.addProperty("value","");this.widget=this.addWidget("text","json","","value");this.widgets_up=!0;this.size=[140,30];this._value=null}function I(){this._value=[];this.addInput("json","");this.addOutput("arrayOut","array");this.addOutput("length","number");this.addProperty("value","[]");this.widget=this.addWidget("text","array", +this.properties.value,"value");this.widgets_up=!0;this.size=[140,50]}function f(){this.addInput("arr","array");this.addInput("value","");this.addOutput("arr","array");this.properties={index:0};this.widget=this.addWidget("number","i",this.properties.index,"index",{precision:0,step:10,min:0})}function J(){this.addInput("array","array,table,string");this.addInput("index","number");this.addOutput("value","");this.addProperty("index",0)}function K(){this.addInput("table","table");this.addInput("row","number"); +this.addInput("col","number");this.addOutput("value","");this.addProperty("row",0);this.addProperty("column",0)}function A(){this.addInput("obj","object");this.addOutput("property",0);this.addProperty("value",0);this.widget=this.addWidget("text","prop.","",this.setValue.bind(this));this.widgets_up=!0;this.size=[140,30];this._value=null}function L(){this.addInput("obj","");this.addOutput("keys","array");this.size=[140,30]}function E(){this.addInput("obj","");this.addInput("value","");this.addOutput("obj", +"");this.properties={property:""};this.name_widget=this.addWidget("text","prop.",this.properties.property,"property")}function N(){this.addInput("A","object");this.addInput("B","object");this.addOutput("out","object");this._result={};var a=this;this.addWidget("button","clear","",function(){a._result={}});this.size=this.computeSize()}function F(){this.size=[60,30];this.addInput("in");this.addOutput("out");this.properties={varname:"myname",container:F.LITEGRAPH};this.value=null}function a(a){return a&& +null!=a.length?Number(a.length):0}function a(a){return a&&null!=a.length?Number(a.length):0}function b(){this.size=[60,30];this.addInput("data",0);this.addInput("download",t.ACTION);this.properties={filename:"data.json"};this.value=null;var a=this;this.addWidget("button","Download","",function(b){a.value&&a.downloadAsFile()})}function c(){this.size=[60,30];this.addInput("value",0,{label:""});this.value=0}function e(){this.addInput("in",0);this.addOutput("out",0);this.size=[40,30]}function d(){this.mode= +t.ON_EVENT;this.size=[80,30];this.addProperty("msg","");this.addInput("log",t.EVENT);this.addInput("msg",0)}function g(){this.mode=t.ON_EVENT;this.addProperty("msg","");this.addInput("",t.EVENT);this.widget=this.addWidget("text","Text","","msg");this.widgets_up=!0;this.size=[200,30]}function k(){this.size=[60,30];this.addProperty("onExecute","return A;");this.addInput("A",0);this.addInput("B",0);this.addOutput("out",0);this._func=null;this.data={}}function n(){this.addInput("A",0);this.addInput("B", +0);this.addOutput("true","boolean");this.addOutput("false","boolean");this.addProperty("A",1);this.addProperty("B",1);this.addProperty("OP","==","enum",{values:n.values});this.addWidget("combo","Op.",this.properties.OP,{property:"OP",values:n.values});this.size=[80,60]}var t=w.LiteGraph;m.title="Time";m.desc="Time";m.prototype.onExecute=function(){this.setOutputData(0,1E3*this.graph.globaltime);this.setOutputData(1,this.graph.globaltime)};t.registerNodeType("basic/time",m);r.title="Subgraph";r.desc= +"Graph inside a node";r.title_color="#334";r.prototype.onGetInputs=function(){return[["enabled","boolean"]]};r.prototype.onDblClick=function(a,b,c){var d=this;setTimeout(function(){c.openSubgraph(d.subgraph)},10)};r.prototype.onAction=function(a,b){this.subgraph.onAction(a,b)};r.prototype.onExecute=function(){if(this.enabled=this.getInputOrProperty("enabled")){if(this.inputs)for(var a=0;aa&&(b[0]=f?this.trigger(null,h,l):this._pending.push([f,h])};B.prototype.onExecute= +function(f,h){f=1E3*this.graph.elapsed_time;this.isInputConnected(1)&&(this.properties.time_in_ms=this.getInputData(1));for(var l=0;lr?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:m.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=m.CENTER;for(var z=0;zz)r.buttons[m.mapping_array[z]]=h.buttons[z].pressed,h.buttons[z].was_pressed&&this.trigger(m.mapping_array[z]+"_button_event");else switch(z){case 12:h.buttons[z].pressed&&(r.hat+="up",r.hatmap|=m.UP); +break;case 13:h.buttons[z].pressed&&(r.hat+="down",r.hatmap|=m.DOWN);break;case 14:h.buttons[z].pressed&&(r.hat+="left",r.hatmap|=m.LEFT);break;case 15:h.buttons[z].pressed&&(r.hat+="right",r.hatmap|=m.RIGHT);break;case 16:r.buttons.home=h.buttons[z].pressed}h.xbox=r;return h}};m.prototype.onDrawBackground=function(h){if(!this.flags.collapsed){var m=this._left_axis,r=this._right_axis;h.strokeStyle="#88A";h.strokeRect(.5*(m[0]+1)*this.size[0]-4,.5*(m[1]+1)*this.size[1]-4,8,8);h.strokeStyle="#8A8"; +h.strokeRect(.5*(r[0]+1)*this.size[0]-4,.5*(r[1]+1)*this.size[1]-4,8,8);m=this.size[1]/this._current_buttons.length;h.fillStyle="#AEB";for(r=0;r","enum",{values:F.values});this.addWidget("combo", +"Cond.",this.properties.OP,{property:"OP",values:F.values});this.size=[80,60]}function a(){this.addInput("in",0);this.addInput("cond","boolean");this.addOutput("true",0);this.addOutput("false",0);this.size=[80,60]}function b(){this.addInput("inc","number");this.addOutput("total","number");this.addProperty("increment",1);this.addProperty("value",0)}function c(){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",q.allow_scripts,function(a){q.allow_scripts=a});this._func=null}function d(){this.addInput("vec2","vec2");this.addOutput("x","number");this.addOutput("y","number")}function g(){this.addInputs([["x","number"],["y","number"]]); +this.addOutput("vec2","vec2");this.properties={x:0,y:0};this._data=new Float32Array(2)}function k(){this.addInput("vec3","vec3");this.addOutput("x","number");this.addOutput("y","number");this.addOutput("z","number")}function n(){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 t(){this.addInput("vec4","vec4");this.addOutput("x","number");this.addOutput("y","number");this.addOutput("z", +"number");this.addOutput("w","number")}function p(){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 q=w.LiteGraph;m.title="Converter";m.desc="type A to type B";m.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=l.data[d];d=l.data[1023==d?0:d+1];b&&(a=a*a*a*(a*(6*a-15)+10));return c*(1-a)+d*a};l.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,g=0;gd);++g);a=this.properties.min;this._last_v=c/f*(this.properties.max-a)+a;this.setOutputData(0,this._last_v)};l.prototype.onDrawBackground=function(a){this.outputs[0].label=(this._last_v||0).toFixed(3)};q.registerNodeType("math/noise",l);C.title="Spikes";C.desc="spike every random time";C.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)};q.registerNodeType("math/spikes",C);B.title="Clamp";B.desc="Clamp number between min and max"; +B.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))};B.prototype.getCode=function(a){a="";this.isInputConnected(0)&&(a+="clamp({{0}},"+this.properties.min+","+this.properties.max+")");return a};q.registerNodeType("math/clamp",B);D.title="Lerp";D.desc="Linear Interpolation";D.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)};D.prototype.onGetInputs=function(){return[["f","number"]]};q.registerNodeType("math/lerp",D);G.title="Abs";G.desc="Absolute";G.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,Math.abs(a))};q.registerNodeType("math/abs",G);H.title="Floor";H.desc="Floor number to remove fractional part";H.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0, +Math.floor(a))};q.registerNodeType("math/floor",H);I.title="Frac";I.desc="Returns fractional part";I.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,a%1)};q.registerNodeType("math/frac",I);f.title="Smoothstep";f.desc="Smoothstep";f.prototype.onExecute=function(){var a=this.getInputData(0);if(void 0!==a){var b=this.properties.A;a=clamp((a-b)/(this.properties.B-b),0,1);this.setOutputData(0,a*a*(3-2*a))}};q.registerNodeType("math/smoothstep",f);J.title="Scale"; +J.desc="v * factor";J.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&this.setOutputData(0,a*this.properties.factor)};q.registerNodeType("math/scale",J);K.title="Gate";K.desc="if v is true, then outputs A, otherwise B";K.prototype.onExecute=function(){var a=this.getInputData(0);this.setOutputData(0,this.getInputData(a?1:2))};q.registerNodeType("math/gate",K);A.title="Average";A.desc="Average Filter";A.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))};q.registerNodeType("math/average",A);L.title="TendTo";L.desc="moves the output value always closer to the input"; +L.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)};q.registerNodeType("math/tendTo",L);E.values="+ - * / % ^ max min".split(" ");E.funcs={"+":function(a,b){return a+b},"-":function(a,b){return a-b},x:function(a,b){return a*b},X:function(a,b){return a*b},"*":function(a,b){return a*b},"/":function(a,b){return a/b},"%":function(a,b){return a%b},"^":function(a, +b){return Math.pow(a,b)},max:function(a,b){return Math.max(a,b)},min:function(a,b){return Math.min(a,b)}};E.title="Operation";E.desc="Easy math operators";E["@OP"]={type:"enum",title:"operation",values:E.values};E.size=[100,60];E.prototype.getTitle=function(){return"max"==this.properties.OP||"min"==this.properties.OP?this.properties.OP+"(A,B)":"A "+this.properties.OP+" B"};E.prototype.setValue=function(a){"string"==typeof a&&(a=parseFloat(a));this.properties.value=a};E.prototype.onPropertyChanged= +function(a,b){"OP"==a&&(this._func=E.funcs[this.properties.OP],this._func||(console.warn("Unknown operation: "+this.properties.OP),this._func=function(a){return a}))};E.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;var c=E.funcs[this.properties.OP];if(a.constructor===Number)var d=c(a,b);else if(a.constructor===Array){d=this._result;d.length=a.length; +for(var e=0;eB":f=a>b;break;case "A=B":f=a>=b}this.setOutputData(c,f)}}};N.prototype.onGetOutputs=function(){return[["A==B","boolean"],["A!=B","boolean"],["A>B","boolean"],["A=B","boolean"],["A<=B","boolean"]]};q.registerNodeType("math/compare",N);q.registerSearchboxExtra("math/compare","==",{outputs:[["A==B","boolean"]],title:"A==B"});q.registerSearchboxExtra("math/compare","!=",{outputs:[["A!=B","boolean"]],title:"A!=B"});q.registerSearchboxExtra("math/compare",">",{outputs:[["A>B","boolean"]], +title:"A>B"});q.registerSearchboxExtra("math/compare","<",{outputs:[["A=",{outputs:[["A>=B","boolean"]],title:"A>=B"});q.registerSearchboxExtra("math/compare","<=",{outputs:[["A<=B","boolean"]],title:"A<=B"});F.values="> < == != <= >= || &&".split(" ");F["@OP"]={type:"enum",title:"operation",values:F.values};F.title="Condition";F.desc="evaluates condition between A and B";F.prototype.getTitle=function(){return"A "+this.properties.OP+ +" B"};F.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)};q.registerNodeType("math/condition",F);a.title= +"Branch";a.desc="If condition is true, outputs IN in true, otherwise in false";a.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))};q.registerNodeType("math/branch",a);b.title="Accumulate";b.desc="Increments a value every time";b.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)};q.registerNodeType("math/accumulate",b);c.title="Trigonometry";c.desc="Sin Cos Tan";c.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;c< e;++c){switch(this.outputs[c].name){case "sin":var f=Math.sin(a);break;case "cos":f=Math.cos(a);break;case "tan":f=Math.tan(a);break;case "asin":f=Math.asin(a);break;case "acos":f=Math.acos(a);break;case "atan":f=Math.atan(a)}this.setOutputData(c,b*f+d)}};c.prototype.onGetInputs=function(){return[["v","number"],["amplitude","number"],["offset","number"]]};c.prototype.onGetOutputs=function(){return[["sin","number"],["cos","number"],["tan","number"],["asin","number"],["acos","number"],["atan","number"]]}; -r.registerNodeType("math/trigonometry",c);r.registerSearchboxExtra("math/trigonometry","SIN()",{outputs:[["sin","number"]],title:"SIN()"});r.registerSearchboxExtra("math/trigonometry","COS()",{outputs:[["cos","number"]],title:"COS()"});r.registerSearchboxExtra("math/trigonometry","TAN()",{outputs:[["tan","number"]],title:"TAN()"});e.title="Formula";e.desc="Compute formula";e.size=[160,100];A.prototype.onPropertyChanged=function(a,b){"formula"==a&&(this.code_widget.value=b)};e.prototype.onExecute= -function(){if(r.allow_scripts){var a=this.getInputData(0),b=this.getInputData(1);null!=a?this.properties.x=a:a=this.properties.x;null!=b?this.properties.y=b:b=this.properties.y;try{this._func&&this._func_code==this.properties.formula||(this._func=new Function("x","y","TIME","return "+this.properties.formula),this._func_code=this.properties.formula);var c=this._func(a,b,this.graph.globaltime);this.boxcolor=null}catch(v){this.boxcolor="red"}this.setOutputData(0,c)}};e.prototype.getTitle=function(){return this._func_code|| -"Formula"};e.prototype.onDrawBackground=function(){var a=this.properties.formula;this.outputs&&this.outputs.length&&(this.outputs[0].label=a)};r.registerNodeType("math/formula",e);d.title="Vec2->XY";d.desc="vector 2 to components";d.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]))};r.registerNodeType("math3d/vec2-to-xy",d);g.title="XY->Vec2";g.desc="components to vector2";g.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)};r.registerNodeType("math3d/xy-to-vec2",g);k.title="Vec3->XYZ";k.desc="vector 3 to components";k.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]))};r.registerNodeType("math3d/vec3-to-xyz",k);m.title="XYZ->Vec3";m.desc="components to vector3";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.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)};r.registerNodeType("math3d/xyz-to-vec3",m);q.title="Vec4->XYZW";q.desc="vector 4 to components";q.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]))};r.registerNodeType("math3d/vec4-to-xyzw",q);p.title="XYZW->Vec4";p.desc="components to vector4";p.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)};r.registerNodeType("math3d/xyzw-to-vec4",p)})(this); -(function(x){function n(){this.addInput("","string");this.addOutput("table","table");this.addOutput("rows","number");this.addProperty("value","");this.addProperty("separator",",");this._table=null}x=x.LiteGraph;x.wrapFunctionAsNode("string/toString",function(n){if(n&&n.constructor===Object)try{return JSON.stringify(n)}catch(h){}return String(n)},[""],"string");x.wrapFunctionAsNode("string/compare",function(n,h){return n==h},["string","string"],"boolean");x.wrapFunctionAsNode("string/concatenate", -function(n,h){return void 0===n?h:void 0===h?n:n+h},["string","string"],"string");x.wrapFunctionAsNode("string/contains",function(n,h){return void 0===n||void 0===h?!1:-1!=n.indexOf(h)},["string","string"],"boolean");x.wrapFunctionAsNode("string/toUpperCase",function(n){return null!=n&&n.constructor===String?n.toUpperCase():n},["string"],"string");x.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 t=[],y=0;yXY";d.desc="vector 2 to components";d.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&(this.setOutputData(0,a[0]),this.setOutputData(1,a[1]))};q.registerNodeType("math3d/vec2-to-xy",d);g.title="XY->Vec2";g.desc="components to vector2";g.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)};q.registerNodeType("math3d/xy-to-vec2",g);k.title="Vec3->XYZ";k.desc="vector 3 to components";k.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]))};q.registerNodeType("math3d/vec3-to-xyz",k);n.title="XYZ->Vec3";n.desc="components to vector3";n.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)};q.registerNodeType("math3d/xyz-to-vec3",n);t.title="Vec4->XYZW";t.desc="vector 4 to components";t.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]))};q.registerNodeType("math3d/vec4-to-xyzw",t);p.title="XYZW->Vec4";p.desc="components to vector4";p.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)};q.registerNodeType("math3d/xyzw-to-vec4",p)})(this); +(function(w){function m(){this.addInput("","string");this.addOutput("table","table");this.addOutput("rows","number");this.addProperty("value","");this.addProperty("separator",",");this._table=null}w=w.LiteGraph;w.wrapFunctionAsNode("string/toString",function(m){if(m&&m.constructor===Object)try{return JSON.stringify(m)}catch(h){}return String(m)},[""],"string");w.wrapFunctionAsNode("string/compare",function(m,h){return m==h},["string","string"],"boolean");w.wrapFunctionAsNode("string/concatenate", +function(m,h){return void 0===m?h:void 0===h?m:m+h},["string","string"],"string");w.wrapFunctionAsNode("string/contains",function(m,h){return void 0===m||void 0===h?!1:-1!=m.indexOf(h)},["string","string"],"boolean");w.wrapFunctionAsNode("string/toUpperCase",function(m){return null!=m&&m.constructor===String?m.toUpperCase():m},["string"],"string");w.wrapFunctionAsNode("string/split",function(m,h){null==h&&(h=this.properties.separator);if(null==m)return[];if(m.constructor===String)return m.split(h|| +" ");if(m.constructor===Array){for(var r=[],z=0;z