Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rete

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rete - npm Package Compare versions

Comparing version 1.0.0-alpha.3 to 1.0.0-alpha.4

2

build/rete.engine.js
/*!
* rete v1.0.0-alpha.3
* rete v1.0.0-alpha.4
* (c) 2018 Vitaliy Stoliarov

@@ -4,0 +4,0 @@ * Released under the MIT License.

/*!
* rete v1.0.0-alpha.3
* rete v1.0.0-alpha.4
* (c) 2018 Vitaliy Stoliarov
* Released under the MIT License.
*/
!function(t){"use strict";function n(t,n,e,o){var i=n&&n.prototype instanceof r?n:r,a=Object.create(i.prototype),u=new h(o||[]);return a._invoke=c(t,e,u),a}function e(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}function r(){}function o(){}function i(){}function a(t){["next","throw","return"].forEach(function(n){t[n]=function(t){return this._invoke(n,t)}})}function u(t){function n(r,o,i,a){var u=e(t[r],t,o);if("throw"!==u.type){var c=u.arg,s=c.value;return s&&"object"==typeof s&&y.call(s,"__await")?Promise.resolve(s.__await).then(function(t){n("next",t,i,a)},function(t){n("throw",t,i,a)}):Promise.resolve(s).then(function(t){c.value=t,i(c)},a)}a(u.arg)}function r(t,e){function r(){return new Promise(function(r,o){n(t,e,r,o)})}return o=o?o.then(r,r):r()}var o;this._invoke=r}function c(t,n,r){var o=O;return function(i,a){if(o===A)throw new Error("Generator is already running");if(o===_){if("throw"===i)throw a;return d()}for(r.method=i,r.arg=a;;){var u=r.delegate;if(u){var c=s(u,r);if(c){if(c===T)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===O)throw o=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=A;var l=e(t,n,r);if("normal"===l.type){if(o=r.done?_:j,l.arg===T)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(o=_,r.method="throw",r.arg=l.arg)}}}function s(t,n){var r=t.iterator[n.method];if(r===v){if(n.delegate=null,"throw"===n.method){if(t.iterator.return&&(n.method="return",n.arg=v,s(t,n),"throw"===n.method))return T;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return T}var o=e(r,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,T;var i=o.arg;return i?i.done?(n[t.resultName]=i.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=v),n.delegate=null,T):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,T)}function l(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function f(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function h(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(l,this),this.reset(!0)}function p(t){if(t){var n=t[w];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,r=function n(){for(;++e<t.length;)if(y.call(t,e))return n.value=t[e],n.done=!1,n;return n.value=v,n.done=!0,n};return r.next=r}}return{next:d}}function d(){return{value:v,done:!0}}var v,m=Object.prototype,y=m.hasOwnProperty,g="function"==typeof Symbol?Symbol:{},w=g.iterator||"@@iterator",b=g.asyncIterator||"@@asyncIterator",E=g.toStringTag||"@@toStringTag",k="object"==typeof module,x=t.regeneratorRuntime;if(x)return void(k&&(module.exports=x));x=t.regeneratorRuntime=k?module.exports:{},x.wrap=n;var O="suspendedStart",j="suspendedYield",A="executing",_="completed",T={},N={};N[w]=function(){return this};var C=Object.getPrototypeOf,V=C&&C(C(p([])));V&&V!==m&&y.call(V,w)&&(N=V);var S=i.prototype=r.prototype=Object.create(N);o.prototype=S.constructor=i,i.constructor=o,i[E]=o.displayName="GeneratorFunction",x.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===o||"GeneratorFunction"===(n.displayName||n.name))},x.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,i):(t.__proto__=i,E in t||(t[E]="GeneratorFunction")),t.prototype=Object.create(S),t},x.awrap=function(t){return{__await:t}},a(u.prototype),u.prototype[b]=function(){return this},x.AsyncIterator=u,x.async=function(t,e,r,o){var i=new u(n(t,e,r,o));return x.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},a(S),S[E]="Generator",S[w]=function(){return this},S.toString=function(){return"[object Generator]"},x.keys=function(t){var n=[];for(var e in t)n.push(e);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},x.values=p,h.prototype={constructor:h,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=v,this.done=!1,this.delegate=null,this.method="next",this.arg=v,this.tryEntries.forEach(f),!t)for(var n in this)"t"===n.charAt(0)&&y.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=v)},stop:function(){this.done=!0;var t=this.tryEntries[0],n=t.completion;if("throw"===n.type)throw n.arg;return this.rval},dispatchException:function(t){function n(n,r){return i.type="throw",i.arg=t,e.next=n,r&&(e.method="next",e.arg=v),!!r}if(this.done)throw t;for(var e=this,r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],i=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var a=y.call(o,"catchLoc"),u=y.call(o,"finallyLoc");if(a&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,n){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc<=this.prev&&y.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=n&&n<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=n,o?(this.method="next",this.next=o.finallyLoc,T):this.complete(i)},complete:function(t,n){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&n&&(this.next=n),T},finish:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),f(e),T}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.tryLoc===t){var r=e.completion;if("throw"===r.type){var o=r.arg;f(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,e){return this.delegate={iterator:p(t),resultName:n,nextLoc:e},"next"===this.method&&(this.arg=v),T}}}(function(){return this}()||Function("return this")()),function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.Rete=n()}(this,function(){"use strict";function t(n,e){if(void 0===e&&(e=0),e+=1,null===n)return"null";if(void 0===n)return"void";if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)return void 0===n?"undefined":d(n);if(Array.isArray(n)){if(n.length>0){if(e>4)return"[...]";var r=t(n[0],e);return n.every(function(n){return t(n,e)===r})?r.trim()+"[]":"["+n.slice(0,15).map(function(n){return t(n,e)}).join(", ")+(n.length>=15?", ...":"")+"]"}return"Array"}var o=Object.keys(n);if(!o.length)return n.constructor&&n.constructor.name&&"Object"!==n.constructor.name?n.constructor.name:"Object";if(e>4)return"{...}";var i=" ".repeat(e-1),a=o.slice(0,15).map(function(r){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(r)?r:JSON.stringify(r))+": "+t(n[r],e)+";"}).join("\n "+i);return o.length>=15&&(a+="\n "+i+"..."),n.constructor&&n.constructor.name&&"Object"!==n.constructor.name?n.constructor.name+" {\n "+i+a+"\n"+i+"}":"{\n "+i+a+"\n"+i+"}"}function n(t,e){if(void 0===e&&(e=0),e+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(e>4)return"[...]";var r=n(t[0],e);return t.every(function(t){return n(t,e)===r})?r.trim()+"[]":"["+t.slice(0,15).map(function(t){return n(t,e)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var o=Object.keys(t);if(!o.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(e>4)return"{...}";var i=" ".repeat(e-1),a=o.slice(0,15).map(function(r){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(r)?r:JSON.stringify(r))+": "+n(t[r],e)+";"}).join("\n "+i);return o.length>=15&&(a+="\n "+i+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+i+a+"\n"+i+"}":"{\n "+i+a+"\n"+i+"}"}function e(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var r=e(t[0],n);return t.every(function(t){return e(t,n)===r})?r.trim()+"[]":"["+t.slice(0,15).map(function(t){return e(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var o=Object.keys(t);if(!o.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var i=" ".repeat(n-1),a=o.slice(0,15).map(function(r){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(r)?r:JSON.stringify(r))+": "+e(t[r],n)+";"}).join("\n "+i);return o.length>=15&&(a+="\n "+i+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+i+a+"\n"+i+"}":"{\n "+i+a+"\n"+i+"}"}function r(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=r(t[0],n);return t.every(function(t){return r(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return r(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var o=Object.keys(t);if(!o.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var i=" ".repeat(n-1),a=o.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+r(t[e],n)+";"}).join("\n "+i);return o.length>=15&&(a+="\n "+i+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+i+a+"\n"+i+"}":"{\n "+i+a+"\n"+i+"}"}function o(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=o(t[0],n);return t.every(function(t){return o(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return o(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var i=" ".repeat(n-1),a=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+o(t[e],n)+";"}).join("\n "+i);return r.length>=15&&(a+="\n "+i+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+i+a+"\n"+i+"}":"{\n "+i+a+"\n"+i+"}"}function i(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=i(t[0],n);return t.every(function(t){return i(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return i(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),a=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+i(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(a+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+a+"\n"+o+"}":"{\n "+o+a+"\n"+o+"}"}function a(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=a(t[0],n);return t.every(function(t){return a(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return a(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+a(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function u(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=u(t[0],n);return t.every(function(t){return u(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return u(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+u(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function c(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=c(t[0],n);return t.every(function(t){return c(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return c(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+c(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function s(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=s(t[0],n);return t.every(function(t){return s(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return s(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+s(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function l(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=l(t[0],n);return t.every(function(t){return l(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return l(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+l(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function f(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=f(t[0],n);return t.every(function(t){return f(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return f(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+f(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function h(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=h(t[0],n);return t.every(function(t){return h(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return h(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+h(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function p(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=p(t[0],n);return t.every(function(t){return p(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return p(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+p(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}var d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v=function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")},m=function(){function t(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(n,e,r){return e&&t(n.prototype,e),r&&t(n,r),n}}(),y=function(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t},g=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},w=function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function, not "+typeof n);t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),n&&(Object.setPrototypeOf?Object.setPrototypeOf(t,n):t.__proto__=n)},b=function(t,n){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!n||"object"!=typeof n&&"function"!=typeof n?t:n},E=function(){function t(t,n){var e=[],r=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(e.push(a.value),!n||e.length!==n);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&u.return&&u.return()}finally{if(o)throw i}}return e}return function(n,e){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return t(n,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),k=function(t){if(Array.isArray(t)){for(var n=0,e=Array(t.length);n<t.length;n++)e[n]=t[n];return e}return Array.from(t)},x=function(){function t(n){if(v(this,t),this.constructor===t)throw new TypeError("Can not construct abstract class.");this.name=n,this.data={},this.engine=null}return m(t,[{key:"worker",value:function(){}}]),t}(),O=function(){function t(){if(v(this,t),this.constructor===t)throw new TypeError("Can not construct abstract class.");this.data={},this.parent=null}return m(t,[{key:"getNode",value:function(){if(null===this.parent)throw new Error("Control isn't added to Node/Input");return this.parent instanceof C?this.parent:this.parent.node}},{key:"getData",value:function(t){return this.getNode().data[t]}},{key:"putData",value:function(t,n){this.getNode().data[t]=n}}]),t}(),j=function(){function t(n,e){v(this,t),this.output=n,this.input=e,this.data={},this.input.addConnection(this)}return m(t,[{key:"remove",value:function(){this.input.removeConnection(this),this.output.removeConnection(this)}}]),t}(),A=function(){function n(t,e,r){v(this,n),this.node=null,this.multipleConnections=r,this.connections=[],this.name=t,this.socket=e}return m(n,[{key:"removeConnection",value:function(n){if(!(n instanceof j))throw new TypeError('Value of argument "connection" violates contract.\n\nExpected:\nConnection\n\nGot:\n'+t(n));this.connections.splice(this.connections.indexOf(n),1)}},{key:"removeConnections",value:function(){var t=this;this.connections.map(function(n){return t.removeConnection(n)})}}]),n}(),_=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(v(this,t),"string"!=typeof e)throw new TypeError('Value of argument "name" violates contract.\n\nExpected:\nstring\n\nGot:\n'+n(e));this.name=e,this.data=r,this.compatible=[]}return m(t,[{key:"combineWith",value:function(e){if(!(e instanceof t))throw new TypeError('Value of argument "socket" violates contract.\n\nExpected:\nSocket\n\nGot:\n'+n(e));this.compatible.push(e)}},{key:"compatibleWith",value:function(e){if(!(e instanceof t))throw new TypeError('Value of argument "socket" violates contract.\n\nExpected:\nSocket\n\nGot:\n'+n(e));return this===e||this.compatible.includes(e)}}]),t}(),T=function(t){function n(t,r){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(v(this,n),"string"!=typeof t)throw new TypeError('Value of argument "title" violates contract.\n\nExpected:\nstring\n\nGot:\n'+e(t));if(!(r instanceof _))throw new TypeError('Value of argument "socket" violates contract.\n\nExpected:\nSocket\n\nGot:\n'+e(r));if("boolean"!=typeof o)throw new TypeError('Value of argument "multiConns" violates contract.\n\nExpected:\nboolean\n\nGot:\n'+e(o));var i=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,r,o));return i.control=null,i}return w(n,t),m(n,[{key:"hasConnection",value:function(){return this.connections.length>0}},{key:"addConnection",value:function(t){if(!(t instanceof j))throw new TypeError('Value of argument "connection" violates contract.\n\nExpected:\nConnection\n\nGot:\n'+e(t));if(!this.multipleConnections&&this.hasConnection())throw new Error("Multiple connections not allowed");this.connections.push(t)}},{key:"addControl",value:function(t){if(!(t instanceof O))throw new TypeError('Value of argument "control" violates contract.\n\nExpected:\nControl\n\nGot:\n'+e(t));this.control=t,t.parent=this}},{key:"showControl",value:function(){return!this.hasConnection()&&null!==this.control}},{key:"toJSON",value:function(){return{connections:this.connections.map(function(t){return{node:t.output.node.id,output:t.output.node.outputs.indexOf(t.output),data:t.data}})}}}]),n}(A),N=function(t){function n(t,e){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(v(this,n),"string"!=typeof t)throw new TypeError('Value of argument "title" violates contract.\n\nExpected:\nstring\n\nGot:\n'+r(t));if(!(e instanceof _))throw new TypeError('Value of argument "socket" violates contract.\n\nExpected:\nSocket\n\nGot:\n'+r(e));if("boolean"!=typeof o)throw new TypeError('Value of argument "multiConns" violates contract.\n\nExpected:\nboolean\n\nGot:\n'+r(o));return b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e,o))}return w(n,t),m(n,[{key:"hasConnection",value:function(){return this.connections.length>0}},{key:"connectTo",value:function(t){if(!(t instanceof T))throw new TypeError('Value of argument "input" violates contract.\n\nExpected:\nInput\n\nGot:\n'+r(t));if(!this.socket.compatibleWith(t.socket))throw new Error("Sockets not compatible");if(!t.multipleConnections&&t.hasConnection())throw new Error("Input already has one connection");if(!this.multipleConnections&&this.hasConnection())throw new Error("Output already has one connection");var n=new j(this,t);return this.connections.push(n),n}},{key:"connectedTo",value:function(t){if(!(t instanceof T))throw new TypeError('Value of argument "input" violates contract.\n\nExpected:\nInput\n\nGot:\n'+r(t));return this.connections.some(function(n){return n.input===t})}},{key:"toJSON",value:function(){return{connections:this.connections.map(function(t){return{node:t.input.node.id,input:t.input.node.inputs.indexOf(t.input),data:t.data}})}}}]),n}(A),C=function(){function t(n){if(v(this,t),"string"!=typeof n)throw new TypeError('Value of argument "name" violates contract.\n\nExpected:\nstring\n\nGot:\n'+o(n));this.name=n,this.id=t.incrementId(),this.position=[0,0],this.inputs=[],this.outputs=[],this.controls=[],this.data={},this.meta={}}return m(t,[{key:"addControl",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.controls.length;if(!(t instanceof O))throw new TypeError('Value of argument "control" violates contract.\n\nExpected:\nControl\n\nGot:\n'+o(t));if(!(null==n||"number"==typeof n&&!isNaN(n)&&n>=0&&n<=255&&n===Math.floor(n)))throw new TypeError('Value of argument "index" violates contract.\n\nExpected:\n?uint8\n\nGot:\n'+o(n));return t.parent=this,this.controls.splice(n,0,t),this}},{key:"removeControl",value:function(t){if(!(t instanceof O))throw new TypeError('Value of argument "control" violates contract.\n\nExpected:\nControl\n\nGot:\n'+o(t));t.parent=null,this.controls.splice(this.controls.indexOf(t),1)}},{key:"addInput",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.inputs.length;if(!(t instanceof T))throw new TypeError('Value of argument "input" violates contract.\n\nExpected:\nInput\n\nGot:\n'+o(t));if(!(null==n||"number"==typeof n&&!isNaN(n)&&n>=0&&n<=255&&n===Math.floor(n)))throw new TypeError('Value of argument "index" violates contract.\n\nExpected:\n?uint8\n\nGot:\n'+o(n));if(null!==t.node)throw new Error("Input has already been added to the node");return t.node=this,this.inputs.splice(n,0,t),this}},{key:"removeInput",value:function(t){if(!(t instanceof T))throw new TypeError('Value of argument "input" violates contract.\n\nExpected:\nInput\n\nGot:\n'+o(t));t.removeConnections(),t.node=null,this.inputs.splice(this.inputs.indexOf(t),1)}},{key:"addOutput",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.outputs.length;if(!(t instanceof N))throw new TypeError('Value of argument "output" violates contract.\n\nExpected:\nOutput\n\nGot:\n'+o(t));if(!(null==n||"number"==typeof n&&!isNaN(n)&&n>=0&&n<=255&&n===Math.floor(n)))throw new TypeError('Value of argument "index" violates contract.\n\nExpected:\n?uint8\n\nGot:\n'+o(n));if(null!==t.node)throw new Error("Output has already been added to the node");return t.node=this,this.outputs.splice(n,0,t),this}},{key:"removeOutput",value:function(t){if(!(t instanceof N))throw new TypeError('Value of argument "output" violates contract.\n\nExpected:\nOutput\n\nGot:\n'+o(t));t.removeConnections(),t.node=null,this.outputs.splice(this.outputs.indexOf(t),1)}},{key:"getConnections",value:function(){return[].concat(k(this.inputs),k(this.outputs)).reduce(function(t,n){return[].concat(k(t),k(n.connections))},[])}},{key:"inputsWithVisibleControl",value:function(){return this.inputs.filter(function(t){return t.showControl()})}},{key:"toJSON",value:function(){return{id:this.id,data:this.data,inputs:this.inputs.map(function(t){return t.toJSON()}),outputs:this.outputs.map(function(t){return t.toJSON()}),position:this.position,name:this.name}}}],[{key:"incrementId",value:function(){return this.latestId?this.latestId++:this.latestId=1,this.latestId}},{key:"fromJSON",value:function(n){if(!(n instanceof Object))throw new TypeError('Value of argument "json" violates contract.\n\nExpected:\nObject\n\nGot:\n'+o(n));var e=new t(n.name);return e.id=n.id,e.data=n.data,e.position=n.position,e.name=n.name,t.latestId=Math.max(e.id,t.latestId),e}}]),t}(),V=function(t){function n(t){v(this,n);var e=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t));if(e.constructor===n)throw new TypeError("Can not construct abstract class.");return e.editor=null,e.data={},e}return w(n,t),m(n,[{key:"builder",value:function(){return regeneratorRuntime.async(function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}},null,this)}},{key:"created",value:function(){}},{key:"destroyed",value:function(){}},{key:"build",value:function(t){return regeneratorRuntime.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t instanceof C){n.next=2;break}throw new TypeError('Value of argument "node" violates contract.\n\nExpected:\nNode\n\nGot:\n'+i(t));case 2:return n.next=4,regeneratorRuntime.awrap(this.builder(t));case 4:return n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this)}},{key:"createNode",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return t=new C(this.name),t.data=n,e.next=4,regeneratorRuntime.awrap(this.build(t));case 4:return e.abrupt("return",t);case 5:case"end":return e.stop()}},null,this)}}]),n}(x),S=function t(n){v(this,t),this.handlers=g({warn:[console.warn],error:[console.error]},n)},G=function(){function t(n){if(v(this,t),!(n instanceof S||n instanceof t))throw new TypeError('Value of argument "events" violates contract.\n\nExpected:\nEvents | Emitter\n\nGot:\n'+a(n));this.events=n instanceof t?n.events:n.handlers,this.silent=!1}return m(t,[{key:"on",value:function(t,n){var e=this;if("string"!=typeof t)throw new TypeError('Value of argument "names" violates contract.\n\nExpected:\nstring\n\nGot:\n'+a(t));if("function"!=typeof n)throw new TypeError('Value of argument "handler" violates contract.\n\nExpected:\n() => {}\n\nGot:\n'+a(n));return t.split(" ").forEach(function(t){if(!e.events[t])throw new Error("The event "+t+" does not exist");e.events[t].push(n)}),this}},{key:"trigger",value:function(t,n){if("string"!=typeof t)throw new TypeError('Value of argument "name" violates contract.\n\nExpected:\nstring\n\nGot:\n'+a(t));if(!(t in this.events))throw new Error("The event "+t+" cannot be triggered");return this.events[t].reduce(function(t,e){return!1!==e(n)&&t},!0)}}]),t}(),R=function(){function t(){v(this,t)}return m(t,null,[{key:"isValidData",
value:function(t){return"string"==typeof t.id&&this.isValidId(t.id)&&t.nodes instanceof Object&&!(t.nodes instanceof Array)}},{key:"isValidId",value:function(t){return/^[\w-]{3,}@[0-9]+\.[0-9]+\.[0-9]+$/.test(t)}},{key:"validate",value:function(t,n){var e="",r=t.split("@"),o=n.id.split("@");return this.isValidData(n)||(e+="Data is not suitable. "),t!==n.id&&(e+="IDs not equal. "),r[0]!==o[0]&&(e+="Names don't match. "),r[1]!==o[1]&&(e+="Versions don't match"),{success:""===e,msg:e}}}]),t}(),L=function(t){function n(t,e){v(this,n);var r=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));if(!R.isValidId(t))throw new Error("ID should be valid to name@0.1.0 format");return r.id=t,r}return w(n,t),m(n,[{key:"use",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.install(this,n)}}]),n}(G),P=function(t){function n(){return v(this,n),b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,{componentregister:[]}))}return w(n,t),n}(S),I={AVALIABLE:0,PROCESSED:1,ABORT:2},$=function(t){function n(t){if(v(this,n),"string"!=typeof t)throw new TypeError('Value of argument "id" violates contract.\n\nExpected:\nstring\n\nGot:\n'+u(t));var e=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,new P));return e.components=[],e.args=[],e.data=null,e.state=I.AVALIABLE,e.onAbort=function(){},e}return w(n,t),m(n,[{key:"clone",value:function(){var t=new n(this.id);return this.components.map(function(n){return t.register(n)}),t}},{key:"register",value:function(t){if(!(t instanceof x))throw new TypeError('Value of argument "component" violates contract.\n\nExpected:\nComponent\n\nGot:\n'+u(t));this.components.push(t),this.trigger("componentregister",t)}},{key:"throwError",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,regeneratorRuntime.awrap(this.abort());case 2:return this.trigger("error",{message:t,data:n}),this.processDone(),e.abrupt("return","error");case 5:case"end":return e.stop()}},null,this)}},{key:"extractInputNodes",value:function(t,n){return t.inputs.reduce(function(t,e){return[].concat(k(t),k((e.connections||[]).reduce(function(t,e){return[].concat(k(t),[n[e.node]])},[])))},[])}},{key:"detectRecursions",value:function(t){var n=this,e=function e(r,o){if(o.some(function(t){return t===r}))return r;for(var i=0;i<o.length;i++)if(e(r,n.extractInputNodes(o[i],t)))return r;return null};return Object.keys(t).map(function(n){return t[n]}).map(function(r){return e(r,n.extractInputNodes(r,t))}).filter(function(t){return null!==t})}},{key:"processStart",value:function(){return this.state===I.AVALIABLE?(this.state=I.PROCESSED,!0):this.state!==I.ABORT&&(console.warn("The process is busy and has not been restarted.\n Use abort() to force it to complete"),!1)}},{key:"processDone",value:function(){var t=this.state!==I.ABORT;return this.state=I.AVALIABLE,t||(this.onAbort(),this.onAbort=function(){}),t}},{key:"abort",value:function(){var t=this;return regeneratorRuntime.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise(function(n){t.state===I.PROCESSED?(t.state=I.ABORT,t.onAbort=n):t.state===I.ABORT?(t.onAbort(),t.onAbort=n):n()}));case 1:case"end":return n.stop()}},null,this)}},{key:"lock",value:function(t){return regeneratorRuntime.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise(function(n){t.unlockPool=t.unlockPool||[],t.busy&&!t.outputData?t.unlockPool.push(n):n(),t.busy=!0}));case 1:case"end":return n.stop()}},null,this)}},{key:"unlock",value:function(t){t.unlockPool.forEach(function(t){return t()}),t.unlockPool=[],t.busy=!1}},{key:"extractInputData",value:function(t){var n=this;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,regeneratorRuntime.awrap(Promise.all(t.inputs.map(function(t){var e,r;return regeneratorRuntime.async(function(o){for(;;)switch(o.prev=o.next){case 0:return e=t.connections,o.next=3,regeneratorRuntime.awrap(Promise.all(e.map(function(t){var e,r;return regeneratorRuntime.async(function(o){for(;;)switch(o.prev=o.next){case 0:return e=n.data.nodes[t.node],o.next=3,regeneratorRuntime.awrap(n.processNode(e));case 3:if(r=o.sent){o.next=8;break}n.abort(),o.next=9;break;case 8:return o.abrupt("return",r[t.output]);case 9:case"end":return o.stop()}},null,n)})));case 3:return r=o.sent,o.abrupt("return",r);case 5:case"end":return o.stop()}},null,n)})));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},null,this)}},{key:"processWorker",value:function(t){var n,e,r;return regeneratorRuntime.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,regeneratorRuntime.awrap(this.extractInputData(t));case 2:return n=o.sent,e=this.components.find(function(n){return n.name===t.name}),r=t.outputs.map(function(){return null}),o.prev=5,o.next=8,regeneratorRuntime.awrap(e.worker.apply(e,[t,n,r].concat(k(this.args))));case 8:o.next=14;break;case 10:o.prev=10,o.t0=o.catch(5),this.abort(),this.trigger("warn",o.t0);case 14:return o.abrupt("return",r);case 15:case"end":return o.stop()}},null,this,[[5,10]])}},{key:"processNode",value:function(t){return regeneratorRuntime.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.state!==I.ABORT&&t){n.next=2;break}return n.abrupt("return",null);case 2:return n.next=4,regeneratorRuntime.awrap(this.lock(t));case 4:return t.outputData||(t.outputData=this.processWorker(t)),this.unlock(t),n.abrupt("return",t.outputData);case 7:case"end":return n.stop()}},null,this)}},{key:"forwardProcess",value:function(t){var n=this;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.state!==I.ABORT){e.next=2;break}return e.abrupt("return",null);case 2:return e.next=4,regeneratorRuntime.awrap(Promise.all(t.outputs.map(function(t){return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,regeneratorRuntime.awrap(Promise.all(t.connections.map(function(t){var e;return regeneratorRuntime.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=n.data.nodes[t.node],r.next=3,regeneratorRuntime.awrap(n.processNode(e));case 3:return r.next=5,regeneratorRuntime.awrap(n.forwardProcess(e));case 5:case"end":return r.stop()}},null,n)})));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},null,n)})));case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}},null,this)}},{key:"copy",value:function(t){return t=Object.assign({},t),t.nodes=Object.assign({},t.nodes),Object.keys(t.nodes).forEach(function(n){t.nodes[n]=Object.assign({},t.nodes[n])}),t}},{key:"validate",value:function(t){var n,e;return regeneratorRuntime.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(n=R.validate(this.id,t),n.success){r.next=5;break}return r.next=4,regeneratorRuntime.awrap(this.throwError(n.msg));case 4:return r.abrupt("return",r.sent);case 5:if(e=this.detectRecursions(t.nodes),!(e.length>0)){r.next=10;break}return r.next=9,regeneratorRuntime.awrap(this.throwError("Recursion detected",e));case 9:return r.abrupt("return",r.sent);case 10:return r.abrupt("return",!0);case 11:case"end":return r.stop()}},null,this)}},{key:"processStartNode",value:function(t){var n;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=10;break}if(n=this.data.nodes[t]){e.next=6;break}return e.next=5,regeneratorRuntime.awrap(this.throwError("Node with such id not found"));case 5:return e.abrupt("return",e.sent);case 6:return e.next=8,regeneratorRuntime.awrap(this.processNode(n));case 8:return e.next=10,regeneratorRuntime.awrap(this.forwardProcess(n));case 10:case"end":return e.stop()}},null,this)}},{key:"processUnreachable",value:function(){var t,n;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=regeneratorRuntime.keys(this.data.nodes);case 1:if((e.t1=e.t0()).done){e.next=11;break}if(t=e.t1.value,void 0!==this.data.nodes[t].outputData){e.next=9;break}return n=this.data.nodes[t],e.next=7,regeneratorRuntime.awrap(this.processNode(n));case 7:return e.next=9,regeneratorRuntime.awrap(this.forwardProcess(n));case 9:e.next=1;break;case 11:case"end":return e.stop()}},null,this)}},{key:"process",value:function(t){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,e=arguments.length,r=Array(e>2?e-2:0),o=2;o<e;o++)r[o-2]=arguments[o];return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(t instanceof Object){e.next=2;break}throw new TypeError('Value of argument "data" violates contract.\n\nExpected:\nObject\n\nGot:\n'+u(t));case 2:if(null==n||"number"==typeof n){e.next=4;break}throw new TypeError('Value of argument "startId" violates contract.\n\nExpected:\n?number\n\nGot:\n'+u(n));case 4:if(this.processStart()){e.next=6;break}return e.abrupt("return");case 6:if(this.validate(t)){e.next=8;break}return e.abrupt("return");case 8:return this.data=this.copy(t),this.args=r,e.next=12,regeneratorRuntime.awrap(this.processStartNode(n));case 12:return e.next=14,regeneratorRuntime.awrap(this.processUnreachable());case 14:return e.abrupt("return",this.processDone()?"success":"aborted");case 15:case"end":return e.stop()}},null,this)}}]),n}(L),Z=function(t){function n(){return v(this,n),b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,{nodecreate:[],nodecreated:[],noderemove:[],noderemoved:[],connectioncreate:[],connectioncreated:[],connectionremove:[],connectionremoved:[],nodetranslate:[],nodetranslated:[],selectnode:[],nodeselect:[],nodeselected:[],rendernode:[],rendersocket:[],rendercontrol:[],renderconnection:[],componentregister:[],keydown:[],keyup:[],translate:[],translated:[],zoom:[],zoomed:[],click:[],mousemove:[],contextmenu:[],import:[],export:[],process:[]}))}return w(n,t),n}(S),D=function(){function t(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){};v(this,t),this.mouseStart=null,this.el=n,this.onTranslate=e,this.onStart=r,this.onDrag=o,n.addEventListener("mousedown",this.mousedown.bind(this)),window.addEventListener("mousemove",this.mousemove.bind(this)),window.addEventListener("mouseup",this.mouseup.bind(this))}return m(t,[{key:"mousedown",value:function(t){t.stopPropagation(),this.mouseStart=[t.pageX,t.pageY],this.onStart()}},{key:"mousemove",value:function(t){if(this.mouseStart){t.preventDefault();var n=[t.pageX-this.mouseStart[0],t.pageY-this.mouseStart[1]],e=this.el.getBoundingClientRect().width/this.el.offsetWidth;this.mouseStart=[t.pageX,t.pageY],this.onTranslate(n[0]/e,n[1]/e)}}},{key:"mouseup",value:function(t){this.mouseStart=null,this.onDrag()}}]),t}(),J=function(){function t(n,e,r,o){v(this,t),this.el=e,this.intensity=r,this.onzoom=o,n.addEventListener("wheel",this.wheel.bind(this))}return m(t,[{key:"wheel",value:function(t){t.preventDefault();var n=this.el.getBoundingClientRect(),e=t.wheelDelta/120*this.intensity,r=(n.left-t.pageX)*e,o=(n.top-t.pageY)*e;this.onzoom(e,r,o)}}]),t}(),M=function(t){function n(t,e){if(v(this,n),!(e instanceof G))throw new TypeError('Value of argument "emitter" violates contract.\n\nExpected:\nEmitter\n\nGot:\n'+c(e));var r=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e)),o=r.el=document.createElement("div");return r.container=t,r.transform={k:1,x:0,y:0},r.mouse=[0,0],o.style.transformOrigin="0 0",r._drag=new D(t,r.onTranslate.bind(r)),r._zoom=new J(t,o,.1,r.onZoom.bind(r)),r.container.addEventListener("mousemove",r.mousemove.bind(r)),r.update(),r}return w(n,t),m(n,[{key:"update",value:function(){var t=this.transform;this.el.style.transform="translate("+t.x+"px, "+t.y+"px) scale("+t.k+")"}},{key:"mousemove",value:function(t){var n=this.el.getBoundingClientRect(),e=t.clientX-n.left,r=t.clientY-n.top,o=this.transform.k;this.trigger("mousemove",{x:e/o,y:r/o})}},{key:"onTranslate",value:function(t,n){this.translate(this.transform.x+t,this.transform.y+n)}},{key:"onZoom",value:function(t,n,e){this.zoom(this.transform.k*(1+t),n,e),this.update()}},{key:"translate",value:function(t,n){var e={transform:this.transform,x:t,y:n};this.trigger("translate",e)&&(this.transform.x=e.x,this.transform.y=e.y,this.update(),this.trigger("translated"))}},{key:"zoom",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r={transform:this.transform,zoom:t};this.trigger("zoom",r)&&(this.transform.k=r.zoom,this.transform.x+=n,this.transform.y+=e,this.update(),this.trigger("zoomed"))}},{key:"appendChild",value:function(t){this.el.appendChild(t)}},{key:"removeChild",value:function(t){this.el.removeChild(t)}}]),n}(G),z=function(t){function n(t,e,r){v(this,n);var o=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,r));return o.trigger("rendercontrol",{el:t,control:e}),o}return w(n,t),n}(G),B=function(t){function n(t,e,r,o,i){var a;v(this,n);var u=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,i));return u.el=t,u.type=e,u.io=r,u.node=o,u.trigger("rendersocket",(a={el:t},y(a,e,u.io),y(a,"socket",r.socket),a)),u}return w(n,t),m(n,[{key:"getPosition",value:function(t){var n=t.position,e=this.el;return[n[0]+e.offsetLeft+e.offsetWidth/2,n[1]+e.offsetTop+e.offsetHeight/2]}}]),n}(G),H=function(t){function n(t,e,r){v(this,n);var o=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,r));return o.node=t,o.component=e,o.sockets=new Map,o.controls=new Map,o.el=document.createElement("div"),o.el.style.position="absolute",o.el.addEventListener("contextmenu",function(t){return o.trigger("contextmenu",{e:t,node:o.node})}),o.drag=new D(o.el,o.onTranslate.bind(o),o.onSelect.bind(o)),o.trigger("rendernode",{el:o.el,node:t,component:e.data,bindSocket:o.bindSocket.bind(o),bindControl:o.bindControl.bind(o)}),o.update(),o}return w(n,t),m(n,[{key:"bindSocket",value:function(t,n,e){if(!(t instanceof HTMLElement))throw new TypeError('Value of argument "el" violates contract.\n\nExpected:\nHTMLElement\n\nGot:\n'+s(t));if("string"!=typeof n)throw new TypeError('Value of argument "type" violates contract.\n\nExpected:\nstring\n\nGot:\n'+s(n));if(!(e instanceof A))throw new TypeError('Value of argument "io" violates contract.\n\nExpected:\nIO\n\nGot:\n'+s(e));this.sockets.set(e,new B(t,n,e,this.node,this))}},{key:"bindControl",value:function(t,n){if(!(t instanceof HTMLElement))throw new TypeError('Value of argument "el" violates contract.\n\nExpected:\nHTMLElement\n\nGot:\n'+s(t));if(!(n instanceof O))throw new TypeError('Value of argument "control" violates contract.\n\nExpected:\nControl\n\nGot:\n'+s(n));this.controls.set(n,new z(t,n,this))}},{key:"getSocketPosition",value:function(t){return this.sockets.get(t).getPosition(this.node)}},{key:"onSelect",value:function(){this.trigger("selectnode",this.node)}},{key:"onTranslate",value:function(t,n){var e=this.node,r=e.position[0]+t,o=e.position[1]+n;this.trigger("nodetranslate",{node:e,x:r,y:o})&&(this.translate(r,o),this.trigger("nodetranslated",{node:e}))}},{key:"translate",value:function(t,n){this.node.position[0]=t,this.node.position[1]=n,this.update()}},{key:"update",value:function(){this.el.style.transform="translate("+this.node.position[0]+"px, "+this.node.position[1]+"px)"}},{key:"remove",value:function(){}}]),n}(G),W=function(t){function n(t,e,r,o){if(v(this,n),!(e instanceof H))throw new TypeError('Value of argument "inputNode" violates contract.\n\nExpected:\nViewNode\n\nGot:\n'+l(e));if(!(r instanceof H))throw new TypeError('Value of argument "outputNode" violates contract.\n\nExpected:\nViewNode\n\nGot:\n'+l(r));var i=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,o));return i.connection=t,i.inputNode=e,i.outputNode=r,i.el=document.createElement("div"),i.el.style.position="absolute",i.el.style.zIndex="-1",i.update(),i}return w(n,t),m(n,[{key:"update",value:function(){var t=this.outputNode.getSocketPosition(this.connection.output),n=E(t,2),e=n[0],r=n[1],o=this.inputNode.getSocketPosition(this.connection.input),i=E(o,2),a=i[0],u=i[1];this.trigger("renderconnection",{el:this.el,connection:this.connection,x1:e,y1:r,x2:a,y2:u})}}]),n}(G),Y=function(t){function n(t,e,r){if(v(this,n),!(t instanceof HTMLElement))throw new TypeError('Value of argument "container" violates contract.\n\nExpected:\nHTMLElement\n\nGot:\n'+f(t));if(!(e instanceof Object))throw new TypeError('Value of argument "components" violates contract.\n\nExpected:\nObject\n\nGot:\n'+f(e));if(!(r instanceof G))throw new TypeError('Value of argument "emitter" violates contract.\n\nExpected:\nEmitter\n\nGot:\n'+f(r));var o=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,r));return o.container=t,o.components=e,o.container.style.overflow="hidden",o.nodes=new Map,o.connections=new Map,o.container.addEventListener("click",o.click.bind(o)),o.container.addEventListener("contextmenu",function(t){return o.trigger("contextmenu",{e:t,view:o})}),window.addEventListener("resize",o.resize.bind(o)),o.on("nodetranslated",o.updateConnections.bind(o)),o.area=new M(t,o),o.container.appendChild(o.area.el),o}return w(n,t),m(n,[{key:"addNode",value:function(t){if(!(t instanceof C))throw new TypeError('Value of argument "node" violates contract.\n\nExpected:\nNode\n\nGot:\n'+f(t));var n=new H(t,this.components.get(t.name),this);this.nodes.set(t,n),this.area.appendChild(n.el)}},{key:"removeNode",value:function(t){if(!(t instanceof C))throw new TypeError('Value of argument "node" violates contract.\n\nExpected:\nNode\n\nGot:\n'+f(t));var n=this.nodes.get(t);this.nodes.delete(t),this.area.removeChild(n.el)}},{key:"addConnection",value:function(t){if(!(t instanceof j))throw new TypeError('Value of argument "connection" violates contract.\n\nExpected:\nConnection\n\nGot:\n'+f(t));var n=this.nodes.get(t.input.node),e=this.nodes.get(t.output.node),r=new W(t,n,e,this);this.connections.set(t,r),this.area.appendChild(r.el)}},{key:"removeConnection",value:function(t){if(!(t instanceof j))throw new TypeError('Value of argument "connection" violates contract.\n\nExpected:\nConnection\n\nGot:\n'+f(t));var n=this.connections.get(t);this.connections.delete(t),this.area.removeChild(n.el)}},{key:"updateConnections",value:function(t){var n=this;t.node.getConnections().map(function(t){n.connections.get(t).update()})}},{key:"resize",value:function(){var t=this.container,n=t.parentElement.clientWidth,e=t.parentElement.clientHeight;t.style.width=n+"px",t.style.height=e+"px"}},{key:"click",value:function(t){var n=this.container;n===t.target&&this.trigger("click",{e:t,container:n})}}]),n}(G),F=function(){function t(){v(this,t),this.list=[]}return m(t,[{key:"add",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!(t instanceof C))throw new TypeError('Value of argument "item" violates contract.\n\nExpected:\nNode\n\nGot:\n'+h(t));n?this.contains(t)?this.remove(t):this.list.push(t):this.list=[t]}},{key:"clear",value:function(){var t=this;this.each(function(n){t.remove(n)})}},{key:"remove",value:function(t){this.list.splice(this.list.indexOf(t),1)}},{key:"contains",value:function(t){return-1!==this.list.indexOf(t)}},{key:"each",value:function(t){this.list.forEach(t)}}]),t}(),X=function(t){function n(t,e){if(v(this,n),"string"!=typeof t)throw new TypeError('Value of argument "id" violates contract.\n\nExpected:\nstring\n\nGot:\n'+p(t));if(!(e instanceof HTMLElement))throw new TypeError('Value of argument "container" violates contract.\n\nExpected:\nHTMLElement\n\nGot:\n'+p(e));var r=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,new Z));return r.nodes=[],r.components=new Map,r.selected=new F,r.view=new Y(e,r.components,r),window.addEventListener("keydown",function(t){return r.trigger("keydown",t)}),window.addEventListener("keyup",function(t){return r.trigger("keyup",t)}),r.on("nodecreated",function(t){return r.getComponent(t.name).created(t)}),r.on("noderemoved",function(t){return r.getComponent(t.name).destroyed(t)}),r.on("selectnode",function(t){return r.selectNode(t)}),r}return w(n,t),m(n,[{key:"addNode",value:function(t){if(!(t instanceof C))throw new TypeError('Value of argument "node" violates contract.\n\nExpected:\nNode\n\nGot:\n'+p(t));this.trigger("nodecreate",t)&&(this.nodes.push(t),this.view.addNode(t),this.trigger("nodecreated",t))}},{key:"removeNode",value:function(t){var n=this;if(!(t instanceof C))throw new TypeError('Value of argument "node" violates contract.\n\nExpected:\nNode\n\nGot:\n'+p(t));this.trigger("noderemove",t)&&(t.getConnections().forEach(function(t){return n.removeConnection(t)}),this.nodes.splice(this.nodes.indexOf(t),1),this.view.removeNode(t),this.trigger("noderemoved",t))}},{key:"connect",value:function(t,n){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!(t instanceof N))throw new TypeError('Value of argument "output" violates contract.\n\nExpected:\nOutput\n\nGot:\n'+p(t));if(!(n instanceof T))throw new TypeError('Value of argument "input" violates contract.\n\nExpected:\nInput\n\nGot:\n'+p(n));if(this.trigger("connectioncreate",{output:t,input:n}))try{var r=t.connectTo(n);r.data=e,this.view.addConnection(r),this.trigger("connectioncreated",r)}catch(t){this.trigger("warn",t)}}},{key:"removeConnection",value:function(t){if(!(t instanceof j))throw new TypeError('Value of argument "connection" violates contract.\n\nExpected:\nConnection\n\nGot:\n'+p(t));this.trigger("connectionremove",t)&&(this.view.removeConnection(t),t.remove(),this.trigger("connectionremoved",t))}},{key:"selectNode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!(t instanceof C))throw new TypeError('Value of argument "node" violates contract.\n\nExpected:\nNode\n\nGot:\n'+p(t));if("boolean"!=typeof n)throw new TypeError('Value of argument "accumulate" violates contract.\n\nExpected:\nboolean\n\nGot:\n'+p(n));if(-1===this.nodes.indexOf(t))throw new Error("Node not exist in list");this.trigger("nodeselect",t)&&(this.selected.add(t,n),this.trigger("nodeselected",t))}},{key:"getComponent",value:function(t){var n=this.components.get(t);if(!n)throw"Component "+t+" not found";return n}},{key:"register",value:function(t){if(!(t instanceof V))throw new TypeError('Value of argument "component" violates contract.\n\nExpected:\nComponent\n\nGot:\n'+p(t));t.editor=this,this.components.set(t.name,t),this.trigger("componentregister",t)}},{key:"clear",value:function(){var t=this;[].concat(k(this.nodes)).map(function(n){return t.removeNode(n)})}},{key:"toJSON",value:function(){var t={id:this.id,nodes:{}};return this.nodes.forEach(function(n){return t.nodes[n.id]=n.toJSON()}),this.trigger("export",t),t}},{key:"beforeImport",value:function(t){if(!(t instanceof Object))throw new TypeError('Value of argument "json" violates contract.\n\nExpected:\nObject\n\nGot:\n'+p(t));var n=R.validate(this.id,t);return n.success?(this.clear(),this.silent=!0,this.trigger("import",t),!0):(this.trigger("warn",n.msg),!1)}},{key:"afterImport",value:function(){return this.silent=!1,!0}},{key:"fromJSON",value:function(t){var n,e=this;return regeneratorRuntime.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t instanceof Object){r.next=2;break}throw new TypeError('Value of argument "json" violates contract.\n\nExpected:\nObject\n\nGot:\n'+p(t));case 2:if(this.beforeImport(t)){r.next=4;break}return r.abrupt("return",!1);case 4:return n={},r.prev=5,r.next=8,regeneratorRuntime.awrap(Promise.all(Object.keys(t.nodes).map(function(r){var o,i;return regeneratorRuntime.async(function(a){for(;;)switch(a.prev=a.next){case 0:return o=t.nodes[r],i=e.getComponent(o.name),a.next=4,regeneratorRuntime.awrap(i.build(C.fromJSON(o)));case 4:n[r]=a.sent,e.addNode(n[r]);case 6:case"end":return a.stop()}},null,e)})));case 8:Object.keys(t.nodes).forEach(function(r){var o=t.nodes[r],i=n[r];o.outputs.forEach(function(t,r){t.connections.forEach(function(t){var o=t.node,a=t.data,u=t.input,c=n[o].inputs[u];e.connect(i.outputs[r],c,a)})})}),r.next=15;break;case 11:return r.prev=11,r.t0=r.catch(5),this.trigger("warn",r.t0),r.abrupt("return",!1);case 15:return r.abrupt("return",this.afterImport());case 16:case"end":return r.stop()}},null,this,[[5,11]])}}]),n}(L);return{Component:V,Control:O,NodeEditor:X,Emitter:G,Engine:$,Input:T,Node:C,Output:N,Socket:_}});
!function(t){"use strict";function n(t,n,e,o){var i=n&&n.prototype instanceof r?n:r,a=Object.create(i.prototype),u=new h(o||[]);return a._invoke=c(t,e,u),a}function e(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}function r(){}function o(){}function i(){}function a(t){["next","throw","return"].forEach(function(n){t[n]=function(t){return this._invoke(n,t)}})}function u(t){function n(r,o,i,a){var u=e(t[r],t,o);if("throw"!==u.type){var c=u.arg,s=c.value;return s&&"object"==typeof s&&y.call(s,"__await")?Promise.resolve(s.__await).then(function(t){n("next",t,i,a)},function(t){n("throw",t,i,a)}):Promise.resolve(s).then(function(t){c.value=t,i(c)},a)}a(u.arg)}function r(t,e){function r(){return new Promise(function(r,o){n(t,e,r,o)})}return o=o?o.then(r,r):r()}var o;this._invoke=r}function c(t,n,r){var o=O;return function(i,a){if(o===A)throw new Error("Generator is already running");if(o===_){if("throw"===i)throw a;return d()}for(r.method=i,r.arg=a;;){var u=r.delegate;if(u){var c=s(u,r);if(c){if(c===T)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===O)throw o=_,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=A;var f=e(t,n,r);if("normal"===f.type){if(o=r.done?_:j,f.arg===T)continue;return{value:f.arg,done:r.done}}"throw"===f.type&&(o=_,r.method="throw",r.arg=f.arg)}}}function s(t,n){var r=t.iterator[n.method];if(r===m){if(n.delegate=null,"throw"===n.method){if(t.iterator.return&&(n.method="return",n.arg=m,s(t,n),"throw"===n.method))return T;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return T}var o=e(r,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,T;var i=o.arg;return i?i.done?(n[t.resultName]=i.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=m),n.delegate=null,T):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,T)}function f(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function l(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function h(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(f,this),this.reset(!0)}function p(t){if(t){var n=t[w];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,r=function n(){for(;++e<t.length;)if(y.call(t,e))return n.value=t[e],n.done=!1,n;return n.value=m,n.done=!0,n};return r.next=r}}return{next:d}}function d(){return{value:m,done:!0}}var m,v=Object.prototype,y=v.hasOwnProperty,g="function"==typeof Symbol?Symbol:{},w=g.iterator||"@@iterator",b=g.asyncIterator||"@@asyncIterator",E=g.toStringTag||"@@toStringTag",k="object"==typeof module,x=t.regeneratorRuntime;if(x)return void(k&&(module.exports=x));x=t.regeneratorRuntime=k?module.exports:{},x.wrap=n;var O="suspendedStart",j="suspendedYield",A="executing",_="completed",T={},N={};N[w]=function(){return this};var C=Object.getPrototypeOf,V=C&&C(C(p([])));V&&V!==v&&y.call(V,w)&&(N=V);var S=i.prototype=r.prototype=Object.create(N);o.prototype=S.constructor=i,i.constructor=o,i[E]=o.displayName="GeneratorFunction",x.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===o||"GeneratorFunction"===(n.displayName||n.name))},x.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,i):(t.__proto__=i,E in t||(t[E]="GeneratorFunction")),t.prototype=Object.create(S),t},x.awrap=function(t){return{__await:t}},a(u.prototype),u.prototype[b]=function(){return this},x.AsyncIterator=u,x.async=function(t,e,r,o){var i=new u(n(t,e,r,o));return x.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},a(S),S[E]="Generator",S[w]=function(){return this},S.toString=function(){return"[object Generator]"},x.keys=function(t){var n=[];for(var e in t)n.push(e);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},x.values=p,h.prototype={constructor:h,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=m,this.done=!1,this.delegate=null,this.method="next",this.arg=m,this.tryEntries.forEach(l),!t)for(var n in this)"t"===n.charAt(0)&&y.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=m)},stop:function(){this.done=!0;var t=this.tryEntries[0],n=t.completion;if("throw"===n.type)throw n.arg;return this.rval},dispatchException:function(t){function n(n,r){return i.type="throw",i.arg=t,e.next=n,r&&(e.method="next",e.arg=m),!!r}if(this.done)throw t;for(var e=this,r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],i=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var a=y.call(o,"catchLoc"),u=y.call(o,"finallyLoc");if(a&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,n){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc<=this.prev&&y.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=n&&n<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=n,o?(this.method="next",this.next=o.finallyLoc,T):this.complete(i)},complete:function(t,n){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&n&&(this.next=n),T},finish:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),l(e),T}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.tryLoc===t){var r=e.completion;if("throw"===r.type){var o=r.arg;l(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,e){return this.delegate={iterator:p(t),resultName:n,nextLoc:e},"next"===this.method&&(this.arg=m),T}}}(function(){return this}()||Function("return this")()),function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.Rete=n()}(this,function(){"use strict";function t(n,e){if(void 0===e&&(e=0),e+=1,null===n)return"null";if(void 0===n)return"void";if("string"==typeof n||"number"==typeof n||"boolean"==typeof n)return void 0===n?"undefined":d(n);if(Array.isArray(n)){if(n.length>0){if(e>4)return"[...]";var r=t(n[0],e);return n.every(function(n){return t(n,e)===r})?r.trim()+"[]":"["+n.slice(0,15).map(function(n){return t(n,e)}).join(", ")+(n.length>=15?", ...":"")+"]"}return"Array"}var o=Object.keys(n);if(!o.length)return n.constructor&&n.constructor.name&&"Object"!==n.constructor.name?n.constructor.name:"Object";if(e>4)return"{...}";var i=" ".repeat(e-1),a=o.slice(0,15).map(function(r){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(r)?r:JSON.stringify(r))+": "+t(n[r],e)+";"}).join("\n "+i);return o.length>=15&&(a+="\n "+i+"..."),n.constructor&&n.constructor.name&&"Object"!==n.constructor.name?n.constructor.name+" {\n "+i+a+"\n"+i+"}":"{\n "+i+a+"\n"+i+"}"}function n(t,e){if(void 0===e&&(e=0),e+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(e>4)return"[...]";var r=n(t[0],e);return t.every(function(t){return n(t,e)===r})?r.trim()+"[]":"["+t.slice(0,15).map(function(t){return n(t,e)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var o=Object.keys(t);if(!o.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(e>4)return"{...}";var i=" ".repeat(e-1),a=o.slice(0,15).map(function(r){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(r)?r:JSON.stringify(r))+": "+n(t[r],e)+";"}).join("\n "+i);return o.length>=15&&(a+="\n "+i+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+i+a+"\n"+i+"}":"{\n "+i+a+"\n"+i+"}"}function e(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var r=e(t[0],n);return t.every(function(t){return e(t,n)===r})?r.trim()+"[]":"["+t.slice(0,15).map(function(t){return e(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var o=Object.keys(t);if(!o.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var i=" ".repeat(n-1),a=o.slice(0,15).map(function(r){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(r)?r:JSON.stringify(r))+": "+e(t[r],n)+";"}).join("\n "+i);return o.length>=15&&(a+="\n "+i+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+i+a+"\n"+i+"}":"{\n "+i+a+"\n"+i+"}"}function r(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=r(t[0],n);return t.every(function(t){return r(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return r(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var o=Object.keys(t);if(!o.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var i=" ".repeat(n-1),a=o.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+r(t[e],n)+";"}).join("\n "+i);return o.length>=15&&(a+="\n "+i+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+i+a+"\n"+i+"}":"{\n "+i+a+"\n"+i+"}"}function o(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=o(t[0],n);return t.every(function(t){return o(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return o(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var i=" ".repeat(n-1),a=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+o(t[e],n)+";"}).join("\n "+i);return r.length>=15&&(a+="\n "+i+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+i+a+"\n"+i+"}":"{\n "+i+a+"\n"+i+"}"}function i(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=i(t[0],n);return t.every(function(t){return i(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return i(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),a=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+i(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(a+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+a+"\n"+o+"}":"{\n "+o+a+"\n"+o+"}"}function a(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=a(t[0],n);return t.every(function(t){return a(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return a(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+a(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function u(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=u(t[0],n);return t.every(function(t){return u(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return u(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+u(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function c(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=c(t[0],n);return t.every(function(t){return c(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return c(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+c(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function s(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=s(t[0],n);return t.every(function(t){return s(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return s(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+s(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function f(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=f(t[0],n);return t.every(function(t){return f(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return f(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+f(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function l(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=l(t[0],n);return t.every(function(t){return l(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return l(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+l(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function h(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=h(t[0],n);return t.every(function(t){return h(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return h(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+h(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}function p(t,n){if(void 0===n&&(n=0),n+=1,null===t)return"null";if(void 0===t)return"void";if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return void 0===t?"undefined":d(t);if(Array.isArray(t)){if(t.length>0){if(n>4)return"[...]";var e=p(t[0],n);return t.every(function(t){return p(t,n)===e})?e.trim()+"[]":"["+t.slice(0,15).map(function(t){return p(t,n)}).join(", ")+(t.length>=15?", ...":"")+"]"}return"Array"}var r=Object.keys(t);if(!r.length)return t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name:"Object";if(n>4)return"{...}";var o=" ".repeat(n-1),i=r.slice(0,15).map(function(e){return(/^([A-Z_$][A-Z0-9_$]*)$/i.test(e)?e:JSON.stringify(e))+": "+p(t[e],n)+";"}).join("\n "+o);return r.length>=15&&(i+="\n "+o+"..."),t.constructor&&t.constructor.name&&"Object"!==t.constructor.name?t.constructor.name+" {\n "+o+i+"\n"+o+"}":"{\n "+o+i+"\n"+o+"}"}var d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m=function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")},v=function(){function t(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(n,e,r){return e&&t(n.prototype,e),r&&t(n,r),n}}(),y=function(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t},g=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},w=function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function, not "+typeof n);t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),n&&(Object.setPrototypeOf?Object.setPrototypeOf(t,n):t.__proto__=n)},b=function(t,n){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!n||"object"!=typeof n&&"function"!=typeof n?t:n},E=function(){function t(t,n){var e=[],r=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(e.push(a.value),!n||e.length!==n);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&u.return&&u.return()}finally{if(o)throw i}}return e}return function(n,e){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return t(n,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),k=function(t){if(Array.isArray(t)){for(var n=0,e=Array(t.length);n<t.length;n++)e[n]=t[n];return e}return Array.from(t)},x=function(){function t(n){if(m(this,t),this.constructor===t)throw new TypeError("Can not construct abstract class.");this.name=n,this.data={},this.engine=null}return v(t,[{key:"worker",value:function(){}}]),t}(),O=function(){function t(){if(m(this,t),this.constructor===t)throw new TypeError("Can not construct abstract class.");this.data={},this.parent=null}return v(t,[{key:"getNode",value:function(){if(null===this.parent)throw new Error("Control isn't added to Node/Input");return this.parent instanceof C?this.parent:this.parent.node}},{key:"getData",value:function(t){return this.getNode().data[t]}},{key:"putData",value:function(t,n){this.getNode().data[t]=n}}]),t}(),j=function(){function t(n,e){m(this,t),this.output=n,this.input=e,this.data={},this.input.addConnection(this)}return v(t,[{key:"remove",value:function(){this.input.removeConnection(this),this.output.removeConnection(this)}}]),t}(),A=function(){function n(t,e,r){m(this,n),this.node=null,this.multipleConnections=r,this.connections=[],this.name=t,this.socket=e}return v(n,[{key:"removeConnection",value:function(n){if(!(n instanceof j))throw new TypeError('Value of argument "connection" violates contract.\n\nExpected:\nConnection\n\nGot:\n'+t(n));this.connections.splice(this.connections.indexOf(n),1)}},{key:"removeConnections",value:function(){var t=this;this.connections.map(function(n){return t.removeConnection(n)})}}]),n}(),_=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(m(this,t),"string"!=typeof e)throw new TypeError('Value of argument "name" violates contract.\n\nExpected:\nstring\n\nGot:\n'+n(e));this.name=e,this.data=r,this.compatible=[]}return v(t,[{key:"combineWith",value:function(e){if(!(e instanceof t))throw new TypeError('Value of argument "socket" violates contract.\n\nExpected:\nSocket\n\nGot:\n'+n(e));this.compatible.push(e)}},{key:"compatibleWith",value:function(e){if(!(e instanceof t))throw new TypeError('Value of argument "socket" violates contract.\n\nExpected:\nSocket\n\nGot:\n'+n(e));return this===e||this.compatible.includes(e)}}]),t}(),T=function(t){function n(t,r){var o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(m(this,n),"string"!=typeof t)throw new TypeError('Value of argument "title" violates contract.\n\nExpected:\nstring\n\nGot:\n'+e(t));if(!(r instanceof _))throw new TypeError('Value of argument "socket" violates contract.\n\nExpected:\nSocket\n\nGot:\n'+e(r));if("boolean"!=typeof o)throw new TypeError('Value of argument "multiConns" violates contract.\n\nExpected:\nboolean\n\nGot:\n'+e(o));var i=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,r,o));return i.control=null,i}return w(n,t),v(n,[{key:"hasConnection",value:function(){return this.connections.length>0}},{key:"addConnection",value:function(t){if(!(t instanceof j))throw new TypeError('Value of argument "connection" violates contract.\n\nExpected:\nConnection\n\nGot:\n'+e(t));if(!this.multipleConnections&&this.hasConnection())throw new Error("Multiple connections not allowed");this.connections.push(t)}},{key:"addControl",value:function(t){if(!(t instanceof O))throw new TypeError('Value of argument "control" violates contract.\n\nExpected:\nControl\n\nGot:\n'+e(t));this.control=t,t.parent=this}},{key:"showControl",value:function(){return!this.hasConnection()&&null!==this.control}},{key:"toJSON",value:function(){return{connections:this.connections.map(function(t){return{node:t.output.node.id,output:t.output.node.outputs.indexOf(t.output),data:t.data}})}}}]),n}(A),N=function(t){function n(t,e){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(m(this,n),"string"!=typeof t)throw new TypeError('Value of argument "title" violates contract.\n\nExpected:\nstring\n\nGot:\n'+r(t));if(!(e instanceof _))throw new TypeError('Value of argument "socket" violates contract.\n\nExpected:\nSocket\n\nGot:\n'+r(e));if("boolean"!=typeof o)throw new TypeError('Value of argument "multiConns" violates contract.\n\nExpected:\nboolean\n\nGot:\n'+r(o));return b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e,o))}return w(n,t),v(n,[{key:"hasConnection",value:function(){return this.connections.length>0}},{key:"connectTo",value:function(t){if(!(t instanceof T))throw new TypeError('Value of argument "input" violates contract.\n\nExpected:\nInput\n\nGot:\n'+r(t));if(!this.socket.compatibleWith(t.socket))throw new Error("Sockets not compatible");if(!t.multipleConnections&&t.hasConnection())throw new Error("Input already has one connection");if(!this.multipleConnections&&this.hasConnection())throw new Error("Output already has one connection");var n=new j(this,t);return this.connections.push(n),n}},{key:"connectedTo",value:function(t){if(!(t instanceof T))throw new TypeError('Value of argument "input" violates contract.\n\nExpected:\nInput\n\nGot:\n'+r(t));return this.connections.some(function(n){return n.input===t})}},{key:"toJSON",value:function(){return{connections:this.connections.map(function(t){return{node:t.input.node.id,input:t.input.node.inputs.indexOf(t.input),data:t.data}})}}}]),n}(A),C=function(){function t(n){if(m(this,t),"string"!=typeof n)throw new TypeError('Value of argument "name" violates contract.\n\nExpected:\nstring\n\nGot:\n'+o(n));this.name=n,this.id=t.incrementId(),this.position=[0,0],this.inputs=[],this.outputs=[],this.controls=[],this.data={},this.meta={}}return v(t,[{key:"addControl",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.controls.length;if(!(t instanceof O))throw new TypeError('Value of argument "control" violates contract.\n\nExpected:\nControl\n\nGot:\n'+o(t));if(!(null==n||"number"==typeof n&&!isNaN(n)&&n>=0&&n<=255&&n===Math.floor(n)))throw new TypeError('Value of argument "index" violates contract.\n\nExpected:\n?uint8\n\nGot:\n'+o(n));return t.parent=this,this.controls.splice(n,0,t),this}},{key:"removeControl",value:function(t){if(!(t instanceof O))throw new TypeError('Value of argument "control" violates contract.\n\nExpected:\nControl\n\nGot:\n'+o(t));t.parent=null,this.controls.splice(this.controls.indexOf(t),1)}},{key:"addInput",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.inputs.length;if(!(t instanceof T))throw new TypeError('Value of argument "input" violates contract.\n\nExpected:\nInput\n\nGot:\n'+o(t));if(!(null==n||"number"==typeof n&&!isNaN(n)&&n>=0&&n<=255&&n===Math.floor(n)))throw new TypeError('Value of argument "index" violates contract.\n\nExpected:\n?uint8\n\nGot:\n'+o(n));if(null!==t.node)throw new Error("Input has already been added to the node");return t.node=this,this.inputs.splice(n,0,t),this}},{key:"removeInput",value:function(t){if(!(t instanceof T))throw new TypeError('Value of argument "input" violates contract.\n\nExpected:\nInput\n\nGot:\n'+o(t));t.removeConnections(),t.node=null,this.inputs.splice(this.inputs.indexOf(t),1)}},{key:"addOutput",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.outputs.length;if(!(t instanceof N))throw new TypeError('Value of argument "output" violates contract.\n\nExpected:\nOutput\n\nGot:\n'+o(t));if(!(null==n||"number"==typeof n&&!isNaN(n)&&n>=0&&n<=255&&n===Math.floor(n)))throw new TypeError('Value of argument "index" violates contract.\n\nExpected:\n?uint8\n\nGot:\n'+o(n));if(null!==t.node)throw new Error("Output has already been added to the node");return t.node=this,this.outputs.splice(n,0,t),this}},{key:"removeOutput",value:function(t){if(!(t instanceof N))throw new TypeError('Value of argument "output" violates contract.\n\nExpected:\nOutput\n\nGot:\n'+o(t));t.removeConnections(),t.node=null,this.outputs.splice(this.outputs.indexOf(t),1)}},{key:"getConnections",value:function(){return[].concat(k(this.inputs),k(this.outputs)).reduce(function(t,n){return[].concat(k(t),k(n.connections))},[])}},{key:"inputsWithVisibleControl",value:function(){return this.inputs.filter(function(t){return t.showControl()})}},{key:"toJSON",value:function(){return{id:this.id,data:this.data,inputs:this.inputs.map(function(t){return t.toJSON()}),outputs:this.outputs.map(function(t){return t.toJSON()}),position:this.position,name:this.name}}}],[{key:"incrementId",value:function(){return this.latestId?this.latestId++:this.latestId=1,this.latestId}},{key:"fromJSON",value:function(n){if(!(n instanceof Object))throw new TypeError('Value of argument "json" violates contract.\n\nExpected:\nObject\n\nGot:\n'+o(n));var e=new t(n.name);return e.id=n.id,e.data=n.data,e.position=n.position,e.name=n.name,t.latestId=Math.max(e.id,t.latestId),e}}]),t}(),V=function(t){function n(t){m(this,n);var e=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t));if(e.constructor===n)throw new TypeError("Can not construct abstract class.");return e.editor=null,e.data={},e}return w(n,t),v(n,[{key:"builder",value:function(){return regeneratorRuntime.async(function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}},null,this)}},{key:"created",value:function(){}},{key:"destroyed",value:function(){}},{key:"build",value:function(t){return regeneratorRuntime.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t instanceof C){n.next=2;break}throw new TypeError('Value of argument "node" violates contract.\n\nExpected:\nNode\n\nGot:\n'+i(t));case 2:return n.next=4,regeneratorRuntime.awrap(this.builder(t));case 4:return n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this)}},{key:"createNode",value:function(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return t=new C(this.name),t.data=n,e.next=4,regeneratorRuntime.awrap(this.build(t));case 4:return e.abrupt("return",t);case 5:case"end":return e.stop()}},null,this)}}]),n}(x),S=function t(n){m(this,t),this.handlers=g({warn:[console.warn],error:[console.error]},n)},G=function(){function t(n){if(m(this,t),!(n instanceof S||n instanceof t))throw new TypeError('Value of argument "events" violates contract.\n\nExpected:\nEvents | Emitter\n\nGot:\n'+a(n));this.events=n instanceof t?n.events:n.handlers,this.silent=!1}return v(t,[{key:"on",value:function(t,n){var e=this;if("string"!=typeof t)throw new TypeError('Value of argument "names" violates contract.\n\nExpected:\nstring\n\nGot:\n'+a(t));if("function"!=typeof n)throw new TypeError('Value of argument "handler" violates contract.\n\nExpected:\n() => {}\n\nGot:\n'+a(n));return t.split(" ").forEach(function(t){if(!e.events[t])throw new Error("The event "+t+" does not exist");e.events[t].push(n)}),this}},{key:"trigger",value:function(t,n){if("string"!=typeof t)throw new TypeError('Value of argument "name" violates contract.\n\nExpected:\nstring\n\nGot:\n'+a(t));if(!(t in this.events))throw new Error("The event "+t+" cannot be triggered");return this.events[t].reduce(function(t,e){return!1!==e(n)&&t},!0)}}]),t}(),R=function(){function t(){m(this,t)}return v(t,null,[{key:"isValidData",
value:function(t){return"string"==typeof t.id&&this.isValidId(t.id)&&t.nodes instanceof Object&&!(t.nodes instanceof Array)}},{key:"isValidId",value:function(t){return/^[\w-]{3,}@[0-9]+\.[0-9]+\.[0-9]+$/.test(t)}},{key:"validate",value:function(t,n){var e="",r=t.split("@"),o=n.id.split("@");return this.isValidData(n)||(e+="Data is not suitable. "),t!==n.id&&(e+="IDs not equal. "),r[0]!==o[0]&&(e+="Names don't match. "),r[1]!==o[1]&&(e+="Versions don't match"),{success:""===e,msg:e}}}]),t}(),L=function(t){function n(t,e){m(this,n);var r=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));if(!R.isValidId(t))throw new Error("ID should be valid to name@0.1.0 format");return r.id=t,r}return w(n,t),v(n,[{key:"use",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.install(this,n)}}]),n}(G),P=function(t){function n(){return m(this,n),b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,{componentregister:[]}))}return w(n,t),n}(S),I={AVALIABLE:0,PROCESSED:1,ABORT:2},$=function(t){function n(t){if(m(this,n),"string"!=typeof t)throw new TypeError('Value of argument "id" violates contract.\n\nExpected:\nstring\n\nGot:\n'+u(t));var e=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,new P));return e.components=[],e.args=[],e.data=null,e.state=I.AVALIABLE,e.onAbort=function(){},e}return w(n,t),v(n,[{key:"clone",value:function(){var t=new n(this.id);return this.components.map(function(n){return t.register(n)}),t}},{key:"register",value:function(t){if(!(t instanceof x))throw new TypeError('Value of argument "component" violates contract.\n\nExpected:\nComponent\n\nGot:\n'+u(t));this.components.push(t),this.trigger("componentregister",t)}},{key:"throwError",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,regeneratorRuntime.awrap(this.abort());case 2:return this.trigger("error",{message:t,data:n}),this.processDone(),e.abrupt("return","error");case 5:case"end":return e.stop()}},null,this)}},{key:"extractInputNodes",value:function(t,n){return t.inputs.reduce(function(t,e){return[].concat(k(t),k((e.connections||[]).reduce(function(t,e){return[].concat(k(t),[n[e.node]])},[])))},[])}},{key:"detectRecursions",value:function(t){var n=this,e=function e(r,o){if(o.some(function(t){return t===r}))return r;for(var i=0;i<o.length;i++)if(e(r,n.extractInputNodes(o[i],t)))return r;return null};return Object.keys(t).map(function(n){return t[n]}).map(function(r){return e(r,n.extractInputNodes(r,t))}).filter(function(t){return null!==t})}},{key:"processStart",value:function(){return this.state===I.AVALIABLE?(this.state=I.PROCESSED,!0):this.state!==I.ABORT&&(console.warn("The process is busy and has not been restarted.\n Use abort() to force it to complete"),!1)}},{key:"processDone",value:function(){var t=this.state!==I.ABORT;return this.state=I.AVALIABLE,t||(this.onAbort(),this.onAbort=function(){}),t}},{key:"abort",value:function(){var t=this;return regeneratorRuntime.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise(function(n){t.state===I.PROCESSED?(t.state=I.ABORT,t.onAbort=n):t.state===I.ABORT?(t.onAbort(),t.onAbort=n):n()}));case 1:case"end":return n.stop()}},null,this)}},{key:"lock",value:function(t){return regeneratorRuntime.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",new Promise(function(n){t.unlockPool=t.unlockPool||[],t.busy&&!t.outputData?t.unlockPool.push(n):n(),t.busy=!0}));case 1:case"end":return n.stop()}},null,this)}},{key:"unlock",value:function(t){t.unlockPool.forEach(function(t){return t()}),t.unlockPool=[],t.busy=!1}},{key:"extractInputData",value:function(t){var n=this;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,regeneratorRuntime.awrap(Promise.all(t.inputs.map(function(t){var e,r;return regeneratorRuntime.async(function(o){for(;;)switch(o.prev=o.next){case 0:return e=t.connections,o.next=3,regeneratorRuntime.awrap(Promise.all(e.map(function(t){var e,r;return regeneratorRuntime.async(function(o){for(;;)switch(o.prev=o.next){case 0:return e=n.data.nodes[t.node],o.next=3,regeneratorRuntime.awrap(n.processNode(e));case 3:if(r=o.sent){o.next=8;break}n.abort(),o.next=9;break;case 8:return o.abrupt("return",r[t.output]);case 9:case"end":return o.stop()}},null,n)})));case 3:return r=o.sent,o.abrupt("return",r);case 5:case"end":return o.stop()}},null,n)})));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},null,this)}},{key:"processWorker",value:function(t){var n,e,r;return regeneratorRuntime.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,regeneratorRuntime.awrap(this.extractInputData(t));case 2:return n=o.sent,e=this.components.find(function(n){return n.name===t.name}),r=t.outputs.map(function(){return null}),o.prev=5,o.next=8,regeneratorRuntime.awrap(e.worker.apply(e,[t,n,r].concat(k(this.args))));case 8:o.next=14;break;case 10:o.prev=10,o.t0=o.catch(5),this.abort(),this.trigger("warn",o.t0);case 14:return o.abrupt("return",r);case 15:case"end":return o.stop()}},null,this,[[5,10]])}},{key:"processNode",value:function(t){return regeneratorRuntime.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.state!==I.ABORT&&t){n.next=2;break}return n.abrupt("return",null);case 2:return n.next=4,regeneratorRuntime.awrap(this.lock(t));case 4:return t.outputData||(t.outputData=this.processWorker(t)),this.unlock(t),n.abrupt("return",t.outputData);case 7:case"end":return n.stop()}},null,this)}},{key:"forwardProcess",value:function(t){var n=this;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.state!==I.ABORT){e.next=2;break}return e.abrupt("return",null);case 2:return e.next=4,regeneratorRuntime.awrap(Promise.all(t.outputs.map(function(t){return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,regeneratorRuntime.awrap(Promise.all(t.connections.map(function(t){var e;return regeneratorRuntime.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=n.data.nodes[t.node],r.next=3,regeneratorRuntime.awrap(n.processNode(e));case 3:return r.next=5,regeneratorRuntime.awrap(n.forwardProcess(e));case 5:case"end":return r.stop()}},null,n)})));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},null,n)})));case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}},null,this)}},{key:"copy",value:function(t){return t=Object.assign({},t),t.nodes=Object.assign({},t.nodes),Object.keys(t.nodes).forEach(function(n){t.nodes[n]=Object.assign({},t.nodes[n])}),t}},{key:"validate",value:function(t){var n,e;return regeneratorRuntime.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(n=R.validate(this.id,t),n.success){r.next=5;break}return r.next=4,regeneratorRuntime.awrap(this.throwError(n.msg));case 4:return r.abrupt("return",r.sent);case 5:if(e=this.detectRecursions(t.nodes),!(e.length>0)){r.next=10;break}return r.next=9,regeneratorRuntime.awrap(this.throwError("Recursion detected",e));case 9:return r.abrupt("return",r.sent);case 10:return r.abrupt("return",!0);case 11:case"end":return r.stop()}},null,this)}},{key:"processStartNode",value:function(t){var n;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=10;break}if(n=this.data.nodes[t]){e.next=6;break}return e.next=5,regeneratorRuntime.awrap(this.throwError("Node with such id not found"));case 5:return e.abrupt("return",e.sent);case 6:return e.next=8,regeneratorRuntime.awrap(this.processNode(n));case 8:return e.next=10,regeneratorRuntime.awrap(this.forwardProcess(n));case 10:case"end":return e.stop()}},null,this)}},{key:"processUnreachable",value:function(){var t,n;return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=regeneratorRuntime.keys(this.data.nodes);case 1:if((e.t1=e.t0()).done){e.next=11;break}if(t=e.t1.value,void 0!==this.data.nodes[t].outputData){e.next=9;break}return n=this.data.nodes[t],e.next=7,regeneratorRuntime.awrap(this.processNode(n));case 7:return e.next=9,regeneratorRuntime.awrap(this.forwardProcess(n));case 9:e.next=1;break;case 11:case"end":return e.stop()}},null,this)}},{key:"process",value:function(t){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,e=arguments.length,r=Array(e>2?e-2:0),o=2;o<e;o++)r[o-2]=arguments[o];return regeneratorRuntime.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(t instanceof Object){e.next=2;break}throw new TypeError('Value of argument "data" violates contract.\n\nExpected:\nObject\n\nGot:\n'+u(t));case 2:if(null==n||"number"==typeof n){e.next=4;break}throw new TypeError('Value of argument "startId" violates contract.\n\nExpected:\n?number\n\nGot:\n'+u(n));case 4:if(this.processStart()){e.next=6;break}return e.abrupt("return");case 6:if(this.validate(t)){e.next=8;break}return e.abrupt("return");case 8:return this.data=this.copy(t),this.args=r,e.next=12,regeneratorRuntime.awrap(this.processStartNode(n));case 12:return e.next=14,regeneratorRuntime.awrap(this.processUnreachable());case 14:return e.abrupt("return",this.processDone()?"success":"aborted");case 15:case"end":return e.stop()}},null,this)}}]),n}(L),Z=function(t){function n(){return m(this,n),b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,{nodecreate:[],nodecreated:[],noderemove:[],noderemoved:[],connectioncreate:[],connectioncreated:[],connectionremove:[],connectionremoved:[],nodetranslate:[],nodetranslated:[],selectnode:[],nodeselect:[],nodeselected:[],rendernode:[],rendersocket:[],rendercontrol:[],renderconnection:[],componentregister:[],keydown:[],keyup:[],translate:[],translated:[],zoom:[],zoomed:[],click:[],mousemove:[],contextmenu:[],import:[],export:[],process:[]}))}return w(n,t),n}(S),D=function(){function t(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){};m(this,t),this.mouseStart=null,this.el=n,this.onTranslate=e,this.onStart=r,this.onDrag=o,n.addEventListener("mousedown",this.mousedown.bind(this)),window.addEventListener("mousemove",this.mousemove.bind(this)),window.addEventListener("mouseup",this.mouseup.bind(this))}return v(t,[{key:"mousedown",value:function(t){t.stopPropagation(),this.mouseStart=[t.pageX,t.pageY],this.onStart()}},{key:"mousemove",value:function(t){if(this.mouseStart){t.preventDefault();var n=[t.pageX-this.mouseStart[0],t.pageY-this.mouseStart[1]],e=this.el.getBoundingClientRect().width/this.el.offsetWidth;this.mouseStart=[t.pageX,t.pageY],this.onTranslate(n[0]/e,n[1]/e)}}},{key:"mouseup",value:function(t){this.mouseStart=null,this.onDrag()}}]),t}(),J=function(){function t(n,e,r,o){m(this,t),this.el=e,this.intensity=r,this.onzoom=o,n.addEventListener("wheel",this.wheel.bind(this))}return v(t,[{key:"wheel",value:function(t){t.preventDefault();var n=this.el.getBoundingClientRect(),e=t.wheelDelta/120*this.intensity,r=(n.left-t.pageX)*e,o=(n.top-t.pageY)*e;this.onzoom(e,r,o)}}]),t}(),M=function(t){function n(t,e){if(m(this,n),!(e instanceof G))throw new TypeError('Value of argument "emitter" violates contract.\n\nExpected:\nEmitter\n\nGot:\n'+c(e));var r=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e)),o=r.el=document.createElement("div");return r.container=t,r.transform={k:1,x:0,y:0},r.mouse=[0,0],o.style.transformOrigin="0 0",r._drag=new D(t,r.onTranslate.bind(r)),r._zoom=new J(t,o,.1,r.onZoom.bind(r)),r.container.addEventListener("mousemove",r.mousemove.bind(r)),r.update(),r}return w(n,t),v(n,[{key:"update",value:function(){var t=this.transform;this.el.style.transform="translate("+t.x+"px, "+t.y+"px) scale("+t.k+")"}},{key:"mousemove",value:function(t){var n=this.el.getBoundingClientRect(),e=t.clientX-n.left,r=t.clientY-n.top,o=this.transform.k;this.trigger("mousemove",{x:e/o,y:r/o})}},{key:"onTranslate",value:function(t,n){this.translate(this.transform.x+t,this.transform.y+n)}},{key:"onZoom",value:function(t,n,e){this.zoom(this.transform.k*(1+t),n,e),this.update()}},{key:"translate",value:function(t,n){var e={transform:this.transform,x:t,y:n};this.trigger("translate",e)&&(this.transform.x=e.x,this.transform.y=e.y,this.update(),this.trigger("translated"))}},{key:"zoom",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=this.transform.k,o={transform:this.transform,zoom:t};if(this.trigger("zoom",o)){var i=(r-o.zoom)/(r-t);this.transform.k=o.zoom,this.transform.x+=n*i,this.transform.y+=e*i,this.update(),this.trigger("zoomed")}}},{key:"appendChild",value:function(t){this.el.appendChild(t)}},{key:"removeChild",value:function(t){this.el.removeChild(t)}}]),n}(G),z=function(t){function n(t,e,r){m(this,n);var o=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,r));return o.trigger("rendercontrol",{el:t,control:e}),o}return w(n,t),n}(G),B=function(t){function n(t,e,r,o,i){var a;m(this,n);var u=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,i));return u.el=t,u.type=e,u.io=r,u.node=o,u.trigger("rendersocket",(a={el:t},y(a,e,u.io),y(a,"socket",r.socket),a)),u}return w(n,t),v(n,[{key:"getPosition",value:function(t){var n=t.position,e=this.el;return[n[0]+e.offsetLeft+e.offsetWidth/2,n[1]+e.offsetTop+e.offsetHeight/2]}}]),n}(G),H=function(t){function n(t,e,r){m(this,n);var o=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,r));return o.node=t,o.component=e,o.sockets=new Map,o.controls=new Map,o.el=document.createElement("div"),o.el.style.position="absolute",o.el.addEventListener("contextmenu",function(t){return o.trigger("contextmenu",{e:t,node:o.node})}),o.drag=new D(o.el,o.onTranslate.bind(o),o.onSelect.bind(o)),o.trigger("rendernode",{el:o.el,node:t,component:e.data,bindSocket:o.bindSocket.bind(o),bindControl:o.bindControl.bind(o)}),o.update(),o}return w(n,t),v(n,[{key:"bindSocket",value:function(t,n,e){if(!(t instanceof HTMLElement))throw new TypeError('Value of argument "el" violates contract.\n\nExpected:\nHTMLElement\n\nGot:\n'+s(t));if("string"!=typeof n)throw new TypeError('Value of argument "type" violates contract.\n\nExpected:\nstring\n\nGot:\n'+s(n));if(!(e instanceof A))throw new TypeError('Value of argument "io" violates contract.\n\nExpected:\nIO\n\nGot:\n'+s(e));this.sockets.set(e,new B(t,n,e,this.node,this))}},{key:"bindControl",value:function(t,n){if(!(t instanceof HTMLElement))throw new TypeError('Value of argument "el" violates contract.\n\nExpected:\nHTMLElement\n\nGot:\n'+s(t));if(!(n instanceof O))throw new TypeError('Value of argument "control" violates contract.\n\nExpected:\nControl\n\nGot:\n'+s(n));this.controls.set(n,new z(t,n,this))}},{key:"getSocketPosition",value:function(t){return this.sockets.get(t).getPosition(this.node)}},{key:"onSelect",value:function(){this.trigger("selectnode",this.node)}},{key:"onTranslate",value:function(t,n){var e=this.node,r=e.position[0]+t,o=e.position[1]+n;this.trigger("nodetranslate",{node:e,x:r,y:o})&&(this.translate(r,o),this.trigger("nodetranslated",{node:e}))}},{key:"translate",value:function(t,n){this.node.position[0]=t,this.node.position[1]=n,this.update()}},{key:"update",value:function(){this.el.style.transform="translate("+this.node.position[0]+"px, "+this.node.position[1]+"px)"}},{key:"remove",value:function(){}}]),n}(G),W=function(t){function n(t,e,r,o){if(m(this,n),!(e instanceof H))throw new TypeError('Value of argument "inputNode" violates contract.\n\nExpected:\nViewNode\n\nGot:\n'+f(e));if(!(r instanceof H))throw new TypeError('Value of argument "outputNode" violates contract.\n\nExpected:\nViewNode\n\nGot:\n'+f(r));var i=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,o));return i.connection=t,i.inputNode=e,i.outputNode=r,i.el=document.createElement("div"),i.el.style.position="absolute",i.el.style.zIndex="-1",i.update(),i}return w(n,t),v(n,[{key:"update",value:function(){var t=this.outputNode.getSocketPosition(this.connection.output),n=E(t,2),e=n[0],r=n[1],o=this.inputNode.getSocketPosition(this.connection.input),i=E(o,2),a=i[0],u=i[1];this.trigger("renderconnection",{el:this.el,connection:this.connection,x1:e,y1:r,x2:a,y2:u})}}]),n}(G),Y=function(t){function n(t,e,r){if(m(this,n),!(t instanceof HTMLElement))throw new TypeError('Value of argument "container" violates contract.\n\nExpected:\nHTMLElement\n\nGot:\n'+l(t));if(!(e instanceof Object))throw new TypeError('Value of argument "components" violates contract.\n\nExpected:\nObject\n\nGot:\n'+l(e));if(!(r instanceof G))throw new TypeError('Value of argument "emitter" violates contract.\n\nExpected:\nEmitter\n\nGot:\n'+l(r));var o=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,r));return o.container=t,o.components=e,o.container.style.overflow="hidden",o.nodes=new Map,o.connections=new Map,o.container.addEventListener("click",o.click.bind(o)),o.container.addEventListener("contextmenu",function(t){return o.trigger("contextmenu",{e:t,view:o})}),window.addEventListener("resize",o.resize.bind(o)),o.on("nodetranslated",o.updateConnections.bind(o)),o.area=new M(t,o),o.container.appendChild(o.area.el),o}return w(n,t),v(n,[{key:"addNode",value:function(t){if(!(t instanceof C))throw new TypeError('Value of argument "node" violates contract.\n\nExpected:\nNode\n\nGot:\n'+l(t));var n=new H(t,this.components.get(t.name),this);this.nodes.set(t,n),this.area.appendChild(n.el)}},{key:"removeNode",value:function(t){if(!(t instanceof C))throw new TypeError('Value of argument "node" violates contract.\n\nExpected:\nNode\n\nGot:\n'+l(t));var n=this.nodes.get(t);this.nodes.delete(t),this.area.removeChild(n.el)}},{key:"addConnection",value:function(t){if(!(t instanceof j))throw new TypeError('Value of argument "connection" violates contract.\n\nExpected:\nConnection\n\nGot:\n'+l(t));var n=this.nodes.get(t.input.node),e=this.nodes.get(t.output.node),r=new W(t,n,e,this);this.connections.set(t,r),this.area.appendChild(r.el)}},{key:"removeConnection",value:function(t){if(!(t instanceof j))throw new TypeError('Value of argument "connection" violates contract.\n\nExpected:\nConnection\n\nGot:\n'+l(t));var n=this.connections.get(t);this.connections.delete(t),this.area.removeChild(n.el)}},{key:"updateConnections",value:function(t){var n=this;t.node.getConnections().map(function(t){n.connections.get(t).update()})}},{key:"resize",value:function(){var t=this.container,n=t.parentElement.clientWidth,e=t.parentElement.clientHeight;t.style.width=n+"px",t.style.height=e+"px"}},{key:"click",value:function(t){var n=this.container;n===t.target&&this.trigger("click",{e:t,container:n})}}]),n}(G),F=function(){function t(){m(this,t),this.list=[]}return v(t,[{key:"add",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!(t instanceof C))throw new TypeError('Value of argument "item" violates contract.\n\nExpected:\nNode\n\nGot:\n'+h(t));n?this.contains(t)?this.remove(t):this.list.push(t):this.list=[t]}},{key:"clear",value:function(){var t=this;this.each(function(n){t.remove(n)})}},{key:"remove",value:function(t){this.list.splice(this.list.indexOf(t),1)}},{key:"contains",value:function(t){return-1!==this.list.indexOf(t)}},{key:"each",value:function(t){this.list.forEach(t)}}]),t}(),X=function(t){function n(t,e){if(m(this,n),"string"!=typeof t)throw new TypeError('Value of argument "id" violates contract.\n\nExpected:\nstring\n\nGot:\n'+p(t));if(!(e instanceof HTMLElement))throw new TypeError('Value of argument "container" violates contract.\n\nExpected:\nHTMLElement\n\nGot:\n'+p(e));var r=b(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,new Z));return r.nodes=[],r.components=new Map,r.selected=new F,r.view=new Y(e,r.components,r),window.addEventListener("keydown",function(t){return r.trigger("keydown",t)}),window.addEventListener("keyup",function(t){return r.trigger("keyup",t)}),r.on("nodecreated",function(t){return r.getComponent(t.name).created(t)}),r.on("noderemoved",function(t){return r.getComponent(t.name).destroyed(t)}),r.on("selectnode",function(t){return r.selectNode(t)}),r}return w(n,t),v(n,[{key:"addNode",value:function(t){if(!(t instanceof C))throw new TypeError('Value of argument "node" violates contract.\n\nExpected:\nNode\n\nGot:\n'+p(t));this.trigger("nodecreate",t)&&(this.nodes.push(t),this.view.addNode(t),this.trigger("nodecreated",t))}},{key:"removeNode",value:function(t){var n=this;if(!(t instanceof C))throw new TypeError('Value of argument "node" violates contract.\n\nExpected:\nNode\n\nGot:\n'+p(t));this.trigger("noderemove",t)&&(t.getConnections().forEach(function(t){return n.removeConnection(t)}),this.nodes.splice(this.nodes.indexOf(t),1),this.view.removeNode(t),this.trigger("noderemoved",t))}},{key:"connect",value:function(t,n){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!(t instanceof N))throw new TypeError('Value of argument "output" violates contract.\n\nExpected:\nOutput\n\nGot:\n'+p(t));if(!(n instanceof T))throw new TypeError('Value of argument "input" violates contract.\n\nExpected:\nInput\n\nGot:\n'+p(n));if(this.trigger("connectioncreate",{output:t,input:n}))try{var r=t.connectTo(n);r.data=e,this.view.addConnection(r),this.trigger("connectioncreated",r)}catch(t){this.trigger("warn",t)}}},{key:"removeConnection",value:function(t){if(!(t instanceof j))throw new TypeError('Value of argument "connection" violates contract.\n\nExpected:\nConnection\n\nGot:\n'+p(t));this.trigger("connectionremove",t)&&(this.view.removeConnection(t),t.remove(),this.trigger("connectionremoved",t))}},{key:"selectNode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!(t instanceof C))throw new TypeError('Value of argument "node" violates contract.\n\nExpected:\nNode\n\nGot:\n'+p(t));if("boolean"!=typeof n)throw new TypeError('Value of argument "accumulate" violates contract.\n\nExpected:\nboolean\n\nGot:\n'+p(n));if(-1===this.nodes.indexOf(t))throw new Error("Node not exist in list");this.trigger("nodeselect",t)&&(this.selected.add(t,n),this.trigger("nodeselected",t))}},{key:"getComponent",value:function(t){var n=this.components.get(t);if(!n)throw"Component "+t+" not found";return n}},{key:"register",value:function(t){if(!(t instanceof V))throw new TypeError('Value of argument "component" violates contract.\n\nExpected:\nComponent\n\nGot:\n'+p(t));t.editor=this,this.components.set(t.name,t),this.trigger("componentregister",t)}},{key:"clear",value:function(){var t=this;[].concat(k(this.nodes)).map(function(n){return t.removeNode(n)})}},{key:"toJSON",value:function(){var t={id:this.id,nodes:{}};return this.nodes.forEach(function(n){return t.nodes[n.id]=n.toJSON()}),this.trigger("export",t),t}},{key:"beforeImport",value:function(t){if(!(t instanceof Object))throw new TypeError('Value of argument "json" violates contract.\n\nExpected:\nObject\n\nGot:\n'+p(t));var n=R.validate(this.id,t);return n.success?(this.clear(),this.silent=!0,this.trigger("import",t),!0):(this.trigger("warn",n.msg),!1)}},{key:"afterImport",value:function(){return this.silent=!1,!0}},{key:"fromJSON",value:function(t){var n,e=this;return regeneratorRuntime.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t instanceof Object){r.next=2;break}throw new TypeError('Value of argument "json" violates contract.\n\nExpected:\nObject\n\nGot:\n'+p(t));case 2:if(this.beforeImport(t)){r.next=4;break}return r.abrupt("return",!1);case 4:return n={},r.prev=5,r.next=8,regeneratorRuntime.awrap(Promise.all(Object.keys(t.nodes).map(function(r){var o,i;return regeneratorRuntime.async(function(a){for(;;)switch(a.prev=a.next){case 0:return o=t.nodes[r],i=e.getComponent(o.name),a.next=4,regeneratorRuntime.awrap(i.build(C.fromJSON(o)));case 4:n[r]=a.sent,e.addNode(n[r]);case 6:case"end":return a.stop()}},null,e)})));case 8:Object.keys(t.nodes).forEach(function(r){var o=t.nodes[r],i=n[r];o.outputs.forEach(function(t,r){t.connections.forEach(function(t){var o=t.node,a=t.data,u=t.input,c=n[o].inputs[u];e.connect(i.outputs[r],c,a)})})}),r.next=15;break;case 11:return r.prev=11,r.t0=r.catch(5),this.trigger("warn",r.t0),r.abrupt("return",!1);case 15:return r.abrupt("return",this.afterImport());case 16:case"end":return r.stop()}},null,this,[[5,11]])}}]),n}(L);return{Component:V,Control:O,NodeEditor:X,Emitter:G,Engine:$,Input:T,Node:C,Output:N,Socket:_}});
//# sourceMappingURL=rete.min.js.map
{
"name": "rete",
"version": "1.0.0-alpha.3",
"version": "1.0.0-alpha.4",
"description": "JavaScript framework",

@@ -5,0 +5,0 @@ "main": "build/rete.js",

@@ -63,2 +63,3 @@ import { Drag } from './drag';

zoom(zoom, ox = 0, oy = 0) {
const k = this.transform.k;
const params = { transform: this.transform, zoom };

@@ -68,5 +69,7 @@

const d = (k - params.zoom) / (k - zoom);
this.transform.k = params.zoom;
this.transform.x += ox;
this.transform.y += oy;
this.transform.x += ox * d;
this.transform.y += oy * d;

@@ -73,0 +76,0 @@ this.update();

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc