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

rete-area-plugin

Package Overview
Dependencies
Maintainers
0
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rete-area-plugin - npm Package Compare versions

Comparing version 2.0.5 to 2.1.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

# [2.1.0](https://github.com/retejs/area-plugin/compare/v2.0.5...v2.1.0) (2024-08-29)
### Features
* add Meta key support for accumulation function ([45e6aa5](https://github.com/retejs/area-plugin/commit/45e6aa54c94c895ec8a2aa162c32eae4375cfe7e))
## [2.0.5](https://github.com/retejs/area-plugin/compare/v2.0.4...v2.0.5) (2024-08-20)

@@ -2,0 +9,0 @@

2

package.json
{
"name": "rete-area-plugin",
"version": "2.0.5",
"version": "2.1.0",
"description": "",

@@ -5,0 +5,0 @@ "author": "Vitaliy Stoliarov",

/*!
* rete-area-plugin v2.0.4
* rete-area-plugin v2.0.5
* (c) 2024 Vitaliy Stoliarov

@@ -992,6 +992,6 @@ * Released under the MIT license.

function keydown(e) {
if (e.key === 'Control') pressed = true;
if (e.key === 'Control' || e.key === 'Meta') pressed = true;
}
function keyup(e) {
if (e.key === 'Control') pressed = false;
if (e.key === 'Control' || e.key === 'Meta') pressed = false;
}

@@ -998,0 +998,0 @@ document.addEventListener('keydown', keydown);

/*!
* rete-area-plugin v2.0.4
* rete-area-plugin v2.0.5
* (c) 2024 Vitaliy Stoliarov

@@ -972,6 +972,6 @@ * Released under the MIT license.

function keydown(e) {
if (e.key === 'Control') pressed = true;
if (e.key === 'Control' || e.key === 'Meta') pressed = true;
}
function keyup(e) {
if (e.key === 'Control') pressed = false;
if (e.key === 'Control' || e.key === 'Meta') pressed = false;
}

@@ -978,0 +978,0 @@ document.addEventListener('keydown', keydown);

/*!
* rete-area-plugin v2.0.4
* rete-area-plugin v2.0.5
* (c) 2024 Vitaliy Stoliarov
* Released under the MIT license.
* */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("rete")):"function"==typeof define&&define.amd?define(["exports","rete"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReteAreaPlugin={},t.Rete)}(this,(function(t,e){"use strict";function n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function r(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){l(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(){o=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,r=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function d(t,e,n,o){var i=e&&e.prototype instanceof p?e:p,a=Object.create(i.prototype),s=new P(o||[]);return r(a,"_invoke",{value:k(t,n,s)}),a}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=d;var f={};function p(){}function h(){}function v(){}var y={};c(y,a,(function(){return this}));var m=Object.getPrototypeOf,w=m&&m(m(O([])));w&&w!==e&&n.call(w,a)&&(y=w);var g=v.prototype=p.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function o(r,i,a,s){var u=l(t[r],t,i);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&n.call(d,"__await")?e.resolve(d.__await).then((function(t){o("next",t,a,s)}),(function(t){o("throw",t,a,s)})):e.resolve(d).then((function(t){c.value=t,a(c)}),(function(t){return o("throw",t,a,s)}))}s(u.arg)}var i;r(this,"_invoke",{value:function(t,n){function r(){return new e((function(e,r){o(t,n,e,r)}))}return i=i?i.then(r,r):r()}})}function k(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return j()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var s=E(a,n);if(s){if(s===f)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=l(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function E(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var o=l(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function z(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function O(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=v,r(g,"constructor",{value:v,configurable:!0}),r(v,"constructor",{value:h,configurable:!0}),h.displayName=c(v,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},b(x.prototype),c(x.prototype,s,(function(){return this})),t.AsyncIterator=x,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new x(d(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(g),c(g,u,"Generator"),c(g,a,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=O,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(z),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){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&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),z(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;z(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:O(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},t}function i(t){return i="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},i(t)}function a(t,e,n,r,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,o)}function s(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function s(t){a(i,r,o,s,u,"next",t)}function u(t){a(i,r,o,s,u,"throw",t)}s(void 0)}))}}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function c(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,g(r.key),r)}}function d(t,e,n){return e&&c(t.prototype,e),n&&c(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function l(t,e,n){return(e=g(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&h(t,e)}function p(t){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},p(t)}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}function v(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function y(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=p(t);if(e){var o=p(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return v(t)}(this,n)}}function m(t){return function(t){if(Array.isArray(t))return w(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return w(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return w(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function g(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var b=function(){function t(e){u(this,t),this.reordered=e,this.holder=document.createElement("div"),this.holder.style.transformOrigin="0 0"}var e;return d(t,[{key:"getPointerFrom",value:function(t){var e=this.holder.getBoundingClientRect(),n=e.left,r=e.top;return{x:t.clientX-n,y:t.clientY-r}}},{key:"add",value:function(t){this.holder.appendChild(t)}},{key:"reorder",value:(e=s(o().mark((function t(e,n){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.holder.contains(e)){t.next=2;break}throw new Error("content doesn't have 'target' for reordering");case 2:if(null===n||this.holder.contains(n)){t.next=4;break}throw new Error("content doesn't have 'next' for reordering");case 4:return this.holder.insertBefore(e,n),t.next=7,this.reordered(e);case 7:case"end":return t.stop()}}),t,this)}))),function(t,n){return e.apply(this,arguments)})},{key:"remove",value:function(t){this.holder.removeChild(t)}}]),t}();function x(t,e){var n=function(t){e.move(t)},r=function t(r){window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t),e.up(r)},o=function(t){window.addEventListener("pointermove",n),window.addEventListener("pointerup",r),window.addEventListener("pointercancel",r),e.down(t)};return t.addEventListener("pointerdown",o),{destroy:function(){t.removeEventListener("pointerdown",o),window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",r),window.removeEventListener("pointercancel",r)}}}var k=function(t){return 0===t.length?0:Math.min.apply(Math,m(t))},E=function(t){return 0===t.length?0:Math.max.apply(Math,m(t))};function L(t){var e=k(t.map((function(t){return t.position.x}))),n=k(t.map((function(t){return t.position.y}))),r=E(t.map((function(t){return t.position.x+t.width}))),o=E(t.map((function(t){return t.position.y+t.height})));return{left:e,right:r,top:n,bottom:o,width:Math.abs(e-r),height:Math.abs(n-o),center:{x:(e+r)/2,y:(n+o)/2}}}var z=function(){function t(e){var n=this;u(this,t),l(this,"down",(function(t){n.guards.down(t)&&(t.stopPropagation(),n.pointerStart={x:t.pageX,y:t.pageY},n.startPosition=r({},n.config.getCurrentPosition()),n.events.start(t))})),l(this,"move",(function(t){if(n.pointerStart&&n.startPosition&&n.guards.move(t)){t.preventDefault();var e=t.pageX-n.pointerStart.x,r=t.pageY-n.pointerStart.y,o=n.config.getZoom(),i=n.startPosition.x+e/o,a=n.startPosition.y+r/o;n.events.translate(i,a,t)}})),l(this,"up",(function(t){n.pointerStart&&(delete n.pointerStart,n.events.drag(t))})),this.guards=e||{down:function(t){return!("mouse"===t.pointerType&&0!==t.button)},move:function(){return!0}}}return d(t,[{key:"initialize",value:function(t,e,n){this.config=e,this.events=n,t.style.touchAction="none",this.pointerListener=x(t,{down:this.down,move:this.move,up:this.up})}},{key:"destroy",value:function(){this.pointerListener.destroy()}}]),t}(),P=function(){function t(e){var n=this;u(this,t),l(this,"previous",null),l(this,"pointers",[]),l(this,"wheel",(function(t){t.preventDefault();var e=n.element.getBoundingClientRect(),r=e.left,o=e.top,i=t.deltaY<0?n.intensity:-n.intensity,a=(r-t.clientX)*i,s=(o-t.clientY)*i;n.onzoom(i,a,s,"wheel")})),l(this,"down",(function(t){n.pointers.push(t)})),l(this,"move",(function(t){if(n.pointers=n.pointers.map((function(e){return e.pointerId===t.pointerId?t:e})),n.isTranslating()){var e=n.element.getBoundingClientRect(),r=e.left,o=e.top,i=n.getTouches(),a=i.cx,s=i.cy,u=i.distance;if(null!==n.previous&&n.previous.distance>0){var c=u/n.previous.distance-1,d=(r-a)*c,l=(o-s)*c;n.onzoom(c,d-(n.previous.cx-a),l-(n.previous.cy-s),"touch")}n.previous={cx:a,cy:s,distance:u}}})),l(this,"contextmenu",(function(){n.pointers=[]})),l(this,"up",(function(t){n.previous=null,n.pointers=n.pointers.filter((function(e){return e.pointerId!==t.pointerId}))})),l(this,"dblclick",(function(t){t.preventDefault();var e=n.element.getBoundingClientRect(),r=e.left,o=e.top,i=4*n.intensity,a=(r-t.clientX)*i,s=(o-t.clientY)*i;n.onzoom(i,a,s,"dblclick")})),this.intensity=e}return d(t,[{key:"initialize",value:function(t,e,n){this.container=t,this.element=e,this.onzoom=n,this.container.addEventListener("wheel",this.wheel),this.container.addEventListener("pointerdown",this.down),this.container.addEventListener("dblclick",this.dblclick),window.addEventListener("pointermove",this.move),window.addEventListener("pointerup",this.up),window.addEventListener("contextmenu",this.contextmenu),window.addEventListener("pointercancel",this.up)}},{key:"getTouches",value:function(){var t={touches:this.pointers},e=[t.touches[0].clientX,t.touches[0].clientY],n=e[0],r=e[1],o=[t.touches[1].clientX,t.touches[1].clientY],i=o[0],a=o[1];return{cx:(n+i)/2,cy:(r+a)/2,distance:Math.sqrt(Math.pow(n-i,2)+Math.pow(r-a,2))}}},{key:"isTranslating",value:function(){return this.pointers.length>=2}},{key:"destroy",value:function(){this.container.removeEventListener("wheel",this.wheel),this.container.removeEventListener("pointerdown",this.down),this.container.removeEventListener("dblclick",this.dblclick),window.removeEventListener("pointermove",this.move),window.removeEventListener("pointerup",this.up),window.removeEventListener("pointercancel",this.up)}}]),t}(),O=function(){function t(e,n,r){var o=this;u(this,t),l(this,"transform",{k:1,x:0,y:0}),l(this,"pointer",{x:0,y:0}),l(this,"zoomHandler",null),l(this,"dragHandler",null),l(this,"pointerdown",(function(t){o.setPointerFrom(t),o.events.pointerDown(o.pointer,t)})),l(this,"pointermove",(function(t){o.setPointerFrom(t),o.events.pointerMove(o.pointer,t)})),l(this,"pointerup",(function(t){o.setPointerFrom(t),o.events.pointerUp(o.pointer,t)})),l(this,"resize",(function(t){o.events.resize(t)})),l(this,"onTranslate",(function(t,e){o.zoomHandler&&o.zoomHandler.isTranslating()||o.translate(t,e)})),l(this,"onZoom",(function(t,e,n,r){o.zoom(o.transform.k*(1+t),e,n,r),o.update()})),this.container=e,this.events=n,this.guards=r,this.content=new b((function(t){return o.events.reordered(t)})),this.content.holder.style.transformOrigin="0 0",this.setZoomHandler(new P(.1)),this.setDragHandler(new z),this.container.addEventListener("pointerdown",this.pointerdown),this.container.addEventListener("pointermove",this.pointermove),window.addEventListener("pointerup",this.pointerup),window.addEventListener("resize",this.resize),e.appendChild(this.content.holder),this.update()}var e,n;return d(t,[{key:"update",value:function(){var t=this.transform,e=t.x,n=t.y,r=t.k;this.content.holder.style.transform="translate(".concat(e,"px, ").concat(n,"px) scale(").concat(r,")")}},{key:"setDragHandler",value:function(t){var e=this;this.dragHandler&&this.dragHandler.destroy(),this.dragHandler=t,this.dragHandler&&this.dragHandler.initialize(this.container,{getCurrentPosition:function(){return e.transform},getZoom:function(){return 1}},{start:function(){return null},translate:this.onTranslate,drag:function(){return null}})}},{key:"setZoomHandler",value:function(t){this.zoomHandler&&this.zoomHandler.destroy(),this.zoomHandler=t,this.zoomHandler&&this.zoomHandler.initialize(this.container,this.content.holder,this.onZoom)}},{key:"setPointerFrom",value:function(t){var e=this.content.getPointerFrom(t),n=e.x,r=e.y,o=this.transform.k;this.pointer={x:n/o,y:r/o}}},{key:"translate",value:(n=s(o().mark((function t(e,n){var r,i;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={x:e,y:n},t.next=3,this.guards.translate({previous:this.transform,position:r});case 3:if(i=t.sent){t.next=6;break}return t.abrupt("return",!1);case 6:return this.transform.x=i.data.position.x,this.transform.y=i.data.position.y,this.update(),t.next=11,this.events.translated(i.data);case 11:return t.abrupt("return",!0);case 12:case"end":return t.stop()}}),t,this)}))),function(t,e){return n.apply(this,arguments)})},{key:"zoom",value:(e=s(o().mark((function t(e){var n,r,i,a,s,u,c=arguments;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=c.length>1&&void 0!==c[1]?c[1]:0,r=c.length>2&&void 0!==c[2]?c[2]:0,i=c.length>3?c[3]:void 0,a=this.transform.k,t.next=6,this.guards.zoom({previous:this.transform,zoom:e,source:i});case 6:if(s=t.sent){t.next=9;break}return t.abrupt("return",!0);case 9:return u=(a-s.data.zoom)/(a-e||1),this.transform.k=s.data.zoom||1,this.transform.x+=n*u,this.transform.y+=r*u,this.update(),t.next=16,this.events.zoomed(s.data);case 16:return t.abrupt("return",!1);case 17:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"destroy",value:function(){this.container.removeEventListener("pointerdown",this.pointerdown),this.container.removeEventListener("pointermove",this.pointermove),window.removeEventListener("pointerup",this.pointerup),window.removeEventListener("resize",this.resize),this.dragHandler&&this.dragHandler.destroy(),this.zoomHandler&&this.zoomHandler.destroy(),this.content.holder.innerHTML=""}}]),t}(),j=function(t){f(n,t);var e=y(n);function n(){return u(this,n),e.apply(this,arguments)}return d(n)}(e.Scope),S=d((function t(e){u(this,t),this.element=document.createElement("div"),this.element.style.position="absolute",this.element.style.left="0",this.element.style.top="0",this.element.addEventListener("contextmenu",(function(t){return e.contextmenu(t)}))})),_=function(){function t(){u(this,t),l(this,"views",new WeakMap),l(this,"viewsElements",new Map)}return d(t,[{key:"set",value:function(t){var e=t.element,n=t.type,r=t.payload;null!=r&&r.id&&(this.views.set(e,t),this.viewsElements.set("".concat(n,"_").concat(r.id),e))}},{key:"get",value:function(t,e){var n=this.viewsElements.get("".concat(t,"_").concat(e));return n&&this.views.get(n)}},{key:"delete",value:function(t){var e,n=this.views.get(t);n&&null!==(e=n.payload)&&void 0!==e&&e.id&&(this.views.delete(t),this.viewsElements.delete("".concat(n.type,"_").concat(n.payload.id)))}}]),t}(),C=function(){function t(e,n,i){var a=this;u(this,t),l(this,"translate",function(){var t=s(o().mark((function t(e,n){var i,s;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=r({},a.position),t.next=3,a.guards.translate({previous:i,position:{x:e,y:n}});case 3:if(s=t.sent){t.next=6;break}return t.abrupt("return",!1);case 6:return a.position=r({},s.data.position),a.element.style.transform="translate(".concat(a.position.x,"px, ").concat(a.position.y,"px)"),t.next=10,a.events.translated({position:a.position,previous:i});case 10:return t.abrupt("return",!0);case 11:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),l(this,"resize",function(){var t=s(o().mark((function t(e,n){var r,i;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={width:e,height:n},t.next=3,a.guards.resize({size:r});case 3:if(t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:if((i=a.element.querySelector("*:not(span):not([fragment])"))&&i instanceof HTMLElement){t.next=8;break}return t.abrupt("return",!1);case 8:return i.style.width="".concat(e,"px"),i.style.height="".concat(n,"px"),t.next=12,a.events.resized({size:r});case 12:return t.abrupt("return",!0);case 13:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),this.getZoom=e,this.events=n,this.guards=i,this.element=document.createElement("div"),this.element.style.position="absolute",this.position={x:0,y:0},this.translate(0,0),this.element.addEventListener("contextmenu",(function(t){return a.events.contextmenu(t)})),this.dragHandler=new z,this.dragHandler.initialize(this.element,{getCurrentPosition:function(){return a.position},getZoom:function(){return a.getZoom()}},{start:this.events.picked,translate:this.translate,drag:this.events.dragged})}return d(t,[{key:"destroy",value:function(){this.dragHandler.destroy()}}]),t}();function H(t,e){return t.map((function(t){return{view:e.get(t.id),node:t}})).filter((function(t){return t.view})).map((function(t){var e=t.view,n=t.node,r=n.width,o=n.height;return void 0!==r&&void 0!==o?{position:e.position,width:r,height:o}:{position:e.position,width:e.element.clientWidth,height:e.element.clientHeight}}))}var V=function(){function t(){u(this,t),l(this,"entities",new Map),l(this,"pickId",null)}return d(t,[{key:"isSelected",value:function(t){return this.entities.has("".concat(t.label,"_").concat(t.id))}},{key:"add",value:function(t,e){e||this.unselectAll(),this.entities.set("".concat(t.label,"_").concat(t.id),t)}},{key:"remove",value:function(t){var e="".concat(t.label,"_").concat(t.id),n=this.entities.get(e);n&&(this.entities.delete(e),n.unselect())}},{key:"unselectAll",value:function(){var t=this;m(Array.from(this.entities.values())).forEach((function(e){return t.remove(e)}))}},{key:"translate",value:function(t,e){var n=this;this.entities.forEach((function(r){return!n.isPicked(r)&&r.translate(t,e)}))}},{key:"pick",value:function(t){this.pickId="".concat(t.label,"_").concat(t.id)}},{key:"release",value:function(){this.pickId=null}},{key:"isPicked",value:function(t){return this.pickId==="".concat(t.label,"_").concat(t.id)}}]),t}();function M(){return(M=s(o().mark((function t(n,r,a){var s,u,c,d,l,f,p,h,v,y,m,w;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=(a||{}).scale,u=void 0===s?.9:s,c=n.parentScope(e.NodeEditor),d=r.map((function(t){return"object"===i(t)?t:c.getNode(t)})),l=H(d,n.nodeViews),f=L(l),p=[n.container.clientWidth,n.container.clientHeight],v=p[1],y=(h=p[0])/f.width,m=v/f.height,w=Math.min(m*u,y*u,1),n.area.transform.x=h/2-f.center.x*w,n.area.transform.y=v/2-f.center.y*w,t.next=12,n.area.zoom(w,0,0);case 12:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var N=Object.freeze({__proto__:null,getBoundingBox:function(t,n){var r=t.parentScope(e.NodeEditor);return L(H(n.map((function(t){return"object"===i(t)?t:r.getNode(t)})),t.nodeViews))},simpleNodesOrder:function(t){var e=t;e.addPipe((function(t){if(!t||"object"!==i(t)||!("type"in t))return t;if("nodepicked"===t.type){var n=e.nodeViews.get(t.data.id),r=e.area.content;n&&r.reorder(n.element,null)}if("connectioncreated"===t.type){var o=e.connectionViews.get(t.data.id),a=e.area.content;o&&a.reorder(o.element,a.holder.firstChild)}return t}))},restrictor:function(t,e){var n=!(null==e||!e.scaling)&&(!0===e.scaling?{min:.1,max:1}:e.scaling),o=!(null==e||!e.translation)&&(!0===e.translation?{left:0,top:0,right:1e3,bottom:1e3}:e.translation);function a(t){if(!n)throw new Error("scaling param isnt defined");var e="function"==typeof n?n():n,r=e.min,o=e.max;return t<r?r:t>o?o:t}function s(t){if(!o)throw new Error("translation param isnt defined");var e=r({},t),n="function"==typeof o?o():o,i=n.left,a=n.top,s=n.right,u=n.bottom;return e.x<i&&(e.x=i),e.x>s&&(e.x=s),e.y<a&&(e.y=a),e.y>u&&(e.y=u),e}t.addPipe((function(e){if(!e||"object"!==i(e)||!("type"in e))return e;if(n&&"zoom"===e.type)return r(r({},e),{},{data:r(r({},e.data),{},{zoom:a(e.data.zoom)})});if(o&&"zoomed"===e.type){var u=s(t.area.transform);t.area.translate(u.x,u.y)}return o&&"translate"===e.type?r(r({},e),{},{data:r(r({},e.data),{},{position:s(e.data.position)})}):e}))},accumulateOnCtrl:function(){var t=!1;function e(e){"Control"===e.key&&(t=!0)}function n(e){"Control"===e.key&&(t=!1)}return document.addEventListener("keydown",e),document.addEventListener("keyup",n),{active:function(){return t},destroy:function(){document.removeEventListener("keydown",e),document.removeEventListener("keyup",n)}}},selectableNodes:function(t,n,r){var o=null,a=t,s=0;function u(t,r){var i=(o||(o=a.parentScope(e.NodeEditor))).getNode(t);i&&(n.add({label:"node",id:i.id,translate:function(t,e){var n=a.nodeViews.get(i.id),r=null==n?void 0:n.position;r&&n.translate(r.x+t,r.y+e)},unselect:function(){!function(t){t.selected&&(t.selected=!1,a.update("node",t.id))}(i)}},r),function(t){t.selected||(t.selected=!0,a.update("node",t.id))}(i))}return a.addPipe((function(t){if(!t||"object"!==i(t)||!("type"in t))return t;if("nodepicked"===t.type){var e=t.data.id,o=r.accumulating.active();n.pick({id:e,label:"node"}),s=null,u(e,o)}else if("nodetranslated"===t.type){var a=t.data,c=a.id,d=a.position,l=a.previous,f=d.x-l.x,p=d.y-l.y;n.isPicked({id:c,label:"node"})&&n.translate(f,p)}else"pointerdown"===t.type?s=0:"pointermove"===t.type?null!==s&&s++:"pointerup"===t.type&&(null!==s&&s<4&&n.unselectAll(),s=null);return t})),{select:u,unselect:function(t){n.remove({id:t,label:"node"})}}},Selector:V,selector:function(){return new V},showInputControl:function(t,n){var r=null,o=function(){return r||(r=t.parentScope(e.NodeEditor))};t.addPipe((function(e){return"connectioncreated"!==e.type&&"connectionremoved"!==e.type||function(e,r){var i=o().getNode(e);if(i){var a=i.inputs[r];if(!a)throw new Error("cannot find input");var s=a.showControl,u=o().getConnections(),c=Boolean(u.find((function(t){return t.target===e&&t.targetInput===r})));a.showControl=n?n({hasAnyConnection:c,input:a}):!c,a.showControl!==s&&t.update("node",i.id)}}(e.data.target,e.data.targetInput),e}))},snapGrid:function(t,e){var n=t,o=void 0===(null==e?void 0:e.size)?16:e.size,a=void 0===(null==e?void 0:e.dynamic)||e.dynamic;function s(t){return Math.round(t/o)*o}n.addPipe((function(t){if(!t||"object"!==i(t)||!("type"in t))return t;if(a&&"nodetranslate"===t.type){var e=t.data.position,o=s(e.x),u=s(e.y);return r(r({},t),{},{data:r(r({},t.data),{},{position:{x:o,y:u}})})}if(!a&&"nodedragged"===t.type){var c=n.nodeViews.get(t.data.id);if(c){var d=c.position,l=d.x,f=d.y;c.translate(s(l),s(f))}}return t}))},zoomAt:function(t,e,n){return M.apply(this,arguments)}}),A=function(t){f(p,t);var e,n,a,c=y(p);function p(t){var e;return u(this,p),l(v(e=c.call(this,"area")),"nodeViews",new Map),l(v(e),"connectionViews",new Map),l(v(e),"elements",new _),l(v(e),"onContextMenu",(function(t){e.emit({type:"contextmenu",data:{event:t,context:"root"}})})),e.container=t,t.style.overflow="hidden",t.addEventListener("contextmenu",e.onContextMenu),e.addPipe((function(t){return t&&"object"===i(t)&&"type"in t?("nodecreated"===t.type&&e.addNodeView(t.data),"noderemoved"===t.type&&e.removeNodeView(t.data.id),"connectioncreated"===t.type&&e.addConnectionView(t.data),"connectionremoved"===t.type&&e.removeConnectionView(t.data.id),"render"===t.type&&e.elements.set(t.data),"unmount"===t.type&&e.elements.delete(t.data.element),t):t})),e.area=new O(t,{zoomed:function(t){return e.emit({type:"zoomed",data:t})},pointerDown:function(t,n){return e.emit({type:"pointerdown",data:{position:t,event:n}})},pointerMove:function(t,n){return e.emit({type:"pointermove",data:{position:t,event:n}})},pointerUp:function(t,n){return e.emit({type:"pointerup",data:{position:t,event:n}})},resize:function(t){return e.emit({type:"resized",data:{event:t}})},translated:function(t){return e.emit({type:"translated",data:t})},reordered:function(t){return e.emit({type:"reordered",data:{element:t}})}},{translate:function(t){return e.emit({type:"translate",data:t})},zoom:function(t){return e.emit({type:"zoom",data:t})}}),e}return d(p,[{key:"addNodeView",value:function(t){var e=this,n=t.id,o=new C((function(){return e.area.transform.k}),{picked:function(){return e.emit({type:"nodepicked",data:{id:n}})},translated:function(t){return e.emit({type:"nodetranslated",data:r({id:n},t)})},dragged:function(){return e.emit({type:"nodedragged",data:t})},contextmenu:function(n){return e.emit({type:"contextmenu",data:{event:n,context:t}})},resized:function(n){var r=n.size;return e.emit({type:"noderesized",data:{id:t.id,size:r}})}},{translate:function(t){return e.emit({type:"nodetranslate",data:r({id:n},t)})},resize:function(n){var r=n.size;return e.emit({type:"noderesize",data:{id:t.id,size:r}})}});return this.nodeViews.set(n,o),this.area.content.add(o.element),this.emit({type:"render",data:{element:o.element,type:"node",payload:t}}),o}},{key:"removeNodeView",value:function(t){var e=this.nodeViews.get(t);e&&(this.emit({type:"unmount",data:{element:e.element}}),this.nodeViews.delete(t),this.area.content.remove(e.element))}},{key:"addConnectionView",value:function(t){var e=this,n=new S({contextmenu:function(n){return e.emit({type:"contextmenu",data:{event:n,context:t}})}});return this.connectionViews.set(t.id,n),this.area.content.add(n.element),this.emit({type:"render",data:{element:n.element,type:"connection",payload:t}}),n}},{key:"removeConnectionView",value:function(t){var e=this.connectionViews.get(t);e&&(this.emit({type:"unmount",data:{element:e.element}}),this.connectionViews.delete(t),this.area.content.remove(e.element))}},{key:"update",value:(a=s(o().mark((function t(e,n){var r;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=this.elements.get(e,n))){t.next=4;break}return t.next=4,this.emit({type:"render",data:r});case 4:case"end":return t.stop()}}),t,this)}))),function(t,e){return a.apply(this,arguments)})},{key:"resize",value:(n=s(o().mark((function t(e,n,r){var i;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(i=this.nodeViews.get(e))){t.next=5;break}return t.next=4,i.resize(n,r);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return n.apply(this,arguments)})},{key:"translate",value:(e=s(o().mark((function t(e,n){var r,i,a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.x,i=n.y,!(a=this.nodeViews.get(e))){t.next=6;break}return t.next=5,a.translate(r,i);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)}))),function(t,n){return e.apply(this,arguments)})},{key:"destroy",value:function(){var t=this;this.container.removeEventListener("contextmenu",this.onContextMenu),Array.from(this.connectionViews.keys()).forEach((function(e){return t.removeConnectionView(e)})),Array.from(this.nodeViews.keys()).forEach((function(e){return t.removeNodeView(e)})),this.area.destroy()}}]),p}(j);t.Area=O,t.AreaExtensions=N,t.AreaPlugin=A,t.BaseAreaPlugin=j,t.Drag=z,t.NodeView=C,t.Zoom=P,t.usePointerListener=x,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("rete")):"function"==typeof define&&define.amd?define(["exports","rete"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReteAreaPlugin={},t.Rete)}(this,(function(t,e){"use strict";function n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function r(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){l(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(){o=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,r=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function d(t,e,n,o){var i=e&&e.prototype instanceof p?e:p,a=Object.create(i.prototype),s=new P(o||[]);return r(a,"_invoke",{value:k(t,n,s)}),a}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=d;var f={};function p(){}function h(){}function v(){}var y={};c(y,a,(function(){return this}));var m=Object.getPrototypeOf,w=m&&m(m(O([])));w&&w!==e&&n.call(w,a)&&(y=w);var g=v.prototype=p.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function o(r,i,a,s){var u=l(t[r],t,i);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&n.call(d,"__await")?e.resolve(d.__await).then((function(t){o("next",t,a,s)}),(function(t){o("throw",t,a,s)})):e.resolve(d).then((function(t){c.value=t,a(c)}),(function(t){return o("throw",t,a,s)}))}s(u.arg)}var i;r(this,"_invoke",{value:function(t,n){function r(){return new e((function(e,r){o(t,n,e,r)}))}return i=i?i.then(r,r):r()}})}function k(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return j()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var s=E(a,n);if(s){if(s===f)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=l(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function E(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var o=l(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function z(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function O(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:j}}function j(){return{value:void 0,done:!0}}return h.prototype=v,r(g,"constructor",{value:v,configurable:!0}),r(v,"constructor",{value:h,configurable:!0}),h.displayName=c(v,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},b(x.prototype),c(x.prototype,s,(function(){return this})),t.AsyncIterator=x,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new x(d(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(g),c(g,u,"Generator"),c(g,a,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=O,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(z),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){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&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),z(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;z(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:O(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},t}function i(t){return i="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},i(t)}function a(t,e,n,r,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,o)}function s(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function s(t){a(i,r,o,s,u,"next",t)}function u(t){a(i,r,o,s,u,"throw",t)}s(void 0)}))}}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function c(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,g(r.key),r)}}function d(t,e,n){return e&&c(t.prototype,e),n&&c(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function l(t,e,n){return(e=g(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&h(t,e)}function p(t){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},p(t)}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}function v(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function y(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=p(t);if(e){var o=p(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return v(t)}(this,n)}}function m(t){return function(t){if(Array.isArray(t))return w(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return w(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return w(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function g(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var b=function(){function t(e){u(this,t),this.reordered=e,this.holder=document.createElement("div"),this.holder.style.transformOrigin="0 0"}var e;return d(t,[{key:"getPointerFrom",value:function(t){var e=this.holder.getBoundingClientRect(),n=e.left,r=e.top;return{x:t.clientX-n,y:t.clientY-r}}},{key:"add",value:function(t){this.holder.appendChild(t)}},{key:"reorder",value:(e=s(o().mark((function t(e,n){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.holder.contains(e)){t.next=2;break}throw new Error("content doesn't have 'target' for reordering");case 2:if(null===n||this.holder.contains(n)){t.next=4;break}throw new Error("content doesn't have 'next' for reordering");case 4:return this.holder.insertBefore(e,n),t.next=7,this.reordered(e);case 7:case"end":return t.stop()}}),t,this)}))),function(t,n){return e.apply(this,arguments)})},{key:"remove",value:function(t){this.holder.removeChild(t)}}]),t}();function x(t,e){var n=function(t){e.move(t)},r=function t(r){window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t),e.up(r)},o=function(t){window.addEventListener("pointermove",n),window.addEventListener("pointerup",r),window.addEventListener("pointercancel",r),e.down(t)};return t.addEventListener("pointerdown",o),{destroy:function(){t.removeEventListener("pointerdown",o),window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",r),window.removeEventListener("pointercancel",r)}}}var k=function(t){return 0===t.length?0:Math.min.apply(Math,m(t))},E=function(t){return 0===t.length?0:Math.max.apply(Math,m(t))};function L(t){var e=k(t.map((function(t){return t.position.x}))),n=k(t.map((function(t){return t.position.y}))),r=E(t.map((function(t){return t.position.x+t.width}))),o=E(t.map((function(t){return t.position.y+t.height})));return{left:e,right:r,top:n,bottom:o,width:Math.abs(e-r),height:Math.abs(n-o),center:{x:(e+r)/2,y:(n+o)/2}}}var z=function(){function t(e){var n=this;u(this,t),l(this,"down",(function(t){n.guards.down(t)&&(t.stopPropagation(),n.pointerStart={x:t.pageX,y:t.pageY},n.startPosition=r({},n.config.getCurrentPosition()),n.events.start(t))})),l(this,"move",(function(t){if(n.pointerStart&&n.startPosition&&n.guards.move(t)){t.preventDefault();var e=t.pageX-n.pointerStart.x,r=t.pageY-n.pointerStart.y,o=n.config.getZoom(),i=n.startPosition.x+e/o,a=n.startPosition.y+r/o;n.events.translate(i,a,t)}})),l(this,"up",(function(t){n.pointerStart&&(delete n.pointerStart,n.events.drag(t))})),this.guards=e||{down:function(t){return!("mouse"===t.pointerType&&0!==t.button)},move:function(){return!0}}}return d(t,[{key:"initialize",value:function(t,e,n){this.config=e,this.events=n,t.style.touchAction="none",this.pointerListener=x(t,{down:this.down,move:this.move,up:this.up})}},{key:"destroy",value:function(){this.pointerListener.destroy()}}]),t}(),P=function(){function t(e){var n=this;u(this,t),l(this,"previous",null),l(this,"pointers",[]),l(this,"wheel",(function(t){t.preventDefault();var e=n.element.getBoundingClientRect(),r=e.left,o=e.top,i=t.deltaY<0?n.intensity:-n.intensity,a=(r-t.clientX)*i,s=(o-t.clientY)*i;n.onzoom(i,a,s,"wheel")})),l(this,"down",(function(t){n.pointers.push(t)})),l(this,"move",(function(t){if(n.pointers=n.pointers.map((function(e){return e.pointerId===t.pointerId?t:e})),n.isTranslating()){var e=n.element.getBoundingClientRect(),r=e.left,o=e.top,i=n.getTouches(),a=i.cx,s=i.cy,u=i.distance;if(null!==n.previous&&n.previous.distance>0){var c=u/n.previous.distance-1,d=(r-a)*c,l=(o-s)*c;n.onzoom(c,d-(n.previous.cx-a),l-(n.previous.cy-s),"touch")}n.previous={cx:a,cy:s,distance:u}}})),l(this,"contextmenu",(function(){n.pointers=[]})),l(this,"up",(function(t){n.previous=null,n.pointers=n.pointers.filter((function(e){return e.pointerId!==t.pointerId}))})),l(this,"dblclick",(function(t){t.preventDefault();var e=n.element.getBoundingClientRect(),r=e.left,o=e.top,i=4*n.intensity,a=(r-t.clientX)*i,s=(o-t.clientY)*i;n.onzoom(i,a,s,"dblclick")})),this.intensity=e}return d(t,[{key:"initialize",value:function(t,e,n){this.container=t,this.element=e,this.onzoom=n,this.container.addEventListener("wheel",this.wheel),this.container.addEventListener("pointerdown",this.down),this.container.addEventListener("dblclick",this.dblclick),window.addEventListener("pointermove",this.move),window.addEventListener("pointerup",this.up),window.addEventListener("contextmenu",this.contextmenu),window.addEventListener("pointercancel",this.up)}},{key:"getTouches",value:function(){var t={touches:this.pointers},e=[t.touches[0].clientX,t.touches[0].clientY],n=e[0],r=e[1],o=[t.touches[1].clientX,t.touches[1].clientY],i=o[0],a=o[1];return{cx:(n+i)/2,cy:(r+a)/2,distance:Math.sqrt(Math.pow(n-i,2)+Math.pow(r-a,2))}}},{key:"isTranslating",value:function(){return this.pointers.length>=2}},{key:"destroy",value:function(){this.container.removeEventListener("wheel",this.wheel),this.container.removeEventListener("pointerdown",this.down),this.container.removeEventListener("dblclick",this.dblclick),window.removeEventListener("pointermove",this.move),window.removeEventListener("pointerup",this.up),window.removeEventListener("pointercancel",this.up)}}]),t}(),O=function(){function t(e,n,r){var o=this;u(this,t),l(this,"transform",{k:1,x:0,y:0}),l(this,"pointer",{x:0,y:0}),l(this,"zoomHandler",null),l(this,"dragHandler",null),l(this,"pointerdown",(function(t){o.setPointerFrom(t),o.events.pointerDown(o.pointer,t)})),l(this,"pointermove",(function(t){o.setPointerFrom(t),o.events.pointerMove(o.pointer,t)})),l(this,"pointerup",(function(t){o.setPointerFrom(t),o.events.pointerUp(o.pointer,t)})),l(this,"resize",(function(t){o.events.resize(t)})),l(this,"onTranslate",(function(t,e){o.zoomHandler&&o.zoomHandler.isTranslating()||o.translate(t,e)})),l(this,"onZoom",(function(t,e,n,r){o.zoom(o.transform.k*(1+t),e,n,r),o.update()})),this.container=e,this.events=n,this.guards=r,this.content=new b((function(t){return o.events.reordered(t)})),this.content.holder.style.transformOrigin="0 0",this.setZoomHandler(new P(.1)),this.setDragHandler(new z),this.container.addEventListener("pointerdown",this.pointerdown),this.container.addEventListener("pointermove",this.pointermove),window.addEventListener("pointerup",this.pointerup),window.addEventListener("resize",this.resize),e.appendChild(this.content.holder),this.update()}var e,n;return d(t,[{key:"update",value:function(){var t=this.transform,e=t.x,n=t.y,r=t.k;this.content.holder.style.transform="translate(".concat(e,"px, ").concat(n,"px) scale(").concat(r,")")}},{key:"setDragHandler",value:function(t){var e=this;this.dragHandler&&this.dragHandler.destroy(),this.dragHandler=t,this.dragHandler&&this.dragHandler.initialize(this.container,{getCurrentPosition:function(){return e.transform},getZoom:function(){return 1}},{start:function(){return null},translate:this.onTranslate,drag:function(){return null}})}},{key:"setZoomHandler",value:function(t){this.zoomHandler&&this.zoomHandler.destroy(),this.zoomHandler=t,this.zoomHandler&&this.zoomHandler.initialize(this.container,this.content.holder,this.onZoom)}},{key:"setPointerFrom",value:function(t){var e=this.content.getPointerFrom(t),n=e.x,r=e.y,o=this.transform.k;this.pointer={x:n/o,y:r/o}}},{key:"translate",value:(n=s(o().mark((function t(e,n){var r,i;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={x:e,y:n},t.next=3,this.guards.translate({previous:this.transform,position:r});case 3:if(i=t.sent){t.next=6;break}return t.abrupt("return",!1);case 6:return this.transform.x=i.data.position.x,this.transform.y=i.data.position.y,this.update(),t.next=11,this.events.translated(i.data);case 11:return t.abrupt("return",!0);case 12:case"end":return t.stop()}}),t,this)}))),function(t,e){return n.apply(this,arguments)})},{key:"zoom",value:(e=s(o().mark((function t(e){var n,r,i,a,s,u,c=arguments;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=c.length>1&&void 0!==c[1]?c[1]:0,r=c.length>2&&void 0!==c[2]?c[2]:0,i=c.length>3?c[3]:void 0,a=this.transform.k,t.next=6,this.guards.zoom({previous:this.transform,zoom:e,source:i});case 6:if(s=t.sent){t.next=9;break}return t.abrupt("return",!0);case 9:return u=(a-s.data.zoom)/(a-e||1),this.transform.k=s.data.zoom||1,this.transform.x+=n*u,this.transform.y+=r*u,this.update(),t.next=16,this.events.zoomed(s.data);case 16:return t.abrupt("return",!1);case 17:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"destroy",value:function(){this.container.removeEventListener("pointerdown",this.pointerdown),this.container.removeEventListener("pointermove",this.pointermove),window.removeEventListener("pointerup",this.pointerup),window.removeEventListener("resize",this.resize),this.dragHandler&&this.dragHandler.destroy(),this.zoomHandler&&this.zoomHandler.destroy(),this.content.holder.innerHTML=""}}]),t}(),j=function(t){f(n,t);var e=y(n);function n(){return u(this,n),e.apply(this,arguments)}return d(n)}(e.Scope),S=d((function t(e){u(this,t),this.element=document.createElement("div"),this.element.style.position="absolute",this.element.style.left="0",this.element.style.top="0",this.element.addEventListener("contextmenu",(function(t){return e.contextmenu(t)}))})),_=function(){function t(){u(this,t),l(this,"views",new WeakMap),l(this,"viewsElements",new Map)}return d(t,[{key:"set",value:function(t){var e=t.element,n=t.type,r=t.payload;null!=r&&r.id&&(this.views.set(e,t),this.viewsElements.set("".concat(n,"_").concat(r.id),e))}},{key:"get",value:function(t,e){var n=this.viewsElements.get("".concat(t,"_").concat(e));return n&&this.views.get(n)}},{key:"delete",value:function(t){var e,n=this.views.get(t);n&&null!==(e=n.payload)&&void 0!==e&&e.id&&(this.views.delete(t),this.viewsElements.delete("".concat(n.type,"_").concat(n.payload.id)))}}]),t}(),C=function(){function t(e,n,i){var a=this;u(this,t),l(this,"translate",function(){var t=s(o().mark((function t(e,n){var i,s;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=r({},a.position),t.next=3,a.guards.translate({previous:i,position:{x:e,y:n}});case 3:if(s=t.sent){t.next=6;break}return t.abrupt("return",!1);case 6:return a.position=r({},s.data.position),a.element.style.transform="translate(".concat(a.position.x,"px, ").concat(a.position.y,"px)"),t.next=10,a.events.translated({position:a.position,previous:i});case 10:return t.abrupt("return",!0);case 11:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),l(this,"resize",function(){var t=s(o().mark((function t(e,n){var r,i;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r={width:e,height:n},t.next=3,a.guards.resize({size:r});case 3:if(t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:if((i=a.element.querySelector("*:not(span):not([fragment])"))&&i instanceof HTMLElement){t.next=8;break}return t.abrupt("return",!1);case 8:return i.style.width="".concat(e,"px"),i.style.height="".concat(n,"px"),t.next=12,a.events.resized({size:r});case 12:return t.abrupt("return",!0);case 13:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()),this.getZoom=e,this.events=n,this.guards=i,this.element=document.createElement("div"),this.element.style.position="absolute",this.position={x:0,y:0},this.translate(0,0),this.element.addEventListener("contextmenu",(function(t){return a.events.contextmenu(t)})),this.dragHandler=new z,this.dragHandler.initialize(this.element,{getCurrentPosition:function(){return a.position},getZoom:function(){return a.getZoom()}},{start:this.events.picked,translate:this.translate,drag:this.events.dragged})}return d(t,[{key:"destroy",value:function(){this.dragHandler.destroy()}}]),t}();function H(t,e){return t.map((function(t){return{view:e.get(t.id),node:t}})).filter((function(t){return t.view})).map((function(t){var e=t.view,n=t.node,r=n.width,o=n.height;return void 0!==r&&void 0!==o?{position:e.position,width:r,height:o}:{position:e.position,width:e.element.clientWidth,height:e.element.clientHeight}}))}var V=function(){function t(){u(this,t),l(this,"entities",new Map),l(this,"pickId",null)}return d(t,[{key:"isSelected",value:function(t){return this.entities.has("".concat(t.label,"_").concat(t.id))}},{key:"add",value:function(t,e){e||this.unselectAll(),this.entities.set("".concat(t.label,"_").concat(t.id),t)}},{key:"remove",value:function(t){var e="".concat(t.label,"_").concat(t.id),n=this.entities.get(e);n&&(this.entities.delete(e),n.unselect())}},{key:"unselectAll",value:function(){var t=this;m(Array.from(this.entities.values())).forEach((function(e){return t.remove(e)}))}},{key:"translate",value:function(t,e){var n=this;this.entities.forEach((function(r){return!n.isPicked(r)&&r.translate(t,e)}))}},{key:"pick",value:function(t){this.pickId="".concat(t.label,"_").concat(t.id)}},{key:"release",value:function(){this.pickId=null}},{key:"isPicked",value:function(t){return this.pickId==="".concat(t.label,"_").concat(t.id)}}]),t}();function M(){return(M=s(o().mark((function t(n,r,a){var s,u,c,d,l,f,p,h,v,y,m,w;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=(a||{}).scale,u=void 0===s?.9:s,c=n.parentScope(e.NodeEditor),d=r.map((function(t){return"object"===i(t)?t:c.getNode(t)})),l=H(d,n.nodeViews),f=L(l),p=[n.container.clientWidth,n.container.clientHeight],v=p[1],y=(h=p[0])/f.width,m=v/f.height,w=Math.min(m*u,y*u,1),n.area.transform.x=h/2-f.center.x*w,n.area.transform.y=v/2-f.center.y*w,t.next=12,n.area.zoom(w,0,0);case 12:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var N=Object.freeze({__proto__:null,getBoundingBox:function(t,n){var r=t.parentScope(e.NodeEditor);return L(H(n.map((function(t){return"object"===i(t)?t:r.getNode(t)})),t.nodeViews))},simpleNodesOrder:function(t){var e=t;e.addPipe((function(t){if(!t||"object"!==i(t)||!("type"in t))return t;if("nodepicked"===t.type){var n=e.nodeViews.get(t.data.id),r=e.area.content;n&&r.reorder(n.element,null)}if("connectioncreated"===t.type){var o=e.connectionViews.get(t.data.id),a=e.area.content;o&&a.reorder(o.element,a.holder.firstChild)}return t}))},restrictor:function(t,e){var n=!(null==e||!e.scaling)&&(!0===e.scaling?{min:.1,max:1}:e.scaling),o=!(null==e||!e.translation)&&(!0===e.translation?{left:0,top:0,right:1e3,bottom:1e3}:e.translation);function a(t){if(!n)throw new Error("scaling param isnt defined");var e="function"==typeof n?n():n,r=e.min,o=e.max;return t<r?r:t>o?o:t}function s(t){if(!o)throw new Error("translation param isnt defined");var e=r({},t),n="function"==typeof o?o():o,i=n.left,a=n.top,s=n.right,u=n.bottom;return e.x<i&&(e.x=i),e.x>s&&(e.x=s),e.y<a&&(e.y=a),e.y>u&&(e.y=u),e}t.addPipe((function(e){if(!e||"object"!==i(e)||!("type"in e))return e;if(n&&"zoom"===e.type)return r(r({},e),{},{data:r(r({},e.data),{},{zoom:a(e.data.zoom)})});if(o&&"zoomed"===e.type){var u=s(t.area.transform);t.area.translate(u.x,u.y)}return o&&"translate"===e.type?r(r({},e),{},{data:r(r({},e.data),{},{position:s(e.data.position)})}):e}))},accumulateOnCtrl:function(){var t=!1;function e(e){"Control"!==e.key&&"Meta"!==e.key||(t=!0)}function n(e){"Control"!==e.key&&"Meta"!==e.key||(t=!1)}return document.addEventListener("keydown",e),document.addEventListener("keyup",n),{active:function(){return t},destroy:function(){document.removeEventListener("keydown",e),document.removeEventListener("keyup",n)}}},selectableNodes:function(t,n,r){var o=null,a=t,s=0;function u(t,r){var i=(o||(o=a.parentScope(e.NodeEditor))).getNode(t);i&&(n.add({label:"node",id:i.id,translate:function(t,e){var n=a.nodeViews.get(i.id),r=null==n?void 0:n.position;r&&n.translate(r.x+t,r.y+e)},unselect:function(){!function(t){t.selected&&(t.selected=!1,a.update("node",t.id))}(i)}},r),function(t){t.selected||(t.selected=!0,a.update("node",t.id))}(i))}return a.addPipe((function(t){if(!t||"object"!==i(t)||!("type"in t))return t;if("nodepicked"===t.type){var e=t.data.id,o=r.accumulating.active();n.pick({id:e,label:"node"}),s=null,u(e,o)}else if("nodetranslated"===t.type){var a=t.data,c=a.id,d=a.position,l=a.previous,f=d.x-l.x,p=d.y-l.y;n.isPicked({id:c,label:"node"})&&n.translate(f,p)}else"pointerdown"===t.type?s=0:"pointermove"===t.type?null!==s&&s++:"pointerup"===t.type&&(null!==s&&s<4&&n.unselectAll(),s=null);return t})),{select:u,unselect:function(t){n.remove({id:t,label:"node"})}}},Selector:V,selector:function(){return new V},showInputControl:function(t,n){var r=null,o=function(){return r||(r=t.parentScope(e.NodeEditor))};t.addPipe((function(e){return"connectioncreated"!==e.type&&"connectionremoved"!==e.type||function(e,r){var i=o().getNode(e);if(i){var a=i.inputs[r];if(!a)throw new Error("cannot find input");var s=a.showControl,u=o().getConnections(),c=Boolean(u.find((function(t){return t.target===e&&t.targetInput===r})));a.showControl=n?n({hasAnyConnection:c,input:a}):!c,a.showControl!==s&&t.update("node",i.id)}}(e.data.target,e.data.targetInput),e}))},snapGrid:function(t,e){var n=t,o=void 0===(null==e?void 0:e.size)?16:e.size,a=void 0===(null==e?void 0:e.dynamic)||e.dynamic;function s(t){return Math.round(t/o)*o}n.addPipe((function(t){if(!t||"object"!==i(t)||!("type"in t))return t;if(a&&"nodetranslate"===t.type){var e=t.data.position,o=s(e.x),u=s(e.y);return r(r({},t),{},{data:r(r({},t.data),{},{position:{x:o,y:u}})})}if(!a&&"nodedragged"===t.type){var c=n.nodeViews.get(t.data.id);if(c){var d=c.position,l=d.x,f=d.y;c.translate(s(l),s(f))}}return t}))},zoomAt:function(t,e,n){return M.apply(this,arguments)}}),A=function(t){f(p,t);var e,n,a,c=y(p);function p(t){var e;return u(this,p),l(v(e=c.call(this,"area")),"nodeViews",new Map),l(v(e),"connectionViews",new Map),l(v(e),"elements",new _),l(v(e),"onContextMenu",(function(t){e.emit({type:"contextmenu",data:{event:t,context:"root"}})})),e.container=t,t.style.overflow="hidden",t.addEventListener("contextmenu",e.onContextMenu),e.addPipe((function(t){return t&&"object"===i(t)&&"type"in t?("nodecreated"===t.type&&e.addNodeView(t.data),"noderemoved"===t.type&&e.removeNodeView(t.data.id),"connectioncreated"===t.type&&e.addConnectionView(t.data),"connectionremoved"===t.type&&e.removeConnectionView(t.data.id),"render"===t.type&&e.elements.set(t.data),"unmount"===t.type&&e.elements.delete(t.data.element),t):t})),e.area=new O(t,{zoomed:function(t){return e.emit({type:"zoomed",data:t})},pointerDown:function(t,n){return e.emit({type:"pointerdown",data:{position:t,event:n}})},pointerMove:function(t,n){return e.emit({type:"pointermove",data:{position:t,event:n}})},pointerUp:function(t,n){return e.emit({type:"pointerup",data:{position:t,event:n}})},resize:function(t){return e.emit({type:"resized",data:{event:t}})},translated:function(t){return e.emit({type:"translated",data:t})},reordered:function(t){return e.emit({type:"reordered",data:{element:t}})}},{translate:function(t){return e.emit({type:"translate",data:t})},zoom:function(t){return e.emit({type:"zoom",data:t})}}),e}return d(p,[{key:"addNodeView",value:function(t){var e=this,n=t.id,o=new C((function(){return e.area.transform.k}),{picked:function(){return e.emit({type:"nodepicked",data:{id:n}})},translated:function(t){return e.emit({type:"nodetranslated",data:r({id:n},t)})},dragged:function(){return e.emit({type:"nodedragged",data:t})},contextmenu:function(n){return e.emit({type:"contextmenu",data:{event:n,context:t}})},resized:function(n){var r=n.size;return e.emit({type:"noderesized",data:{id:t.id,size:r}})}},{translate:function(t){return e.emit({type:"nodetranslate",data:r({id:n},t)})},resize:function(n){var r=n.size;return e.emit({type:"noderesize",data:{id:t.id,size:r}})}});return this.nodeViews.set(n,o),this.area.content.add(o.element),this.emit({type:"render",data:{element:o.element,type:"node",payload:t}}),o}},{key:"removeNodeView",value:function(t){var e=this.nodeViews.get(t);e&&(this.emit({type:"unmount",data:{element:e.element}}),this.nodeViews.delete(t),this.area.content.remove(e.element))}},{key:"addConnectionView",value:function(t){var e=this,n=new S({contextmenu:function(n){return e.emit({type:"contextmenu",data:{event:n,context:t}})}});return this.connectionViews.set(t.id,n),this.area.content.add(n.element),this.emit({type:"render",data:{element:n.element,type:"connection",payload:t}}),n}},{key:"removeConnectionView",value:function(t){var e=this.connectionViews.get(t);e&&(this.emit({type:"unmount",data:{element:e.element}}),this.connectionViews.delete(t),this.area.content.remove(e.element))}},{key:"update",value:(a=s(o().mark((function t(e,n){var r;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=this.elements.get(e,n))){t.next=4;break}return t.next=4,this.emit({type:"render",data:r});case 4:case"end":return t.stop()}}),t,this)}))),function(t,e){return a.apply(this,arguments)})},{key:"resize",value:(n=s(o().mark((function t(e,n,r){var i;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(i=this.nodeViews.get(e))){t.next=5;break}return t.next=4,i.resize(n,r);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return n.apply(this,arguments)})},{key:"translate",value:(e=s(o().mark((function t(e,n){var r,i,a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.x,i=n.y,!(a=this.nodeViews.get(e))){t.next=6;break}return t.next=5,a.translate(r,i);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)}))),function(t,n){return e.apply(this,arguments)})},{key:"destroy",value:function(){var t=this;this.container.removeEventListener("contextmenu",this.onContextMenu),Array.from(this.connectionViews.keys()).forEach((function(e){return t.removeConnectionView(e)})),Array.from(this.nodeViews.keys()).forEach((function(e){return t.removeNodeView(e)})),this.area.destroy()}}]),p}(j);t.Area=O,t.AreaExtensions=N,t.AreaPlugin=A,t.BaseAreaPlugin=j,t.Drag=z,t.NodeView=C,t.Zoom=P,t.usePointerListener=x,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=rete-area-plugin.min.js.map

Sorry, the diff of this file is not supported yet

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