bpmn-js
Version:
A bpmn 2.0 toolkit and web modeler
7 lines • 485 kB
JavaScript
/*! bpmn-js - bpmn-modeler v8.9.1 | Copyright (c) 2014-present, camunda Services GmbH | bpmn.io/license */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).BpmnJS=t()}(this,(function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t={exports:{}};"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}};var n=t.exports;var i=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t=e.exports=function(e,n){if(n||(n=16),void 0===e&&(e=128),e<=0)return"0";for(var i=Math.log(Math.pow(2,e))/Math.log(n),r=2;i===1/0;r*=2)i=Math.log(Math.pow(2,e/r))/Math.log(n)*r;var o=i-Math.floor(i),a="";for(r=0;r<Math.floor(i);r++){a=Math.floor(Math.random()*n).toString(n)+a}if(o){var s=Math.pow(n,o);a=Math.floor(Math.random()*s).toString(n)+a}var c=parseInt(a,n);return c!==1/0&&c>=Math.pow(2,e)?t(e,n):a};t.rack=function(e,n,i){var r=function(r){var a=0;do{if(a++>10){if(!i)throw new Error("too many ID collisions, use more bits");e+=i}var s=t(e,n)}while(Object.hasOwnProperty.call(o,s));return o[s]=r,s},o=r.hats={};return r.get=function(e){return r.hats[e]},r.set=function(e,t){return r.hats[e]=t,r},r.bits=e||128,r.base=n||16,r}}));function r(e){if(!(this instanceof r))return new r(e);e=e||[128,36,1],this._seed=e.length?i.rack(e[0],e[1],e[2]):e}function o(e){return Array.prototype.concat.apply([],e)}r.prototype.next=function(e){return this._seed(e||!0)},r.prototype.nextPrefixed=function(e,t){var n;do{n=e+this.next(!0)}while(this.assigned(n));return this.claim(n,t),n},r.prototype.claim=function(e,t){this._seed.set(e,t||!0)},r.prototype.assigned=function(e){return this._seed.get(e)||!1},r.prototype.unclaim=function(e){delete this._seed.hats[e]},r.prototype.clear=function(){var e,t=this._seed.hats;for(e in t)this.unclaim(e)};var a=Object.prototype.toString,s=Object.prototype.hasOwnProperty;function c(e){return void 0===e}function p(e){return void 0!==e}function l(e){return null==e}function u(e){return"[object Array]"===a.call(e)}function h(e){return"[object Object]"===a.call(e)}function d(e){return"[object Number]"===a.call(e)}function f(e){var t=a.call(e);return"[object Function]"===t||"[object AsyncFunction]"===t||"[object GeneratorFunction]"===t||"[object AsyncGeneratorFunction]"===t||"[object Proxy]"===t}function m(e){return"[object String]"===a.call(e)}function v(e,t){return s.call(e,t)}function y(e,t){var n;return t=N(t),b(e,(function(e,i){if(t(e,i))return n=e,!1})),n}function g(e,t){var n=[];return b(e,(function(e,i){t(e,i)&&n.push(e)})),n}function b(e,t){var n;if(!c(e)){var i=u(e)?j:O;for(var r in e)if(v(e,r)&&!1===t(n=e[r],i(r)))return n}}function x(e,t){return c(e)?[]:(function(e){if(!u(e))throw new Error("must supply array")}(e),t=N(t),e.filter((function(e,n){return!t(e,n)})))}function _(e,t,n){return b(e,(function(e,i){n=t(n,e,i)})),n}function E(e,t){return!!_(e,(function(e,n,i){return e&&t(n,i)}),!0)}function w(e,t){return!!y(e,t)}function S(e,t){var n=[];return b(e,(function(e,i){n.push(t(e,i))})),n}function C(e){return e&&Object.keys(e)||[]}function T(e){return C(e).length}function R(e){return S(e,(function(e){return e}))}function P(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t=B(t),b(e,(function(e){var i=t(e)||"_",r=n[i];r||(r=n[i]=[]),r.push(e)})),n}function A(e){e=B(e);for(var t={},n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];b(i,(function(n){return P(n,e,t)}));var o=S(t,(function(e,t){return e[0]}));return o}var k=A;function M(e,t){t=B(t);var n=[];return b(e,(function(e,i){for(var r=t(e,i),o={d:r,v:e},a=0;a<n.length;a++){if(r<n[a].d)return void n.splice(a,0,o)}n.push(o)})),S(n,(function(e){return e.v}))}function D(e){return function(t){return E(e,(function(e,n){return t[n]===e}))}}function B(e){return f(e)?e:function(t){return t[e]}}function N(e){return f(e)?e:function(t){return t===e}}function O(e){return e}function j(e){return Number(e)}function L(e,t){var n,i,r,o;function a(){var a=Date.now(),c=o+t-a;if(c>0)return s(c);e.apply(r,i),n=o=i=r=void 0}function s(e){n=setTimeout(a,e)}return function(){o=Date.now();for(var e=arguments.length,a=new Array(e),c=0;c<e;c++)a[c]=arguments[c];i=a,r=this,n||s(t)}}function I(e,t){return e.bind(t)}function z(){return(z=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}function F(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return z.apply(void 0,[e].concat(n))}function $(e,t){var n={},i=Object(e);return b(t,(function(t){t in i&&(n[t]=e[t])})),n}function H(e,t){var n={};return b(Object(e),(function(e,i){-1===t.indexOf(i)&&(n[i]=e)})),n}function G(e,t,n){return 2==arguments.length?e.getAttribute(t):null===n?e.removeAttribute(t):(e.setAttribute(t,n),e)}var W=[].indexOf,V=function(e,t){if(W)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},U=/\s+/,q=Object.prototype.toString;function K(e){return new Y(e)}function Y(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function X(e){for(var t;e.childNodes.length;)t=e.childNodes[0],e.removeChild(t);return e}Y.prototype.add=function(e){if(this.list)return this.list.add(e),this;var t=this.array();return~V(t,e)||t.push(e),this.el.className=t.join(" "),this},Y.prototype.remove=function(e){if("[object RegExp]"==q.call(e))return this.removeMatching(e);if(this.list)return this.list.remove(e),this;var t=this.array(),n=V(t,e);return~n&&t.splice(n,1),this.el.className=t.join(" "),this},Y.prototype.removeMatching=function(e){for(var t=this.array(),n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Y.prototype.toggle=function(e,t){return this.list?(void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this):(void 0!==t?t?this.add(e):this.remove(e):this.has(e)?this.remove(e):this.add(e),this)},Y.prototype.array=function(){var e=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(U);return""===e[0]&&e.shift(),e},Y.prototype.has=Y.prototype.contains=function(e){return this.list?this.list.contains(e):!!~V(this.array(),e)};var Z="undefined"!=typeof Element?Element.prototype:{},Q=Z.matches||Z.matchesSelector||Z.webkitMatchesSelector||Z.mozMatchesSelector||Z.msMatchesSelector||Z.oMatchesSelector,J=function(e,t){if(!e||1!==e.nodeType)return!1;if(Q)return Q.call(e,t);for(var n=e.parentNode.querySelectorAll(t),i=0;i<n.length;i++)if(n[i]==e)return!0;return!1};function ee(e,t,n){for(var i=n?e:e.parentNode;i&&i.nodeType!==document.DOCUMENT_NODE&&i.nodeType!==document.DOCUMENT_FRAGMENT_NODE;){if(J(i,t))return i;i=i.parentNode}return J(i,t)?i:null}var te=window.addEventListener?"addEventListener":"attachEvent",ne=window.removeEventListener?"removeEventListener":"detachEvent",ie="addEventListener"!==te?"on":"",re={bind:function(e,t,n,i){return e[te](ie+t,n,i||!1),n},unbind:function(e,t,n,i){return e[ne](ie+t,n,i||!1),n}},oe=["focus","blur"];var ae,se={bind:function(e,t,n,i,r){return-1!==oe.indexOf(n)&&(r=!0),re.bind(e,n,(function(n){var r=n.target||n.srcElement;n.delegateTarget=ee(r,t,!0),n.delegateTarget&&i.call(e,n)}),r)},unbind:function(e,t,n,i){return-1!==oe.indexOf(t)&&(i=!0),re.unbind(e,t,n,i)}},ce=function(e,t){if("string"!=typeof e)throw new TypeError("String expected");t||(t=document);var n=/<([\w:]+)/.exec(e);if(!n)return t.createTextNode(e);e=e.replace(/^\s+|\s+$/g,"");var i=n[1];if("body"==i){return(r=t.createElement("html")).innerHTML=e,r.removeChild(r.lastChild)}var r,o=le[i]||le._default,a=o[0],s=o[1],c=o[2];(r=t.createElement("div")).innerHTML=s+e+c;for(;a--;)r=r.lastChild;if(r.firstChild==r.lastChild)return r.removeChild(r.firstChild);var p=t.createDocumentFragment();for(;r.firstChild;)p.appendChild(r.removeChild(r.firstChild));return p},pe=!1;"undefined"!=typeof document&&((ae=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',pe=!ae.getElementsByTagName("link").length,ae=void 0);var le={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:pe?[1,"X<div>","</div>"]:[0,"",""]};function ue(e,t){return(t=t||document).querySelector(e)}function he(e,t){return(t=t||document).querySelectorAll(e)}function de(e){e.parentNode&&e.parentNode.removeChild(e)}function fe(e,t){return t.appendChild(function(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch(e){}return e}(e,t))}function me(e,t){return fe(t,e),e}le.td=le.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],le.option=le.optgroup=[1,'<select multiple="multiple">',"</select>"],le.thead=le.tbody=le.colgroup=le.caption=le.tfoot=[1,"<table>","</table>"],le.polyline=le.ellipse=le.polygon=le.circle=le.text=le.line=le.path=le.rect=le.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var ve={"alignment-baseline":1,"baseline-shift":1,clip:1,"clip-path":1,"clip-rule":1,color:1,"color-interpolation":1,"color-interpolation-filters":1,"color-profile":1,"color-rendering":1,cursor:1,direction:1,display:1,"dominant-baseline":1,"enable-background":1,fill:1,"fill-opacity":1,"fill-rule":1,filter:1,"flood-color":1,"flood-opacity":1,font:1,"font-family":1,"font-size":2,"font-size-adjust":1,"font-stretch":1,"font-style":1,"font-variant":1,"font-weight":1,"glyph-orientation-horizontal":1,"glyph-orientation-vertical":1,"image-rendering":1,kerning:1,"letter-spacing":1,"lighting-color":1,marker:1,"marker-end":1,"marker-mid":1,"marker-start":1,mask:1,opacity:1,overflow:1,"pointer-events":1,"shape-rendering":1,"stop-color":1,"stop-opacity":1,stroke:1,"stroke-dasharray":1,"stroke-dashoffset":1,"stroke-linecap":1,"stroke-linejoin":1,"stroke-miterlimit":1,"stroke-opacity":1,"stroke-width":2,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function ye(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=ve[i];r?(2===r&&"number"==typeof n&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function ge(e,t,n){if("string"==typeof t){if(void 0===n)return function(e,t){return ve[t]?e.style[t]:e.getAttributeNS(null,t)}(e,t);ye(e,t,n)}else!function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)ye(e,i,t[i])}(e,t);return e}function be(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1}var xe=/\s+/,_e=Object.prototype.toString;function Ee(e){return void 0!==e}function we(e){return new Se(e)}function Se(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function Ce(e){var t=e.parentNode;return t&&t.removeChild(e),e}function Te(e){for(var t;t=e.firstChild;)Ce(t);return e}function Re(e){return e.cloneNode(!0)}Se.prototype.add=function(e){if(this.list)return this.list.add(e),this;var t=this.array();return~be(t,e)||t.push(e),Ee(this.el.className.baseVal)?this.el.className.baseVal=t.join(" "):this.el.className=t.join(" "),this},Se.prototype.remove=function(e){if("[object RegExp]"===_e.call(e))return this.removeMatching(e);if(this.list)return this.list.remove(e),this;var t=this.array(),n=be(t,e);return~n&&t.splice(n,1),this.el.className.baseVal=t.join(" "),this},Se.prototype.removeMatching=function(e){for(var t=this.array(),n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Se.prototype.toggle=function(e,t){return this.list?(Ee(t)?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this):(Ee(t)?t?this.add(e):this.remove(e):this.has(e)?this.remove(e):this.add(e),this)},Se.prototype.array=function(){var e=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(xe);return""===e[0]&&e.shift(),e},Se.prototype.has=Se.prototype.contains=function(e){return this.list?this.list.contains(e):!!~be(this.array(),e)};var Pe="http://www.w3.org/2000/svg",Ae='<svg xmlns="'+Pe+'"';function ke(e){var t=!1;"<svg"===e.substring(0,4)?-1===e.indexOf(Pe)&&(e=Ae+e.substring(4)):(e=Ae+">"+e+"</svg>",t=!0);var n=function(e){var t;return(t=new DOMParser).async=!1,t.parseFromString(e,"text/xml")}(e);if(!t)return n;for(var i=document.createDocumentFragment(),r=n.firstChild;r.firstChild;)i.appendChild(r.firstChild);return i}function Me(e,t){var n;return"<"===e.charAt(0)?(n=ke(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(Pe,e),t&&ge(n,t),n}var De=Me("svg");function Be(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)e[i]=t[i];return e}function Ne(e){return e?De.createSVGTransformFromMatrix(e):De.createSVGTransform()}var Oe=/([&<>]{1})/g,je=/([\n\r"]{1})/g,Le={"&":"&","<":"<",">":">",'"':"'"};function Ie(e,t){return e.replace(t,(function(e,t){return Le[t]||t}))}function ze(e,t){var n,i,r,o,a;switch(e.nodeType){case 3:t.push(Ie(e.textContent,Oe));break;case 1:if(t.push("<",e.tagName),e.hasAttributes())for(n=0,i=(r=e.attributes).length;n<i;++n)o=r.item(n),t.push(" ",o.name,'="',Ie(o.value,je),'"');if(e.hasChildNodes()){for(t.push(">"),n=0,i=(a=e.childNodes).length;n<i;++n)ze(a.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("\x3c!--",Ie(e.nodeValue,Oe),"--\x3e");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function Fe(e,t){var n=ke(t);if(Te(e),t){(function(e){return"#document-fragment"===e.nodeName})(n)||(n=n.documentElement);for(var i,r=(i=n.childNodes,Array.prototype.slice.call(i)),o=0;o<r.length;o++)fe(r[o],e)}}function $e(e,t){if(void 0!==t){try{Fe(e,t)}catch(e){throw new Error("error parsing SVG: "+e.message)}return e}return function(e){for(var t=e.firstChild,n=[];t;)ze(t,n),t=t.nextSibling;return n.join("")}(e)}function He(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function Ge(e,t){var n=e.transform.baseVal;return t&&(Array.isArray(t)||(t=[t]),function(e,t){var n,i;for(e.clear(),n=0;i=t[n];n++)e.appendItem(He(e,i))}(n,t)),n.consolidate()}var We=/^class /;function Ve(e){return"[object Array]"===Object.prototype.toString.call(e)}function Ue(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function qe(){var e=Array.prototype.slice.call(arguments);1===e.length&&Ve(e[0])&&(e=e[0]);var t=e.pop();return t.$inject=e,t}var Ke=/constructor\s*[^(]*\(\s*([^)]*)\)/m,Ye=/^(?:async )?(?:function\s*)?[^(]*\(\s*([^)]*)\)/m,Xe=/\/\*([^*]*)\*\//m;function Ze(e){if("function"!=typeof e)throw new Error('Cannot annotate "'+e+'". Expected a function!');var t=e.toString().match(function(e){return We.test(e.toString())}(e)?Ke:Ye);return t&&t[1]&&t[1].split(",").map((function(e){return(t=e.match(Xe))?t[1].trim():e.trim()}))||[]}function Qe(){var e=[];this.factory=function(t,n){return e.push([t,"factory",n]),this},this.value=function(t,n){return e.push([t,"value",n]),this},this.type=function(t,n){return e.push([t,"type",n]),this},this.forEach=function(t){e.forEach(t)}}function Je(e,t){t=t||{get:function(e,t){if(n.push(e),!1===t)return null;throw a('No provider for "'+e+'"!')}};var n=[],i=this._providers=Object.create(t._providers||null),r=this._instances=Object.create(null),o=r.injector=this,a=function(e){var t=n.join(" -> ");return n.length=0,new Error(t?e+" (Resolving: "+t+")":e)},s=function(e,o){if(!i[e]&&-1!==e.indexOf(".")){for(var c=e.split("."),p=s(c.shift());c.length;)p=p[c.shift()];return p}if(Ue(r,e))return r[e];if(Ue(i,e)){if(-1!==n.indexOf(e))throw n.push(e),a("Cannot resolve circular dependency!");return n.push(e),r[e]=i[e][0](i[e][1]),n.pop(),r[e]}return t.get(e,o)},c=function(e,t){if(void 0===t&&(t={}),"function"!=typeof e){if(!Ve(e))throw new Error('Cannot invoke "'+e+'". Expected a function!');e=qe(e.slice())}return{fn:e,dependencies:(e.$inject||Ze(e)).map((function(e){return Ue(t,e)?t[e]:s(e)}))}},p=function(e){var t=c(e),n=t.fn,i=t.dependencies;return new(Function.prototype.bind.apply(n,[null].concat(i)))},l=function(e,t,n){var i=c(e,n),r=i.fn,o=i.dependencies;return r.apply(t,o)},u=function(e){return qe((function(t){return e.get(t)}))},h={factory:l,type:p,value:function(e){return e}};e.forEach((function(e){function t(e,t){return"value"!==e&&Ve(t)&&(t=qe(t.slice())),t}if(e instanceof Qe)e.forEach((function(e){var n=e[0],r=e[1],o=e[2];i[n]=[h[r],t(r,o),r]}));else if("object"==typeof e)if(e.__exports__){var n=Object.keys(e).reduce((function(t,n){return"__"!==n.substring(0,2)&&(t[n]=e[n]),t}),Object.create(null)),r=new Je((e.__modules__||[]).concat([n]),o),a=qe((function(e){return r.get(e)}));e.__exports__.forEach((function(e){i[e]=[a,e,"private",r]}))}else Object.keys(e).forEach((function(n){if("private"!==e[n][2]){var r=e[n][0],o=e[n][1];i[n]=[h[r],t(r,o),r]}else i[n]=e[n]}))})),this.get=s,this.invoke=l,this.instantiate=p,this.createChild=function(e,t){if(t&&t.length){var n,r,a,s,c=Object.create(null),p=Object.create(null),l=[],h=[],d=[];for(var f in i)n=i[f],-1!==t.indexOf(f)&&("private"===n[2]?-1===(r=l.indexOf(n[3]))?(a=n[3].createChild([],t),s=u(a),l.push(n[3]),h.push(a),d.push(s),c[f]=[s,f,"private",a]):c[f]=[d[r],f,"private",h[r]]:c[f]=[n[2],n[1]],p[f]=!0),"factory"!==n[2]&&"type"!==n[2]||!n[1].$scope||t.forEach((function(e){-1!==n[1].$scope.indexOf(e)&&(c[f]=[n[2],n[1]],p[e]=!0)}));t.forEach((function(e){if(!p[e])throw new Error('No provider for "'+e+'". Cannot use provider from the parent!')})),e.unshift(c)}return new Je(e,o)}}function et(e,t){var n=this;t=t||1e3,e.on(["render.shape","render.connection"],t,(function(e,t){var i=e.type,r=t.element,o=t.gfx,a=t.attrs;if(n.canRender(r))return"render.shape"===i?n.drawShape(o,r,a):n.drawConnection(o,r,a)})),e.on(["render.getShapePath","render.getConnectionPath"],t,(function(e,t){if(n.canRender(t))return"render.getShapePath"===e.type?n.getShapePath(t):n.getConnectionPath(t)}))}function tt(e){return e.join(",").replace(/,?([A-z]),?/g,"$1")}function nt(e){for(var t,n="",i=0;t=e[i];i++)n+=t.x+","+t.y+" ";return n}function it(e,t){var n=Me("polyline");return ge(n,{points:nt(e)}),t&&ge(n,t),n}function rt(e){return g(e,(function(t){return!y(e,(function(e){return e!==t&&ot(t,e)}))}))}function ot(e,t){if(t){if(e===t)return t;if(e.parent)return ot(e.parent,t)}}function at(e,t,n){var i=!n||-1===e.indexOf(t);return i&&e.push(t),i}function st(e,t,n){n=n||0,u(e)||(e=[e]),b(e,(function(e,i){var r=t(e,i,n);u(r)&&r.length&&st(r,t,n+1)}))}function ct(e,t){return function(e,t,n){var i=[],r=[];return st(e,(function(e,o,a){at(i,e,t);var s=e.children;if((-1===n||a<n)&&s&&at(r,s,t))return s})),i}(e,!t,-1)}function pt(e,t){var n,i,r,o;return t=!!t,u(e)||(e=[e]),b(e,(function(e){var a=e;e.waypoints&&!t&&(a=pt(e.waypoints,!0));var s=a.x,c=a.y,p=a.height||0,l=a.width||0;(s<n||void 0===n)&&(n=s),(c<i||void 0===i)&&(i=c),(s+l>r||void 0===r)&&(r=s+l),(c+p>o||void 0===o)&&(o=c+p)})),{x:n,y:i,height:o-i,width:r-n}}function lt(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}function ut(e){return!(!e||!e.isFrame)}function ht(e,t){return F({},e||{},t||{})}et.prototype.canRender=function(){},et.prototype.drawShape=function(){},et.prototype.drawConnection=function(){},et.prototype.getShapePath=function(){},et.prototype.getConnectionPath=function(){};function dt(e,t){et.call(this,e,1),this.CONNECTION_STYLE=t.style(["no-fill"],{strokeWidth:5,stroke:"fuchsia"}),this.SHAPE_STYLE=t.style({fill:"white",stroke:"fuchsia",strokeWidth:2}),this.FRAME_STYLE=t.style(["no-fill"],{stroke:"fuchsia",strokeDasharray:4,strokeWidth:2})}n(dt,et),dt.prototype.canRender=function(){return!0},dt.prototype.drawShape=function(e,t,n){var i=Me("rect");return ge(i,{x:0,y:0,width:t.width||0,height:t.height||0}),ut(t)?ge(i,F({},this.FRAME_STYLE,n||{})):ge(i,F({},this.SHAPE_STYLE,n||{})),me(e,i),i},dt.prototype.drawConnection=function(e,t,n){var i=it(t.waypoints,F({},this.CONNECTION_STYLE,n||{}));return me(e,i),i},dt.prototype.getShapePath=function(e){var t=e.x,n=e.y,i=e.width;return tt([["M",t,n],["l",i,0],["l",0,e.height],["l",-i,0],["z"]])},dt.prototype.getConnectionPath=function(e){var t,n,i=e.waypoints,r=[];for(t=0;n=i[t];t++)n=n.original||n,r.push([0===t?"M":"L",n.x,n.y]);return tt(r)},dt.$inject=["eventBus","styles"];var ft={__init__:["defaultRenderer"],defaultRenderer:["type",dt],styles:["type",function(){var e={"no-fill":{fill:"none"},"no-border":{strokeOpacity:0},"no-events":{pointerEvents:"none"}},t=this;this.cls=function(e,t,n){return F(this.style(t,n),{class:e})},this.style=function(t,n){u(t)||n||(n=t,t=[]);var i=_(t,(function(t,n){return F(t,e[n]||{})}),{});return n?F(i,n):i},this.computeStyle=function(e,n,i){return u(n)||(i=n,n=[]),t.style(n||[],F({},i,e||{}))}}]};function mt(e,t){if(!e||!t)return-1;var n=e.indexOf(t);return-1!==n&&e.splice(n,1),n}function vt(e,t,n){if(e&&t){"number"!=typeof n&&(n=-1);var i=e.indexOf(t);if(-1!==i){if(i===n)return;if(-1===n)return;e.splice(i,1)}-1!==n?e.splice(n,0,t):e.push(t)}}function yt(e,t){return e&&t?e.indexOf(t):-1}function gt(e,t){return e&&t?Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)):-1}function bt(e,t,n,i){if(void 0===i&&(i=5),!e||!t||!n)return!1;var r=(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),o=gt(e,t);return Math.abs(r/o)<=i}function xt(e,t){var n;return function(e,t){var n;n=u(e)?e:[e,t];var i=n.slice().shift();return E(n,(function(e){return Math.abs(i.y-e.y)<=2}))}(n=u(e)?e:[e,t])?"h":!!function(e,t){var n;n=u(e)?e:[e,t];var i=n.slice().shift();return E(n,(function(e){return Math.abs(i.x-e.x)<=2}))}(n)&&"v"}function _t(e,t,n){return n=n||0,e.x>t.x-n&&e.y>t.y-n&&e.x<t.x+t.width+n&&e.y<t.y+t.height+n}function Et(e,t){return{x:Math.round(e.x+(t.x-e.x)/2),y:Math.round(e.y+(t.y-e.y)/2)}}
/**
* This file contains source code adapted from Snap.svg (licensed Apache-2.0).
*
* @see https://github.com/adobe-webplatform/Snap.svg/blob/master/src/path.js
*/var wt=/,?([a-z]),?/gi,St=parseFloat,Ct=Math,Tt=Ct.PI,Rt=Ct.min,Pt=Ct.max,At=Ct.pow,kt=Ct.abs,Mt=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?[\s]*,?[\s]*)+)/gi,Dt=/(-?\d*\.?\d*(?:e[-+]?\d+)?)[\s]*,?[\s]*/gi,Bt=Array.isArray||function(e){return e instanceof Array};function Nt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ot(e){if("function"==typeof e||Object(e)!==e)return e;var t=new e.constructor;for(var n in e)Nt(e,n)&&(t[n]=Ot(e[n]));return t}function jt(e,t){for(var n=0,i=e.length;n<i;n++)if(e[n]===t)return e.push(e.splice(n,1)[0])}function Lt(e){var t=Lt.ps=Lt.ps||{};return t[e]?t[e].sleep=100:t[e]={sleep:100},setTimeout((function(){for(var n in t)Nt(t,n)&&n!=e&&(t[n].sleep--,!t[n].sleep&&delete t[n])})),t[e]}function It(e,t,n,i){return 1===arguments.length&&(t=e.y,n=e.width,i=e.height,e=e.x),{x:e,y:t,width:n,height:i,x2:e+n,y2:t+i}}function zt(){return this.join(",").replace(wt,"$1")}function Ft(e){var t=Ot(e);return t.toString=zt,t}function $t(e,t,n,i,r,o,a,s,c){var p=1-c,l=At(p,3),u=At(p,2),h=c*c*c,d=l*t+3*u*c*i+3*p*c*c*o+h*s;return{x:qt(l*e+3*u*c*n+3*p*c*c*r+h*a),y:qt(d)}}function Ht(e){var t=en.apply(null,e);return It(t.x0,t.y0,t.x1-t.x0,t.y1-t.y0)}function Gt(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function Wt(e,t,n,i,r){return e*(e*(-3*t+9*n-9*i+3*r)+6*t-12*n+6*i)-3*t+3*n}function Vt(e,t,n,i,r,o,a,s,c){null==c&&(c=1);for(var p=(c=c>1?1:c<0?0:c)/2,l=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],u=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],h=0,d=0;d<12;d++){var f=p*l[d]+p,m=Wt(f,e,n,r,a),v=Wt(f,t,i,o,s),y=m*m+v*v;h+=u[d]*Ct.sqrt(y)}return p*h}function Ut(e,t,n,i,r,o,a,s){if(!(Pt(e,n)<Rt(r,a)||Rt(e,n)>Pt(r,a)||Pt(t,i)<Rt(o,s)||Rt(t,i)>Pt(o,s))){var c=(e*i-t*n)*(o-s)-(t-i)*(r*s-o*a),p=(e-n)*(o-s)-(t-i)*(r-a);if(p){var l=qt(((e*i-t*n)*(r-a)-(e-n)*(r*s-o*a))/p),u=qt(c/p),h=+l.toFixed(2),d=+u.toFixed(2);if(!(h<+Rt(e,n).toFixed(2)||h>+Pt(e,n).toFixed(2)||h<+Rt(r,a).toFixed(2)||h>+Pt(r,a).toFixed(2)||d<+Rt(t,i).toFixed(2)||d>+Pt(t,i).toFixed(2)||d<+Rt(o,s).toFixed(2)||d>+Pt(o,s).toFixed(2)))return{x:l,y:u}}}}function qt(e){return Math.round(1e11*e)/1e11}function Kt(e,t,n){if(!function(e,t){return e=It(e),Gt(t=It(t),e.x,e.y)||Gt(t,e.x2,e.y)||Gt(t,e.x,e.y2)||Gt(t,e.x2,e.y2)||Gt(e,t.x,t.y)||Gt(e,t.x2,t.y)||Gt(e,t.x,t.y2)||Gt(e,t.x2,t.y2)||(e.x<t.x2&&e.x>t.x||t.x<e.x2&&t.x>e.x)&&(e.y<t.y2&&e.y>t.y||t.y<e.y2&&t.y>e.y)}(Ht(e),Ht(t)))return n?0:[];for(var i=Vt.apply(0,e),r=Vt.apply(0,t),o=Xt(e)?1:~~(i/5)||1,a=Xt(t)?1:~~(r/5)||1,s=[],c=[],p={},l=n?0:[],u=0;u<o+1;u++){var h=$t.apply(0,e.concat(u/o));s.push({x:h.x,y:h.y,t:u/o})}for(u=0;u<a+1;u++)h=$t.apply(0,t.concat(u/a)),c.push({x:h.x,y:h.y,t:u/a});for(u=0;u<o;u++)for(var d=0;d<a;d++){var f,m=s[u],v=s[u+1],y=c[d],g=c[d+1],b=kt(v.x-m.x)<.01?"y":"x",x=kt(g.x-y.x)<.01?"y":"x",_=Ut(m.x,m.y,v.x,v.y,y.x,y.y,g.x,g.y);if(_){if(p[f=_.x.toFixed(9)+"#"+_.y.toFixed(9)])continue;p[f]=!0;var E=m.t+kt((_[b]-m[b])/(v[b]-m[b]))*(v.t-m.t),w=y.t+kt((_[x]-y[x])/(g[x]-y[x]))*(g.t-y.t);E>=0&&E<=1&&w>=0&&w<=1&&(n?l++:l.push({x:_.x,y:_.y,t1:E,t2:w}))}}return l}function Yt(e){var t=Lt(e);if(t.abs)return Ft(t.abs);if(Bt(e)&&Bt(e&&e[0])||(e=function(e){if(!e)return null;var t=Lt(e);if(t.arr)return Ot(t.arr);var n={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},i=[];return Bt(e)&&Bt(e[0])&&(i=Ot(e)),i.length||String(e).replace(Mt,(function(e,t,r){var o=[],a=t.toLowerCase();for(r.replace(Dt,(function(e,t){t&&o.push(+t)})),"m"==a&&o.length>2&&(i.push([t].concat(o.splice(0,2))),a="l",t="m"==t?"l":"L");o.length>=n[a]&&(i.push([t].concat(o.splice(0,n[a]))),n[a]););})),i.toString=Lt.toString,t.arr=Ot(i),i}(e)),!e||!e.length)return[["M",0,0]];var n,i=[],r=0,o=0,a=0,s=0,c=0;"M"==e[0][0]&&(a=r=+e[0][1],s=o=+e[0][2],c++,i[0]=["M",r,o]);for(var p,l,u=c,h=e.length;u<h;u++){if(i.push(p=[]),(n=(l=e[u])[0])!=n.toUpperCase())switch(p[0]=n.toUpperCase(),p[0]){case"A":p[1]=l[1],p[2]=l[2],p[3]=l[3],p[4]=l[4],p[5]=l[5],p[6]=+l[6]+r,p[7]=+l[7]+o;break;case"V":p[1]=+l[1]+o;break;case"H":p[1]=+l[1]+r;break;case"M":a=+l[1]+r,s=+l[2]+o;default:for(var d=1,f=l.length;d<f;d++)p[d]=+l[d]+(d%2?r:o)}else for(var m=0,v=l.length;m<v;m++)p[m]=l[m];switch(n=n.toUpperCase(),p[0]){case"Z":r=+a,o=+s;break;case"H":r=p[1];break;case"V":o=p[1];break;case"M":a=p[p.length-2],s=p[p.length-1];default:r=p[p.length-2],o=p[p.length-1]}}return i.toString=zt,t.abs=Ft(i),i}function Xt(e){return e[0]===e[2]&&e[1]===e[3]&&e[4]===e[6]&&e[5]===e[7]}function Zt(e,t,n,i){return[e,t,n,i,n,i]}function Qt(e,t,n,i,r,o){var a=1/3,s=2/3;return[a*e+s*n,a*t+s*i,a*r+s*n,a*o+s*i,r,o]}function Jt(e,t,n,i,r,o,a,s,c,p){var l,u,h=120*Tt/180,d=Tt/180*(+r||0),f=[],m=(u=function(e,t,n){return{x:e*Ct.cos(n)-t*Ct.sin(n),y:e*Ct.sin(n)+t*Ct.cos(n)}},function e(){var t=Array.prototype.slice.call(arguments,0),n=t.join("␀"),i=e.cache=e.cache||{},r=e.count=e.count||[];return Nt(i,n)?(jt(r,n),i[n]):(r.length>=1e3&&delete i[r.shift()],r.push(n),i[n]=u.apply(0,t),i[n])});if(p)S=p[0],C=p[1],E=p[2],w=p[3];else{e=(l=m(e,t,-d)).x,t=l.y;var v=(e-(s=(l=m(s,c,-d)).x))/2,y=(t-(c=l.y))/2,g=v*v/(n*n)+y*y/(i*i);g>1&&(n*=g=Ct.sqrt(g),i*=g);var b=n*n,x=i*i,_=(o==a?-1:1)*Ct.sqrt(kt((b*x-b*y*y-x*v*v)/(b*y*y+x*v*v))),E=_*n*y/i+(e+s)/2,w=_*-i*v/n+(t+c)/2,S=Ct.asin(((t-w)/i).toFixed(9)),C=Ct.asin(((c-w)/i).toFixed(9));(S=e<E?Tt-S:S)<0&&(S=2*Tt+S),(C=s<E?Tt-C:C)<0&&(C=2*Tt+C),a&&S>C&&(S-=2*Tt),!a&&C>S&&(C-=2*Tt)}var T=C-S;if(kt(T)>h){var R=C,P=s,A=c;C=S+h*(a&&C>S?1:-1),f=Jt(s=E+n*Ct.cos(C),c=w+i*Ct.sin(C),n,i,r,0,a,P,A,[C,R,E,w])}T=C-S;var k=Ct.cos(S),M=Ct.sin(S),D=Ct.cos(C),B=Ct.sin(C),N=Ct.tan(T/4),O=4/3*n*N,j=4/3*i*N,L=[e,t],I=[e+O*M,t-j*k],z=[s+O*B,c-j*D],F=[s,c];if(I[0]=2*L[0]-I[0],I[1]=2*L[1]-I[1],p)return[I,z,F].concat(f);for(var $=[],H=0,G=(f=[I,z,F].concat(f).join().split(",")).length;H<G;H++)$[H]=H%2?m(f[H-1],f[H],d).y:m(f[H],f[H+1],d).x;return $}function en(e,t,n,i,r,o,a,s){for(var c,p,l,u,h,d,f,m,v=[],y=[[],[]],g=0;g<2;++g)if(0==g?(p=6*e-12*n+6*r,c=-3*e+9*n-9*r+3*a,l=3*n-3*e):(p=6*t-12*i+6*o,c=-3*t+9*i-9*o+3*s,l=3*i-3*t),kt(c)<1e-12){if(kt(p)<1e-12)continue;0<(u=-l/p)&&u<1&&v.push(u)}else f=p*p-4*l*c,m=Ct.sqrt(f),f<0||(0<(h=(-p+m)/(2*c))&&h<1&&v.push(h),0<(d=(-p-m)/(2*c))&&d<1&&v.push(d));for(var b,x=v.length,_=x;x--;)b=1-(u=v[x]),y[0][x]=b*b*b*e+3*b*b*u*n+3*b*u*u*r+u*u*u*a,y[1][x]=b*b*b*t+3*b*b*u*i+3*b*u*u*o+u*u*u*s;return y[0][_]=e,y[1][_]=t,y[0][_+1]=a,y[1][_+1]=s,y[0].length=y[1].length=_+2,{x0:Rt.apply(0,y[0]),y0:Rt.apply(0,y[1]),x1:Pt.apply(0,y[0]),y1:Pt.apply(0,y[1])}}function tn(e){var t=Lt(e);if(t.curve)return Ft(t.curve);for(var n=Yt(e),i={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},r=function(e,t,n){var i,r;if(!e)return["C",t.x,t.y,t.x,t.y,t.x,t.y];switch(!(e[0]in{T:1,Q:1})&&(t.qx=t.qy=null),e[0]){case"M":t.X=e[1],t.Y=e[2];break;case"A":e=["C"].concat(Jt.apply(0,[t.x,t.y].concat(e.slice(1))));break;case"S":"C"==n||"S"==n?(i=2*t.x-t.bx,r=2*t.y-t.by):(i=t.x,r=t.y),e=["C",i,r].concat(e.slice(1));break;case"T":"Q"==n||"T"==n?(t.qx=2*t.x-t.qx,t.qy=2*t.y-t.qy):(t.qx=t.x,t.qy=t.y),e=["C"].concat(Qt(t.x,t.y,t.qx,t.qy,e[1],e[2]));break;case"Q":t.qx=e[1],t.qy=e[2],e=["C"].concat(Qt(t.x,t.y,e[1],e[2],e[3],e[4]));break;case"L":e=["C"].concat(Zt(t.x,t.y,e[1],e[2]));break;case"H":e=["C"].concat(Zt(t.x,t.y,e[1],t.y));break;case"V":e=["C"].concat(Zt(t.x,t.y,t.x,e[1]));break;case"Z":e=["C"].concat(Zt(t.x,t.y,t.X,t.Y))}return e},o=function(e,t){if(e[t].length>7){e[t].shift();for(var i=e[t];i.length;)a[t]="A",e.splice(t++,0,["C"].concat(i.splice(0,6)));e.splice(t,1),l=n.length}},a=[],s="",c="",p=0,l=n.length;p<l;p++){n[p]&&(s=n[p][0]),"C"!=s&&(a[p]=s,p&&(c=a[p-1])),n[p]=r(n[p],i,c),"A"!=a[p]&&"C"==s&&(a[p]="C"),o(n,p);var u=n[p],h=u.length;i.x=u[h-2],i.y=u[h-1],i.bx=St(u[h-4])||i.x,i.by=St(u[h-3])||i.y}return t.curve=Ft(n),n}var nn=function(e,t,n){e=tn(e),t=tn(t);for(var i,r,o,a,s,c,p,l,u,h,d=n?0:[],f=0,m=e.length;f<m;f++){var v=e[f];if("M"==v[0])i=s=v[1],r=c=v[2];else{"C"==v[0]?(u=[i,r].concat(v.slice(1)),i=u[6],r=u[7]):(u=[i,r,i,r,s,c,s,c],i=s,r=c);for(var y=0,g=t.length;y<g;y++){var b=t[y];if("M"==b[0])o=p=b[1],a=l=b[2];else{"C"==b[0]?(h=[o,a].concat(b.slice(1)),o=h[6],a=h[7]):(h=[o,a,o,a,p,l,p,l],o=p,a=l);var x=Kt(u,h,n);if(n)d+=x;else{for(var _=0,E=x.length;_<E;_++)x[_].segment1=f,x[_].segment2=y,x[_].bez1=u,x[_].bez2=h;d=d.concat(x)}}}}}return d};function rn(e){return{x:Math.round(e.x),y:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height)}}function on(e){return{x:Math.round(e.x),y:Math.round(e.y)}}function an(e){return{top:e.y,right:e.x+(e.width||0),bottom:e.y+(e.height||0),left:e.x}}function sn(e){return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}function cn(e){return on({x:e.x+(e.width||0)/2,y:e.y+(e.height||0)/2})}function pn(e,t,n){h(n=n||0)||(n={x:n,y:n});var i=an(e),r=an(t),o=i.bottom+n.y<=r.top,a=i.left-n.x>=r.right,s=i.top-n.y>=r.bottom,c=o?"top":s?"bottom":null,p=i.right+n.x<=r.left?"left":a?"right":null;return p&&c?c+"-"+p:p||c||"intersect"}function ln(e,t,n){var i=nn(e,t);return 1===i.length||2===i.length&>(i[0],i[1])<1?on(i[0]):i.length>1?on((i=M(i,(function(e){var t=Math.floor(100*e.t2)||1;return t=((t=100-t)<10?"0":"")+t,e.segment2+"#"+t})))[n?0:i.length-1]):null}function un(e,t){return Math.round(e*t)/t}function hn(e){return d(e)?e+"px":e}function dn(e,t,n){var i=Me("g");we(i).add(t);var r=void 0!==n?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[r]||null),i}var fn="base",mn="djs-element-hidden",vn={shape:["x","y","width","height"],connection:["waypoints"]};function yn(e,t,n,i){this._eventBus=t,this._elementRegistry=i,this._graphicsFactory=n,this._init(e||{})}function gn(e,t){var n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}yn.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],yn.prototype._init=function(e){var t=this._eventBus,n=this._container=function(e){var t=(e=F({},{width:"100%",height:"100%"},e)).container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container"),F(n.style,{position:"relative",overflow:"hidden",width:hn(e.width),height:hn(e.height)}),t.appendChild(n),n}(e),i=this._svg=Me("svg");ge(i,{width:"100%",height:"100%"}),me(n,i);var r=this._viewport=dn(i,"viewport");this._layers={},this._planes={},!1!==e.deferUpdate&&(this._viewboxChanged=L(I(this._viewboxChanged,this),300)),t.on("diagram.init",(function(){t.fire("canvas.init",{svg:i,viewport:r})}),this),t.on(["shape.added","connection.added","shape.removed","connection.removed","elements.changed","plane.set"],(function(){delete this._cachedViewbox}),this),t.on("diagram.destroy",500,this._destroy,this),t.on("diagram.clear",500,this._clear,this)},yn.prototype._destroy=function(e){this._eventBus.fire("canvas.destroy",{svg:this._svg,viewport:this._viewport});var t=this._container.parentNode;t&&t.removeChild(this._container),delete this._svg,delete this._container,delete this._layers,delete this._planes,delete this._activePlane,delete this._viewport},yn.prototype._clear=function(){var e=this;this._elementRegistry.getAll().forEach((function(t){var n=lt(t);"root"===n?e.setRootElementForPlane(null,e.findPlane(t),!0):e._removeElement(t,n)})),this._activePlane=null,this._planes={},delete this._cachedViewbox},yn.prototype.getDefaultLayer=function(){return this.getLayer(fn,0)},yn.prototype.getLayer=function(e,t){if(!e)throw new Error("must specify a name");var n=this._layers[e];if(n||(n=this._layers[e]=this._createLayer(e,t)),void 0!==t&&n.index!==t)throw new Error("layer <"+e+"> already created at index <"+t+">");return n.group},yn.prototype._createLayer=function(e,t){void 0===t&&(t=1);var n=_(this._layers,(function(e,n){return t>=n.index&&e++,e}),0);return{group:dn(this._viewport,"layer-"+e,n),index:t}},yn.prototype.getPlane=function(e){if(!e)throw new Error("must specify a name");return this._planes[e]},yn.prototype.createPlane=function(e,t){if(!e)throw new Error("must specify a name");if(this._planes[e])throw new Error("plane "+e+" already exists");t||(t={id:"__implicitroot"+e,children:[],isImplicit:!0});var n=this.getLayer(e,0);we(n).add(mn);var i=this._planes[e]={layer:n,name:e,rootElement:null};return this.setRootElementForPlane(t,i),i},yn.prototype.setActivePlane=function(e){if(!e)throw new Error("must specify a plane");return"string"==typeof e&&(e=this.getPlane(e)),this._activePlane&&we(this._activePlane.layer).add(mn),this._activePlane=e,we(e.layer).remove(mn),e.rootElement&&this._elementRegistry.updateGraphics(e.rootElement,this._svg,!0),this._eventBus.fire("plane.set",{plane:e}),e},yn.prototype.getActiveLayer=function(){return this.getActivePlane().layer},yn.prototype.getActivePlane=function(){var e=this._activePlane;return e||(e=this.createPlane(fn),this.setActivePlane(fn)),e},yn.prototype.findPlane=function(e){"string"==typeof e&&(e=this._elementRegistry.get(e));var t=function(e){for(;e.parent;)e=e.parent;return e}(e);return y(this._planes,(function(e){return e.rootElement===t}))},yn.prototype.getContainer=function(){return this._container},yn.prototype._updateMarker=function(e,t,n){var i;e.id||(e=this._elementRegistry.get(e)),(i=this._elementRegistry._elements[e.id])&&(b([i.gfx,i.secondaryGfx],(function(e){e&&(n?we(e).add(t):we(e).remove(t))})),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},yn.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},yn.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},yn.prototype.hasMarker=function(e,t){return e.id||(e=this._elementRegistry.get(e)),we(this.getGraphics(e)).has(t)},yn.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},yn.prototype.getRootElement=function(){return this.getActivePlane().rootElement},yn.prototype.setRootElement=function(e,t){var n=this._activePlane;if(n)return this.setRootElementForPlane(e,n,t);var i=this.createPlane(fn,e);return this.setActivePlane(i),i.rootElement},yn.prototype.setRootElementForPlane=function(e,t,n){"string"==typeof t&&(t=this.getPlane(t)),e&&this._ensureValid("root",e);var i=t.rootElement,r=this._elementRegistry,o=this._eventBus;if(i){if(!n)throw new Error("rootElement already set, need to specify override");o.fire("root.remove",{element:i}),o.fire("root.removed",{element:i}),r.remove(i)}if(e){var a=t.layer;o.fire("root.add",{element:e}),r.add(e,a),o.fire("root.added",{element:e,gfx:a}),t===this._activePlane&&this._elementRegistry.updateGraphics(e,this._svg,!0)}return t.rootElement=e,e},yn.prototype._ensureValid=function(e,t){if(!t.id)throw new Error("element must have an id");if(this._elementRegistry.get(t.id))throw new Error("element with id "+t.id+" already exists");var n=vn[e];if(!E(n,(function(e){return void 0!==t[e]})))throw new Error("must supply { "+n.join(", ")+" } with "+e)},yn.prototype._setParent=function(e,t,n){vt(t.children,e,n),e.parent=t},yn.prototype._addElement=function(e,t,n,i){n=n||this.getRootElement();var r=this._eventBus,o=this._graphicsFactory;this._ensureValid(e,t),r.fire(e+".add",{element:t,parent:n}),this._setParent(t,n,i);var a=o.create(e,t,i);return this._elementRegistry.add(t,a),o.update(e,t,a),r.fire(e+".added",{element:t,gfx:a}),t},yn.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},yn.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},yn.prototype._removeElement=function(e,t){var n=this._elementRegistry,i=this._graphicsFactory,r=this._eventBus;if(e=n.get(e.id||e))return r.fire(t+".remove",{element:e}),i.remove(e),mt(e.parent&&e.parent.children,e),e.parent=null,r.fire(t+".removed",{element:e}),n.remove(e),e},yn.prototype.removeShape=function(e){return this._removeElement(e,"shape")},yn.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},yn.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},yn.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},yn.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},yn.prototype.viewbox=function(e){if(void 0===e&&this._cachedViewbox)return this._cachedViewbox;var t,n,i,r,o,a,s=this._viewport,c=this.getSize();return e?(this._changeViewbox((function(){r=Math.min(c.width/e.width,c.height/e.height);var t=this._svg.createSVGMatrix().scale(r).translate(-e.x,-e.y);Ge(s,t)})),e):(t=this._activePlane&&this._activePlane.layer.getBBox()||{},n=(i=Ge(s))?i.matrix:function(e,t,n,i,r,o){var a=De.createSVGMatrix();switch(arguments.length){case 0:return a;case 1:return Be(a,e);case 6:return Be(a,{a:e,b:t,c:n,d:i,e:r,f:o})}}(),r=un(n.a,1e3),o=un(-n.e||0,1e3),a=un(-n.f||0,1e3),e=this._cachedViewbox={x:o?o/r:0,y:a?a/r:0,width:c.width/r,height:c.height/r,scale:r,inner:{width:t.width||0,height:t.height||0,x:t.x||0,y:t.y||0},outer:c})},yn.prototype.scroll=function(e){var t=this._viewport,n=t.getCTM();return e&&this._changeViewbox((function(){e=F({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),gn(t,n)})),{x:n.e,y:n.f}},yn.prototype.scrollToElement=function(e,t){var n=100;"string"==typeof e&&(e=this._elementRegistry.get(e));var i=this.findPlane(e);i!==this._activePlane&&this.setActivePlane(i),t||(t={}),"number"==typeof t&&(n=t),t={top:t.top||n,right:t.right||n,bottom:t.bottom||n,left:t.left||n};var r,o,a=pt(e),s=an(a),c=this.viewbox(),p=this.zoom();c.y+=t.top/p,c.x+=t.left/p,c.width-=(t.right+t.left)/p,c.height-=(t.bottom+t.top)/p;var l=an(c);if(a.width<c.width&&a.height<c.height){var u=Math.max(0,s.right-l.right),h=Math.min(0,s.left-l.left),d=Math.max(0,s.bottom-l.bottom),f=Math.min(0,s.top-l.top);r=u||h,o=d||f}else r=a.x-c.x,o=a.y-c.y;this.scroll({dx:-r*p,dy:-o*p})},yn.prototype.zoom=function(e,t){return e?"fit-viewport"===e?this._fitViewport(t):(this._changeViewbox((function(){"object"!=typeof t&&(n=this.viewbox().outer,t={x:n.width/2,y:n.height/2}),i=this._setZoom(e,t)})),un(i.a,1e3)):this.viewbox(e).scale;var n,i},yn.prototype._fitViewport=function(e){var t,n,i=this.viewbox(),r=i.outer,o=i.inner;return o.x>=0&&o.y>=0&&o.x+o.width<=r.width&&o.y+o.height<=r.height&&!e?n={x:0,y:0,width:Math.max(o.width+o.x,r.width),height:Math.max(o.height+o.y,r.height)}:(t=Math.min(1,r.width/o.width,r.height/o.height),n={x:o.x+(e?o.width/2-r.width/t/2:0),y:o.y+(e?o.height/2-r.height/t/2:0),width:r.width/t,height:r.height/t}),this.viewbox(n),this.viewbox(!1).scale},yn.prototype._setZoom=function(e,t){var n,i,r,o,a=this._svg,s=this._viewport,c=a.createSVGMatrix(),p=a.createSVGPoint(),l=(i=s.getCTM()).a;return t?(n=F(p,t).matrixTransform(i.inverse()),r=c.translate(n.x,n.y).scale(1/l*e).translate(-n.x,-n.y),o=i.multiply(r)):o=c.scale(e),gn(this._viewport,o),o},yn.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},yn.prototype.getAbsoluteBBox=function(e){var t,n=this.viewbox();e.waypoints?t=this.getGraphics(e).getBBox():t=e;return{x:t.x*n.scale-n.x*n.scale,y:t.y*n.scale-n.y*n.scale,width:t.width*n.scale,height:t.height*n.scale}},yn.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var bn="data-element-id";function xn(e){this._elements={},this._eventBus=e}xn.$inject=["eventBus"],xn.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),ge(t,bn,i),n&&ge(n,bn,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},xn.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(ge(i.gfx,bn,""),i.secondaryGfx&&ge(i.secondaryGfx,bn,""),delete t[n])},xn.prototype.updateId=function(e,t){this._validateId(t),"string"==typeof e&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t});var n=this.getGraphics(e),i=this.getGraphics(e,!0);this.remove(e),e.id=t,this.add(e,n,i)},xn.prototype.updateGraphics=function(e,t,n){var i=e.id||e,r=this._elements[i];return n?r.secondaryGfx=t:r.gfx=t,ge(t,bn,i),t},xn.prototype.get=function(e){var t;t="string"==typeof e?e:e&&ge(e,bn);var n=this._elements[t];return n&&n.element},xn.prototype.filter=function(e){var t=[];return this.forEach((function(n,i){e(n,i)&&t.push(n)})),t},xn.prototype.find=function(e){for(var t=this._elements,n=Object.keys(t),i=0;i<n.length;i++){var r=t[n[i]],o=r.element;if(e(o,r.gfx))return o}},xn.prototype.getAll=function(){return this.filter((function(e){return e}))},xn.prototype.forEach=function(e){var t=this._elements;Object.keys(t).forEach((function(n){var i=t[n],r=i.element,o=i.gfx;return e(r,o)}))},xn.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},xn.prototype._validateId=function(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")};var _n={exports:{}},En={};En.extend=function(e,t,n,i){var r=n.inverse;return Object.defineProperty(e,"remove",{value:function(e){var n=this.indexOf(e);return-1!==n&&(this.splice(n,1),t.unset(e,r,i)),e}}),Object.defineProperty(e,"contains",{value:function(e){return-1!==this.indexOf(e)}}),Object.defineProperty(e,"add",{value:function(e,n){var o=this.indexOf(e);if(void 0===n){if(-1!==o)return;n=this.length}-1!==o&&this.splice(o,1),this.splice(n,0,e),-1===o&&t.set(e,r,i)}}),Object.defineProperty(e,"__refs_collection",{value:!0}),e},En.isExtended=function(e){return!0===e.__refs_collection};var wn=En;function Sn(e,t,n){var i=wn.extend(n[t.name]||[],e,t,n);Object.defineProperty(n,t.name,{enumerable:t.enumerable,value:i}),i.length&&i.forEach((function(i){e.set(i,t.inverse,n)}))}function Cn(e,t){if(!(this instanceof Cn))return new Cn(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}Cn.prototype.bind=function(e,t){if("string"==typeof t){if(!this.props[t])throw new Error("no property <"+t+"> in ref");t=this.props[t]}t.collection?Sn(this,t,e):function(e,t,n){var i=t.inverse,r=n[t.name];Object.defineProperty(n,t.name,{configurable:t.configurable,enumerable:t.enumerable,get:function(){return r},set:function(t){if(t!==r){var o=r;r=null,o&&e.unset(o,i,n),r=t,e.set(r,i,n)}}})}(this,t,e)},Cn.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return wn.isExtended(n)||Sn(this,t,e),n},Cn.prototype.ensureBound=function(e,t){(function(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)})(e,t)||this.bind(e,t)},Cn.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},Cn.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var Tn=Cn;_n.exports=Tn,_n.exports.Collection=En;var Rn=_n.exports,Pn=new Rn({name:"children",enumerable:!0,collection:!0},{name:"parent"}),An=new Rn({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),kn=new Rn({name:"attachers",collection:!0},{name:"host"}),Mn=new Rn({name:"outgoing",collection:!0},{name:"source"}),Dn=new Rn({name:"incoming",collection:!0},{name:"target"});function Bn(){Object.defineProperty(this,"businessObject",{writable:!0}),Object.defineProperty(this,"label",{get:function(){return this.labels[0]},set:function(e){var t=this.label,n=this.labels;!e&&t?n.remove(t):n.add(e,0)}}),Pn.bind(this,"parent"),An.bind(this,"labels"),Mn.bind(this,"outgoing"),Dn.bind(this,"incoming")}function Nn(){Bn.call(this),Pn.bind(this,"children"),kn.bind(this,"host"),kn.bind(this,"attachers")}function On(){Nn.call(this)}function jn(){Nn.call(this),An.bind(this,"labelTarget")}function Ln(){Bn.call(this),Mn.bind(this,"source"),Dn.bind(this,"target")}n(Nn,Bn),n(On,Nn),n(jn,Nn),n(Ln,Bn);var In={connection:Ln,shape:Nn,label:jn,root:On};function zn(){this._uid=12}zn.prototype.createRoot=function(e){return this.create("root",e)},zn.prototype.createLabel=function(e){return this.create("label",e)},zn.prototype.createShape=function(e){return this.create("shape",e)},zn.prototype.createConnection=function(e){return this.create("connection",e)},zn.prototype.create=function(e,t){return(t=F({},t||{})).id||(t.id=e+"_"+this._uid++),function(e,t){var n=In[e];if(!n)throw new Error("unknown type: <"+e+">");return F(new n,t)}(e,t)};var Fn=Array.prototype.slice;function $n(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}function Hn(){}function Gn(e){return e.childNodes[0]}function Wn(e,t,n,i,r){var o=Ne();o.setTranslate(t,n);var a=Ne();a.setRotate(i||0,0,0);var s=Ne();s.setScale(r||1,r||1),Ge(e,[o,a,s])}function Vn(e,t,n){var i=Ne();i.setTranslate(t,n),Ge(e,i)}function Un(e,t){var n=Ne();n.setRotate(t,0,0),Ge(e,n)}function qn(e,t){this._eventBus=e,this._elementRegistry=t}function Kn(e,t,n){var i=n||t.firstChild;e!==i&&t.insertBefore(e,i)}$n.prototype.on=function(e,t,n,i){if(e=u(e)?e:[e],f(t)&&(i=n,n=t,t=1e3),!d(t))throw new Error("priority must be a number");var r=n;i&&((r=I(n,i)).__fn=n.__fn||n);var o=this;e.forEach((function(e){o._addListener(e,{priority:t,callback:r,next:null})}))},$n.prototype.once=function(e,t,n,i){var r=this;if(f(t)&&(i=n,n=t,t=1e3),!d(t))throw new Error("priority must be a number");function o(){o.__isTomb=!0;var t=n.apply(i,arguments);return r.off(e,o),t}o.__fn=n,this.on(e,t,o)},$n.prototype.off=function(e,t){e=u(e)?e:[e];var n=this;e.forEach((function(e){n._removeListener(e,t)}))},$n.prototype.createEvent=function(e){var t=new Hn;return t.init(e),t},$n.prototype.fire=function(e,t){var n,i,r,o;if(o=Fn.call(arguments),"object"==typeof e&&(e=(t=e).type),!e)throw new Error("no event type specified");if(i=this._listeners[e]){n=t instanceof Hn?t:this.createEvent(t),o[0]=n;var a=n.type;e!==a&&(n.type=e);try{r=this._invokeListeners(n,o,i)}finally{e!==a&&(n.type=a)}return void 0===r&&n.defaultPrevented&&(r=!1),r}},$n.prototype.handleError=function(e){return!1===this.fire("error",{error:e})},$n.prototype._destroy=function(){this._listeners={}},$n.prototype._invokeListeners=function(e,t,n){for(var i;n&&!e.cancelBubble;)i=this._invokeListener(e,t,n),n=n.next;return i},$n.prototype._invokeListener=function(e,t,n){var i;if(n.callback.__isTomb)return i;try{void 0!==(i=function(e,t){return e.apply(null,t)}(n.callback,t))&&(e.returnValue=i,e.stopPropagation()),!1===i&&e.preventDefault()}catch(e){if(!this.handleError(e))throw console.error("unhandled error in event listener",e),e}return i},$n.prototype._addListener=function(e,t){var n,i=this._getListeners(e);if(i){for(;i;){if(i.priority<t.priority)return t.next=i,void(n?n.next=t:this._setListeners(e,t));n=i,i=i.next}n.next=t}else this._setListeners(e,t)},$n.prototype._getListeners=function(e){return this._listeners[e]},$n.prototype._setListeners=function(e,t){this._listeners[e]=t},$n.prototype._removeListener=function(e,t){var n,i,r,o=this._getListeners(e);if(t)for(;o;)n=o.next,(r=o.callback)!==t&&r.__fn!==t||(i?i.next=n:this._setListeners(e,n)),i=o,o=n;else this._setListeners(e,null)},Hn.prototype.stopPropagation=function(){this.cancelBubble=!0},Hn.prototype.preventDefault=function(){this.defaultPrevented=!0},Hn.prototype.init=function(e){F(this,e||{})},qn.$inject=["eventBus","elementRegistry"],qn.prototype._getChildrenContainer=function(e){var t,n=this._elementRegistry.getGraphics(e);return e.parent?(t=function(e){return e.parentNode.childNodes[1]}(n))||(we(t=Me("g")).add("djs-children"),me(n.parentNode,t)):t=n,t},qn.prototype._clear=function(e){var t=Gn(e);return X(t),t},qn.prototype._createContainer=function(e,t,n,i){var r=Me("g");we(r).add("djs-group"),void 0!==n?Kn(r,t,t.childNodes[n]):me(t,r);var o=Me("g");we(o).add("djs-element"),we(o).add("djs-"+e),i&&we(o).add("djs-frame"),me(r,o);var a=Me("g");return we(a).add("djs-visual"),me(o,a),o},qn.prototype.create=function(e,t,n){var i=this._getChildrenContainer(t.parent);r