bpmn-js 8.9.0 → 8.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/bpmn-modeler.development.js +67 -86
- package/dist/bpmn-modeler.production.min.js +2 -2
- package/dist/bpmn-navigated-viewer.development.js +2 -2
- package/dist/bpmn-navigated-viewer.production.min.js +1 -1
- package/dist/bpmn-viewer.development.js +2 -2
- package/dist/bpmn-viewer.production.min.js +1 -1
- package/lib/features/modeling/BpmnFactory.js +4 -0
- package/lib/features/modeling/behavior/CreateParticipantBehavior.js +59 -84
- package/lib/features/modeling/behavior/UnclaimIdBehavior.js +3 -1
- package/lib/features/popup-menu/ReplaceMenuProvider.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! bpmn-js - bpmn-modeler v8.9.
|
|
1
|
+
/*! bpmn-js - bpmn-modeler v8.9.1 | Copyright (c) 2014-present, camunda Services GmbH | bpmn.io/license */
|
|
2
2
|
!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)}}
|
|
3
3
|
/**
|
|
4
4
|
* This file contains source code adapted from Snap.svg (licensed Apache-2.0).
|
|
@@ -31,4 +31,4 @@ var t,n;e=F({},Tr,e),this._moddle=this._createModdle(e),this._container=this._cr
|
|
|
31
31
|
*
|
|
32
32
|
* Copyright (c) 2016 Jorik Tangelder;
|
|
33
33
|
* Licensed under the MIT license */!function(e){!function(t,n,i,r){var o,a=["","webkit","Moz","MS","ms","o"],s=n.createElement("div"),c=Math.round,p=Math.abs,l=Date.now;function u(e,t,n){return setTimeout(g(e,n),t)}function h(e,t,n){return!!Array.isArray(e)&&(d(e,n[t],n),!0)}function d(e,t,n){var i;if(e)if(e.forEach)e.forEach(t,n);else if(e.length!==r)for(i=0;i<e.length;)t.call(n,e[i],i,e),i++;else for(i in e)e.hasOwnProperty(i)&&t.call(n,e[i],i,e)}function f(e,n,i){var r="DEPRECATED METHOD: "+n+"\n"+i+" AT \n";return function(){var n=new Error("get-stack-trace"),i=n&&n.stack?n.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",o=t.console&&(t.console.warn||t.console.log);return o&&o.call(t.console,r,i),e.apply(this,arguments)}}o="function"!=typeof Object.assign?function(e){if(e===r||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==r&&null!==i)for(var o in i)i.hasOwnProperty(o)&&(t[o]=i[o])}return t}:Object.assign;var m=f((function(e,t,n){for(var i=Object.keys(t),o=0;o<i.length;)(!n||n&&e[i[o]]===r)&&(e[i[o]]=t[i[o]]),o++;return e}),"extend","Use `assign`."),v=f((function(e,t){return m(e,t,!0)}),"merge","Use `assign`.");function y(e,t,n){var i,r=t.prototype;(i=e.prototype=Object.create(r)).constructor=e,i._super=r,n&&o(i,n)}function g(e,t){return function(){return e.apply(t,arguments)}}function b(e,t){return"function"==typeof e?e.apply(t&&t[0]||r,t):e}function x(e,t){return e===r?t:e}function _(e,t,n){d(C(t),(function(t){e.addEventListener(t,n,!1)}))}function E(e,t,n){d(C(t),(function(t){e.removeEventListener(t,n,!1)}))}function w(e,t){for(;e;){if(e==t)return!0;e=e.parentNode}return!1}function S(e,t){return e.indexOf(t)>-1}function C(e){return e.trim().split(/\s+/g)}function T(e,t,n){if(e.indexOf&&!n)return e.indexOf(t);for(var i=0;i<e.length;){if(n&&e[i][n]==t||!n&&e[i]===t)return i;i++}return-1}function R(e){return Array.prototype.slice.call(e,0)}function P(e,t,n){for(var i=[],r=[],o=0;o<e.length;){var a=t?e[o][t]:e[o];T(r,a)<0&&i.push(e[o]),r[o]=a,o++}return n&&(i=t?i.sort((function(e,n){return e[t]>n[t]})):i.sort()),i}function A(e,t){for(var n,i,o=t[0].toUpperCase()+t.slice(1),s=0;s<a.length;){if((i=(n=a[s])?n+o:t)in e)return i;s++}return r}var k=1;function M(e){var n=e.ownerDocument||e;return n.defaultView||n.parentWindow||t}var D="ontouchstart"in t,B=A(t,"PointerEvent")!==r,N=D&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),O="touch",j="mouse",L=24,I=["x","y"],z=["clientX","clientY"];function F(e,t){var n=this;this.manager=e,this.callback=t,this.element=e.element,this.target=e.options.inputTarget,this.domHandler=function(t){b(e.options.enable,[e])&&n.handler(t)},this.init()}function $(e,t,n){var i=n.pointers.length,o=n.changedPointers.length,a=1&t&&i-o==0,s=12&t&&i-o==0;n.isFirst=!!a,n.isFinal=!!s,a&&(e.session={}),n.eventType=t,function(e,t){var n=e.session,i=t.pointers,o=i.length;n.firstInput||(n.firstInput=H(t));o>1&&!n.firstMultiple?n.firstMultiple=H(t):1===o&&(n.firstMultiple=!1);var a=n.firstInput,s=n.firstMultiple,c=s?s.center:a.center,u=t.center=G(i);t.timeStamp=l(),t.deltaTime=t.timeStamp-a.timeStamp,t.angle=q(c,u),t.distance=U(c,u),function(e,t){var n=t.center,i=e.offsetDelta||{},r=e.prevDelta||{},o=e.prevInput||{};1!==t.eventType&&4!==o.eventType||(r=e.prevDelta={x:o.deltaX||0,y:o.deltaY||0},i=e.offsetDelta={x:n.x,y:n.y});t.deltaX=r.x+(n.x-i.x),t.deltaY=r.y+(n.y-i.y)}(n,t),t.offsetDirection=V(t.deltaX,t.deltaY);var h=W(t.deltaTime,t.deltaX,t.deltaY);t.overallVelocityX=h.x,t.overallVelocityY=h.y,t.overallVelocity=p(h.x)>p(h.y)?h.x:h.y,t.scale=s?(d=s.pointers,f=i,U(f[0],f[1],z)/U(d[0],d[1],z)):1,t.rotation=s?function(e,t){return q(t[1],t[0],z)+q(e[1],e[0],z)}(s.pointers,i):0,t.maxPointers=n.prevInput?t.pointers.length>n.prevInput.maxPointers?t.pointers.length:n.prevInput.maxPointers:t.pointers.length,function(e,t){var n,i,o,a,s=e.lastInterval||t,c=t.timeStamp-s.timeStamp;if(8!=t.eventType&&(c>25||s.velocity===r)){var l=t.deltaX-s.deltaX,u=t.deltaY-s.deltaY,h=W(c,l,u);i=h.x,o=h.y,n=p(h.x)>p(h.y)?h.x:h.y,a=V(l,u),e.lastInterval=t}else n=s.velocity,i=s.velocityX,o=s.velocityY,a=s.direction;t.velocity=n,t.velocityX=i,t.velocityY=o,t.direction=a}(n,t);var d,f;var m=e.element;w(t.srcEvent.target,m)&&(m=t.srcEvent.target);t.target=m}(e,n),e.emit("hammer.input",n),e.recognize(n),e.session.prevInput=n}function H(e){for(var t=[],n=0;n<e.pointers.length;)t[n]={clientX:c(e.pointers[n].clientX),clientY:c(e.pointers[n].clientY)},n++;return{timeStamp:l(),pointers:t,center:G(t),deltaX:e.deltaX,deltaY:e.deltaY}}function G(e){var t=e.length;if(1===t)return{x:c(e[0].clientX),y:c(e[0].clientY)};for(var n=0,i=0,r=0;r<t;)n+=e[r].clientX,i+=e[r].clientY,r++;return{x:c(n/t),y:c(i/t)}}function W(e,t,n){return{x:t/e||0,y:n/e||0}}function V(e,t){return e===t?1:p(e)>=p(t)?e<0?2:4:t<0?8:16}function U(e,t,n){n||(n=I);var i=t[n[0]]-e[n[0]],r=t[n[1]]-e[n[1]];return Math.sqrt(i*i+r*r)}function q(e,t,n){n||(n=I);var i=t[n[0]]-e[n[0]],r=t[n[1]]-e[n[1]];return 180*Math.atan2(r,i)/Math.PI}F.prototype={handler:function(){},init:function(){this.evEl&&_(this.element,this.evEl,this.domHandler),this.evTarget&&_(this.target,this.evTarget,this.domHandler),this.evWin&&_(M(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&E(this.element,this.evEl,this.domHandler),this.evTarget&&E(this.target,this.evTarget,this.domHandler),this.evWin&&E(M(this.element),this.evWin,this.domHandler)}};var K={mousedown:1,mousemove:2,mouseup:4},Y="mousedown",X="mousemove mouseup";function Z(){this.evEl=Y,this.evWin=X,this.pressed=!1,F.apply(this,arguments)}y(Z,F,{handler:function(e){var t=K[e.type];1&t&&0===e.button&&(this.pressed=!0),2&t&&1!==e.which&&(t=4),this.pressed&&(4&t&&(this.pressed=!1),this.callback(this.manager,t,{pointers:[e],changedPointers:[e],pointerType:j,srcEvent:e}))}});var Q={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},J={2:O,3:"pen",4:j,5:"kinect"},ee="pointerdown",te="pointermove pointerup pointercancel";function ne(){this.evEl=ee,this.evWin=te,F.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}t.MSPointerEvent&&!t.PointerEvent&&(ee="MSPointerDown",te="MSPointerMove MSPointerUp MSPointerCancel"),y(ne,F,{handler:function(e){var t=this.store,n=!1,i=e.type.toLowerCase().replace("ms",""),r=Q[i],o=J[e.pointerType]||e.pointerType,a=o==O,s=T(t,e.pointerId,"pointerId");1&r&&(0===e.button||a)?s<0&&(t.push(e),s=t.length-1):12&r&&(n=!0),s<0||(t[s]=e,this.callback(this.manager,r,{pointers:t,changedPointers:[e],pointerType:o,srcEvent:e}),n&&t.splice(s,1))}});var ie={touchstart:1,touchmove:2,touchend:4,touchcancel:8},re="touchstart",oe="touchstart touchmove touchend touchcancel";function ae(){this.evTarget=re,this.evWin=oe,this.started=!1,F.apply(this,arguments)}function se(e,t){var n=R(e.touches),i=R(e.changedTouches);return 12&t&&(n=P(n.concat(i),"identifier",!0)),[n,i]}y(ae,F,{handler:function(e){var t=ie[e.type];if(1===t&&(this.started=!0),this.started){var n=se.call(this,e,t);12&t&&n[0].length-n[1].length==0&&(this.started=!1),this.callback(this.manager,t,{pointers:n[0],changedPointers:n[1],pointerType:O,srcEvent:e})}}});var ce={touchstart:1,touchmove:2,touchend:4,touchcancel:8},pe="touchstart touchmove touchend touchcancel";function le(){this.evTarget=pe,this.targetIds={},F.apply(this,arguments)}function ue(e,t){var n=R(e.touches),i=this.targetIds;if(3&t&&1===n.length)return i[n[0].identifier]=!0,[n,n];var r,o,a=R(e.changedTouches),s=[],c=this.target;if(o=n.filter((function(e){return w(e.target,c)})),1===t)for(r=0;r<o.length;)i[o[r].identifier]=!0,r++;for(r=0;r<a.length;)i[a[r].identifier]&&s.push(a[r]),12&t&&delete i[a[r].identifier],r++;return s.length?[P(o.concat(s),"identifier",!0),s]:void 0}y(le,F,{handler:function(e){var t=ce[e.type],n=ue.call(this,e,t);n&&this.callback(this.manager,t,{pointers:n[0],changedPointers:n[1],pointerType:O,srcEvent:e})}});function he(){F.apply(this,arguments);var e=g(this.handler,this);this.touch=new le(this.manager,e),this.mouse=new Z(this.manager,e),this.primaryTouch=null,this.lastTouches=[]}function de(e,t){1&e?(this.primaryTouch=t.changedPointers[0].identifier,fe.call(this,t)):12&e&&fe.call(this,t)}function fe(e){var t=e.changedPointers[0];if(t.identifier===this.primaryTouch){var n={x:t.clientX,y:t.clientY};this.lastTouches.push(n);var i=this.lastTouches;setTimeout((function(){var e=i.indexOf(n);e>-1&&i.splice(e,1)}),2500)}}function me(e){for(var t=e.srcEvent.clientX,n=e.srcEvent.clientY,i=0;i<this.lastTouches.length;i++){var r=this.lastTouches[i],o=Math.abs(t-r.x),a=Math.abs(n-r.y);if(o<=25&&a<=25)return!0}return!1}y(he,F,{handler:function(e,t,n){var i=n.pointerType==O,r=n.pointerType==j;if(!(r&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(i)de.call(this,t,n);else if(r&&me.call(this,n))return;this.callback(e,t,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var ve=A(s.style,"touchAction"),ye=ve!==r,ge="compute",be="auto",xe="manipulation",_e="none",Ee="pan-x",we="pan-y",Se=function(){if(!ye)return!1;var e={},n=t.CSS&&t.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach((function(i){e[i]=!n||t.CSS.supports("touch-action",i)})),e}();function Ce(e,t){this.manager=e,this.set(t)}Ce.prototype={set:function(e){e==ge&&(e=this.compute()),ye&&this.manager.element.style&&Se[e]&&(this.manager.element.style[ve]=e),this.actions=e.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var e=[];return d(this.manager.recognizers,(function(t){b(t.options.enable,[t])&&(e=e.concat(t.getTouchAction()))})),function(e){if(S(e,_e))return _e;var t=S(e,Ee),n=S(e,we);if(t&&n)return _e;if(t||n)return t?Ee:we;if(S(e,xe))return xe;return be}(e.join(" "))},preventDefaults:function(e){var t=e.srcEvent,n=e.offsetDirection;if(this.manager.session.prevented)t.preventDefault();else{var i=this.actions,r=S(i,_e)&&!Se.none,o=S(i,we)&&!Se["pan-y"],a=S(i,Ee)&&!Se["pan-x"];if(r){var s=1===e.pointers.length,c=e.distance<2,p=e.deltaTime<250;if(s&&c&&p)return}if(!a||!o)return r||o&&6&n||a&&n&L?this.preventSrc(t):void 0}},preventSrc:function(e){this.manager.session.prevented=!0,e.preventDefault()}};var Te=32;function Re(e){this.options=o({},this.defaults,e||{}),this.id=k++,this.manager=null,this.options.enable=x(this.options.enable,!0),this.state=1,this.simultaneous={},this.requireFail=[]}function Pe(e){return 16&e?"cancel":8&e?"end":4&e?"move":2&e?"start":""}function Ae(e){return 16==e?"down":8==e?"up":2==e?"left":4==e?"right":""}function ke(e,t){var n=t.manager;return n?n.get(e):e}function Me(){Re.apply(this,arguments)}function De(){Me.apply(this,arguments),this.pX=null,this.pY=null}function Be(){Me.apply(this,arguments)}function Ne(){Re.apply(this,arguments),this._timer=null,this._input=null}function Oe(){Me.apply(this,arguments)}function je(){Me.apply(this,arguments)}function Le(){Re.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function Ie(e,t){return(t=t||{}).recognizers=x(t.recognizers,Ie.defaults.preset),new ze(e,t)}Re.prototype={defaults:{},set:function(e){return o(this.options,e),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(e){if(h(e,"recognizeWith",this))return this;var t=this.simultaneous;return t[(e=ke(e,this)).id]||(t[e.id]=e,e.recognizeWith(this)),this},dropRecognizeWith:function(e){return h(e,"dropRecognizeWith",this)||(e=ke(e,this),delete this.simultaneous[e.id]),this},requireFailure:function(e){if(h(e,"requireFailure",this))return this;var t=this.requireFail;return-1===T(t,e=ke(e,this))&&(t.push(e),e.requireFailure(this)),this},dropRequireFailure:function(e){if(h(e,"dropRequireFailure",this))return this;e=ke(e,this);var t=T(this.requireFail,e);return t>-1&&this.requireFail.splice(t,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(e){return!!this.simultaneous[e.id]},emit:function(e){var t=this,n=this.state;function i(n){t.manager.emit(n,e)}n<8&&i(t.options.event+Pe(n)),i(t.options.event),e.additionalEvent&&i(e.additionalEvent),n>=8&&i(t.options.event+Pe(n))},tryEmit:function(e){if(this.canEmit())return this.emit(e);this.state=Te},canEmit:function(){for(var e=0;e<this.requireFail.length;){if(!(33&this.requireFail[e].state))return!1;e++}return!0},recognize:function(e){var t=o({},e);if(!b(this.options.enable,[this,t]))return this.reset(),void(this.state=Te);56&this.state&&(this.state=1),this.state=this.process(t),30&this.state&&this.tryEmit(t)},process:function(e){},getTouchAction:function(){},reset:function(){}},y(Me,Re,{defaults:{pointers:1},attrTest:function(e){var t=this.options.pointers;return 0===t||e.pointers.length===t},process:function(e){var t=this.state,n=e.eventType,i=6&t,r=this.attrTest(e);return i&&(8&n||!r)?16|t:i||r?4&n?8|t:2&t?4|t:2:Te}}),y(De,Me,{defaults:{event:"pan",threshold:10,pointers:1,direction:30},getTouchAction:function(){var e=this.options.direction,t=[];return 6&e&&t.push(we),e&L&&t.push(Ee),t},directionTest:function(e){var t=this.options,n=!0,i=e.distance,r=e.direction,o=e.deltaX,a=e.deltaY;return r&t.direction||(6&t.direction?(r=0===o?1:o<0?2:4,n=o!=this.pX,i=Math.abs(e.deltaX)):(r=0===a?1:a<0?8:16,n=a!=this.pY,i=Math.abs(e.deltaY))),e.direction=r,n&&i>t.threshold&&r&t.direction},attrTest:function(e){return Me.prototype.attrTest.call(this,e)&&(2&this.state||!(2&this.state)&&this.directionTest(e))},emit:function(e){this.pX=e.deltaX,this.pY=e.deltaY;var t=Ae(e.direction);t&&(e.additionalEvent=this.options.event+t),this._super.emit.call(this,e)}}),y(Be,Me,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[_e]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.scale-1)>this.options.threshold||2&this.state)},emit:function(e){if(1!==e.scale){var t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}this._super.emit.call(this,e)}}),y(Ne,Re,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[be]},process:function(e){var t=this.options,n=e.pointers.length===t.pointers,i=e.distance<t.threshold,r=e.deltaTime>t.time;if(this._input=e,!i||!n||12&e.eventType&&!r)this.reset();else if(1&e.eventType)this.reset(),this._timer=u((function(){this.state=8,this.tryEmit()}),t.time,this);else if(4&e.eventType)return 8;return Te},reset:function(){clearTimeout(this._timer)},emit:function(e){8===this.state&&(e&&4&e.eventType?this.manager.emit(this.options.event+"up",e):(this._input.timeStamp=l(),this.manager.emit(this.options.event,this._input)))}}),y(Oe,Me,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[_e]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.rotation)>this.options.threshold||2&this.state)}}),y(je,Me,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return De.prototype.getTouchAction.call(this)},attrTest:function(e){var t,n=this.options.direction;return 30&n?t=e.overallVelocity:6&n?t=e.overallVelocityX:n&L&&(t=e.overallVelocityY),this._super.attrTest.call(this,e)&&n&e.offsetDirection&&e.distance>this.options.threshold&&e.maxPointers==this.options.pointers&&p(t)>this.options.velocity&&4&e.eventType},emit:function(e){var t=Ae(e.offsetDirection);t&&this.manager.emit(this.options.event+t,e),this.manager.emit(this.options.event,e)}}),y(Le,Re,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[xe]},process:function(e){var t=this.options,n=e.pointers.length===t.pointers,i=e.distance<t.threshold,r=e.deltaTime<t.time;if(this.reset(),1&e.eventType&&0===this.count)return this.failTimeout();if(i&&r&&n){if(4!=e.eventType)return this.failTimeout();var o=!this.pTime||e.timeStamp-this.pTime<t.interval,a=!this.pCenter||U(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,a&&o?this.count+=1:this.count=1,this._input=e,0===this.count%t.taps)return this.hasRequireFailures()?(this._timer=u((function(){this.state=8,this.tryEmit()}),t.interval,this),2):8}return Te},failTimeout:function(){return this._timer=u((function(){this.state=Te}),this.options.interval,this),Te},reset:function(){clearTimeout(this._timer)},emit:function(){8==this.state&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),Ie.VERSION="2.0.7",Ie.defaults={domEvents:!1,touchAction:ge,enable:!0,inputTarget:null,inputClass:null,preset:[[Oe,{enable:!1}],[Be,{enable:!1},["rotate"]],[je,{direction:6}],[De,{direction:6},["swipe"]],[Le],[Le,{event:"doubletap",taps:2},["tap"]],[Ne]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function ze(e,t){var n;this.options=o({},Ie.defaults,t||{}),this.options.inputTarget=this.options.inputTarget||e,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new((n=this).options.inputClass||(B?ne:N?le:D?he:Z))(n,$),this.touchAction=new Ce(this,this.options.touchAction),Fe(this,!0),d(this.options.recognizers,(function(e){var t=this.add(new e[0](e[1]));e[2]&&t.recognizeWith(e[2]),e[3]&&t.requireFailure(e[3])}),this)}function Fe(e,t){var n,i=e.element;i.style&&(d(e.options.cssProps,(function(r,o){n=A(i.style,o),t?(e.oldCssProps[n]=i.style[n],i.style[n]=r):i.style[n]=e.oldCssProps[n]||""})),t||(e.oldCssProps={}))}ze.prototype={set:function(e){return o(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this},stop:function(e){this.session.stopped=e?2:1},recognize:function(e){var t=this.session;if(!t.stopped){var n;this.touchAction.preventDefaults(e);var i=this.recognizers,r=t.curRecognizer;(!r||r&&8&r.state)&&(r=t.curRecognizer=null);for(var o=0;o<i.length;)n=i[o],2===t.stopped||r&&n!=r&&!n.canRecognizeWith(r)?n.reset():n.recognize(e),!r&&14&n.state&&(r=t.curRecognizer=n),o++}},get:function(e){if(e instanceof Re)return e;for(var t=this.recognizers,n=0;n<t.length;n++)if(t[n].options.event==e)return t[n];return null},add:function(e){if(h(e,"add",this))return this;var t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e},remove:function(e){if(h(e,"remove",this))return this;if(e=this.get(e)){var t=this.recognizers,n=T(t,e);-1!==n&&(t.splice(n,1),this.touchAction.update())}return this},on:function(e,t){if(e!==r&&t!==r){var n=this.handlers;return d(C(e),(function(e){n[e]=n[e]||[],n[e].push(t)})),this}},off:function(e,t){if(e!==r){var n=this.handlers;return d(C(e),(function(e){t?n[e]&&n[e].splice(T(n[e],t),1):delete n[e]})),this}},emit:function(e,t){this.options.domEvents&&function(e,t){var i=n.createEvent("Event");i.initEvent(e,!0,!0),i.gesture=t,t.target.dispatchEvent(i)}(e,t);var i=this.handlers[e]&&this.handlers[e].slice();if(i&&i.length){t.type=e,t.preventDefault=function(){t.srcEvent.preventDefault()};for(var r=0;r<i.length;)i[r](t),r++}},destroy:function(){this.element&&Fe(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},o(Ie,{INPUT_START:1,INPUT_MOVE:2,INPUT_END:4,INPUT_CANCEL:8,STATE_POSSIBLE:1,STATE_BEGAN:2,STATE_CHANGED:4,STATE_ENDED:8,STATE_RECOGNIZED:8,STATE_CANCELLED:16,STATE_FAILED:Te,DIRECTION_NONE:1,DIRECTION_LEFT:2,DIRECTION_RIGHT:4,DIRECTION_UP:8,DIRECTION_DOWN:16,DIRECTION_HORIZONTAL:6,DIRECTION_VERTICAL:L,DIRECTION_ALL:30,Manager:ze,Input:F,TouchAction:Ce,TouchInput:le,MouseInput:Z,PointerEventInput:ne,TouchMouseInput:he,SingleTouchInput:ae,Recognizer:Re,AttrRecognizer:Me,Tap:Le,Pan:De,Swipe:je,Pinch:Be,Rotate:Oe,Press:Ne,on:_,off:E,each:d,merge:v,extend:m,assign:o,inherit:y,bindFn:g,prefixed:A}),(void 0!==t?t:"undefined"!=typeof self?self:{}).Hammer=Ie,e.exports?e.exports=Ie:t.Hammer=Ie}(window,document)}(ba);var xa=ba.exports,_a=["mousedown","mouseup","mouseover","mouseout","click","dblclick"];function Ea(e,t){return t.get(e,!1)}function wa(e){e.preventDefault(),"function"==typeof e.stopPropagation?e.stopPropagation():e.srcEvent&&"function"==typeof e.srcEvent.stopPropagation&&e.srcEvent.stopPropagation(),"function"==typeof e.stopImmediatePropagation&&e.stopImmediatePropagation()}function Sa(e){function t(t){setTimeout((function(){b(_a,(function(t){re.unbind(e,t,wa,!0)}))}),500)}re.bind(e,"touchstart",(function(t){b(_a,(function(t){re.bind(e,t,wa,!0)}))}),!0),re.bind(e,"touchend",t,!0),re.bind(e,"touchcancel",t,!0);var n=new xa.Manager(e,{inputClass:xa.TouchInput,recognizers:[],domEvents:!0}),i=new xa.Tap,r=new xa.Pan({threshold:10}),o=new xa.Press,a=new xa.Pinch,s=new xa.Tap({event:"doubletap",taps:2});return a.requireFailure(r),a.requireFailure(o),n.add([r,o,a,s,i]),n.reset=function(e){var t=this.recognizers,i=this.session;i.stopped||(n.stop(e),setTimeout((function(){var e,n;for(e=0;n=t[e];e++)n.reset(),n.state=8;i.curRecognizer=null}),0))},n.on("hammer.input",(function(e){e.srcEvent.defaultPrevented&&n.reset(!0)})),n}function Ca(e,t,n,i,r){var o,a=Ea("dragging",e),s=Ea("move",e),c=Ea("contextPad",e),p=Ea("palette",e);function l(e,t){return function(n){var o=u(n.target),a=o&&i.get(o);return t&&(n.srcEvent.button=t),r.fire(e,n,a)}}function u(e){return ee(e,"svg, .djs-element",!0)}function h(e){function n(e){var n=u(e.target),r=n&&i.get(n);if(s&&t.getRootElement()!==r)return s.start(e,r,!0);!function(e){var n=0,i=0;function r(e){var r=e.deltaX-n,o=e.deltaY-i;t.scroll({dx:r,dy:o}),n=e.deltaX,i=e.deltaY}function a(e){o.off("panmove",r),o.off("panend",a),o.off("pancancel",a)}o.on("panmove",r),o.on("panend",a),o.on("pancancel",a)}()}(o=Sa(e)).on("tap",l("element.click")),o.on("doubletap",l("element.dblclick",1)),o.on("panstart",n),o.on("press",n),o.on("pinchstart",(function(e){var n=t.zoom(),i=e.center;function r(e){var r=1-(1-e.scale)/1.5,o=Math.max(.2,Math.min(4,r*n));t.zoom(o,i),wa(e)}function a(e){o.off("pinchmove",r),o.off("pinchend",a),o.off("pinchcancel",a),o.reset(!0)}o.on("pinchmove",r),o.on("pinchend",a),o.on("pinchcancel",a)}))}a&&n.on("drag.move",(function(e){var t=e.originalEvent;if(t&&!(t instanceof MouseEvent)){var n=yo(t),r=u(document.elementFromPoint(n.x,n.y)),o=r&&i.get(r);o!==e.hover&&(e.hover&&a.out(e),o&&(a.hover({element:o,gfx:r}),e.hover=o,e.hoverGfx=r))}})),c&&n.on("contextPad.create",(function(e){var t=Sa(e.pad.html);t.on("panstart",(function(e){c.trigger("dragstart",e,!0)})),t.on("press",(function(e){c.trigger("dragstart",e,!0)})),t.on("tap",(function(e){c.trigger("click",e)}))})),p&&n.on("palette.create",(function(e){var t=Sa(e.container);t.on("panstart",(function(e){p.trigger("dragstart",e,!0)})),t.on("press",(function(e){p.trigger("dragstart",e,!0)})),t.on("tap",(function(e){p.trigger("click",e)}))})),n.on("canvas.init",(function(e){h(e.svg)}))}function Ta(e,t){var n=this;t.on("canvas.init",(function(e){n.addBBoxMarker(e.svg)}))}Ca.$inject=["injector","canvas","eventBus","elementRegistry","interactionEvents","touchFix"],Ta.$inject=["canvas","eventBus"],Ta.prototype.addBBoxMarker=function(e){var t={fill:"none",class:"outer-bound-marker"},n=Me("rect");ge(n,{x:-1e4,y:1e4,width:10,height:10}),ge(n,t),me(e,n);var i=Me("rect");ge(i,{x:1e4,y:1e4,width:10,height:10}),ge(i,t),me(e,i)};var Ra={__depends__:[{__depends__:[Co],__init__:["touchInteractionEvents"],touchInteractionEvents:["type",Ca],touchFix:["type",Ta]}]};function Pa(e){return e&&e[e.length-1]}function Aa(e){return e.y}function ka(e){return e.x}var Ma={left:ka,center:ka,right:function(e){return e.x+e.width},top:Aa,middle:Aa,bottom:function(e){return e.y+e.height}};function Da(e){this._modeling=e}Da.$inject=["modeling"],Da.prototype._getOrientationDetails=function(e){var t="x",n="width";return-1!==["top","bottom","middle"].indexOf(e)&&(t="y",n="height"),{axis:t,dimension:n}},Da.prototype._isType=function(e,t){return-1!==t.indexOf(e)},Da.prototype._alignmentPosition=function(e,t){var n,i,r,o=this._getOrientationDetails(e),a=o.axis,s=o.dimension,c={},p={},l=!1;if(this._isType(e,["left","top"]))c[e]=t[0][a];else if(this._isType(e,["right","bottom"]))r=Pa(t),c[e]=r[a]+r[s];else if(this._isType(e,["center","middle"])){if(b(t,(function(e){var t=e[a]+Math.round(e[s]/2);p[t]?p[t].elements.push(e):p[t]={elements:[e],center:t}})),n=M(p,(function(e){return e.elements.length>1&&(l=!0),e.elements.length})),l)return c[e]=Pa(n).center,c;i=t[0],r=Pa(t=M(t,(function(e){return e[a]+e[s]}))),c[e]=function(e,t){return Math.round((e[a]+t[a]+t[s])/2)}(i,r)}return c},Da.prototype.trigger=function(e,t){var n=this._modeling,i=g(e,(function(e){return!(e.waypoints||e.host||e.labelTarget)}));if(!(i.length<2)){var r=M(i,Ma[t]),o=this._alignmentPosition(t,r);n.alignElements(r,o)}};var Ba={__init__:["alignElements"],alignElements:["type",Da]};function Na(e,t,n,i){for(var r;r=ja(e,n,t);)n=i(t,n,r);return n}function Oa(e){return function(t,n,i){var r={x:n.x,y:n.y};return["x","y"].forEach((function(o){var a=e[o];if(a){var s="x"===o?"width":"height",c=a.margin,p=a.minDistance;r[o]=c<0?Math.min(i[o]+c-t[s]/2,n[o]-p+c):Math.max(i[o]+i[s]+c+t[s]/2,n[o]+p+c)}})),r}}function ja(e,t,n){var i={x:t.x-n.width/2,y:t.y-n.height/2,width:n.width,height:n.height};return y(function(e){var t=La(e);e.host&&(t=t.concat(La(e.host)));e.attachers&&(t=t.concat(e.attachers.reduce((function(e,t){return e.concat(La(t))}),[])));return t}(e),(function(e){return e!==n&&"intersect"===pn(e,i,10)}))}function La(e){return(t=e,t.outgoing.map((function(e){return e.target}))).concat(function(e){return e.incoming.map((function(e){return e.source}))}(e));var t}function Ia(){return!0}function za(e,t,n){e.on("autoPlace",100,(function(e){var t=e.shape;return function(e,t,n){n||(n={});var i=n.defaultDistance||50,r=cn(e);return{x:an(e).right+i+t.width/2,y:r.y}}(e.source,t)})),e.on("autoPlace.end",(function(e){n.scrollToElement(e.shape)})),this.append=function(n,i,r){e.fire("autoPlace.start",{source:n,shape:i});var o=e.fire("autoPlace",{source:n,shape:i}),a=t.appendShape(n,i,o,n.parent,r);return e.fire("autoPlace.end",{source:n,shape:a}),a}}function Fa(e,t){e.on("autoPlace.end",500,(function(e){t.select(e.shape)}))}za.$inject=["eventBus","modeling","canvas"],Fa.$inject=["eventBus","selection"];var $a={__init__:["autoPlaceSelectionBehavior"],autoPlace:["type",za],autoPlaceSelectionBehavior:["type",Fa]};function Ha(e,t){return w(t,(function(t){return Ar(e,t)}))}function Ga(e,t){for("string"==typeof t&&(t=[t]);e=e.parent;)if(Ha(e,t))return e;return null}function Wa(e,t){return Ar(t,"bpmn:TextAnnotation")?function(e,t){var n=an(e),i={x:n.right+t.width/2,y:n.top-50-t.height/2};return Na(e,t,i,Oa({y:{margin:-30,minDistance:20}}))}(e,t):Ha(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])?function(e,t){var n=an(e),i={x:n.right-10+t.width/2,y:n.bottom+40+t.width/2};return Na(e,t,i,Oa({x:{margin:30,minDistance:30}}))}(e,t):Ar(t,"bpmn:FlowNode")?function(e,t){var n=an(e),i=cn(e),r=function(e,t){t||(t={});var n=t.defaultDistance||50,i=t.direction||"e",r=t.filter,o=t.getWeight||function(t){return t.source===e?1:-1},a=t.maxDistance||250,s=t.reference||"start";function c(e,t){return"n"===i?"start"===s?an(e).top-an(t).bottom:"center"===s?an(e).top-cn(t).y:an(e).top-an(t).top:"w"===i?"start"===s?an(e).left-an(t).right:"center"===s?an(e).left-cn(t).x:an(e).left-an(t).left:"s"===i?"start"===s?an(t).top-an(e).bottom:"center"===s?cn(t).y-an(e).bottom:an(t).bottom-an(e).bottom:"start"===s?an(t).left-an(e).right:"center"===s?cn(t).x-an(e).right:an(t).right-an(e).right}r||(r=Ia);var p=e.incoming.filter(r).map((function(t){var n=o(t),i=n<0?c(t.source,e):c(e,t.source);return{id:t.source.id,distance:i,weight:n}})),l=e.outgoing.filter(r).map((function(t){var n=o(t),i=n>0?c(e,t.target):c(t.target,e);return{id:t.target.id,distance:i,weight:n}}));return _(p.concat(l).reduce((function(e,t){return e[t.id+"__weight_"+t.weight]=t,e}),{}),(function(e,t){var n=t.distance,i=t.weight;return n<0||n>a||(e[String(n)]||(e[String(n)]=0),e[String(n)]+=1*i,(!e.distance||e[e.distance]<e[String(n)])&&(e.distance=n)),e}),{}).distance||n}(e,{filter:function(e){return Ar(e,"bpmn:SequenceFlow")}}),o=30,a=80,s="left";Ar(e,"bpmn:BoundaryEvent")&&-1!==(s=pn(e,e.host,-25)).indexOf("top")&&(o*=-1);var c={x:n.right+r+t.width/2,y:i.y+Va(s,a)};return Na(e,t,c,Oa({y:{margin:o,minDistance:a}}))}(e,t):void 0}function Va(e,t){return-1!=e.indexOf("top")?-1*t:-1!=e.indexOf("bottom")?t:0}function Ua(e){e.on("autoPlace",(function(e){var t=e.shape;return Wa(e.source,t)}))}Ua.$inject=["eventBus"];var qa={__depends__:[$a],__init__:["bpmnAutoPlace"],bpmnAutoPlace:["type",Ua]};function Ka(e){this._eventBus=e}Ka.$inject=["eventBus"],Ka.prototype.on=function(e,t,n,i,r,o){if((f(t)||d(t))&&(o=r,r=i,i=n,n=t,t=null),f(n)&&(o=r,r=i,i=n,n=1e3),h(r)&&(o=r,r=!1),!f(i))throw new Error("handlerFn must be a function");u(e)||(e=[e]);var a=this._eventBus;b(e,(function(e){var s=["commandStack",e,t].filter((function(e){return e})).join(".");a.on(s,n,r?function(e,t){return function(n){return e.call(t||null,n.context,n.command,n)}}(i,o):i,o)}))};function Ya(e,t,n,i){Ka.call(this,e),this._elementRegistry=t,this._modeling=n,this._rules=i;var r=this;this.postExecuted(["shape.create"],(function(e){var t=e.context,n=t.hints||{},i=t.shape,o=t.parent||t.newParent;!1!==n.autoResize&&r._expand([i],o)})),this.postExecuted(["elements.move"],(function(e){var t=e.context,n=o(R(t.closure.topLevel)),i=t.hints,a=!i||i.autoResize;!1!==a&&b(P(n,(function(e){return e.parent.id})),(function(e,t){u(a)&&(e=e.filter((function(e){return y(a,D({id:e.id}))}))),r._expand(e,t)}))})),this.postExecuted(["shape.toggleCollapse"],(function(e){var t=e.context,n=t.hints,i=t.shape;n&&!1===n.autoResize||i.collapsed||r._expand(i.children||[],i)})),this.postExecuted(["shape.resize"],(function(e){var t=e.context,n=t.hints,i=t.shape,o=i.parent;n&&!1===n.autoResize||o&&r._expand([i],o)}))}function Xa(e){e.invoke(Ya,this)}function Za(e){Ka.call(this,e),this.init()}function Qa(e){Za.call(this,e);var t=this;this.addRule("element.autoResize",(function(e){return t.canResize(e.elements,e.target)}))}function Ja(e,t){Qa.call(this,e),this._modeling=t}b(["canExecute","preExecute","preExecuted","execute","executed","postExecute","postExecuted","revert","reverted"],(function(e){Ka.prototype[e]=function(t,n,i,r,o){(f(t)||d(t))&&(o=r,r=i,i=n,n=t,t=null),this.on(t,e,n,i,r,o)}})),Ya.$inject=["eventBus","elementRegistry","modeling","rules"],n(Ya,Ka),Ya.prototype._getOptimalBounds=function(e,t){var n=this.getOffset(t),i=this.getPadding(t),r=an(pt(e)),o=an(t),a={};return r.top-o.top<i.top&&(a.top=r.top-n.top),r.left-o.left<i.left&&(a.left=r.left-n.left),o.right-r.right<i.right&&(a.right=r.right+n.right),o.bottom-r.bottom<i.bottom&&(a.bottom=r.bottom+n.bottom),sn(F({},o,a))},Ya.prototype._expand=function(e,t){if("string"==typeof t&&(t=this._elementRegistry.get(t)),this._rules.allowed("element.autoResize",{elements:e,target:t})){var n=this._getOptimalBounds(e,t);if(function(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}(n,t)){var i=function(e,t){var n="";e=an(e),t=an(t),e.top>t.top&&(n=n.concat("n"));e.right<t.right&&(n=n.concat("w"));e.bottom<t.bottom&&(n=n.concat("s"));e.left>t.left&&(n=n.concat("e"));return n}($(t,["x","y","width","height"]),n);this.resize(t,n,{autoResize:i});var r=t.parent;r&&this._expand([t],r)}}},Ya.prototype.getOffset=function(e){return{top:60,bottom:60,left:100,right:100}},Ya.prototype.getPadding=function(e){return{top:2,bottom:2,left:15,right:15}},Ya.prototype.resize=function(e,t,n){this._modeling.resizeShape(e,t,null,n)},Xa.$inject=["injector"],n(Xa,Ya),Xa.prototype.resize=function(e,t,n){Ar(e,"bpmn:Participant")?this._modeling.resizeLane(e,t,null,n):this._modeling.resizeShape(e,t,null,n)},Za.$inject=["eventBus"],n(Za,Ka),Za.prototype.addRule=function(e,t,n){var i=this;"string"==typeof e&&(e=[e]),e.forEach((function(e){i.canExecute(e,t,(function(e,t,i){return n(e)}),!0)}))},Za.prototype.init=function(){},Qa.$inject=["eventBus"],n(Qa,Za),Qa.prototype.canResize=function(e,t){return!1},n(Ja,Qa),Ja.$inject=["eventBus","modeling"],Ja.prototype.canResize=function(e,t){if(!Ar(t,"bpmn:Participant")&&!Ar(t,"bpmn:Lane")&&!Ar(t,"bpmn:SubProcess"))return!1;var n=!0;return b(e,(function(e){(Ar(e,"bpmn:Lane")||e.labelTarget)&&(n=!1)})),n};var es={__init__:["bpmnAutoResize","bpmnAutoResizeProvider"],bpmnAutoResize:["type",Xa],bpmnAutoResizeProvider:["type",Ja]};function ts(e,t,n){var i,r,o=this,a=n.get("dragging",!1);a&&t.on("drag.start",(function(n){t.once("drag.move",1500,(function(t){!function(t){if(!t.hover){var n=t.originalEvent,i=o._findTargetGfx(n),r=i&&e.get(i);i&&r&&(t.stopPropagation(),a.hover({element:r,gfx:i}),a.move(n))}}(t)}))})),t.on("element.hover",(function(e){i=e.gfx,r=e.element})),t.on("element.hover",1500,(function(e){r&&t.fire("element.out",{element:r,gfx:i})})),t.on("element.out",(function(){i=null,r=null})),this._findTargetGfx=function(e){var t;if(e instanceof MouseEvent)return t=yo(e),function(e){return ee(e,"svg, .djs-element",!0)}(document.elementFromPoint(t.x,t.y))}}ts.$inject=["elementRegistry","eventBus","injector"];var ns={__init__:["hoverFix"],hoverFix:["type",ts]},is=Math.round,rs="djs-drag-active";function os(e){e.preventDefault()}function as(e,t,n,i){var r,o={threshold:5,trapClick:!0};function a(e){var n=t.viewbox(),i=t._container.getBoundingClientRect();return{x:n.x+(e.x-i.left)/n.scale,y:n.y+(e.y-i.top)/n.scale}}function s(t,n){n=n||r;var i=e.createEvent(F({},n.payload,n.data,{isTouch:n.isTouch}));return!1!==e.fire("drag."+t,i)&&e.fire(n.prefix+"."+t,i)}function c(e,i){var o,c=r.payload,p=r.displacement,l=r.globalStart,u=yo(e),h=pa(u,l),d=r.localStart,f=a(u),v=pa(f,d);if(!r.active&&(i||(o=h,Math.sqrt(Math.pow(o.x,2)+Math.pow(o.y,2))>r.threshold))){if(F(c,{x:is(d.x+p.x),y:is(d.y+p.y),dx:0,dy:0},{originalEvent:e}),!1===s("start"))return m();r.active=!0,r.keepSelection||(c.previousSelection=n.get(),n.select(null)),r.cursor&&oa(r.cursor),t.addMarker(t.getRootElement(),rs)}vo(e),r.active&&(F(c,{x:is(f.x+p.x),y:is(f.y+p.y),dx:is(v.x),dy:is(v.y)},{originalEvent:e}),s("move"))}function p(e){var t=!0;r.active&&(e&&(r.payload.originalEvent=e,vo(e)),t=s("end")),!1===t&&s("rejected"),s("ended",v(!0!==t))}function l(e){27===e.which&&(os(e),m())}function u(t){var n;r.active&&(n=sa(e),setTimeout(n,400),os(t)),p(t)}function h(e){c(e)}function d(e){var t=r.payload;t.hoverGfx=e.gfx,t.hover=e.element,s("hover")}function f(e){s("out");var t=r.payload;t.hoverGfx=null,t.hover=null}function m(e){var t;if(r){var n=r.active;n&&s("cancel"),t=v(e),n&&s("canceled",t)}}function v(o){var a,v;s("cleanup"),aa(),v=r.trapClick?u:p,re.unbind(document,"mousemove",c),re.unbind(document,"dragstart",os),re.unbind(document,"selectstart",os),re.unbind(document,"mousedown",v,!0),re.unbind(document,"mouseup",v,!0),re.unbind(document,"keyup",l),re.unbind(document,"touchstart",h,!0),re.unbind(document,"touchcancel",m,!0),re.unbind(document,"touchmove",c,!0),re.unbind(document,"touchend",p,!0),e.off("element.hover",d),e.off("element.out",f),t.removeMarker(t.getRootElement(),rs);var y=r.payload.previousSelection;return!1!==o&&y&&!n.get().length&&function(e){var t=e.filter((function(e){return i.get(e.id)}));t.length&&n.select(t)}(y),a=r,r=null,a}e.on("diagram.destroy",m),this.init=function(t,n,i,v){r&&m(!1),"string"==typeof n&&(v=i,i=n,n=null);var y,g,b,x,_,E=(v=F({},o,v||{})).data||{};x=v.trapClick?u:p,t?(y=mo(t)||t,g=yo(t),vo(t),"dragstart"===y.type&&os(y)):(y=null,g={x:0,y:0}),b=a(g),n||(n=b),_=function(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent}(y),r=F({prefix:i,data:E,payload:{},globalStart:g,displacement:pa(n,b),localStart:b,isTouch:_},v),v.manual||(_?(re.bind(document,"touchstart",h,!0),re.bind(document,"touchcancel",m,!0),re.bind(document,"touchmove",c,!0),re.bind(document,"touchend",p,!0)):(re.bind(document,"mousemove",c),re.bind(document,"dragstart",os),re.bind(document,"selectstart",os),re.bind(document,"mousedown",x,!0),re.bind(document,"mouseup",x,!0)),re.bind(document,"keyup",l),e.on("element.hover",d),e.on("element.out",f)),s("init"),v.autoActivate&&c(t,!0)},this.move=c,this.hover=d,this.out=f,this.end=p,this.cancel=m,this.context=function(){return r},this.setOptions=function(e){F(o,e)}}as.$inject=["eventBus","canvas","selection","elementRegistry"];var ss={__depends__:[ns,No],dragging:["type",as]};function cs(e,t,n){this._canvas=n,this._opts=F({scrollThresholdIn:[20,20,20,20],scrollThresholdOut:[0,0,0,0],scrollRepeatTimeout:15,scrollStep:10},e);var i=this;t.on("drag.move",(function(e){var t=i._toBorderPoint(e);i.startScroll(t)})),t.on(["drag.cleanup"],(function(){i.stopScroll()}))}function ps(e,t,n){return t<e&&e<n}cs.$inject=["config.autoScroll","eventBus","canvas"],cs.prototype.startScroll=function(e){var t=this._canvas,n=this._opts,i=this,r=t.getContainer().getBoundingClientRect(),o=[e.x,e.y,r.width-e.x,r.height-e.y];this.stopScroll();for(var a=0,s=0,c=0;c<4;c++)ps(o[c],n.scrollThresholdOut[c],n.scrollThresholdIn[c])&&(0===c?a=n.scrollStep:1==c?s=n.scrollStep:2==c?a=-n.scrollStep:3==c&&(s=-n.scrollStep));0===a&&0===s||(t.scroll({dx:a,dy:s}),this._scrolling=setTimeout((function(){i.startScroll(e)}),n.scrollRepeatTimeout))},cs.prototype.stopScroll=function(){clearTimeout(this._scrolling)},cs.prototype.setOptions=function(e){this._opts=F({},this._opts,e)},cs.prototype._toBorderPoint=function(e){var t=this._canvas._container.getBoundingClientRect(),n=yo(e.originalEvent);return{x:n.x-t.left,y:n.y-t.top}};var ls={__depends__:[ss],__init__:["autoScroll"],autoScroll:["type",cs]};function us(e){this._commandStack=e.get("commandStack",!1)}us.$inject=["injector"],us.prototype.allowed=function(e,t){var n=!0,i=this._commandStack;return i&&(n=i.canExecute(e,t)),void 0===n||n};var hs={__init__:["rules"],rules:["type",us]},ds=Math.round,fs=Math.max;function ms(e,t){return function(e,t){var n,i;for(n=0;i=e[n];n++)if(gt(i,t)<=10)return{point:e[n],bendpoint:!0,index:n};return null}(e,t)||function(e,t){var n,i,r=nn(function(e,t){return[["M",e.x,e.y],["m",0,-t],["a",t,t,0,1,1,0,2*t],["a",t,t,0,1,1,0,-2*t],["z"]]}(t,10),(n=[],e.forEach((function(e,t){n.push([0===t?"M":"L",e.x,e.y])})),n)),o=r[0],a=r[r.length-1];return o?o!==a?o.segment2!==a.segment2?{point:e[i=fs(o.segment2,a.segment2)-1],bendpoint:!0,index:i}:{point:{x:ds(o.x+a.x)/2,y:ds(o.y+a.y)/2},index:o.segment2}:{point:{x:ds(o.x),y:ds(o.y)},index:o.segment2}:null}(e,t)}var vs="djs-bendpoint",ys="djs-segment-dragger";function gs(e,t,n){return ms(t,function(e,t){var n,i=yo(t),r=e._container.getBoundingClientRect();n={x:r.left,y:r.top};var o=e.viewbox();return{x:o.x+(i.x-n.x)/o.scale,y:o.y+(i.y-n.y)/o.scale}}(e,n))}function bs(e,t){var n=Me("g");we(n).add(vs),me(e,n);var i=Me("circle");ge(i,{cx:0,cy:0,r:4}),we(i).add("djs-visual"),me(n,i);var r=Me("circle");return ge(r,{cx:0,cy:0,r:10}),we(r).add("djs-hit"),me(n,r),t&&we(n).add(t),n}function xs(e,t,n,i){var r=Me("g");me(e,r);var o=function(e,t,n){var i=t.x-e.x,r=t.y-e.y;return Es("h"===n?i:r)}(t,n,i),a=Me("rect");ge(a,{x:-7,y:-1.5,width:14,height:3}),we(a).add("djs-visual"),me(r,a);var s=Me("rect");return ge(s,{x:-o/2,y:-7,width:o,height:14}),we(s).add("djs-hit"),me(r,s),Un(r,"v"===i?90:0),r}function _s(e,t,n){var i=Me("g"),r=Et(t,n),o=xt(t,n);return me(e,i),xs(i,t,n,o),we(i).add(ys),we(i).add("h"===o?"horizontal":"vertical"),Vn(i,r.x,r.y),i}function Es(e){return Math.abs(Math.round(2*e/3))}var ws={exports:{}};
|
|
34
|
-
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */!function(t,n){var i;i=e,t.exports=function(e){if(e.CSS&&e.CSS.escape)return e.CSS.escape;var t=function(e){if(0==arguments.length)throw new TypeError("`CSS.escape` requires an argument.");for(var t,n=String(e),i=n.length,r=-1,o="",a=n.charCodeAt(0);++r<i;)0!=(t=n.charCodeAt(r))?o+=t>=1&&t<=31||127==t||0==r&&t>=48&&t<=57||1==r&&t>=48&&t<=57&&45==a?"\\"+t.toString(16)+" ":0==r&&1==i&&45==t||!(t>=128||45==t||95==t||t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122)?"\\"+n.charAt(r):n.charAt(r):o+="�";return o};return e.CSS||(e.CSS={}),e.CSS.escape=t,t}(i)}(ws);var Ss=ws.exports,Cs={"&":"&","<":"<",">":">",'"':""","'":"'"};function Ts(e){return(e=""+e)&&e.replace(/[&<>"']/g,(function(e){return Cs[e]}))}function Rs(e,t,n,i,r){function o(e,n){var o=n.waypoints,a=gs(t,o,e);if(a)return!function(e,t,n){var i,r,o,a,s,c,p=e.index,l=e.point;return!(p<=0||e.bendpoint)&&(o=Et(i=t[p-1],r=t[p]),a=xt(i,r),s=Math.abs(l.x-o.x),c=Math.abs(l.y-o.y),a&&s<=n&&c<=n)}(a,o,function(e,t){var n,i,r=e.waypoints;return t.index<=0||t.bendpoint?null:(i=xt((n={start:r[t.index-1],end:r[t.index]}).start,n.end))?Es("h"===i?n.end.x-n.start.x:n.end.y-n.start.y)/2:null}(n,a))?i.start(e,n,a.index,!a.bendpoint):r.start(e,n,a.index),!0}function a(e,t,i){re.bind(e,t,(function(e){n.triggerMouseEvent(t,e,i),e.stopPropagation()}))}function s(e,n){var i=t.getLayer("overlays"),r=ue('.djs-bendpoints[data-element-id="'+Ss(e.id)+'"]',i);return!r&&n&&(ge(r=Me("g"),{"data-element-id":e.id}),we(r).add("djs-bendpoints"),me(i,r),a(r,"mousedown",e),a(r,"click",e),a(r,"dblclick",e)),r}function c(e,t){return ue('.djs-segment-dragger[data-segment-idx="'+e+'"]',t)}function p(e,t){t.waypoints.forEach((function(t,n){var i=bs(e);me(e,i),Vn(i,t.x,t.y)})),bs(e,"floating")}function l(e,t){for(var n,i,r,o=t.waypoints,s=1;s<o.length;s++)xt(n=o[s-1],i=o[s])&&(ge(r=_s(e,n,i),{"data-segment-idx":s}),a(r,"mousemove",t))}function u(e){var t=s(e);return t||(p(t=s(e,!0),e),l(t,e)),t}function h(e){var t=s(e);t&&(!function(e){b(he(".djs-segment-dragger",e),(function(e){Ce(e)}))}(t),function(e){b(he(".djs-bendpoint",e),(function(e){Ce(e)}))}(t),l(t,e),p(t,e))}function d(e,t,n){var i,r,o=c(t.index,e),a=n[t.index-1],s=n[t.index],p=t.point,l=Et(a,s),u=xt(a,s);o&&(i=function(e){return ue(".djs-visual",e)}(o),r={x:p.x-l.x,y:p.y-l.y},"v"===u&&(r={x:r.y,y:r.x}),Vn(i,r.x,r.y))}e.on("connection.changed",(function(e){h(e.element)})),e.on("connection.remove",(function(e){var t=s(e.element);t&&Ce(t)})),e.on("element.marker.update",(function(e){var t,n=e.element;n.waypoints&&(t=u(n),e.add?we(t).add(e.marker):we(t).remove(e.marker))})),e.on("element.mousemove",(function(e){var n,i,r=e.element,o=r.waypoints;if(o){if(n=s(r,!0),!(i=gs(t,o,e.originalEvent)))return;!function(e,t){var n=ue(".floating",e),i=t.point;n&&Vn(n,i.x,i.y)}(n,i),i.bendpoint||d(n,i,o)}})),e.on("element.mousedown",(function(e){if(bo(e)){var t=e.originalEvent,n=e.element;if(n.waypoints)return o(t,n)}})),e.on("selection.changed",(function(e){var t=e.newSelection[0];t&&t.waypoints&&u(t)})),e.on("element.hover",(function(e){var t=e.element;t.waypoints&&(u(t),n.registerEvent(e.gfx,"mousemove","element.mousemove"))})),e.on("element.out",(function(e){n.unregisterEvent(e.gfx,"mousemove","element.mousemove")})),e.on("element.updateId",(function(e){var t=e.element,n=e.newId;if(t.waypoints){var i=s(t);i&&ge(i,{"data-element-id":n})}})),this.addHandles=u,this.updateHandles=h,this.getBendpointsContainer=s,this.getSegmentDragger=c}Rs.$inject=["eventBus","canvas","interactionEvents","bendpointMove","connectionSegmentMove"];var Ps=Math.round,As="reconnectStart",ks="reconnectEnd",Ms="updateWaypoints";function Ds(e,t,n,i,r,o){this._injector=e,this.start=function(e,t,o,a){var s,c=n.getGraphics(t),p=t.source,l=t.target,u=t.waypoints,h=(s=a||0!==o?a||o!==u.length-1?Ms:ks:As)===Ms?"connection.updateWaypoints":"connection.reconnect",d=r.allowed(h,{connection:t,source:p,target:l});!1===d&&(d=r.allowed(h,{connection:t,source:l,target:p})),!1!==d&&i.init(e,"bendpoint.move",{data:{connection:t,connectionGfx:c,context:{allowed:d,bendpointIndex:o,connection:t,source:p,target:l,insert:a,type:s}}})},t.on("bendpoint.move.hover",(function(e){var t,n=e.context,i=n.connection,o=i.source,a=i.target,s=e.hover,c=n.type;if(n.hover=s,s){var p=c===Ms?"connection.updateWaypoints":"connection.reconnect";if(t=n.allowed=r.allowed(p,{connection:i,source:c===As?s:o,target:c===ks?s:a}))return n.source=c===As?s:o,void(n.target=c===ks?s:a);!1===t&&(t=n.allowed=r.allowed(p,{connection:i,source:c===ks?s:a,target:c===As?s:o})),t&&(n.source=c===ks?s:a,n.target=c===As?s:o)}})),t.on(["bendpoint.move.out","bendpoint.move.cleanup"],(function(e){var t=e.context,n=t.type;t.hover=null,t.source=null,t.target=null,n!==Ms&&(t.allowed=!1)})),t.on("bendpoint.move.end",(function(e){var t=e.context,n=t.allowed,i=t.bendpointIndex,r=t.connection,a=t.insert,s=r.waypoints.slice(),c=t.source,p=t.target,l=t.type,u=t.hints||{},h={x:Ps(e.x),y:Ps(e.y)};if(!n)return!1;l===Ms?(a?s.splice(i,0,h):s[i]=h,u.bendpointMove={insert:a,bendpointIndex:i},s=this.cropWaypoints(r,s),o.updateWaypoints(r,function(e){e=e.slice();for(var t,n,i,r=0;e[r];)t=e[r],n=e[r-1],0===gt(t,i=e[r+1])||bt(n,i,t)?e.splice(r,1):r++;return e}(s),u)):(l===As?(u.docking="source",Bs(t)&&(u.docking="target",u.newWaypoints=s.reverse())):l===ks&&(u.docking="target",Bs(t)&&(u.docking="source",u.newWaypoints=s.reverse())),o.reconnect(r,c,p,h,u))}),this)}function Bs(e){var t=e.hover,n=e.source,i=e.target,r=e.type;return r===As?t&&i&&t===i&&n!==i:r===ks?t&&n&&t===n&&n!==i:void 0}Ds.$inject=["injector","eventBus","canvas","dragging","rules","modeling"],Ds.prototype.cropWaypoints=function(e,t){var n=this._injector.get("connectionDocking",!1);if(!n)return t;var i=e.waypoints;return e.waypoints=t,e.waypoints=n.getCroppedWaypoints(e),t=e.waypoints,e.waypoints=i,t};var Ns="updateWaypoints",Os="connect-ok",js="connect-not-ok",Ls="connect-hover",Is="djs-updating",zs="djs-element-hidden";function Fs(e,t,n,i){this._injector=t;var r=t.get("connectionPreview",!1);n.on("bendpoint.move.start",(function(e){var t=e.context,n=t.bendpointIndex,r=t.connection,o=t.insert,a=r.waypoints,s=a.slice();t.waypoints=a,o&&s.splice(n,0,{x:e.x,y:e.y}),r.waypoints=s,we(t.draggerGfx=bs(i.getLayer("overlays"))).add("djs-dragging"),i.addMarker(r,zs),i.addMarker(r,Is)})),n.on("bendpoint.move.hover",(function(e){var t=e.context,n=t.allowed,r=t.hover,o=t.type;if(r){if(i.addMarker(r,Ls),o===Ns)return;n?(i.removeMarker(r,js),i.addMarker(r,Os)):!1===n&&(i.removeMarker(r,Os),i.addMarker(r,js))}})),n.on(["bendpoint.move.out","bendpoint.move.cleanup"],1100,(function(e){var t=e.context,n=t.hover,r=t.target;n&&(i.removeMarker(n,Ls),i.removeMarker(n,r?Os:js))})),n.on("bendpoint.move.move",(function(t){var n=t.context,i=n.allowed,o=n.bendpointIndex,a=n.draggerGfx,s=n.hover,c=n.type,p=n.connection,l=p.source,u=p.target,h=p.waypoints.slice(),d={x:t.x,y:t.y},f=n.hints||{},m={};r&&(f.connectionStart&&(m.connectionStart=f.connectionStart),f.connectionEnd&&(m.connectionEnd=f.connectionEnd),"reconnectStart"===c?Bs(n)?(m.connectionEnd=m.connectionEnd||d,m.source=u,m.target=s||l,h=h.reverse()):(m.connectionStart=m.connectionStart||d,m.source=s||l,m.target=u):"reconnectEnd"===c?Bs(n)?(m.connectionStart=m.connectionStart||d,m.source=s||u,m.target=l,h=h.reverse()):(m.connectionEnd=m.connectionEnd||d,m.source=l,m.target=s||u):(m.noCropping=!0,m.noLayout=!0,h[o]=d),c===Ns&&(h=e.cropWaypoints(p,h)),m.waypoints=h,r.drawPreview(n,i,m)),Vn(a,t.x,t.y)}),this),n.on(["bendpoint.move.end","bendpoint.move.cancel"],1100,(function(e){var t=e.context,n=t.connection,o=t.draggerGfx,a=t.hover,s=t.target,c=t.waypoints;n.waypoints=c,Ce(o),i.removeMarker(n,Is),i.removeMarker(n,zs),a&&(i.removeMarker(a,Os),i.removeMarker(a,s?Os:js)),r&&r.cleanUp(t)}))}Fs.$inject=["bendpointMove","injector","eventBus","canvas"];var $s="connect-hover",Hs="djs-updating";function Gs(e,t,n){return Ws(e,t,e[t]+n)}function Ws(e,t,n){return{x:"x"===t?n:e.x,y:"y"===t?n:e.y}}function Vs(e){return"x"===e?"y":"x"}function Us(e,t,n){var i,r;return e.original?e.original:(i=cn(t),Ws(e,r=Vs(n),i[r]))}function qs(e,t,n,i,r,o){var a=e.get("connectionDocking",!1);function s(e,t){if(!a)return t;var n,i=e.waypoints;return e.waypoints=t,n=a.getCroppedWaypoints(e),e.waypoints=i,n}function c(e){r.update("connection",e.connection,e.connectionGfx)}function p(e,t,n){var i=e.newWaypoints,r=function(e,t,n,i){var r=Math.max(t[i],n[i]),o=Math.min(t[i],n[i]);return Ws(t,i,Math.min(Math.max(o+20,e[i]),r-20))}(n,i[e.segmentStartIndex+t],i[e.segmentEndIndex+t],Vs(e.axis));Vn(e.draggerGfx,r.x,r.y)}this.start=function(e,t,r){var o,a,s,c,p=n.getGraphics(t),l=r-1,u=r,h=t.waypoints,d=h[l],f=h[u],m=gs(n,h,e);(a=xt(d,f))&&(s="v"===a?"x":"y",0===l&&(d=Us(d,t.source,s)),u===h.length-1&&(f=Us(f,t.target,s)),o={connection:t,segmentStartIndex:l,segmentEndIndex:u,segmentStart:d,segmentEnd:f,axis:s,dragPosition:c=m?m.point:{x:(d.x+f.x)/2,y:(d.y+f.y)/2}},i.init(e,c,"connectionSegment.move",{cursor:"x"===s?"resize-ew":"resize-ns",data:{connection:t,connectionGfx:p,context:o}}))},t.on("connectionSegment.move.start",(function(e){var t=e.context,i=e.connection,r=n.getLayer("overlays");t.originalWaypoints=i.waypoints.slice(),t.draggerGfx=_s(r,t.segmentStart,t.segmentEnd),we(t.draggerGfx).add("djs-dragging"),n.addMarker(i,Hs)})),t.on("connectionSegment.move.move",(function(e){var t,n,i=e.context,r=i.connection,o=i.segmentStartIndex,a=i.segmentEndIndex,l=i.segmentStart,u=i.segmentEnd,h=i.axis,d=i.originalWaypoints.slice(),f=Gs(l,h,e["d"+h]),m=Gs(u,h,e["d"+h]),v=d.length,y=0;d[o]=f,d[a]=m,o<2&&(t=pn(r.source,f),1===o?"intersect"===t&&(d.shift(),d[0]=f,y--):"intersect"!==t&&(d.unshift(l),y++)),a>v-3&&(n=pn(r.target,m),a===v-2?"intersect"===n&&(d.pop(),d[d.length-1]=m):"intersect"!==n&&d.push(u)),i.newWaypoints=r.waypoints=s(r,d),p(i,y,e),i.newSegmentStartIndex=o+y,c(e)})),t.on("connectionSegment.move.hover",(function(e){e.context.hover=e.hover,n.addMarker(e.hover,$s)})),t.on(["connectionSegment.move.out","connectionSegment.move.cleanup"],(function(e){var t=e.context.hover;t&&n.removeMarker(t,$s)})),t.on("connectionSegment.move.cleanup",(function(e){var t=e.context,i=t.connection;t.draggerGfx&&Ce(t.draggerGfx),n.removeMarker(i,Hs)})),t.on(["connectionSegment.move.cancel","connectionSegment.move.end"],(function(e){var t=e.context;t.connection.waypoints=t.originalWaypoints,c(e)})),t.on("connectionSegment.move.end",(function(e){var t=e.context,n=t.connection,i=t.newWaypoints,r=t.newSegmentStartIndex,a=function(e,t){var n=0;return{waypoints:e.filter((function(i,r){return!bt(e[r-1],e[r+1],i)||(n=r<=t?n-1:n,!1)})),segmentOffset:n}}(i=i.map((function(e){return{original:e.original,x:Math.round(e.x),y:Math.round(e.y)}})),r),c=s(n,a.waypoints),p=a.segmentOffset,l={segmentMove:{segmentStartIndex:t.segmentStartIndex,newSegmentStartIndex:r+p}};o.updateWaypoints(n,c,l)}))}qs.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];var Ks=Math.abs,Ys=Math.round;function Xs(e){return{x:e.x,y:e.y}}function Zs(e){return{x:e.x+e.width,y:e.y+e.height}}function Qs(e,t){return!e||isNaN(e.x)||isNaN(e.y)?t:{x:Ys(e.x+e.width/2),y:Ys(e.y+e.height/2)}}function Js(e,t){var n=e.snapped;return!!n&&("string"==typeof t?n[t]:n.x&&n.y)}function ec(e,t,n){if("string"!=typeof t)throw new Error("axis must be in [x, y]");if("number"!=typeof n&&!1!==n)throw new Error("value must be Number or false");var i,r=e[t],o=e.snapped=e.snapped||{};return!1===n?o[t]=!1:(o[t]=!0,i=n-r,e[t]+=i,e["d"+t]+=i),r}function tc(e){return e.children||[]}var nc=Math.abs,ic=Math.round;function rc(e){function t(e,t){if(u(e)){for(var n=e.length;n--;)if(nc(e[n]-t)<=10)return e[n]}else{var i=t%(e=+e);if(i<10)return t-i;if(i>e-10)return t-i+e}return t}function n(e){if(e.width)return{x:ic(e.width/2+e.x),y:ic(e.height/2+e.y)}}e.on("connectionSegment.move.move",1500,(function(e){var i,r,o=function(e){var t=e.snapPoints,i=e.connection,r=i.waypoints,o=e.segmentStart,a=e.segmentStartIndex,s=e.segmentEnd,c=e.segmentEndIndex,p=e.axis;if(t)return t;var l=[r[a-1],o,s,r[c+1]];return a<2&&l.unshift(n(i.source)),c>r.length-3&&l.unshift(n(i.target)),e.snapPoints=t={horizontal:[],vertical:[]},b(l,(function(e){e&&(e=e.original||e,"y"===p&&t.horizontal.push(e.y),"x"===p&&t.vertical.push(e.x))})),t}(e.context),a=e.x,s=e.y;if(o){var c=a-(i=t(o.vertical,a)),p=s-(r=t(o.horizontal,s));F(e,{dx:e.dx-c,dy:e.dy-p,x:i,y:r}),(c||-1!==o.vertical.indexOf(a))&&ec(e,"x",i),(p||-1!==o.horizontal.indexOf(s))&&ec(e,"y",r)}})),e.on(["bendpoint.move.move","bendpoint.move.end"],1500,(function(e){var i,r,o=e.context,a=function(e){var t=e.snapPoints,n=e.connection.waypoints,i=e.bendpointIndex;if(t)return t;var r=[n[i-1],n[i+1]];return e.snapPoints=t={horizontal:[],vertical:[]},b(r,(function(e){e&&(e=e.original||e,t.horizontal.push(e.y),t.vertical.push(e.x))})),t}(o),s=o.hover,c=s&&n(s),p=e.x,l=e.y;if(a){var u=p-(i=t(c?a.vertical.concat([c.x]):a.vertical,p)),h=l-(r=t(c?a.horizontal.concat([c.y]):a.horizontal,l));F(e,{dx:e.dx-u,dy:e.dy-h,x:e.x-u,y:e.y-h}),(u||-1!==a.vertical.indexOf(p))&&ec(e,"x",i),(h||-1!==a.horizontal.indexOf(l))&&ec(e,"y",r)}}))}rc.$inject=["eventBus"];var oc={__depends__:[ss,hs],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",Rs],bendpointMove:["type",Ds],bendpointMovePreview:["type",Fs],connectionSegmentMove:["type",qs],bendpointSnapping:["type",rc]};function ac(e,t,n,i){function r(e,t){return i.allowed("connection.create",{source:e,target:t})}e.on("connect.hover",(function(e){var t,n=e.context,i=n.start,o=e.hover;if(n.hover=o,!l(t=n.canExecute=r(i,o))){if(!1!==t)return n.source=i,void(n.target=o);l(t=n.canExecute=r(o,i))||!1!==t&&(n.source=o,n.target=i)}})),e.on(["connect.out","connect.cleanup"],(function(e){var t=e.context;t.hover=null,t.source=null,t.target=null,t.canExecute=!1})),e.on("connect.end",(function(e){var t=e.context,i=t.canExecute,r=t.connectionStart,o={x:e.x,y:e.y},a=t.source,s=t.target;if(!i)return!1;var c=null,p={connectionStart:sc(t)?o:r,connectionEnd:sc(t)?r:o};h(i)&&(c=i),n.connect(a,s,c,p)})),this.start=function(e,n,i,r){h(i)||(r=i,i=cn(n)),t.init(e,"connect",{autoActivate:r,data:{shape:n,context:{start:n,connectionStart:i}}})}}function sc(e){var t=e.hover,n=e.source,i=e.target;return t&&n&&t===n&&n!==i}ac.$inject=["eventBus","dragging","modeling","rules"];var cc="connect-ok",pc="connect-not-ok";function lc(e,t,n){var i=e.get("connectionPreview",!1);i&&t.on("connect.move",(function(e){var t=e.context,n=t.canExecute,r=t.hover,o=t.source,a=t.start,s=t.startPosition,c=t.target,p=t.connectionStart||s,l=t.connectionEnd||{x:e.x,y:e.y},u=p,h=l;sc(t)&&(u=l,h=p),i.drawPreview(t,n,{source:o||a,target:c||r,connectionStart:u,connectionEnd:h})})),t.on("connect.hover",900,(function(e){var t=e.context,i=e.hover,r=t.canExecute;null!==r&&n.addMarker(i,r?cc:pc)})),t.on(["connect.out","connect.cleanup"],1100,(function(e){var t=e.hover;t&&(n.removeMarker(t,cc),n.removeMarker(t,pc))})),i&&t.on("connect.cleanup",(function(e){i.cleanUp(e.context)}))}lc.$inject=["injector","eventBus","canvas"];var uc={__depends__:[No,hs,ss],__init__:["connectPreview"],connect:["type",ac],connectPreview:["type",lc]};function hc(e,t,n,i){this._canvas=t,this._graphicsFactory=n,this._elementFactory=i,this._connectionDocking=e.get("connectionDocking",!1),this._layouter=e.get("layouter",!1)}hc.$inject=["injector","canvas","graphicsFactory","elementFactory"],hc.prototype.drawPreview=function(e,t,n){n=n||{};var i,r,o,a=e.connectionPreviewGfx,s=e.getConnection,c=n.source,p=n.target,l=n.waypoints,u=n.connectionStart,h=n.connectionEnd,d=n.noLayout,f=n.noCropping,m=n.noNoop,v=this;a||(a=e.connectionPreviewGfx=this.createConnectionPreviewGfx()),Te(a),s||(s=e.getConnection=(r=function(e,t,n){return v.getConnection(e,t,n)},o={},function(e){var t=JSON.stringify(e),n=o[t];return n||(n=o[t]=r.apply(null,arguments)),n})),t&&(i=s(t,c,p)),i?(i.waypoints=l||[],this._layouter&&!d&&(i.waypoints=this._layouter.layoutConnection(i,{source:c,target:p,connectionStart:u,connectionEnd:h,waypoints:n.waypoints||i.waypoints})),i.waypoints&&i.waypoints.length||(i.waypoints=[c?cn(c):u,p?cn(p):h]),this._connectionDocking&&(c||p)&&!f&&(i.waypoints=this._connectionDocking.getCroppedWaypoints(i,c,p)),this._graphicsFactory.drawConnection(a,i)):!m&&this.drawNoopPreview(a,n)},hc.prototype.drawNoopPreview=function(e,t){var n=t.source,i=t.target,r=t.connectionStart||cn(n),o=t.connectionEnd||cn(i),a=this.cropWaypoints(r,o,n,i);me(e,this.createNoopConnection(a[0],a[1]))},hc.prototype.cropWaypoints=function(e,t,n,i){var r=this._graphicsFactory,o=n&&r.getShapePath(n),a=i&&r.getShapePath(i),s=r.getConnectionPath({waypoints:[e,t]});return[e=n&&ln(o,s,!0)||e,t=i&&ln(a,s,!1)||t]},hc.prototype.cleanUp=function(e){e&&e.connectionPreviewGfx&&Ce(e.connectionPreviewGfx)},hc.prototype.getConnection=function(e){var t=function(e){return h(e)?e:{}}(e);return this._elementFactory.createConnection(t)},hc.prototype.createConnectionPreviewGfx=function(){var e=Me("g");return ge(e,{pointerEvents:"none"}),we(e).add("djs-connection-preview"),me(this._canvas.getActiveLayer(),e),e},hc.prototype.createNoopConnection=function(e,t){var n=Me("polyline");return ge(n,{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"}),ge(n,{points:[e.x,e.y,t.x,t.y]}),n};var dc={__init__:["connectionPreview"],connectionPreview:["type",hc]},fc=Math.min,mc=Math.max;function vc(e){e.preventDefault()}function yc(e){e.stopPropagation()}function gc(e){this.container=e.container,this.parent=ce('<div class="djs-direct-editing-parent"><div class="djs-direct-editing-content" contenteditable="true"></div></div>'),this.content=ue("[contenteditable]",this.parent),this.keyHandler=e.keyHandler||function(){},this.resizeHandler=e.resizeHandler||function(){},this.autoResize=I(this.autoResize,this),this.handlePaste=I(this.handlePaste,this)}function bc(e,t){this._eventBus=e,this._providers=[],this._textbox=new gc({container:t.getContainer(),keyHandler:I(this._handleKey,this),resizeHandler:I(this._handleResize,this)})}gc.prototype.create=function(e,t,n,i){var r=this.parent,o=this.content,a=this.container;i=this.options=i||{};var s=$(t=this.style=t||{},["width","height","maxWidth","maxHeight","minWidth","minHeight","left","top","backgroundColor","position","overflow","border","wordWrap","textAlign","outline","transform"]);F(r.style,{width:e.width+"px",height:e.height+"px",maxWidth:e.maxWidth+"px",maxHeight:e.maxHeight+"px",minWidth:e.minWidth+"px",minHeight:e.minHeight+"px",left:e.x+"px",top:e.y+"px",backgroundColor:"#ffffff",position:"absolute",overflow:"visible",border:"1px solid #ccc",boxSizing:"border-box",wordWrap:"normal",textAlign:"center",outline:"none"},s);var c=$(t,["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"]);return F(o.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},c),i.centerVertically&&F(o.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},c),o.innerText=n,re.bind(o,"keydown",this.keyHandler),re.bind(o,"mousedown",yc),re.bind(o,"paste",this.handlePaste),i.autoResize&&re.bind(o,"input",this.autoResize),i.resizable&&this.resizable(t),a.appendChild(r),this.setSelection(o.lastChild,o.lastChild&&o.lastChild.length),r},gc.prototype.handlePaste=function(e){var t,n=this.options,i=this.style;if(e.preventDefault(),t=e.clipboardData?e.clipboardData.getData("text/plain"):window.clipboardData.getData("Text"),this.insertText(t),n.autoResize){var r=this.autoResize(i);r&&this.resizeHandler(r)}},gc.prototype.insertText=function(e){e=e.replace(/\r\n|\r|\n/g,"\n"),document.execCommand("insertText",!1,e)||this._insertTextIE(e)},gc.prototype._insertTextIE=function(e){var t,n,i,r=this.getSelection(),o=r.startContainer,a=r.endContainer,s=r.startOffset,c=r.endOffset,p=r.commonAncestorContainer,l=(t=p.childNodes,[].slice.call(t));if(function(e){return e.nodeType===Node.TEXT_NODE}(p)){var u=o.textContent;o.textContent=u.substring(0,s)+e+u.substring(c),n=o,i=s+e.length}else if(o===this.content&&a===this.content){var h=document.createTextNode(e);this.content.insertBefore(h,l[s]),n=h,i=h.textContent.length}else{var d=l.indexOf(o),f=l.indexOf(a);l.forEach((function(t,n){n===d?t.textContent=o.textContent.substring(0,s)+e+a.textContent.substring(c):n>d&&n<=f&&de(t)})),n=o,i=s+e.length}n&&void 0!==i&&setTimeout((function(){self.setSelection(n,i)}))},gc.prototype.autoResize=function(){var e=this.parent,t=this.content,n=parseInt(this.style.fontSize)||12;if(t.scrollHeight>e.offsetHeight||t.scrollHeight<e.offsetHeight-n){var i=e.getBoundingClientRect(),r=t.scrollHeight;e.style.height=r+"px",this.resizeHandler({width:i.width,height:i.height,dx:0,dy:r-i.height})}},gc.prototype.resizable=function(){var e=this,t=this.parent,n=this.resizeHandle,i=parseInt(this.style.minWidth)||0,r=parseInt(this.style.minHeight)||0,o=parseInt(this.style.maxWidth)||1/0,a=parseInt(this.style.maxHeight)||1/0;if(!n){var s,c,p,l;n=this.resizeHandle=ce('<div class="djs-direct-editing-resize-handle"></div>');var u=function(n){vc(n),yc(n);var u=fc(mc(p+n.clientX-s,i),o),h=fc(mc(l+n.clientY-c,r),a);t.style.width=u+"px",t.style.height=h+"px",e.resizeHandler({width:p,height:l,dx:n.clientX-s,dy:n.clientY-c})},h=function(e){vc(e),yc(e),re.unbind(document,"mousemove",u,!1),re.unbind(document,"mouseup",h,!1)};re.bind(n,"mousedown",(function(e){vc(e),yc(e),s=e.clientX,c=e.clientY;var n=t.getBoundingClientRect();p=n.width,l=n.height,re.bind(document,"mousemove",u),re.bind(document,"mouseup",h)}))}F(n.style,{position:"absolute",bottom:"0px",right:"0px",cursor:"nwse-resize",width:"0",height:"0",borderTop:(parseInt(this.style.fontSize)/4||3)+"px solid transparent",borderRight:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderBottom:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderLeft:(parseInt(this.style.fontSize)/4||3)+"px solid transparent"}),t.appendChild(n)},gc.prototype.destroy=function(){var e=this.parent,t=this.content,n=this.resizeHandle;t.innerText="",e.removeAttribute("style"),t.removeAttribute("style"),re.unbind(t,"keydown",this.keyHandler),re.unbind(t,"mousedown",yc),re.unbind(t,"input",this.autoResize),re.unbind(t,"paste",this.handlePaste),n&&(n.removeAttribute("style"),de(n)),de(e)},gc.prototype.getValue=function(){return this.content.innerText.trim()},gc.prototype.getSelection=function(){return window.getSelection().getRangeAt(0)},gc.prototype.setSelection=function(e,t){var n=document.createRange();null===e?n.selectNodeContents(this.content):(n.setStart(e,t),n.setEnd(e,t));var i=window.getSelection();i.removeAllRanges(),i.addRange(n)},bc.$inject=["eventBus","canvas"],bc.prototype.registerProvider=function(e){this._providers.push(e)},bc.prototype.isActive=function(){return!!this._active},bc.prototype.cancel=function(){this._active&&(this._fire("cancel"),this.close())},bc.prototype._fire=function(e,t){this._eventBus.fire("directEditing."+e,t||{active:this._active})},bc.prototype.close=function(){this._textbox.destroy(),this._fire("deactivate"),this._active=null,this.resizable=void 0},bc.prototype.complete=function(){var e=this._active;if(e){var t,n=e.context.bounds,i=this.$textbox.getBoundingClientRect(),r=this.getValue();r===e.context.text&&i.height===n.height&&i.width===n.width||(t=this._textbox.container.getBoundingClientRect(),e.provider.update(e.element,r,e.context.text,{x:i.left-t.left,y:i.top-t.top,width:i.width,height:i.height})),this._fire("complete"),this.close()}},bc.prototype.getValue=function(){return this._textbox.getValue()},bc.prototype._handleKey=function(e){e.stopPropagation();var t=e.keyCode||e.charCode;return 27===t?(e.preventDefault(),this.cancel()):13!==t||e.shiftKey?void 0:(e.preventDefault(),this.complete())},bc.prototype._handleResize=function(e){this._fire("resize",e)},bc.prototype.activate=function(e){var t;this.isActive()&&this.cancel();var n=y(this._providers,(function(n){return(t=n.activate(e))?n:null}));return t&&(this.$textbox=this._textbox.create(t.bounds,t.style,t.text,t.options),this._active={element:e,context:t,provider:n},t.options&&t.options.resizable&&(this.resizable=!0),this._fire("activate")),!!t};var xc={__depends__:[Co],__init__:["directEditing"],directEditing:["type",bc]},_c=".entry";function Ec(e,t,n){this._eventBus=t,this._overlays=n;var i=p(e&&e.scale)?e.scale:{min:1,max:1.5};this._overlaysConfig={position:{right:-9,top:-6},scale:i},this._current=null,this._init()}Ec.$inject=["config.contextPad","eventBus","overlays"],Ec.prototype._init=function(){var e=this._eventBus,t=this;e.on("selection.changed",(function(e){var n=e.newSelection;1===n.length?t.open(n[0]):t.close()})),e.on("elements.delete",(function(e){b(e.elements,(function(e){t.isOpen(e)&&t.close()}))})),e.on("element.changed",(function(e){var n=e.element,i=t._current;i&&i.element===n&&t.open(n,!0)}))},Ec.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("contextPad.getProviders",e,(function(e){e.providers.push(t)}))},Ec.prototype.getEntries=function(e){var t=this._getProviders(),n={};return b(t,(function(t){var i=t.getContextPadEntries(e);f(i)?n=i(n):b(i,(function(e,t){n[t]=e}))})),n},Ec.prototype.trigger=function(e,t,n){var i,r,o=this._current.element,a=this._current.entries,s=t.delegateTarget||t.target;if(!s)return t.preventDefault();if(i=a[G(s,"data-action")].action,r=t.originalEvent||t,f(i)){if("click"===e)return i(r,o,n)}else if(i[e])return i[e](r,o,n);t.preventDefault()},Ec.prototype.open=function(e,t){!t&&this.isOpen(e)||(this.close(),this._updateAndOpen(e))},Ec.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"contextPad.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},Ec.prototype._updateAndOpen=function(e){var t=this.getEntries(e),n=this.getPad(e),i=n.html;b(t,(function(e,t){var n,r=e.group||"default",o=ce(e.html||'<div class="entry" draggable="true"></div>');G(o,"data-action",t),(n=ue("[data-group="+r+"]",i))||(n=ce('<div class="group" data-group="'+r+'"></div>'),i.appendChild(n)),n.appendChild(o),e.className&&function(e,t){var n=K(e);(u(t)?t:t.split(/\s+/g)).forEach((function(e){n.add(e)}))}(o,e.className),e.title&&G(o,"title",e.title),e.imageUrl&&o.appendChild(ce('<img src="'+e.imageUrl+'">'))})),K(i).add("open"),this._current={element:e,pad:n,entries:t},this._eventBus.fire("contextPad.open",{current:this._current})},Ec.prototype.getPad=function(e){if(this.isOpen())return this._current.pad;var t=this,n=this._overlays,i=ce('<div class="djs-context-pad"></div>'),r=F({html:i},this._overlaysConfig);se.bind(i,_c,"click",(function(e){t.trigger("click",e)})),se.bind(i,_c,"dragstart",(function(e){t.trigger("dragstart",e)})),re.bind(i,"mousedown",(function(e){e.stopPropagation()})),this._overlayId=n.add(e,"context-pad",r);var o=n.get(this._overlayId);return this._eventBus.fire("contextPad.create",{element:e,pad:o}),o},Ec.prototype.close=function(){this.isOpen()&&(this._overlays.remove(this._overlayId),this._overlayId=null,this._eventBus.fire("contextPad.close",{current:this._current}),this._current=null)},Ec.prototype.isOpen=function(e){return!(!this._current||e&&this._current.element!==e)};var wc={__depends__:[Co,$o],contextPad:["type",Ec]},Sc=["marker-start","marker-mid","marker-end"],Cc=["circle","ellipse","line","path","polygon","polyline","rect"];function Tc(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._styles=i,this._clonedMarkers={};var r=this;t.on("drag.cleanup",(function(){b(r._clonedMarkers,(function(e){Ce(e)})),r._clonedMarkers={}}))}Tc.$inject=["elementRegistry","eventBus","canvas","styles"],Tc.prototype.getGfx=function(e){return this._elementRegistry.getGraphics(e)},Tc.prototype.addDragger=function(e,t,n){var i=Re(n=n||this.getGfx(e)),r=n.getBoundingClientRect();return this._cloneMarkers(Gn(i)),ge(i,this._styles.cls("djs-dragger",[],{x:r.top,y:r.left})),me(t,i),i},Tc.prototype.addFrame=function(e,t){var n=Me("rect",{class:"djs-resize-overlay",width:e.width,height:e.height,x:e.x,y:e.y});return me(t,n),n},Tc.prototype._cloneMarkers=function(e){var t=this;if(e.childNodes)for(var n=0;n<e.childNodes.length;n++)t._cloneMarkers(e.childNodes[n]);(function(e){return-1!==Cc.indexOf(e.nodeName)})(e)&&Sc.forEach((function(n){if(ge(e,n)){var i=function(e,t,n){return ue("marker#"+(i=ge(e,t),i.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]),n||document);var i}(e,n,t._canvas.getContainer());t._cloneMarker(e,i,n)}}))},Tc.prototype._cloneMarker=function(e,t,n){var i=t.id,r=this._clonedMarkers[i];if(!r){var o=i+"-clone";(r=Re(t)).id=o,we(r).add("djs-dragger").add("djs-dragger-marker"),this._clonedMarkers[i]=r;var a=ue("defs",this._canvas._svg);a||(a=Me("defs"),me(this._canvas._svg,a)),me(a,r)}ge(e,n,"url(#"+this._clonedMarkers[i].id+")")};var Rc={__init__:["previewSupport"],previewSupport:["type",Tc]},Pc="drop-ok",Ac="drop-not-ok",kc="attach-ok",Mc="new-parent",Dc="create";function Bc(e,t,n,i,r){function o(t,n){[kc,Pc,Ac,Mc].forEach((function(i){i===n?e.addMarker(t,i):e.removeMarker(t,i)}))}function a(){var e=t.context();e&&e.prefix===Dc&&t.cancel()}n.on(["create.move","create.hover"],(function(e){var t=e.context,n=t.elements,i=e.hover,a=t.source,s=t.hints||{};if(!i)return t.canExecute=!1,void(t.target=null);Nc(e);var c={x:e.x,y:e.y},p=t.canExecute=i&&function(e,t,n,i,o){if(!t)return!1;var a=y(e=g(e,(function(t){var n=t.labelTarget;return!(t.parent||function(e){return!!e.labelTarget}(t)&&-1!==e.indexOf(n))})),(function(e){return!Oc(e)})),s=!1,c=!1,p=!1;jc(e)&&(s=r.allowed("shape.attach",{position:n,shape:a,target:t})),s||(p=jc(e)?r.allowed("shape.create",{position:n,shape:a,source:i,target:t}):r.allowed("elements.create",{elements:e,position:n,target:t}));var l=o.connectionTarget;return p||s?(a&&i&&(c=r.allowed("connection.create",{source:l===i?a:i,target:l===i?i:a,hints:{targetParent:t,targetAttach:s}})),{attach:s,connect:c}):(null===p||null===s)&&null}(n,i,c,a,s);i&&null!==p&&(t.target=i,p&&p.attach?o(i,kc):o(i,p?Mc:Ac))})),n.on(["create.end","create.out","create.cleanup"],(function(e){var t=e.hover;t&&o(t,null)})),n.on("create.end",(function(e){var t=e.context,n=t.source,r=t.shape,o=t.elements,a=t.target,s=t.canExecute,c=s&&s.attach,p=s&&s.connect,l=t.hints||{};if(!1===s||!a)return!1;Nc(e);var u={x:e.x,y:e.y};r=p?i.appendShape(n,r,u,a,{attach:c,connection:!0===p?{}:p,connectionTarget:l.connectionTarget}):y(o=i.createElements(o,u,a,F({},l,{attach:c})),(function(e){return!Oc(e)})),F(t,{elements:o,shape:r}),F(e,{elements:o,shape:r})})),n.on("create.init",(function(){n.on("elements.changed",a),n.once(["create.cancel","create.end"],2e3,(function(){n.off("elements.changed",a)}))})),this.start=function(e,n,i){u(n)||(n=[n]);var r=y(n,(function(e){return!Oc(e)}));if(r){i=F({elements:n,hints:{},shape:r},i||{}),b(n,(function(e){d(e.x)||(e.x=0),d(e.y)||(e.y=0)}));var o=pt(n);b(n,(function(e){Oc(e)&&(e.waypoints=S(e.waypoints,(function(e){return{x:e.x-o.x-o.width/2,y:e.y-o.y-o.height/2}}))),F(e,{x:e.x-o.x-o.width/2,y:e.y-o.y-o.height/2})})),t.init(e,Dc,{cursor:"grabbing",autoActivate:!0,data:{shape:r,elements:n,context:i}})}}}function Nc(e){var t=e.context.createConstraints;t&&(t.left&&(e.x=Math.max(e.x,t.left)),t.right&&(e.x=Math.min(e.x,t.right)),t.top&&(e.y=Math.max(e.y,t.top)),t.bottom&&(e.y=Math.min(e.y,t.bottom)))}function Oc(e){return!!e.waypoints}function jc(e){return e&&1===e.length&&!Oc(e[0])}Bc.$inject=["canvas","dragging","eventBus","modeling","rules"];function Lc(e,t,n,i,r){t.on("create.move",750,(function(t){var o=t.hover,a=t.context,s=a.elements,c=a.dragGroup;c||(c=a.dragGroup=function(e){var t=Me("g");ge(t,r.cls("djs-drag-group",["no-events"]));var o=Me("g");return e.forEach((function(e){var r;e.hidden||(e.waypoints?(r=n._createContainer("connection",o),n.drawConnection(Gn(r),e)):(r=n._createContainer("shape",o),n.drawShape(Gn(r),e),Vn(r,e.x,e.y)),i.addDragger(e,t,r))})),t}(s)),o?(c.parentNode||me(e.getActiveLayer(),c),Vn(c,t.x,t.y)):Ce(c)})),t.on("create.cleanup",(function(e){var t=e.context.dragGroup;t&&Ce(t)}))}Lc.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];var Ic={__depends__:[ss,Rc,hs,No],__init__:["create","createPreview"],create:["type",Bc],createPreview:["type",Lc]},zc="data-id",Fc=["contextPad.close","canvas.viewbox.changing","commandStack.changed"];function $c(e,t,n){var i=p(e&&e.scale)?e.scale:{min:1,max:1.5};this._config={scale:i},this._eventBus=t,this._canvas=n,this._providers={},this._current={}}$c.$inject=["config.popupMenu","eventBus","canvas"],$c.prototype.registerProvider=function(e,t,n){n||(n=t,t=1e3),this._eventBus.on("popupMenu.getProviders."+e,t,(function(e){e.providers.push(n)}))},$c.prototype.isEmpty=function(e,t){if(!e)throw new Error("element parameter is missing");if(!t)throw new Error("providerId parameter is missing");var n=this._getProviders(t);if(!n)return!0;var i=this._getEntries(e,n),r=this._getHeaderEntries(e,n),o=T(i)>0,a=r&&T(r)>0;return!o&&!a},$c.prototype.open=function(e,t,n){var i=this._getProviders(t);if(!e)throw new Error("Element is missing");if(!i||!i.length)throw new Error("No registered providers for: "+t);if(!n)throw new Error("the position argument is missing");this.isOpen()&&this.close(),this._emit("open");var r=this._current={className:t,element:e,position:n},o=this._getEntries(e,i),a=this._getHeaderEntries(e,i);r.entries=F({},o,a),r.container=this._createContainer(),T(a)&&r.container.appendChild(this._createEntries(a,"djs-popup-header")),T(o)&&r.container.appendChild(this._createEntries(o,"djs-popup-body"));var s=this._canvas.getContainer();this._attachContainer(r.container,s,n.cursor),this._bindAutoClose()},$c.prototype.close=function(){this.isOpen()&&(this._emit("close"),this._unbindAutoClose(),de(this._current.container),this._current.container=null)},$c.prototype.isOpen=function(){return!!this._current.container},$c.prototype.trigger=function(e){e.preventDefault();var t=G(e.delegateTarget||e.target,zc),n=this._getEntry(t);if(n.action)return n.action.call(null,e,n)},$c.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"popupMenu.getProviders."+e,providers:[]});return this._eventBus.fire(t),t.providers},$c.prototype._getEntries=function(e,t){var n={};return b(t,(function(t){if(t.getPopupMenuEntries){var i=t.getPopupMenuEntries(e);f(i)?n=i(n):b(i,(function(e,t){n[t]=e}))}else b(t.getEntries(e),(function(e){var t=e.id;if(!t)throw new Error("every entry must have the id property set");n[t]=H(e,["id"])}))})),n},$c.prototype._getHeaderEntries=function(e,t){var n={};return b(t,(function(t){if(t.getPopupMenuHeaderEntries){var i=t.getPopupMenuHeaderEntries(e);f(i)?n=i(n):b(i,(function(e,t){n[t]=e}))}else{if(!t.getHeaderEntries)return;b(t.getHeaderEntries(e),(function(e){var t=e.id;if(!t)throw new Error("every entry must have the id property set");n[t]=H(e,["id"])}))}})),n},$c.prototype._getEntry=function(e){var t=this._current.entries[e];if(!t)throw new Error("entry not found");return t},$c.prototype._emit=function(e){this._eventBus.fire("popupMenu."+e)},$c.prototype._createContainer=function(){var e=ce('<div class="djs-popup">'),t=this._current.position,n=this._current.className;return F(e.style,{position:"absolute",left:t.x+"px",top:t.y+"px",visibility:"hidden"}),K(e).add(n),e},$c.prototype._attachContainer=function(e,t,n){var i=this;se.bind(e,".entry","click",(function(e){i.trigger(e)})),this._updateScale(e),t.appendChild(e),n&&this._assureIsInbounds(e,n)},$c.prototype._updateScale=function(e){var t,n,i=this._canvas.zoom(),r=this._config.scale,o=i;!0!==r&&(!1===r?(t=1,n=1):(t=r.min,n=r.max),p(t)&&i<t&&(o=t),p(n)&&i>n&&(o=n)),function(e,t){e.style["transform-origin"]="top left",["","-ms-","-webkit-"].forEach((function(n){e.style[n+"transform"]=t}))}(e,"scale("+o+")")},$c.prototype._assureIsInbounds=function(e,t){var n,i,r=this._canvas._container.getBoundingClientRect(),o=e.offsetLeft,a=e.offsetTop,s=e.scrollWidth,c=e.scrollHeight,p={},l=t.x-r.left,u=t.y-r.top;o+s>r.width&&(p.x=!0),a+c>r.height&&(p.y=!0),p.x&&p.y?(n=l-s+"px",i=u-c+"px"):p.x?(n=l-s+"px",i=u+"px"):p.y&&u<c?(n=l+"px",i="10px"):p.y&&(n=l+"px",i=u-c+"px"),F(e.style,{left:n,top:i},{visibility:"visible","z-index":1e3})},$c.prototype._createEntries=function(e,t){var n=ce("<div>"),i=this;return K(n).add(t),b(e,(function(e,t){var r=i._createEntry(e,t);n.appendChild(r)})),n},$c.prototype._createEntry=function(e,t){var n=ce("<div>"),i=K(n);if(i.add("entry"),e.className&&e.className.split(" ").forEach((function(e){i.add(e)})),G(n,zc,t),e.label){var r=ce("<span>");r.textContent=e.label,n.appendChild(r)}return e.imageUrl&&n.appendChild(ce('<img src="'+e.imageUrl+'" />')),!0===e.active&&i.add("active"),!0===e.disabled&&i.add("disabled"),e.title&&(n.title=e.title),n},$c.prototype._bindAutoClose=function(){this._eventBus.once(Fc,this.close,this)},$c.prototype._unbindAutoClose=function(){this._eventBus.off(Fc,this.close,this)};var Hc={__init__:["popupMenu"],popupMenu:["type",$c]};function Gc(){}Gc.prototype.get=function(){return this._data},Gc.prototype.set=function(e){this._data=e},Gc.prototype.clear=function(){var e=this._data;return delete this._data,e},Gc.prototype.isEmpty=function(){return!this._data};var Wc={clipboard:["type",Gc]};function Vc(e){var t=this;function n(e){t._lastMoveEvent=e}this._lastMoveEvent=null,e.on("canvas.init",(function(e){(t._svg=e.svg).addEventListener("mousemove",n)})),e.on("canvas.destroy",(function(){t._lastMouseEvent=null,t._svg.removeEventListener("mousemove",n)}))}Vc.$inject=["eventBus"],Vc.prototype.getLastMoveEvent=function(){return this._lastMoveEvent||function(e,t){var n=document.createEvent("MouseEvent"),i=e,r=t,o=e,a=t;n.initMouseEvent&&n.initMouseEvent("mousemove",!0,!0,window,0,i,r,o,a,!1,!1,!1,!1,0,null);return n}(0,0)};var Uc={__init__:["mouse"],mouse:["type",Vc]};function qc(e,t,n,i,r,o,a,s){this._canvas=e,this._create=t,this._clipboard=n,this._elementFactory=i,this._eventBus=r,this._modeling=o,this._mouse=a,this._rules=s,r.on("copyPaste.copyElement",(function(e){var t=e.descriptor,n=e.element,i=e.elements;t.priority=1,t.id=n.id,y(i,(function(e){return e===n.parent}))&&(t.parent=n.parent.id),function(e){return!!e.host}(n)&&(t.priority=2,t.host=n.host.id),Kc(n)&&(t.priority=3,t.source=n.source.id,t.target=n.target.id,t.waypoints=function(e){return S(e.waypoints,(function(e){return(e=Xc(e)).original&&(e.original=Xc(e.original)),e}))}(n)),Yc(n)&&(t.priority=4,t.labelTarget=n.labelTarget.id),b(["x","y","width","height"],(function(e){d(n[e])&&(t[e]=n[e])})),t.hidden=n.hidden,t.collapsed=n.collapsed})),r.on("copyPaste.pasteElements",(function(e){F(e.hints,{createElementsBehavior:!1})}))}function Kc(e){return!!e.waypoints}function Yc(e){return!!e.labelTarget}function Xc(e){return F({},e)}function Zc(e,t){var n=t.indexOf(e);return-1===n?t:t.splice(n,1)}qc.$inject=["canvas","create","clipboard","elementFactory","eventBus","modeling","mouse","rules"],qc.prototype.copy=function(e){var t,n;return u(e)||(e=e?[e]:[]),n=!1===(t=this._eventBus.fire("copyPaste.canCopyElements",{elements:e}))?{}:this.createTree(u(t)?t:e),this._clipboard.set(n),this._eventBus.fire("copyPaste.elementsCopied",{elements:e,tree:n}),n},qc.prototype.paste=function(e){var t=this._clipboard.get();if(!this._clipboard.isEmpty()){var n=e&&e.hints||{};this._eventBus.fire("copyPaste.pasteElements",{hints:n});var i=this._createElements(t);if(e&&e.element&&e.point)return this._paste(i,e.element,e.point,n);this._create.start(this._mouse.getLastMoveEvent(),i,{hints:n||{}})}},qc.prototype._paste=function(e,t,n,i){b(e,(function(e){d(e.x)||(e.x=0),d(e.y)||(e.y=0)}));var r=pt(e);return b(e,(function(e){Kc(e)&&(e.waypoints=S(e.waypoints,(function(e){return{x:e.x-r.x-r.width/2,y:e.y-r.y-r.height/2}}))),F(e,{x:e.x-r.x-r.width/2,y:e.y-r.y-r.height/2})})),this._modeling.createElements(e,n,t,F({},i))},qc.prototype._createElements=function(e){var t=this,n=this._eventBus,i={},r=[];return b(e,(function(e,o){b(e=M(e,"priority"),(function(e){var o,a=F({},H(e,["priority"]));return i[e.parent]?a.parent=i[e.parent]:delete a.parent,n.fire("copyPaste.pasteElement",{cache:i,descriptor:a}),Kc(a)?(a.source=i[e.source],a.target=i[e.target],o=i[e.id]=t.createConnection(a),void r.push(o)):Yc(a)?(a.labelTarget=i[a.labelTarget],o=i[e.id]=t.createLabel(a),void r.push(o)):(a.host&&(a.host=i[a.host]),o=i[e.id]=t.createShape(a),void r.push(o))}))})),r},qc.prototype.createConnection=function(e){return this._elementFactory.createConnection(H(e,["id"]))},qc.prototype.createLabel=function(e){return this._elementFactory.createLabel(H(e,["id"]))},qc.prototype.createShape=function(e){return this._elementFactory.createShape(H(e,["id"]))},qc.prototype.hasRelations=function(e,t){var n,i;return!(Kc(e)&&(n=y(t,D({id:e.source.id})),i=y(t,D({id:e.target.id})),!n||!i))&&!(Yc(e)&&!y(t,D({id:e.labelTarget.id})))},qc.prototype.createTree=function(e){var t=this._rules,n=this,i={},r=[];function o(e,t){var n=y(r,(function(t){return e===t.element}));n?n.depth<t&&(r=function(e,t){var n=t.indexOf(e);-1!==n&&t.splice(n,1);return t}(n,r)).push({element:n.element,depth:t}):r.push({element:e,depth:t})}return st(rt(e),(function(e,t,n){if(!Yc(e))return b(e.labels,(function(e){o(e,n)})),b([e.attachers,e.incoming,e.outgoing],(function(e){e&&e.length&&b(e,(function(e){b(e.labels,(function(e){o(e,n)})),o(e,n)}))})),o(e,n),e.children})),e=S(r,(function(e){return e.element})),r=M(r=S(r,(function(t){return t.descriptor={},n._eventBus.fire("copyPaste.copyElement",{descriptor:t.descriptor,element:t.element,elements:e}),t})),(function(e){return e.descriptor.priority})),e=S(r,(function(e){return e.element})),b(r,(function(r){var o=r.depth;n.hasRelations(r.element,e)?!function(e,n){return t.allowed("element.copy",{element:e,elements:n})}(r.element,e)?Zc(r.element,e):(i[o]||(i[o]=[]),i[o].push(r.descriptor)):Zc(r.element,e)})),i};var Qc={__depends__:[Wc,Ic,Uc,hs],__init__:["copyPaste"],copyPaste:["type",qc]};function Jc(e,t,n){u(n)||(n=[n]),b(n,(function(n){c(e[n])||(t[n]=e[n])}))}function ep(e,t,n){var i;t.on("copyPaste.copyElement",750,(function(e){var t=e.descriptor,n=e.element,i=t.oldBusinessObject=kr(n);if(t.type=n.type,Jc(i,t,"name"),t.di={},Jc(i.di,t.di,["fill","stroke","background-color","border-color","color"]),Jc(i.di,t,"isExpanded"),tp(t))return t;i.default&&(t.default=i.default.id)})),t.on("moddleCopy.canCopyProperty",(function(t){var i,r=t.parent,o=t.property;if("processRef"===t.propertyName&&Ar(r,"bpmn:Participant")&&Ar(o,"bpmn:Process"))return i=e.create("bpmn:Process"),n.copyElement(o,i)})),t.on("copyPaste.pasteElements",(function(){i={}})),t.on("copyPaste.pasteElement",(function(t){var r,o,a,s=t.cache,c=t.descriptor,p=c.oldBusinessObject;tp(c)?c.businessObject=kr(s[c.labelTarget]):(r=e.create(p.$type),c.businessObject=n.copyElement(p,r),function(e,t){var n=kr(e);e.default&&(i[e.default]={element:n,property:"default"}),e.host&&(kr(e).attachedToRef=kr(t[e.host])),i=H(i,_(i,(function(t,i,r){var o=i.element,a=i.property;return r===e.id&&(o[a]=n,t.push(e.id)),t}),[]))}(c,s),Jc(c,r,["isExpanded","name"]),o=c,u(a="oldBusinessObject")||(a=[a]),b(a,(function(e){o[e]&&delete o[e]})))}))}function tp(e){return!!e.labelTarget}ep.$inject=["bpmnFactory","eventBus","moddleCopy"];var np=["artifacts","dataInputAssociations","dataOutputAssociations","default","flowElements","lanes","incoming","outgoing"];function ip(e,t,n){this._bpmnFactory=t,this._eventBus=e,this._moddle=n,e.on("moddleCopy.canCopyProperties",(function(e){var t=e.propertyNames;if(t&&t.length)return M(t,(function(e){return"extensionElements"===e}))})),e.on("moddleCopy.canCopyProperty",(function(e){var t=e.parent,n=h(t)&&t.$descriptor,i=e.propertyName;return(!i||-1===np.indexOf(i))&&(!(i&&n&&!y(n.properties,D({name:i})))&&void 0)})),e.on("moddleCopy.canSetCopiedProperty",(function(e){var t,n,i=e.property;if(n="bpmn:ExtensionElements",(t=i)&&"function"==typeof t.$instanceOf&&t.$instanceOf(n)&&(!i.values||!i.values.length))return!1}))}function rp(e,t){return _(e.properties,(function(e,n){return t&&n.default?e:e.concat(n.name)}),[])}ip.$inject=["eventBus","bpmnFactory","moddle"],ip.prototype.copyElement=function(e,t,n){var i=this;n&&!u(n)&&(n=[n]),n=n||rp(e.$descriptor);var r=this._eventBus.fire("moddleCopy.canCopyProperties",{propertyNames:n,sourceElement:e,targetElement:t});return!1===r||(u(r)&&(n=r),b(n,(function(n){var r;v(e,n)&&(r=e.get(n));var o=i.copyProperty(r,t,n);!1!==i._eventBus.fire("moddleCopy.canSetCopiedProperty",{parent:t,property:o,propertyName:n})&&p(o)&&t.set(n,o)}))),t},ip.prototype.copyProperty=function(e,t,n){var i=this,r=this._eventBus.fire("moddleCopy.canCopyProperty",{parent:t,property:e,propertyName:n});if(!1!==r){if(r)return h(r)&&r.$type&&!r.$parent&&(r.$parent=t),r;var o=this._moddle.getPropertyDescriptor(t,n);if(!o.isReference){if(o.isId)return this._copyId(e,t);if(u(e))return _(e,(function(e,o){return(r=i.copyProperty(o,t,n))?(r.$parent=t,e.concat(r)):e}),[]);if(h(e)&&e.$type){if(this._moddle.getElementDescriptor(e).isGeneric)return;return(r=i._bpmnFactory.create(e.$type)).$parent=t,r=i.copyElement(e,r)}return e}}},ip.prototype._copyId=function(e,t){return this._moddle.ids.assigned(e)?void 0:(this._moddle.ids.claim(e,t),e)};var op={__depends__:[Qc],__init__:["bpmnCopyPaste","moddleCopy"],bpmnCopyPaste:["type",ep],moddleCopy:["type",ip]},ap=Math.round;function sp(e){this._modeling=e}sp.$inject=["modeling"],sp.prototype.replaceElement=function(e,t,n){if(e.waypoints)return null;var i=this._modeling,r=t.width||e.width,o=t.height||e.height,a=t.x||e.x,s=t.y||e.y,c=ap(a+r/2),p=ap(s+o/2);return i.replaceShape(e,F({},t,{x:c,y:p,width:r,height:o}),n)};var cp={__init__:["replace"],replace:["type",sp]};var pp=["cancelActivity","instantiate","eventGatewayType","triggeredByEvent","isInterrupting"];function lp(e,t,n,i,r,o,a){this.replaceElement=function(s,p,l){l=l||{};var h=p.type,d=s.businessObject;if(up(d)&&"bpmn:SubProcess"===h&&function(e,t){var n=e&&v(e,"collapsed")?e.collapsed:!Mr(e);return n!==(t&&(v(t,"collapsed")||v(t,"isExpanded"))?v(t,"collapsed")?t.collapsed:!t.isExpanded:n)&&(e.collapsed=n,!0)}(s,p))return i.toggleCollapse(s),s;var f,m=e.create(h),y={type:h,businessObject:m},x=rp(d.$descriptor),_=rp(m.$descriptor,!0),E=(f=_,x.filter((function(e){return-1!==f.indexOf(e)})));F(m,$(p,pp));var w=g(E,(function(e){return"eventDefinitions"===e?hp(s,p.eventDefinitionType):"loopCharacteristics"===e?!Dr(m):!v(m,e)&&(("processRef"!==e||!1!==p.isExpanded)&&"triggeredByEvent"!==e)}));return m=n.copyElement(d,m,w),p.eventDefinitionType&&(hp(m,p.eventDefinitionType)||(y.eventDefinitionType=p.eventDefinitionType,y.eventDefinitionAttrs=p.eventDefinitionAttrs)),Ar(d,"bpmn:Activity")&&(up(d)?y.isExpanded=Mr(d):p&&v(p,"isExpanded")&&(y.isExpanded=p.isExpanded),Mr(d)&&!Ar(d,"bpmn:Task")&&y.isExpanded&&(y.width=s.width,y.height=s.height)),up(d)&&!up(m)&&(l.moveChildren=!1),Ar(d,"bpmn:Participant")&&(!0===p.isExpanded?m.processRef=e.create("bpmn:Process"):l.moveChildren=!1,y.width=s.width,y.height=t._getDefaultSize(m).height),o.allowed("shape.resize",{shape:m})||(y.height=t._getDefaultSize(m).height,y.width=t._getDefaultSize(m).width),m.name=d.name,Ha(d,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&Ha(m,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&(m.default=d.default),p.host&&!Ar(d,"bpmn:BoundaryEvent")&&Ar(m,"bpmn:BoundaryEvent")&&(y.host=p.host),"bpmn:DataStoreReference"!==y.type&&"bpmn:DataObjectReference"!==y.type||(y.x=s.x+(s.width-y.width)/2),y.di={},function(e,t,n){u(n)||(n=[n]),b(n,(function(n){c(e[n])||(t[n]=e[n])}))}(d.di,y.di,["fill","stroke","background-color","border-color","color"]),y=r.replaceElement(s,y,l),!1!==l.select&&a.select(y),y}}function up(e){return Ar(e,"bpmn:SubProcess")}function hp(e,t){var n=kr(e);return t&&n.get("eventDefinitions").some((function(e){return Ar(e,t)}))}lp.$inject=["bpmnFactory","elementFactory","moddleCopy","modeling","replace","rules","selection"];var dp={__depends__:[op,cp,No],bpmnReplace:["type",lp]};function fp(e){return function(t){var n=t.target,i=kr(e),r=i.eventDefinitions&&i.eventDefinitions[0],o=i.$type===n.type,a=(r&&r.$type)===n.eventDefinitionType,s=i.triggeredByEvent===n.triggeredByEvent,c=void 0===n.isExpanded||n.isExpanded===Mr(i);return!(o&&a&&s&&c)}}var mp=[{label:"Start Event",actionName:"replace-with-none-start",className:"bpmn-icon-start-event-none",target:{type:"bpmn:StartEvent"}},{label:"Intermediate Throw Event",actionName:"replace-with-none-intermediate-throwing",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:IntermediateThrowEvent"}},{label:"End Event",actionName:"replace-with-none-end",className:"bpmn-icon-end-event-none",target:{type:"bpmn:EndEvent"}},{label:"Message Start Event",actionName:"replace-with-message-start",className:"bpmn-icon-start-event-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Timer Start Event",actionName:"replace-with-timer-start",className:"bpmn-icon-start-event-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition"}},{label:"Conditional Start Event",actionName:"replace-with-conditional-start",className:"bpmn-icon-start-event-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition"}},{label:"Signal Start Event",actionName:"replace-with-signal-start",className:"bpmn-icon-start-event-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}}],vp=[{label:"Start Event",actionName:"replace-with-none-start",className:"bpmn-icon-start-event-none",target:{type:"bpmn:StartEvent"}},{label:"Intermediate Throw Event",actionName:"replace-with-none-intermediate-throwing",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:IntermediateThrowEvent"}},{label:"End Event",actionName:"replace-with-none-end",className:"bpmn-icon-end-event-none",target:{type:"bpmn:EndEvent"}}],yp=[{label:"Start Event",actionName:"replace-with-none-start",className:"bpmn-icon-start-event-none",target:{type:"bpmn:StartEvent"}},{label:"Intermediate Throw Event",actionName:"replace-with-none-intermediate-throw",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:IntermediateThrowEvent"}},{label:"End Event",actionName:"replace-with-none-end",className:"bpmn-icon-end-event-none",target:{type:"bpmn:EndEvent"}},{label:"Message Intermediate Catch Event",actionName:"replace-with-message-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-message",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Message Intermediate Throw Event",actionName:"replace-with-message-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-message",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Timer Intermediate Catch Event",actionName:"replace-with-timer-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-timer",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:TimerEventDefinition"}},{label:"Escalation Intermediate Throw Event",actionName:"replace-with-escalation-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-escalation",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},{label:"Conditional Intermediate Catch Event",actionName:"replace-with-conditional-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-condition",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition"}},{label:"Link Intermediate Catch Event",actionName:"replace-with-link-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-link",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:LinkEventDefinition",eventDefinitionAttrs:{name:""}}},{label:"Link Intermediate Throw Event",actionName:"replace-with-link-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-link",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:LinkEventDefinition",eventDefinitionAttrs:{name:""}}},{label:"Compensation Intermediate Throw Event",actionName:"replace-with-compensation-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-compensation",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},{label:"Signal Intermediate Catch Event",actionName:"replace-with-signal-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-signal",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},{label:"Signal Intermediate Throw Event",actionName:"replace-with-signal-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-signal",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}}],gp=[{label:"Start Event",actionName:"replace-with-none-start",className:"bpmn-icon-start-event-none",target:{type:"bpmn:StartEvent"}},{label:"Intermediate Throw Event",actionName:"replace-with-none-intermediate-throw",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:IntermediateThrowEvent"}},{label:"End Event",actionName:"replace-with-none-end",className:"bpmn-icon-end-event-none",target:{type:"bpmn:EndEvent"}},{label:"Message End Event",actionName:"replace-with-message-end",className:"bpmn-icon-end-event-message",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Escalation End Event",actionName:"replace-with-escalation-end",className:"bpmn-icon-end-event-escalation",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},{label:"Error End Event",actionName:"replace-with-error-end",className:"bpmn-icon-end-event-error",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:ErrorEventDefinition"}},{label:"Cancel End Event",actionName:"replace-with-cancel-end",className:"bpmn-icon-end-event-cancel",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:CancelEventDefinition"}},{label:"Compensation End Event",actionName:"replace-with-compensation-end",className:"bpmn-icon-end-event-compensation",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},{label:"Signal End Event",actionName:"replace-with-signal-end",className:"bpmn-icon-end-event-signal",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},{label:"Terminate End Event",actionName:"replace-with-terminate-end",className:"bpmn-icon-end-event-terminate",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:TerminateEventDefinition"}}],bp=[{label:"Exclusive Gateway",actionName:"replace-with-exclusive-gateway",className:"bpmn-icon-gateway-xor",target:{type:"bpmn:ExclusiveGateway"}},{label:"Parallel Gateway",actionName:"replace-with-parallel-gateway",className:"bpmn-icon-gateway-parallel",target:{type:"bpmn:ParallelGateway"}},{label:"Inclusive Gateway",actionName:"replace-with-inclusive-gateway",className:"bpmn-icon-gateway-or",target:{type:"bpmn:InclusiveGateway"}},{label:"Complex Gateway",actionName:"replace-with-complex-gateway",className:"bpmn-icon-gateway-complex",target:{type:"bpmn:ComplexGateway"}},{label:"Event based Gateway",actionName:"replace-with-event-based-gateway",className:"bpmn-icon-gateway-eventbased",target:{type:"bpmn:EventBasedGateway",instantiate:!1,eventGatewayType:"Exclusive"}}],xp=[{label:"Transaction",actionName:"replace-with-transaction",className:"bpmn-icon-transaction",target:{type:"bpmn:Transaction",isExpanded:!0}},{label:"Event Sub Process",actionName:"replace-with-event-subprocess",className:"bpmn-icon-event-subprocess-expanded",target:{type:"bpmn:SubProcess",triggeredByEvent:!0,isExpanded:!0}},{label:"Sub Process (collapsed)",actionName:"replace-with-collapsed-subprocess",className:"bpmn-icon-subprocess-collapsed",target:{type:"bpmn:SubProcess",isExpanded:!1}}],_p=[{label:"Sub Process",actionName:"replace-with-subprocess",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:SubProcess",isExpanded:!0}},{label:"Event Sub Process",actionName:"replace-with-event-subprocess",className:"bpmn-icon-event-subprocess-expanded",target:{type:"bpmn:SubProcess",triggeredByEvent:!0,isExpanded:!0}}],Ep=[{label:"Sub Process",actionName:"replace-with-subprocess",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:SubProcess",isExpanded:!0}},{label:"Transaction",actionName:"replace-with-transaction",className:"bpmn-icon-transaction",target:{type:"bpmn:Transaction",isExpanded:!0}}],wp=[{label:"Task",actionName:"replace-with-task",className:"bpmn-icon-task",target:{type:"bpmn:Task"}},{label:"Send Task",actionName:"replace-with-send-task",className:"bpmn-icon-send",target:{type:"bpmn:SendTask"}},{label:"Receive Task",actionName:"replace-with-receive-task",className:"bpmn-icon-receive",target:{type:"bpmn:ReceiveTask"}},{label:"User Task",actionName:"replace-with-user-task",className:"bpmn-icon-user",target:{type:"bpmn:UserTask"}},{label:"Manual Task",actionName:"replace-with-manual-task",className:"bpmn-icon-manual",target:{type:"bpmn:ManualTask"}},{label:"Business Rule Task",actionName:"replace-with-rule-task",className:"bpmn-icon-business-rule",target:{type:"bpmn:BusinessRuleTask"}},{label:"Service Task",actionName:"replace-with-service-task",className:"bpmn-icon-service",target:{type:"bpmn:ServiceTask"}},{label:"Script Task",actionName:"replace-with-script-task",className:"bpmn-icon-script",target:{type:"bpmn:ScriptTask"}},{label:"Call Activity",actionName:"replace-with-call-activity",className:"bpmn-icon-call-activity",target:{type:"bpmn:CallActivity"}},{label:"Sub Process (collapsed)",actionName:"replace-with-collapsed-subprocess",className:"bpmn-icon-subprocess-collapsed",target:{type:"bpmn:SubProcess",isExpanded:!1}},{label:"Sub Process (expanded)",actionName:"replace-with-expanded-subprocess",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:SubProcess",isExpanded:!0}}],Sp=[{label:"Data Store Reference",actionName:"replace-with-data-store-reference",className:"bpmn-icon-data-store",target:{type:"bpmn:DataStoreReference"}}],Cp=[{label:"Data Object Reference",actionName:"replace-with-data-object-reference",className:"bpmn-icon-data-object",target:{type:"bpmn:DataObjectReference"}}],Tp=[{label:"Message Boundary Event",actionName:"replace-with-message-boundary",className:"bpmn-icon-intermediate-event-catch-message",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Timer Boundary Event",actionName:"replace-with-timer-boundary",className:"bpmn-icon-intermediate-event-catch-timer",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:TimerEventDefinition"}},{label:"Escalation Boundary Event",actionName:"replace-with-escalation-boundary",className:"bpmn-icon-intermediate-event-catch-escalation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},{label:"Conditional Boundary Event",actionName:"replace-with-conditional-boundary",className:"bpmn-icon-intermediate-event-catch-condition",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition"}},{label:"Error Boundary Event",actionName:"replace-with-error-boundary",className:"bpmn-icon-intermediate-event-catch-error",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ErrorEventDefinition"}},{label:"Cancel Boundary Event",actionName:"replace-with-cancel-boundary",className:"bpmn-icon-intermediate-event-catch-cancel",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:CancelEventDefinition"}},{label:"Signal Boundary Event",actionName:"replace-with-signal-boundary",className:"bpmn-icon-intermediate-event-catch-signal",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},{label:"Compensation Boundary Event",actionName:"replace-with-compensation-boundary",className:"bpmn-icon-intermediate-event-catch-compensation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},{label:"Message Boundary Event (non-interrupting)",actionName:"replace-with-non-interrupting-message-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-message",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:MessageEventDefinition",cancelActivity:!1}},{label:"Timer Boundary Event (non-interrupting)",actionName:"replace-with-non-interrupting-timer-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-timer",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:TimerEventDefinition",cancelActivity:!1}},{label:"Escalation Boundary Event (non-interrupting)",actionName:"replace-with-non-interrupting-escalation-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-escalation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",cancelActivity:!1}},{label:"Conditional Boundary Event (non-interrupting)",actionName:"replace-with-non-interrupting-conditional-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-condition",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",cancelActivity:!1}},{label:"Signal Boundary Event (non-interrupting)",actionName:"replace-with-non-interrupting-signal-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-signal",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:SignalEventDefinition",cancelActivity:!1}}],Rp=[{label:"Message Start Event",actionName:"replace-with-message-start",className:"bpmn-icon-start-event-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Timer Start Event",actionName:"replace-with-timer-start",className:"bpmn-icon-start-event-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition"}},{label:"Conditional Start Event",actionName:"replace-with-conditional-start",className:"bpmn-icon-start-event-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition"}},{label:"Signal Start Event",actionName:"replace-with-signal-start",className:"bpmn-icon-start-event-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},{label:"Error Start Event",actionName:"replace-with-error-start",className:"bpmn-icon-start-event-error",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ErrorEventDefinition"}},{label:"Escalation Start Event",actionName:"replace-with-escalation-start",className:"bpmn-icon-start-event-escalation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},{label:"Compensation Start Event",actionName:"replace-with-compensation-start",className:"bpmn-icon-start-event-compensation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},{label:"Message Start Event (non-interrupting)",actionName:"replace-with-non-interrupting-message-start",className:"bpmn-icon-start-event-non-interrupting-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition",isInterrupting:!1}},{label:"Timer Start Event (non-interrupting)",actionName:"replace-with-non-interrupting-timer-start",className:"bpmn-icon-start-event-non-interrupting-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition",isInterrupting:!1}},{label:"Conditional Start Event (non-interrupting)",actionName:"replace-with-non-interrupting-conditional-start",className:"bpmn-icon-start-event-non-interrupting-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",isInterrupting:!1}},{label:"Signal Start Event (non-interrupting)",actionName:"replace-with-non-interrupting-signal-start",className:"bpmn-icon-start-event-non-interrupting-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition",isInterrupting:!1}},{label:"Escalation Start Event (non-interrupting)",actionName:"replace-with-non-interrupting-escalation-start",className:"bpmn-icon-start-event-non-interrupting-escalation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",isInterrupting:!1}}],Pp=[{label:"Sequence Flow",actionName:"replace-with-sequence-flow",className:"bpmn-icon-connection"},{label:"Default Flow",actionName:"replace-with-default-flow",className:"bpmn-icon-default-flow"},{label:"Conditional Flow",actionName:"replace-with-conditional-flow",className:"bpmn-icon-conditional-flow"}],Ap=[{label:"Expanded Pool",actionName:"replace-with-expanded-pool",className:"bpmn-icon-participant",target:{type:"bpmn:Participant",isExpanded:!0}},{label:function(e){var t="Empty Pool";return e.children&&e.children.length&&(t+=" (removes content)"),t},actionName:"replace-with-collapsed-pool",className:"bpmn-icon-lane",target:{type:"bpmn:Participant",isExpanded:!1}}];function kp(e,t,n,i,r,o,a){this._bpmnFactory=e,this._popupMenu=t,this._modeling=n,this._moddle=i,this._bpmnReplace=r,this._rules=o,this._translate=a,this.register()}kp.$inject=["bpmnFactory","popupMenu","modeling","moddle","bpmnReplace","rules","translate"],kp.prototype.register=function(){this._popupMenu.registerProvider("bpmn-replace",this)},kp.prototype.getEntries=function(e){var t,n=e.businessObject;if(!this._rules.allowed("shape.replace",{element:e}))return[];var i=fp(e);return Ar(n,"bpmn:DataObjectReference")?this._createEntries(e,Sp):Ar(n,"bpmn:DataStoreReference")?this._createEntries(e,Cp):Ar(n,"bpmn:StartEvent")&&!Ar(n.$parent,"bpmn:SubProcess")?(t=g(mp,i),this._createEntries(e,t)):Ar(n,"bpmn:Participant")?(t=g(Ap,(function(e){return Mr(n)!==e.target.isExpanded})),this._createEntries(e,t)):Ar(n,"bpmn:StartEvent")&&Dr(n.$parent)?(t=g(Rp,(function(t){var n=!1!==t.target.isInterrupting,r=kr(e).isInterrupting===n;return i(t)||!i(t)&&!r})),this._createEntries(e,t)):Ar(n,"bpmn:StartEvent")&&!Dr(n.$parent)&&Ar(n.$parent,"bpmn:SubProcess")?(t=g(vp,i),this._createEntries(e,t)):Ar(n,"bpmn:EndEvent")?(t=g(gp,(function(e){return!("bpmn:CancelEventDefinition"==e.target.eventDefinitionType&&!Ar(n.$parent,"bpmn:Transaction"))&&i(e)})),this._createEntries(e,t)):Ar(n,"bpmn:BoundaryEvent")?(t=g(Tp,(function(e){var t=e.target;if("bpmn:CancelEventDefinition"==t.eventDefinitionType&&!Ar(n.attachedToRef,"bpmn:Transaction"))return!1;var r=!1!==t.cancelActivity,o=n.cancelActivity==r;return i(e)||!i(e)&&!o})),this._createEntries(e,t)):Ar(n,"bpmn:IntermediateCatchEvent")||Ar(n,"bpmn:IntermediateThrowEvent")?(t=g(yp,i),this._createEntries(e,t)):Ar(n,"bpmn:Gateway")?(t=g(bp,i),this._createEntries(e,t)):Ar(n,"bpmn:Transaction")?(t=g(_p,i),this._createEntries(e,t)):Dr(n)&&Mr(n)?(t=g(Ep,i),this._createEntries(e,t)):Ar(n,"bpmn:SubProcess")&&Mr(n)?(t=g(xp,i),this._createEntries(e,t)):Ar(n,"bpmn:AdHocSubProcess")&&!Mr(n)?(t=g(wp,(function(t){var n=t.target,i="bpmn:SubProcess"===n.type,r=!0===n.isExpanded;return fp(e)&&(!i||r)})),this._createEntries(e,t)):Ar(n,"bpmn:SequenceFlow")?this._createSequenceFlowEntries(e,Pp):Ar(n,"bpmn:FlowNode")?(t=g(wp,i),Ar(n,"bpmn:SubProcess")&&!Mr(n)&&(t=g(t,(function(e){return"Sub Process (collapsed)"!==e.label}))),this._createEntries(e,t)):[]},kp.prototype.getHeaderEntries=function(e){var t=[];return Ar(e,"bpmn:Activity")&&!Dr(e)&&(t=t.concat(this._getLoopEntries(e))),Ar(e,"bpmn:DataObjectReference")&&(t=t.concat(this._getDataObjectIsCollection(e))),Ar(e,"bpmn:Participant")&&(t=t.concat(this._getParticipantMultiplicity(e))),!Ar(e,"bpmn:SubProcess")||Ar(e,"bpmn:Transaction")||Dr(e)||t.push(this._getAdHocEntry(e)),t},kp.prototype._createEntries=function(e,t){var n=[],i=this;return b(t,(function(t){var r=i._createMenuEntry(t,e);n.push(r)})),n},kp.prototype._createSequenceFlowEntries=function(e,t){var n=kr(e),i=[],r=this._modeling,o=this._moddle,a=this;return b(t,(function(t){switch(t.actionName){case"replace-with-default-flow":n.sourceRef.default!==n&&(Ar(n.sourceRef,"bpmn:ExclusiveGateway")||Ar(n.sourceRef,"bpmn:InclusiveGateway")||Ar(n.sourceRef,"bpmn:ComplexGateway")||Ar(n.sourceRef,"bpmn:Activity"))&&i.push(a._createMenuEntry(t,e,(function(){r.updateProperties(e.source,{default:n})})));break;case"replace-with-conditional-flow":!n.conditionExpression&&Ar(n.sourceRef,"bpmn:Activity")&&i.push(a._createMenuEntry(t,e,(function(){var t=o.create("bpmn:FormalExpression",{body:""});r.updateProperties(e,{conditionExpression:t})})));break;default:if(Ar(n.sourceRef,"bpmn:Activity")&&n.conditionExpression)return i.push(a._createMenuEntry(t,e,(function(){r.updateProperties(e,{conditionExpression:void 0})})));if((Ar(n.sourceRef,"bpmn:ExclusiveGateway")||Ar(n.sourceRef,"bpmn:InclusiveGateway")||Ar(n.sourceRef,"bpmn:ComplexGateway")||Ar(n.sourceRef,"bpmn:Activity"))&&n.sourceRef.default===n)return i.push(a._createMenuEntry(t,e,(function(){r.updateProperties(e.source,{default:void 0})})))}})),i},kp.prototype._createMenuEntry=function(e,t,n){var i=this._translate,r=this._bpmnReplace.replaceElement,o=e.label;return o&&"function"==typeof o&&(o=o(t)),n=n||function(){return r(t,e.target)},{label:i(o),className:e.className,id:e.actionName,action:n}},kp.prototype._getLoopEntries=function(e){var t=this,n=this._translate;function i(n,i){var r;i.active?r=void 0:(r=t._moddle.create(i.options.loopCharacteristics),i.options.isSequential&&(r.isSequential=i.options.isSequential)),t._modeling.updateProperties(e,{loopCharacteristics:r})}var r,o,a,s=kr(e).loopCharacteristics;return s&&(r=s.isSequential,o=void 0===s.isSequential,a=void 0!==s.isSequential&&!s.isSequential),[{id:"toggle-parallel-mi",className:"bpmn-icon-parallel-mi-marker",title:n("Parallel Multi Instance"),active:a,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!1}},{id:"toggle-sequential-mi",className:"bpmn-icon-sequential-mi-marker",title:n("Sequential Multi Instance"),active:r,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!0}},{id:"toggle-loop",className:"bpmn-icon-loop-marker",title:n("Loop"),active:o,action:i,options:{loopCharacteristics:"bpmn:StandardLoopCharacteristics"}}]},kp.prototype._getDataObjectIsCollection=function(e){var t=this,n=this._translate;var i=e.businessObject.dataObjectRef,r=i.isCollection;return[{id:"toggle-is-collection",className:"bpmn-icon-parallel-mi-marker",title:n("Collection"),active:r,action:function(n,r){t._modeling.updateModdleProperties(e,i,{isCollection:!r.active})}}]},kp.prototype._getParticipantMultiplicity=function(e){var t=this,n=this._bpmnFactory,i=this._translate;var r=e.businessObject.participantMultiplicity;return[{id:"toggle-participant-multiplicity",className:"bpmn-icon-parallel-mi-marker",title:i("Participant Multiplicity"),active:!!r,action:function(i,r){var o;r.active||(o=n.create("bpmn:ParticipantMultiplicity")),t._modeling.updateProperties(e,{participantMultiplicity:o})}}]},kp.prototype._getAdHocEntry=function(e){var t=this._translate,n=Ar(kr(e),"bpmn:AdHocSubProcess"),i=this._bpmnReplace.replaceElement;return{id:"toggle-adhoc",className:"bpmn-icon-ad-hoc-marker",title:t("Ad-hoc"),active:n,action:function(t,r){return i(e,n?{type:"bpmn:SubProcess"}:{type:"bpmn:AdHocSubProcess"},{autoResize:!1,layoutConnection:!1})}}};var Mp={__depends__:[Hc,dp],__init__:["replaceMenuProvider"],replaceMenuProvider:["type",kp]},Dp=Math.max,Bp=Math.min;function Np(e,t){return{top:e.top-t.top,right:e.right-t.right,bottom:e.bottom-t.bottom,left:e.left-t.left}}function Op(e,t,n){var i=t[e],r=n.min&&n.min[e],o=n.max&&n.max[e];return d(r)&&(i=(/top|left/.test(e)?Bp:Dp)(i,r)),d(o)&&(i=(/top|left/.test(e)?Dp:Bp)(i,o)),i}function jp(e,t){return void 0!==e?e:20}function Lp(e){return!e.waypoints&&"label"!==e.type}function Ip(e,t){var n;if((n=void 0===e.length?g(e.children,Lp):e).length)return function(e,t){var n,i,r,o;return"object"==typeof t?(n=jp(t.left),i=jp(t.right),r=jp(t.top),o=jp(t.bottom)):n=i=r=o=jp(t),{x:e.x-n,y:e.y-r,width:e.width+n+i,height:e.height+r+o}}(pt(n),t)}var zp=Math.abs;var Fp=["bpmn:Participant","bpmn:Process","bpmn:SubProcess"],$p=30;function Hp(e,t){return t=t||[],e.children.filter((function(e){Ar(e,"bpmn:Lane")&&(Hp(e,t),t.push(e))})),t}function Gp(e){return e.children.filter((function(e){return Ar(e,"bpmn:Lane")}))}function Wp(e){return Ga(e,Fp)||e}function Vp(e,t){var n=Wp(e),i=Hp(n,Ar(n,"bpmn:Process")?[]:[n]),r=an(e),o=an(t),a=function(e,t){return Np(an(t),an(e))}(e,t),s=[];return i.forEach((function(t){if(t!==e){var n,i,c=0,p=a.right,l=0,u=a.left,h=an(t);a.top&&(zp(h.bottom-r.top)<10&&(l=o.top-h.bottom),zp(h.top-r.top)<5&&(c=o.top-h.top)),a.bottom&&(zp(h.top-r.bottom)<10&&(c=o.bottom-h.top),zp(h.bottom-r.bottom)<5&&(l=o.bottom-h.bottom)),(c||p||l||u)&&s.push({shape:t,newBounds:(n=t,i={top:c,right:p,bottom:l,left:u},{x:n.x+(i.left||0),y:n.y+(i.top||0),width:n.width-(i.left||0)+(i.right||0),height:n.height-(i.top||0)+(i.bottom||0)})})}})),s}function Up(e,t,n,i,r,o,a,s,c,p,l,u){e=e||{},i.registerProvider(this),this._contextPad=i,this._modeling=r,this._elementFactory=o,this._connect=a,this._create=s,this._popupMenu=c,this._canvas=p,this._rules=l,this._translate=u,!1!==e.autoPlace&&(this._autoPlace=t.get("autoPlace",!1)),n.on("create.end",250,(function(e){var t=e.context.shape;if(xo(e)&&i.isOpen(t)){var n=i.getEntries(t);n.replace&&n.replace.action.click(e,t)}}))}function qp(e,t,n){var i=e.$instanceOf(t),r=!1;return b(e.eventDefinitions||[],(function(e){e.$type===n&&(r=!0)})),i&&r}Up.$inject=["config.contextPad","injector","eventBus","contextPad","modeling","elementFactory","connect","create","popupMenu","canvas","rules","translate"],Up.prototype.getContextPadEntries=function(e){var t=this._contextPad,n=this._modeling,i=this._elementFactory,r=this._connect,o=this._create,a=this._popupMenu,s=this._canvas,c=this._rules,p=this._autoPlace,l=this._translate,h={};if("label"===e.type)return h;var d=e.businessObject;function f(e,t){r.start(e,t)}function m(e,t,n,r){function a(t,n){var a=i.createShape(F({type:e},r));o.start(t,a,{source:n})}return"string"!=typeof n&&(r=n,n=l("Append {type}",{type:e.replace(/^bpmn:/,"")})),{group:"model",className:t,title:n,action:{dragstart:a,click:p?function(t,n){var o=i.createShape(F({type:e},r));p.append(n,o)}:a}}}function v(e){return function(i,r){n.splitLane(r,e),t.open(r,!0)}}if(Ha(d,["bpmn:Lane","bpmn:Participant"])&&Mr(d)){var y=Gp(e);F(h,{"lane-insert-above":{group:"lane-insert-above",className:"bpmn-icon-lane-insert-above",title:l("Add Lane above"),action:{click:function(e,t){n.addLane(t,"top")}}}}),y.length<2&&(e.height>=120&&F(h,{"lane-divide-two":{group:"lane-divide",className:"bpmn-icon-lane-divide-two",title:l("Divide into two Lanes"),action:{click:v(2)}}}),e.height>=180&&F(h,{"lane-divide-three":{group:"lane-divide",className:"bpmn-icon-lane-divide-three",title:l("Divide into three Lanes"),action:{click:v(3)}}})),F(h,{"lane-insert-below":{group:"lane-insert-below",className:"bpmn-icon-lane-insert-below",title:l("Add Lane below"),action:{click:function(e,t){n.addLane(t,"bottom")}}}})}Ar(d,"bpmn:FlowNode")&&(Ar(d,"bpmn:EventBasedGateway")?F(h,{"append.receive-task":m("bpmn:ReceiveTask","bpmn-icon-receive-task",l("Append ReceiveTask")),"append.message-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-message",l("Append MessageIntermediateCatchEvent"),{eventDefinitionType:"bpmn:MessageEventDefinition"}),"append.timer-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-timer",l("Append TimerIntermediateCatchEvent"),{eventDefinitionType:"bpmn:TimerEventDefinition"}),"append.condition-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-condition",l("Append ConditionIntermediateCatchEvent"),{eventDefinitionType:"bpmn:ConditionalEventDefinition"}),"append.signal-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-signal",l("Append SignalIntermediateCatchEvent"),{eventDefinitionType:"bpmn:SignalEventDefinition"})}):qp(d,"bpmn:BoundaryEvent","bpmn:CompensateEventDefinition")?F(h,{"append.compensation-activity":m("bpmn:Task","bpmn-icon-task",l("Append compensation activity"),{isForCompensation:!0})}):Ar(d,"bpmn:EndEvent")||d.isForCompensation||qp(d,"bpmn:IntermediateThrowEvent","bpmn:LinkEventDefinition")||Dr(d)||F(h,{"append.end-event":m("bpmn:EndEvent","bpmn-icon-end-event-none",l("Append EndEvent")),"append.gateway":m("bpmn:ExclusiveGateway","bpmn-icon-gateway-none",l("Append Gateway")),"append.append-task":m("bpmn:Task","bpmn-icon-task",l("Append Task")),"append.intermediate-event":m("bpmn:IntermediateThrowEvent","bpmn-icon-intermediate-event-none",l("Append Intermediate/Boundary Event"))})),a.isEmpty(e,"bpmn-replace")||F(h,{replace:{group:"edit",className:"bpmn-icon-screw-wrench",title:l("Change type"),action:{click:function(e,n){var i=F(function(e){var n=s.getContainer(),i=t.getPad(e).html,r=n.getBoundingClientRect(),o=i.getBoundingClientRect(),a=o.top-r.top;return{x:o.left-r.left,y:a+o.height+5}}(n),{cursor:{x:e.x,y:e.y}});a.open(n,"bpmn-replace",i)}}}}),Ha(d,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference"])&&F(h,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation"),connect:{group:"connect",className:"bpmn-icon-connection-multi",title:l("Connect using "+(d.isForCompensation?"":"Sequence/MessageFlow or ")+"Association"),action:{click:f,dragstart:f}}}),Ar(d,"bpmn:TextAnnotation")&&F(h,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:l("Connect using Association"),action:{click:f,dragstart:f}}}),Ha(d,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&F(h,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:l("Connect using DataInputAssociation"),action:{click:f,dragstart:f}}}),Ar(d,"bpmn:Group")&&F(h,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation")});var g=c.allowed("elements.delete",{elements:[e]});return u(g)&&(g=g[0]===e),g&&F(h,{delete:{group:"edit",className:"bpmn-icon-trash",title:l("Remove"),action:{click:function(t){n.removeElements([e])}}}}),h};var Kp={__depends__:[xc,wc,No,uc,Ic,Mp],__init__:["contextPadProvider"],contextPadProvider:["type",Up]},Yp={horizontal:["x","width"],vertical:["y","height"]};function Xp(e){this._modeling=e,this._filters=[],this.registerFilter((function(e,t,n){var i,r=0,o=0;return b(e,(function(e){e.waypoints||e.labelTarget||(r+=e[n],o+=1)})),i=Math.round(r/o),g(e,(function(e){return e[n]<i+50}))}))}Xp.$inject=["modeling"],Xp.prototype.registerFilter=function(e){if("function"!=typeof e)throw new Error("the filter has to be a function");this._filters.push(e)},Xp.prototype.trigger=function(e,t){var n,i,r=this._modeling;if(!(e.length<3||(this._setOrientation(t),i=this._filterElements(e),(n=this._createGroups(i)).length<=2)))return r.distributeElements(n,this._axis,this._dimension),n},Xp.prototype._filterElements=function(e){var t=this._filters,n=this._axis,i=this._dimension,r=[].concat(e);return t.length?(b(t,(function(e){r=e(r,n,i)})),r):e},Xp.prototype._createGroups=function(e){var t=[],n=this,i=this._axis,r=this._dimension;if(!i)throw new Error('must have a defined "axis" and "dimension"');return b(M(e,i),(function(e,o){var a,s=n._findRange(e,i,r),c=t[t.length-1];c&&n._hasIntersection(c.range,s)?t[t.length-1].elements.push(e):(a={range:s,elements:[e]},t.push(a))})),t},Xp.prototype._setOrientation=function(e){var t=Yp[e];this._axis=t[0],this._dimension=t[1]},Xp.prototype._hasIntersection=function(e,t){return Math.max(e.min,e.max)>=Math.min(t.min,t.max)&&Math.min(e.min,e.max)<=Math.max(t.min,t.max)},Xp.prototype._findRange=function(e){var t=e[this._axis];return{min:t+5,max:t+e[this._dimension]-5}};var Zp={__init__:["distributeElements"],distributeElements:["type",Xp]};function Qp(e){e.registerFilter((function(e){return g(e,(function(e){var t=Ha(e,["bpmn:Association","bpmn:BoundaryEvent","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:Lane","bpmn:MessageFlow","bpmn:Participant","bpmn:SequenceFlow","bpmn:TextAnnotation"]);return!(e.labelTarget||t)}))}))}Qp.$inject=["distributeElements"];var Jp={__depends__:[Zp],__init__:["bpmnDistributeElements"],bpmnDistributeElements:["type",Qp]},el="is not a registered action";function tl(e,t){this._actions={};var n=this;e.on("diagram.init",(function(){n._registerDefaultActions(t),e.fire("editorActions.init",{editorActions:n})}))}function nl(e,t){return new Error(e+" "+t)}tl.$inject=["eventBus","injector"],tl.prototype._registerDefaultActions=function(e){var t=e.get("commandStack",!1),n=e.get("modeling",!1),i=e.get("selection",!1),r=e.get("zoomScroll",!1),o=e.get("copyPaste",!1),a=e.get("canvas",!1),s=e.get("rules",!1),c=e.get("keyboardMove",!1),p=e.get("keyboardMoveSelection",!1);t&&(this.register("undo",(function(){t.undo()})),this.register("redo",(function(){t.redo()}))),o&&i&&this.register("copy",(function(){var e=i.get();o.copy(e)})),o&&this.register("paste",(function(){o.paste()})),r&&this.register("stepZoom",(function(e){r.stepZoom(e.value)})),a&&this.register("zoom",(function(e){a.zoom(e.value)})),n&&i&&s&&this.register("removeSelection",(function(){var e=i.get();if(e.length){var t,r=s.allowed("elements.delete",{elements:e});!1!==r&&(t=u(r)?r:e).length&&n.removeElements(t.slice())}})),c&&this.register("moveCanvas",(function(e){c.moveCanvas(e)})),p&&this.register("moveSelection",(function(e){p.moveSelection(e.direction,e.accelerated)}))},tl.prototype.trigger=function(e,t){if(!this._actions[e])throw nl(e,el);return this._actions[e](t)},tl.prototype.register=function(e,t){var n=this;if("string"==typeof e)return this._registerAction(e,t);b(e,(function(e,t){n._registerAction(t,e)}))},tl.prototype._registerAction=function(e,t){if(this.isRegistered(e))throw nl(e,"is already registered");this._actions[e]=t},tl.prototype.unregister=function(e){if(!this.isRegistered(e))throw nl(e,el);this._actions[e]=void 0},tl.prototype.getActions=function(){return Object.keys(this._actions)},tl.prototype.isRegistered=function(e){return!!this._actions[e]};var il={__init__:["editorActions"],editorActions:["type",tl]};function rl(e){e.invoke(tl,this)}n(rl,tl),rl.$inject=["injector"],rl.prototype._registerDefaultActions=function(e){tl.prototype._registerDefaultActions.call(this,e);var t=e.get("canvas",!1),n=e.get("elementRegistry",!1),i=e.get("selection",!1),r=e.get("spaceTool",!1),o=e.get("lassoTool",!1),a=e.get("handTool",!1),s=e.get("globalConnect",!1),c=e.get("distributeElements",!1),p=e.get("alignElements",!1),l=e.get("directEditing",!1),u=e.get("searchPad",!1),h=e.get("modeling",!1);t&&n&&i&&this._registerAction("selectElements",(function(){var e=t.getRootElement(),r=n.filter((function(t){return t!==e}));return i.select(r),r})),r&&this._registerAction("spaceTool",(function(){r.toggle()})),o&&this._registerAction("lassoTool",(function(){o.toggle()})),a&&this._registerAction("handTool",(function(){a.toggle()})),s&&this._registerAction("globalConnectTool",(function(){s.toggle()})),i&&c&&this._registerAction("distributeElements",(function(e){var t=i.get(),n=e.type;t.length&&c.trigger(t,n)})),i&&p&&this._registerAction("alignElements",(function(e){var t=i.get(),n=[],r=e.type;t.length&&(n=g(t,(function(e){return!Ar(e,"bpmn:Lane")})),p.trigger(n,r))})),i&&h&&this._registerAction("setColor",(function(e){var t=i.get();t.length&&h.setColor(t,e)})),i&&l&&this._registerAction("directEditing",(function(){var e=i.get();e.length&&l.activate(e[0])})),u&&this._registerAction("find",(function(){u.toggle()})),t&&h&&this._registerAction("moveToOrigin",(function(){var e,i,r=t.getRootElement();e=pt(i=Ar(r,"bpmn:Collaboration")?n.filter((function(e){return Ar(e.parent,"bpmn:Collaboration")})):n.filter((function(e){return e!==r&&!Ar(e.parent,"bpmn:SubProcess")}))),h.moveElements(i,{x:-e.x,y:-e.y},r)}))};var ol={__depends__:[il],editorActions:["type",rl]};function al(e){e.on(["create.init","shape.move.init"],(function(e){var t=e.context;Ha(e.shape,["bpmn:Participant","bpmn:SubProcess","bpmn:TextAnnotation"])&&(t.gridSnappingContext||(t.gridSnappingContext={}),t.gridSnappingContext.snapLocation="top-left")}))}al.$inject=["eventBus"];function sl(e,t,n){return n||(n="round"),Math[n](e/t)*t}function cl(e,t,n){var i=!n||!1!==n.active;this._eventBus=t;var r=this;t.on("diagram.init",800,(function(){r.setActive(i)})),t.on(["create.move","create.end","bendpoint.move.move","bendpoint.move.end","connect.move","connect.end","connectionSegment.move.move","connectionSegment.move.end","resize.move","resize.end","shape.move.move","shape.move.end"],1200,(function(t){var n=t.originalEvent;if(!(!r.active||n&&Go(n))){var i=t.context,o=i.gridSnappingContext;o||(o=i.gridSnappingContext={}),["x","y"].forEach((function(n){var i={},o=function(e,t,n){var i=e.context,r=e.shape,o=i.gridSnappingContext,a=o.snapLocation,s=o.snapOffset;if(s&&d(s[t]))return s[t];s||(s=o.snapOffset={});d(s[t])||(s[t]=0);if(!r)return s[t];n.get(r.id)||(pl(t)?s[t]+=r[t]+r.width/2:s[t]+=r[t]+r.height/2);if(!a)return s[t];"x"===t?/left/.test(a)?s[t]-=r.width/2:/right/.test(a)&&(s[t]+=r.width/2):/top/.test(a)?s[t]-=r.height/2:/bottom/.test(a)&&(s[t]+=r.height/2);return s[t]}(t,n,e);o&&(i.offset=o);var a=function(e,t){var n=e.context,i=n.createConstraints,r=n.resizeConstraints||{},o=n.gridSnappingContext,a=o.snapConstraints;if(a&&a[t])return a[t];a||(a=o.snapConstraints={});a[t]||(a[t]={});var s=n.direction;i&&(pl(t)?(a.x.min=i.left,a.x.max=i.right):(a.y.min=i.top,a.y.max=i.bottom));var c=r.min,p=r.max;c&&(pl(t)?ul(s)?a.x.max=c.left:a.x.min=c.right:ll(s)?a.y.max=c.top:a.y.min=c.bottom);p&&(pl(t)?ul(s)?a.x.min=p.left:a.x.max=p.right:ll(s)?a.y.min=p.top:a.y.max=p.bottom);return a[t]}(t,n);a&&F(i,a),Js(t,n)||r.snapEvent(t,n,i)}))}}))}function pl(e){return"x"===e}function ll(e){return-1!==e.indexOf("n")}function ul(e){return-1!==e.indexOf("w")}function hl(e,t){Ka.call(this,e),this._gridSnapping=t;var n=this;this.preExecute("shape.resize",(function(e){var t=e.context,i=(t.hints||{}).autoResize;if(i){var r=t.shape,o=t.newBounds;m(i)?t.newBounds=n.snapComplex(o,i):t.newBounds=n.snapSimple(r,o)}}))}cl.prototype.snapEvent=function(e,t,n){ec(e,t,this.snapValue(e[t],n))},cl.prototype.getGridSpacing=function(){return 10},cl.prototype.snapValue=function(e,t){var n,i,r=0;return t&&t.offset&&(r=t.offset),e=sl(e+=r,10),t&&t.min&&d(n=t.min)&&(n=sl(n+r,10,"ceil"),e=Math.max(e,n)),t&&t.max&&d(i=t.max)&&(i=sl(i+r,10,"floor"),e=Math.min(e,i)),e-=r},cl.prototype.isActive=function(){return this.active},cl.prototype.setActive=function(e){this.active=e,this._eventBus.fire("gridSnapping.toggle",{active:e})},cl.prototype.toggleActive=function(){this.setActive(!this.active)},cl.$inject=["elementRegistry","eventBus","config.gridSnapping"],hl.$inject=["eventBus","gridSnapping","modeling"],n(hl,Ka),hl.prototype.snapSimple=function(e,t){var n=this._gridSnapping;return t.width=n.snapValue(t.width,{min:t.width}),t.height=n.snapValue(t.height,{min:t.height}),t.x=e.x+e.width/2-t.width/2,t.y=e.y+e.height/2-t.height/2,t},hl.prototype.snapComplex=function(e,t){return/w|e/.test(t)&&(e=this.snapHorizontally(e,t)),/n|s/.test(t)&&(e=this.snapVertically(e,t)),e},hl.prototype.snapHorizontally=function(e,t){var n=this._gridSnapping,i=/w/.test(t),r=/e/.test(t),o={};return o.width=n.snapValue(e.width,{min:e.width}),r&&(i?(o.x=n.snapValue(e.x,{max:e.x}),o.width+=n.snapValue(e.x-o.x,{min:e.x-o.x})):e.x=e.x+e.width-o.width),F(e,o),e},hl.prototype.snapVertically=function(e,t){var n=this._gridSnapping,i=/n/.test(t),r=/s/.test(t),o={};return o.height=n.snapValue(e.height,{min:e.height}),i&&(r?(o.y=n.snapValue(e.y,{max:e.y}),o.height+=n.snapValue(e.y-o.y,{min:e.y-o.y})):e.y=e.y+e.height-o.height),F(e,o),e};function dl(e,t){e.on(["spaceTool.move","spaceTool.end"],2e3,(function(e){var n,i=e.context;i.initialized&&("x"===i.axis?(n=t.snapValue(e.dx),e.x=e.x+n-e.dx,e.dx=n):(n=t.snapValue(e.dy),e.y=e.y+n-e.dy,e.dy=n))}))}dl.$inject=["eventBus","gridSnapping"];var fl={__depends__:[{__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",hl],gridSnappingSpaceToolBehavior:["type",dl]}],__init__:["gridSnapping"],gridSnapping:["type",cl]};function ml(e,t){e.on("autoPlace",2e3,(function(e){var n=e.source,i=cn(n),r=e.shape,o=Wa(n,r);return["x","y"].forEach((function(e){var n={};o[e]!==i[e]&&(o[e]>i[e]?n.min=o[e]:n.max=o[e],Ar(r,"bpmn:TextAnnotation")&&(!function(e){return"x"===e}(e)?n.offset=-r.height/2:n.offset=-r.width/2),o[e]=t.snapValue(o[e],n))})),o}))}ml.$inject=["eventBus","gridSnapping"];function vl(e,t,n){t.on(["create.start","shape.move.start"],1750,(function(t){var i=t.context,r=i.shape,o=e.getRootElement();Ar(r,"bpmn:Participant")&&Ar(o,"bpmn:Process")&&o.children.length&&(i.createConstraints&&(r.width=n.snapValue(r.width,{min:r.width}),r.height=n.snapValue(r.height,{min:r.height})))}))}vl.$inject=["canvas","eventBus","gridSnapping"];function yl(e,t,n){Ka.call(this,e),this._gridSnapping=t;var i=this;this.postExecuted(["connection.create","connection.layout"],3e3,(function(e){var t=e.context,r=t.connection,o=t.hints||{},a=r.waypoints;o.connectionStart||o.connectionEnd||!1===o.createElementsBehavior||function(e){return e.length>3}(a)&&n.updateWaypoints(r,i.snapMiddleSegments(a))}))}function gl(e,t,n){var i=xt(t,n),r={};return function(e){return"h"===e}(i)&&(r.y=e.snapValue(t.y)),function(e){return"v"===e}(i)&&(r.x=e.snapValue(t.x)),("x"in r||"y"in r)&&(t=F({},t,r),n=F({},n,r)),[t,n]}yl.$inject=["eventBus","gridSnapping","modeling"],n(yl,Ka),yl.prototype.snapMiddleSegments=function(e){var t,n=this._gridSnapping;e=e.slice();for(var i=1;i<e.length-2;i++)t=gl(n,e[i],e[i+1]),e[i]=t[0],e[i+1]=t[1];return e};var bl={__depends__:[fl,{__init__:["gridSnappingAutoPlaceBehavior","gridSnappingCreateParticipantBehavior","gridSnappingLayoutConnectionBehavior"],gridSnappingAutoPlaceBehavior:["type",ml],gridSnappingCreateParticipantBehavior:["type",vl],gridSnappingLayoutConnectionBehavior:["type",yl]}],__init__:["bpmnGridSnapping"],bpmnGridSnapping:["type",al]};function xl(e,t){this._interactionEvents=t;var n=this;e.on(["interactionEvents.createHit","interactionEvents.updateHit"],(function(e){var t=e.element,i=e.gfx;return Ar(t,"bpmn:Lane")?n.createParticipantHit(t,i):Ar(t,"bpmn:Participant")?Mr(t)?n.createParticipantHit(t,i):n.createDefaultHit(t,i):Ar(t,"bpmn:SubProcess")?Mr(t)?n.createSubProcessHit(t,i):n.createDefaultHit(t,i):void 0}))}xl.$inject=["eventBus","interactionEvents"],xl.prototype.createDefaultHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createDefaultHit(e,t),!0},xl.prototype.createParticipantHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"all",{width:30,height:e.height}),!0},xl.prototype.createSubProcessHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"all",{width:e.width,height:30}),!0};var _l={__init__:["bpmnInteractionEvents"],bpmnInteractionEvents:["type",xl]};function El(e){e.invoke(Jo,this)}n(El,Jo),El.$inject=["injector"],El.prototype.registerBindings=function(e,t){function n(n,i){t.isRegistered(n)&&e.addListener(i)}Jo.prototype.registerBindings.call(this,e,t),n("selectElements",(function(n){var i=n.keyEvent;if(e.isKey(["a","A"],i)&&e.isCmd(i))return t.trigger("selectElements"),!0})),n("find",(function(n){var i=n.keyEvent;if(e.isKey(["f","F"],i)&&e.isCmd(i))return t.trigger("find"),!0})),n("spaceTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["s","S"],i)?(t.trigger("spaceTool"),!0):void 0})),n("lassoTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["l","L"],i)?(t.trigger("lassoTool"),!0):void 0})),n("handTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["h","H"],i)?(t.trigger("handTool"),!0):void 0})),n("globalConnectTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["c","C"],i)?(t.trigger("globalConnectTool"),!0):void 0})),n("directEditing",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["e","E"],i)?(t.trigger("directEditing"),!0):void 0}))};var wl={__depends__:[ea],__init__:["keyboardBindings"],keyboardBindings:["type",El]},Sl={moveSpeed:1,moveSpeedAccelerated:10},Cl="left",Tl="right",Rl="down",Pl={ArrowLeft:Cl,Left:Cl,ArrowUp:"up",Up:"up",ArrowRight:Tl,Right:Tl,ArrowDown:Rl,Down:Rl},Al={left:function(e){return{x:-e,y:0}},up:function(e){return{x:0,y:-e}},right:function(e){return{x:e,y:0}},down:function(e){return{x:0,y:e}}};function kl(e,t,n,i,r){var o=this;this._config=F({},Sl,e||{}),t.addListener(1500,(function(e){var n=e.keyEvent,i=Pl[n.key];if(i&&!t.isCmd(n)){var r=t.isShift(n);return o.moveSelection(i,r),!0}})),this.moveSelection=function(e,t){var o=r.get();if(o.length){var a=this._config[t?"moveSpeedAccelerated":"moveSpeed"],s=Al[e](a);i.allowed("elements.move",{shapes:o})&&n.moveElements(o,s)}}}kl.$inject=["config.keyboardMoveSelection","keyboard","modeling","rules","selection"];var Ml={__depends__:[ea,No],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",kl]};function Dl(e,t,n,i){e.on("element.changed",(function(i){var r=i.element;(r.parent||r===t.getRootElement())&&(i.gfx=n.getGraphics(r)),i.gfx&&e.fire(lt(r)+".changed",i)})),e.on("elements.changed",(function(t){var n=t.elements;n.forEach((function(t){e.fire("element.changed",{element:t})})),i.updateContainments(n)})),e.on("shape.changed",(function(e){i.update("shape",e.element,e.gfx)})),e.on("connection.changed",(function(e){i.update("connection",e.element,e.gfx)}))}Dl.$inject=["eventBus","canvas","elementRegistry","graphicsFactory"];var Bl={__init__:["changeSupport"],changeSupport:["type",Dl]};function Nl(e,t,n,i){this._dragging=i,this._rules=t;var r=this;function o(e,t){var n,i=e.shape,o=e.direction,a=e.resizeConstraints;e.delta=t,n=function(e,t,n){var i=n.x,r=n.y,o={x:e.x,y:e.y,width:e.width,height:e.height};return-1!==t.indexOf("n")?(o.y=e.y+r,o.height=e.height-r):-1!==t.indexOf("s")&&(o.height=e.height+r),-1!==t.indexOf("e")?o.width=e.width+i:-1!==t.indexOf("w")&&(o.x=e.x+i,o.width=e.width-i),o}(i,o,t),e.newBounds=function(e,t){if(!t)return e;var n=an(e);return sn({top:Op("top",n,t),right:Op("right",n,t),bottom:Op("bottom",n,t),left:Op("left",n,t)})}(n,a),e.canExecute=r.canResize(e)}e.on("resize.start",(function(e){var t,n,i;t=e.context,n=t.resizeConstraints,i=t.minBounds,void 0===n&&(void 0===i&&(i=r.computeMinResizeBox(t)),t.resizeConstraints={min:an(i)})})),e.on("resize.move",(function(e){var t={x:e.dx,y:e.dy};o(e.context,t)})),e.on("resize.end",(function(e){!function(e){var t=e.shape,i=e.canExecute,r=e.newBounds;if(i){if(!function(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}(t,r=rn(r)))return;n.resizeShape(t,r)}}(e.context)}))}function Ol(e,t){var n=cn(e),i=an(e),r={x:n.x,y:n.y};return-1!==t.indexOf("n")?r.y=i.top:-1!==t.indexOf("s")&&(r.y=i.bottom),-1!==t.indexOf("e")?r.x=i.right:-1!==t.indexOf("w")&&(r.x=i.left),r}function jl(e){return"n"===e||"s"===e?"resize-ns":"e"===e||"w"===e?"resize-ew":"nw"===e||"se"===e?"resize-nwse":"resize-nesw"}Nl.prototype.canResize=function(e){var t=this._rules,n=$(e,["newBounds","shape","delta","direction"]);return t.allowed("shape.resize",n)},Nl.prototype.activate=function(e,t,n){var i,r,o=this._dragging;if("string"==typeof n&&(n={direction:n}),!(r=(i=F({shape:t},n)).direction))throw new Error("must provide a direction (n|w|s|e|nw|se|ne|sw)");o.init(e,Ol(t,r),"resize",{autoActivate:!0,cursor:jl(r),data:{shape:t,context:i}})},Nl.prototype.computeMinResizeBox=function(e){var t=e.shape;return function(e,t,n,i){var r=an(t),o={top:/n/.test(e)?r.bottom-n.height:r.top,left:/w/.test(e)?r.right-n.width:r.left,bottom:/s/.test(e)?r.top+n.height:r.bottom,right:/e/.test(e)?r.left+n.width:r.right},a=i?an(i):o;return sn({top:Bp(o.top,a.top),left:Bp(o.left,a.left),bottom:Dp(o.bottom,a.bottom),right:Dp(o.right,a.right)})}(e.direction,t,e.minDimensions||{width:10,height:10},Ip(t,e.childrenBoxPadding))},Nl.$inject=["eventBus","rules","modeling","dragging"];var Ll="djs-resizing",Il="resize-not-ok";function zl(e,t,n){e.on("resize.move",500,(function(e){var i,r,o,a;i=e.context,r=i.shape,o=i.newBounds,(a=i.frame)||(a=i.frame=n.addFrame(r,t.getActiveLayer()),t.addMarker(r,Ll)),o.width>5&&ge(a,{x:o.x,width:o.width}),o.height>5&&ge(a,{y:o.y,height:o.height}),i.canExecute?we(a).remove(Il):we(a).add(Il)})),e.on("resize.cleanup",(function(e){var n,i;n=e.context,i=n.shape,n.frame&&Ce(n.frame),t.removeMarker(i,Ll)}))}zl.$inject=["eventBus","canvas","previewSupport"];var Fl=-6,$l="djs-resizer",Hl=["n","w","s","e","nw","ne","se","sw"];function Gl(e,t,n,i){this._resize=i,this._canvas=t;var r=this;e.on("selection.changed",(function(e){var t=e.newSelection;r.removeResizers(),1===t.length&&b(t,I(r.addResizer,r))})),e.on("shape.changed",(function(e){var t=e.element;n.isSelected(t)&&(r.removeResizers(),r.addResizer(t))}))}Gl.prototype.makeDraggable=function(e,t,n){var i=this._resize;function r(t){bo(t)&&i.activate(t,e,n)}re.bind(t,"mousedown",r),re.bind(t,"touchstart",r)},Gl.prototype._createResizer=function(e,t,n,i){var r=this._getResizersParent(),o=function(e){var t={x:0,y:0};-1!==e.indexOf("e")?t.x=6:-1!==e.indexOf("w")&&(t.x=Fl);-1!==e.indexOf("s")?t.y=6:-1!==e.indexOf("n")&&(t.y=Fl);return t}(i),a=Me("g");we(a).add($l),we(a).add("djs-resizer-"+e.id),we(a).add("djs-resizer-"+i),me(r,a);var s=Me("rect");ge(s,{x:-2+o.x,y:-2+o.y,width:4,height:4}),we(s).add("djs-resizer-visual"),me(a,s);var c=Me("rect");return ge(c,{x:-10+o.x,y:-10+o.y,width:20,height:20}),we(c).add("djs-resizer-hit"),me(a,c),Wn(a,t,n),a},Gl.prototype.createResizer=function(e,t){var n=Ol(e,t),i=this._createResizer(e,n.x,n.y,t);this.makeDraggable(e,i,t)},Gl.prototype.addResizer=function(e){var t=this;this._resize.canResize({shape:e})&&b(Hl,(function(n){t.createResizer(e,n)}))},Gl.prototype.removeResizers=function(){Te(this._getResizersParent())},Gl.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")},Gl.$inject=["eventBus","canvas","selection","resize"];var Wl={__depends__:[hs,ss,Rc],__init__:["resize","resizePreview","resizeHandles"],resize:["type",Nl],resizePreview:["type",zl],resizeHandles:["type",Gl]};function Vl(e,t){var n=t.create("bpmn:CategoryValue"),i=t.create("bpmn:Category",{categoryValue:[n]});return vt(e.get("rootElements"),i),kr(i).$parent=e,kr(n).$parent=i,n}function Ul(e,t,n,i,r,o,a){function s(e,t){(t||Ha(e,["bpmn:Task","bpmn:TextAnnotation"])||ql(e))&&i.activate(e)}this._bpmnFactory=t,this._canvas=n,this._modeling=r,this._textRenderer=a,i.registerProvider(this),e.on("element.dblclick",(function(e){s(e.element,!0)})),e.on(["autoPlace.start","canvas.viewbox.changing","drag.init","element.mousedown","popupMenu.open"],(function(e){i.isActive()&&i.complete()})),e.on(["commandStack.changed"],(function(e){i.isActive()&&i.cancel()})),e.on("directEditing.activate",(function(e){o.removeResizers()})),e.on("create.end",500,(function(e){var t=e.context,n=t.shape,i=e.context.canExecute;e.isTouch||i&&(t.hints&&!1===t.hints.createElementsBehavior||s(n))})),e.on("autoPlace.end",500,(function(e){s(e.shape)}))}function ql(e){return Ar(e,"bpmn:SubProcess")&&!Mr(e)}Ul.$inject=["eventBus","bpmnFactory","canvas","directEditing","modeling","resizeHandles","textRenderer"],Ul.prototype.activate=function(e){var t=Or(e);if(void 0!==t){var n={text:t};F(n,this.getEditingBBox(e));var i={};return(Ha(e,["bpmn:Task","bpmn:Participant","bpmn:Lane","bpmn:CallActivity"])||ql(e))&&F(i,{centerVertically:!0}),io(e)&&F(i,{autoResize:!0}),Ar(e,"bpmn:TextAnnotation")&&F(i,{resizable:!0,autoResize:!0}),F(n,{options:i}),n}},Ul.prototype.getEditingBBox=function(e){var t=this._canvas,n=e.label||e,i=t.getAbsoluteBBox(n),r=i.x+i.width/2,o=i.y+i.height/2,a={x:i.x,y:i.y},s=t.zoom(),c=this._textRenderer.getDefaultStyle(),p=this._textRenderer.getExternalStyle(),l=p.fontSize*s,u=p.lineHeight,h=c.fontSize*s,d=c.lineHeight,f={fontFamily:this._textRenderer.getDefaultStyle().fontFamily,fontWeight:this._textRenderer.getDefaultStyle().fontWeight};(Ar(e,"bpmn:Lane")||function(e){return Ar(e,"bpmn:Participant")&&Mr(e)}(e))&&(F(a,{width:i.height,height:30*s,x:i.x-i.height/2+15*s,y:o-30*s/2}),F(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px",transform:"rotate(-90deg)"})),(Ha(e,["bpmn:Task","bpmn:CallActivity"])||function(e){return Ar(e,"bpmn:Participant")&&!Mr(e)}(e)||ql(e))&&(F(a,{width:i.width,height:i.height}),F(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px"})),function(e){return Ar(e,"bpmn:SubProcess")&&Mr(e)}(e)&&(F(a,{width:i.width,x:i.x}),F(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px"}));var m=90*s,v=7*s,y=4*s;if(n.labelTarget&&(F(a,{width:m,height:i.height+v+y,x:r-m/2,y:i.y-v}),F(f,{fontSize:l+"px",lineHeight:u,paddingTop:v+"px",paddingBottom:y+"px"})),io(n)&&!ro(n)&&!so(n)){var g=ao(e),b=t.getAbsoluteBBox({x:g.x,y:g.y,width:0,height:0}),x=l+v+y;F(a,{width:m,height:x,x:b.x-m/2,y:b.y-x/2}),F(f,{fontSize:l+"px",lineHeight:u,paddingTop:v+"px",paddingBottom:y+"px"})}return Ar(e,"bpmn:TextAnnotation")&&(F(a,{width:i.width,height:i.height,minWidth:30*s,minHeight:10*s}),F(f,{textAlign:"left",paddingTop:5*s+"px",paddingBottom:7*s+"px",paddingLeft:7*s+"px",paddingRight:5*s+"px",fontSize:h+"px",lineHeight:d})),{bounds:a,style:f}},Ul.prototype.update=function(e,t,n,i){var r,o,a;if((Ar(e,"bpmn:TextAnnotation")&&(o=this._canvas.getAbsoluteBBox(e),r={x:e.x,y:e.y,width:e.width/o.width*i.width,height:e.height/o.height*i.height}),Ar(e,"bpmn:Group"))&&!kr(e).categoryValueRef){var s=Vl(kr(this._canvas.getRootElement()).$parent,this._bpmnFactory);kr(e).categoryValueRef=s}(a=t)&&a.trim()||(t=null),this._modeling.updateLabel(e,t,r)};var Kl="djs-element-hidden",Yl="djs-label-hidden";function Xl(e,t,n,i){var r,o,a,s=this,c=t.getDefaultLayer();e.on("directEditing.activate",(function(e){var n=e.active;if(Ar(r=n.element.label||n.element,"bpmn:TextAnnotation")){o=t.getAbsoluteBBox(r),a=Me("g");var p=i.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:r.width,containerHeight:r.height,position:{mx:0,my:0}}),l=s.path=Me("path");ge(l,{d:p,strokeWidth:2,stroke:Zl(r)}),me(a,l),me(c,a),Vn(a,r.x,r.y)}Ar(r,"bpmn:TextAnnotation")||r.labelTarget?t.addMarker(r,Kl):(Ar(r,"bpmn:Task")||Ar(r,"bpmn:CallActivity")||Ar(r,"bpmn:SubProcess")||Ar(r,"bpmn:Participant"))&&t.addMarker(r,Yl)})),e.on("directEditing.resize",(function(e){if(Ar(r,"bpmn:TextAnnotation")){var t=e.height,n=e.dy,a=Math.max(r.height/o.height*(t+n),0),c=i.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:r.width,containerHeight:a,position:{mx:0,my:0}});ge(s.path,{d:c})}})),e.on(["directEditing.complete","directEditing.cancel"],(function(e){var n=e.active;n&&(t.removeMarker(n.element.label||n.element,Kl),t.removeMarker(r,Yl)),r=void 0,o=void 0,a&&(Ce(a),a=void 0)}))}function Zl(e,t){return kr(e).di.get("stroke")||t||"black"}Xl.$inject=["eventBus","canvas","elementRegistry","pathMap"];var Ql={__depends__:[Bl,Wl,xc],__init__:["labelEditingProvider","labelEditingPreview"],labelEditingProvider:["type",Ul],labelEditingPreview:["type",Xl]},Jl=["top","bottom","left","right"],eu=10;function tu(e,t){function n(e){if(ro(e)){var n=function(e){var t=cn(e.label),n=nu(cn(e),t);if(i=n,-1===Jl.indexOf(i))return;var i;var r=function(e){var t=cn(e);return[].concat(e.incoming.map((function(e){return e.waypoints[e.waypoints.length-2]})),e.outgoing.map((function(e){return e.waypoints[1]}))).map((function(e){return nu(t,e)}))}(e);if(e.host){var o=function(e){var t,n=e.host,i=pn(cn(e),n);t=i.indexOf("-")>=0?i.split("-"):[i];return Jl.filter((function(e){return-1===t.indexOf(e)}))}(e);r=r.concat(o)}var a=Jl.filter((function(e){return-1===r.indexOf(e)}));if(-1!==a.indexOf(n))return;return a[0]}(e);n&&function(e,n){var i=cn(e),r=e.label,o=cn(r);if(!r.parent)return;var a,s=an(e);switch(n){case"top":a={x:i.x,y:s.top-eu-r.height/2};break;case"left":a={x:s.left-eu-r.width/2,y:i.y};break;case"bottom":a={x:i.x,y:s.bottom+eu+r.height/2};break;case"right":a={x:s.right+eu+r.width/2,y:i.y}}var c=pa(a,o);t.moveShape(r,c)}(e,n)}}Ka.call(this,e),this.postExecuted(["connection.create","connection.layout","connection.updateWaypoints"],(function(e){var t=e.context,i=t.connection,r=i.source,o=i.target;!1!==(t.hints||{}).createElementsBehavior&&(n(r),n(o))})),this.postExecuted(["label.create"],(function(e){var t=e.context,i=t.shape;!1!==(t.hints||{}).createElementsBehavior&&n(i.labelTarget)})),this.postExecuted(["elements.create"],(function(e){var t=e.context,i=t.elements;!1!==(t.hints||{}).createElementsBehavior&&i.forEach((function(e){n(e)}))}))}function nu(e,t){return pn(t,e,5)}function iu(e,t,n){Ka.call(this,e),this.preExecute("shape.append",(function(e){var t=e.source,n=e.shape;e.position||(Ar(n,"bpmn:TextAnnotation")?e.position={x:t.x+t.width/2+75,y:t.y-50-n.height/2}:e.position={x:t.x+t.width+80+n.width/2,y:t.y+t.height/2})}),!0)}function ru(e,t){e.invoke(Ka,this),this.postExecute("shape.move",(function(e){var n=e.newParent,i=e.shape;b(g(i.incoming.concat(i.outgoing),(function(e){return Ar(e,"bpmn:Association")})),(function(e){t.moveConnection(e,{x:0,y:0},n)}))}),!0)}n(tu,Ka),tu.$inject=["eventBus","modeling"],n(iu,Ka),iu.$inject=["eventBus","elementFactory","bpmnRules"],n(ru,Ka),ru.$inject=["injector","modeling"];function ou(e,t){t.invoke(Ka,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",500,(function(e){var t=e.elements;1===(t=t.filter((function(e){return au(e,e.host)}))).length&&t.map((function(e){return t.indexOf(e)})).forEach((function(i){var r=t[i];e.elements[i]=n.replaceShape(t[i],r)}))}),!0),this.preExecute("elements.move",500,(function(e){var t=e.shapes,i=e.newHost;if(1===t.length){var r=t[0];au(r,i)&&(e.shapes=[n.replaceShape(r,i)])}}),!0)}function au(e,t){return!so(e)&&Ha(e,["bpmn:IntermediateThrowEvent","bpmn:IntermediateCatchEvent"])&&!!t}ou.$inject=["bpmnReplace","injector"],n(ou,Ka),ou.prototype.replaceShape=function(e,t){var n,i=(n=kr(e).eventDefinitions)&&n[0],r={type:"bpmn:BoundaryEvent",host:t};return i&&(r.eventDefinitionType=i.$type),this._bpmnReplace.replaceElement(e,r,{layoutConnection:!1})};function su(e,t,n){function i(e){return g(e.attachers,(function(e){return Ar(e,"bpmn:BoundaryEvent")}))}Ka.call(this,e),this.postExecute("connection.create",(function(e){var t=e.context.source,r=e.context.target,o=i(r);Ar(t,"bpmn:EventBasedGateway")&&Ar(r,"bpmn:ReceiveTask")&&o.length>0&&n.removeElements(o)})),this.postExecute("connection.reconnect",(function(e){var t=e.context.oldSource,r=e.context.newSource;Ar(t,"bpmn:Gateway")&&Ar(r,"bpmn:EventBasedGateway")&&b(r.outgoing,(function(e){var t=e.target,r=i(t);Ar(t,"bpmn:ReceiveTask")&&r.length>0&&n.removeElements(r)}))})),e.on("moddleCopy.canCopyProperty",2e3,(function(e){var n=e.parent,i=e.property,r=e.propertyName,o=t.getPropertyDescriptor(n,r);o&&o.isReference&&Ar(i,"bpmn:RootElement")&&n.set(r,i)}))}su.$inject=["eventBus","moddle","modeling"],n(su,Ka);function cu(e,t,n,i,r){function o(e){return Ha(e,["bpmn:ReceiveTask","bpmn:SendTask"])||function(e,t){u(t)||(t=[t]);return w(t,(function(t){return Br(e,t)}))}(e,["bpmn:ErrorEventDefinition","bpmn:EscalationEventDefinition","bpmn:MessageEventDefinition","bpmn:SignalEventDefinition"])}function a(t){return!!y(e.getDefinitions().get("rootElements"),D({id:t.id}))}function s(e){return Ar(e,"bpmn:ErrorEventDefinition")?"errorRef":Ar(e,"bpmn:EscalationEventDefinition")?"escalationRef":Ar(e,"bpmn:MessageEventDefinition")?"messageRef":Ar(e,"bpmn:SignalEventDefinition")?"signalRef":void 0}function c(e){if(Ha(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.get("messageRef");var t=e.get("eventDefinitions")[0];return t.get(s(t))}n.invoke(Ka,this),this.executed("shape.create",(function(t){var n=t.shape;if(o(n)){var i=c(kr(n));i&&!a(i)&&(vt(e.getDefinitions().get("rootElements"),i),t.addedRootElement=i)}}),!0),this.reverted("shape.create",(function(t){var n=t.addedRootElement;n&&mt(e.getDefinitions().get("rootElements"),n)}),!0),t.on("copyPaste.copyElement",(function(e){var t=e.descriptor,n=e.element;if(o(n)){var i=c(kr(n));i&&(t.referencedRootElement=i)}})),t.on("copyPaste.pasteElement",500,(function(e){var t=e.descriptor,n=t.businessObject;if(o(n)){var c=t.referencedRootElement;c&&(a(c)||(c=i.copyElement(c,r.create(c.$type))),function(e,t){if(Ha(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.set("messageRef",t);var n=e.get("eventDefinitions")[0];n.set(s(n),t)}(n,c))}}))}function pu(e){e.invoke(Ka,this),this.preExecute("shape.create",1500,(function(e){var t=e.context,n=t.parent,i=t.shape;Ar(n,"bpmn:Lane")&&!Ar(i,"bpmn:Lane")&&(t.parent=Ga(n,"bpmn:Participant"))}))}cu.$inject=["bpmnjs","eventBus","injector","moddleCopy","bpmnFactory"],n(cu,Ka),pu.$inject=["injector"],n(pu,Ka);var lu=1500;function uu(e,t,n){t.on(["create.hover","create.move","create.out","create.end","shape.move.hover","shape.move.move","shape.move.out","shape.move.end"],lu,(function(t){var i=t.context.shape||t.shape,r=t.hover;Ar(r,"bpmn:Lane")&&!Ha(i,["bpmn:Lane","bpmn:Participant"])&&(t.hover=Wp(r),t.hoverGfx=e.getGraphics(t.hover));var o=n.getRootElement();r!==o&&(i.labelTarget||Ar(i,"bpmn:Group"))&&(t.hover=o,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["connect.hover","connect.out","connect.end","connect.cleanup","global-connect.hover","global-connect.out","global-connect.end","global-connect.cleanup"],lu,(function(t){var n=t.hover;Ar(n,"bpmn:Lane")&&(t.hover=Wp(n)||n,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["bendpoint.move.hover"],lu,(function(t){var n=t.context,i=t.hover,r=n.type;Ar(i,"bpmn:Lane")&&/reconnect/.test(r)&&(t.hover=Wp(i)||i,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["connect.start"],lu,(function(e){var t=e.context,n=t.start;Ar(n,"bpmn:Lane")&&(t.start=Wp(n)||n)})),t.on("shape.move.start",2e3,(function(e){var t=e.shape;Ar(t,"bpmn:Lane")&&(e.shape=Wp(t)||t)}))}function hu(e,t,n){Ka.call(this,e),this.preExecute("shape.create",(function(e){var n=e.context.shape;if(Ar(n,"bpmn:DataObjectReference")&&"label"!==n.type){var i=t.create("bpmn:DataObject");n.businessObject.dataObjectRef=i}}))}uu.$inject=["elementRegistry","eventBus","canvas"],hu.$inject=["eventBus","bpmnFactory","moddle"],n(hu,Ka);var du=20,fu=20,mu=2e3;function vu(e,t,n){function i(t){var i,r=t.parent,o=e.getRootElement();Ar(o,"bpmn:Collaboration")?i=o:(i=n.makeCollaboration(),t.process=r),t.parent=i}Ka.call(this,t),t.on(["create.start","shape.move.start"],mu,(function(t){var n=t.context,i=n.shape,r=e.getRootElement();if(Ar(i,"bpmn:Participant")&&Ar(r,"bpmn:Process")&&r.children.length){var o=r.children.filter((function(e){return!Ar(e,"bpmn:Group")&&!so(e)&&!function(e){return!!e.waypoints}(e)}));if(o.length){var a=pt(o);F(i,function(e,t){t={width:t.width+40+30,height:t.height+40};var n=Math.max(e.width,t.width),i=Math.max(e.height,t.height);return{x:-n/2,y:-i/2,width:n,height:i}}(i,a)),n.createConstraints=function(e,t){return{bottom:(t=an(t)).top+e.height/2-fu,left:t.right-e.width/2+du,top:t.bottom-e.height/2+fu,right:t.left+e.width/2-du-30}}(i,a)}}})),t.on("create.start",mu,(function(n){var i=n.context.shape,r=e.getRootElement(),o=e.getGraphics(r);function a(e){e.element=r,e.gfx=o}Ar(i,"bpmn:Participant")&&Ar(r,"bpmn:Process")&&(t.on("element.hover",mu,a),t.once("create.cleanup",(function(){t.off("element.hover",a)})))})),this.preExecute("shape.create",(function(e){var t=e.parent;Ar(e.shape,"bpmn:Participant")&&Ar(t,"bpmn:Process")&&i(e)}),!0),this.execute("shape.create",(function(e){var t=e.process,n=e.shape;t&&(e.oldProcessRef=n.businessObject.processRef,n.businessObject.processRef=t.businessObject)}),!0),this.revert("shape.create",(function(e){var t=e.process,n=e.shape;t&&(n.businessObject.processRef=e.oldProcessRef)}),!0),this.postExecute("shape.create",(function(e){var t=e.process,i=e.shape;if(t){var r=t.children.slice();n.moveElements(r,{x:0,y:0},i)}}),!0),this.preExecute("elements.create",mu,(function(e){var t,n=e.elements,r=e.parent;yu(n)&&Ar(r,"bpmn:Process")&&(i(e),t=yu(n),e.oldProcessRef=t.businessObject.processRef,t.businessObject.processRef=r.businessObject)}),!0),this.revert("elements.create",(function(e){var t=e.elements;e.process&&(yu(t).businessObject.processRef=e.oldProcessRef)}),!0),this.postExecute("elements.create",(function(e){var t,i=e.elements,r=e.process;if(r){t=yu(i);var o=r.children.slice();n.moveElements(o,{x:0,y:0},t)}}),!0)}function yu(e){return y(e,(function(e){return Ar(e,"bpmn:Participant")}))}vu.$inject=["canvas","eventBus","modeling"],n(vu,Ka);var gu="__targetRef_placeholder";function bu(e,t){function n(e,n){var i=e.get("properties"),r=y(i,(function(e){return e.name===gu}));return!r&&n&&vt(i,r=t.create("bpmn:Property",{name:gu})),r}function i(e,t){var i=n(e);i&&(function(e,t,n){return y(e.get("dataInputAssociations"),(function(e){return e!==n&&e.targetRef===t}))}(e,i,t)||mt(e.get("properties"),i))}function r(e){var t,r=e.context,o=r.connection,a=o.businessObject,s=o.target,c=s&&s.businessObject,p=r.newTarget,l=p&&p.businessObject,u=r.oldTarget||r.target,h=u&&u.businessObject,d=o.businessObject;h&&h!==c&&i(h,a),l&&l!==c&&i(l,a),c?(t=n(c,!0),d.targetRef=t):d.targetRef=null}Ka.call(this,e),this.executed(["connection.create","connection.delete","connection.move","connection.reconnect"],xu(r)),this.reverted(["connection.create","connection.delete","connection.move","connection.reconnect"],xu(r))}function xu(e){return function(t){if(Ar(t.context.connection,"bpmn:DataInputAssociation"))return e(t)}}function _u(e){this._bpmnUpdater=e}function Eu(e,t,n,i){function r(e){return e.children.filter((function(e){return Ar(e,"bpmn:DataStoreReference")&&!e.labelTarget}))}function o(e,i){var r=e.businessObject||e;if(i=i||n.filter((function(e){return Ar(e,"bpmn:Participant")&&kr(e).processRef}))[0]){var o=i.businessObject||i;t.execute("dataStore.updateContainment",{dataStoreBo:r,newSemanticParent:o.processRef||o,newDiParent:o.di})}}Ka.call(this,i),t.registerHandler("dataStore.updateContainment",_u),this.preExecute("shape.create",(function(e){var t=e.context,n=t.shape;Ar(n,"bpmn:DataStoreReference")&&"label"!==n.type&&(t.hints||(t.hints={}),t.hints.autoResize=!1)})),this.preExecute("elements.move",(function(e){var t=e.context,n=t.shapes;n.filter((function(e){return Ar(e,"bpmn:DataStoreReference")})).length&&(t.hints||(t.hints={}),t.hints.autoResize=n.filter((function(e){return!Ar(e,"bpmn:DataStoreReference")})))})),this.postExecute("shape.create",(function(e){var t=e.context.shape,n=t.parent;Ar(t,"bpmn:DataStoreReference")&&"label"!==t.type&&Ar(n,"bpmn:Collaboration")&&o(t)})),this.postExecute("shape.move",(function(e){var t=e.context,n=t.shape,i=t.oldParent,r=n.parent;Ar(i,"bpmn:Collaboration")||Ar(n,"bpmn:DataStoreReference")&&"label"!==n.type&&Ar(r,"bpmn:Collaboration")&&o(n,Ar(i,"bpmn:Participant")?i:function(e,t){for(;e.parent;){if(Ar(e.parent,t))return e.parent;e=e.parent}}(i,"bpmn:Participant"))})),this.postExecute("shape.delete",(function(t){var n=t.context.shape,i=e.getRootElement();Ha(n,["bpmn:Participant","bpmn:SubProcess"])&&Ar(i,"bpmn:Collaboration")&&r(i).filter((function(e){return function(e,t){var n=e.businessObject||e,i=t.businessObject||t;for(;n.$parent;){if(n.$parent===i.processRef||i)return!0;n=n.$parent}return!1}(e,n)})).forEach((function(e){o(e)}))})),this.postExecute("canvas.updateRoot",(function(e){var t=e.context,n=t.oldRoot,i=t.newRoot;r(n).forEach((function(e){Ar(i,"bpmn:Process")&&o(e,i)}))}))}bu.$inject=["eventBus","bpmnFactory"],n(bu,Ka),_u.$inject=["bpmnUpdater"],_u.prototype.execute=function(e){var t=e.dataStoreBo,n=e.newSemanticParent,i=e.newDiParent;e.oldSemanticParent=t.$parent,e.oldDiParent=t.di.$parent,this._bpmnUpdater.updateSemanticParent(t,n),this._bpmnUpdater.updateDiParent(t.di,i)},_u.prototype.revert=function(e){var t=e.dataStoreBo,n=e.oldSemanticParent,i=e.oldDiParent;this._bpmnUpdater.updateSemanticParent(t,n),this._bpmnUpdater.updateDiParent(t.di,i)},Eu.$inject=["canvas","commandStack","elementRegistry","eventBus"],n(Eu,Ka);function wu(e,t,n){Ka.call(this,e),this.postExecuted("shape.delete",500,(function(e){var t=e.context,i=t.hints,r=t.shape,o=t.oldParent;Ar(r,"bpmn:Lane")&&(i&&i.nested||function(e,t){var i,r,o,a=Gp(t),s=[],c=[];st(a,(function(t){return t.y>e.y?c.push(t):s.push(t),t.children})),a.length&&(i=c.length&&s.length?e.height/2:e.height,s.length&&(r=n.calculateAdjustments(s,"y",i,e.y-10),n.makeSpace(r.movingShapes,r.resizingShapes,{x:0,y:i},"s")),c.length&&(o=n.calculateAdjustments(c,"y",-i,e.y+e.height+10),n.makeSpace(o.movingShapes,o.resizingShapes,{x:0,y:-i},"n")))}(r,o))}))}wu.$inject=["eventBus","modeling","spaceTool"],n(wu,Ka);function Su(e,t){t.invoke(Ka,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",500,(function(e){var t=e.elements;t.filter((function(e){return Cu(e,e.host)})).map((function(e){return t.indexOf(e)})).forEach((function(i){e.elements[i]=n.replaceShape(t[i])}))}),!0),this.preExecute("elements.move",500,(function(e){var t=e.shapes,i=e.newHost;t.forEach((function(e,r){var o,a=e.host;Cu(e,(o=a,-1!==t.indexOf(o)?a:i))&&(t[r]=n.replaceShape(e))}))}),!0)}function Cu(e,t){return!so(e)&&Ar(e,"bpmn:BoundaryEvent")&&!t}function Tu(e,t,n){function i(e,i,r){var o,a,s,c,p,l,u,h,f=i.waypoints,m=e.outgoing.slice(),v=e.incoming.slice(),y=ms(f,h=d(r.width)?cn(r):r);if(y){if(o=f.slice(0,y.index),a=f.slice(y.index+(y.bendpoint?1:0)),!o.length||!a.length)return;s=y.bendpoint?f[y.index]:h,1!==o.length&&Ru(e,o[o.length-1])||o.push(Pu(s)),1!==a.length&&Ru(e,a[0])||a.unshift(Pu(s))}c=i.source,p=i.target,t.canConnect(c,e,i)&&(n.reconnectEnd(i,e,o||h),l=i),t.canConnect(e,p,i)&&(l?u=n.connect(e,p,{type:i.type,waypoints:a}):(n.reconnectStart(i,e,a||h),u=i));var b=[].concat(l&&g(v,(function(e){return e.source===l.source}))||[],u&&g(m,(function(e){return e.target===u.target}))||[]);b.length&&n.removeElements(b)}Ka.call(this,e),this.preExecute("elements.move",(function(e){var n=e.newParent,i=e.shapes,r=e.delta,o=i[0];if(o&&n){n&&n.waypoints&&(e.newParent=n=n.parent);var a=cn(o),s={x:a.x+r.x,y:a.y+r.y},c=y(n.children,(function(e){return t.canInsert(i,e)&&ms(e.waypoints,s)}));c&&(e.targetFlow=c,e.position=s)}}),!0),this.postExecuted("elements.move",(function(e){var t=e.shapes,n=e.targetFlow,r=e.position;n&&i(t[0],n,r)}),!0),this.preExecute("shape.create",(function(e){var n=e.parent,i=e.shape;t.canInsert(i,n)&&(e.targetFlow=n,e.parent=n.parent)}),!0),this.postExecuted("shape.create",(function(e){var t=e.shape,n=e.targetFlow,r=e.position;n&&i(t,n,r)}),!0)}function Ru(e,t){var n=t.x,i=t.y;return n>=e.x&&n<=e.x+e.width&&i>=e.y&&i<=e.y+e.height}function Pu(e){return F({},e)}function Au(e,t){Ka.call(this,e),this.preExecuted("connection.create",(function(e){var n=e.context,i=n.source,r=n.target,o=r.incoming.slice();n.hints&&!1===n.hints.createElementsBehavior||Ar(i,"bpmn:EventBasedGateway")&&r.incoming.length&&o.filter(ku).forEach((function(e){t.removeConnection(e)}))})),this.preExecuted("shape.replace",(function(e){var n=e.context.newShape;Ar(n,"bpmn:EventBasedGateway")&&n.outgoing.filter(ku).map((function(e){return e.target})).reduce((function(e,t){var n=t.incoming.filter(ku);return e.concat(n)}),[]).forEach((function(e){e.source!==n&&t.removeConnection(e)}))}))}function ku(e){return Ar(e,"bpmn:SequenceFlow")}Su.$inject=["bpmnReplace","injector"],n(Su,Ka),Su.prototype.replaceShape=function(e){var t,n,i=(n=kr(e).eventDefinitions)&&n[0];return t=i?{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:i.$type}:{type:"bpmn:IntermediateThrowEvent"},this._bpmnReplace.replaceElement(e,t,{layoutConnection:!1})},n(Tu,Ka),Tu.$inject=["eventBus","bpmnRules","modeling"],Au.$inject=["eventBus","modeling"],n(Au,Ka);function Mu(e,t,n,i,r,o){function a(){return kr(t.getRootElement()).$parent}function s(e){var t=kr(e).categoryValueRef;if(t){var n=t.$parent;t&&(mt(n.categoryValue,t),n&&!n.categoryValue.length&&function(e){mt(a().get("rootElements"),e)}(n))}}r.invoke(Ka,this),this.executed("shape.delete",(function(e){var t,i=e.context.shape;if(Ar(i,"bpmn:Group")){var r=kr(i).categoryValueRef,o=n.filter((function(e){return Ar(e,"bpmn:Group")}));t=r,o.some((function(e){var n=kr(e);return n.categoryValueRef&&n.categoryValueRef===t}))||s(i)}})),this.reverted("shape.delete",(function(e){var t=e.context.shape;if(Ar(t,"bpmn:Group")){var n=kr(t).categoryValueRef,i=a(),r=n?n.$parent:null;vt(r.get("categoryValue"),n),vt(i.get("rootElements"),r)}})),this.execute("shape.create",(function(t){var n=kr(t.context.shape);if(Ar(n,"bpmn:Group")&&!n.categoryValueRef){var i=Vl(a(),e);n.categoryValueRef=i}})),this.revert("shape.create",(function(e){var t=e.context.shape;Ar(t,"bpmn:Group")&&(s(t),delete kr(t).categoryValueRef)})),i.on("moddleCopy.canCopyProperty",2e3,(function(t){var n,i=t.property;if(Ar(i,"bpmn:CategoryValue"))return n=Vl(a(),e),o.copyElement(i,n)}))}function Du(e,t,n,i){var r,o,a,s;return 0==(r=(i.y-n.y)*(t.x-e.x)-(i.x-n.x)*(t.y-e.y))?null:(o=e.y-n.y,a=e.x-n.x,s=((i.x-n.x)*o-(i.y-n.y)*a)/r,{x:Math.round(e.x+s*(t.x-e.x)),y:Math.round(e.y+s*(t.y-e.y))})}function Bu(e){function t(e,t,n){var i,r={x:n.x,y:n.y-50},o={x:n.x-50,y:n.y},a=Du(e,t,n,r),s=Du(e,t,n,o);i=a&&s?Nu(a,n)>Nu(s,n)?s:a:a||s,e.original=i}e.on("bpmnElement.added",(function(e){var n,i,r=e.element;r.waypoints&&(t((i=(n=r).waypoints)[0],i[1],cn(n.source)),t(i[i.length-1],i[i.length-2],cn(n.target)))}))}function Nu(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Ou(e){Ka.call(this,e);var t=["bpmn:Participant","bpmn:Lane"];this.executed(["shape.move","shape.create","shape.resize"],(function(e){var n=kr(e.context.shape);Ha(n,t)&&!n.di.get("isHorizontal")&&n.di.set("isHorizontal",!0)}))}function ju(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}function Lu(e){return Math.atan((e[1].y-e[0].y)/(e[1].x-e[0].x))}function Iu(e,t){var n=t[0],i=t[1],r={x:i.x-n.x,y:i.y-n.y},o=function(e,t,n){var i=[{n:e[0]-n[0],lambda:t[0]},{n:e[1]-n[1],lambda:t[1]}];return-(i[0].n*t[0]+i[1].n*t[1])/(i[0].lambda*t[0]+i[1].lambda*t[1])}([n.x,n.y],[r.x,r.y],[e.x,e.y]);return{x:n.x+o*r.x,y:n.y+o*r.y}}function zu(e,t){var n=Iu(e,t);return ju({x:n.x-e.x,y:n.y-e.y})}function Fu(e,t){return ju({x:e.x-t.x,y:e.y-t.y})}Mu.$inject=["bpmnFactory","canvas","elementRegistry","eventBus","injector","moddleCopy"],n(Mu,Ka),Bu.$inject=["eventBus"],Ou.$inject=["eventBus"],n(Ou,Ka);var $u=Math.sqrt,Hu=Math.min,Gu=Math.max,Wu=Math.abs;function Vu(e){return Math.pow(e,2)}function Uu(e,t){return $u(Vu(e.x-t.x)+Vu(e.y-t.y))}function qu(e,t,n,i){var r=t.x-e.x,o=t.y-e.y,a=n.x-e.x,s=n.y-e.y,c=r*r+o*o,p=(r*a+o*s)/c,l=p*p-(a*a+s*s-i*i)/c;if(l<0&&l>-1e-6&&(l=0),l<0)return[];var u=$u(l),h=-p+u,d=-p-u,f={x:e.x-r*h,y:e.y-o*h};return 0===l?[f]:[f,{x:e.x-r*d,y:e.y-o*d}].filter((function(n){return function(e,t,n){return Ku(e.x,t.x,n.x)&&Ku(e.y,t.y,n.y)}(n,e,t)}))}function Ku(e,t,n){return e>=Hu(t,n)-Yu&&e<=Gu(t,n)+Yu}var Yu=.1;function Xu(e,t){return Wu(e.x-t.x)<=Yu&&Wu(e.y-t.y)<=Yu}function Zu(e,t,n,i){var r=0,o=0,a=function(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}(e),s=function(e,t){var n,i,r,o,a,s,c,p,l,u,h,d,f=0;for(f=0;f<t.length-1;f++){if(Xu(n=t[f],i=t[f+1])?s=[n]:(r=Uu(e,n),o=Uu(e,i),s=qu(n,i,e,Hu(r,o))),s.length<1)throw new Error("expected between [1, 2] circle -> line intersections");1===s.length&&(c={type:"bendpoint",position:s[0],segmentIndex:f,bendpointIndex:Xu(n,s[0])?f:f+1}),2===s.length&&(h=s[0],d=s[1],c={type:"segment",position:a={x:(h.x+d.x)/2,y:(h.y+d.y)/2},segmentIndex:f,relativeLocation:Uu(n,a)/Uu(n,i)}),p=Uu(c.position,e),(!u||l>p)&&(u=c,l=p)}return u}(a,n),c=s.segmentIndex,p=function(e,t,n,i){var r=n.segmentIndex,o=t.length-e.length;if(i.segmentMove){var a=i.segmentMove.segmentStartIndex,s=i.segmentMove.newSegmentStartIndex;return r===a?s:r>=s?r+o<s?s:r+o:r}if(i.bendpointMove){var c,p=i.bendpointMove.insert,l=i.bendpointMove.bendpointIndex;return 0===o?r:(r>=l&&(c=p?r+1:r-1),r<l&&(c=r,p&&"bendpoint"!==n.type&&l-1===r&&Qu(t,l)<n.relativeLocation&&c++),c)}return 0===o?r:i.connectionStart?0===r?0:null:i.connectionEnd&&r===e.length-2?t.length-2:null}(n,t,s,i);if(null===p)return{x:r,y:o};if(p<0||p>t.length-2)return{x:r,y:o};var l,u,h=Ju(n,c),d=Ju(t,p),f=s.position,m=function(e,t){var n=Fu(e[0],e[1]),i=Fu(e[0],t);return 0===n?0:i/n}(h,f),v=(l=d,u=Lu(h),Lu(l)-u);if("bendpoint"===s.type){var y=t.length-n.length,g=s.bendpointIndex,b=n[g];if(-1!==t.indexOf(b))return{x:r,y:o};if(0===y){var x=t[g];return{x:x.x-s.position.x,y:x.y-s.position.y}}y<0&&0!==g&&g<n.length-1&&(m=Qu(n,g))}var _,E,w=(d[1].x-d[0].x)*m+d[0].x,S=(d[1].y-d[0].y)*m+d[0].y,C=(_={x:a.x-f.x,y:a.y-f.y},(E=v)?{x:Math.cos(E)*_.x-Math.sin(E)*_.y,y:Math.sin(E)*_.x+Math.cos(E)*_.y}:_);return on({x:r=w+C.x-a.x,y:o=S+C.y-a.y})}function Qu(e,t){var n=Fu(e[t-1],e[t]);return n/(n+Fu(e[t],e[t+1]))}function Ju(e,t){return[e[t],e[t+1]]}function eh(e,t,n){var i=ca(t),r=ca(n),o=pa(e,i),a=o.x*(n.width/t.width),s=o.y*(n.height/t.height);return on({x:r.x+a,y:r.y+s})}function th(e,t,n){var i=ca(e),r=ca(t),o=ca(n),a=pa(e,i),s=pa(i,r),c=function(e,t,n){var i=an(t),r=an(n);if(function(e,t){return function(e,t){return e.right!==t.right&&e.left!==t.left}(e,t)||function(e,t){return e.top!==t.top&&e.bottom!==t.bottom}(e,t)}(i,r))return null;var o,a,s=pn(t,e);if("top"===s)o={x:0,y:r.bottom-i.bottom};else if("bottom"===s)o={x:0,y:r.top-i.top};else if("right"===s)o={x:r.left-i.left,y:0};else{if("left"!==s)return null;o={x:r.right-i.right,y:0}}if(a={x:e.x+o.x,y:e.y+o.y},pn(n,a)!==s)return null;return o}(i,t,n);if(c)return c;var p=s.x*(n.width/t.width),l=s.y*(n.height/t.height),u=o.x+p,h=o.y+l;return on({x:u+a.x-e.x,y:h+a.y-e.y})}var nh={width:90,height:20},ih="name",rh="text";function oh(e,t,n,i){Ka.call(this,e),this.postExecute("element.updateProperties",(function(e){var n=e.context,r=n.element,o=n.properties;if(ih in o&&t.updateLabel(r,o.name),rh in o&&Ar(r,"bpmn:TextAnnotation")){var a=i.getTextAnnotationBounds({x:r.x,y:r.y,width:r.width,height:r.height},o.text||"");t.updateLabel(r,o.text,a)}})),this.postExecute(["shape.create","connection.create"],(function(e){var n=e.context;if(!1!==(n.hints||{}).createElementsBehavior){var r=n.shape||n.connection,o=r.businessObject;if(!so(r)&&io(r)&&Or(r)){var a=ao(r),s=i.getExternalLabelBounds(nh,Or(r));t.createLabel(r,a,{id:o.id+"_label",businessObject:o,width:s.width,height:s.height})}}})),this.postExecute("shape.delete",(function(e){var n=e.context,i=n.labelTarget,r=n.hints||{};i&&!1!==r.unsetLabel&&t.updateLabel(i,null,null,{removeShape:!1})})),this.postExecute(["label.create"],(function(e){var t,i=e.context.shape;i.labelTarget&&Ar(i.labelTarget||i,"bpmn:BaseElement")&&((t=i.businessObject.di).label||(t.label=n.create("bpmndi:BPMNLabel",{bounds:n.create("dc:Bounds")})),F(t.label.bounds,{x:i.x,y:i.y,width:i.width,height:i.height}))})),this.postExecute(["connection.layout","connection.updateWaypoints"],(function(e){var n=e.context;if(!1!==(n.hints||{}).labelBehavior){var i,r=n.connection.label;r&&r.parent&&(i=function(e){var t=e.context,n=t.connection,i=n.label,r=F({},t.hints),o=t.newWaypoints||n.waypoints,a=t.oldWaypoints;return void 0===r.startChanged&&(r.startChanged=!!r.connectionStart),void 0===r.endChanged&&(r.endChanged=!!r.connectionEnd),Zu(i,o,a,r)}(e),t.moveShape(r,i))}})),this.postExecute(["shape.replace"],(function(e){var t=e.context,n=t.newShape,i=t.oldShape,r=kr(n);r&&io(r)&&i.label&&n.label&&(n.label.x=i.label.x,n.label.y=i.label.y)})),this.postExecute("shape.resize",(function(e){var n,i=e.context,r=i.shape,o=i.newBounds,a=i.oldBounds;if(ro(r)){var s=r.label,c=ah(function(e,t){if(!t.length)return;var n=function(e,t){return M(t.map((function(t){return{line:t,distance:zu(e,t)}})),"distance")[0].line}(e,t);return Iu(e,n)}(cn(s),[[{x:(n=a).x,y:n.y},{x:n.x+(n.width||0),y:n.y}],[{x:n.x+(n.width||0),y:n.y},{x:n.x+(n.width||0),y:n.y+(n.height||0)}],[{x:n.x,y:n.y+(n.height||0)},{x:n.x+(n.width||0),y:n.y+(n.height||0)}],[{x:n.x,y:n.y},{x:n.x,y:n.y+(n.height||0)}]]),a,o);t.moveShape(s,c)}}))}function ah(e,t,n){return on(pa(eh(e,t,n),e))}function sh(e,t,n){var i=hh(e),r=dh(i,t),o=i[0];return r.length?r[r.length-1]:eh(o.original||o,n,t)}function ch(e,t,n){var i=hh(e),r=dh(i,t),o=i[i.length-1];return r.length?r[0]:eh(o.original||o,n,t)}function ph(e,t,n){var i=hh(e),r=uh(t,n),o=i[0];return eh(o.original||o,r,t)}function lh(e,t,n){var i=hh(e),r=uh(t,n),o=i[i.length-1];return eh(o.original||o,r,t)}function uh(e,t){return{x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}}function hh(e){var t=e.waypoints;if(!t.length)throw new Error("connection#"+e.id+": no waypoints");return t}function dh(e,t){return g(S(e,fh),(function(e){return function(e,t){return"intersect"===pn(t,e,1)}(e,t)}))}function fh(e){return e.original||e}function mh(e,t){Ka.call(this,e),this.postExecute("shape.replace",(function(e){var n=e.oldShape,i=e.newShape;if(function(e,t){return Ar(e,"bpmn:Participant")&&Mr(e)&&Ar(t,"bpmn:Participant")&&!Mr(t)}(n,i)){var r,o,a,s,c=(o=ct([r=n],!1),a=[],s=[],o.forEach((function(e){e!==r&&(e.incoming.forEach((function(e){Ar(e,"bpmn:MessageFlow")&&a.push(e)})),e.outgoing.forEach((function(e){Ar(e,"bpmn:MessageFlow")&&s.push(e)})))}),[]),{incoming:a,outgoing:s});c.incoming.forEach((function(e){var r=ch(e,i,n);t.reconnectEnd(e,i,r)})),c.outgoing.forEach((function(e){var r=sh(e,i,n);t.reconnectStart(e,i,r)}))}}),!0)}n(oh,Ka),oh.$inject=["eventBus","modeling","bpmnFactory","textRenderer"],mh.$inject=["eventBus","modeling"],n(mh,Ka);function vh(e,t,n){e.on(["shape.move.rejected","create.rejected"],(function(e){var i,r,o,a=e.context,s=a.shape;Ar(a.target,"bpmn:Collaboration")&&Ar(s,"bpmn:FlowNode")&&(i=e,r=n("flow elements must be children of pools/participants"),t.add({position:{x:i.x+5,y:i.y+5},type:"error",timeout:o||2e3,html:"<div>"+r+"</div>"}))}))}function yh(e,t,n,i){Ka.call(this,e);var r=i.get("dragging",!1);function o(e){var i,r,o=e.source,a=e.target;e.parent&&(Ar(e,"bpmn:SequenceFlow")&&(n.canConnectSequenceFlow(o,a)||(r=!0),n.canConnectMessageFlow(o,a)&&(i="bpmn:MessageFlow")),Ar(e,"bpmn:MessageFlow")&&(n.canConnectMessageFlow(o,a)||(r=!0),n.canConnectSequenceFlow(o,a)&&(i="bpmn:SequenceFlow")),Ar(e,"bpmn:Association")&&!n.canConnectAssociation(o,a)&&(r=!0),r&&t.removeConnection(e),i&&t.connect(o,a,{type:i,waypoints:e.waypoints.slice()}))}this.postExecuted("elements.move",(function(e){b(e.closure.allConnections,o)}),!0),this.preExecute("connection.reconnect",(function(e){var i,o,a=e.context,s=a.connection,c=a.newSource||s.source,p=a.newTarget||s.target;(i=n.canConnect(c,p))&&i.type!==s.type&&(o=t.connect(c,p,{type:i.type,waypoints:s.waypoints.slice()}),t.removeConnection(s),a.connection=o,r&&function(e,t){var n,i=r.context(),o=i&&i.payload.previousSelection;if(!o||!o.length)return;if(-1===(n=o.indexOf(e)))return;o.splice(n,1,t)}(s,o))})),this.postExecuted("element.updateProperties",(function(e){var n,i=e.context,r=i.properties,o=i.element,a=o.businessObject;r.default&&(n=y(o.outgoing,D({id:o.businessObject.default.id})))&&t.updateProperties(n,{conditionExpression:void 0}),r.conditionExpression&&a.sourceRef.default===a&&t.updateProperties(o.source,{default:void 0})}))}function gh(e,t){Ka.call(this,e),this.preExecute("shape.delete",(function(e){var t=e.shape,n=t.parent;Ar(t,"bpmn:Participant")&&(e.collaborationRoot=n)}),!0),this.postExecute("shape.delete",(function(e){var n=e.collaborationRoot;n&&!n.businessObject.participants.length&&t.makeProcess()}),!0)}function bh(e,t,n,i,r,o){i.invoke(Ka,this),this._bpmnReplace=e,this._elementRegistry=n,this._selection=o,this.postExecuted(["elements.create"],500,(function(e){var n=e.context,i=n.parent,r=n.elements,o=t.canReplace(r,i);o&&this.replaceElements(r,o.replacements)}),this),this.postExecuted(["elements.move"],500,(function(e){var n=e.context,i=n.newParent,r=n.newHost,o=[];b(n.closure.topLevel,(function(e){o=Dr(e)?o.concat(e.children):o.concat(e)})),1===o.length&&r&&(i=r);var a=t.canReplace(o,i);a&&this.replaceElements(o,a.replacements,r)}),this),this.postExecute(["shape.replace"],1500,(function(e){var n,i=e.context,r=i.oldShape,o=i.newShape,a=r.attachers;a&&a.length&&(n=t.canReplace(a,o),this.replaceElements(a,n.replacements))}),this),this.postExecuted(["shape.replace"],1500,(function(e){var t=e.context,n=t.oldShape,i=t.newShape;r.unclaimId(n.businessObject.id,n.businessObject),r.updateProperties(i,{id:n.id})}))}vh.$inject=["eventBus","tooltips","translate"],n(yh,Ka),yh.$inject=["eventBus","modeling","bpmnRules","injector"],gh.$inject=["eventBus","modeling"],n(gh,Ka),n(bh,Ka),bh.prototype.replaceElements=function(e,t){var n=this._elementRegistry,i=this._bpmnReplace,r=this._selection;b(t,(function(t){var r={type:t.newElementType},o=n.get(t.oldElementId),a=e.indexOf(o);e[a]=i.replaceElement(o,r,{select:!1})})),t&&r.select(e)},bh.$inject=["bpmnReplace","bpmnRules","elementRegistry","injector","modeling","selection"];var xh=300,_h=60,Eh={width:300,height:150},wh={width:140,height:120},Sh={width:50,height:30};function Ch(e){e.on("resize.start",1500,(function(e){var t=e.context,n=t.shape,i=t.direction,r=t.balanced;(Ar(n,"bpmn:Lane")||Ar(n,"bpmn:Participant"))&&(t.resizeConstraints=function(e,t,n){var i=Wp(e),r=!0,o=!0,a=Hp(i,[i]),s=an(e),c={},p={};/e/.test(t)?p.right=s.left+xh:/w/.test(t)&&(p.left=s.right-xh);return a.forEach((function(e){var i=an(e);/n/.test(t)&&(i.top<s.top-10&&(r=!1),n&&Th(s.top-i.bottom)<10&&Mh(c,"top",i.top+_h),Th(s.top-i.top)<5&&kh(p,"top",i.bottom-_h)),/s/.test(t)&&(i.bottom>s.bottom+10&&(o=!1),n&&Th(s.bottom-i.top)<10&&kh(c,"bottom",i.bottom-_h),Th(s.bottom-i.bottom)<5&&Mh(p,"bottom",i.top+_h))})),i.children.filter((function(e){return!e.hidden&&!e.waypoints&&(Ar(e,"bpmn:FlowElement")||Ar(e,"bpmn:Artifact"))})).forEach((function(e){var n=an(e);r&&/n/.test(t)&&kh(p,"top",n.top-20),/e/.test(t)&&Mh(p,"right",n.right+20),o&&/s/.test(t)&&Mh(p,"bottom",n.bottom+20),/w/.test(t)&&kh(p,"left",n.left-50)})),{min:p,max:c}}(n,i,r)),Ar(n,"bpmn:Participant")&&(t.minDimensions=Eh),Ar(n,"bpmn:SubProcess")&&Mr(n)&&(t.minDimensions=wh),Ar(n,"bpmn:TextAnnotation")&&(t.minDimensions=Sh)}))}Ch.$inject=["eventBus"];var Th=Math.abs,Rh=Math.min,Ph=Math.max;function Ah(e,t,n,i){var r=e[t];e[t]=void 0===r?n:i(n,r)}function kh(e,t,n){return Ah(e,t,n,Rh)}function Mh(e,t,n){return Ah(e,t,n,Ph)}function Dh(e,t){e.on("resize.start",1501,(function(e){var t=e.context,n=t.shape;(Ar(n,"bpmn:Lane")||Ar(n,"bpmn:Participant"))&&(t.balanced=!xo(e))})),e.on("resize.end",1001,(function(e){var n=e.context,i=n.shape,r=n.canExecute,o=n.newBounds;if(Ar(i,"bpmn:Lane")||Ar(i,"bpmn:Participant"))return r&&(o=rn(o),t.resizeLane(i,o,n.balanced)),!1}))}function Bh(e,t,n){Ka.call(this,e),this.preExecute("shape.delete",(function(e){var i=e.context.shape;if(1===i.incoming.length&&1===i.outgoing.length){var r=i.incoming[0],o=i.outgoing[0];if(Ar(r,"bpmn:SequenceFlow")&&Ar(o,"bpmn:SequenceFlow")&&t.canConnect(r.source,o.target,r)){var a=function(e,t){var n=Du(Nh(e[e.length-2]),Nh(e[e.length-1]),Nh(t[1]),Nh(t[0]));return n?[].concat(e.slice(0,e.length-1),[n],t.slice(1)):[Nh(e[0]),Nh(t[t.length-1])]}(r.waypoints,o.waypoints);n.reconnectEnd(r,o.target,a)}}}))}function Nh(e){return e.original||e}Dh.$inject=["eventBus","modeling"],n(Bh,Ka),Bh.$inject=["eventBus","bpmnRules","modeling"];var Oh=Math.max;function jh(e){e.on("spaceTool.getMinDimensions",(function(e){var t=e.shapes,n=e.axis,i=e.start,r={};return b(t,(function(e){var t=e.id;Ar(e,"bpmn:Participant")&&(!function(e){return"x"===e}(n)?r[t]={width:Eh.width,height:Lh(e,i)}:r[t]=Eh),Ar(e,"bpmn:SubProcess")&&Mr(e)&&(r[t]=wh),Ar(e,"bpmn:TextAnnotation")&&(r[t]=Sh)})),r}))}function Lh(e,t){var n;return Gp(e).length?(n=function(e,t){var n,i=Gp(e);return n=Ih(i,t),e.height-n.height+_h}(e,t),Oh(Eh.height,n)):Eh.height}function Ih(e,t){var n,i,r;for(n=0;n<e.length;n++)if(t>=(i=e[n]).y&&t<=i.y+i.height)return(r=Gp(i)).length?Ih(r,t):i}function zh(e,t){e.invoke(Ka,this),this.postExecuted("shape.replace",(function(e){var n=e.context.oldShape,i=e.context.newShape;if(Ar(i,"bpmn:SubProcess")&&Ar(n,"bpmn:Task")&&Mr(i)){var r,o={x:(r=i).x+r.width/6,y:r.y+r.height/2};t.createShape({type:"bpmn:StartEvent"},o,i)}}))}jh.$inject=["eventBus"],zh.$inject=["injector","modeling"],n(zh,Ka);function Fh(e,t,n,i){Ka.call(this,e),this.executed(["shape.toggleCollapse"],500,(function(e){var t,n=e.context.shape;Ar(n,"bpmn:SubProcess")&&(n.collapsed?kr(n).di.isExpanded=!1:((t=n.children).length&&t.forEach((function(e){"label"!==e.type||e.businessObject.name||(e.hidden=!0)})),kr(n).di.isExpanded=!0))})),this.reverted(["shape.toggleCollapse"],500,(function(e){var t=e.context.shape;t.collapsed?kr(t).di.isExpanded=!1:kr(t).di.isExpanded=!0})),this.postExecuted(["shape.toggleCollapse"],500,(function(e){var i,r=e.context.shape,o=t._getDefaultSize(r);i=r.collapsed?function(e,t){return{x:e.x+(e.width-t.width)/2,y:e.y+(e.height-t.height)/2,width:t.width,height:t.height}}(r,o):function(e,t){var n,i,r=e.children,o=t;return(n=Ip((i=r,i.filter((function(e){return!e.hidden}))).concat([e])))?(o.width=Math.max(n.width,o.width),o.height=Math.max(n.height,o.height),o.x=n.x+(n.width-o.width)/2,o.y=n.y+(n.height-o.height)/2):(o.x=e.x+(e.width-o.width)/2,o.y=e.y+(e.height-o.height)/2),o}(r,o),n.resizeShape(r,i,null,{autoResize:!r.collapsed&&"nwse"})}))}function $h(e,t,n,i){t.invoke(Ka,this),this.preExecute("shape.delete",(function(e){var t=e.context.shape,r=t.businessObject;so(t)||(Ar(t,"bpmn:Participant")&&Mr(t)&&n.ids.unclaim(r.processRef.id),i.unclaimId(r.id,r))})),this.preExecute("connection.delete",(function(e){var t=e.context.connection.businessObject;i.unclaimId(t.id,t)})),this.preExecute("canvas.updateRoot",(function(){var t=e.getRootElement().businessObject;n.ids.unclaim(t.id)}))}n(Fh,Ka),Fh.$inject=["eventBus","elementFactory","modeling"],n($h,Ka),$h.$inject=["canvas","injector","moddle","modeling"];function Hh(e,t,n){var i;function r(){if(!i)throw new Error(n("out of bounds release"));return i}Ka.call(this,e);var o=["spaceTool","lane.add","lane.resize","lane.split","elements.create","elements.delete","elements.move","shape.create","shape.delete","shape.move","shape.resize"];this.preExecute(o,5e3,(function(e){(i=i||new Gh).enter()})),this.postExecuted(o,500,(function(e){!function(){if(!i)throw new Error(n("out of bounds release"));var e=i.leave();e&&(t.updateLaneRefs(i.flowNodes,i.lanes),i=null)}()})),this.preExecute(["shape.create","shape.move","shape.delete","shape.resize"],(function(e){var t=e.context.shape,n=r();t.labelTarget||(Ar(t,"bpmn:Lane")&&n.addLane(t),Ar(t,"bpmn:FlowNode")&&n.addFlowNode(t))}))}function Gh(){this.flowNodes=[],this.lanes=[],this.counter=0,this.addLane=function(e){this.lanes.push(e)},this.addFlowNode=function(e){this.flowNodes.push(e)},this.enter=function(){this.counter++},this.leave=function(){return this.counter--,!this.counter}}function Wh(e,t){Ka.call(this,e),this.preExecute("connection.delete",(function(e){var n=e.context.connection,i=n.source;(function(e,t){if(!Ar(e,"bpmn:SequenceFlow"))return!1;var n=kr(t),i=kr(e);return n.get("default")===i})(n,i)&&t.updateProperties(i,{default:null})}))}Hh.$inject=["eventBus","modeling","translate"],n(Hh,Ka),n(Wh,Ka),Wh.$inject=["eventBus","modeling"];var Vh={__init__:["adaptiveLabelPositioningBehavior","appendBehavior","associationBehavior","attachEventBehavior","boundaryEventBehavior","rootElementReferenceBehavior","createBehavior","fixHoverBehavior","createDataObjectBehavior","createParticipantBehavior","dataStoreBehavior","dataInputAssociationBehavior","deleteLaneBehavior","detachEventBehavior","dropOnFlowBehavior","eventBasedGatewayBehavior","groupBehavior","importDockingFix","isHorizontalFix","labelBehavior","messageFlowBehavior","modelingFeedback","removeElementBehavior","removeParticipantBehavior","replaceConnectionBehavior","replaceElementBehaviour","resizeBehavior","resizeLaneBehavior","toggleElementCollapseBehaviour","spaceToolBehavior","subProcessStartEventBehavior","unclaimIdBehavior","unsetDefaultFlowBehavior","updateFlowNodeRefsBehavior"],adaptiveLabelPositioningBehavior:["type",tu],appendBehavior:["type",iu],associationBehavior:["type",ru],attachEventBehavior:["type",ou],boundaryEventBehavior:["type",su],rootElementReferenceBehavior:["type",cu],createBehavior:["type",pu],fixHoverBehavior:["type",uu],createDataObjectBehavior:["type",hu],createParticipantBehavior:["type",vu],dataInputAssociationBehavior:["type",bu],dataStoreBehavior:["type",Eu],deleteLaneBehavior:["type",wu],detachEventBehavior:["type",Su],dropOnFlowBehavior:["type",Tu],eventBasedGatewayBehavior:["type",Au],groupBehavior:["type",Mu],importDockingFix:["type",Bu],isHorizontalFix:["type",Ou],labelBehavior:["type",oh],messageFlowBehavior:["type",mh],modelingFeedback:["type",vh],replaceConnectionBehavior:["type",yh],removeParticipantBehavior:["type",gh],replaceElementBehaviour:["type",bh],resizeBehavior:["type",Ch],resizeLaneBehavior:["type",Dh],removeElementBehavior:["type",Bh],toggleElementCollapseBehaviour:["type",Fh],spaceToolBehavior:["type",jh],subProcessStartEventBehavior:["type",zh],unclaimIdBehavior:["type",$h],updateFlowNodeRefsBehavior:["type",Hh],unsetDefaultFlowBehavior:["type",Wh]};function Uh(e,t){var n=pn(e,t,-15);return"intersect"!==n?n:null}function qh(e){Za.call(this,e)}function Kh(e){return!e||so(e)}function Yh(e){do{if(Ar(e,"bpmn:Process"))return kr(e);if(Ar(e,"bpmn:Participant"))return kr(e).processRef||kr(e)}while(e=e.parent)}function Xh(e){return Ar(e,"bpmn:TextAnnotation")}function Zh(e){return Ar(e,"bpmn:Group")&&!e.labelTarget}function Qh(e){return Ar(e,"bpmn:BoundaryEvent")&&td(e,"bpmn:CompensateEventDefinition")}function Jh(e){return kr(e).isForCompensation}function ed(e){for(var t=e;t=t.parent;){if(Ar(t,"bpmn:FlowElementsContainer"))return kr(t);if(Ar(t,"bpmn:Participant"))return kr(t).processRef}return null}function td(e,t){return!!y(kr(e).eventDefinitions||[],(function(e){return Ar(e,t)}))}function nd(e,t){return(kr(e).eventDefinitions||[]).every((function(e){return Ar(e,t)}))}function id(e){return Ar(e,"bpmn:ReceiveTask")||Ar(e,"bpmn:IntermediateCatchEvent")&&(td(e,"bpmn:MessageEventDefinition")||td(e,"bpmn:TimerEventDefinition")||td(e,"bpmn:ConditionalEventDefinition")||td(e,"bpmn:SignalEventDefinition"))}function rd(e){return e.waypoints}function od(e,t){return-1!==function(e){for(var t=[];e;)(e=e.parent)&&t.push(e);return t}(t).indexOf(e)}function ad(e,t,n){if(Kh(e)||Kh(t))return null;if(!Ar(n,"bpmn:DataAssociation")){if(bd(e,t))return{type:"bpmn:MessageFlow"};if(xd(e,t))return{type:"bpmn:SequenceFlow"}}var i=_d(e,t);return i||(Qh(e)&&Jh(t)?{type:"bpmn:Association",associationDirection:"One"}:!!gd(e,t)&&{type:"bpmn:Association"})}function sd(e,t,n){return!(!so(e)&&!Zh(e))||!(Ar(t,"bpmn:Participant")&&!Mr(t))&&(Ar(e,"bpmn:Participant")?Ar(t,"bpmn:Process")||Ar(t,"bpmn:Collaboration"):Ha(e,["bpmn:DataInput","bpmn:DataOutput"])&&e.parent?t===e.parent:Ar(e,"bpmn:Lane")?Ar(t,"bpmn:Participant")||Ar(t,"bpmn:Lane"):!(Ar(e,"bpmn:BoundaryEvent")&&(i=e,!kr(i).cancelActivity||!ld(i)&&!ud(i)))&&(Ar(e,"bpmn:FlowElement")&&!Ar(e,"bpmn:DataStoreReference")?Ar(t,"bpmn:FlowElementsContainer")?Mr(t):Ha(t,["bpmn:Participant","bpmn:Lane"]):Ar(e,"bpmn:DataStoreReference")&&Ar(t,"bpmn:Collaboration")?w(kr(t).get("participants"),(function(e){return!!e.get("processRef")})):Ha(e,["bpmn:Artifact","bpmn:DataAssociation","bpmn:DataStoreReference"])?Ha(t,["bpmn:Collaboration","bpmn:Lane","bpmn:Participant","bpmn:Process","bpmn:SubProcess"]):!!Ar(e,"bpmn:MessageFlow")&&(Ar(t,"bpmn:Collaboration")||e.source.parent==t||e.target.parent==t)));var i}function cd(e){return Ar(e,"bpmn:Lane")}function pd(e){return!!function(e){return!so(e)&&Ar(e,"bpmn:BoundaryEvent")}(e)||(!(!Ar(e,"bpmn:IntermediateThrowEvent")||!ld(e))||Ar(e,"bpmn:IntermediateCatchEvent")&&ud(e))}function ld(e){var t=kr(e);return t&&!(t.eventDefinitions&&t.eventDefinitions.length)}function ud(e){return hd(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])}function hd(e,t){return t.some((function(t){return td(e,t)}))}function dd(e,t,n,i){if(Array.isArray(e)||(e=[e]),1!==e.length)return!1;var r=e[0];return!so(r)&&(!!pd(r)&&(!Dr(t)&&(!(!Ar(t,"bpmn:Activity")||Jh(t))&&(!(i&&!Uh(i,t))&&(!function(e){return Ar(e,"bpmn:ReceiveTask")&&y(e.incoming,(function(e){return Ar(e.source,"bpmn:EventBasedGateway")}))}(t)&&"attach")))))}function fd(e,t,n){if(!t)return!1;var i={replacements:[]};return b(e,(function(e){Dr(t)||Ar(e,"bpmn:StartEvent")&&"label"!==e.type&&sd(e,t)&&(function(e){return e&&!1!==kr(e).isInterrupting}(e)||i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),(function(e){return Br(e,"bpmn:ErrorEventDefinition")}(e)||function(e){return Br(e,"bpmn:EscalationEventDefinition")}(e)||function(e){return Br(e,"bpmn:CompensateEventDefinition")}(e))&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),hd(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])&&Ar(t,"bpmn:SubProcess")&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"})),Ar(t,"bpmn:Transaction")||td(e,"bpmn:CancelEventDefinition")&&"label"!==e.type&&(Ar(e,"bpmn:EndEvent")&&sd(e,t)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:EndEvent"}),Ar(e,"bpmn:BoundaryEvent")&&dd(e,t,0,n)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:BoundaryEvent"}))})),!!i.replacements.length&&i}function md(e,t){return!w(e,cd)&&(!t||e.every((function(e){return sd(e,t)})))}function vd(e,t,n,i){return!!t&&(!(!so(e)&&!Zh(e))||n!==t&&((!n||!od(n,t))&&(sd(e,t)||Ed(e,t))))}function yd(e,t){return Ar(e,"bpmn:SubProcess")?Mr(e)&&(!t||t.width>=100&&t.height>=80):Ar(e,"bpmn:Lane")?!t||t.width>=130&&t.height>=60:Ar(e,"bpmn:Participant")?!t||t.width>=250&&t.height>=50:!!Xh(e)||!!Zh(e)}function gd(e,t){return!rd(e)&&!rd(t)&&(!(!Qh(e)||!Jh(t))||!od(t,e)&&!od(e,t)&&(!!function(e,t){var n=Xh(e),i=Xh(t);return(n||i)&&n!==i}(e,t)||!!_d(e,t)))}function bd(e,t){return!(Cd(e)&&!Cd(t))&&(Ar(i=e,"bpmn:InteractionNode")&&!Ar(i,"bpmn:BoundaryEvent")&&(!Ar(i,"bpmn:Event")||Ar(i,"bpmn:ThrowEvent")&&nd(i,"bpmn:MessageEventDefinition"))&&function(e){return Ar(e,"bpmn:InteractionNode")&&!Jh(e)&&(!Ar(e,"bpmn:Event")||Ar(e,"bpmn:CatchEvent")&&nd(e,"bpmn:MessageEventDefinition"))&&!(Ar(e,"bpmn:BoundaryEvent")&&!td(e,"bpmn:MessageEventDefinition"))}(t)&&(n=t,!(Yh(e)===Yh(n))));var n,i}function xd(e,t){return!(id(t)&&t.incoming.length>0&&(n=t.incoming,(n=n||[]).some(Sd))&&!Ar(e,"bpmn:EventBasedGateway"))&&(Ar(r=e,"bpmn:FlowNode")&&!Ar(r,"bpmn:EndEvent")&&!Dr(r)&&!(Ar(r,"bpmn:IntermediateThrowEvent")&&td(r,"bpmn:LinkEventDefinition"))&&!Qh(r)&&!Jh(r)&&function(e){return Ar(e,"bpmn:FlowNode")&&!Ar(e,"bpmn:StartEvent")&&!Ar(e,"bpmn:BoundaryEvent")&&!Dr(e)&&!(Ar(e,"bpmn:IntermediateCatchEvent")&&td(e,"bpmn:LinkEventDefinition"))&&!Jh(e)}(t)&&(i=t,ed(e)===ed(i))&&!(Ar(e,"bpmn:EventBasedGateway")&&!id(t)));var n,i,r}function _d(e,t){return Ha(e,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&Ha(t,["bpmn:Activity","bpmn:ThrowEvent"])?{type:"bpmn:DataInputAssociation"}:!(!Ha(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])||!Ha(e,["bpmn:Activity","bpmn:CatchEvent"]))&&{type:"bpmn:DataOutputAssociation"}}function Ed(e,t,n){if(!t)return!1;if(Array.isArray(e)){if(1!==e.length)return!1;e=e[0]}return t.source!==e&&t.target!==e&&(Ha(t,["bpmn:SequenceFlow","bpmn:MessageFlow"])&&!so(t)&&Ar(e,"bpmn:FlowNode")&&!Ar(e,"bpmn:BoundaryEvent")&&sd(e,t.parent))}function wd(e,t){return!!so(t)||!(Ar(t,"bpmn:Lane")&&!function(e,t){return e&&t&&-1!==e.indexOf(t)}(e,t.parent))}function Sd(e){if(e&&e.source)return Ar(e.source,"bpmn:EventBasedGateway")}function Cd(e){return Ga(e,"bpmn:Process")||Ga(e,"bpmn:Collaboration")}n(qh,Za),qh.$inject=["eventBus"],qh.prototype.init=function(){this.addRule("connection.start",(function(e){return function(e){if(Kh(e))return null;return Ha(e,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference","bpmn:Group","bpmn:TextAnnotation"])}(e.source)})),this.addRule("connection.create",(function(e){var t=e.source,n=e.target,i=e.hints||{},r=i.targetParent;if(i.targetAttach)return!1;r&&(n.parent=r);try{return ad(t,n)}finally{r&&(n.parent=null)}})),this.addRule("connection.reconnect",(function(e){var t=e.connection;return ad(e.source,e.target,t)})),this.addRule("connection.updateWaypoints",(function(e){return{type:e.connection.type}})),this.addRule("shape.resize",(function(e){return yd(e.shape,e.newBounds)})),this.addRule("elements.create",(function(e){var t=e.elements,n=e.position,i=e.target;return!(rd(i)&&!Ed(t,i))&&E(t,(function(e){return rd(e)?ad(e.source,e.target,e):e.host?dd(e,e.host,null,n):vd(e,i,null)}))})),this.addRule("elements.move",(function(e){var t=e.target,n=e.shapes,i=e.position;return dd(n,t,null,i)||fd(n,t,i)||md(n,t)||Ed(n,t)})),this.addRule("shape.create",(function(e){return vd(e.shape,e.target,e.source,e.position)})),this.addRule("shape.attach",(function(e){return dd(e.shape,e.target,null,e.position)})),this.addRule("element.copy",(function(e){var t=e.element;return wd(e.elements,t)}))},qh.prototype.canConnectMessageFlow=bd,qh.prototype.canConnectSequenceFlow=xd,qh.prototype.canConnectDataAssociation=_d,qh.prototype.canConnectAssociation=gd,qh.prototype.canMove=md,qh.prototype.canAttach=dd,qh.prototype.canReplace=fd,qh.prototype.canDrop=sd,qh.prototype.canInsert=Ed,qh.prototype.canCreate=vd,qh.prototype.canConnect=ad,qh.prototype.canResize=yd,qh.prototype.canCopy=wd;var Td={__depends__:[hs],__init__:["bpmnRules"],bpmnRules:["type",qh]};function Rd(e,t){e.on("saveXML.start",2e3,(function(){var e,n,i=t.getRootElement(),r=kr(i).di;e=g(e=ct([i],!1),(function(e){return e!==i&&!e.labelTarget})),n=S(e,Lr),r.set("planeElement",n)}))}Rd.$inject=["eventBus","canvas"];var Pd={__init__:["bpmnDiOrdering"],bpmnDiOrdering:["type",Rd]};function Ad(e){Ka.call(this,e);var t=this;this.preExecute(["shape.create","connection.create"],(function(e){var n=e.context,i=n.shape||n.connection,r=n.parent,o=t.getOrdering(i,r);o&&(void 0!==o.parent&&(n.parent=o.parent),n.parentIndex=o.index)})),this.preExecute(["shape.move","connection.move"],(function(e){var n=e.context,i=n.shape||n.connection,r=n.newParent||i.parent,o=t.getOrdering(i,r);o&&(void 0!==o.parent&&(n.newParent=o.parent),n.newParentIndex=o.index)}))}function kd(e,t,n){Ad.call(this,e);var i=[{type:"bpmn:SubProcess",order:{level:6}},{type:"bpmn:SequenceFlow",order:{level:3,containers:["bpmn:Participant","bpmn:FlowElementsContainer"]}},{type:"bpmn:DataAssociation",order:{level:9,containers:["bpmn:Collaboration","bpmn:Process"]}},{type:"bpmn:MessageFlow",order:{level:9,containers:["bpmn:Collaboration"]}},{type:"bpmn:Association",order:{level:6,containers:["bpmn:Participant","bpmn:FlowElementsContainer","bpmn:Collaboration"]}},{type:"bpmn:BoundaryEvent",order:{level:8}},{type:"bpmn:Group",order:{level:10,containers:["bpmn:Collaboration","bpmn:Process"]}},{type:"bpmn:FlowElement",order:{level:5}},{type:"bpmn:Participant",order:{level:-2}},{type:"bpmn:Lane",order:{level:-1}}];function r(e){var t=e.order;if(t||(e.order=t=function(e){if(e.labelTarget)return{level:10};var t=y(i,(function(t){return Ha(e,[t.type])}));return t&&t.order||{level:1}}(e)),!t)throw new Error("no order for <"+e.id+">");return t}this.getOrdering=function(e,n){if(e.labelTarget)return{parent:t.getRootElement(),index:-1};var i=r(e);i.containers&&(n=function(e,t,n){for(var i=t;i&&!Ha(i,n);)i=i.parent;if(!i)throw new Error("no parent for <"+e.id+"> in <"+(t&&t.id)+">");return i}(e,n,i.containers));var o=n.children.indexOf(e),a=function(e,t){t=N(t);var n=u(e)?-1:void 0;return b(e,(function(e,i){if(t(e,i))return n=i,!1})),n}(n.children,(function(t){return!(!e.labelTarget&&t.labelTarget)&&i.level<r(t).level}));return-1!==a&&-1!==o&&o<a&&(a-=1),{index:a,parent:n}}}Ad.prototype.getOrdering=function(e,t){return null},n(Ad,Ka),kd.$inject=["eventBus","canvas","translate"],n(kd,Ad);var Md={__depends__:[to],__init__:["bpmnOrderingProvider"],bpmnOrderingProvider:["type",kd]};function Dd(e,t){this._handlerMap={},this._stack=[],this._stackIdx=-1,this._currentExecution={actions:[],dirty:[],trigger:null},this._injector=t,this._eventBus=e,this._uid=1,e.on(["diagram.destroy","diagram.clear"],(function(){this.clear(!1)}),this)}Dd.$inject=["eventBus","injector"],Dd.prototype.execute=function(e,t){if(!e)throw new Error("command required");this._currentExecution.trigger="execute";var n={command:e,context:t};this._pushAction(n),this._internalExecute(n),this._popAction(n)},Dd.prototype.canExecute=function(e,t){var n={command:e,context:t},i=this._getHandler(e),r=this._fire(e,"canExecute",n);if(void 0===r){if(!i)return!1;i.canExecute&&(r=i.canExecute(t))}return r},Dd.prototype.clear=function(e){this._stack.length=0,this._stackIdx=-1,!1!==e&&this._fire("changed",{trigger:"clear"})},Dd.prototype.undo=function(){var e,t=this._getUndoAction();if(t){for(this._currentExecution.trigger="undo",this._pushAction(t);t&&(this._internalUndo(t),(e=this._getUndoAction())&&e.id===t.id);)t=e;this._popAction()}},Dd.prototype.redo=function(){var e,t=this._getRedoAction();if(t){for(this._currentExecution.trigger="redo",this._pushAction(t);t&&(this._internalExecute(t,!0),(e=this._getRedoAction())&&e.id===t.id);)t=e;this._popAction()}},Dd.prototype.register=function(e,t){this._setHandler(e,t)},Dd.prototype.registerHandler=function(e,t){if(!e||!t)throw new Error("command and handlerCls must be defined");var n=this._injector.instantiate(t);this.register(e,n)},Dd.prototype.canUndo=function(){return!!this._getUndoAction()},Dd.prototype.canRedo=function(){return!!this._getRedoAction()},Dd.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]},Dd.prototype._getUndoAction=function(){return this._stack[this._stackIdx]},Dd.prototype._internalUndo=function(e){var t=this,n=e.command,i=e.context,r=this._getHandler(n);this._atomicDo((function(){t._fire(n,"revert",e),r.revert&&t._markDirty(r.revert(i)),t._revertedAction(e),t._fire(n,"reverted",e)}))},Dd.prototype._fire=function(e,t,n){arguments.length<3&&(n=t,t=null);var i,r,o,a=t?[e+"."+t,t]:[e];for(n=this._eventBus.createEvent(n),i=0;(r=a[i])&&(o=this._eventBus.fire("commandStack."+r,n),!n.cancelBubble);i++);return o},Dd.prototype._createId=function(){return this._uid++},Dd.prototype._atomicDo=function(e){var t=this._currentExecution;t.atomic=!0;try{e()}finally{t.atomic=!1}},Dd.prototype._internalExecute=function(e,t){var n=this,i=e.command,r=e.context,o=this._getHandler(i);if(!o)throw new Error("no command handler registered for <"+i+">");this._pushAction(e),t||(this._fire(i,"preExecute",e),o.preExecute&&o.preExecute(r),this._fire(i,"preExecuted",e)),this._atomicDo((function(){n._fire(i,"execute",e),o.execute&&n._markDirty(o.execute(r)),n._executedAction(e,t),n._fire(i,"executed",e)})),t||(this._fire(i,"postExecute",e),o.postExecute&&o.postExecute(r),this._fire(i,"postExecuted",e)),this._popAction(e)},Dd.prototype._pushAction=function(e){var t=this._currentExecution,n=t.actions,i=n[0];if(t.atomic)throw new Error("illegal invocation in <execute> or <revert> phase (action: "+e.command+")");e.id||(e.id=i&&i.id||this._createId()),n.push(e)},Dd.prototype._popAction=function(){var e=this._currentExecution,t=e.trigger,n=e.actions,i=e.dirty;n.pop(),n.length||(this._eventBus.fire("elements.changed",{elements:A("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:t}),e.trigger=null)},Dd.prototype._markDirty=function(e){var t=this._currentExecution;e&&(e=u(e)?e:[e],t.dirty=t.dirty.concat(e))},Dd.prototype._executedAction=function(e,t){var n=++this._stackIdx;t||this._stack.splice(n,this._stack.length,e)},Dd.prototype._revertedAction=function(e){this._stackIdx--},Dd.prototype._getHandler=function(e){return this._handlerMap[e]},Dd.prototype._setHandler=function(e,t){if(!e||!t)throw new Error("command and handler required");if(this._handlerMap[e])throw new Error("overriding handler for command <"+e+">");this._handlerMap[e]=t};var Bd={commandStack:["type",Dd]},Nd=new Oo("tt");function Od(e,t){e.style.display=!1===t?"none":""}var jd=".djs-tooltip";function Ld(e,t){var n,i;this._eventBus=e,this._canvas=t,this._ids=Nd,this._tooltipDefaults={show:{minZoom:.7,maxZoom:5}},this._tooltips={},this._tooltipRoot=(n=t.getContainer(),i=ce('<div class="djs-tooltip-container" style="position: absolute; width: 0; height: 0;" />'),n.insertBefore(i,n.firstChild),i);var r=this;se.bind(this._tooltipRoot,jd,"mousedown",(function(e){e.stopPropagation()})),se.bind(this._tooltipRoot,jd,"mouseover",(function(e){r.trigger("mouseover",e)})),se.bind(this._tooltipRoot,jd,"mouseout",(function(e){r.trigger("mouseout",e)})),this._init()}Ld.$inject=["eventBus","canvas"],Ld.prototype.add=function(e){if(!e.position)throw new Error("must specifiy tooltip position");if(!e.html)throw new Error("must specifiy tooltip html");var t=this._ids.next();return e=F({},this._tooltipDefaults,e,{id:t}),this._addTooltip(e),e.timeout&&this.setTimeout(e),t},Ld.prototype.trigger=function(e,t){var n=t.delegateTarget||t.target,i=this.get(G(n,"data-tooltip-id"));i&&("mouseover"===e&&i.timeout&&this.clearTimeout(i),"mouseout"===e&&i.timeout&&(i.timeout=1e3,this.setTimeout(i)))},Ld.prototype.get=function(e){return"string"!=typeof e&&(e=e.id),this._tooltips[e]},Ld.prototype.clearTimeout=function(e){if(e=this.get(e)){var t=e.removeTimer;t&&(clearTimeout(t),e.removeTimer=null)}},Ld.prototype.setTimeout=function(e){if(e=this.get(e)){this.clearTimeout(e);var t=this;e.removeTimer=setTimeout((function(){t.remove(e)}),e.timeout)}},Ld.prototype.remove=function(e){var t=this.get(e);t&&(de(t.html),de(t.htmlContainer),delete t.htmlContainer,delete this._tooltips[t.id])},Ld.prototype.show=function(){Od(this._tooltipRoot)},Ld.prototype.hide=function(){Od(this._tooltipRoot,!1)},Ld.prototype._updateRoot=function(e){var t=e.scale||1,n=e.scale||1,i="matrix("+t+",0,0,"+n+","+-1*e.x*t+","+-1*e.y*n+")";this._tooltipRoot.style.transform=i,this._tooltipRoot.style["-ms-transform"]=i},Ld.prototype._addTooltip=function(e){var t,n=e.id,i=e.html,r=this._tooltipRoot;i.get&&i.constructor.prototype.jquery&&(i=i.get(0)),m(i)&&(i=ce(i)),(t=ce('<div data-tooltip-id="'+n+'" class="'+'djs-tooltip" style="position: absolute">')).appendChild(i),e.type&&K(t).add("djs-tooltip-"+e.type),e.className&&K(t).add(e.className),e.htmlContainer=t,r.appendChild(t),this._tooltips[n]=e,this._updateTooltip(e)},Ld.prototype._updateTooltip=function(e){var t,n,i,r=e.position,o=e.htmlContainer;t=o,n=r.x,i=r.y,F(t.style,{left:n+"px",top:i+"px"})},Ld.prototype._updateTooltipVisibilty=function(e){b(this._tooltips,(function(t){var n=t.show,i=t.htmlContainer,r=!0;n&&((n.minZoom>e.scale||n.maxZoom<e.scale)&&(r=!1),Od(i,r))}))},Ld.prototype._init=function(){var e=this;this._eventBus.on("canvas.viewbox.changing",(function(t){e.hide()})),this._eventBus.on("canvas.viewbox.changed",(function(t){var n;n=t.viewbox,e._updateRoot(n),e._updateTooltipVisibilty(n),e.show()}))};var Id={__init__:["tooltips"],tooltips:["type",Ld]};function zd(e,t){if("function"!=typeof t)throw new Error("removeFn iterator must be a function");if(e){for(var n;n=e[0];)t(n);return e}}function Fd(e,t,n){Ka.call(this,t);var i=e.get("movePreview",!1);t.on("shape.move.start",1400,(function(e){var t=e.context,n=t.shapes,i=t.validatedShapes;t.shapes=$d(n),t.validatedShapes=$d(i)})),i&&t.on("shape.move.start",250,(function(e){var t=e.context,n=t.shapes,r=[];b(n,(function(e){b(e.labels,(function(n){n.hidden||-1!==t.shapes.indexOf(n)||r.push(n),e.labelTarget&&r.push(e)}))})),b(r,(function(e){i.makeDraggable(t,e,!0)}))})),this.preExecuted("elements.move",1400,(function(e){var t=e.context.closure,n=t.enclosedElements,i=[];b(n,(function(e){b(e.labels,(function(e){n[e.id]||i.push(e)}))})),t.addAll(i)})),this.preExecute(["connection.delete","shape.delete"],(function(e){var t=e.context;zd((t.connection||t.shape).labels,(function(e){n.removeShape(e,{nested:!0})}))})),this.execute("shape.delete",(function(e){var t=e.context,n=t.shape,i=n.labelTarget;i&&(t.labelTargetIndex=yt(i.labels,n),t.labelTarget=i,n.labelTarget=null)})),this.revert("shape.delete",(function(e){var t=e.context,n=t.shape,i=t.labelTarget,r=t.labelTargetIndex;i&&(vt(i.labels,n,r),n.labelTarget=i)}))}function $d(e){return g(e,(function(t){return-1===e.indexOf(t.labelTarget)}))}n(Fd,Ka),Fd.$inject=["injector","eventBus","modeling"];var Hd={__init__:["labelSupport"],labelSupport:["type",Fd]},Gd="attach-ok";function Wd(e,t,n,i,r){Ka.call(this,t);var o=e.get("movePreview",!1);t.on("shape.move.start",1401,(function(e){var t,n,i=e.context,r=i.shapes,o=i.validatedShapes;i.shapes=(n=Vd(t=r),k("id",t,n)),i.validatedShapes=function(e){var t=P(e,"id");return g(e,(function(e){for(;e;){if(e.host&&t[e.host.id])return!1;e=e.parent}return!0}))}(o)})),o&&t.on("shape.move.start",251,(function(e){var t=e.context;b(Vd(t.shapes),(function(e){o.makeDraggable(t,e,!0),b(e.labels,(function(e){o.makeDraggable(t,e,!0)}))}))})),o&&t.on("shape.move.start",(function(e){var i=e.context.shapes;if(1===i.length){var r=i[0].host;r&&(n.addMarker(r,Gd),t.once(["shape.move.out","shape.move.cleanup"],(function(){n.removeMarker(r,Gd)})))}})),this.preExecuted("elements.move",1401,(function(e){var t=e.context,n=t.closure;b(Vd(t.shapes),(function(e){n.add(e,n.topLevel[e.host.id])}))})),this.postExecuted("elements.move",(function(e){var t=e.context,n=t.shapes,i=t.newHost;i&&1!==n.length||b(i?n:g(n,(function(e){var t,i=e.host;return function(e){return!!e.host}(e)&&(t=i,!(-1!==n.indexOf(t)))})),(function(e){r.updateAttachment(e,i)}))})),this.postExecuted("elements.move",(function(e){b(e.context.shapes,(function(e){b(e.attachers,(function(e){b(e.outgoing.slice(),(function(e){i.allowed("connection.reconnect",{connection:e,source:e.source,target:e.target})||r.removeConnection(e)})),b(e.incoming.slice(),(function(e){i.allowed("connection.reconnect",{connection:e,source:e.source,target:e.target})||r.removeConnection(e)}))}))}))})),this.postExecute("shape.create",(function(e){var t=e.context,n=t.shape,i=t.host;i&&r.updateAttachment(n,i)})),this.postExecute("shape.replace",(function(e){var t=e.context,n=t.oldShape,o=t.newShape;zd(n.attachers,(function(e){"attach"===i.allowed("elements.move",{target:o,shapes:[e]})?r.updateAttachment(e,o):r.removeShape(e)})),o.attachers.length&&b(o.attachers,(function(e){var t=th(e,n,o);r.moveShape(e,t,e.parent)}))})),this.postExecute("shape.resize",(function(e){var t=e.context,n=t.shape,i=t.oldBounds,o=t.newBounds,a=n.attachers;!1!==(t.hints||{}).attachSupport&&b(a,(function(e){var t=th(e,i,o);r.moveShape(e,t,e.parent),b(e.labels,(function(e){r.moveShape(e,t,e.parent)}))}))})),this.preExecute("shape.delete",(function(e){var t=e.context.shape;zd(t.attachers,(function(e){r.removeShape(e)})),t.host&&r.updateAttachment(t,null)}))}function Vd(e){return o(S(e,(function(e){return e.attachers||[]})))}n(Wd,Ka),Wd.$inject=["injector","eventBus","canvas","rules","modeling"];var Ud={__depends__:[hs],__init__:["attachSupport"],attachSupport:["type",Wd]};function qd(e,t){this._eventBus=e,this._dragging=t,this._tools=[],this._active=null}qd.$inject=["eventBus","dragging"],qd.prototype.registerTool=function(e,t){var n=this._tools;if(!t)throw new Error('A tool has to be registered with it\'s "events"');n.push(e),this.bindEvents(e,t)},qd.prototype.isActive=function(e){return e&&this._active===e},qd.prototype.length=function(e){return this._tools.length},qd.prototype.setActive=function(e){var t=this._eventBus;this._active!==e&&(this._active=e,t.fire("tool-manager.update",{tool:e}))},qd.prototype.bindEvents=function(e,t){var n=this._eventBus,i=this._dragging,r=[];n.on(t.tool+".init",(function(t){if(!t.context.reactivate&&this.isActive(e))return this.setActive(null),void i.cancel();this.setActive(e)}),this),b(t,(function(e){r.push(e+".ended"),r.push(e+".canceled")})),n.on(r,250,(function(e){this._active&&(function(e){var t=e.originalEvent&&e.originalEvent.target;return t&&ee(t,'.group[data-group="tools"]')}(e)||this.setActive(null))}),this)};var Kd={__depends__:[ss],__init__:["toolManager"],toolManager:["type",qd]};function Yd(e,t){return-1!==e.indexOf(t)}var Xd=Math.abs,Zd=Math.round,Qd={x:"width",y:"height"},Jd="crosshair",ef={n:"top",w:"left",s:"bottom",e:"right"},tf={n:"s",w:"e",s:"n",e:"w"};function nf(e,t,n,i,r,o,a){this._canvas=e,this._dragging=t,this._eventBus=n,this._modeling=i,this._rules=r,this._toolManager=o,this._mouse=a;var s=this;o.registerTool("space",{tool:"spaceTool.selection",dragging:"spaceTool"}),n.on("spaceTool.selection.end",(function(e){n.once("spaceTool.selection.ended",(function(){s.activateMakeSpace(e.originalEvent)}))})),n.on("spaceTool.move",1500,(function(e){var t=e.context,n=t.initialized;n||(n=t.initialized=s.init(e,t)),n&&of(e)})),n.on("spaceTool.end",(function(e){var t=e.context,i=t.axis,r=t.direction,o=t.movingShapes,a=t.resizingShapes,c=t.start;if(t.initialized){of(e);var p={x:0,y:0};p[i]=Zd(e["d"+i]),s.makeSpace(o,a,p,r,c),n.once("spaceTool.ended",(function(e){s.activateSelection(e.originalEvent,!0,!0)}))}}))}function rf(e){return{top:e.top-20,right:e.right+20,bottom:e.bottom+20,left:e.left-20}}function of(e){var t,n,i=e.context.spaceToolConstraints;i&&(d(i.left)&&(t=Math.max(e.x,i.left),e.dx=e.dx+t-e.x,e.x=t),d(i.right)&&(t=Math.min(e.x,i.right),e.dx=e.dx+t-e.x,e.x=t),d(i.top)&&(n=Math.max(e.y,i.top),e.dy=e.dy+n-e.y,e.y=n),d(i.bottom)&&(n=Math.min(e.y,i.bottom),e.dy=e.dy+n-e.y,e.y=n))}function af(e,t){return-1!==e.indexOf(t)}function sf(e){return!!e.waypoints}function cf(e){return!!e.labelTarget}nf.$inject=["canvas","dragging","eventBus","modeling","rules","toolManager","mouse"],nf.prototype.activateSelection=function(e,t,n){this._dragging.init(e,"spaceTool.selection",{autoActivate:t,cursor:Jd,data:{context:{reactivate:n}},trapClick:!1})},nf.prototype.activateMakeSpace=function(e){this._dragging.init(e,"spaceTool",{autoActivate:!0,cursor:Jd,data:{context:{}}})},nf.prototype.makeSpace=function(e,t,n,i,r){return this._modeling.createSpace(e,t,n,i,r)},nf.prototype.init=function(e,t){var n=Xd(e.dx)>Xd(e.dy)?"x":"y",i=e["d"+n],r=e[n]-i;if(Xd(i)<5)return!1;i<0&&(i*=-1),xo(e)&&(i*=-1);var o=function(e,t){if("x"===e){if(t>0)return"e";if(t<0)return"w"}if("y"===e){if(t>0)return"s";if(t<0)return"n"}return null}(n,i),a=ct(this._canvas.getRootElement(),!0),s=this.calculateAdjustments(a,n,i,r);return F(t,s,{axis:n,direction:o,spaceToolConstraints:function(e,t,n,i,r){var o=e.movingShapes,a=e.resizingShapes;if(!a.length)return;var s,c,p={};return b(a,(function(e){var l,u,h,f=an(e),m=g(e.children,(function(e){return!(sf(e)||cf(e)||af(o,e)||af(a,e))})),v=g(e.children,(function(e){return!sf(e)&&!cf(e)&&af(o,e)}));m.length&&(u=rf(an(pt(m))),l=i-f[ef[n]]+u[ef[n]],"n"===n?p.bottom=c=d(c)?Math.min(c,l):l:"w"===n?p.right=c=d(c)?Math.min(c,l):l:"s"===n?p.top=s=d(s)?Math.max(s,l):l:"e"===n&&(p.left=s=d(s)?Math.max(s,l):l)),v.length&&(h=rf(an(pt(v))),l=i-h[ef[tf[n]]]+f[ef[tf[n]]],"n"===n?p.bottom=c=d(c)?Math.min(c,l):l:"w"===n?p.right=c=d(c)?Math.min(c,l):l:"s"===n?p.top=s=d(s)?Math.max(s,l):l:"e"===n&&(p.left=s=d(s)?Math.max(s,l):l));var y=r&&r[e.id];y&&("n"===n?(l=i+e[Qd[t]]-y[Qd[t]],p.bottom=c=d(c)?Math.min(c,l):l):"w"===n?(l=i+e[Qd[t]]-y[Qd[t]],p.right=c=d(c)?Math.min(c,l):l):"s"===n?(l=i-e[Qd[t]]+y[Qd[t]],p.top=s=d(s)?Math.max(s,l):l):"e"===n&&(l=i-e[Qd[t]]+y[Qd[t]],p.left=s=d(s)?Math.max(s,l):l))})),p}(s,n,o,r,this._eventBus.fire("spaceTool.getMinDimensions",{axis:n,direction:o,shapes:s.resizingShapes,start:r})),start:r}),oa("resize-"+("x"===n?"ew":"ns")),!0},nf.prototype.calculateAdjustments=function(e,t,n,i){var r=this._rules,o=[],a=[];return b(e,(function(e){if(e.parent&&!sf(e)){var s=e[t],c=s+e[Qd[t]];return n>0&&s>i||n<0&&c<i?o.push(e):s<i&&c>i&&r.allowed("shape.resize",{shape:e})?a.push(e):void 0}})),{movingShapes:o,resizingShapes:a}},nf.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},nf.prototype.isActive=function(){var e=this._dragging.context();return e&&/^spaceTool/.test(e.prefix)};var pf="djs-dragging",lf="djs-resizing",uf=Math.max;function hf(e,t,n,i,r){function o(e,t){b(e,(function(e){r.addDragger(e,t),n.addMarker(e,pf)}))}e.on("spaceTool.selection.start",(function(e){var t=n.getLayer("space"),r=e.context,o="M 0,-10000 L 0,10000",a="M -10000,0 L 10000,0",s=Me("g");ge(s,i.cls("djs-crosshair-group",["no-events"])),me(t,s);var c=Me("path");ge(c,"d",o),we(c).add("djs-crosshair"),me(s,c);var p=Me("path");ge(p,"d",a),we(p).add("djs-crosshair"),me(s,p),r.crosshairGroup=s})),e.on("spaceTool.selection.move",(function(e){Vn(e.context.crosshairGroup,e.x,e.y)})),e.on("spaceTool.selection.cleanup",(function(e){var t=e.context.crosshairGroup;t&&Ce(t)})),e.on("spaceTool.move",250,(function(e){var a=e.context,s=a.line,c=a.axis,p=a.movingShapes,l=a.resizingShapes;if(a.initialized){if(!a.dragGroup){var u=n.getLayer("space");ge(s=Me("path"),"d","M0,0 L0,0"),we(s).add("djs-crosshair"),me(u,s),a.line=s;var h=Me("g");ge(h,i.cls("djs-drag-group",["no-events"])),me(n.getActiveLayer(),h),o(p,h),o(a.movingConnections=t.filter((function(e){var t=!1;b(p,(function(n){b(n.outgoing,(function(n){e===n&&(t=!0)}))}));var n=!1;b(p,(function(t){b(t.incoming,(function(t){e===t&&(n=!0)}))}));var i=!1;b(l,(function(t){b(t.outgoing,(function(t){e===t&&(i=!0)}))}));var r=!1;return b(l,(function(t){b(t.incoming,(function(t){e===t&&(r=!0)}))})),function(e){return e.waypoints}(e)&&(t||i)&&(n||r)})),h),a.dragGroup=h}if(!a.frameGroup){var d=Me("g");ge(d,i.cls("djs-frame-group",["no-events"])),me(n.getActiveLayer(),d);var f=[];b(l,(function(e){var t=r.addFrame(e,d),i=t.getBBox();f.push({element:t,initialBounds:i}),n.addMarker(e,lf)})),a.frameGroup=d,a.frames=f}ge(s,{d:{x:"M"+e.x+", -10000 L"+e.x+", 10000",y:"M -10000, "+e.y+" L 10000, "+e.y}[c]});var m={x:e.dx,y:e.dy};m[{x:"y",y:"x"}[a.axis]]=0,Vn(a.dragGroup,m.x,m.y),b(a.frames,(function(e){var t,n,i=e.element,r=e.initialBounds;"e"===a.direction?ge(i,{width:uf(r.width+m.x,5)}):ge(i,{width:t=uf(r.width-m.x,5),x:r.x+r.width-t}),"s"===a.direction?ge(i,{height:uf(r.height+m.y,5)}):ge(i,{height:n=uf(r.height-m.y,5),y:r.y+r.height-n})}))}})),e.on("spaceTool.cleanup",(function(e){var t=e.context,i=t.movingShapes,r=t.movingConnections,o=t.resizingShapes,a=t.line,s=t.dragGroup,c=t.frameGroup;b(i,(function(e){n.removeMarker(e,pf)})),b(r,(function(e){n.removeMarker(e,pf)})),s&&(Ce(a),Ce(s)),b(o,(function(e){n.removeMarker(e,lf)})),c&&Ce(c)}))}hf.$inject=["eventBus","elementRegistry","canvas","styles","previewSupport"];var df={__init__:["spaceToolPreview"],__depends__:[ss,hs,Kd,Rc,Uc],spaceTool:["type",nf],spaceToolPreview:["type",hf]};function ff(e){this._model=e}function mf(e,t,n,i){Ka.call(this,e),this._bpmnFactory=t,this._translate=i;var r=this;function o(e){b(e.context.oldRoot.children,(function(e){Ar(e,"bpmn:BaseElement")&&r.updateParent(e)}))}function a(e){var t=e.context.shape;Ar(t,"bpmn:BaseElement")&&r.updateBounds(t)}function s(e){r.updateConnection(e.context)}function c(e){r.updateConnectionWaypoints(e.context.connection)}function p(e){r.updateAttachment(e.context)}this.executed(["connection.layout","connection.create"],(function(e){var t,i=e.context,r=i.hints||{};i.cropped||!1===r.createElementsBehavior||((t=i.connection).waypoints=n.getCroppedWaypoints(t),i.cropped=!0)})),this.reverted(["connection.layout"],(function(e){delete e.context.cropped})),this.executed(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],vf((function(e){var t=e.context;r.updateParent(t.shape||t.connection,t.oldParent)}))),this.reverted(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],vf((function(e){var t=e.context,n=t.shape||t.connection,i=t.parent||t.newParent;r.updateParent(n,i)}))),this.executed(["canvas.updateRoot"],o),this.reverted(["canvas.updateRoot"],o),this.executed(["shape.move","shape.create","shape.resize"],vf((function(e){"label"!==e.context.shape.type&&a(e)}))),this.reverted(["shape.move","shape.create","shape.resize"],vf((function(e){"label"!==e.context.shape.type&&a(e)}))),e.on("shape.changed",(function(e){"label"===e.element.type&&a({context:{shape:e.element}})})),this.executed(["connection.create","connection.move","connection.delete","connection.reconnect"],vf(s)),this.reverted(["connection.create","connection.move","connection.delete","connection.reconnect"],vf(s)),this.executed(["connection.layout","connection.move","connection.updateWaypoints"],vf(c)),this.reverted(["connection.layout","connection.move","connection.updateWaypoints"],vf(c)),this.executed("connection.reconnect",vf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=kr(n),a=kr(i),s=kr(r);o.conditionExpression&&!Ha(s,["bpmn:Activity","bpmn:ExclusiveGateway","bpmn:InclusiveGateway"])&&(t.oldConditionExpression=o.conditionExpression,delete o.conditionExpression),i!==r&&a.default===o&&(t.oldDefault=a.default,delete a.default)}))),this.reverted("connection.reconnect",vf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=kr(n),a=kr(i),s=kr(r);t.oldConditionExpression&&(o.conditionExpression=t.oldConditionExpression),t.oldDefault&&(a.default=t.oldDefault,delete s.default)}))),this.executed(["element.updateAttachment"],vf(p)),this.reverted(["element.updateAttachment"],vf(p))}function vf(e){return function(t){var n=t.context;Ar(n.shape||n.connection,"bpmn:BaseElement")&&e(t)}}function yf(e,t,n){zn.call(this),this._bpmnFactory=e,this._moddle=t,this._translate=n}function gf(e,t,n){e[n]=t[n],delete t[n]}function bf(e,t){this._modeling=e,this._canvas=t}function xf(e){this._modeling=e}function _f(e,t){this._canvas=e,this._layouter=t}ff.$inject=["moddle"],ff.prototype._needsId=function(e){return Ha(e,["bpmn:RootElement","bpmn:FlowElement","bpmn:MessageFlow","bpmn:DataAssociation","bpmn:Artifact","bpmn:Participant","bpmn:Lane","bpmn:LaneSet","bpmn:Process","bpmn:Collaboration","bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane","bpmn:Property","bpmn:CategoryValue"])},ff.prototype._ensureId=function(e){var t;t=Ar(e,"bpmn:Activity")?"Activity":Ar(e,"bpmn:Event")?"Event":Ar(e,"bpmn:Gateway")?"Gateway":Ha(e,["bpmn:SequenceFlow","bpmn:MessageFlow"])?"Flow":(e.$type||"").replace(/^[^:]*:/g,""),t+="_",!e.id&&this._needsId(e)&&(e.id=this._model.ids.nextPrefixed(t,e))},ff.prototype.create=function(e,t){var n=this._model.create(e,t||{});return this._ensureId(n),n},ff.prototype.createDiLabel=function(){return this.create("bpmndi:BPMNLabel",{bounds:this.createDiBounds()})},ff.prototype.createDiShape=function(e,t,n){return this.create("bpmndi:BPMNShape",F({bpmnElement:e,bounds:this.createDiBounds(t)},n))},ff.prototype.createDiBounds=function(e){return this.create("dc:Bounds",e)},ff.prototype.createDiWaypoints=function(e){var t=this;return S(e,(function(e){return t.createDiWaypoint(e)}))},ff.prototype.createDiWaypoint=function(e){return this.create("dc:Point",$(e,["x","y"]))},ff.prototype.createDiEdge=function(e,t,n){return this.create("bpmndi:BPMNEdge",F({bpmnElement:e,waypoint:this.createDiWaypoints(t)},n))},ff.prototype.createDiPlane=function(e){return this.create("bpmndi:BPMNPlane",{bpmnElement:e})},n(mf,Ka),mf.$inject=["eventBus","bpmnFactory","connectionDocking","translate"],mf.prototype.updateAttachment=function(e){var t=e.shape,n=t.businessObject,i=t.host;n.attachedToRef=i&&i.businessObject},mf.prototype.updateParent=function(e,t){if(!(e instanceof jn||Ar(e,"bpmn:DataStoreReference")&&e.parent&&Ar(e.parent,"bpmn:Collaboration"))){var n=e.parent,i=e.businessObject,r=n&&n.businessObject,o=r&&r.di;Ar(e,"bpmn:FlowNode")&&this.updateFlowNodeRefs(i,r,t&&t.businessObject),Ar(e,"bpmn:DataOutputAssociation")&&(r=e.source?e.source.businessObject:null),Ar(e,"bpmn:DataInputAssociation")&&(r=e.target?e.target.businessObject:null),this.updateSemanticParent(i,r),Ar(e,"bpmn:DataObjectReference")&&i.dataObjectRef&&this.updateSemanticParent(i.dataObjectRef,r),this.updateDiParent(i.di,o)}},mf.prototype.updateBounds=function(e){var t=e.businessObject.di,n=e instanceof jn?this._getLabel(t):t,i=n.bounds;i||(i=this._bpmnFactory.createDiBounds(),n.set("bounds",i)),F(i,{x:e.x,y:e.y,width:e.width,height:e.height})},mf.prototype.updateFlowNodeRefs=function(e,t,n){n!==t&&(Ar(n,"bpmn:Lane")&&mt(n.get("flowNodeRef"),e),Ar(t,"bpmn:Lane")&&vt(t.get("flowNodeRef"),e))},mf.prototype.updateDiConnection=function(e,t,n){e.sourceElement&&e.sourceElement.bpmnElement!==t&&(e.sourceElement=t&&t.di),e.targetElement&&e.targetElement.bpmnElement!==n&&(e.targetElement=n&&n.di)},mf.prototype.updateDiParent=function(e,t){if(t&&!Ar(t,"bpmndi:BPMNPlane")&&(t=t.$parent),e.$parent!==t){var n=(t||e.$parent).get("planeElement");t?(n.push(e),e.$parent=t):(mt(n,e),e.$parent=null)}},mf.prototype.getLaneSet=function(e){var t,n;return Ar(e,"bpmn:Lane")?((t=e.childLaneSet)||(t=this._bpmnFactory.create("bpmn:LaneSet"),e.childLaneSet=t,t.$parent=e),t):(Ar(e,"bpmn:Participant")&&(e=e.processRef),(t=(n=e.get("laneSets"))[0])||((t=this._bpmnFactory.create("bpmn:LaneSet")).$parent=e,n.push(t)),t)},mf.prototype.updateSemanticParent=function(e,t,n){var i,r=this._translate;if(e.$parent!==t&&(!Ar(e,"bpmn:DataInput")&&!Ar(e,"bpmn:DataOutput")||(Ar(t,"bpmn:Participant")&&"processRef"in t&&(t=t.processRef),!("ioSpecification"in t)||t.ioSpecification!==e.$parent))){if(Ar(e,"bpmn:Lane"))t&&(t=this.getLaneSet(t)),i="lanes";else if(Ar(e,"bpmn:FlowElement")){if(t)if(Ar(t,"bpmn:Participant"))t=t.processRef;else if(Ar(t,"bpmn:Lane"))do{t=t.$parent.$parent}while(Ar(t,"bpmn:Lane"));i="flowElements"}else if(Ar(e,"bpmn:Artifact")){for(;t&&!Ar(t,"bpmn:Process")&&!Ar(t,"bpmn:SubProcess")&&!Ar(t,"bpmn:Collaboration");){if(Ar(t,"bpmn:Participant")){t=t.processRef;break}t=t.$parent}i="artifacts"}else if(Ar(e,"bpmn:MessageFlow"))i="messageFlows";else if(Ar(e,"bpmn:Participant")){i="participants";var o,a=e.processRef;a&&(o=function(e){for(;e&&!Ar(e,"bpmn:Definitions");)e=e.$parent;return e}(e.$parent||t),e.$parent&&(mt(o.get("rootElements"),a),a.$parent=null),t&&(vt(o.get("rootElements"),a),a.$parent=o))}else Ar(e,"bpmn:DataOutputAssociation")?i="dataOutputAssociations":Ar(e,"bpmn:DataInputAssociation")&&(i="dataInputAssociations");if(!i)throw new Error(r("no parent for {element} in {parent}",{element:e.id,parent:t.id}));var s;if(e.$parent&&mt(s=e.$parent.get(i),e),t?((s=t.get(i)).push(e),e.$parent=t):e.$parent=null,n){var c=n.get(i);mt(s,e),t&&(c||(c=[],t.set(i,c)),c.push(e))}}},mf.prototype.updateConnectionWaypoints=function(e){e.businessObject.di.set("waypoint",this._bpmnFactory.createDiWaypoints(e.waypoints))},mf.prototype.updateConnection=function(e){var t,n=e.connection,i=kr(n),r=kr(n.source),o=kr(n.target);if(Ar(i,"bpmn:DataAssociation"))Ar(i,"bpmn:DataInputAssociation")?(i.get("sourceRef")[0]=r,t=e.parent||e.newParent||o,this.updateSemanticParent(i,o,t)):Ar(i,"bpmn:DataOutputAssociation")&&(t=e.parent||e.newParent||r,this.updateSemanticParent(i,r,t),i.targetRef=o);else{var a=Ar(i,"bpmn:SequenceFlow");i.sourceRef!==r&&(a&&(mt(i.sourceRef&&i.sourceRef.get("outgoing"),i),r&&r.get("outgoing")&&r.get("outgoing").push(i)),i.sourceRef=r),i.targetRef!==o&&(a&&(mt(i.targetRef&&i.targetRef.get("incoming"),i),o&&o.get("incoming")&&o.get("incoming").push(i)),i.targetRef=o)}this.updateConnectionWaypoints(n),this.updateDiConnection(i.di,r,o)},mf.prototype._getLabel=function(e){return e.label||(e.label=this._bpmnFactory.createDiLabel()),e.label},n(yf,zn),yf.$inject=["bpmnFactory","moddle","translate"],yf.prototype.baseCreate=zn.prototype.create,yf.prototype.create=function(e,t){return"label"===e?this.baseCreate(e,F({type:"label"},no,t)):this.createBpmnElement(e,t)},yf.prototype.createBpmnElement=function(e,t){var n,i,r,o=this._translate,a=(t=t||{}).businessObject;if(!a){if(!t.type)throw new Error(o("no shape type specified"));a=this._bpmnFactory.create(t.type)}return a.di||(a.di="root"===e?this._bpmnFactory.createDiPlane(a,[],{id:a.id+"_di"}):"connection"===e?this._bpmnFactory.createDiEdge(a,[],{id:a.id+"_di"}):this._bpmnFactory.createDiShape(a,{},{id:a.id+"_di"})),Ar(a,"bpmn:Group")&&(t=F({isFrame:!0},t)),t.di&&(F(a.di,t.di),delete t.di),function(e,t,n){b(n,(function(n){void 0!==t[n]&&gf(e,t,n)}))}(a,t,["processRef","isInterrupting","associationDirection","isForCompensation"]),t.isExpanded&&gf(a.di,t,"isExpanded"),Ar(a,"bpmn:ExclusiveGateway")&&(a.di.isMarkerVisible=!0),t.eventDefinitionType&&(i=a.get("eventDefinitions")||[],r=this._bpmnFactory.create(t.eventDefinitionType,t.eventDefinitionAttrs),"bpmn:ConditionalEventDefinition"===t.eventDefinitionType&&(r.condition=this._bpmnFactory.create("bpmn:FormalExpression")),i.push(r),r.$parent=a,a.eventDefinitions=i,delete t.eventDefinitionType),n=this._getDefaultSize(a),t=F({businessObject:a,id:a.id},n,t),this.baseCreate(e,t)},yf.prototype._getDefaultSize=function(e){return Ar(e,"bpmn:SubProcess")?Mr(e)?{width:350,height:200}:{width:100,height:80}:Ar(e,"bpmn:Task")?{width:100,height:80}:Ar(e,"bpmn:Gateway")?{width:50,height:50}:Ar(e,"bpmn:Event")?{width:36,height:36}:Ar(e,"bpmn:Participant")?Mr(e)?{width:600,height:250}:{width:400,height:60}:Ar(e,"bpmn:Lane")?{width:400,height:100}:Ar(e,"bpmn:DataObjectReference")?{width:36,height:50}:Ar(e,"bpmn:DataStoreReference")?{width:50,height:50}:Ar(e,"bpmn:TextAnnotation")?{width:100,height:30}:Ar(e,"bpmn:Group")?{width:300,height:300}:{width:100,height:80}},yf.prototype.createParticipantShape=function(e){return h(e)||(e={isExpanded:e}),!1!==(e=F({type:"bpmn:Participant"},e||{})).isExpanded&&(e.processRef=this._bpmnFactory.create("bpmn:Process")),this.createShape(e)},bf.$inject=["modeling","canvas"],bf.prototype.preExecute=function(e){var t=this._modeling,n=e.elements,i=e.alignment;b(n,(function(e){var n={x:0,y:0};i.left?n.x=i.left-e.x:i.right?n.x=i.right-e.width-e.x:i.center?n.x=i.center-Math.round(e.width/2)-e.x:i.top?n.y=i.top-e.y:i.bottom?n.y=i.bottom-e.height-e.y:i.middle&&(n.y=i.middle-Math.round(e.height/2)-e.y),t.moveElements([e],n,e.parent)}))},bf.prototype.postExecute=function(e){},xf.$inject=["modeling"],xf.prototype.preExecute=function(e){var t=e.source;if(!t)throw new Error("source required");var n=e.target||t.parent,i=e.shape,r=e.hints||{};i=e.shape=this._modeling.createShape(i,e.position,n,{attach:r.attach}),e.shape=i},xf.prototype.postExecute=function(e){var t,n,i=e.hints||{};t=e.source,n=e.shape,w(t.outgoing,(function(e){return e.target===n}))||(i.connectionTarget===e.source?this._modeling.connect(e.shape,e.source,e.connection):this._modeling.connect(e.source,e.shape,e.connection))},_f.$inject=["canvas","layouter"],_f.prototype.execute=function(e){var t=e.connection,n=e.source,i=e.target,r=e.parent,o=e.parentIndex,a=e.hints;if(!n||!i)throw new Error("source and target required");if(!r)throw new Error("parent required");return t.source=n,t.target=i,t.waypoints||(t.waypoints=this._layouter.layoutConnection(t,a)),this._canvas.addConnection(t,r,o),t},_f.prototype.revert=function(e){var t=e.connection;return this._canvas.removeConnection(t),t.source=null,t.target=null,t};var Ef=Math.round;function wf(e){this._modeling=e}function Sf(e){return!!e.waypoints}wf.$inject=["modeling"],wf.prototype.preExecute=function(e){var t=e.elements,n=e.parent,i=e.parentIndex,r=e.position,o=e.hints,a=this._modeling;b(t,(function(e){d(e.x)||(e.x=0),d(e.y)||(e.y=0)}));var s=pt(t);b(t,(function(e){Sf(e)&&(e.waypoints=S(e.waypoints,(function(e){return{x:Ef(e.x-s.x-s.width/2+r.x),y:Ef(e.y-s.y-s.height/2+r.y)}}))),F(e,{x:Ef(e.x-s.x-s.width/2+r.x),y:Ef(e.y-s.y-s.height/2+r.y)})}));var c=rt(t),p={};b(t,(function(e){if(Sf(e))p[e.id]=d(i)?a.createConnection(p[e.source.id],p[e.target.id],i,e,e.parent||n,o):a.createConnection(p[e.source.id],p[e.target.id],e,e.parent||n,o);else{var t=F({},o);-1===c.indexOf(e)&&(t.autoResize=!1),p[e.id]=d(i)?a.createShape(e,$(e,["x","y","width","height"]),e.parent||n,i,t):a.createShape(e,$(e,["x","y","width","height"]),e.parent||n,t)}})),e.elements=R(p)};var Cf=Math.round;function Tf(e){this._canvas=e}function Rf(e){Tf.call(this,e)}Tf.$inject=["canvas"],Tf.prototype.execute=function(e){var t=e.shape,n=e.position,i=e.parent,r=e.parentIndex;if(!i)throw new Error("parent required");if(!n)throw new Error("position required");return void 0!==n.width?F(t,n):F(t,{x:n.x-Cf(t.width/2),y:n.y-Cf(t.height/2)}),this._canvas.addShape(t,i,r),t},Tf.prototype.revert=function(e){var t=e.shape;return this._canvas.removeShape(t),t},n(Rf,Tf),Rf.$inject=["canvas"];var Pf=Tf.prototype.execute;Rf.prototype.execute=function(e){var t=e.shape;return function(e){["width","height"].forEach((function(t){void 0===e[t]&&(e[t]=0)}))}(t),t.labelTarget=e.labelTarget,Pf.call(this,e)};var Af=Tf.prototype.revert;function kf(e,t){this._canvas=e,this._modeling=t}function Mf(e,t){this._modeling=e,this._elementRegistry=t}function Df(e,t){this._canvas=e,this._modeling=t}function Bf(e){this._modeling=e}Rf.prototype.revert=function(e){return e.shape.labelTarget=null,Af.call(this,e)},kf.$inject=["canvas","modeling"],kf.prototype.execute=function(e){var t=e.connection,n=t.parent;return e.parent=n,e.parentIndex=yt(n.children,t),e.source=t.source,e.target=t.target,this._canvas.removeConnection(t),t.source=null,t.target=null,t},kf.prototype.revert=function(e){var t=e.connection,n=e.parent,i=e.parentIndex;return t.source=e.source,t.target=e.target,vt(n.children,t,i),this._canvas.addConnection(t,n),t},Mf.$inject=["modeling","elementRegistry"],Mf.prototype.postExecute=function(e){var t=this._modeling,n=this._elementRegistry;b(e.elements,(function(e){n.get(e.id)&&(e.waypoints?t.removeConnection(e):t.removeShape(e))}))},Df.$inject=["canvas","modeling"],Df.prototype.preExecute=function(e){var t=this._modeling,n=e.shape;zd(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),zd(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})})),zd(n.children,(function(e){e.waypoints?t.removeConnection(e,{nested:!0}):t.removeShape(e,{nested:!0})}))},Df.prototype.execute=function(e){var t=this._canvas,n=e.shape,i=n.parent;return e.oldParent=i,e.oldParentIndex=yt(i.children,n),t.removeShape(n),n},Df.prototype.revert=function(e){var t=this._canvas,n=e.shape,i=e.oldParent,r=e.oldParentIndex;return vt(i.children,n,r),t.addShape(n,i),n},Bf.$inject=["modeling"];var Nf={x:"y",y:"x"};function Of(e,t){this._layouter=e,this._canvas=t}function jf(){}function Lf(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}function If(e){this._modeling=e}function zf(e){this._helper=new If(e)}function Ff(e){this._modeling=e,this._helper=new If(e)}function $f(e){this._modeling=e}function Hf(e){return e.original||e}function Gf(e,t){this._modeling=e,this._rules=t}function Wf(e){this._modeling=e}function Vf(e){this._modeling=e}function Uf(e){return F({},e)}function qf(e){switch(e){case"n":return"y";case"w":return"x";case"s":return"y";case"e":return"x"}}function Kf(e,t,n){var i=qf(n);return/e|s/.test(n)?e[i]>t:/n|w/.test(n)?e[i]<t:void 0}function Yf(e,t){return-1!==e.indexOf(t)}function Xf(e){this._modeling=e}function Zf(e){var t={};return b(e,(function(e){t[e.id]=e.hidden,e.children&&(t=F({},t,Zf(e.children)))})),t}function Qf(e,t){var n=[];return b(e,(function(e){e.hidden=t,n=n.concat(e),e.children&&(n=n.concat(Qf(e.children,e.collapsed||t)))})),n}function Jf(e,t){var n=[];return b(e,(function(e){e.hidden=t[e.id],n=n.concat(e),e.children&&(n=n.concat(Jf(e.children,t)))})),n}function em(e){this._modeling=e}function tm(e,t){return mt(e&&e.attachers,t)}function nm(e,t,n){if(e){var i=e.attachers;i||(e.attachers=i=[]),vt(i,t,n)}}function im(){}function rm(e,t,n){this._eventBus=e,this._elementFactory=t,this._commandStack=n;var i=this;e.on("diagram.init",(function(){i.registerHandlers(n)}))}function om(e){this._elementRegistry=e}function am(e,t){b(t,(function(t,n){e.set(n,t)}))}Bf.prototype.preExecute=function(e){var t=this._modeling,n=e.groups,i=e.axis,r=e.dimension;function o(e,t){e.range.min=Math.min(t[i],e.range.min),e.range.max=Math.max(t[i]+t[r],e.range.max)}function a(e){return e[i]+e[r]/2}function s(e){return e.length-1}function c(e){return e.max-e.min}var p,l,u=n[0],h=s(n),d=n[h],f=0;b(n,(function(e,p){var l,u,d;e.elements.length<2?p&&p!==n.length-1&&(o(e,e.elements[0]),f+=c(e.range)):(u=(l=M(e.elements,i))[0],p===h&&(u=l[s(l)]),d=a(u),e.range=null,b(l,(function(n){!function(e,n){var r={y:0};r[i]=e-a(n),r[i]&&(r[Nf[i]]=0,t.moveElements([n],r,n.parent))}(d,n),null!==e.range?o(e,n):e.range={min:n[i],max:n[i]+n[r]}})),p&&p!==n.length-1&&(f+=c(e.range)))})),l=Math.abs(d.range.min-u.range.max),(p=Math.round((l-f)/(n.length-1)))<n.length-1||b(n,(function(e,o){var a,s={};e!==u&&e!==d&&(a=n[o-1],e.range.max=0,b(e.elements,(function(n,o){s[Nf[i]]=0,s[i]=a.range.max-n[i]+p,e.range.min!==n[i]&&(s[i]+=n[i]-e.range.min),s[i]&&t.moveElements([n],s,n.parent),e.range.max=Math.max(n[i]+n[r],o?e.range.max:0)})))}))},Bf.prototype.postExecute=function(e){},Of.$inject=["layouter","canvas"],Of.prototype.execute=function(e){var t=e.connection;return F(e,{oldWaypoints:t.waypoints}),t.waypoints=this._layouter.layoutConnection(t,e.hints),t},Of.prototype.revert=function(e){var t=e.connection;return t.waypoints=e.oldWaypoints,t},jf.prototype.execute=function(e){var t=e.connection,n=e.delta,i=e.newParent||t.parent,r=e.newParentIndex,o=t.parent;return e.oldParent=o,e.oldParentIndex=mt(o.children,t),vt(i.children,t,r),t.parent=i,b(t.waypoints,(function(e){e.x+=n.x,e.y+=n.y,e.original&&(e.original.x+=n.x,e.original.y+=n.y)})),t},jf.prototype.revert=function(e){var t=e.connection,n=t.parent,i=e.oldParent,r=e.oldParentIndex,o=e.delta;return mt(n.children,t),vt(i.children,t,r),t.parent=i,b(t.waypoints,(function(e){e.x-=o.x,e.y-=o.y,e.original&&(e.original.x-=o.x,e.original.y-=o.y)})),t},Lf.prototype.add=function(e,t){return this.addAll([e],t)},Lf.prototype.addAll=function(e,t){return F(this,function(e,t,n){c(t)&&(t=!0),h(t)&&(n=t,t=!0);var i=ht((n=n||{}).allShapes),r=ht(n.allConnections),o=ht(n.enclosedElements),a=ht(n.enclosedConnections),s=ht(n.topLevel,t&&P(e,(function(e){return e.id})));function p(e){s[e.source.id]&&s[e.target.id]&&(s[e.id]=[e]),i[e.source.id]&&i[e.target.id]&&(a[e.id]=o[e.id]=e),r[e.id]=e}return st(e,(function(e){if(o[e.id]=e,!e.waypoints)return i[e.id]=e,b(e.incoming,p),b(e.outgoing,p),e.children;a[e.id]=r[e.id]=e})),{allShapes:i,allConnections:r,topLevel:s,enclosedConnections:a,enclosedElements:o}}(e,!!t,this)),this},If.prototype.moveRecursive=function(e,t,n){return e?this.moveClosure(this.getClosure(e),t,n):[]},If.prototype.moveClosure=function(e,t,n,i,r){var o=this._modeling,a=e.allShapes,s=e.allConnections,c=e.enclosedConnections,p=e.topLevel,l=!1;r&&r.parent===n&&(l=!0),b(a,(function(e){o.moveShape(e,t,p[e.id]&&!l&&n,{recurse:!1,layout:!1})})),b(s,(function(e){var i=!!a[e.source.id],r=!!a[e.target.id];c[e.id]&&i&&r?o.moveConnection(e,t,p[e.id]&&!l&&n):o.layoutConnection(e,{connectionStart:i&&ph(e,e.source,t),connectionEnd:r&&lh(e,e.target,t)})}))},If.prototype.getClosure=function(e){return(new Lf).addAll(e,!0)},zf.$inject=["modeling"],zf.prototype.preExecute=function(e){e.closure=this._helper.getClosure(e.shapes)},zf.prototype.postExecute=function(e){var t,n=e.hints;n&&n.primaryShape&&(t=n.primaryShape,n.oldParent=t.parent),this._helper.moveClosure(e.closure,e.delta,e.newParent,e.newHost,t)},Ff.$inject=["modeling"],Ff.prototype.execute=function(e){var t=e.shape,n=e.delta,i=e.newParent||t.parent,r=e.newParentIndex,o=t.parent;return e.oldBounds=$(t,["x","y","width","height"]),e.oldParent=o,e.oldParentIndex=mt(o.children,t),vt(i.children,t,r),F(t,{parent:i,x:t.x+n.x,y:t.y+n.y}),t},Ff.prototype.postExecute=function(e){var t=e.shape,n=e.delta,i=e.hints,r=this._modeling;!1!==i.layout&&(b(t.incoming,(function(e){r.layoutConnection(e,{connectionEnd:lh(e,t,n)})})),b(t.outgoing,(function(e){r.layoutConnection(e,{connectionStart:ph(e,t,n)})}))),!1!==i.recurse&&this.moveChildren(e)},Ff.prototype.revert=function(e){var t=e.shape,n=e.oldParent,i=e.oldParentIndex,r=e.delta;return vt(n.children,t,i),F(t,{parent:n,x:t.x-r.x,y:t.y-r.y}),t},Ff.prototype.moveChildren=function(e){var t=e.delta,n=e.shape;this._helper.moveRecursive(n.children,t,null)},Ff.prototype.getNewParent=function(e){return e.newParent||e.shape.parent},$f.$inject=["modeling"],$f.prototype.execute=function(e){var t=e.newSource,n=e.newTarget,i=e.connection,r=e.dockingOrPoints;if(!t&&!n)throw new Error("newSource or newTarget required");return u(r)&&(e.oldWaypoints=i.waypoints,i.waypoints=r),t&&(e.oldSource=i.source,i.source=t),n&&(e.oldTarget=i.target,i.target=n),i},$f.prototype.postExecute=function(e){var t=e.connection,n=e.newSource,i=e.newTarget,r=e.dockingOrPoints,o=e.hints||{},a={};o.connectionStart&&(a.connectionStart=o.connectionStart),o.connectionEnd&&(a.connectionEnd=o.connectionEnd),!1!==o.layoutConnection&&(!n||i&&"source"!==o.docking||(a.connectionStart=a.connectionStart||Hf(u(r)?r[0]:r)),!i||n&&"target"!==o.docking||(a.connectionEnd=a.connectionEnd||Hf(u(r)?r[r.length-1]:r)),o.newWaypoints&&(a.waypoints=o.newWaypoints),this._modeling.layoutConnection(t,a))},$f.prototype.revert=function(e){var t=e.oldSource,n=e.oldTarget,i=e.oldWaypoints,r=e.connection;return t&&(r.source=t),n&&(r.target=n),i&&(r.waypoints=i),r},Gf.$inject=["modeling","rules"],Gf.prototype.preExecute=function(e){var t,n=this,i=this._modeling,r=this._rules,o=e.oldShape,a=e.newData,s=e.hints||{};function c(e,t,n){return r.allowed("connection.reconnect",{connection:n,source:e,target:t})}var p,l={x:a.x,y:a.y},u={x:o.x,y:o.y,width:o.width,height:o.height};t=e.newShape=e.newShape||n.createShape(a,l,o.parent,s),o.host&&i.updateAttachment(t,o.host),!1!==s.moveChildren&&(p=o.children.slice(),i.moveElements(p,{x:0,y:0},t,s));var h=o.incoming.slice(),d=o.outgoing.slice();b(h,(function(e){c(e.source,t,e)&&n.reconnectEnd(e,t,ch(e,t,u),s)})),b(d,(function(e){var i=e.target;c(t,i,e)&&n.reconnectStart(e,t,sh(e,t,u),s)}))},Gf.prototype.postExecute=function(e){var t=e.oldShape;this._modeling.removeShape(t)},Gf.prototype.execute=function(e){},Gf.prototype.revert=function(e){},Gf.prototype.createShape=function(e,t,n,i){return this._modeling.createShape(e,t,n,i)},Gf.prototype.reconnectStart=function(e,t,n,i){this._modeling.reconnectStart(e,t,n,i)},Gf.prototype.reconnectEnd=function(e,t,n,i){this._modeling.reconnectEnd(e,t,n,i)},Wf.$inject=["modeling"],Wf.prototype.execute=function(e){var t=e.shape,n=e.newBounds,i=e.minBounds;if(void 0===n.x||void 0===n.y||void 0===n.width||void 0===n.height)throw new Error("newBounds must have {x, y, width, height} properties");if(i&&(n.width<i.width||n.height<i.height))throw new Error("width and height cannot be less than minimum height and width");if(!i&&n.width<10||n.height<10)throw new Error("width and height cannot be less than 10px");return e.oldBounds={width:t.width,height:t.height,x:t.x,y:t.y},F(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Wf.prototype.postExecute=function(e){var t=this._modeling,n=e.shape,i=e.oldBounds;!1!==(e.hints||{}).layout&&(b(n.incoming,(function(e){t.layoutConnection(e,{connectionEnd:ch(e,n,i)})})),b(n.outgoing,(function(e){t.layoutConnection(e,{connectionStart:sh(e,n,i)})})))},Wf.prototype.revert=function(e){var t=e.shape,n=e.oldBounds;return F(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Vf.$inject=["modeling"],Vf.prototype.preExecute=function(e){var t=e.delta,n=e.direction,i=e.movingShapes,r=e.resizingShapes,o=e.start,a={};this.moveShapes(i,t),b(r,(function(e){a[e.id]=function(e){return{x:e.x,y:e.y,height:e.height,width:e.width}}(e)})),this.resizeShapes(r,t,n),this.updateConnectionWaypoints(function(e,t){var n=[];return b(e.concat(t),(function(i){var r=i.incoming,o=i.outgoing;b(r.concat(o),(function(i){var r=i.source,o=i.target;(Yd(e,r)||Yd(e,o)||Yd(t,r)||Yd(t,o))&&(Yd(n,i)||n.push(i))}))})),n}(i,r),t,n,o,i,r,a)},Vf.prototype.execute=function(){},Vf.prototype.revert=function(){},Vf.prototype.moveShapes=function(e,t){var n=this;b(e,(function(e){n._modeling.moveShape(e,t,null,{autoResize:!1,layout:!1,recurse:!1})}))},Vf.prototype.resizeShapes=function(e,t,n){var i=this;b(e,(function(e){var r=function(e,t,n){var i=e.x,r=e.y,o=e.width,a=e.height,s=n.x,c=n.y;switch(t){case"n":return{x:i,y:r+c,width:o,height:a-c};case"s":return{x:i,y:r,width:o,height:a+c};case"w":return{x:i+s,y:r,width:o-s,height:a};case"e":return{x:i,y:r,width:o+s,height:a};default:throw new Error("unknown direction: "+t)}}(e,n,t);i._modeling.resizeShape(e,r,null,{attachSupport:!1,autoResize:!1,layout:!1})}))},Vf.prototype.updateConnectionWaypoints=function(e,t,n,i,r,o,a){var s=this,c=r.concat(o);b(e,(function(e){var p=e.source,l=e.target,u=function(e){return S(e.waypoints,(function(e){return(e=Uf(e)).original&&(e.original=Uf(e.original)),e}))}(e),h=qf(n),d={labelBehavior:!1};Yf(c,p)&&Yf(c,l)?(u=S(u,(function(e){return Kf(e,i,n)&&(e[h]=e[h]+t[h]),e.original&&Kf(e.original,i,n)&&(e.original[h]=e.original[h]+t[h]),e})),s._modeling.updateWaypoints(e,u,{labelBehavior:!1})):(Yf(c,p)||Yf(c,l))&&(Yf(r,p)?d.connectionStart=ph(e,p,t):Yf(r,l)?d.connectionEnd=lh(e,l,t):Yf(o,p)?d.connectionStart=sh(e,p,a[p.id]):Yf(o,l)&&(d.connectionEnd=ch(e,l,a[l.id])),s._modeling.layoutConnection(e,d))}))},Xf.$inject=["modeling"],Xf.prototype.execute=function(e){var t=e.shape,n=t.children;e.oldChildrenVisibility=Zf(n),t.collapsed=!t.collapsed;var i=Qf(n,t.collapsed);return[t].concat(i)},Xf.prototype.revert=function(e){var t=e.shape,n=e.oldChildrenVisibility,i=Jf(t.children,n);return t.collapsed=!t.collapsed,[t].concat(i)},em.$inject=["modeling"],em.prototype.execute=function(e){var t=e.shape,n=e.newHost,i=t.host;return e.oldHost=i,e.attacherIdx=tm(i,t),nm(n,t),t.host=n,t},em.prototype.revert=function(e){var t=e.shape,n=e.newHost,i=e.oldHost,r=e.attacherIdx;return t.host=i,tm(n,t),nm(i,t,r),t},im.prototype.execute=function(e){var t=e.connection,n=e.newWaypoints;return e.oldWaypoints=t.waypoints,t.waypoints=n,t},im.prototype.revert=function(e){var t=e.connection,n=e.oldWaypoints;return t.waypoints=n,t},rm.$inject=["eventBus","elementFactory","commandStack"],rm.prototype.getHandlers=function(){return{"shape.append":xf,"shape.create":Tf,"shape.delete":Df,"shape.move":Ff,"shape.resize":Wf,"shape.replace":Gf,"shape.toggleCollapse":Xf,spaceTool:Vf,"label.create":Rf,"connection.create":_f,"connection.delete":kf,"connection.move":jf,"connection.layout":Of,"connection.updateWaypoints":im,"connection.reconnect":$f,"elements.create":wf,"elements.move":zf,"elements.delete":Mf,"elements.distribute":Bf,"elements.align":bf,"element.updateAttachment":em}},rm.prototype.registerHandlers=function(e){b(this.getHandlers(),(function(t,n){e.registerHandler(n,t)}))},rm.prototype.moveShape=function(e,t,n,i,r){"object"==typeof i&&(r=i,i=null);var o={shape:e,delta:t,newParent:n,newParentIndex:i,hints:r||{}};this._commandStack.execute("shape.move",o)},rm.prototype.updateAttachment=function(e,t){var n={shape:e,newHost:t};this._commandStack.execute("element.updateAttachment",n)},rm.prototype.moveElements=function(e,t,n,i){var r,o=(i=i||{}).attach,a=n;!0===o?(r=n,a=n.parent):!1===o&&(r=null);var s={shapes:e,delta:t,newParent:a,newHost:r,hints:i};this._commandStack.execute("elements.move",s)},rm.prototype.moveConnection=function(e,t,n,i,r){"object"==typeof i&&(r=i,i=void 0);var o={connection:e,delta:t,newParent:n,newParentIndex:i,hints:r||{}};this._commandStack.execute("connection.move",o)},rm.prototype.layoutConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.layout",n)},rm.prototype.createConnection=function(e,t,n,i,r,o){"object"==typeof n&&(o=r,r=i,i=n,n=void 0);var a={source:e,target:t,parent:r,parentIndex:n,connection:i=this._create("connection",i),hints:o};return this._commandStack.execute("connection.create",a),a.connection},rm.prototype.createShape=function(e,t,n,i,r){"number"!=typeof i&&(r=i,i=void 0);var o,a,s=(r=r||{}).attach;e=this._create("shape",e),s?(o=n.parent,a=n):o=n;var c={position:t,shape:e,parent:o,parentIndex:i,host:a,hints:r};return this._commandStack.execute("shape.create",c),c.shape},rm.prototype.createElements=function(e,t,n,i,r){u(e)||(e=[e]),"number"!=typeof i&&(r=i,i=void 0);var o={position:t,elements:e,parent:n,parentIndex:i,hints:r=r||{}};return this._commandStack.execute("elements.create",o),o.elements},rm.prototype.createLabel=function(e,t,n,i){n=this._create("label",n);var r={labelTarget:e,position:t,parent:i||e.parent,shape:n};return this._commandStack.execute("label.create",r),r.shape},rm.prototype.appendShape=function(e,t,n,i,r){r=r||{};var o={source:e,position:n,target:i,shape:t=this._create("shape",t),connection:r.connection,connectionParent:r.connectionParent,hints:r};return this._commandStack.execute("shape.append",o),o.shape},rm.prototype.removeElements=function(e){var t={elements:e};this._commandStack.execute("elements.delete",t)},rm.prototype.distributeElements=function(e,t,n){var i={groups:e,axis:t,dimension:n};this._commandStack.execute("elements.distribute",i)},rm.prototype.removeShape=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.delete",n)},rm.prototype.removeConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.delete",n)},rm.prototype.replaceShape=function(e,t,n){var i={oldShape:e,newData:t,hints:n||{}};return this._commandStack.execute("shape.replace",i),i.newShape},rm.prototype.alignElements=function(e,t){var n={elements:e,alignment:t};this._commandStack.execute("elements.align",n)},rm.prototype.resizeShape=function(e,t,n,i){var r={shape:e,newBounds:t,minBounds:n,hints:i};this._commandStack.execute("shape.resize",r)},rm.prototype.createSpace=function(e,t,n,i,r){var o={delta:n,direction:i,movingShapes:e,resizingShapes:t,start:r};this._commandStack.execute("spaceTool",o)},rm.prototype.updateWaypoints=function(e,t,n){var i={connection:e,newWaypoints:t,hints:n||{}};this._commandStack.execute("connection.updateWaypoints",i)},rm.prototype.reconnect=function(e,t,n,i,r){var o={connection:e,newSource:t,newTarget:n,dockingOrPoints:i,hints:r||{}};this._commandStack.execute("connection.reconnect",o)},rm.prototype.reconnectStart=function(e,t,n,i){i||(i={}),this.reconnect(e,t,e.target,n,F(i,{docking:"source"}))},rm.prototype.reconnectEnd=function(e,t,n,i){i||(i={}),this.reconnect(e,e.source,t,n,F(i,{docking:"target"}))},rm.prototype.connect=function(e,t,n,i){return this.createConnection(e,t,n||{},e.parent,i)},rm.prototype._create=function(e,t){return t instanceof Bn?t:this._elementFactory.create(e,t)},rm.prototype.toggleCollapse=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.toggleCollapse",n)},om.$inject=["elementRegistry"],om.prototype.execute=function(e){var t=e.element,n=e.moddleElement,i=e.properties;if(!n)throw new Error("<moddleElement> required");var r=e.changed||this.getVisualReferences(n).concat(t),o=e.oldProperties||function(e,t){return _(t,(function(t,n){return t[n]=e.get(n),t}),{})}(n,C(i));return am(n,i),e.oldProperties=o,e.changed=r,r},om.prototype.revert=function(e){var t=e.oldProperties,n=e.moddleElement,i=e.changed;return am(n,t),i},om.prototype.getVisualReferences=function(e){var t=this._elementRegistry;return Ar(e,"bpmn:DataObject")?function(e,t){return t.filter((function(t){return Ar(t,"bpmn:DataObjectReference")&&kr(t).dataObjectRef===e}))}(e,t):[]};var sm="default",cm="id",pm="di",lm={width:0,height:0};function um(e,t,n,i,r){this._elementRegistry=e,this._moddle=t,this._translate=n,this._modeling=i,this._textRenderer=r}function hm(e,t){return cm in e&&e.id!==t.id}function dm(e,t){b(t,(function(t,n){n!==pm?e.set(n,t):e.di&&function(e,t){b(t,(function(t,n){e.set(n,t)}))}(e.di,t)}))}um.$inject=["elementRegistry","moddle","translate","modeling","textRenderer"],um.prototype.execute=function(e){var t=e.element,n=[t],i=this._translate;if(!t)throw new Error(i("element required"));var r=this._elementRegistry,o=this._moddle.ids,a=t.businessObject,s=function(e){var t=F({},e);return fm.forEach((function(n){n in e&&(t[n]=kr(t[n]))})),t}(e.properties),c=e.oldProperties||function(e,t){return _(C(t),(function(n,i){return n[i]=i!==pm?e.get(i):function(e,t){return _(t,(function(t,n){return t[n]=e.get(n),t}),{})}(e.di,C(t.di)),n}),{})}(a,s);return hm(s,a)&&(o.unclaim(a.id),r.updateId(t,s.id),o.claim(s.id,a)),sm in s&&(s.default&&n.push(r.get(s.default.id)),a.default&&n.push(r.get(a.default.id))),dm(a,s),e.oldProperties=c,e.changed=n,n},um.prototype.postExecute=function(e){var t=e.element.label,n=t&&kr(t).name;if(n){var i=this._textRenderer.getExternalLabelBounds(t,n);this._modeling.resizeShape(t,i,lm)}},um.prototype.revert=function(e){var t=e.element,n=e.properties,i=e.oldProperties,r=t.businessObject,o=this._elementRegistry,a=this._moddle.ids;return dm(r,i),hm(n,r)&&(a.unclaim(n.id),o.updateId(t,i.id),a.claim(i.id,r)),e.changed};var fm=["default"];function mm(e,t){this._canvas=e,this._modeling=t}function vm(e,t){this._modeling=e,this._spaceTool=t}function ym(e,t){this._modeling=e,this._translate=t}function gm(e,t){this._modeling=e,this._spaceTool=t}mm.$inject=["canvas","modeling"],mm.prototype.execute=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,r=t.getRootElement(),o=r.businessObject,a=o.$parent,s=o.di;t.setRootElement(n,!0),vt(a.rootElements,i),i.$parent=a,mt(a.rootElements,o),o.$parent=null,o.di=null,s.bpmnElement=i,i.di=s,e.oldRoot=r},mm.prototype.revert=function(e){var t=this._canvas,n=e.newRoot.businessObject,i=e.oldRoot,r=i.businessObject,o=n.$parent,a=n.di;t.setRootElement(i,!0),mt(o.rootElements,n),n.$parent=null,vt(o.rootElements,r),r.$parent=o,n.di=null,a.bpmnElement=r,r.di=a},vm.$inject=["modeling","spaceTool"],vm.prototype.preExecute=function(e){var t=this._spaceTool,n=this._modeling,i=e.shape,r=e.location,o=Wp(i),a=o===i,s=a?i:i.parent;Gp(s).length||n.createShape({type:"bpmn:Lane"},{x:i.x+$p,y:i.y,width:i.width-$p,height:i.height},s);var c=[];st(o,(function(e){return c.push(e),e.label&&c.push(e.label),e===i?[]:g(e.children,(function(e){return e!==i}))}));var p="top"===r?-120:120,l="top"===r?i.y:i.y+i.height,u=l+("top"===r?10:-10),h="top"===r?"n":"s",d=t.calculateAdjustments(c,"y",p,u);t.makeSpace(d.movingShapes,d.resizingShapes,{x:0,y:p},h,u),e.newLane=n.createShape({type:"bpmn:Lane"},{x:i.x+(a?$p:0),y:l-("top"===r?120:0),width:i.width-(a?$p:0),height:120},s)},ym.$inject=["modeling","translate"],ym.prototype.preExecute=function(e){var t=this._modeling,n=this._translate,i=e.shape,r=e.count,o=Gp(i),a=o.length;if(a>r)throw new Error(n("more than {count} child lanes",{count:r}));var s,c,p,l,u,h=Math.round(i.height/r);for(u=0;u<r;u++)s=i.y+u*h,c=u===r-1?i.height-h*u:h,p={x:i.x+$p,y:s,width:i.width-$p,height:c},u<a?t.resizeShape(o[u],p):(l={type:"bpmn:Lane"},t.createShape(l,p,i))},gm.$inject=["modeling","spaceTool"],gm.prototype.preExecute=function(e){var t=e.shape,n=e.newBounds;!1!==e.balanced?this.resizeBalanced(t,n):this.resizeSpace(t,n)},gm.prototype.resizeBalanced=function(e,t){var n=this._modeling,i=Vp(e,t);n.resizeShape(e,t),i.forEach((function(e){n.resizeShape(e.shape,e.newBounds)}))},gm.prototype.resizeSpace=function(e,t){var n,i,r,o,a,s=this._spaceTool,c=an(e),p=Np(an(t),c),l=Wp(e),u=[],h=[];st(l,(function(e){return u.push(e),(Ar(e,"bpmn:Lane")||Ar(e,"bpmn:Participant"))&&h.push(e),e.children})),(p.bottom||p.top)&&(n=p.bottom||p.top,i=e.y+(p.bottom?e.height:0)+(p.bottom?-10:10),r=p.bottom?"s":"n",o=p.top>0||p.bottom<0?-n:n,a=s.calculateAdjustments(u,"y",o,i),s.makeSpace(a.movingShapes,a.resizingShapes,{x:0,y:n},r)),(p.left||p.right)&&(n=p.right||p.left,i=e.x+(p.right?e.width:0)+(p.right?-10:100),r=p.right?"e":"w",o=p.left>0||p.right<0?-n:n,a=s.calculateAdjustments(h,"x",o,i),s.makeSpace(a.movingShapes,a.resizingShapes,{x:n,y:0},r))};var bm="flowNodeRef",xm="lanes";function _m(e){this._elementRegistry=e}function Em(e){this._moddle=e}_m.$inject=["elementRegistry"],_m.prototype.computeUpdates=function(e,t){var n=[],i=[],r={},o=[];function a(e){-1===n.indexOf(e)&&(o.push(e),n.push(e))}function s(e){return e.parent?function(e){var t=Wp(e);return r[t.id]||(r[t.id]=Hp(t)),r[t.id]}(e).filter((function(t){return n=e,i=an(t),r=n.x+n.width/2,o=n.y+n.height/2,r>i.left&&r<i.right&&o>i.top&&o<i.bottom;var n,i,r,o})).map((function(e){return e.businessObject})):[]}return t.forEach((function(e){var t=Wp(e);t&&-1===n.indexOf(t)&&(t.children.filter((function(e){return Ar(e,"bpmn:FlowNode")})).forEach(a),n.push(t))})),e.forEach(a),o.forEach((function(e){var t=e.businessObject,n=t.get(xm).slice(),r=s(e);i.push({flowNode:t,remove:n,add:r})})),t.forEach((function(e){var t=e.businessObject;e.parent||t.get(bm).forEach((function(e){i.push({flowNode:e,remove:[t],add:[]})}))})),i},_m.prototype.execute=function(e){var t=e.updates;t||(t=e.updates=this.computeUpdates(e.flowNodeShapes,e.laneShapes)),t.forEach((function(e){var t=e.flowNode,n=t.get(xm);e.remove.forEach((function(e){mt(n,e),mt(e.get(bm),t)})),e.add.forEach((function(e){vt(n,e),vt(e.get(bm),t)}))}))},_m.prototype.revert=function(e){e.updates.forEach((function(e){var t=e.flowNode,n=t.get(xm);e.add.forEach((function(e){mt(n,e),mt(e.get(bm),t)})),e.remove.forEach((function(e){vt(n,e),vt(e.get(bm),t)}))}))},Em.$inject=["moddle"],Em.prototype.execute=function(e){var t=this._moddle.ids,n=e.id,i=e.element;e.claiming?t.claim(n,i):t.unclaim(n)},Em.prototype.revert=function(e){var t=this._moddle.ids,n=e.id,i=e.element;e.claiming?t.unclaim(n):t.claim(n,i)};var wm={fill:void 0,stroke:void 0};function Sm(e){this._commandStack=e,this._normalizeColor=function(e){if(e){if(m(e)){var t=function(e){var t=document.createElement("canvas").getContext("2d");return t.fillStyle="transparent",t.fillStyle=e,/^#[0-9a-fA-F]{6}$/.test(t.fillStyle)?t.fillStyle:null}(e);if(t)return t}throw new Error("invalid color value: "+e)}}}Sm.$inject=["commandStack"],Sm.prototype.postExecute=function(e){var t=e.elements,n=e.colors||wm,i=this,r={};"fill"in n&&F(r,{"background-color":this._normalizeColor(n.fill)}),"stroke"in n&&F(r,{"border-color":this._normalizeColor(n.stroke)}),b(t,(function(e){var t=function(e){return!!e.waypoints}(e)?$(r,["border-color"]):r;!function(e){"border-color"in e&&(e.stroke=e["border-color"]);"background-color"in e&&(e.fill=e["background-color"])}(t),e.labelTarget?i._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:e.businessObject.di.label,properties:{color:r["background-color"]}}):i._commandStack.execute("element.updateProperties",{element:e,properties:{di:t}})}))};var Cm={width:0,height:0};function Tm(e,t){function n(e,t){var n=e.label||e,i=e.labelTarget||e;return function(e,t,n){var i=e.businessObject,r=Nr(i);r&&("categoryValueRef"===r?i.categoryValueRef.value=t:i[r]=t)}(n,t),[n,i]}this.preExecute=function(t){var n=t.element,i=n.businessObject,r=t.newLabel;if(!so(n)&&io(n)&&!ro(n)&&!Rm(r)){var o=ao(n);o={x:o.x,y:o.y+7},e.createLabel(n,o,{id:i.id+"_label",businessObject:i})}},this.execute=function(e){return e.oldLabel=Or(e.element),n(e.element,e.newLabel)},this.revert=function(e){return n(e.element,e.oldLabel)},this.postExecute=function(n){var i=n.element,r=i.label||i,o=n.newLabel,a=n.newBounds,s=n.hints||{};if(so(r)||Ar(r,"bpmn:TextAnnotation"))if(so(r)&&Rm(o))!1!==s.removeShape&&e.removeShape(r,{unsetLabel:!1});else{var c=Or(r);void 0===a&&(a=t.getExternalLabelBounds(r,c)),a&&e.resizeShape(r,a,Cm)}}}function Rm(e){return!e||!e.trim()}function Pm(e,t,n,i){rm.call(this,e,t,n),this._bpmnRules=i}function Am(){}Tm.$inject=["modeling","textRenderer"],n(Pm,rm),Pm.$inject=["eventBus","elementFactory","commandStack","bpmnRules"],Pm.prototype.getHandlers=function(){var e=rm.prototype.getHandlers.call(this);return e["element.updateModdleProperties"]=om,e["element.updateProperties"]=um,e["canvas.updateRoot"]=mm,e["lane.add"]=vm,e["lane.resize"]=gm,e["lane.split"]=ym,e["lane.updateRefs"]=_m,e["id.updateClaim"]=Em,e["element.setColor"]=Sm,e["element.updateLabel"]=Tm,e},Pm.prototype.updateLabel=function(e,t,n,i){this._commandStack.execute("element.updateLabel",{element:e,newLabel:t,newBounds:n,hints:i||{}})},Pm.prototype.connect=function(e,t,n,i){var r=this._bpmnRules;if(n||(n=r.canConnect(e,t)),n)return this.createConnection(e,t,n,e.parent,i)},Pm.prototype.updateModdleProperties=function(e,t,n){this._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:t,properties:n})},Pm.prototype.updateProperties=function(e,t){this._commandStack.execute("element.updateProperties",{element:e,properties:t})},Pm.prototype.resizeLane=function(e,t,n){this._commandStack.execute("lane.resize",{shape:e,newBounds:t,balanced:n})},Pm.prototype.addLane=function(e,t){var n={shape:e,location:t};return this._commandStack.execute("lane.add",n),n.newLane},Pm.prototype.splitLane=function(e,t){this._commandStack.execute("lane.split",{shape:e,count:t})},Pm.prototype.makeCollaboration=function(){var e=this._create("root",{type:"bpmn:Collaboration"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},Pm.prototype.updateLaneRefs=function(e,t){this._commandStack.execute("lane.updateRefs",{flowNodeShapes:e,laneShapes:t})},Pm.prototype.makeProcess=function(){var e={newRoot:this._create("root",{type:"bpmn:Process"})};this._commandStack.execute("canvas.updateRoot",e)},Pm.prototype.claimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t,claiming:!0})},Pm.prototype.unclaimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t})},Pm.prototype.setColor=function(e,t){e.length||(e=[e]),this._commandStack.execute("element.setColor",{elements:e,colors:t})},Am.prototype.layoutConnection=function(e,t){return[(t=t||{}).connectionStart||cn(t.source||e.source),t.connectionEnd||cn(t.target||e.target)]};var km=Math.round,Mm={"h:h":20,"v:v":20,"h:v":-10,"v:h":-10};function Dm(e,t,n){var i,r,o,a=pn(t,e,5),s=n.split(":")[0],c=km((t.x-e.x)/2+e.x),p=km((t.y-e.y)/2+e.y),l=(o=a,{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/left|right/,v:/top|bottom/}[s].test(o)),u=/h|r|l/.test(s),h=!1;return l?(i=u?{x:c,y:e.y}:{x:e.x,y:p},r=u?"h:h":"v:v"):(r=u?"h:v":"v:h",function(e,t){return!{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/./,v:/./}[t].test(e)}(a,s)?u?(h=p===e.y,i={x:e.x+20*(/l/.test(s)?-1:1),y:h?p+20:p}):i={x:(h=c===e.x)?c+20:c,y:e.y+20*(/t/.test(s)?-1:1)}:i={x:c,y:p}),{waypoints:Nm(e,i,r).concat(i),directions:r,turnNextDirections:h}}function Bm(e){return e.split(":").reverse().join(":")}function Nm(e,t,n){if(!function(e){return e&&/^h|v|t|r|b|l:h|v|t|r|b|l$/.test(e)}(n=n||"h:h"))throw new Error("unknown directions: <"+n+">: must be specified as <start>:<end> with start/end in { h,v,t,r,b,l }");if(zm(n)){var i=function(e,t,n){return Dm(e,t,n)}(e,t,n),r=function(e,t,n){var i=Dm(t,e,Bm(n));return{waypoints:i.waypoints.slice().reverse(),directions:Bm(i.directions),turnNextDirections:i.turnNextDirections}}(e,t,n),o=function(e,t){var n=e.directions.split(":")[1],i=t.directions.split(":")[0];e.turnNextDirections&&(n="h"==n?"v":"h"),t.turnNextDirections&&(i="h"==i?"v":"h");var r=n+":"+i;return{waypoints:Nm(e.waypoints[e.waypoints.length-1],t.waypoints[0],r),directions:r}}(i,r);return[].concat(i.waypoints,o.waypoints,r.waypoints)}return function(e,t,n){var i=km((t.x-e.x)/2+e.x),r=km((t.y-e.y)/2+e.y);if("h:v"===n)return[{x:t.x,y:e.y}];if("v:h"===n)return[{x:e.x,y:t.y}];if("h:h"===n)return[{x:i,y:e.y},{x:i,y:t.y}];if("v:v"===n)return[{x:e.x,y:r},{x:t.x,y:r}];throw new Error("invalid directions: can only handle varians of [hv]:[hv]")}(e,t,n)}function Om(e,t,n,i,r){var o=x(r&&r.preferredLayouts||[],"straight")[0]||"h:h",a=pn(e,t,Mm[o]||0),s=function(e,t){if(zm(t))return t;switch(e){case"intersect":return"t:t";case"top":case"bottom":return"v:v";case"left":case"right":return"h:h";default:return t}}(a,o);n=n||cn(e),i=i||cn(t);var c=s.split(":");return function(e,t,n){var i=Nm(e,t,n);return i.unshift(e),i.push(t),$m(i)}(Fm(n,e,c[0],function(e){return{top:"bottom",bottom:"top",left:"right",right:"left","top-left":"bottom-right","bottom-right":"top-left","top-right":"bottom-left","bottom-left":"top-right"}[e]}(a)),Fm(i,t,c[1],a),s)}function jm(e,t,n,i,r,o){var a;return u(n)&&(r=n,o=i,n=cn(e),i=cn(t)),r=r||[],(a=-1!==(o=F({preferredLayouts:[]},o)).preferredLayouts.indexOf("straight")&&function(e,t,n,i,r){var o,a,s={};if(a=pn(e,t),!/^(top|bottom|left|right)$/.test(a))return null;/top|bottom/.test(a)&&(o="x");/left|right/.test(a)&&(o="y");return"target"===r.preserveDocking?Lm(o,i,e)?(s[o]=i[o],[{x:void 0!==s.x?s.x:n.x,y:void 0!==s.y?s.y:n.y,original:{x:void 0!==s.x?s.x:n.x,y:void 0!==s.y?s.y:n.y}},{x:i.x,y:i.y}]):null:Lm(o,n,t)?(s[o]=n[o],[{x:n.x,y:n.y},{x:void 0!==s.x?s.x:i.x,y:void 0!==s.y?s.y:i.y,original:{x:void 0!==s.x?s.x:i.x,y:void 0!==s.y?s.y:i.y}}]):null}(e,t,n,i,o))||(a=o.connectionEnd&&function(e,t,n,i){var r=i.slice().reverse();return(r=Im(e,t,n,r))?r.reverse():null}(t,e,i,r))?a:(a=o.connectionStart&&Im(e,t,n,r))||(!o.connectionStart&&!o.connectionEnd&&r&&r.length?r:Om(e,t,n,i,o))}function Lm(e,t,n){return function(e,t,n){return e>=t&&e<=n}(t[e],n[e],n[e]+n[{x:"width",y:"height"}[e]])}function Im(e,t,n,i){if(function(e){return e.length<3||!(e.length>4)&&!!y(e,(function(t,n){var i=e[n-1];return i&>(t,i)<3}))}(i))return null;var r,o=i[0],a=i.slice();return a[0]=n,a[1]=function(e,t,n){switch(xt(t,e)){case"v":return{x:n.x,y:e.y};case"h":return{x:e.x,y:n.y}}return{x:e.x,y:e.y}}(a[1],o,n),(r=function(e,t,n){var i;for(i=e.length-2;0!==i;i--)if(_t(e[i],t,20)||_t(e[i],n,20))return e.slice(i);return e}(a,e,t))!==a&&(a=Im(e,t,n,r)),a&&xt(a)?null:a}function zm(e){return e&&/t|r|b|l/.test(e)}function Fm(e,t,n,i){if("h"===n&&(n=/left/.test(i)?"l":"r"),"v"===n&&(n=/top/.test(i)?"t":"b"),"t"===n)return{original:e,x:e.x,y:t.y};if("r"===n)return{original:e,x:t.x+t.width,y:e.y};if("b"===n)return{original:e,x:e.x,y:t.y+t.height};if("l"===n)return{original:e,x:t.x,y:e.y};throw new Error("unexpected dockingDirection: <"+n+">")}function $m(e){return e.reduce((function(t,n,i){return bt(t[t.length-1],e[i+1],n,0)||t.push(n),t}),[])}var Hm={top:"bottom","top-right":"bottom-left","top-left":"bottom-right",right:"left",bottom:"top","bottom-right":"top-left","bottom-left":"top-right",left:"right"},Gm={top:"t",right:"r",bottom:"b",left:"l"};function Wm(){}function Vm(e,t){return Ar(t,"bpmn:Participant")?"source":Ar(e,"bpmn:Participant")?"target":Ym(t)?"source":Ym(e)||Ar(t,"bpmn:Event")?"target":Ar(e,"bpmn:Event")?"source":null}function Um(e){return Ym(e)?"target":"source"}function qm(e,t){return e?e.original||e:cn(t)}function Km(e,t){return Ar(t,"bpmn:Activity")&&Ar(e,"bpmn:BoundaryEvent")&&t.businessObject.isForCompensation}function Ym(e){return Ar(e,"bpmn:SubProcess")&&Mr(e)}function Xm(e,t){return e===t}function Zm(e){var t=/right|left/.exec(e);return t&&t[0]}function Qm(e){var t=/top|bottom/.exec(e);return t&&t[0]}function Jm(e){return"right"===e||"left"===e}function ev(e,t){var n=t.waypoints,i=n&&n.length&&pn(n[0],e);return"top"===i?["t:r"]:"right"===i?["r:b"]:"left"===i?["l:t"]:["b:l"]}function tv(e,t,n){var i,r,o=cn(e),a=cn(t),s=(r=(i=e).host,pn(cn(i),r,-10)),c=Xm(e.host,t),p=-1!==["top","right","bottom","left"].indexOf(s),l=pn(a,o,{x:e.width/2+t.width/2,y:e.height/2+t.height/2});return c?function(e,t,n,i,r){var o,a=t?e:Qm(e),s=Gm[a];o=t?Jm(e)?nv("y",n,i,r)?"h":"b":nv("x",n,i,r)?"v":"l":"v";return[s+":"+o]}(s,p,e,t,n):[function(e,t,n){if(n)return Gm[e];if(Xm(Qm(e),Qm(t))||(i=Zm(e),r=Zm(t),Hm[i]===r))return Gm[Qm(e)];var i,r;return Gm[Zm(e)]}(s,l,p)+":"+function(e,t,n){if(n)return Jm(e)?(i=t,r=Zm(e),o=Hm[r],-1!==i.indexOf(o)||Xm(e,t)?"h":"v"):function(e,t){var n=Qm(e),i=Hm[n];return-1!==t.indexOf(i)}(e,t)||Xm(e,t)?"v":"h";var i,r,o;return Jm(t)||Xm(Qm(e),Qm(t))&&Zm(t)?"h":"v"}(s,l,p)]}function nv(e,t,n,i){return!(iv(e,i,n,40)||iv(e,i,{x:n.x+n.width,y:n.y+n.height},40)||iv(e,i,cn(t),40))}function iv(e,t,n,i){return Math.abs(t[e]-n[e])<i}function rv(e){return F({original:e.point.original||e.point},e.actual)}function ov(e,t){this._elementRegistry=e,this._graphicsFactory=t}n(Wm,Am),Wm.prototype.layoutConnection=function(e,t){t||(t={});var n,i,r=t.source||e.source,o=t.target||e.target,a=t.waypoints||e.waypoints,s=t.connectionStart,c=t.connectionEnd;return s||(s=qm(a&&a[0],r)),c||(c=qm(a&&a[a.length-1],o)),(Ar(e,"bpmn:Association")||Ar(e,"bpmn:DataAssociation"))&&a&&!Km(r,o)?[].concat([s],a.slice(1,-1),[c]):(Ar(e,"bpmn:MessageFlow")?n=function(e,t){return{preferredLayouts:["straight","v:v"],preserveDocking:Vm(e,t)}}(r,o):(Ar(e,"bpmn:SequenceFlow")||Km(r,o))&&(n=r===o?{preferredLayouts:ev(r,e)}:Ar(r,"bpmn:BoundaryEvent")?{preferredLayouts:tv(r,o,c)}:Ym(r)||Ym(o)?function(e){return{preferredLayouts:["straight","h:h"],preserveDocking:Um(e)}}(r):Ar(r,"bpmn:Gateway")?{preferredLayouts:["v:h"]}:Ar(o,"bpmn:Gateway")?{preferredLayouts:["h:v"]}:{preferredLayouts:["h:h"]}),n&&(i=$m(jm(r,o,s,c,a,n=F(n,t)))),i||[s,c])},ov.$inject=["elementRegistry","graphicsFactory"],ov.prototype.getCroppedWaypoints=function(e,t,n){t=t||e.source,n=n||e.target;var i=this.getDockingPoint(e,t,!0),r=this.getDockingPoint(e,n),o=e.waypoints.slice(i.idx+1,r.idx);return o.unshift(rv(i)),o.push(rv(r)),o},ov.prototype.getDockingPoint=function(e,t,n){var i,r,o=e.waypoints;return{point:r=o[i=n?0:o.length-1],actual:this._getIntersection(t,e,n)||r,idx:i}},ov.prototype._getIntersection=function(e,t,n){return ln(this._getShapePath(e),this._getConnectionPath(t),n)},ov.prototype._getConnectionPath=function(e){return this._graphicsFactory.getConnectionPath(e)},ov.prototype._getShapePath=function(e){return this._graphicsFactory.getShapePath(e)},ov.prototype._getGfx=function(e){return this._elementRegistry.getGraphics(e)};var av={__init__:["modeling","bpmnUpdater"],__depends__:[Vh,Td,Pd,Md,dp,Bd,Id,Hd,Ud,No,Bl,df],bpmnFactory:["type",ff],bpmnUpdater:["type",mf],elementFactory:["type",yf],modeling:["type",Pm],layouter:["type",Wm],connectionDocking:["type",ov]},sv=Math.round;function cv(e,t,n,i,r){function o(e,t,n,i){return r.allowed("elements.move",{shapes:e,delta:t,position:n,target:i})}function a(e,n,i,r){if(h(i)&&(r=i,i=!1),!n.waypoints&&n.parent){var o=function(e){return{x:e.x+sv(e.width/2),y:e.y+sv(e.height/2)}}(n);return t.init(e,o,"shape.move",{cursor:"grabbing",autoActivate:i,data:{shape:n,context:r||{}}}),!0}}e.on("shape.move.start",1500,(function(e){var t=e.context,n=e.shape,r=i.get().slice();-1===r.indexOf(n)&&(r=[n]),F(t,{shapes:r=function(e){var t=P(e,"id");return g(e,(function(e){for(;e=e.parent;)if(t[e.id])return!1;return!0}))}(r),validatedShapes:r,shape:n})})),e.on("shape.move.start",1250,(function(e){var t=e.context,n=t.validatedShapes;if(!(t.canExecute=o(n)))return!1})),e.on("shape.move.move",500,(function(e){var t,n=e.context,i=n.validatedShapes,r=e.hover,a={x:e.dx,y:e.dy};t=o(i,a,{x:e.x,y:e.y},r),n.delta=a,n.canExecute=t,n.target=null!==t?r:null})),e.on("shape.move.end",(function(e){var t=e.context,i=t.delta,r=t.canExecute,o="attach"===r,a=t.shapes;if(!1===r)return!1;i.x=sv(i.x),i.y=sv(i.y),0===i.x&&0===i.y||n.moveElements(a,i,t.target,{primaryShape:t.shape,attach:o})})),e.on("element.mousedown",(function(e){if(bo(e)){var t=mo(e);if(!t)throw new Error("must supply DOM mousedown event");return a(t,e.element)}})),this.start=a}cv.$inject=["eventBus","dragging","modeling","selection","rules"];var pv="djs-dragging",lv="drop-ok",uv="drop-not-ok",hv="new-parent",dv="attach-ok";function fv(e,t,n,i){function r(e){return function(e){return g(e,(function(t){return!function(e){return e.waypoints}(t)||y(e,D({id:t.source.id}))&&y(e,D({id:t.target.id}))}))}(a(e))}function a(e){var t=ct(e,!0),n=S(t,(function(e){return(e.incoming||[]).concat(e.outgoing||[])}));return o(t.concat(n))}function s(e,n){[dv,lv,uv,hv].forEach((function(i){i===n?t.addMarker(e,i):t.removeMarker(e,i)}))}e.on("shape.move.start",499,(function(e){var s=e.context,c=s.shapes,p=s.allDraggedElements,l=r(c);if(!s.dragGroup){var u=Me("g");ge(u,n.cls("djs-drag-group",["no-events"])),me(t.getActiveLayer(),u),s.dragGroup=u}l.forEach((function(e){i.addDragger(e,s.dragGroup)})),b(p=p?o([p,a(c)]):a(c),(function(e){t.addMarker(e,pv)})),s.allDraggedElements=p,s.differentParents=1!==T(P(c,(function(e){return e.parent&&e.parent.id})))})),e.on("shape.move.move",499,(function(e){var t=e.context,n=t.dragGroup,i=t.target,r=t.shape.parent,o=t.canExecute;i&&("attach"===o?s(i,dv):t.canExecute&&i&&i.id!==r.id?s(i,hv):s(i,t.canExecute?lv:uv)),Vn(n,e.dx,e.dy)})),e.on(["shape.move.out","shape.move.cleanup"],(function(e){var t=e.context.target;t&&s(t,null)})),e.on("shape.move.cleanup",(function(e){var n=e.context,i=n.allDraggedElements,r=n.dragGroup;b(i,(function(e){t.removeMarker(e,pv)})),r&&Ce(r)})),this.makeDraggable=function(e,n,r){i.addDragger(n,e.dragGroup),r&&t.addMarker(n,pv),e.allDraggedElements?e.allDraggedElements.push(n):e.allDraggedElements=[n]}}fv.$inject=["eventBus","canvas","styles","previewSupport"];var mv={__depends__:[Co,No,Ro,hs,ss,Rc],__init__:["move","movePreview"],move:["type",cv],movePreview:["type",fv]},vv=".djs-palette-toggle",yv=".entry",gv="open",bv="two-column";function xv(e,t){this._eventBus=e,this._canvas=t;var n=this;e.on("tool-manager.update",(function(e){var t=e.tool;n.updateToolHighlight(t)})),e.on("i18n.changed",(function(){n._update()})),e.on("diagram.init",(function(){n._diagramInitialized=!0,n._rebuild()}))}function _v(e,t){var n=t.getPaletteEntries();return f(n)?n(e):(b(n,(function(t,n){e[n]=t})),e)}xv.$inject=["eventBus","canvas"],xv.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("palette.getProviders",e,(function(e){e.providers.push(t)})),this._rebuild()},xv.prototype.getEntries=function(){return this._getProviders().reduce(_v,{})},xv.prototype._rebuild=function(){this._diagramInitialized&&(this._getProviders().length&&(this._container||this._init(),this._update()))},xv.prototype._init=function(){var e=this,t=this._eventBus,n=this._getParentContainer(),i=this._container=ce(xv.HTML_MARKUP);n.appendChild(i),K(n).add("djs-palette-shown"),se.bind(i,".djs-palette-toggle, .entry","click",(function(t){var n=t.delegateTarget;if(J(n,vv))return e.toggle();e.trigger("click",t)})),re.bind(i,"mousedown",(function(e){e.stopPropagation()})),se.bind(i,yv,"dragstart",(function(t){e.trigger("dragstart",t)})),t.on("canvas.resized",this._layoutChanged,this),t.fire("palette.create",{container:i})},xv.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(t),t.providers},xv.prototype._toggleState=function(e){e=e||{};var t,n=this._getParentContainer(),i=this._container,r=this._eventBus,o=K(i),a=K(n);t="twoColumn"in e?e.twoColumn:this._needsCollapse(n.clientHeight,this._entries||{}),o.toggle(bv,t),a.toggle("djs-palette-two-column",t),"open"in e&&(o.toggle(gv,e.open),a.toggle("djs-palette-open",e.open)),r.fire("palette.changed",{twoColumn:t,open:this.isOpen()})},xv.prototype._update=function(){var e=ue(".djs-palette-entries",this._container),t=this._entries=this.getEntries();X(e),b(t,(function(t,n){var i=t.group||"default",r=ue("[data-group="+i+"]",e);r||(r=ce('<div class="group" data-group="'+i+'"></div>'),e.appendChild(r));var o=t.html||(t.separator?'<hr class="separator" />':'<div class="entry" draggable="true"></div>'),a=ce(o);r.appendChild(a),t.separator||(G(a,"data-action",n),t.title&&G(a,"title",t.title),t.className&&function(e,t){var n=K(e);(u(t)?t:t.split(/\s+/g)).forEach((function(e){n.add(e)}))}(a,t.className),t.imageUrl&&a.appendChild(ce('<img src="'+t.imageUrl+'">')))})),this.open()},xv.prototype.trigger=function(e,t,n){var i,r,o,a=this._entries,s=t.delegateTarget||t.target;if(!s)return t.preventDefault();(i=a[G(s,"data-action")])&&(r=i.action,o=t.originalEvent||t,f(r)?"click"===e&&r(o,n):r[e]&&r[e](o,n),t.preventDefault())},xv.prototype._layoutChanged=function(){this._toggleState({})},xv.prototype._needsCollapse=function(e,t){return e<46*Object.keys(t).length+50},xv.prototype.close=function(){this._toggleState({open:!1,twoColumn:!1})},xv.prototype.open=function(){this._toggleState({open:!0})},xv.prototype.toggle=function(e){this.isOpen()?this.close():this.open()},xv.prototype.isActiveTool=function(e){return e&&this._activeTool===e},xv.prototype.updateToolHighlight=function(e){var t;this._toolsContainer||(t=ue(".djs-palette-entries",this._container),this._toolsContainer=ue("[data-group=tools]",t)),b(this._toolsContainer.children,(function(t){var n=t.getAttribute("data-action");if(n){var i=K(t);n=n.replace("-tool",""),i.contains("entry")&&n===e?i.add("highlighted-entry"):i.remove("highlighted-entry")}}))},xv.prototype.isOpen=function(){return K(this._container).has(gv)},xv.prototype._getParentContainer=function(){return this._canvas.getContainer()},xv.HTML_MARKUP='<div class="djs-palette"><div class="djs-palette-entries"></div><div class="djs-palette-toggle"></div></div>';var Ev={__init__:["palette"],palette:["type",xv]},wv="crosshair";function Sv(e,t,n,i,r,o,a){this._selection=r,this._dragging=n,this._mouse=a;var s=this,c=function(e){var n,i=t.getActiveLayer();ge(n=e.frame=Me("rect"),{class:"djs-lasso-overlay",width:1,height:1,x:0,y:0}),me(i,n)},p=function(e){var t=e.frame,n=e.bbox;ge(t,{x:n.x,y:n.y,width:n.width,height:n.height})},l=function(e){e.frame&&Ce(e.frame)};o.registerTool("lasso",{tool:"lasso.selection",dragging:"lasso"}),e.on("lasso.selection.end",(function(t){var n=t.originalEvent.target;(t.hover||n instanceof SVGElement)&&e.once("lasso.selection.ended",(function(){s.activateLasso(t.originalEvent,!0)}))})),e.on("lasso.end",(function(e){var t=Cv(e),n=i.filter((function(e){return e}));s.select(n,t)})),e.on("lasso.start",(function(e){var t=e.context;t.bbox=Cv(e),c(t)})),e.on("lasso.move",(function(e){var t=e.context;t.bbox=Cv(e),p(t)})),e.on("lasso.cleanup",(function(e){var t=e.context;l(t)})),e.on("element.mousedown",1500,(function(e){if(_o(e))return s.activateLasso(e.originalEvent),!0}))}function Cv(e){var t={x:e.x-e.dx,y:e.y-e.dy},n={x:e.x,y:e.y};return t.x<=n.x&&t.y<n.y||t.x<n.x&&t.y<=n.y?{x:t.x,y:t.y,width:n.x-t.x,height:n.y-t.y}:t.x>=n.x&&t.y<n.y||t.x>n.x&&t.y<=n.y?{x:n.x,y:t.y,width:t.x-n.x,height:n.y-t.y}:t.x<=n.x&&t.y>n.y||t.x<n.x&&t.y>=n.y?{x:t.x,y:n.y,width:n.x-t.x,height:t.y-n.y}:t.x>=n.x&&t.y>n.y||t.x>n.x&&t.y>=n.y?{x:n.x,y:n.y,width:t.x-n.x,height:t.y-n.y}:{x:n.x,y:n.y,width:0,height:0}}Sv.$inject=["eventBus","canvas","dragging","elementRegistry","selection","toolManager","mouse"],Sv.prototype.activateLasso=function(e,t){this._dragging.init(e,"lasso",{autoActivate:t,cursor:wv,data:{context:{}}})},Sv.prototype.activateSelection=function(e,t){this._dragging.init(e,"lasso.selection",{trapClick:!1,autoActivate:t,cursor:wv,data:{context:{}}})},Sv.prototype.select=function(e,t){var n=function(e,t){var n={};return b(e,(function(e){var i=e;i.waypoints&&(i=pt(i)),!d(t.y)&&i.x>t.x&&(n[e.id]=e),!d(t.x)&&i.y>t.y&&(n[e.id]=e),i.x>t.x&&i.y>t.y&&(d(t.width)&&d(t.height)&&i.width+i.x<t.width+t.x&&i.height+i.y<t.height+t.y?n[e.id]=e:d(t.width)&&d(t.height)||(n[e.id]=e))})),n}(e,t);this._selection.select(R(n))},Sv.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},Sv.prototype.isActive=function(){var e=this._dragging.context();return e&&/^lasso/.test(e.prefix)};var Tv={__depends__:[Kd,Uc],__init__:["lassoTool"],lassoTool:["type",Sv]},Rv=1500,Pv="grab";function Av(e,t,n,i,r,o){this._dragging=n,this._mouse=o;var a=this,s=i.get("keyboard",!1);r.registerTool("hand",{tool:"hand",dragging:"hand.move"}),e.on("element.mousedown",Rv,(function(e){if(xo(e))return a.activateMove(e.originalEvent,!0),!1})),s&&s.addListener(Rv,(function(e){if(kv(e.keyEvent)&&!a.isActive()){var t=a._mouse.getLastMoveEvent();a.activateMove(t,!!t)}}),"keyboard.keydown"),s&&s.addListener(Rv,(function(e){kv(e.keyEvent)&&a.isActive()&&a.toggle()}),"keyboard.keyup"),e.on("hand.end",(function(t){var n=t.originalEvent.target;if(!(t.hover||n instanceof SVGElement))return!1;e.once("hand.ended",(function(){a.activateMove(t.originalEvent,{reactivate:!0})}))})),e.on("hand.move.move",(function(e){var n=t.viewbox().scale;t.scroll({dx:e.dx*n,dy:e.dy*n})})),e.on("hand.move.end",(function(t){var n=t.context.reactivate;return!xo(t)&&n&&e.once("hand.move.ended",(function(e){a.activateHand(e.originalEvent,!0,!0)})),!1}))}function kv(e){return Wo(" ",e)}Av.$inject=["eventBus","canvas","dragging","injector","toolManager","mouse"],Av.prototype.activateMove=function(e,t,n){"object"==typeof t&&(n=t,t=!1),this._dragging.init(e,"hand.move",{autoActivate:t,cursor:Pv,data:{context:n||{}}})},Av.prototype.activateHand=function(e,t,n){this._dragging.init(e,"hand",{trapClick:!1,autoActivate:t,cursor:Pv,data:{context:{reactivate:n}}})},Av.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateHand(e,!!e)},Av.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^(hand|hand\.move)$/.test(e.prefix)};var Mv={__depends__:[Kd,Uc],__init__:["handTool"],handTool:["type",Av]},Dv="connect-ok",Bv="connect-not-ok";function Nv(e,t,n,i,r,o,a){var s=this;this._dragging=t,this._rules=o,this._mouse=a,r.registerTool("global-connect",{tool:"global-connect",dragging:"global-connect.drag"}),e.on("global-connect.hover",(function(e){var t=e.context,n=e.hover,r=t.canStartConnect=s.canStartConnect(n);null!==r&&(t.startTarget=n,i.addMarker(n,r?Dv:Bv))})),e.on(["global-connect.out","global-connect.cleanup"],(function(e){var t=e.context.startTarget,n=e.context.canStartConnect;t&&i.removeMarker(t,n?Dv:Bv)})),e.on(["global-connect.ended"],(function(t){var i=t.context.startTarget,r={x:t.x,y:t.y};if(s.canStartConnect(i))return e.once("element.out",(function(){e.once(["connect.ended","connect.canceled"],(function(){e.fire("global-connect.drag.ended")})),n.start(null,i,r)})),!1}))}Nv.$inject=["eventBus","dragging","connect","canvas","toolManager","rules","mouse"],Nv.prototype.start=function(e,t){this._dragging.init(e,"global-connect",{autoActivate:t,trapClick:!1,data:{context:{}}})},Nv.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();return this.start(e,!!e)},Nv.prototype.isActive=function(){var e=this._dragging.context();return e&&/^global-connect/.test(e.prefix)},Nv.prototype.canStartConnect=function(e){return this._rules.allowed("connection.start",{source:e})};var Ov={__depends__:[uc,hs,ss,Kd,Uc],globalConnect:["type",Nv]};function jv(e,t,n,i,r,o,a,s){this._palette=e,this._create=t,this._elementFactory=n,this._spaceTool=i,this._lassoTool=r,this._handTool=o,this._globalConnect=a,this._translate=s,e.registerProvider(this)}jv.$inject=["palette","create","elementFactory","spaceTool","lassoTool","handTool","globalConnect","translate"],jv.prototype.getPaletteEntries=function(e){var t={},n=this._create,i=this._elementFactory,r=this._spaceTool,o=this._lassoTool,a=this._handTool,s=this._globalConnect,c=this._translate;function p(e,t,r,o,a){function s(t){var r=i.createShape(F({type:e},a));a&&(r.businessObject.di.isExpanded=a.isExpanded),n.start(t,r)}var p=e.replace(/^bpmn:/,"");return{group:t,className:r,title:o||c("Create {type}",{type:p}),action:{dragstart:s,click:s}}}function l(e){var t=i.createShape({type:"bpmn:SubProcess",x:0,y:0,isExpanded:!0}),r=i.createShape({type:"bpmn:StartEvent",x:40,y:82,parent:t});n.start(e,[t,r],{hints:{autoSelect:[t]}})}function u(e){n.start(e,i.createParticipantShape())}return F(t,{"hand-tool":{group:"tools",className:"bpmn-icon-hand-tool",title:c("Activate the hand tool"),action:{click:function(e){a.activateHand(e)}}},"lasso-tool":{group:"tools",className:"bpmn-icon-lasso-tool",title:c("Activate the lasso tool"),action:{click:function(e){o.activateSelection(e)}}},"space-tool":{group:"tools",className:"bpmn-icon-space-tool",title:c("Activate the create/remove space tool"),action:{click:function(e){r.activateSelection(e)}}},"global-connect-tool":{group:"tools",className:"bpmn-icon-connection-multi",title:c("Activate the global connect tool"),action:{click:function(e){s.start(e)}}},"tool-separator":{group:"tools",separator:!0},"create.start-event":p("bpmn:StartEvent","event","bpmn-icon-start-event-none",c("Create StartEvent")),"create.intermediate-event":p("bpmn:IntermediateThrowEvent","event","bpmn-icon-intermediate-event-none",c("Create Intermediate/Boundary Event")),"create.end-event":p("bpmn:EndEvent","event","bpmn-icon-end-event-none",c("Create EndEvent")),"create.exclusive-gateway":p("bpmn:ExclusiveGateway","gateway","bpmn-icon-gateway-none",c("Create Gateway")),"create.task":p("bpmn:Task","activity","bpmn-icon-task",c("Create Task")),"create.data-object":p("bpmn:DataObjectReference","data-object","bpmn-icon-data-object",c("Create DataObjectReference")),"create.data-store":p("bpmn:DataStoreReference","data-store","bpmn-icon-data-store",c("Create DataStoreReference")),"create.subprocess-expanded":{group:"activity",className:"bpmn-icon-subprocess-expanded",title:c("Create expanded SubProcess"),action:{dragstart:l,click:l}},"create.participant-expanded":{group:"collaboration",className:"bpmn-icon-participant",title:c("Create Pool/Participant"),action:{dragstart:u,click:u}},"create.group":p("bpmn:Group","artifact","bpmn-icon-group",c("Create Group"))}),t};var Lv={__depends__:[Ev,Ic,df,Tv,Mv,Ov,to],__init__:["paletteProvider"],paletteProvider:["type",jv]};function Iv(e,t,n,i,r){Ka.call(this,e),e.on("shape.move.move",250,(function(e){var o=e.context,a=o.canExecute;o.visualReplacements||(o.visualReplacements={}),a&&a.replacements?function(e){b(e.canExecute.replacements,(function(o){var a=o.oldElementId,s={type:o.newElementType};if(!e.visualReplacements[a]){var c=t.get(a);F(s,{x:c.x,y:c.y});var p=n.createShape(s);i.addShape(p,c.parent);var l=ue('[data-element-id="'+Ss(c.id)+'"]',e.dragGroup);l&&ge(l,{display:"none"});var u=r.addDragger(p,e.dragGroup);e.visualReplacements[a]=u,i.removeShape(p)}}))}(o):function(e){var t=e.visualReplacements;b(t,(function(n,i){var r=ue('[data-element-id="'+Ss(i)+'"]',e.dragGroup);r&&ge(r,{display:"inline"}),n.remove(),t[i]&&delete t[i]}))}(o)}))}Iv.$inject=["eventBus","elementRegistry","elementFactory","canvas","previewSupport"],n(Iv,Ka);var zv={__depends__:[Rc],__init__:["bpmnReplacePreview"],bpmnReplacePreview:["type",Iv]},Fv=40,$v=["x","y"],Hv=Math.abs;function Gv(e){e.on(["connect.hover","connect.move","connect.end"],1250,(function(e){var t=e.context,n=t.canExecute,i=t.start,r=t.hover,o=t.source,a=t.target;e.originalEvent&&Go(e.originalEvent)||(t.initialConnectionStart||(t.initialConnectionStart=t.connectionStart),n&&r&&function(e,t,n){$v.forEach((function(i){var r=Uv(i,t);e[i]<t[i]+n?ec(e,i,t[i]+n):e[i]>t[i]+r-n&&ec(e,i,t[i]+r-n)}))}(e,r,function(e){return Ar(e,"bpmn:Task")?10:20}(r)),r&&function(e,t){return w(t,(function(t){return Vv(e,t)}))}(n,["bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:SequenceFlow"])?(t.connectionStart=Qs(i),Ha(r,["bpmn:Event","bpmn:Gateway"])&&Wv(e,Qs(r)),Ha(r,["bpmn:Task","bpmn:SubProcess"])&&function(e,t){var n=Qs(t);$v.forEach((function(i){(function(e,t,n){return e[n]>t[n]+20&&e[n]<t[n]+Uv(n,t)-20})(e,t,i)&&ec(e,i,n[i])}))}(e,r),Ar(o,"bpmn:BoundaryEvent")&&a===o.host&&function(e){var t=e.context,n=t.source,i=t.target;if(function(e){var t=e.hover,n=e.source;return t&&n&&t===n}(t))return;var r=Qs(n),o=pn(r,i,-10),a=[];/top|bottom/.test(o)&&a.push("x");/left|right/.test(o)&&a.push("y");a.forEach((function(t){var n,i=e[t];Hv(i-r[t])<Fv&&(n=i>r[t]?r[t]+Fv:r[t]-Fv,ec(e,t,n))}))}(e)):Vv(n,"bpmn:MessageFlow")?(Ar(i,"bpmn:Event")&&(t.connectionStart=Qs(i)),Ar(r,"bpmn:Event")&&Wv(e,Qs(r))):t.connectionStart=t.initialConnectionStart)}))}function Wv(e,t){ec(e,"x",t.x),ec(e,"y",t.y)}function Vv(e,t){return e&&e.type===t}function Uv(e,t){return"x"===e?t.width:t.height}function qv(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}function Kv(e){this._snapValues={}}Gv.$inject=["eventBus"],qv.prototype.getSnapOrigin=function(e){return this._snapOrigins[e]},qv.prototype.setSnapOrigin=function(e,t){this._snapOrigins[e]=t,-1===this._snapLocations.indexOf(e)&&this._snapLocations.push(e)},qv.prototype.addDefaultSnap=function(e,t){var n=this._defaultSnaps[e];n||(n=this._defaultSnaps[e]=[]),n.push(t)},qv.prototype.getSnapLocations=function(){return this._snapLocations},qv.prototype.setSnapLocations=function(e){this._snapLocations=e},qv.prototype.pointsForTarget=function(e){var t=e.id||e,n=this._targets[t];return n||(n=this._targets[t]=new Kv).initDefaults(this._defaultSnaps),n},Kv.prototype.add=function(e,t){var n=this._snapValues[e];n||(n=this._snapValues[e]={x:[],y:[]}),-1===n.x.indexOf(t.x)&&n.x.push(t.x),-1===n.y.indexOf(t.y)&&n.y.push(t.y)},Kv.prototype.snap=function(e,t,n,i){var r=this._snapValues[t];return r&&function(e,t,n){var i,r;for(n=void 0===n?10:n,i=0;i<t.length;i++)if(r=t[i],Ks(r-e)<=n)return r}(e[n],r[n],i)},Kv.prototype.initDefaults=function(e){var t=this;b(e||{},(function(e,n){b(e,(function(e){t.add(n,e)}))}))};function Yv(e,t,n){var i=this;this._elementRegistry=e,t.on(["create.start","shape.move.start"],(function(e){i.initSnap(e)})),t.on(["create.move","create.end","shape.move.move","shape.move.end"],1250,(function(e){var t=e.context,r=t.shape,o=t.snapContext,a=t.target;if((!e.originalEvent||!Go(e.originalEvent))&&!Js(e)&&a){var s=o.pointsForTarget(a);s.initialized||((s=i.addSnapTargetPoints(s,r,a)).initialized=!0),n.snap(e,s)}})),t.on(["create.cleanup","shape.move.cleanup"],(function(){n.hide()}))}function Xv(e){return!!e.labelTarget}Yv.$inject=["elementRegistry","eventBus","snapping"],Yv.prototype.initSnap=function(e){var t,n=this._elementRegistry,i=e.context,r=i.shape,o=i.snapContext;o||(o=i.snapContext=new qv);var a=(t=n.get(r.id)?Qs(r,e):{x:e.x+Qs(r).x,y:e.y+Qs(r).y}).x-r.width/2,s=t.y-r.height/2,c=t.x+r.width/2,p=t.y+r.height/2;return o.setSnapOrigin("mid",{x:t.x-e.x,y:t.y-e.y}),Xv(r)||(o.setSnapOrigin("top-left",{x:a-e.x,y:s-e.y}),o.setSnapOrigin("bottom-right",{x:c-e.x,y:p-e.y})),o},Yv.prototype.addSnapTargetPoints=function(e,t,n){return b(this.getSnapTargets(t,n),(function(n){if(Xv(n))Xv(t)&&e.add("mid",Qs(n));else if(n.waypoints){if(n.waypoints.length<3)return;b(n.waypoints.slice(1,-1),(function(t){e.add("mid",t)}))}else{e.add("mid",Qs(n))}})),d(t.x)&&d(t.y)?(this._elementRegistry.get(t.id)&&e.add("mid",Qs(t)),e):e},Yv.prototype.getSnapTargets=function(e,t){return tc(t).filter((function(e){return!e.hidden}))};function Zv(e,t){t.invoke(Yv,this),e.on(["create.move","create.end"],1500,Qv),e.on(["create.move","create.end","shape.move.move","shape.move.end"],1500,(function(e){var t=e.context,n=t.canExecute,i=t.target;n&&("attach"===n||n.attach)&&!Js(e)&&function(e,t){var n,i=an(t),r=Uh(e,t),o=e.context.shape;n=o.parent?{x:0,y:0}:cn(o);/top/.test(r)?ec(e,"y",i.top-n.y):/bottom/.test(r)&&ec(e,"y",i.bottom-n.y);/left/.test(r)?ec(e,"x",i.left-n.x):/right/.test(r)&&ec(e,"x",i.right-n.x)}(e,i)}))}function Qv(e){var t=e.context.createConstraints;if(t){var n=t.top,i=t.right,r=t.bottom,o=t.left;(o&&o>=e.x||i&&i<=e.x)&&ec(e,"x",e.x),(n&&n>=e.y||r&&r<=e.y)&&ec(e,"y",e.y)}}function Jv(e,t){return-1!==e.indexOf(t)}function ey(e,t,n){return t?{x:e.x-n.x,y:e.y-n.y}:{x:e.x,y:e.y}}n(Zv,Yv),Zv.$inject=["eventBus","injector"],Zv.prototype.initSnap=function(e){var t=Yv.prototype.initSnap.call(this,e),n=e.shape,i=!!this._elementRegistry.get(n.id);return b(n.outgoing,(function(n){var r=n.waypoints[0];r=r.original||r,t.setSnapOrigin(n.id+"-docking",ey(r,i,e))})),b(n.incoming,(function(n){var r=n.waypoints[n.waypoints.length-1];r=r.original||r,t.setSnapOrigin(n.id+"-docking",ey(r,i,e))})),Ar(n,"bpmn:Participant")&&t.setSnapLocations(["top-left","bottom-right","mid"]),t},Zv.prototype.addSnapTargetPoints=function(e,t,n){Yv.prototype.addSnapTargetPoints.call(this,e,t,n);var i=this.getSnapTargets(t,n);b(i,(function(n){var i;(function(e){if(Ar(e,"bpmn:SubProcess")&&Mr(e))return!0;return Ar(e,"bpmn:Participant")}(n)||(i="bpmn:TextAnnotation",[t,n].every((function(e){return Ar(e,i)}))))&&(e.add("top-left",Xs(n)),e.add("bottom-right",Zs(n)))}));var r=this._elementRegistry;return b(t.incoming,(function(n){if(r.get(t.id)){Jv(i,n.source)||e.add("mid",cn(n.source));var o=n.waypoints[0];e.add(n.id+"-docking",o.original||o)}})),b(t.outgoing,(function(n){if(r.get(t.id)){Jv(i,n.target)||e.add("mid",cn(n.target));var o=n.waypoints[n.waypoints.length-1];e.add(n.id+"-docking",o.original||o)}})),Ar(n,"bpmn:SequenceFlow")&&(e=this.addSnapTargetPoints(e,t,n.parent)),e},Zv.prototype.getSnapTargets=function(e,t){return Yv.prototype.getSnapTargets.call(this,e,t).filter((function(e){return!Ar(e,"bpmn:Lane")}))};function ty(e,t){var n=this;e.on(["resize.start"],(function(e){n.initSnap(e)})),e.on(["resize.move","resize.end"],1250,(function(e){var i=e.context,r=i.shape,o=r.parent,a=i.direction,s=i.snapContext;if(!(e.originalEvent&&Go(e.originalEvent)||Js(e))){var c=s.pointsForTarget(o);c.initialized||((c=n.addSnapTargetPoints(c,r,o,a)).initialized=!0),function(e){return"n"===e||"s"===e}(a)&&ec(e,"x",e.x),function(e){return"e"===e||"w"===e}(a)&&ec(e,"y",e.y),t.snap(e,c)}})),e.on(["resize.cleanup"],(function(){t.hide()}))}function ny(e,t){var n=cn(e),i=an(e),r={x:n.x,y:n.y};return-1!==t.indexOf("n")?r.y=i.top:-1!==t.indexOf("s")&&(r.y=i.bottom),-1!==t.indexOf("e")?r.x=i.right:-1!==t.indexOf("w")&&(r.x=i.left),r}ty.prototype.initSnap=function(e){var t=e.context,n=t.shape,i=t.direction,r=t.snapContext;r||(r=t.snapContext=new qv);var o=ny(n,i);return r.setSnapOrigin("corner",{x:o.x-e.x,y:o.y-e.y}),r},ty.prototype.addSnapTargetPoints=function(e,t,n,i){return b(this.getSnapTargets(t,n),(function(t){e.add("corner",Zs(t)),e.add("corner",Xs(t))})),e.add("corner",ny(t,i)),e},ty.$inject=["eventBus","snapping"],ty.prototype.getSnapTargets=function(e,t){return tc(t).filter((function(t){return!(n=t,i=e,n.host===i||function(e){return!!e.waypoints}(t)||function(e){return!!e.hidden}(t)||function(e){return!!e.labelTarget}(t));var n,i}))};function iy(e){this._canvas=e,this._asyncHide=L(I(this.hide,this),1e3)}iy.$inject=["canvas"],iy.prototype.snap=function(e,t){var n=e.context.snapContext,i=n.getSnapLocations(),r={x:Js(e,"x"),y:Js(e,"y")};b(i,(function(i){var o=n.getSnapOrigin(i),a={x:e.x+o.x,y:e.y+o.y};if(b(["x","y"],(function(e){var n;r[e]||void 0!==(n=t.snap(a,i,e,7))&&(r[e]={value:n,originValue:n-o[e]})})),r.x&&r.y)return!1})),this.showSnapLine("vertical",r.x&&r.x.value),this.showSnapLine("horizontal",r.y&&r.y.value),b(["x","y"],(function(t){var n=r[t];h(n)&&ec(e,t,n.originValue)}))},iy.prototype._createLine=function(e){var t=this._canvas.getLayer("snap"),n=Me("path");return ge(n,{d:"M0,0 L0,0"}),we(n).add("djs-snap-line"),me(t,n),{update:function(t){d(t)?ge(n,"horizontal"===e?{d:"M-100000,"+t+" L+100000,"+t,display:""}:{d:"M "+t+",-100000 L "+t+", +100000",display:""}):ge(n,{display:"none"})}}},iy.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}},iy.prototype.showSnapLine=function(e,t){var n=this.getSnapLine(e);n&&n.update(t),this._asyncHide()},iy.prototype.getSnapLine=function(e){return this._snapLines||this._createSnapLines(),this._snapLines[e]},iy.prototype.hide=function(){b(this._snapLines,(function(e){e.update()}))};var ry={__depends__:[{__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",Yv],resizeSnapping:["type",ty],snapping:["type",iy]}],__init__:["connectSnapping","createMoveSnapping"],connectSnapping:["type",Gv],createMoveSnapping:["type",Zv]};function oy(e,t,n,i){this._open=!1,this._results=[],this._eventMaps=[],this._canvas=e,this._eventBus=t,this._overlays=n,this._selection=i,this._container=ce(oy.BOX_HTML),this._searchInput=ue(oy.INPUT_SELECTOR,this._container),this._resultsContainer=ue(oy.RESULTS_CONTAINER_SELECTOR,this._container),this._canvas.getContainer().appendChild(this._container),t.on(["canvas.destroy","diagram.destroy"],this.close,this)}function ay(e,t,n){var i=function(e){var t="";return e.forEach((function(e){e.matched?t+='<strong class="'+oy.RESULT_HIGHLIGHT_CLASS+'">'+Ts(e.matched)+"</strong>":t+=Ts(e.normal)})),""!==t?t:null}(t),r=ce(n);r.innerHTML=i,e.appendChild(r)}oy.$inject=["canvas","eventBus","overlays","selection"],oy.prototype._bindEvents=function(){var e=this;function t(t,n,i,r){e._eventMaps.push({el:t,type:i,listener:se.bind(t,n,i,r)})}t(document,"html","click",(function(t){e.close()})),t(this._container,oy.INPUT_SELECTOR,"click",(function(e){e.stopPropagation(),e.delegateTarget.focus()})),t(this._container,oy.RESULT_SELECTOR,"mouseover",(function(t){t.stopPropagation(),e._scrollToNode(t.delegateTarget),e._preselect(t.delegateTarget)})),t(this._container,oy.RESULT_SELECTOR,"click",(function(t){t.stopPropagation(),e._select(t.delegateTarget)})),t(this._container,oy.INPUT_SELECTOR,"keydown",(function(e){38===e.keyCode&&e.preventDefault(),40===e.keyCode&&e.preventDefault()})),t(this._container,oy.INPUT_SELECTOR,"keyup",(function(t){if(27===t.keyCode)return e.close();if(13===t.keyCode){var n=e._getCurrentResult();return n?e._select(n):e.close()}return 38===t.keyCode?e._scrollToDirection(!0):40===t.keyCode?e._scrollToDirection():void(37!==t.keyCode&&39!==t.keyCode&&e._search(t.delegateTarget.value))}))},oy.prototype._unbindEvents=function(){this._eventMaps.forEach((function(e){se.unbind(e.el,e.type,e.listener)}))},oy.prototype._search=function(e){var t=this;if(this._clearResults(),e&&""!==e){var n=this._searchProvider.find(e);if(n.length){n.forEach((function(e){var n=e.element.id,i=t._createResultNode(e,n);t._results[n]={element:e.element,node:i}}));var i=ue(oy.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}}},oy.prototype._scrollToDirection=function(e){var t=this._getCurrentResult();if(t){var n=e?t.previousElementSibling:t.nextElementSibling;n&&(this._scrollToNode(n),this._preselect(n))}},oy.prototype._scrollToNode=function(e){if(e&&e!==this._getCurrentResult()){var t=e.offsetTop,n=this._resultsContainer.scrollTop,i=t-this._resultsContainer.clientHeight+e.clientHeight;t<n?this._resultsContainer.scrollTop=t:n<i&&(this._resultsContainer.scrollTop=i)}},oy.prototype._clearResults=function(){X(this._resultsContainer),this._results=[],this._resetOverlay(),this._eventBus.fire("searchPad.cleared")},oy.prototype._getCurrentResult=function(){return ue(oy.RESULT_SELECTED_SELECTOR,this._resultsContainer)},oy.prototype._createResultNode=function(e,t){var n=ce(oy.RESULT_HTML);return e.primaryTokens.length>0&&ay(n,e.primaryTokens,oy.RESULT_PRIMARY_HTML),ay(n,e.secondaryTokens,oy.RESULT_SECONDARY_HTML),G(n,oy.RESULT_ID_ATTRIBUTE,t),this._resultsContainer.appendChild(n),n},oy.prototype.registerProvider=function(e){this._searchProvider=e},oy.prototype.open=function(){if(!this._searchProvider)throw new Error("no search provider registered");this.isOpen()||(this._bindEvents(),this._open=!0,K(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))},oy.prototype.close=function(){this.isOpen()&&(this._unbindEvents(),this._open=!1,K(this._container).remove("open"),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._resetOverlay(),this._eventBus.fire("searchPad.closed"))},oy.prototype.toggle=function(){this.isOpen()?this.close():this.open()},oy.prototype.isOpen=function(){return this._open},oy.prototype._preselect=function(e){var t=this._getCurrentResult();if(e!==t){t&&K(t).remove(oy.RESULT_SELECTED_CLASS);var n=G(e,oy.RESULT_ID_ATTRIBUTE),i=this._results[n].element;K(e).add(oy.RESULT_SELECTED_CLASS),this._resetOverlay(i),this._canvas.scrollToElement(i,{top:400}),this._selection.select(i),this._eventBus.fire("searchPad.preselected",i)}},oy.prototype._select=function(e){var t=G(e,oy.RESULT_ID_ATTRIBUTE),n=this._results[t].element;this.close(),this._resetOverlay(),this._canvas.scrollToElement(n,{top:400}),this._selection.select(n),this._eventBus.fire("searchPad.selected",n)},oy.prototype._resetOverlay=function(e){if(this._overlayId&&this._overlays.remove(this._overlayId),e){var t=function(e){var t=6,n=e.width+2*t,i=e.height+2*t,r=["width: "+n+"px","height: "+i+"px"].join("; ");return{position:{bottom:i-t,right:n-t},show:!0,html:'<div style="'+r+'" class="'+oy.OVERLAY_CLASS+'"></div>'}}(pt(e));this._overlayId=this._overlays.add(e,t)}},oy.CONTAINER_SELECTOR=".djs-search-container",oy.INPUT_SELECTOR=".djs-search-input input",oy.RESULTS_CONTAINER_SELECTOR=".djs-search-results",oy.RESULT_SELECTOR=".djs-search-result",oy.RESULT_SELECTED_CLASS="djs-search-result-selected",oy.RESULT_SELECTED_SELECTOR="."+oy.RESULT_SELECTED_CLASS,oy.RESULT_ID_ATTRIBUTE="data-result-id",oy.RESULT_HIGHLIGHT_CLASS="djs-search-highlight",oy.OVERLAY_CLASS="djs-search-overlay",oy.BOX_HTML='<div class="djs-search-container djs-draggable djs-scrollable"><div class="djs-search-input"><input type="text"/></div><div class="djs-search-results"></div></div>',oy.RESULT_HTML='<div class="djs-search-result"></div>',oy.RESULT_PRIMARY_HTML='<div class="djs-search-result-primary"></div>',oy.RESULT_SECONDARY_HTML='<p class="djs-search-result-secondary"></p>';var sy={__depends__:[$o,No],searchPad:["type",oy]};function cy(e,t,n){this._elementRegistry=e,this._canvas=n,t.registerProvider(this)}function py(e){return g(e,(function(e){return!!e.matched})).length>0}function ly(e,t){var n=[],i=e;if(!e)return n;e=e.toLowerCase(),t=t.toLowerCase();var r=e.indexOf(t);return r>-1?(0!==r&&n.push({normal:i.substr(0,r)}),n.push({matched:i.substr(r,t.length)}),t.length+r<e.length&&n.push({normal:i.substr(t.length+r,e.length)})):n.push({normal:i}),n}cy.$inject=["elementRegistry","searchPad","canvas"],cy.prototype.find=function(e){var t=this._canvas.getRootElement(),n=this._elementRegistry.filter((function(e){return!e.labelTarget}));return n=g(n,(function(e){return e!==t})),n=M(n=g(n=S(n,(function(t){return{primaryTokens:ly(Or(t),e),secondaryTokens:ly(t.id,e),element:t}})),(function(e){return py(e.primaryTokens)||py(e.secondaryTokens)})),(function(e){return Or(e.element)+e.element.id}))};var uy={__depends__:[sy],__init__:["bpmnSearch"],bpmnSearch:["type",cy]};function hy(e){Pr.call(this,e)}return n(hy,Pr),hy.Viewer=Ho,hy.NavigatedViewer=ga,hy.prototype.createDiagram=gr((function(){return this.importXML('<?xml version="1.0" encoding="UTF-8"?><bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" targetNamespace="http://bpmn.io/schema/bpmn" id="Definitions_1"><bpmn:process id="Process_1" isExecutable="false"><bpmn:startEvent id="StartEvent_1"/></bpmn:process><bpmndi:BPMNDiagram id="BPMNDiagram_1"><bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"><bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"><dc:Bounds height="36.0" width="36.0" x="173.0" y="102.0"/></bpmndi:BPMNShape></bpmndi:BPMNPlane></bpmndi:BPMNDiagram></bpmn:definitions>')})),hy.prototype._interactionModules=[ia,ua,Ra,ya],hy.prototype._modelingModules=[Ba,qa,ls,es,oc,uc,dc,Kp,op,Ic,Jp,ol,bl,_l,wl,Ml,Ql,av,mv,Lv,zv,Wl,ry,uy],hy.prototype._modules=[].concat(Ho.prototype._modules,hy.prototype._interactionModules,hy.prototype._modelingModules),hy}));
|
|
34
|
+
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */!function(t,n){var i;i=e,t.exports=function(e){if(e.CSS&&e.CSS.escape)return e.CSS.escape;var t=function(e){if(0==arguments.length)throw new TypeError("`CSS.escape` requires an argument.");for(var t,n=String(e),i=n.length,r=-1,o="",a=n.charCodeAt(0);++r<i;)0!=(t=n.charCodeAt(r))?o+=t>=1&&t<=31||127==t||0==r&&t>=48&&t<=57||1==r&&t>=48&&t<=57&&45==a?"\\"+t.toString(16)+" ":0==r&&1==i&&45==t||!(t>=128||45==t||95==t||t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122)?"\\"+n.charAt(r):n.charAt(r):o+="�";return o};return e.CSS||(e.CSS={}),e.CSS.escape=t,t}(i)}(ws);var Ss=ws.exports,Cs={"&":"&","<":"<",">":">",'"':""","'":"'"};function Ts(e){return(e=""+e)&&e.replace(/[&<>"']/g,(function(e){return Cs[e]}))}function Rs(e,t,n,i,r){function o(e,n){var o=n.waypoints,a=gs(t,o,e);if(a)return!function(e,t,n){var i,r,o,a,s,c,p=e.index,l=e.point;return!(p<=0||e.bendpoint)&&(o=Et(i=t[p-1],r=t[p]),a=xt(i,r),s=Math.abs(l.x-o.x),c=Math.abs(l.y-o.y),a&&s<=n&&c<=n)}(a,o,function(e,t){var n,i,r=e.waypoints;return t.index<=0||t.bendpoint?null:(i=xt((n={start:r[t.index-1],end:r[t.index]}).start,n.end))?Es("h"===i?n.end.x-n.start.x:n.end.y-n.start.y)/2:null}(n,a))?i.start(e,n,a.index,!a.bendpoint):r.start(e,n,a.index),!0}function a(e,t,i){re.bind(e,t,(function(e){n.triggerMouseEvent(t,e,i),e.stopPropagation()}))}function s(e,n){var i=t.getLayer("overlays"),r=ue('.djs-bendpoints[data-element-id="'+Ss(e.id)+'"]',i);return!r&&n&&(ge(r=Me("g"),{"data-element-id":e.id}),we(r).add("djs-bendpoints"),me(i,r),a(r,"mousedown",e),a(r,"click",e),a(r,"dblclick",e)),r}function c(e,t){return ue('.djs-segment-dragger[data-segment-idx="'+e+'"]',t)}function p(e,t){t.waypoints.forEach((function(t,n){var i=bs(e);me(e,i),Vn(i,t.x,t.y)})),bs(e,"floating")}function l(e,t){for(var n,i,r,o=t.waypoints,s=1;s<o.length;s++)xt(n=o[s-1],i=o[s])&&(ge(r=_s(e,n,i),{"data-segment-idx":s}),a(r,"mousemove",t))}function u(e){var t=s(e);return t||(p(t=s(e,!0),e),l(t,e)),t}function h(e){var t=s(e);t&&(!function(e){b(he(".djs-segment-dragger",e),(function(e){Ce(e)}))}(t),function(e){b(he(".djs-bendpoint",e),(function(e){Ce(e)}))}(t),l(t,e),p(t,e))}function d(e,t,n){var i,r,o=c(t.index,e),a=n[t.index-1],s=n[t.index],p=t.point,l=Et(a,s),u=xt(a,s);o&&(i=function(e){return ue(".djs-visual",e)}(o),r={x:p.x-l.x,y:p.y-l.y},"v"===u&&(r={x:r.y,y:r.x}),Vn(i,r.x,r.y))}e.on("connection.changed",(function(e){h(e.element)})),e.on("connection.remove",(function(e){var t=s(e.element);t&&Ce(t)})),e.on("element.marker.update",(function(e){var t,n=e.element;n.waypoints&&(t=u(n),e.add?we(t).add(e.marker):we(t).remove(e.marker))})),e.on("element.mousemove",(function(e){var n,i,r=e.element,o=r.waypoints;if(o){if(n=s(r,!0),!(i=gs(t,o,e.originalEvent)))return;!function(e,t){var n=ue(".floating",e),i=t.point;n&&Vn(n,i.x,i.y)}(n,i),i.bendpoint||d(n,i,o)}})),e.on("element.mousedown",(function(e){if(bo(e)){var t=e.originalEvent,n=e.element;if(n.waypoints)return o(t,n)}})),e.on("selection.changed",(function(e){var t=e.newSelection[0];t&&t.waypoints&&u(t)})),e.on("element.hover",(function(e){var t=e.element;t.waypoints&&(u(t),n.registerEvent(e.gfx,"mousemove","element.mousemove"))})),e.on("element.out",(function(e){n.unregisterEvent(e.gfx,"mousemove","element.mousemove")})),e.on("element.updateId",(function(e){var t=e.element,n=e.newId;if(t.waypoints){var i=s(t);i&&ge(i,{"data-element-id":n})}})),this.addHandles=u,this.updateHandles=h,this.getBendpointsContainer=s,this.getSegmentDragger=c}Rs.$inject=["eventBus","canvas","interactionEvents","bendpointMove","connectionSegmentMove"];var Ps=Math.round,As="reconnectStart",ks="reconnectEnd",Ms="updateWaypoints";function Ds(e,t,n,i,r,o){this._injector=e,this.start=function(e,t,o,a){var s,c=n.getGraphics(t),p=t.source,l=t.target,u=t.waypoints,h=(s=a||0!==o?a||o!==u.length-1?Ms:ks:As)===Ms?"connection.updateWaypoints":"connection.reconnect",d=r.allowed(h,{connection:t,source:p,target:l});!1===d&&(d=r.allowed(h,{connection:t,source:l,target:p})),!1!==d&&i.init(e,"bendpoint.move",{data:{connection:t,connectionGfx:c,context:{allowed:d,bendpointIndex:o,connection:t,source:p,target:l,insert:a,type:s}}})},t.on("bendpoint.move.hover",(function(e){var t,n=e.context,i=n.connection,o=i.source,a=i.target,s=e.hover,c=n.type;if(n.hover=s,s){var p=c===Ms?"connection.updateWaypoints":"connection.reconnect";if(t=n.allowed=r.allowed(p,{connection:i,source:c===As?s:o,target:c===ks?s:a}))return n.source=c===As?s:o,void(n.target=c===ks?s:a);!1===t&&(t=n.allowed=r.allowed(p,{connection:i,source:c===ks?s:a,target:c===As?s:o})),t&&(n.source=c===ks?s:a,n.target=c===As?s:o)}})),t.on(["bendpoint.move.out","bendpoint.move.cleanup"],(function(e){var t=e.context,n=t.type;t.hover=null,t.source=null,t.target=null,n!==Ms&&(t.allowed=!1)})),t.on("bendpoint.move.end",(function(e){var t=e.context,n=t.allowed,i=t.bendpointIndex,r=t.connection,a=t.insert,s=r.waypoints.slice(),c=t.source,p=t.target,l=t.type,u=t.hints||{},h={x:Ps(e.x),y:Ps(e.y)};if(!n)return!1;l===Ms?(a?s.splice(i,0,h):s[i]=h,u.bendpointMove={insert:a,bendpointIndex:i},s=this.cropWaypoints(r,s),o.updateWaypoints(r,function(e){e=e.slice();for(var t,n,i,r=0;e[r];)t=e[r],n=e[r-1],0===gt(t,i=e[r+1])||bt(n,i,t)?e.splice(r,1):r++;return e}(s),u)):(l===As?(u.docking="source",Bs(t)&&(u.docking="target",u.newWaypoints=s.reverse())):l===ks&&(u.docking="target",Bs(t)&&(u.docking="source",u.newWaypoints=s.reverse())),o.reconnect(r,c,p,h,u))}),this)}function Bs(e){var t=e.hover,n=e.source,i=e.target,r=e.type;return r===As?t&&i&&t===i&&n!==i:r===ks?t&&n&&t===n&&n!==i:void 0}Ds.$inject=["injector","eventBus","canvas","dragging","rules","modeling"],Ds.prototype.cropWaypoints=function(e,t){var n=this._injector.get("connectionDocking",!1);if(!n)return t;var i=e.waypoints;return e.waypoints=t,e.waypoints=n.getCroppedWaypoints(e),t=e.waypoints,e.waypoints=i,t};var Ns="updateWaypoints",Os="connect-ok",js="connect-not-ok",Ls="connect-hover",Is="djs-updating",zs="djs-element-hidden";function Fs(e,t,n,i){this._injector=t;var r=t.get("connectionPreview",!1);n.on("bendpoint.move.start",(function(e){var t=e.context,n=t.bendpointIndex,r=t.connection,o=t.insert,a=r.waypoints,s=a.slice();t.waypoints=a,o&&s.splice(n,0,{x:e.x,y:e.y}),r.waypoints=s,we(t.draggerGfx=bs(i.getLayer("overlays"))).add("djs-dragging"),i.addMarker(r,zs),i.addMarker(r,Is)})),n.on("bendpoint.move.hover",(function(e){var t=e.context,n=t.allowed,r=t.hover,o=t.type;if(r){if(i.addMarker(r,Ls),o===Ns)return;n?(i.removeMarker(r,js),i.addMarker(r,Os)):!1===n&&(i.removeMarker(r,Os),i.addMarker(r,js))}})),n.on(["bendpoint.move.out","bendpoint.move.cleanup"],1100,(function(e){var t=e.context,n=t.hover,r=t.target;n&&(i.removeMarker(n,Ls),i.removeMarker(n,r?Os:js))})),n.on("bendpoint.move.move",(function(t){var n=t.context,i=n.allowed,o=n.bendpointIndex,a=n.draggerGfx,s=n.hover,c=n.type,p=n.connection,l=p.source,u=p.target,h=p.waypoints.slice(),d={x:t.x,y:t.y},f=n.hints||{},m={};r&&(f.connectionStart&&(m.connectionStart=f.connectionStart),f.connectionEnd&&(m.connectionEnd=f.connectionEnd),"reconnectStart"===c?Bs(n)?(m.connectionEnd=m.connectionEnd||d,m.source=u,m.target=s||l,h=h.reverse()):(m.connectionStart=m.connectionStart||d,m.source=s||l,m.target=u):"reconnectEnd"===c?Bs(n)?(m.connectionStart=m.connectionStart||d,m.source=s||u,m.target=l,h=h.reverse()):(m.connectionEnd=m.connectionEnd||d,m.source=l,m.target=s||u):(m.noCropping=!0,m.noLayout=!0,h[o]=d),c===Ns&&(h=e.cropWaypoints(p,h)),m.waypoints=h,r.drawPreview(n,i,m)),Vn(a,t.x,t.y)}),this),n.on(["bendpoint.move.end","bendpoint.move.cancel"],1100,(function(e){var t=e.context,n=t.connection,o=t.draggerGfx,a=t.hover,s=t.target,c=t.waypoints;n.waypoints=c,Ce(o),i.removeMarker(n,Is),i.removeMarker(n,zs),a&&(i.removeMarker(a,Os),i.removeMarker(a,s?Os:js)),r&&r.cleanUp(t)}))}Fs.$inject=["bendpointMove","injector","eventBus","canvas"];var $s="connect-hover",Hs="djs-updating";function Gs(e,t,n){return Ws(e,t,e[t]+n)}function Ws(e,t,n){return{x:"x"===t?n:e.x,y:"y"===t?n:e.y}}function Vs(e){return"x"===e?"y":"x"}function Us(e,t,n){var i,r;return e.original?e.original:(i=cn(t),Ws(e,r=Vs(n),i[r]))}function qs(e,t,n,i,r,o){var a=e.get("connectionDocking",!1);function s(e,t){if(!a)return t;var n,i=e.waypoints;return e.waypoints=t,n=a.getCroppedWaypoints(e),e.waypoints=i,n}function c(e){r.update("connection",e.connection,e.connectionGfx)}function p(e,t,n){var i=e.newWaypoints,r=function(e,t,n,i){var r=Math.max(t[i],n[i]),o=Math.min(t[i],n[i]);return Ws(t,i,Math.min(Math.max(o+20,e[i]),r-20))}(n,i[e.segmentStartIndex+t],i[e.segmentEndIndex+t],Vs(e.axis));Vn(e.draggerGfx,r.x,r.y)}this.start=function(e,t,r){var o,a,s,c,p=n.getGraphics(t),l=r-1,u=r,h=t.waypoints,d=h[l],f=h[u],m=gs(n,h,e);(a=xt(d,f))&&(s="v"===a?"x":"y",0===l&&(d=Us(d,t.source,s)),u===h.length-1&&(f=Us(f,t.target,s)),o={connection:t,segmentStartIndex:l,segmentEndIndex:u,segmentStart:d,segmentEnd:f,axis:s,dragPosition:c=m?m.point:{x:(d.x+f.x)/2,y:(d.y+f.y)/2}},i.init(e,c,"connectionSegment.move",{cursor:"x"===s?"resize-ew":"resize-ns",data:{connection:t,connectionGfx:p,context:o}}))},t.on("connectionSegment.move.start",(function(e){var t=e.context,i=e.connection,r=n.getLayer("overlays");t.originalWaypoints=i.waypoints.slice(),t.draggerGfx=_s(r,t.segmentStart,t.segmentEnd),we(t.draggerGfx).add("djs-dragging"),n.addMarker(i,Hs)})),t.on("connectionSegment.move.move",(function(e){var t,n,i=e.context,r=i.connection,o=i.segmentStartIndex,a=i.segmentEndIndex,l=i.segmentStart,u=i.segmentEnd,h=i.axis,d=i.originalWaypoints.slice(),f=Gs(l,h,e["d"+h]),m=Gs(u,h,e["d"+h]),v=d.length,y=0;d[o]=f,d[a]=m,o<2&&(t=pn(r.source,f),1===o?"intersect"===t&&(d.shift(),d[0]=f,y--):"intersect"!==t&&(d.unshift(l),y++)),a>v-3&&(n=pn(r.target,m),a===v-2?"intersect"===n&&(d.pop(),d[d.length-1]=m):"intersect"!==n&&d.push(u)),i.newWaypoints=r.waypoints=s(r,d),p(i,y,e),i.newSegmentStartIndex=o+y,c(e)})),t.on("connectionSegment.move.hover",(function(e){e.context.hover=e.hover,n.addMarker(e.hover,$s)})),t.on(["connectionSegment.move.out","connectionSegment.move.cleanup"],(function(e){var t=e.context.hover;t&&n.removeMarker(t,$s)})),t.on("connectionSegment.move.cleanup",(function(e){var t=e.context,i=t.connection;t.draggerGfx&&Ce(t.draggerGfx),n.removeMarker(i,Hs)})),t.on(["connectionSegment.move.cancel","connectionSegment.move.end"],(function(e){var t=e.context;t.connection.waypoints=t.originalWaypoints,c(e)})),t.on("connectionSegment.move.end",(function(e){var t=e.context,n=t.connection,i=t.newWaypoints,r=t.newSegmentStartIndex,a=function(e,t){var n=0;return{waypoints:e.filter((function(i,r){return!bt(e[r-1],e[r+1],i)||(n=r<=t?n-1:n,!1)})),segmentOffset:n}}(i=i.map((function(e){return{original:e.original,x:Math.round(e.x),y:Math.round(e.y)}})),r),c=s(n,a.waypoints),p=a.segmentOffset,l={segmentMove:{segmentStartIndex:t.segmentStartIndex,newSegmentStartIndex:r+p}};o.updateWaypoints(n,c,l)}))}qs.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];var Ks=Math.abs,Ys=Math.round;function Xs(e){return{x:e.x,y:e.y}}function Zs(e){return{x:e.x+e.width,y:e.y+e.height}}function Qs(e,t){return!e||isNaN(e.x)||isNaN(e.y)?t:{x:Ys(e.x+e.width/2),y:Ys(e.y+e.height/2)}}function Js(e,t){var n=e.snapped;return!!n&&("string"==typeof t?n[t]:n.x&&n.y)}function ec(e,t,n){if("string"!=typeof t)throw new Error("axis must be in [x, y]");if("number"!=typeof n&&!1!==n)throw new Error("value must be Number or false");var i,r=e[t],o=e.snapped=e.snapped||{};return!1===n?o[t]=!1:(o[t]=!0,i=n-r,e[t]+=i,e["d"+t]+=i),r}function tc(e){return e.children||[]}var nc=Math.abs,ic=Math.round;function rc(e){function t(e,t){if(u(e)){for(var n=e.length;n--;)if(nc(e[n]-t)<=10)return e[n]}else{var i=t%(e=+e);if(i<10)return t-i;if(i>e-10)return t-i+e}return t}function n(e){if(e.width)return{x:ic(e.width/2+e.x),y:ic(e.height/2+e.y)}}e.on("connectionSegment.move.move",1500,(function(e){var i,r,o=function(e){var t=e.snapPoints,i=e.connection,r=i.waypoints,o=e.segmentStart,a=e.segmentStartIndex,s=e.segmentEnd,c=e.segmentEndIndex,p=e.axis;if(t)return t;var l=[r[a-1],o,s,r[c+1]];return a<2&&l.unshift(n(i.source)),c>r.length-3&&l.unshift(n(i.target)),e.snapPoints=t={horizontal:[],vertical:[]},b(l,(function(e){e&&(e=e.original||e,"y"===p&&t.horizontal.push(e.y),"x"===p&&t.vertical.push(e.x))})),t}(e.context),a=e.x,s=e.y;if(o){var c=a-(i=t(o.vertical,a)),p=s-(r=t(o.horizontal,s));F(e,{dx:e.dx-c,dy:e.dy-p,x:i,y:r}),(c||-1!==o.vertical.indexOf(a))&&ec(e,"x",i),(p||-1!==o.horizontal.indexOf(s))&&ec(e,"y",r)}})),e.on(["bendpoint.move.move","bendpoint.move.end"],1500,(function(e){var i,r,o=e.context,a=function(e){var t=e.snapPoints,n=e.connection.waypoints,i=e.bendpointIndex;if(t)return t;var r=[n[i-1],n[i+1]];return e.snapPoints=t={horizontal:[],vertical:[]},b(r,(function(e){e&&(e=e.original||e,t.horizontal.push(e.y),t.vertical.push(e.x))})),t}(o),s=o.hover,c=s&&n(s),p=e.x,l=e.y;if(a){var u=p-(i=t(c?a.vertical.concat([c.x]):a.vertical,p)),h=l-(r=t(c?a.horizontal.concat([c.y]):a.horizontal,l));F(e,{dx:e.dx-u,dy:e.dy-h,x:e.x-u,y:e.y-h}),(u||-1!==a.vertical.indexOf(p))&&ec(e,"x",i),(h||-1!==a.horizontal.indexOf(l))&&ec(e,"y",r)}}))}rc.$inject=["eventBus"];var oc={__depends__:[ss,hs],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",Rs],bendpointMove:["type",Ds],bendpointMovePreview:["type",Fs],connectionSegmentMove:["type",qs],bendpointSnapping:["type",rc]};function ac(e,t,n,i){function r(e,t){return i.allowed("connection.create",{source:e,target:t})}e.on("connect.hover",(function(e){var t,n=e.context,i=n.start,o=e.hover;if(n.hover=o,!l(t=n.canExecute=r(i,o))){if(!1!==t)return n.source=i,void(n.target=o);l(t=n.canExecute=r(o,i))||!1!==t&&(n.source=o,n.target=i)}})),e.on(["connect.out","connect.cleanup"],(function(e){var t=e.context;t.hover=null,t.source=null,t.target=null,t.canExecute=!1})),e.on("connect.end",(function(e){var t=e.context,i=t.canExecute,r=t.connectionStart,o={x:e.x,y:e.y},a=t.source,s=t.target;if(!i)return!1;var c=null,p={connectionStart:sc(t)?o:r,connectionEnd:sc(t)?r:o};h(i)&&(c=i),n.connect(a,s,c,p)})),this.start=function(e,n,i,r){h(i)||(r=i,i=cn(n)),t.init(e,"connect",{autoActivate:r,data:{shape:n,context:{start:n,connectionStart:i}}})}}function sc(e){var t=e.hover,n=e.source,i=e.target;return t&&n&&t===n&&n!==i}ac.$inject=["eventBus","dragging","modeling","rules"];var cc="connect-ok",pc="connect-not-ok";function lc(e,t,n){var i=e.get("connectionPreview",!1);i&&t.on("connect.move",(function(e){var t=e.context,n=t.canExecute,r=t.hover,o=t.source,a=t.start,s=t.startPosition,c=t.target,p=t.connectionStart||s,l=t.connectionEnd||{x:e.x,y:e.y},u=p,h=l;sc(t)&&(u=l,h=p),i.drawPreview(t,n,{source:o||a,target:c||r,connectionStart:u,connectionEnd:h})})),t.on("connect.hover",900,(function(e){var t=e.context,i=e.hover,r=t.canExecute;null!==r&&n.addMarker(i,r?cc:pc)})),t.on(["connect.out","connect.cleanup"],1100,(function(e){var t=e.hover;t&&(n.removeMarker(t,cc),n.removeMarker(t,pc))})),i&&t.on("connect.cleanup",(function(e){i.cleanUp(e.context)}))}lc.$inject=["injector","eventBus","canvas"];var uc={__depends__:[No,hs,ss],__init__:["connectPreview"],connect:["type",ac],connectPreview:["type",lc]};function hc(e,t,n,i){this._canvas=t,this._graphicsFactory=n,this._elementFactory=i,this._connectionDocking=e.get("connectionDocking",!1),this._layouter=e.get("layouter",!1)}hc.$inject=["injector","canvas","graphicsFactory","elementFactory"],hc.prototype.drawPreview=function(e,t,n){n=n||{};var i,r,o,a=e.connectionPreviewGfx,s=e.getConnection,c=n.source,p=n.target,l=n.waypoints,u=n.connectionStart,h=n.connectionEnd,d=n.noLayout,f=n.noCropping,m=n.noNoop,v=this;a||(a=e.connectionPreviewGfx=this.createConnectionPreviewGfx()),Te(a),s||(s=e.getConnection=(r=function(e,t,n){return v.getConnection(e,t,n)},o={},function(e){var t=JSON.stringify(e),n=o[t];return n||(n=o[t]=r.apply(null,arguments)),n})),t&&(i=s(t,c,p)),i?(i.waypoints=l||[],this._layouter&&!d&&(i.waypoints=this._layouter.layoutConnection(i,{source:c,target:p,connectionStart:u,connectionEnd:h,waypoints:n.waypoints||i.waypoints})),i.waypoints&&i.waypoints.length||(i.waypoints=[c?cn(c):u,p?cn(p):h]),this._connectionDocking&&(c||p)&&!f&&(i.waypoints=this._connectionDocking.getCroppedWaypoints(i,c,p)),this._graphicsFactory.drawConnection(a,i)):!m&&this.drawNoopPreview(a,n)},hc.prototype.drawNoopPreview=function(e,t){var n=t.source,i=t.target,r=t.connectionStart||cn(n),o=t.connectionEnd||cn(i),a=this.cropWaypoints(r,o,n,i);me(e,this.createNoopConnection(a[0],a[1]))},hc.prototype.cropWaypoints=function(e,t,n,i){var r=this._graphicsFactory,o=n&&r.getShapePath(n),a=i&&r.getShapePath(i),s=r.getConnectionPath({waypoints:[e,t]});return[e=n&&ln(o,s,!0)||e,t=i&&ln(a,s,!1)||t]},hc.prototype.cleanUp=function(e){e&&e.connectionPreviewGfx&&Ce(e.connectionPreviewGfx)},hc.prototype.getConnection=function(e){var t=function(e){return h(e)?e:{}}(e);return this._elementFactory.createConnection(t)},hc.prototype.createConnectionPreviewGfx=function(){var e=Me("g");return ge(e,{pointerEvents:"none"}),we(e).add("djs-connection-preview"),me(this._canvas.getActiveLayer(),e),e},hc.prototype.createNoopConnection=function(e,t){var n=Me("polyline");return ge(n,{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"}),ge(n,{points:[e.x,e.y,t.x,t.y]}),n};var dc={__init__:["connectionPreview"],connectionPreview:["type",hc]},fc=Math.min,mc=Math.max;function vc(e){e.preventDefault()}function yc(e){e.stopPropagation()}function gc(e){this.container=e.container,this.parent=ce('<div class="djs-direct-editing-parent"><div class="djs-direct-editing-content" contenteditable="true"></div></div>'),this.content=ue("[contenteditable]",this.parent),this.keyHandler=e.keyHandler||function(){},this.resizeHandler=e.resizeHandler||function(){},this.autoResize=I(this.autoResize,this),this.handlePaste=I(this.handlePaste,this)}function bc(e,t){this._eventBus=e,this._providers=[],this._textbox=new gc({container:t.getContainer(),keyHandler:I(this._handleKey,this),resizeHandler:I(this._handleResize,this)})}gc.prototype.create=function(e,t,n,i){var r=this.parent,o=this.content,a=this.container;i=this.options=i||{};var s=$(t=this.style=t||{},["width","height","maxWidth","maxHeight","minWidth","minHeight","left","top","backgroundColor","position","overflow","border","wordWrap","textAlign","outline","transform"]);F(r.style,{width:e.width+"px",height:e.height+"px",maxWidth:e.maxWidth+"px",maxHeight:e.maxHeight+"px",minWidth:e.minWidth+"px",minHeight:e.minHeight+"px",left:e.x+"px",top:e.y+"px",backgroundColor:"#ffffff",position:"absolute",overflow:"visible",border:"1px solid #ccc",boxSizing:"border-box",wordWrap:"normal",textAlign:"center",outline:"none"},s);var c=$(t,["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"]);return F(o.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},c),i.centerVertically&&F(o.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},c),o.innerText=n,re.bind(o,"keydown",this.keyHandler),re.bind(o,"mousedown",yc),re.bind(o,"paste",this.handlePaste),i.autoResize&&re.bind(o,"input",this.autoResize),i.resizable&&this.resizable(t),a.appendChild(r),this.setSelection(o.lastChild,o.lastChild&&o.lastChild.length),r},gc.prototype.handlePaste=function(e){var t,n=this.options,i=this.style;if(e.preventDefault(),t=e.clipboardData?e.clipboardData.getData("text/plain"):window.clipboardData.getData("Text"),this.insertText(t),n.autoResize){var r=this.autoResize(i);r&&this.resizeHandler(r)}},gc.prototype.insertText=function(e){e=e.replace(/\r\n|\r|\n/g,"\n"),document.execCommand("insertText",!1,e)||this._insertTextIE(e)},gc.prototype._insertTextIE=function(e){var t,n,i,r=this.getSelection(),o=r.startContainer,a=r.endContainer,s=r.startOffset,c=r.endOffset,p=r.commonAncestorContainer,l=(t=p.childNodes,[].slice.call(t));if(function(e){return e.nodeType===Node.TEXT_NODE}(p)){var u=o.textContent;o.textContent=u.substring(0,s)+e+u.substring(c),n=o,i=s+e.length}else if(o===this.content&&a===this.content){var h=document.createTextNode(e);this.content.insertBefore(h,l[s]),n=h,i=h.textContent.length}else{var d=l.indexOf(o),f=l.indexOf(a);l.forEach((function(t,n){n===d?t.textContent=o.textContent.substring(0,s)+e+a.textContent.substring(c):n>d&&n<=f&&de(t)})),n=o,i=s+e.length}n&&void 0!==i&&setTimeout((function(){self.setSelection(n,i)}))},gc.prototype.autoResize=function(){var e=this.parent,t=this.content,n=parseInt(this.style.fontSize)||12;if(t.scrollHeight>e.offsetHeight||t.scrollHeight<e.offsetHeight-n){var i=e.getBoundingClientRect(),r=t.scrollHeight;e.style.height=r+"px",this.resizeHandler({width:i.width,height:i.height,dx:0,dy:r-i.height})}},gc.prototype.resizable=function(){var e=this,t=this.parent,n=this.resizeHandle,i=parseInt(this.style.minWidth)||0,r=parseInt(this.style.minHeight)||0,o=parseInt(this.style.maxWidth)||1/0,a=parseInt(this.style.maxHeight)||1/0;if(!n){var s,c,p,l;n=this.resizeHandle=ce('<div class="djs-direct-editing-resize-handle"></div>');var u=function(n){vc(n),yc(n);var u=fc(mc(p+n.clientX-s,i),o),h=fc(mc(l+n.clientY-c,r),a);t.style.width=u+"px",t.style.height=h+"px",e.resizeHandler({width:p,height:l,dx:n.clientX-s,dy:n.clientY-c})},h=function(e){vc(e),yc(e),re.unbind(document,"mousemove",u,!1),re.unbind(document,"mouseup",h,!1)};re.bind(n,"mousedown",(function(e){vc(e),yc(e),s=e.clientX,c=e.clientY;var n=t.getBoundingClientRect();p=n.width,l=n.height,re.bind(document,"mousemove",u),re.bind(document,"mouseup",h)}))}F(n.style,{position:"absolute",bottom:"0px",right:"0px",cursor:"nwse-resize",width:"0",height:"0",borderTop:(parseInt(this.style.fontSize)/4||3)+"px solid transparent",borderRight:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderBottom:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderLeft:(parseInt(this.style.fontSize)/4||3)+"px solid transparent"}),t.appendChild(n)},gc.prototype.destroy=function(){var e=this.parent,t=this.content,n=this.resizeHandle;t.innerText="",e.removeAttribute("style"),t.removeAttribute("style"),re.unbind(t,"keydown",this.keyHandler),re.unbind(t,"mousedown",yc),re.unbind(t,"input",this.autoResize),re.unbind(t,"paste",this.handlePaste),n&&(n.removeAttribute("style"),de(n)),de(e)},gc.prototype.getValue=function(){return this.content.innerText.trim()},gc.prototype.getSelection=function(){return window.getSelection().getRangeAt(0)},gc.prototype.setSelection=function(e,t){var n=document.createRange();null===e?n.selectNodeContents(this.content):(n.setStart(e,t),n.setEnd(e,t));var i=window.getSelection();i.removeAllRanges(),i.addRange(n)},bc.$inject=["eventBus","canvas"],bc.prototype.registerProvider=function(e){this._providers.push(e)},bc.prototype.isActive=function(){return!!this._active},bc.prototype.cancel=function(){this._active&&(this._fire("cancel"),this.close())},bc.prototype._fire=function(e,t){this._eventBus.fire("directEditing."+e,t||{active:this._active})},bc.prototype.close=function(){this._textbox.destroy(),this._fire("deactivate"),this._active=null,this.resizable=void 0},bc.prototype.complete=function(){var e=this._active;if(e){var t,n=e.context.bounds,i=this.$textbox.getBoundingClientRect(),r=this.getValue();r===e.context.text&&i.height===n.height&&i.width===n.width||(t=this._textbox.container.getBoundingClientRect(),e.provider.update(e.element,r,e.context.text,{x:i.left-t.left,y:i.top-t.top,width:i.width,height:i.height})),this._fire("complete"),this.close()}},bc.prototype.getValue=function(){return this._textbox.getValue()},bc.prototype._handleKey=function(e){e.stopPropagation();var t=e.keyCode||e.charCode;return 27===t?(e.preventDefault(),this.cancel()):13!==t||e.shiftKey?void 0:(e.preventDefault(),this.complete())},bc.prototype._handleResize=function(e){this._fire("resize",e)},bc.prototype.activate=function(e){var t;this.isActive()&&this.cancel();var n=y(this._providers,(function(n){return(t=n.activate(e))?n:null}));return t&&(this.$textbox=this._textbox.create(t.bounds,t.style,t.text,t.options),this._active={element:e,context:t,provider:n},t.options&&t.options.resizable&&(this.resizable=!0),this._fire("activate")),!!t};var xc={__depends__:[Co],__init__:["directEditing"],directEditing:["type",bc]},_c=".entry";function Ec(e,t,n){this._eventBus=t,this._overlays=n;var i=p(e&&e.scale)?e.scale:{min:1,max:1.5};this._overlaysConfig={position:{right:-9,top:-6},scale:i},this._current=null,this._init()}Ec.$inject=["config.contextPad","eventBus","overlays"],Ec.prototype._init=function(){var e=this._eventBus,t=this;e.on("selection.changed",(function(e){var n=e.newSelection;1===n.length?t.open(n[0]):t.close()})),e.on("elements.delete",(function(e){b(e.elements,(function(e){t.isOpen(e)&&t.close()}))})),e.on("element.changed",(function(e){var n=e.element,i=t._current;i&&i.element===n&&t.open(n,!0)}))},Ec.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("contextPad.getProviders",e,(function(e){e.providers.push(t)}))},Ec.prototype.getEntries=function(e){var t=this._getProviders(),n={};return b(t,(function(t){var i=t.getContextPadEntries(e);f(i)?n=i(n):b(i,(function(e,t){n[t]=e}))})),n},Ec.prototype.trigger=function(e,t,n){var i,r,o=this._current.element,a=this._current.entries,s=t.delegateTarget||t.target;if(!s)return t.preventDefault();if(i=a[G(s,"data-action")].action,r=t.originalEvent||t,f(i)){if("click"===e)return i(r,o,n)}else if(i[e])return i[e](r,o,n);t.preventDefault()},Ec.prototype.open=function(e,t){!t&&this.isOpen(e)||(this.close(),this._updateAndOpen(e))},Ec.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"contextPad.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},Ec.prototype._updateAndOpen=function(e){var t=this.getEntries(e),n=this.getPad(e),i=n.html;b(t,(function(e,t){var n,r=e.group||"default",o=ce(e.html||'<div class="entry" draggable="true"></div>');G(o,"data-action",t),(n=ue("[data-group="+r+"]",i))||(n=ce('<div class="group" data-group="'+r+'"></div>'),i.appendChild(n)),n.appendChild(o),e.className&&function(e,t){var n=K(e);(u(t)?t:t.split(/\s+/g)).forEach((function(e){n.add(e)}))}(o,e.className),e.title&&G(o,"title",e.title),e.imageUrl&&o.appendChild(ce('<img src="'+e.imageUrl+'">'))})),K(i).add("open"),this._current={element:e,pad:n,entries:t},this._eventBus.fire("contextPad.open",{current:this._current})},Ec.prototype.getPad=function(e){if(this.isOpen())return this._current.pad;var t=this,n=this._overlays,i=ce('<div class="djs-context-pad"></div>'),r=F({html:i},this._overlaysConfig);se.bind(i,_c,"click",(function(e){t.trigger("click",e)})),se.bind(i,_c,"dragstart",(function(e){t.trigger("dragstart",e)})),re.bind(i,"mousedown",(function(e){e.stopPropagation()})),this._overlayId=n.add(e,"context-pad",r);var o=n.get(this._overlayId);return this._eventBus.fire("contextPad.create",{element:e,pad:o}),o},Ec.prototype.close=function(){this.isOpen()&&(this._overlays.remove(this._overlayId),this._overlayId=null,this._eventBus.fire("contextPad.close",{current:this._current}),this._current=null)},Ec.prototype.isOpen=function(e){return!(!this._current||e&&this._current.element!==e)};var wc={__depends__:[Co,$o],contextPad:["type",Ec]},Sc=["marker-start","marker-mid","marker-end"],Cc=["circle","ellipse","line","path","polygon","polyline","rect"];function Tc(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._styles=i,this._clonedMarkers={};var r=this;t.on("drag.cleanup",(function(){b(r._clonedMarkers,(function(e){Ce(e)})),r._clonedMarkers={}}))}Tc.$inject=["elementRegistry","eventBus","canvas","styles"],Tc.prototype.getGfx=function(e){return this._elementRegistry.getGraphics(e)},Tc.prototype.addDragger=function(e,t,n){var i=Re(n=n||this.getGfx(e)),r=n.getBoundingClientRect();return this._cloneMarkers(Gn(i)),ge(i,this._styles.cls("djs-dragger",[],{x:r.top,y:r.left})),me(t,i),i},Tc.prototype.addFrame=function(e,t){var n=Me("rect",{class:"djs-resize-overlay",width:e.width,height:e.height,x:e.x,y:e.y});return me(t,n),n},Tc.prototype._cloneMarkers=function(e){var t=this;if(e.childNodes)for(var n=0;n<e.childNodes.length;n++)t._cloneMarkers(e.childNodes[n]);(function(e){return-1!==Cc.indexOf(e.nodeName)})(e)&&Sc.forEach((function(n){if(ge(e,n)){var i=function(e,t,n){return ue("marker#"+(i=ge(e,t),i.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]),n||document);var i}(e,n,t._canvas.getContainer());t._cloneMarker(e,i,n)}}))},Tc.prototype._cloneMarker=function(e,t,n){var i=t.id,r=this._clonedMarkers[i];if(!r){var o=i+"-clone";(r=Re(t)).id=o,we(r).add("djs-dragger").add("djs-dragger-marker"),this._clonedMarkers[i]=r;var a=ue("defs",this._canvas._svg);a||(a=Me("defs"),me(this._canvas._svg,a)),me(a,r)}ge(e,n,"url(#"+this._clonedMarkers[i].id+")")};var Rc={__init__:["previewSupport"],previewSupport:["type",Tc]},Pc="drop-ok",Ac="drop-not-ok",kc="attach-ok",Mc="new-parent",Dc="create";function Bc(e,t,n,i,r){function o(t,n){[kc,Pc,Ac,Mc].forEach((function(i){i===n?e.addMarker(t,i):e.removeMarker(t,i)}))}function a(){var e=t.context();e&&e.prefix===Dc&&t.cancel()}n.on(["create.move","create.hover"],(function(e){var t=e.context,n=t.elements,i=e.hover,a=t.source,s=t.hints||{};if(!i)return t.canExecute=!1,void(t.target=null);Nc(e);var c={x:e.x,y:e.y},p=t.canExecute=i&&function(e,t,n,i,o){if(!t)return!1;var a=y(e=g(e,(function(t){var n=t.labelTarget;return!(t.parent||function(e){return!!e.labelTarget}(t)&&-1!==e.indexOf(n))})),(function(e){return!Oc(e)})),s=!1,c=!1,p=!1;jc(e)&&(s=r.allowed("shape.attach",{position:n,shape:a,target:t})),s||(p=jc(e)?r.allowed("shape.create",{position:n,shape:a,source:i,target:t}):r.allowed("elements.create",{elements:e,position:n,target:t}));var l=o.connectionTarget;return p||s?(a&&i&&(c=r.allowed("connection.create",{source:l===i?a:i,target:l===i?i:a,hints:{targetParent:t,targetAttach:s}})),{attach:s,connect:c}):(null===p||null===s)&&null}(n,i,c,a,s);i&&null!==p&&(t.target=i,p&&p.attach?o(i,kc):o(i,p?Mc:Ac))})),n.on(["create.end","create.out","create.cleanup"],(function(e){var t=e.hover;t&&o(t,null)})),n.on("create.end",(function(e){var t=e.context,n=t.source,r=t.shape,o=t.elements,a=t.target,s=t.canExecute,c=s&&s.attach,p=s&&s.connect,l=t.hints||{};if(!1===s||!a)return!1;Nc(e);var u={x:e.x,y:e.y};r=p?i.appendShape(n,r,u,a,{attach:c,connection:!0===p?{}:p,connectionTarget:l.connectionTarget}):y(o=i.createElements(o,u,a,F({},l,{attach:c})),(function(e){return!Oc(e)})),F(t,{elements:o,shape:r}),F(e,{elements:o,shape:r})})),n.on("create.init",(function(){n.on("elements.changed",a),n.once(["create.cancel","create.end"],2e3,(function(){n.off("elements.changed",a)}))})),this.start=function(e,n,i){u(n)||(n=[n]);var r=y(n,(function(e){return!Oc(e)}));if(r){i=F({elements:n,hints:{},shape:r},i||{}),b(n,(function(e){d(e.x)||(e.x=0),d(e.y)||(e.y=0)}));var o=pt(n);b(n,(function(e){Oc(e)&&(e.waypoints=S(e.waypoints,(function(e){return{x:e.x-o.x-o.width/2,y:e.y-o.y-o.height/2}}))),F(e,{x:e.x-o.x-o.width/2,y:e.y-o.y-o.height/2})})),t.init(e,Dc,{cursor:"grabbing",autoActivate:!0,data:{shape:r,elements:n,context:i}})}}}function Nc(e){var t=e.context.createConstraints;t&&(t.left&&(e.x=Math.max(e.x,t.left)),t.right&&(e.x=Math.min(e.x,t.right)),t.top&&(e.y=Math.max(e.y,t.top)),t.bottom&&(e.y=Math.min(e.y,t.bottom)))}function Oc(e){return!!e.waypoints}function jc(e){return e&&1===e.length&&!Oc(e[0])}Bc.$inject=["canvas","dragging","eventBus","modeling","rules"];function Lc(e,t,n,i,r){t.on("create.move",750,(function(t){var o=t.hover,a=t.context,s=a.elements,c=a.dragGroup;c||(c=a.dragGroup=function(e){var t=Me("g");ge(t,r.cls("djs-drag-group",["no-events"]));var o=Me("g");return e.forEach((function(e){var r;e.hidden||(e.waypoints?(r=n._createContainer("connection",o),n.drawConnection(Gn(r),e)):(r=n._createContainer("shape",o),n.drawShape(Gn(r),e),Vn(r,e.x,e.y)),i.addDragger(e,t,r))})),t}(s)),o?(c.parentNode||me(e.getActiveLayer(),c),Vn(c,t.x,t.y)):Ce(c)})),t.on("create.cleanup",(function(e){var t=e.context.dragGroup;t&&Ce(t)}))}Lc.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];var Ic={__depends__:[ss,Rc,hs,No],__init__:["create","createPreview"],create:["type",Bc],createPreview:["type",Lc]},zc="data-id",Fc=["contextPad.close","canvas.viewbox.changing","commandStack.changed"];function $c(e,t,n){var i=p(e&&e.scale)?e.scale:{min:1,max:1.5};this._config={scale:i},this._eventBus=t,this._canvas=n,this._providers={},this._current={}}$c.$inject=["config.popupMenu","eventBus","canvas"],$c.prototype.registerProvider=function(e,t,n){n||(n=t,t=1e3),this._eventBus.on("popupMenu.getProviders."+e,t,(function(e){e.providers.push(n)}))},$c.prototype.isEmpty=function(e,t){if(!e)throw new Error("element parameter is missing");if(!t)throw new Error("providerId parameter is missing");var n=this._getProviders(t);if(!n)return!0;var i=this._getEntries(e,n),r=this._getHeaderEntries(e,n),o=T(i)>0,a=r&&T(r)>0;return!o&&!a},$c.prototype.open=function(e,t,n){var i=this._getProviders(t);if(!e)throw new Error("Element is missing");if(!i||!i.length)throw new Error("No registered providers for: "+t);if(!n)throw new Error("the position argument is missing");this.isOpen()&&this.close(),this._emit("open");var r=this._current={className:t,element:e,position:n},o=this._getEntries(e,i),a=this._getHeaderEntries(e,i);r.entries=F({},o,a),r.container=this._createContainer(),T(a)&&r.container.appendChild(this._createEntries(a,"djs-popup-header")),T(o)&&r.container.appendChild(this._createEntries(o,"djs-popup-body"));var s=this._canvas.getContainer();this._attachContainer(r.container,s,n.cursor),this._bindAutoClose()},$c.prototype.close=function(){this.isOpen()&&(this._emit("close"),this._unbindAutoClose(),de(this._current.container),this._current.container=null)},$c.prototype.isOpen=function(){return!!this._current.container},$c.prototype.trigger=function(e){e.preventDefault();var t=G(e.delegateTarget||e.target,zc),n=this._getEntry(t);if(n.action)return n.action.call(null,e,n)},$c.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"popupMenu.getProviders."+e,providers:[]});return this._eventBus.fire(t),t.providers},$c.prototype._getEntries=function(e,t){var n={};return b(t,(function(t){if(t.getPopupMenuEntries){var i=t.getPopupMenuEntries(e);f(i)?n=i(n):b(i,(function(e,t){n[t]=e}))}else b(t.getEntries(e),(function(e){var t=e.id;if(!t)throw new Error("every entry must have the id property set");n[t]=H(e,["id"])}))})),n},$c.prototype._getHeaderEntries=function(e,t){var n={};return b(t,(function(t){if(t.getPopupMenuHeaderEntries){var i=t.getPopupMenuHeaderEntries(e);f(i)?n=i(n):b(i,(function(e,t){n[t]=e}))}else{if(!t.getHeaderEntries)return;b(t.getHeaderEntries(e),(function(e){var t=e.id;if(!t)throw new Error("every entry must have the id property set");n[t]=H(e,["id"])}))}})),n},$c.prototype._getEntry=function(e){var t=this._current.entries[e];if(!t)throw new Error("entry not found");return t},$c.prototype._emit=function(e){this._eventBus.fire("popupMenu."+e)},$c.prototype._createContainer=function(){var e=ce('<div class="djs-popup">'),t=this._current.position,n=this._current.className;return F(e.style,{position:"absolute",left:t.x+"px",top:t.y+"px",visibility:"hidden"}),K(e).add(n),e},$c.prototype._attachContainer=function(e,t,n){var i=this;se.bind(e,".entry","click",(function(e){i.trigger(e)})),this._updateScale(e),t.appendChild(e),n&&this._assureIsInbounds(e,n)},$c.prototype._updateScale=function(e){var t,n,i=this._canvas.zoom(),r=this._config.scale,o=i;!0!==r&&(!1===r?(t=1,n=1):(t=r.min,n=r.max),p(t)&&i<t&&(o=t),p(n)&&i>n&&(o=n)),function(e,t){e.style["transform-origin"]="top left",["","-ms-","-webkit-"].forEach((function(n){e.style[n+"transform"]=t}))}(e,"scale("+o+")")},$c.prototype._assureIsInbounds=function(e,t){var n,i,r=this._canvas._container.getBoundingClientRect(),o=e.offsetLeft,a=e.offsetTop,s=e.scrollWidth,c=e.scrollHeight,p={},l=t.x-r.left,u=t.y-r.top;o+s>r.width&&(p.x=!0),a+c>r.height&&(p.y=!0),p.x&&p.y?(n=l-s+"px",i=u-c+"px"):p.x?(n=l-s+"px",i=u+"px"):p.y&&u<c?(n=l+"px",i="10px"):p.y&&(n=l+"px",i=u-c+"px"),F(e.style,{left:n,top:i},{visibility:"visible","z-index":1e3})},$c.prototype._createEntries=function(e,t){var n=ce("<div>"),i=this;return K(n).add(t),b(e,(function(e,t){var r=i._createEntry(e,t);n.appendChild(r)})),n},$c.prototype._createEntry=function(e,t){var n=ce("<div>"),i=K(n);if(i.add("entry"),e.className&&e.className.split(" ").forEach((function(e){i.add(e)})),G(n,zc,t),e.label){var r=ce("<span>");r.textContent=e.label,n.appendChild(r)}return e.imageUrl&&n.appendChild(ce('<img src="'+e.imageUrl+'" />')),!0===e.active&&i.add("active"),!0===e.disabled&&i.add("disabled"),e.title&&(n.title=e.title),n},$c.prototype._bindAutoClose=function(){this._eventBus.once(Fc,this.close,this)},$c.prototype._unbindAutoClose=function(){this._eventBus.off(Fc,this.close,this)};var Hc={__init__:["popupMenu"],popupMenu:["type",$c]};function Gc(){}Gc.prototype.get=function(){return this._data},Gc.prototype.set=function(e){this._data=e},Gc.prototype.clear=function(){var e=this._data;return delete this._data,e},Gc.prototype.isEmpty=function(){return!this._data};var Wc={clipboard:["type",Gc]};function Vc(e){var t=this;function n(e){t._lastMoveEvent=e}this._lastMoveEvent=null,e.on("canvas.init",(function(e){(t._svg=e.svg).addEventListener("mousemove",n)})),e.on("canvas.destroy",(function(){t._lastMouseEvent=null,t._svg.removeEventListener("mousemove",n)}))}Vc.$inject=["eventBus"],Vc.prototype.getLastMoveEvent=function(){return this._lastMoveEvent||function(e,t){var n=document.createEvent("MouseEvent"),i=e,r=t,o=e,a=t;n.initMouseEvent&&n.initMouseEvent("mousemove",!0,!0,window,0,i,r,o,a,!1,!1,!1,!1,0,null);return n}(0,0)};var Uc={__init__:["mouse"],mouse:["type",Vc]};function qc(e,t,n,i,r,o,a,s){this._canvas=e,this._create=t,this._clipboard=n,this._elementFactory=i,this._eventBus=r,this._modeling=o,this._mouse=a,this._rules=s,r.on("copyPaste.copyElement",(function(e){var t=e.descriptor,n=e.element,i=e.elements;t.priority=1,t.id=n.id,y(i,(function(e){return e===n.parent}))&&(t.parent=n.parent.id),function(e){return!!e.host}(n)&&(t.priority=2,t.host=n.host.id),Kc(n)&&(t.priority=3,t.source=n.source.id,t.target=n.target.id,t.waypoints=function(e){return S(e.waypoints,(function(e){return(e=Xc(e)).original&&(e.original=Xc(e.original)),e}))}(n)),Yc(n)&&(t.priority=4,t.labelTarget=n.labelTarget.id),b(["x","y","width","height"],(function(e){d(n[e])&&(t[e]=n[e])})),t.hidden=n.hidden,t.collapsed=n.collapsed})),r.on("copyPaste.pasteElements",(function(e){F(e.hints,{createElementsBehavior:!1})}))}function Kc(e){return!!e.waypoints}function Yc(e){return!!e.labelTarget}function Xc(e){return F({},e)}function Zc(e,t){var n=t.indexOf(e);return-1===n?t:t.splice(n,1)}qc.$inject=["canvas","create","clipboard","elementFactory","eventBus","modeling","mouse","rules"],qc.prototype.copy=function(e){var t,n;return u(e)||(e=e?[e]:[]),n=!1===(t=this._eventBus.fire("copyPaste.canCopyElements",{elements:e}))?{}:this.createTree(u(t)?t:e),this._clipboard.set(n),this._eventBus.fire("copyPaste.elementsCopied",{elements:e,tree:n}),n},qc.prototype.paste=function(e){var t=this._clipboard.get();if(!this._clipboard.isEmpty()){var n=e&&e.hints||{};this._eventBus.fire("copyPaste.pasteElements",{hints:n});var i=this._createElements(t);if(e&&e.element&&e.point)return this._paste(i,e.element,e.point,n);this._create.start(this._mouse.getLastMoveEvent(),i,{hints:n||{}})}},qc.prototype._paste=function(e,t,n,i){b(e,(function(e){d(e.x)||(e.x=0),d(e.y)||(e.y=0)}));var r=pt(e);return b(e,(function(e){Kc(e)&&(e.waypoints=S(e.waypoints,(function(e){return{x:e.x-r.x-r.width/2,y:e.y-r.y-r.height/2}}))),F(e,{x:e.x-r.x-r.width/2,y:e.y-r.y-r.height/2})})),this._modeling.createElements(e,n,t,F({},i))},qc.prototype._createElements=function(e){var t=this,n=this._eventBus,i={},r=[];return b(e,(function(e,o){b(e=M(e,"priority"),(function(e){var o,a=F({},H(e,["priority"]));return i[e.parent]?a.parent=i[e.parent]:delete a.parent,n.fire("copyPaste.pasteElement",{cache:i,descriptor:a}),Kc(a)?(a.source=i[e.source],a.target=i[e.target],o=i[e.id]=t.createConnection(a),void r.push(o)):Yc(a)?(a.labelTarget=i[a.labelTarget],o=i[e.id]=t.createLabel(a),void r.push(o)):(a.host&&(a.host=i[a.host]),o=i[e.id]=t.createShape(a),void r.push(o))}))})),r},qc.prototype.createConnection=function(e){return this._elementFactory.createConnection(H(e,["id"]))},qc.prototype.createLabel=function(e){return this._elementFactory.createLabel(H(e,["id"]))},qc.prototype.createShape=function(e){return this._elementFactory.createShape(H(e,["id"]))},qc.prototype.hasRelations=function(e,t){var n,i;return!(Kc(e)&&(n=y(t,D({id:e.source.id})),i=y(t,D({id:e.target.id})),!n||!i))&&!(Yc(e)&&!y(t,D({id:e.labelTarget.id})))},qc.prototype.createTree=function(e){var t=this._rules,n=this,i={},r=[];function o(e,t){var n=y(r,(function(t){return e===t.element}));n?n.depth<t&&(r=function(e,t){var n=t.indexOf(e);-1!==n&&t.splice(n,1);return t}(n,r)).push({element:n.element,depth:t}):r.push({element:e,depth:t})}return st(rt(e),(function(e,t,n){if(!Yc(e))return b(e.labels,(function(e){o(e,n)})),b([e.attachers,e.incoming,e.outgoing],(function(e){e&&e.length&&b(e,(function(e){b(e.labels,(function(e){o(e,n)})),o(e,n)}))})),o(e,n),e.children})),e=S(r,(function(e){return e.element})),r=M(r=S(r,(function(t){return t.descriptor={},n._eventBus.fire("copyPaste.copyElement",{descriptor:t.descriptor,element:t.element,elements:e}),t})),(function(e){return e.descriptor.priority})),e=S(r,(function(e){return e.element})),b(r,(function(r){var o=r.depth;n.hasRelations(r.element,e)?!function(e,n){return t.allowed("element.copy",{element:e,elements:n})}(r.element,e)?Zc(r.element,e):(i[o]||(i[o]=[]),i[o].push(r.descriptor)):Zc(r.element,e)})),i};var Qc={__depends__:[Wc,Ic,Uc,hs],__init__:["copyPaste"],copyPaste:["type",qc]};function Jc(e,t,n){u(n)||(n=[n]),b(n,(function(n){c(e[n])||(t[n]=e[n])}))}function ep(e,t,n){var i;t.on("copyPaste.copyElement",750,(function(e){var t=e.descriptor,n=e.element,i=t.oldBusinessObject=kr(n);if(t.type=n.type,Jc(i,t,"name"),t.di={},Jc(i.di,t.di,["fill","stroke","background-color","border-color","color"]),Jc(i.di,t,"isExpanded"),tp(t))return t;i.default&&(t.default=i.default.id)})),t.on("moddleCopy.canCopyProperty",(function(t){var i,r=t.parent,o=t.property;if("processRef"===t.propertyName&&Ar(r,"bpmn:Participant")&&Ar(o,"bpmn:Process"))return i=e.create("bpmn:Process"),n.copyElement(o,i)})),t.on("copyPaste.pasteElements",(function(){i={}})),t.on("copyPaste.pasteElement",(function(t){var r,o,a,s=t.cache,c=t.descriptor,p=c.oldBusinessObject;tp(c)?c.businessObject=kr(s[c.labelTarget]):(r=e.create(p.$type),c.businessObject=n.copyElement(p,r),function(e,t){var n=kr(e);e.default&&(i[e.default]={element:n,property:"default"}),e.host&&(kr(e).attachedToRef=kr(t[e.host])),i=H(i,_(i,(function(t,i,r){var o=i.element,a=i.property;return r===e.id&&(o[a]=n,t.push(e.id)),t}),[]))}(c,s),Jc(c,r,["isExpanded","name"]),o=c,u(a="oldBusinessObject")||(a=[a]),b(a,(function(e){o[e]&&delete o[e]})))}))}function tp(e){return!!e.labelTarget}ep.$inject=["bpmnFactory","eventBus","moddleCopy"];var np=["artifacts","dataInputAssociations","dataOutputAssociations","default","flowElements","lanes","incoming","outgoing"];function ip(e,t,n){this._bpmnFactory=t,this._eventBus=e,this._moddle=n,e.on("moddleCopy.canCopyProperties",(function(e){var t=e.propertyNames;if(t&&t.length)return M(t,(function(e){return"extensionElements"===e}))})),e.on("moddleCopy.canCopyProperty",(function(e){var t=e.parent,n=h(t)&&t.$descriptor,i=e.propertyName;return(!i||-1===np.indexOf(i))&&(!(i&&n&&!y(n.properties,D({name:i})))&&void 0)})),e.on("moddleCopy.canSetCopiedProperty",(function(e){var t,n,i=e.property;if(n="bpmn:ExtensionElements",(t=i)&&"function"==typeof t.$instanceOf&&t.$instanceOf(n)&&(!i.values||!i.values.length))return!1}))}function rp(e,t){return _(e.properties,(function(e,n){return t&&n.default?e:e.concat(n.name)}),[])}ip.$inject=["eventBus","bpmnFactory","moddle"],ip.prototype.copyElement=function(e,t,n){var i=this;n&&!u(n)&&(n=[n]),n=n||rp(e.$descriptor);var r=this._eventBus.fire("moddleCopy.canCopyProperties",{propertyNames:n,sourceElement:e,targetElement:t});return!1===r||(u(r)&&(n=r),b(n,(function(n){var r;v(e,n)&&(r=e.get(n));var o=i.copyProperty(r,t,n);!1!==i._eventBus.fire("moddleCopy.canSetCopiedProperty",{parent:t,property:o,propertyName:n})&&p(o)&&t.set(n,o)}))),t},ip.prototype.copyProperty=function(e,t,n){var i=this,r=this._eventBus.fire("moddleCopy.canCopyProperty",{parent:t,property:e,propertyName:n});if(!1!==r){if(r)return h(r)&&r.$type&&!r.$parent&&(r.$parent=t),r;var o=this._moddle.getPropertyDescriptor(t,n);if(!o.isReference){if(o.isId)return this._copyId(e,t);if(u(e))return _(e,(function(e,o){return(r=i.copyProperty(o,t,n))?(r.$parent=t,e.concat(r)):e}),[]);if(h(e)&&e.$type){if(this._moddle.getElementDescriptor(e).isGeneric)return;return(r=i._bpmnFactory.create(e.$type)).$parent=t,r=i.copyElement(e,r)}return e}}},ip.prototype._copyId=function(e,t){return this._moddle.ids.assigned(e)?void 0:(this._moddle.ids.claim(e,t),e)};var op={__depends__:[Qc],__init__:["bpmnCopyPaste","moddleCopy"],bpmnCopyPaste:["type",ep],moddleCopy:["type",ip]},ap=Math.round;function sp(e){this._modeling=e}sp.$inject=["modeling"],sp.prototype.replaceElement=function(e,t,n){if(e.waypoints)return null;var i=this._modeling,r=t.width||e.width,o=t.height||e.height,a=t.x||e.x,s=t.y||e.y,c=ap(a+r/2),p=ap(s+o/2);return i.replaceShape(e,F({},t,{x:c,y:p,width:r,height:o}),n)};var cp={__init__:["replace"],replace:["type",sp]};var pp=["cancelActivity","instantiate","eventGatewayType","triggeredByEvent","isInterrupting"];function lp(e,t,n,i,r,o,a){this.replaceElement=function(s,p,l){l=l||{};var h=p.type,d=s.businessObject;if(up(d)&&"bpmn:SubProcess"===h&&function(e,t){var n=e&&v(e,"collapsed")?e.collapsed:!Mr(e);return n!==(t&&(v(t,"collapsed")||v(t,"isExpanded"))?v(t,"collapsed")?t.collapsed:!t.isExpanded:n)&&(e.collapsed=n,!0)}(s,p))return i.toggleCollapse(s),s;var f,m=e.create(h),y={type:h,businessObject:m},x=rp(d.$descriptor),_=rp(m.$descriptor,!0),E=(f=_,x.filter((function(e){return-1!==f.indexOf(e)})));F(m,$(p,pp));var w=g(E,(function(e){return"eventDefinitions"===e?hp(s,p.eventDefinitionType):"loopCharacteristics"===e?!Dr(m):!v(m,e)&&(("processRef"!==e||!1!==p.isExpanded)&&"triggeredByEvent"!==e)}));return m=n.copyElement(d,m,w),p.eventDefinitionType&&(hp(m,p.eventDefinitionType)||(y.eventDefinitionType=p.eventDefinitionType,y.eventDefinitionAttrs=p.eventDefinitionAttrs)),Ar(d,"bpmn:Activity")&&(up(d)?y.isExpanded=Mr(d):p&&v(p,"isExpanded")&&(y.isExpanded=p.isExpanded),Mr(d)&&!Ar(d,"bpmn:Task")&&y.isExpanded&&(y.width=s.width,y.height=s.height)),up(d)&&!up(m)&&(l.moveChildren=!1),Ar(d,"bpmn:Participant")&&(!0===p.isExpanded?m.processRef=e.create("bpmn:Process"):l.moveChildren=!1,y.width=s.width,y.height=t._getDefaultSize(m).height),o.allowed("shape.resize",{shape:m})||(y.height=t._getDefaultSize(m).height,y.width=t._getDefaultSize(m).width),m.name=d.name,Ha(d,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&Ha(m,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&(m.default=d.default),p.host&&!Ar(d,"bpmn:BoundaryEvent")&&Ar(m,"bpmn:BoundaryEvent")&&(y.host=p.host),"bpmn:DataStoreReference"!==y.type&&"bpmn:DataObjectReference"!==y.type||(y.x=s.x+(s.width-y.width)/2),y.di={},function(e,t,n){u(n)||(n=[n]),b(n,(function(n){c(e[n])||(t[n]=e[n])}))}(d.di,y.di,["fill","stroke","background-color","border-color","color"]),y=r.replaceElement(s,y,l),!1!==l.select&&a.select(y),y}}function up(e){return Ar(e,"bpmn:SubProcess")}function hp(e,t){var n=kr(e);return t&&n.get("eventDefinitions").some((function(e){return Ar(e,t)}))}lp.$inject=["bpmnFactory","elementFactory","moddleCopy","modeling","replace","rules","selection"];var dp={__depends__:[op,cp,No],bpmnReplace:["type",lp]};function fp(e){return function(t){var n=t.target,i=kr(e),r=i.eventDefinitions&&i.eventDefinitions[0],o=i.$type===n.type,a=(r&&r.$type)===n.eventDefinitionType,s=i.triggeredByEvent===n.triggeredByEvent,c=void 0===n.isExpanded||n.isExpanded===Mr(i);return!(o&&a&&s&&c)}}var mp=[{label:"Start Event",actionName:"replace-with-none-start",className:"bpmn-icon-start-event-none",target:{type:"bpmn:StartEvent"}},{label:"Intermediate Throw Event",actionName:"replace-with-none-intermediate-throwing",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:IntermediateThrowEvent"}},{label:"End Event",actionName:"replace-with-none-end",className:"bpmn-icon-end-event-none",target:{type:"bpmn:EndEvent"}},{label:"Message Start Event",actionName:"replace-with-message-start",className:"bpmn-icon-start-event-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Timer Start Event",actionName:"replace-with-timer-start",className:"bpmn-icon-start-event-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition"}},{label:"Conditional Start Event",actionName:"replace-with-conditional-start",className:"bpmn-icon-start-event-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition"}},{label:"Signal Start Event",actionName:"replace-with-signal-start",className:"bpmn-icon-start-event-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}}],vp=[{label:"Start Event",actionName:"replace-with-none-start",className:"bpmn-icon-start-event-none",target:{type:"bpmn:StartEvent"}},{label:"Intermediate Throw Event",actionName:"replace-with-none-intermediate-throwing",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:IntermediateThrowEvent"}},{label:"End Event",actionName:"replace-with-none-end",className:"bpmn-icon-end-event-none",target:{type:"bpmn:EndEvent"}}],yp=[{label:"Start Event",actionName:"replace-with-none-start",className:"bpmn-icon-start-event-none",target:{type:"bpmn:StartEvent"}},{label:"Intermediate Throw Event",actionName:"replace-with-none-intermediate-throw",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:IntermediateThrowEvent"}},{label:"End Event",actionName:"replace-with-none-end",className:"bpmn-icon-end-event-none",target:{type:"bpmn:EndEvent"}},{label:"Message Intermediate Catch Event",actionName:"replace-with-message-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-message",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Message Intermediate Throw Event",actionName:"replace-with-message-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-message",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Timer Intermediate Catch Event",actionName:"replace-with-timer-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-timer",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:TimerEventDefinition"}},{label:"Escalation Intermediate Throw Event",actionName:"replace-with-escalation-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-escalation",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},{label:"Conditional Intermediate Catch Event",actionName:"replace-with-conditional-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-condition",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition"}},{label:"Link Intermediate Catch Event",actionName:"replace-with-link-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-link",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:LinkEventDefinition",eventDefinitionAttrs:{name:""}}},{label:"Link Intermediate Throw Event",actionName:"replace-with-link-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-link",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:LinkEventDefinition",eventDefinitionAttrs:{name:""}}},{label:"Compensation Intermediate Throw Event",actionName:"replace-with-compensation-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-compensation",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},{label:"Signal Intermediate Catch Event",actionName:"replace-with-signal-intermediate-catch",className:"bpmn-icon-intermediate-event-catch-signal",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},{label:"Signal Intermediate Throw Event",actionName:"replace-with-signal-intermediate-throw",className:"bpmn-icon-intermediate-event-throw-signal",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}}],gp=[{label:"Start Event",actionName:"replace-with-none-start",className:"bpmn-icon-start-event-none",target:{type:"bpmn:StartEvent"}},{label:"Intermediate Throw Event",actionName:"replace-with-none-intermediate-throw",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:IntermediateThrowEvent"}},{label:"End Event",actionName:"replace-with-none-end",className:"bpmn-icon-end-event-none",target:{type:"bpmn:EndEvent"}},{label:"Message End Event",actionName:"replace-with-message-end",className:"bpmn-icon-end-event-message",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Escalation End Event",actionName:"replace-with-escalation-end",className:"bpmn-icon-end-event-escalation",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},{label:"Error End Event",actionName:"replace-with-error-end",className:"bpmn-icon-end-event-error",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:ErrorEventDefinition"}},{label:"Cancel End Event",actionName:"replace-with-cancel-end",className:"bpmn-icon-end-event-cancel",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:CancelEventDefinition"}},{label:"Compensation End Event",actionName:"replace-with-compensation-end",className:"bpmn-icon-end-event-compensation",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},{label:"Signal End Event",actionName:"replace-with-signal-end",className:"bpmn-icon-end-event-signal",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},{label:"Terminate End Event",actionName:"replace-with-terminate-end",className:"bpmn-icon-end-event-terminate",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:TerminateEventDefinition"}}],bp=[{label:"Exclusive Gateway",actionName:"replace-with-exclusive-gateway",className:"bpmn-icon-gateway-xor",target:{type:"bpmn:ExclusiveGateway"}},{label:"Parallel Gateway",actionName:"replace-with-parallel-gateway",className:"bpmn-icon-gateway-parallel",target:{type:"bpmn:ParallelGateway"}},{label:"Inclusive Gateway",actionName:"replace-with-inclusive-gateway",className:"bpmn-icon-gateway-or",target:{type:"bpmn:InclusiveGateway"}},{label:"Complex Gateway",actionName:"replace-with-complex-gateway",className:"bpmn-icon-gateway-complex",target:{type:"bpmn:ComplexGateway"}},{label:"Event based Gateway",actionName:"replace-with-event-based-gateway",className:"bpmn-icon-gateway-eventbased",target:{type:"bpmn:EventBasedGateway",instantiate:!1,eventGatewayType:"Exclusive"}}],xp=[{label:"Transaction",actionName:"replace-with-transaction",className:"bpmn-icon-transaction",target:{type:"bpmn:Transaction",isExpanded:!0}},{label:"Event Sub Process",actionName:"replace-with-event-subprocess",className:"bpmn-icon-event-subprocess-expanded",target:{type:"bpmn:SubProcess",triggeredByEvent:!0,isExpanded:!0}},{label:"Sub Process (collapsed)",actionName:"replace-with-collapsed-subprocess",className:"bpmn-icon-subprocess-collapsed",target:{type:"bpmn:SubProcess",isExpanded:!1}}],_p=[{label:"Sub Process",actionName:"replace-with-subprocess",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:SubProcess",isExpanded:!0}},{label:"Event Sub Process",actionName:"replace-with-event-subprocess",className:"bpmn-icon-event-subprocess-expanded",target:{type:"bpmn:SubProcess",triggeredByEvent:!0,isExpanded:!0}}],Ep=[{label:"Sub Process",actionName:"replace-with-subprocess",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:SubProcess",isExpanded:!0}},{label:"Transaction",actionName:"replace-with-transaction",className:"bpmn-icon-transaction",target:{type:"bpmn:Transaction",isExpanded:!0}}],wp=[{label:"Task",actionName:"replace-with-task",className:"bpmn-icon-task",target:{type:"bpmn:Task"}},{label:"Send Task",actionName:"replace-with-send-task",className:"bpmn-icon-send",target:{type:"bpmn:SendTask"}},{label:"Receive Task",actionName:"replace-with-receive-task",className:"bpmn-icon-receive",target:{type:"bpmn:ReceiveTask"}},{label:"User Task",actionName:"replace-with-user-task",className:"bpmn-icon-user",target:{type:"bpmn:UserTask"}},{label:"Manual Task",actionName:"replace-with-manual-task",className:"bpmn-icon-manual",target:{type:"bpmn:ManualTask"}},{label:"Business Rule Task",actionName:"replace-with-rule-task",className:"bpmn-icon-business-rule",target:{type:"bpmn:BusinessRuleTask"}},{label:"Service Task",actionName:"replace-with-service-task",className:"bpmn-icon-service",target:{type:"bpmn:ServiceTask"}},{label:"Script Task",actionName:"replace-with-script-task",className:"bpmn-icon-script",target:{type:"bpmn:ScriptTask"}},{label:"Call Activity",actionName:"replace-with-call-activity",className:"bpmn-icon-call-activity",target:{type:"bpmn:CallActivity"}},{label:"Sub Process (collapsed)",actionName:"replace-with-collapsed-subprocess",className:"bpmn-icon-subprocess-collapsed",target:{type:"bpmn:SubProcess",isExpanded:!1}},{label:"Sub Process (expanded)",actionName:"replace-with-expanded-subprocess",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:SubProcess",isExpanded:!0}}],Sp=[{label:"Data Store Reference",actionName:"replace-with-data-store-reference",className:"bpmn-icon-data-store",target:{type:"bpmn:DataStoreReference"}}],Cp=[{label:"Data Object Reference",actionName:"replace-with-data-object-reference",className:"bpmn-icon-data-object",target:{type:"bpmn:DataObjectReference"}}],Tp=[{label:"Message Boundary Event",actionName:"replace-with-message-boundary",className:"bpmn-icon-intermediate-event-catch-message",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Timer Boundary Event",actionName:"replace-with-timer-boundary",className:"bpmn-icon-intermediate-event-catch-timer",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:TimerEventDefinition"}},{label:"Escalation Boundary Event",actionName:"replace-with-escalation-boundary",className:"bpmn-icon-intermediate-event-catch-escalation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},{label:"Conditional Boundary Event",actionName:"replace-with-conditional-boundary",className:"bpmn-icon-intermediate-event-catch-condition",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition"}},{label:"Error Boundary Event",actionName:"replace-with-error-boundary",className:"bpmn-icon-intermediate-event-catch-error",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ErrorEventDefinition"}},{label:"Cancel Boundary Event",actionName:"replace-with-cancel-boundary",className:"bpmn-icon-intermediate-event-catch-cancel",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:CancelEventDefinition"}},{label:"Signal Boundary Event",actionName:"replace-with-signal-boundary",className:"bpmn-icon-intermediate-event-catch-signal",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},{label:"Compensation Boundary Event",actionName:"replace-with-compensation-boundary",className:"bpmn-icon-intermediate-event-catch-compensation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},{label:"Message Boundary Event (non-interrupting)",actionName:"replace-with-non-interrupting-message-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-message",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:MessageEventDefinition",cancelActivity:!1}},{label:"Timer Boundary Event (non-interrupting)",actionName:"replace-with-non-interrupting-timer-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-timer",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:TimerEventDefinition",cancelActivity:!1}},{label:"Escalation Boundary Event (non-interrupting)",actionName:"replace-with-non-interrupting-escalation-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-escalation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",cancelActivity:!1}},{label:"Conditional Boundary Event (non-interrupting)",actionName:"replace-with-non-interrupting-conditional-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-condition",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",cancelActivity:!1}},{label:"Signal Boundary Event (non-interrupting)",actionName:"replace-with-non-interrupting-signal-boundary",className:"bpmn-icon-intermediate-event-catch-non-interrupting-signal",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:SignalEventDefinition",cancelActivity:!1}}],Rp=[{label:"Message Start Event",actionName:"replace-with-message-start",className:"bpmn-icon-start-event-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},{label:"Timer Start Event",actionName:"replace-with-timer-start",className:"bpmn-icon-start-event-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition"}},{label:"Conditional Start Event",actionName:"replace-with-conditional-start",className:"bpmn-icon-start-event-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition"}},{label:"Signal Start Event",actionName:"replace-with-signal-start",className:"bpmn-icon-start-event-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},{label:"Error Start Event",actionName:"replace-with-error-start",className:"bpmn-icon-start-event-error",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ErrorEventDefinition"}},{label:"Escalation Start Event",actionName:"replace-with-escalation-start",className:"bpmn-icon-start-event-escalation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},{label:"Compensation Start Event",actionName:"replace-with-compensation-start",className:"bpmn-icon-start-event-compensation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},{label:"Message Start Event (non-interrupting)",actionName:"replace-with-non-interrupting-message-start",className:"bpmn-icon-start-event-non-interrupting-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition",isInterrupting:!1}},{label:"Timer Start Event (non-interrupting)",actionName:"replace-with-non-interrupting-timer-start",className:"bpmn-icon-start-event-non-interrupting-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition",isInterrupting:!1}},{label:"Conditional Start Event (non-interrupting)",actionName:"replace-with-non-interrupting-conditional-start",className:"bpmn-icon-start-event-non-interrupting-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",isInterrupting:!1}},{label:"Signal Start Event (non-interrupting)",actionName:"replace-with-non-interrupting-signal-start",className:"bpmn-icon-start-event-non-interrupting-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition",isInterrupting:!1}},{label:"Escalation Start Event (non-interrupting)",actionName:"replace-with-non-interrupting-escalation-start",className:"bpmn-icon-start-event-non-interrupting-escalation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",isInterrupting:!1}}],Pp=[{label:"Sequence Flow",actionName:"replace-with-sequence-flow",className:"bpmn-icon-connection"},{label:"Default Flow",actionName:"replace-with-default-flow",className:"bpmn-icon-default-flow"},{label:"Conditional Flow",actionName:"replace-with-conditional-flow",className:"bpmn-icon-conditional-flow"}],Ap=[{label:"Expanded Pool",actionName:"replace-with-expanded-pool",className:"bpmn-icon-participant",target:{type:"bpmn:Participant",isExpanded:!0}},{label:function(e){var t="Empty Pool";return e.children&&e.children.length&&(t+=" (removes content)"),t},actionName:"replace-with-collapsed-pool",className:"bpmn-icon-lane",target:{type:"bpmn:Participant",isExpanded:!1}}];function kp(e,t,n,i,r,o,a){this._bpmnFactory=e,this._popupMenu=t,this._modeling=n,this._moddle=i,this._bpmnReplace=r,this._rules=o,this._translate=a,this.register()}kp.$inject=["bpmnFactory","popupMenu","modeling","moddle","bpmnReplace","rules","translate"],kp.prototype.register=function(){this._popupMenu.registerProvider("bpmn-replace",this)},kp.prototype.getEntries=function(e){var t,n=e.businessObject;if(!this._rules.allowed("shape.replace",{element:e}))return[];var i=fp(e);return Ar(n,"bpmn:DataObjectReference")?this._createEntries(e,Sp):Ar(n,"bpmn:DataStoreReference")&&!Ar(e.parent,"bpmn:Collaboration")?this._createEntries(e,Cp):Ar(n,"bpmn:StartEvent")&&!Ar(n.$parent,"bpmn:SubProcess")?(t=g(mp,i),this._createEntries(e,t)):Ar(n,"bpmn:Participant")?(t=g(Ap,(function(e){return Mr(n)!==e.target.isExpanded})),this._createEntries(e,t)):Ar(n,"bpmn:StartEvent")&&Dr(n.$parent)?(t=g(Rp,(function(t){var n=!1!==t.target.isInterrupting,r=kr(e).isInterrupting===n;return i(t)||!i(t)&&!r})),this._createEntries(e,t)):Ar(n,"bpmn:StartEvent")&&!Dr(n.$parent)&&Ar(n.$parent,"bpmn:SubProcess")?(t=g(vp,i),this._createEntries(e,t)):Ar(n,"bpmn:EndEvent")?(t=g(gp,(function(e){return!("bpmn:CancelEventDefinition"==e.target.eventDefinitionType&&!Ar(n.$parent,"bpmn:Transaction"))&&i(e)})),this._createEntries(e,t)):Ar(n,"bpmn:BoundaryEvent")?(t=g(Tp,(function(e){var t=e.target;if("bpmn:CancelEventDefinition"==t.eventDefinitionType&&!Ar(n.attachedToRef,"bpmn:Transaction"))return!1;var r=!1!==t.cancelActivity,o=n.cancelActivity==r;return i(e)||!i(e)&&!o})),this._createEntries(e,t)):Ar(n,"bpmn:IntermediateCatchEvent")||Ar(n,"bpmn:IntermediateThrowEvent")?(t=g(yp,i),this._createEntries(e,t)):Ar(n,"bpmn:Gateway")?(t=g(bp,i),this._createEntries(e,t)):Ar(n,"bpmn:Transaction")?(t=g(_p,i),this._createEntries(e,t)):Dr(n)&&Mr(n)?(t=g(Ep,i),this._createEntries(e,t)):Ar(n,"bpmn:SubProcess")&&Mr(n)?(t=g(xp,i),this._createEntries(e,t)):Ar(n,"bpmn:AdHocSubProcess")&&!Mr(n)?(t=g(wp,(function(t){var n=t.target,i="bpmn:SubProcess"===n.type,r=!0===n.isExpanded;return fp(e)&&(!i||r)})),this._createEntries(e,t)):Ar(n,"bpmn:SequenceFlow")?this._createSequenceFlowEntries(e,Pp):Ar(n,"bpmn:FlowNode")?(t=g(wp,i),Ar(n,"bpmn:SubProcess")&&!Mr(n)&&(t=g(t,(function(e){return"Sub Process (collapsed)"!==e.label}))),this._createEntries(e,t)):[]},kp.prototype.getHeaderEntries=function(e){var t=[];return Ar(e,"bpmn:Activity")&&!Dr(e)&&(t=t.concat(this._getLoopEntries(e))),Ar(e,"bpmn:DataObjectReference")&&(t=t.concat(this._getDataObjectIsCollection(e))),Ar(e,"bpmn:Participant")&&(t=t.concat(this._getParticipantMultiplicity(e))),!Ar(e,"bpmn:SubProcess")||Ar(e,"bpmn:Transaction")||Dr(e)||t.push(this._getAdHocEntry(e)),t},kp.prototype._createEntries=function(e,t){var n=[],i=this;return b(t,(function(t){var r=i._createMenuEntry(t,e);n.push(r)})),n},kp.prototype._createSequenceFlowEntries=function(e,t){var n=kr(e),i=[],r=this._modeling,o=this._moddle,a=this;return b(t,(function(t){switch(t.actionName){case"replace-with-default-flow":n.sourceRef.default!==n&&(Ar(n.sourceRef,"bpmn:ExclusiveGateway")||Ar(n.sourceRef,"bpmn:InclusiveGateway")||Ar(n.sourceRef,"bpmn:ComplexGateway")||Ar(n.sourceRef,"bpmn:Activity"))&&i.push(a._createMenuEntry(t,e,(function(){r.updateProperties(e.source,{default:n})})));break;case"replace-with-conditional-flow":!n.conditionExpression&&Ar(n.sourceRef,"bpmn:Activity")&&i.push(a._createMenuEntry(t,e,(function(){var t=o.create("bpmn:FormalExpression",{body:""});r.updateProperties(e,{conditionExpression:t})})));break;default:if(Ar(n.sourceRef,"bpmn:Activity")&&n.conditionExpression)return i.push(a._createMenuEntry(t,e,(function(){r.updateProperties(e,{conditionExpression:void 0})})));if((Ar(n.sourceRef,"bpmn:ExclusiveGateway")||Ar(n.sourceRef,"bpmn:InclusiveGateway")||Ar(n.sourceRef,"bpmn:ComplexGateway")||Ar(n.sourceRef,"bpmn:Activity"))&&n.sourceRef.default===n)return i.push(a._createMenuEntry(t,e,(function(){r.updateProperties(e.source,{default:void 0})})))}})),i},kp.prototype._createMenuEntry=function(e,t,n){var i=this._translate,r=this._bpmnReplace.replaceElement,o=e.label;return o&&"function"==typeof o&&(o=o(t)),n=n||function(){return r(t,e.target)},{label:i(o),className:e.className,id:e.actionName,action:n}},kp.prototype._getLoopEntries=function(e){var t=this,n=this._translate;function i(n,i){var r;i.active?r=void 0:(r=t._moddle.create(i.options.loopCharacteristics),i.options.isSequential&&(r.isSequential=i.options.isSequential)),t._modeling.updateProperties(e,{loopCharacteristics:r})}var r,o,a,s=kr(e).loopCharacteristics;return s&&(r=s.isSequential,o=void 0===s.isSequential,a=void 0!==s.isSequential&&!s.isSequential),[{id:"toggle-parallel-mi",className:"bpmn-icon-parallel-mi-marker",title:n("Parallel Multi Instance"),active:a,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!1}},{id:"toggle-sequential-mi",className:"bpmn-icon-sequential-mi-marker",title:n("Sequential Multi Instance"),active:r,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!0}},{id:"toggle-loop",className:"bpmn-icon-loop-marker",title:n("Loop"),active:o,action:i,options:{loopCharacteristics:"bpmn:StandardLoopCharacteristics"}}]},kp.prototype._getDataObjectIsCollection=function(e){var t=this,n=this._translate;var i=e.businessObject.dataObjectRef,r=i.isCollection;return[{id:"toggle-is-collection",className:"bpmn-icon-parallel-mi-marker",title:n("Collection"),active:r,action:function(n,r){t._modeling.updateModdleProperties(e,i,{isCollection:!r.active})}}]},kp.prototype._getParticipantMultiplicity=function(e){var t=this,n=this._bpmnFactory,i=this._translate;var r=e.businessObject.participantMultiplicity;return[{id:"toggle-participant-multiplicity",className:"bpmn-icon-parallel-mi-marker",title:i("Participant Multiplicity"),active:!!r,action:function(i,r){var o;r.active||(o=n.create("bpmn:ParticipantMultiplicity")),t._modeling.updateProperties(e,{participantMultiplicity:o})}}]},kp.prototype._getAdHocEntry=function(e){var t=this._translate,n=Ar(kr(e),"bpmn:AdHocSubProcess"),i=this._bpmnReplace.replaceElement;return{id:"toggle-adhoc",className:"bpmn-icon-ad-hoc-marker",title:t("Ad-hoc"),active:n,action:function(t,r){return i(e,n?{type:"bpmn:SubProcess"}:{type:"bpmn:AdHocSubProcess"},{autoResize:!1,layoutConnection:!1})}}};var Mp={__depends__:[Hc,dp],__init__:["replaceMenuProvider"],replaceMenuProvider:["type",kp]},Dp=Math.max,Bp=Math.min;function Np(e,t){return{top:e.top-t.top,right:e.right-t.right,bottom:e.bottom-t.bottom,left:e.left-t.left}}function Op(e,t,n){var i=t[e],r=n.min&&n.min[e],o=n.max&&n.max[e];return d(r)&&(i=(/top|left/.test(e)?Bp:Dp)(i,r)),d(o)&&(i=(/top|left/.test(e)?Dp:Bp)(i,o)),i}function jp(e,t){return void 0!==e?e:20}function Lp(e){return!e.waypoints&&"label"!==e.type}function Ip(e,t){var n;if((n=void 0===e.length?g(e.children,Lp):e).length)return function(e,t){var n,i,r,o;return"object"==typeof t?(n=jp(t.left),i=jp(t.right),r=jp(t.top),o=jp(t.bottom)):n=i=r=o=jp(t),{x:e.x-n,y:e.y-r,width:e.width+n+i,height:e.height+r+o}}(pt(n),t)}var zp=Math.abs;var Fp=["bpmn:Participant","bpmn:Process","bpmn:SubProcess"],$p=30;function Hp(e,t){return t=t||[],e.children.filter((function(e){Ar(e,"bpmn:Lane")&&(Hp(e,t),t.push(e))})),t}function Gp(e){return e.children.filter((function(e){return Ar(e,"bpmn:Lane")}))}function Wp(e){return Ga(e,Fp)||e}function Vp(e,t){var n=Wp(e),i=Hp(n,Ar(n,"bpmn:Process")?[]:[n]),r=an(e),o=an(t),a=function(e,t){return Np(an(t),an(e))}(e,t),s=[];return i.forEach((function(t){if(t!==e){var n,i,c=0,p=a.right,l=0,u=a.left,h=an(t);a.top&&(zp(h.bottom-r.top)<10&&(l=o.top-h.bottom),zp(h.top-r.top)<5&&(c=o.top-h.top)),a.bottom&&(zp(h.top-r.bottom)<10&&(c=o.bottom-h.top),zp(h.bottom-r.bottom)<5&&(l=o.bottom-h.bottom)),(c||p||l||u)&&s.push({shape:t,newBounds:(n=t,i={top:c,right:p,bottom:l,left:u},{x:n.x+(i.left||0),y:n.y+(i.top||0),width:n.width-(i.left||0)+(i.right||0),height:n.height-(i.top||0)+(i.bottom||0)})})}})),s}function Up(e,t,n,i,r,o,a,s,c,p,l,u){e=e||{},i.registerProvider(this),this._contextPad=i,this._modeling=r,this._elementFactory=o,this._connect=a,this._create=s,this._popupMenu=c,this._canvas=p,this._rules=l,this._translate=u,!1!==e.autoPlace&&(this._autoPlace=t.get("autoPlace",!1)),n.on("create.end",250,(function(e){var t=e.context.shape;if(xo(e)&&i.isOpen(t)){var n=i.getEntries(t);n.replace&&n.replace.action.click(e,t)}}))}function qp(e,t,n){var i=e.$instanceOf(t),r=!1;return b(e.eventDefinitions||[],(function(e){e.$type===n&&(r=!0)})),i&&r}Up.$inject=["config.contextPad","injector","eventBus","contextPad","modeling","elementFactory","connect","create","popupMenu","canvas","rules","translate"],Up.prototype.getContextPadEntries=function(e){var t=this._contextPad,n=this._modeling,i=this._elementFactory,r=this._connect,o=this._create,a=this._popupMenu,s=this._canvas,c=this._rules,p=this._autoPlace,l=this._translate,h={};if("label"===e.type)return h;var d=e.businessObject;function f(e,t){r.start(e,t)}function m(e,t,n,r){function a(t,n){var a=i.createShape(F({type:e},r));o.start(t,a,{source:n})}return"string"!=typeof n&&(r=n,n=l("Append {type}",{type:e.replace(/^bpmn:/,"")})),{group:"model",className:t,title:n,action:{dragstart:a,click:p?function(t,n){var o=i.createShape(F({type:e},r));p.append(n,o)}:a}}}function v(e){return function(i,r){n.splitLane(r,e),t.open(r,!0)}}if(Ha(d,["bpmn:Lane","bpmn:Participant"])&&Mr(d)){var y=Gp(e);F(h,{"lane-insert-above":{group:"lane-insert-above",className:"bpmn-icon-lane-insert-above",title:l("Add Lane above"),action:{click:function(e,t){n.addLane(t,"top")}}}}),y.length<2&&(e.height>=120&&F(h,{"lane-divide-two":{group:"lane-divide",className:"bpmn-icon-lane-divide-two",title:l("Divide into two Lanes"),action:{click:v(2)}}}),e.height>=180&&F(h,{"lane-divide-three":{group:"lane-divide",className:"bpmn-icon-lane-divide-three",title:l("Divide into three Lanes"),action:{click:v(3)}}})),F(h,{"lane-insert-below":{group:"lane-insert-below",className:"bpmn-icon-lane-insert-below",title:l("Add Lane below"),action:{click:function(e,t){n.addLane(t,"bottom")}}}})}Ar(d,"bpmn:FlowNode")&&(Ar(d,"bpmn:EventBasedGateway")?F(h,{"append.receive-task":m("bpmn:ReceiveTask","bpmn-icon-receive-task",l("Append ReceiveTask")),"append.message-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-message",l("Append MessageIntermediateCatchEvent"),{eventDefinitionType:"bpmn:MessageEventDefinition"}),"append.timer-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-timer",l("Append TimerIntermediateCatchEvent"),{eventDefinitionType:"bpmn:TimerEventDefinition"}),"append.condition-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-condition",l("Append ConditionIntermediateCatchEvent"),{eventDefinitionType:"bpmn:ConditionalEventDefinition"}),"append.signal-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-signal",l("Append SignalIntermediateCatchEvent"),{eventDefinitionType:"bpmn:SignalEventDefinition"})}):qp(d,"bpmn:BoundaryEvent","bpmn:CompensateEventDefinition")?F(h,{"append.compensation-activity":m("bpmn:Task","bpmn-icon-task",l("Append compensation activity"),{isForCompensation:!0})}):Ar(d,"bpmn:EndEvent")||d.isForCompensation||qp(d,"bpmn:IntermediateThrowEvent","bpmn:LinkEventDefinition")||Dr(d)||F(h,{"append.end-event":m("bpmn:EndEvent","bpmn-icon-end-event-none",l("Append EndEvent")),"append.gateway":m("bpmn:ExclusiveGateway","bpmn-icon-gateway-none",l("Append Gateway")),"append.append-task":m("bpmn:Task","bpmn-icon-task",l("Append Task")),"append.intermediate-event":m("bpmn:IntermediateThrowEvent","bpmn-icon-intermediate-event-none",l("Append Intermediate/Boundary Event"))})),a.isEmpty(e,"bpmn-replace")||F(h,{replace:{group:"edit",className:"bpmn-icon-screw-wrench",title:l("Change type"),action:{click:function(e,n){var i=F(function(e){var n=s.getContainer(),i=t.getPad(e).html,r=n.getBoundingClientRect(),o=i.getBoundingClientRect(),a=o.top-r.top;return{x:o.left-r.left,y:a+o.height+5}}(n),{cursor:{x:e.x,y:e.y}});a.open(n,"bpmn-replace",i)}}}}),Ha(d,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference"])&&F(h,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation"),connect:{group:"connect",className:"bpmn-icon-connection-multi",title:l("Connect using "+(d.isForCompensation?"":"Sequence/MessageFlow or ")+"Association"),action:{click:f,dragstart:f}}}),Ar(d,"bpmn:TextAnnotation")&&F(h,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:l("Connect using Association"),action:{click:f,dragstart:f}}}),Ha(d,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&F(h,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:l("Connect using DataInputAssociation"),action:{click:f,dragstart:f}}}),Ar(d,"bpmn:Group")&&F(h,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation")});var g=c.allowed("elements.delete",{elements:[e]});return u(g)&&(g=g[0]===e),g&&F(h,{delete:{group:"edit",className:"bpmn-icon-trash",title:l("Remove"),action:{click:function(t){n.removeElements([e])}}}}),h};var Kp={__depends__:[xc,wc,No,uc,Ic,Mp],__init__:["contextPadProvider"],contextPadProvider:["type",Up]},Yp={horizontal:["x","width"],vertical:["y","height"]};function Xp(e){this._modeling=e,this._filters=[],this.registerFilter((function(e,t,n){var i,r=0,o=0;return b(e,(function(e){e.waypoints||e.labelTarget||(r+=e[n],o+=1)})),i=Math.round(r/o),g(e,(function(e){return e[n]<i+50}))}))}Xp.$inject=["modeling"],Xp.prototype.registerFilter=function(e){if("function"!=typeof e)throw new Error("the filter has to be a function");this._filters.push(e)},Xp.prototype.trigger=function(e,t){var n,i,r=this._modeling;if(!(e.length<3||(this._setOrientation(t),i=this._filterElements(e),(n=this._createGroups(i)).length<=2)))return r.distributeElements(n,this._axis,this._dimension),n},Xp.prototype._filterElements=function(e){var t=this._filters,n=this._axis,i=this._dimension,r=[].concat(e);return t.length?(b(t,(function(e){r=e(r,n,i)})),r):e},Xp.prototype._createGroups=function(e){var t=[],n=this,i=this._axis,r=this._dimension;if(!i)throw new Error('must have a defined "axis" and "dimension"');return b(M(e,i),(function(e,o){var a,s=n._findRange(e,i,r),c=t[t.length-1];c&&n._hasIntersection(c.range,s)?t[t.length-1].elements.push(e):(a={range:s,elements:[e]},t.push(a))})),t},Xp.prototype._setOrientation=function(e){var t=Yp[e];this._axis=t[0],this._dimension=t[1]},Xp.prototype._hasIntersection=function(e,t){return Math.max(e.min,e.max)>=Math.min(t.min,t.max)&&Math.min(e.min,e.max)<=Math.max(t.min,t.max)},Xp.prototype._findRange=function(e){var t=e[this._axis];return{min:t+5,max:t+e[this._dimension]-5}};var Zp={__init__:["distributeElements"],distributeElements:["type",Xp]};function Qp(e){e.registerFilter((function(e){return g(e,(function(e){var t=Ha(e,["bpmn:Association","bpmn:BoundaryEvent","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:Lane","bpmn:MessageFlow","bpmn:Participant","bpmn:SequenceFlow","bpmn:TextAnnotation"]);return!(e.labelTarget||t)}))}))}Qp.$inject=["distributeElements"];var Jp={__depends__:[Zp],__init__:["bpmnDistributeElements"],bpmnDistributeElements:["type",Qp]},el="is not a registered action";function tl(e,t){this._actions={};var n=this;e.on("diagram.init",(function(){n._registerDefaultActions(t),e.fire("editorActions.init",{editorActions:n})}))}function nl(e,t){return new Error(e+" "+t)}tl.$inject=["eventBus","injector"],tl.prototype._registerDefaultActions=function(e){var t=e.get("commandStack",!1),n=e.get("modeling",!1),i=e.get("selection",!1),r=e.get("zoomScroll",!1),o=e.get("copyPaste",!1),a=e.get("canvas",!1),s=e.get("rules",!1),c=e.get("keyboardMove",!1),p=e.get("keyboardMoveSelection",!1);t&&(this.register("undo",(function(){t.undo()})),this.register("redo",(function(){t.redo()}))),o&&i&&this.register("copy",(function(){var e=i.get();o.copy(e)})),o&&this.register("paste",(function(){o.paste()})),r&&this.register("stepZoom",(function(e){r.stepZoom(e.value)})),a&&this.register("zoom",(function(e){a.zoom(e.value)})),n&&i&&s&&this.register("removeSelection",(function(){var e=i.get();if(e.length){var t,r=s.allowed("elements.delete",{elements:e});!1!==r&&(t=u(r)?r:e).length&&n.removeElements(t.slice())}})),c&&this.register("moveCanvas",(function(e){c.moveCanvas(e)})),p&&this.register("moveSelection",(function(e){p.moveSelection(e.direction,e.accelerated)}))},tl.prototype.trigger=function(e,t){if(!this._actions[e])throw nl(e,el);return this._actions[e](t)},tl.prototype.register=function(e,t){var n=this;if("string"==typeof e)return this._registerAction(e,t);b(e,(function(e,t){n._registerAction(t,e)}))},tl.prototype._registerAction=function(e,t){if(this.isRegistered(e))throw nl(e,"is already registered");this._actions[e]=t},tl.prototype.unregister=function(e){if(!this.isRegistered(e))throw nl(e,el);this._actions[e]=void 0},tl.prototype.getActions=function(){return Object.keys(this._actions)},tl.prototype.isRegistered=function(e){return!!this._actions[e]};var il={__init__:["editorActions"],editorActions:["type",tl]};function rl(e){e.invoke(tl,this)}n(rl,tl),rl.$inject=["injector"],rl.prototype._registerDefaultActions=function(e){tl.prototype._registerDefaultActions.call(this,e);var t=e.get("canvas",!1),n=e.get("elementRegistry",!1),i=e.get("selection",!1),r=e.get("spaceTool",!1),o=e.get("lassoTool",!1),a=e.get("handTool",!1),s=e.get("globalConnect",!1),c=e.get("distributeElements",!1),p=e.get("alignElements",!1),l=e.get("directEditing",!1),u=e.get("searchPad",!1),h=e.get("modeling",!1);t&&n&&i&&this._registerAction("selectElements",(function(){var e=t.getRootElement(),r=n.filter((function(t){return t!==e}));return i.select(r),r})),r&&this._registerAction("spaceTool",(function(){r.toggle()})),o&&this._registerAction("lassoTool",(function(){o.toggle()})),a&&this._registerAction("handTool",(function(){a.toggle()})),s&&this._registerAction("globalConnectTool",(function(){s.toggle()})),i&&c&&this._registerAction("distributeElements",(function(e){var t=i.get(),n=e.type;t.length&&c.trigger(t,n)})),i&&p&&this._registerAction("alignElements",(function(e){var t=i.get(),n=[],r=e.type;t.length&&(n=g(t,(function(e){return!Ar(e,"bpmn:Lane")})),p.trigger(n,r))})),i&&h&&this._registerAction("setColor",(function(e){var t=i.get();t.length&&h.setColor(t,e)})),i&&l&&this._registerAction("directEditing",(function(){var e=i.get();e.length&&l.activate(e[0])})),u&&this._registerAction("find",(function(){u.toggle()})),t&&h&&this._registerAction("moveToOrigin",(function(){var e,i,r=t.getRootElement();e=pt(i=Ar(r,"bpmn:Collaboration")?n.filter((function(e){return Ar(e.parent,"bpmn:Collaboration")})):n.filter((function(e){return e!==r&&!Ar(e.parent,"bpmn:SubProcess")}))),h.moveElements(i,{x:-e.x,y:-e.y},r)}))};var ol={__depends__:[il],editorActions:["type",rl]};function al(e){e.on(["create.init","shape.move.init"],(function(e){var t=e.context;Ha(e.shape,["bpmn:Participant","bpmn:SubProcess","bpmn:TextAnnotation"])&&(t.gridSnappingContext||(t.gridSnappingContext={}),t.gridSnappingContext.snapLocation="top-left")}))}al.$inject=["eventBus"];function sl(e,t,n){return n||(n="round"),Math[n](e/t)*t}function cl(e,t,n){var i=!n||!1!==n.active;this._eventBus=t;var r=this;t.on("diagram.init",800,(function(){r.setActive(i)})),t.on(["create.move","create.end","bendpoint.move.move","bendpoint.move.end","connect.move","connect.end","connectionSegment.move.move","connectionSegment.move.end","resize.move","resize.end","shape.move.move","shape.move.end"],1200,(function(t){var n=t.originalEvent;if(!(!r.active||n&&Go(n))){var i=t.context,o=i.gridSnappingContext;o||(o=i.gridSnappingContext={}),["x","y"].forEach((function(n){var i={},o=function(e,t,n){var i=e.context,r=e.shape,o=i.gridSnappingContext,a=o.snapLocation,s=o.snapOffset;if(s&&d(s[t]))return s[t];s||(s=o.snapOffset={});d(s[t])||(s[t]=0);if(!r)return s[t];n.get(r.id)||(pl(t)?s[t]+=r[t]+r.width/2:s[t]+=r[t]+r.height/2);if(!a)return s[t];"x"===t?/left/.test(a)?s[t]-=r.width/2:/right/.test(a)&&(s[t]+=r.width/2):/top/.test(a)?s[t]-=r.height/2:/bottom/.test(a)&&(s[t]+=r.height/2);return s[t]}(t,n,e);o&&(i.offset=o);var a=function(e,t){var n=e.context,i=n.createConstraints,r=n.resizeConstraints||{},o=n.gridSnappingContext,a=o.snapConstraints;if(a&&a[t])return a[t];a||(a=o.snapConstraints={});a[t]||(a[t]={});var s=n.direction;i&&(pl(t)?(a.x.min=i.left,a.x.max=i.right):(a.y.min=i.top,a.y.max=i.bottom));var c=r.min,p=r.max;c&&(pl(t)?ul(s)?a.x.max=c.left:a.x.min=c.right:ll(s)?a.y.max=c.top:a.y.min=c.bottom);p&&(pl(t)?ul(s)?a.x.min=p.left:a.x.max=p.right:ll(s)?a.y.min=p.top:a.y.max=p.bottom);return a[t]}(t,n);a&&F(i,a),Js(t,n)||r.snapEvent(t,n,i)}))}}))}function pl(e){return"x"===e}function ll(e){return-1!==e.indexOf("n")}function ul(e){return-1!==e.indexOf("w")}function hl(e,t){Ka.call(this,e),this._gridSnapping=t;var n=this;this.preExecute("shape.resize",(function(e){var t=e.context,i=(t.hints||{}).autoResize;if(i){var r=t.shape,o=t.newBounds;m(i)?t.newBounds=n.snapComplex(o,i):t.newBounds=n.snapSimple(r,o)}}))}cl.prototype.snapEvent=function(e,t,n){ec(e,t,this.snapValue(e[t],n))},cl.prototype.getGridSpacing=function(){return 10},cl.prototype.snapValue=function(e,t){var n,i,r=0;return t&&t.offset&&(r=t.offset),e=sl(e+=r,10),t&&t.min&&d(n=t.min)&&(n=sl(n+r,10,"ceil"),e=Math.max(e,n)),t&&t.max&&d(i=t.max)&&(i=sl(i+r,10,"floor"),e=Math.min(e,i)),e-=r},cl.prototype.isActive=function(){return this.active},cl.prototype.setActive=function(e){this.active=e,this._eventBus.fire("gridSnapping.toggle",{active:e})},cl.prototype.toggleActive=function(){this.setActive(!this.active)},cl.$inject=["elementRegistry","eventBus","config.gridSnapping"],hl.$inject=["eventBus","gridSnapping","modeling"],n(hl,Ka),hl.prototype.snapSimple=function(e,t){var n=this._gridSnapping;return t.width=n.snapValue(t.width,{min:t.width}),t.height=n.snapValue(t.height,{min:t.height}),t.x=e.x+e.width/2-t.width/2,t.y=e.y+e.height/2-t.height/2,t},hl.prototype.snapComplex=function(e,t){return/w|e/.test(t)&&(e=this.snapHorizontally(e,t)),/n|s/.test(t)&&(e=this.snapVertically(e,t)),e},hl.prototype.snapHorizontally=function(e,t){var n=this._gridSnapping,i=/w/.test(t),r=/e/.test(t),o={};return o.width=n.snapValue(e.width,{min:e.width}),r&&(i?(o.x=n.snapValue(e.x,{max:e.x}),o.width+=n.snapValue(e.x-o.x,{min:e.x-o.x})):e.x=e.x+e.width-o.width),F(e,o),e},hl.prototype.snapVertically=function(e,t){var n=this._gridSnapping,i=/n/.test(t),r=/s/.test(t),o={};return o.height=n.snapValue(e.height,{min:e.height}),i&&(r?(o.y=n.snapValue(e.y,{max:e.y}),o.height+=n.snapValue(e.y-o.y,{min:e.y-o.y})):e.y=e.y+e.height-o.height),F(e,o),e};function dl(e,t){e.on(["spaceTool.move","spaceTool.end"],2e3,(function(e){var n,i=e.context;i.initialized&&("x"===i.axis?(n=t.snapValue(e.dx),e.x=e.x+n-e.dx,e.dx=n):(n=t.snapValue(e.dy),e.y=e.y+n-e.dy,e.dy=n))}))}dl.$inject=["eventBus","gridSnapping"];var fl={__depends__:[{__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",hl],gridSnappingSpaceToolBehavior:["type",dl]}],__init__:["gridSnapping"],gridSnapping:["type",cl]};function ml(e,t){e.on("autoPlace",2e3,(function(e){var n=e.source,i=cn(n),r=e.shape,o=Wa(n,r);return["x","y"].forEach((function(e){var n={};o[e]!==i[e]&&(o[e]>i[e]?n.min=o[e]:n.max=o[e],Ar(r,"bpmn:TextAnnotation")&&(!function(e){return"x"===e}(e)?n.offset=-r.height/2:n.offset=-r.width/2),o[e]=t.snapValue(o[e],n))})),o}))}ml.$inject=["eventBus","gridSnapping"];function vl(e,t,n){t.on(["create.start","shape.move.start"],1750,(function(t){var i=t.context,r=i.shape,o=e.getRootElement();Ar(r,"bpmn:Participant")&&Ar(o,"bpmn:Process")&&o.children.length&&(i.createConstraints&&(r.width=n.snapValue(r.width,{min:r.width}),r.height=n.snapValue(r.height,{min:r.height})))}))}vl.$inject=["canvas","eventBus","gridSnapping"];function yl(e,t,n){Ka.call(this,e),this._gridSnapping=t;var i=this;this.postExecuted(["connection.create","connection.layout"],3e3,(function(e){var t=e.context,r=t.connection,o=t.hints||{},a=r.waypoints;o.connectionStart||o.connectionEnd||!1===o.createElementsBehavior||function(e){return e.length>3}(a)&&n.updateWaypoints(r,i.snapMiddleSegments(a))}))}function gl(e,t,n){var i=xt(t,n),r={};return function(e){return"h"===e}(i)&&(r.y=e.snapValue(t.y)),function(e){return"v"===e}(i)&&(r.x=e.snapValue(t.x)),("x"in r||"y"in r)&&(t=F({},t,r),n=F({},n,r)),[t,n]}yl.$inject=["eventBus","gridSnapping","modeling"],n(yl,Ka),yl.prototype.snapMiddleSegments=function(e){var t,n=this._gridSnapping;e=e.slice();for(var i=1;i<e.length-2;i++)t=gl(n,e[i],e[i+1]),e[i]=t[0],e[i+1]=t[1];return e};var bl={__depends__:[fl,{__init__:["gridSnappingAutoPlaceBehavior","gridSnappingCreateParticipantBehavior","gridSnappingLayoutConnectionBehavior"],gridSnappingAutoPlaceBehavior:["type",ml],gridSnappingCreateParticipantBehavior:["type",vl],gridSnappingLayoutConnectionBehavior:["type",yl]}],__init__:["bpmnGridSnapping"],bpmnGridSnapping:["type",al]};function xl(e,t){this._interactionEvents=t;var n=this;e.on(["interactionEvents.createHit","interactionEvents.updateHit"],(function(e){var t=e.element,i=e.gfx;return Ar(t,"bpmn:Lane")?n.createParticipantHit(t,i):Ar(t,"bpmn:Participant")?Mr(t)?n.createParticipantHit(t,i):n.createDefaultHit(t,i):Ar(t,"bpmn:SubProcess")?Mr(t)?n.createSubProcessHit(t,i):n.createDefaultHit(t,i):void 0}))}xl.$inject=["eventBus","interactionEvents"],xl.prototype.createDefaultHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createDefaultHit(e,t),!0},xl.prototype.createParticipantHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"all",{width:30,height:e.height}),!0},xl.prototype.createSubProcessHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"all",{width:e.width,height:30}),!0};var _l={__init__:["bpmnInteractionEvents"],bpmnInteractionEvents:["type",xl]};function El(e){e.invoke(Jo,this)}n(El,Jo),El.$inject=["injector"],El.prototype.registerBindings=function(e,t){function n(n,i){t.isRegistered(n)&&e.addListener(i)}Jo.prototype.registerBindings.call(this,e,t),n("selectElements",(function(n){var i=n.keyEvent;if(e.isKey(["a","A"],i)&&e.isCmd(i))return t.trigger("selectElements"),!0})),n("find",(function(n){var i=n.keyEvent;if(e.isKey(["f","F"],i)&&e.isCmd(i))return t.trigger("find"),!0})),n("spaceTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["s","S"],i)?(t.trigger("spaceTool"),!0):void 0})),n("lassoTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["l","L"],i)?(t.trigger("lassoTool"),!0):void 0})),n("handTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["h","H"],i)?(t.trigger("handTool"),!0):void 0})),n("globalConnectTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["c","C"],i)?(t.trigger("globalConnectTool"),!0):void 0})),n("directEditing",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["e","E"],i)?(t.trigger("directEditing"),!0):void 0}))};var wl={__depends__:[ea],__init__:["keyboardBindings"],keyboardBindings:["type",El]},Sl={moveSpeed:1,moveSpeedAccelerated:10},Cl="left",Tl="right",Rl="down",Pl={ArrowLeft:Cl,Left:Cl,ArrowUp:"up",Up:"up",ArrowRight:Tl,Right:Tl,ArrowDown:Rl,Down:Rl},Al={left:function(e){return{x:-e,y:0}},up:function(e){return{x:0,y:-e}},right:function(e){return{x:e,y:0}},down:function(e){return{x:0,y:e}}};function kl(e,t,n,i,r){var o=this;this._config=F({},Sl,e||{}),t.addListener(1500,(function(e){var n=e.keyEvent,i=Pl[n.key];if(i&&!t.isCmd(n)){var r=t.isShift(n);return o.moveSelection(i,r),!0}})),this.moveSelection=function(e,t){var o=r.get();if(o.length){var a=this._config[t?"moveSpeedAccelerated":"moveSpeed"],s=Al[e](a);i.allowed("elements.move",{shapes:o})&&n.moveElements(o,s)}}}kl.$inject=["config.keyboardMoveSelection","keyboard","modeling","rules","selection"];var Ml={__depends__:[ea,No],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",kl]};function Dl(e,t,n,i){e.on("element.changed",(function(i){var r=i.element;(r.parent||r===t.getRootElement())&&(i.gfx=n.getGraphics(r)),i.gfx&&e.fire(lt(r)+".changed",i)})),e.on("elements.changed",(function(t){var n=t.elements;n.forEach((function(t){e.fire("element.changed",{element:t})})),i.updateContainments(n)})),e.on("shape.changed",(function(e){i.update("shape",e.element,e.gfx)})),e.on("connection.changed",(function(e){i.update("connection",e.element,e.gfx)}))}Dl.$inject=["eventBus","canvas","elementRegistry","graphicsFactory"];var Bl={__init__:["changeSupport"],changeSupport:["type",Dl]};function Nl(e,t,n,i){this._dragging=i,this._rules=t;var r=this;function o(e,t){var n,i=e.shape,o=e.direction,a=e.resizeConstraints;e.delta=t,n=function(e,t,n){var i=n.x,r=n.y,o={x:e.x,y:e.y,width:e.width,height:e.height};return-1!==t.indexOf("n")?(o.y=e.y+r,o.height=e.height-r):-1!==t.indexOf("s")&&(o.height=e.height+r),-1!==t.indexOf("e")?o.width=e.width+i:-1!==t.indexOf("w")&&(o.x=e.x+i,o.width=e.width-i),o}(i,o,t),e.newBounds=function(e,t){if(!t)return e;var n=an(e);return sn({top:Op("top",n,t),right:Op("right",n,t),bottom:Op("bottom",n,t),left:Op("left",n,t)})}(n,a),e.canExecute=r.canResize(e)}e.on("resize.start",(function(e){var t,n,i;t=e.context,n=t.resizeConstraints,i=t.minBounds,void 0===n&&(void 0===i&&(i=r.computeMinResizeBox(t)),t.resizeConstraints={min:an(i)})})),e.on("resize.move",(function(e){var t={x:e.dx,y:e.dy};o(e.context,t)})),e.on("resize.end",(function(e){!function(e){var t=e.shape,i=e.canExecute,r=e.newBounds;if(i){if(!function(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}(t,r=rn(r)))return;n.resizeShape(t,r)}}(e.context)}))}function Ol(e,t){var n=cn(e),i=an(e),r={x:n.x,y:n.y};return-1!==t.indexOf("n")?r.y=i.top:-1!==t.indexOf("s")&&(r.y=i.bottom),-1!==t.indexOf("e")?r.x=i.right:-1!==t.indexOf("w")&&(r.x=i.left),r}function jl(e){return"n"===e||"s"===e?"resize-ns":"e"===e||"w"===e?"resize-ew":"nw"===e||"se"===e?"resize-nwse":"resize-nesw"}Nl.prototype.canResize=function(e){var t=this._rules,n=$(e,["newBounds","shape","delta","direction"]);return t.allowed("shape.resize",n)},Nl.prototype.activate=function(e,t,n){var i,r,o=this._dragging;if("string"==typeof n&&(n={direction:n}),!(r=(i=F({shape:t},n)).direction))throw new Error("must provide a direction (n|w|s|e|nw|se|ne|sw)");o.init(e,Ol(t,r),"resize",{autoActivate:!0,cursor:jl(r),data:{shape:t,context:i}})},Nl.prototype.computeMinResizeBox=function(e){var t=e.shape;return function(e,t,n,i){var r=an(t),o={top:/n/.test(e)?r.bottom-n.height:r.top,left:/w/.test(e)?r.right-n.width:r.left,bottom:/s/.test(e)?r.top+n.height:r.bottom,right:/e/.test(e)?r.left+n.width:r.right},a=i?an(i):o;return sn({top:Bp(o.top,a.top),left:Bp(o.left,a.left),bottom:Dp(o.bottom,a.bottom),right:Dp(o.right,a.right)})}(e.direction,t,e.minDimensions||{width:10,height:10},Ip(t,e.childrenBoxPadding))},Nl.$inject=["eventBus","rules","modeling","dragging"];var Ll="djs-resizing",Il="resize-not-ok";function zl(e,t,n){e.on("resize.move",500,(function(e){var i,r,o,a;i=e.context,r=i.shape,o=i.newBounds,(a=i.frame)||(a=i.frame=n.addFrame(r,t.getActiveLayer()),t.addMarker(r,Ll)),o.width>5&&ge(a,{x:o.x,width:o.width}),o.height>5&&ge(a,{y:o.y,height:o.height}),i.canExecute?we(a).remove(Il):we(a).add(Il)})),e.on("resize.cleanup",(function(e){var n,i;n=e.context,i=n.shape,n.frame&&Ce(n.frame),t.removeMarker(i,Ll)}))}zl.$inject=["eventBus","canvas","previewSupport"];var Fl=-6,$l="djs-resizer",Hl=["n","w","s","e","nw","ne","se","sw"];function Gl(e,t,n,i){this._resize=i,this._canvas=t;var r=this;e.on("selection.changed",(function(e){var t=e.newSelection;r.removeResizers(),1===t.length&&b(t,I(r.addResizer,r))})),e.on("shape.changed",(function(e){var t=e.element;n.isSelected(t)&&(r.removeResizers(),r.addResizer(t))}))}Gl.prototype.makeDraggable=function(e,t,n){var i=this._resize;function r(t){bo(t)&&i.activate(t,e,n)}re.bind(t,"mousedown",r),re.bind(t,"touchstart",r)},Gl.prototype._createResizer=function(e,t,n,i){var r=this._getResizersParent(),o=function(e){var t={x:0,y:0};-1!==e.indexOf("e")?t.x=6:-1!==e.indexOf("w")&&(t.x=Fl);-1!==e.indexOf("s")?t.y=6:-1!==e.indexOf("n")&&(t.y=Fl);return t}(i),a=Me("g");we(a).add($l),we(a).add("djs-resizer-"+e.id),we(a).add("djs-resizer-"+i),me(r,a);var s=Me("rect");ge(s,{x:-2+o.x,y:-2+o.y,width:4,height:4}),we(s).add("djs-resizer-visual"),me(a,s);var c=Me("rect");return ge(c,{x:-10+o.x,y:-10+o.y,width:20,height:20}),we(c).add("djs-resizer-hit"),me(a,c),Wn(a,t,n),a},Gl.prototype.createResizer=function(e,t){var n=Ol(e,t),i=this._createResizer(e,n.x,n.y,t);this.makeDraggable(e,i,t)},Gl.prototype.addResizer=function(e){var t=this;this._resize.canResize({shape:e})&&b(Hl,(function(n){t.createResizer(e,n)}))},Gl.prototype.removeResizers=function(){Te(this._getResizersParent())},Gl.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")},Gl.$inject=["eventBus","canvas","selection","resize"];var Wl={__depends__:[hs,ss,Rc],__init__:["resize","resizePreview","resizeHandles"],resize:["type",Nl],resizePreview:["type",zl],resizeHandles:["type",Gl]};function Vl(e,t){var n=t.create("bpmn:CategoryValue"),i=t.create("bpmn:Category",{categoryValue:[n]});return vt(e.get("rootElements"),i),kr(i).$parent=e,kr(n).$parent=i,n}function Ul(e,t,n,i,r,o,a){function s(e,t){(t||Ha(e,["bpmn:Task","bpmn:TextAnnotation"])||ql(e))&&i.activate(e)}this._bpmnFactory=t,this._canvas=n,this._modeling=r,this._textRenderer=a,i.registerProvider(this),e.on("element.dblclick",(function(e){s(e.element,!0)})),e.on(["autoPlace.start","canvas.viewbox.changing","drag.init","element.mousedown","popupMenu.open"],(function(e){i.isActive()&&i.complete()})),e.on(["commandStack.changed"],(function(e){i.isActive()&&i.cancel()})),e.on("directEditing.activate",(function(e){o.removeResizers()})),e.on("create.end",500,(function(e){var t=e.context,n=t.shape,i=e.context.canExecute;e.isTouch||i&&(t.hints&&!1===t.hints.createElementsBehavior||s(n))})),e.on("autoPlace.end",500,(function(e){s(e.shape)}))}function ql(e){return Ar(e,"bpmn:SubProcess")&&!Mr(e)}Ul.$inject=["eventBus","bpmnFactory","canvas","directEditing","modeling","resizeHandles","textRenderer"],Ul.prototype.activate=function(e){var t=Or(e);if(void 0!==t){var n={text:t};F(n,this.getEditingBBox(e));var i={};return(Ha(e,["bpmn:Task","bpmn:Participant","bpmn:Lane","bpmn:CallActivity"])||ql(e))&&F(i,{centerVertically:!0}),io(e)&&F(i,{autoResize:!0}),Ar(e,"bpmn:TextAnnotation")&&F(i,{resizable:!0,autoResize:!0}),F(n,{options:i}),n}},Ul.prototype.getEditingBBox=function(e){var t=this._canvas,n=e.label||e,i=t.getAbsoluteBBox(n),r=i.x+i.width/2,o=i.y+i.height/2,a={x:i.x,y:i.y},s=t.zoom(),c=this._textRenderer.getDefaultStyle(),p=this._textRenderer.getExternalStyle(),l=p.fontSize*s,u=p.lineHeight,h=c.fontSize*s,d=c.lineHeight,f={fontFamily:this._textRenderer.getDefaultStyle().fontFamily,fontWeight:this._textRenderer.getDefaultStyle().fontWeight};(Ar(e,"bpmn:Lane")||function(e){return Ar(e,"bpmn:Participant")&&Mr(e)}(e))&&(F(a,{width:i.height,height:30*s,x:i.x-i.height/2+15*s,y:o-30*s/2}),F(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px",transform:"rotate(-90deg)"})),(Ha(e,["bpmn:Task","bpmn:CallActivity"])||function(e){return Ar(e,"bpmn:Participant")&&!Mr(e)}(e)||ql(e))&&(F(a,{width:i.width,height:i.height}),F(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px"})),function(e){return Ar(e,"bpmn:SubProcess")&&Mr(e)}(e)&&(F(a,{width:i.width,x:i.x}),F(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px"}));var m=90*s,v=7*s,y=4*s;if(n.labelTarget&&(F(a,{width:m,height:i.height+v+y,x:r-m/2,y:i.y-v}),F(f,{fontSize:l+"px",lineHeight:u,paddingTop:v+"px",paddingBottom:y+"px"})),io(n)&&!ro(n)&&!so(n)){var g=ao(e),b=t.getAbsoluteBBox({x:g.x,y:g.y,width:0,height:0}),x=l+v+y;F(a,{width:m,height:x,x:b.x-m/2,y:b.y-x/2}),F(f,{fontSize:l+"px",lineHeight:u,paddingTop:v+"px",paddingBottom:y+"px"})}return Ar(e,"bpmn:TextAnnotation")&&(F(a,{width:i.width,height:i.height,minWidth:30*s,minHeight:10*s}),F(f,{textAlign:"left",paddingTop:5*s+"px",paddingBottom:7*s+"px",paddingLeft:7*s+"px",paddingRight:5*s+"px",fontSize:h+"px",lineHeight:d})),{bounds:a,style:f}},Ul.prototype.update=function(e,t,n,i){var r,o,a;if((Ar(e,"bpmn:TextAnnotation")&&(o=this._canvas.getAbsoluteBBox(e),r={x:e.x,y:e.y,width:e.width/o.width*i.width,height:e.height/o.height*i.height}),Ar(e,"bpmn:Group"))&&!kr(e).categoryValueRef){var s=Vl(kr(this._canvas.getRootElement()).$parent,this._bpmnFactory);kr(e).categoryValueRef=s}(a=t)&&a.trim()||(t=null),this._modeling.updateLabel(e,t,r)};var Kl="djs-element-hidden",Yl="djs-label-hidden";function Xl(e,t,n,i){var r,o,a,s=this,c=t.getDefaultLayer();e.on("directEditing.activate",(function(e){var n=e.active;if(Ar(r=n.element.label||n.element,"bpmn:TextAnnotation")){o=t.getAbsoluteBBox(r),a=Me("g");var p=i.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:r.width,containerHeight:r.height,position:{mx:0,my:0}}),l=s.path=Me("path");ge(l,{d:p,strokeWidth:2,stroke:Zl(r)}),me(a,l),me(c,a),Vn(a,r.x,r.y)}Ar(r,"bpmn:TextAnnotation")||r.labelTarget?t.addMarker(r,Kl):(Ar(r,"bpmn:Task")||Ar(r,"bpmn:CallActivity")||Ar(r,"bpmn:SubProcess")||Ar(r,"bpmn:Participant"))&&t.addMarker(r,Yl)})),e.on("directEditing.resize",(function(e){if(Ar(r,"bpmn:TextAnnotation")){var t=e.height,n=e.dy,a=Math.max(r.height/o.height*(t+n),0),c=i.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:r.width,containerHeight:a,position:{mx:0,my:0}});ge(s.path,{d:c})}})),e.on(["directEditing.complete","directEditing.cancel"],(function(e){var n=e.active;n&&(t.removeMarker(n.element.label||n.element,Kl),t.removeMarker(r,Yl)),r=void 0,o=void 0,a&&(Ce(a),a=void 0)}))}function Zl(e,t){return kr(e).di.get("stroke")||t||"black"}Xl.$inject=["eventBus","canvas","elementRegistry","pathMap"];var Ql={__depends__:[Bl,Wl,xc],__init__:["labelEditingProvider","labelEditingPreview"],labelEditingProvider:["type",Ul],labelEditingPreview:["type",Xl]},Jl=["top","bottom","left","right"],eu=10;function tu(e,t){function n(e){if(ro(e)){var n=function(e){var t=cn(e.label),n=nu(cn(e),t);if(i=n,-1===Jl.indexOf(i))return;var i;var r=function(e){var t=cn(e);return[].concat(e.incoming.map((function(e){return e.waypoints[e.waypoints.length-2]})),e.outgoing.map((function(e){return e.waypoints[1]}))).map((function(e){return nu(t,e)}))}(e);if(e.host){var o=function(e){var t,n=e.host,i=pn(cn(e),n);t=i.indexOf("-")>=0?i.split("-"):[i];return Jl.filter((function(e){return-1===t.indexOf(e)}))}(e);r=r.concat(o)}var a=Jl.filter((function(e){return-1===r.indexOf(e)}));if(-1!==a.indexOf(n))return;return a[0]}(e);n&&function(e,n){var i=cn(e),r=e.label,o=cn(r);if(!r.parent)return;var a,s=an(e);switch(n){case"top":a={x:i.x,y:s.top-eu-r.height/2};break;case"left":a={x:s.left-eu-r.width/2,y:i.y};break;case"bottom":a={x:i.x,y:s.bottom+eu+r.height/2};break;case"right":a={x:s.right+eu+r.width/2,y:i.y}}var c=pa(a,o);t.moveShape(r,c)}(e,n)}}Ka.call(this,e),this.postExecuted(["connection.create","connection.layout","connection.updateWaypoints"],(function(e){var t=e.context,i=t.connection,r=i.source,o=i.target;!1!==(t.hints||{}).createElementsBehavior&&(n(r),n(o))})),this.postExecuted(["label.create"],(function(e){var t=e.context,i=t.shape;!1!==(t.hints||{}).createElementsBehavior&&n(i.labelTarget)})),this.postExecuted(["elements.create"],(function(e){var t=e.context,i=t.elements;!1!==(t.hints||{}).createElementsBehavior&&i.forEach((function(e){n(e)}))}))}function nu(e,t){return pn(t,e,5)}function iu(e,t,n){Ka.call(this,e),this.preExecute("shape.append",(function(e){var t=e.source,n=e.shape;e.position||(Ar(n,"bpmn:TextAnnotation")?e.position={x:t.x+t.width/2+75,y:t.y-50-n.height/2}:e.position={x:t.x+t.width+80+n.width/2,y:t.y+t.height/2})}),!0)}function ru(e,t){e.invoke(Ka,this),this.postExecute("shape.move",(function(e){var n=e.newParent,i=e.shape;b(g(i.incoming.concat(i.outgoing),(function(e){return Ar(e,"bpmn:Association")})),(function(e){t.moveConnection(e,{x:0,y:0},n)}))}),!0)}n(tu,Ka),tu.$inject=["eventBus","modeling"],n(iu,Ka),iu.$inject=["eventBus","elementFactory","bpmnRules"],n(ru,Ka),ru.$inject=["injector","modeling"];function ou(e,t){t.invoke(Ka,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",500,(function(e){var t=e.elements;1===(t=t.filter((function(e){return au(e,e.host)}))).length&&t.map((function(e){return t.indexOf(e)})).forEach((function(i){var r=t[i];e.elements[i]=n.replaceShape(t[i],r)}))}),!0),this.preExecute("elements.move",500,(function(e){var t=e.shapes,i=e.newHost;if(1===t.length){var r=t[0];au(r,i)&&(e.shapes=[n.replaceShape(r,i)])}}),!0)}function au(e,t){return!so(e)&&Ha(e,["bpmn:IntermediateThrowEvent","bpmn:IntermediateCatchEvent"])&&!!t}ou.$inject=["bpmnReplace","injector"],n(ou,Ka),ou.prototype.replaceShape=function(e,t){var n,i=(n=kr(e).eventDefinitions)&&n[0],r={type:"bpmn:BoundaryEvent",host:t};return i&&(r.eventDefinitionType=i.$type),this._bpmnReplace.replaceElement(e,r,{layoutConnection:!1})};function su(e,t,n){function i(e){return g(e.attachers,(function(e){return Ar(e,"bpmn:BoundaryEvent")}))}Ka.call(this,e),this.postExecute("connection.create",(function(e){var t=e.context.source,r=e.context.target,o=i(r);Ar(t,"bpmn:EventBasedGateway")&&Ar(r,"bpmn:ReceiveTask")&&o.length>0&&n.removeElements(o)})),this.postExecute("connection.reconnect",(function(e){var t=e.context.oldSource,r=e.context.newSource;Ar(t,"bpmn:Gateway")&&Ar(r,"bpmn:EventBasedGateway")&&b(r.outgoing,(function(e){var t=e.target,r=i(t);Ar(t,"bpmn:ReceiveTask")&&r.length>0&&n.removeElements(r)}))})),e.on("moddleCopy.canCopyProperty",2e3,(function(e){var n=e.parent,i=e.property,r=e.propertyName,o=t.getPropertyDescriptor(n,r);o&&o.isReference&&Ar(i,"bpmn:RootElement")&&n.set(r,i)}))}su.$inject=["eventBus","moddle","modeling"],n(su,Ka);function cu(e,t,n,i,r){function o(e){return Ha(e,["bpmn:ReceiveTask","bpmn:SendTask"])||function(e,t){u(t)||(t=[t]);return w(t,(function(t){return Br(e,t)}))}(e,["bpmn:ErrorEventDefinition","bpmn:EscalationEventDefinition","bpmn:MessageEventDefinition","bpmn:SignalEventDefinition"])}function a(t){return!!y(e.getDefinitions().get("rootElements"),D({id:t.id}))}function s(e){return Ar(e,"bpmn:ErrorEventDefinition")?"errorRef":Ar(e,"bpmn:EscalationEventDefinition")?"escalationRef":Ar(e,"bpmn:MessageEventDefinition")?"messageRef":Ar(e,"bpmn:SignalEventDefinition")?"signalRef":void 0}function c(e){if(Ha(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.get("messageRef");var t=e.get("eventDefinitions")[0];return t.get(s(t))}n.invoke(Ka,this),this.executed("shape.create",(function(t){var n=t.shape;if(o(n)){var i=c(kr(n));i&&!a(i)&&(vt(e.getDefinitions().get("rootElements"),i),t.addedRootElement=i)}}),!0),this.reverted("shape.create",(function(t){var n=t.addedRootElement;n&&mt(e.getDefinitions().get("rootElements"),n)}),!0),t.on("copyPaste.copyElement",(function(e){var t=e.descriptor,n=e.element;if(o(n)){var i=c(kr(n));i&&(t.referencedRootElement=i)}})),t.on("copyPaste.pasteElement",500,(function(e){var t=e.descriptor,n=t.businessObject;if(o(n)){var c=t.referencedRootElement;c&&(a(c)||(c=i.copyElement(c,r.create(c.$type))),function(e,t){if(Ha(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.set("messageRef",t);var n=e.get("eventDefinitions")[0];n.set(s(n),t)}(n,c))}}))}function pu(e){e.invoke(Ka,this),this.preExecute("shape.create",1500,(function(e){var t=e.context,n=t.parent,i=t.shape;Ar(n,"bpmn:Lane")&&!Ar(i,"bpmn:Lane")&&(t.parent=Ga(n,"bpmn:Participant"))}))}cu.$inject=["bpmnjs","eventBus","injector","moddleCopy","bpmnFactory"],n(cu,Ka),pu.$inject=["injector"],n(pu,Ka);var lu=1500;function uu(e,t,n){t.on(["create.hover","create.move","create.out","create.end","shape.move.hover","shape.move.move","shape.move.out","shape.move.end"],lu,(function(t){var i=t.context.shape||t.shape,r=t.hover;Ar(r,"bpmn:Lane")&&!Ha(i,["bpmn:Lane","bpmn:Participant"])&&(t.hover=Wp(r),t.hoverGfx=e.getGraphics(t.hover));var o=n.getRootElement();r!==o&&(i.labelTarget||Ar(i,"bpmn:Group"))&&(t.hover=o,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["connect.hover","connect.out","connect.end","connect.cleanup","global-connect.hover","global-connect.out","global-connect.end","global-connect.cleanup"],lu,(function(t){var n=t.hover;Ar(n,"bpmn:Lane")&&(t.hover=Wp(n)||n,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["bendpoint.move.hover"],lu,(function(t){var n=t.context,i=t.hover,r=n.type;Ar(i,"bpmn:Lane")&&/reconnect/.test(r)&&(t.hover=Wp(i)||i,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["connect.start"],lu,(function(e){var t=e.context,n=t.start;Ar(n,"bpmn:Lane")&&(t.start=Wp(n)||n)})),t.on("shape.move.start",2e3,(function(e){var t=e.shape;Ar(t,"bpmn:Lane")&&(e.shape=Wp(t)||t)}))}function hu(e,t,n){Ka.call(this,e),this.preExecute("shape.create",(function(e){var n=e.context.shape;if(Ar(n,"bpmn:DataObjectReference")&&"label"!==n.type){var i=t.create("bpmn:DataObject");n.businessObject.dataObjectRef=i}}))}uu.$inject=["elementRegistry","eventBus","canvas"],hu.$inject=["eventBus","bpmnFactory","moddle"],n(hu,Ka);var du=20,fu=20,mu=2e3;function vu(e,t,n){function i(){var t=e.getRootElement();return Ar(t,"bpmn:Collaboration")?t:n.makeCollaboration()}Ka.call(this,t),t.on(["create.start","shape.move.start"],mu,(function(t){var n=t.context,i=n.shape,r=e.getRootElement();if(Ar(i,"bpmn:Participant")&&Ar(r,"bpmn:Process")&&r.children.length){var o=r.children.filter((function(e){return!Ar(e,"bpmn:Group")&&!so(e)&&!function(e){return!!e.waypoints}(e)}));if(o.length){var a=pt(o);F(i,function(e,t){t={width:t.width+40+30,height:t.height+40};var n=Math.max(e.width,t.width),i=Math.max(e.height,t.height);return{x:-n/2,y:-i/2,width:n,height:i}}(i,a)),n.createConstraints=function(e,t){return{bottom:(t=an(t)).top+e.height/2-fu,left:t.right-e.width/2+du,top:t.bottom-e.height/2+fu,right:t.left+e.width/2-du-30}}(i,a)}}})),t.on("create.start",mu,(function(n){var i=n.context.shape,r=e.getRootElement(),o=e.getGraphics(r);function a(e){e.element=r,e.gfx=o}Ar(i,"bpmn:Participant")&&Ar(r,"bpmn:Process")&&(t.on("element.hover",mu,a),t.once("create.cleanup",(function(){t.off("element.hover",a)})))})),this.preExecute("elements.create",mu,(function(e){var t,n=e.elements,r=e.parent,o=function(e){return y(e,(function(e){return Ar(e,"bpmn:Participant")}))}(n);o&&Ar(r,"bpmn:Process")&&(e.parent=i(),(t=e.hints=e.hints||{}).participant=o,t.process=r,t.processRef=kr(o).get("processRef"))}),!0),this.preExecute("shape.create",(function(e){var t=e.parent,n=e.shape;Ar(n,"bpmn:Participant")&&Ar(t,"bpmn:Process")&&(e.parent=i(),e.process=t,e.processRef=kr(n).get("processRef"))}),!0),this.execute("shape.create",(function(e){var t=e.hints||{},n=e.process||t.process,i=e.shape,r=t.participant;!n||r&&i!==r||kr(i).set("processRef",kr(n))}),!0),this.revert("shape.create",(function(e){var t=e.hints||{},n=e.process||t.process,i=e.processRef||t.processRef,r=e.shape,o=t.participant;!n||o&&r!==o||kr(r).set("processRef",i)}),!0),this.postExecute("shape.create",(function(e){var t=e.hints||{},i=e.process||e.hints.process,r=e.shape,o=t.participant;if(i){var a=i.children.slice();o?r===o&&n.moveElements(a,{x:0,y:0},o):n.moveElements(a,{x:0,y:0},r)}}),!0)}vu.$inject=["canvas","eventBus","modeling"],n(vu,Ka);var yu="__targetRef_placeholder";function gu(e,t){function n(e,n){var i=e.get("properties"),r=y(i,(function(e){return e.name===yu}));return!r&&n&&vt(i,r=t.create("bpmn:Property",{name:yu})),r}function i(e,t){var i=n(e);i&&(function(e,t,n){return y(e.get("dataInputAssociations"),(function(e){return e!==n&&e.targetRef===t}))}(e,i,t)||mt(e.get("properties"),i))}function r(e){var t,r=e.context,o=r.connection,a=o.businessObject,s=o.target,c=s&&s.businessObject,p=r.newTarget,l=p&&p.businessObject,u=r.oldTarget||r.target,h=u&&u.businessObject,d=o.businessObject;h&&h!==c&&i(h,a),l&&l!==c&&i(l,a),c?(t=n(c,!0),d.targetRef=t):d.targetRef=null}Ka.call(this,e),this.executed(["connection.create","connection.delete","connection.move","connection.reconnect"],bu(r)),this.reverted(["connection.create","connection.delete","connection.move","connection.reconnect"],bu(r))}function bu(e){return function(t){if(Ar(t.context.connection,"bpmn:DataInputAssociation"))return e(t)}}function xu(e){this._bpmnUpdater=e}function _u(e,t,n,i){function r(e){return e.children.filter((function(e){return Ar(e,"bpmn:DataStoreReference")&&!e.labelTarget}))}function o(e,i){var r=e.businessObject||e;if(i=i||n.filter((function(e){return Ar(e,"bpmn:Participant")&&kr(e).processRef}))[0]){var o=i.businessObject||i;t.execute("dataStore.updateContainment",{dataStoreBo:r,newSemanticParent:o.processRef||o,newDiParent:o.di})}}Ka.call(this,i),t.registerHandler("dataStore.updateContainment",xu),this.preExecute("shape.create",(function(e){var t=e.context,n=t.shape;Ar(n,"bpmn:DataStoreReference")&&"label"!==n.type&&(t.hints||(t.hints={}),t.hints.autoResize=!1)})),this.preExecute("elements.move",(function(e){var t=e.context,n=t.shapes;n.filter((function(e){return Ar(e,"bpmn:DataStoreReference")})).length&&(t.hints||(t.hints={}),t.hints.autoResize=n.filter((function(e){return!Ar(e,"bpmn:DataStoreReference")})))})),this.postExecute("shape.create",(function(e){var t=e.context.shape,n=t.parent;Ar(t,"bpmn:DataStoreReference")&&"label"!==t.type&&Ar(n,"bpmn:Collaboration")&&o(t)})),this.postExecute("shape.move",(function(e){var t=e.context,n=t.shape,i=t.oldParent,r=n.parent;Ar(i,"bpmn:Collaboration")||Ar(n,"bpmn:DataStoreReference")&&"label"!==n.type&&Ar(r,"bpmn:Collaboration")&&o(n,Ar(i,"bpmn:Participant")?i:function(e,t){for(;e.parent;){if(Ar(e.parent,t))return e.parent;e=e.parent}}(i,"bpmn:Participant"))})),this.postExecute("shape.delete",(function(t){var n=t.context.shape,i=e.getRootElement();Ha(n,["bpmn:Participant","bpmn:SubProcess"])&&Ar(i,"bpmn:Collaboration")&&r(i).filter((function(e){return function(e,t){var n=e.businessObject||e,i=t.businessObject||t;for(;n.$parent;){if(n.$parent===i.processRef||i)return!0;n=n.$parent}return!1}(e,n)})).forEach((function(e){o(e)}))})),this.postExecute("canvas.updateRoot",(function(e){var t=e.context,n=t.oldRoot,i=t.newRoot;r(n).forEach((function(e){Ar(i,"bpmn:Process")&&o(e,i)}))}))}gu.$inject=["eventBus","bpmnFactory"],n(gu,Ka),xu.$inject=["bpmnUpdater"],xu.prototype.execute=function(e){var t=e.dataStoreBo,n=e.newSemanticParent,i=e.newDiParent;e.oldSemanticParent=t.$parent,e.oldDiParent=t.di.$parent,this._bpmnUpdater.updateSemanticParent(t,n),this._bpmnUpdater.updateDiParent(t.di,i)},xu.prototype.revert=function(e){var t=e.dataStoreBo,n=e.oldSemanticParent,i=e.oldDiParent;this._bpmnUpdater.updateSemanticParent(t,n),this._bpmnUpdater.updateDiParent(t.di,i)},_u.$inject=["canvas","commandStack","elementRegistry","eventBus"],n(_u,Ka);function Eu(e,t,n){Ka.call(this,e),this.postExecuted("shape.delete",500,(function(e){var t=e.context,i=t.hints,r=t.shape,o=t.oldParent;Ar(r,"bpmn:Lane")&&(i&&i.nested||function(e,t){var i,r,o,a=Gp(t),s=[],c=[];st(a,(function(t){return t.y>e.y?c.push(t):s.push(t),t.children})),a.length&&(i=c.length&&s.length?e.height/2:e.height,s.length&&(r=n.calculateAdjustments(s,"y",i,e.y-10),n.makeSpace(r.movingShapes,r.resizingShapes,{x:0,y:i},"s")),c.length&&(o=n.calculateAdjustments(c,"y",-i,e.y+e.height+10),n.makeSpace(o.movingShapes,o.resizingShapes,{x:0,y:-i},"n")))}(r,o))}))}Eu.$inject=["eventBus","modeling","spaceTool"],n(Eu,Ka);function wu(e,t){t.invoke(Ka,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",500,(function(e){var t=e.elements;t.filter((function(e){return Su(e,e.host)})).map((function(e){return t.indexOf(e)})).forEach((function(i){e.elements[i]=n.replaceShape(t[i])}))}),!0),this.preExecute("elements.move",500,(function(e){var t=e.shapes,i=e.newHost;t.forEach((function(e,r){var o,a=e.host;Su(e,(o=a,-1!==t.indexOf(o)?a:i))&&(t[r]=n.replaceShape(e))}))}),!0)}function Su(e,t){return!so(e)&&Ar(e,"bpmn:BoundaryEvent")&&!t}function Cu(e,t,n){function i(e,i,r){var o,a,s,c,p,l,u,h,f=i.waypoints,m=e.outgoing.slice(),v=e.incoming.slice(),y=ms(f,h=d(r.width)?cn(r):r);if(y){if(o=f.slice(0,y.index),a=f.slice(y.index+(y.bendpoint?1:0)),!o.length||!a.length)return;s=y.bendpoint?f[y.index]:h,1!==o.length&&Tu(e,o[o.length-1])||o.push(Ru(s)),1!==a.length&&Tu(e,a[0])||a.unshift(Ru(s))}c=i.source,p=i.target,t.canConnect(c,e,i)&&(n.reconnectEnd(i,e,o||h),l=i),t.canConnect(e,p,i)&&(l?u=n.connect(e,p,{type:i.type,waypoints:a}):(n.reconnectStart(i,e,a||h),u=i));var b=[].concat(l&&g(v,(function(e){return e.source===l.source}))||[],u&&g(m,(function(e){return e.target===u.target}))||[]);b.length&&n.removeElements(b)}Ka.call(this,e),this.preExecute("elements.move",(function(e){var n=e.newParent,i=e.shapes,r=e.delta,o=i[0];if(o&&n){n&&n.waypoints&&(e.newParent=n=n.parent);var a=cn(o),s={x:a.x+r.x,y:a.y+r.y},c=y(n.children,(function(e){return t.canInsert(i,e)&&ms(e.waypoints,s)}));c&&(e.targetFlow=c,e.position=s)}}),!0),this.postExecuted("elements.move",(function(e){var t=e.shapes,n=e.targetFlow,r=e.position;n&&i(t[0],n,r)}),!0),this.preExecute("shape.create",(function(e){var n=e.parent,i=e.shape;t.canInsert(i,n)&&(e.targetFlow=n,e.parent=n.parent)}),!0),this.postExecuted("shape.create",(function(e){var t=e.shape,n=e.targetFlow,r=e.position;n&&i(t,n,r)}),!0)}function Tu(e,t){var n=t.x,i=t.y;return n>=e.x&&n<=e.x+e.width&&i>=e.y&&i<=e.y+e.height}function Ru(e){return F({},e)}function Pu(e,t){Ka.call(this,e),this.preExecuted("connection.create",(function(e){var n=e.context,i=n.source,r=n.target,o=r.incoming.slice();n.hints&&!1===n.hints.createElementsBehavior||Ar(i,"bpmn:EventBasedGateway")&&r.incoming.length&&o.filter(Au).forEach((function(e){t.removeConnection(e)}))})),this.preExecuted("shape.replace",(function(e){var n=e.context.newShape;Ar(n,"bpmn:EventBasedGateway")&&n.outgoing.filter(Au).map((function(e){return e.target})).reduce((function(e,t){var n=t.incoming.filter(Au);return e.concat(n)}),[]).forEach((function(e){e.source!==n&&t.removeConnection(e)}))}))}function Au(e){return Ar(e,"bpmn:SequenceFlow")}wu.$inject=["bpmnReplace","injector"],n(wu,Ka),wu.prototype.replaceShape=function(e){var t,n,i=(n=kr(e).eventDefinitions)&&n[0];return t=i?{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:i.$type}:{type:"bpmn:IntermediateThrowEvent"},this._bpmnReplace.replaceElement(e,t,{layoutConnection:!1})},n(Cu,Ka),Cu.$inject=["eventBus","bpmnRules","modeling"],Pu.$inject=["eventBus","modeling"],n(Pu,Ka);function ku(e,t,n,i,r,o){function a(){return kr(t.getRootElement()).$parent}function s(e){var t=kr(e).categoryValueRef;if(t){var n=t.$parent;t&&(mt(n.categoryValue,t),n&&!n.categoryValue.length&&function(e){mt(a().get("rootElements"),e)}(n))}}r.invoke(Ka,this),this.executed("shape.delete",(function(e){var t,i=e.context.shape;if(Ar(i,"bpmn:Group")){var r=kr(i).categoryValueRef,o=n.filter((function(e){return Ar(e,"bpmn:Group")}));t=r,o.some((function(e){var n=kr(e);return n.categoryValueRef&&n.categoryValueRef===t}))||s(i)}})),this.reverted("shape.delete",(function(e){var t=e.context.shape;if(Ar(t,"bpmn:Group")){var n=kr(t).categoryValueRef,i=a(),r=n?n.$parent:null;vt(r.get("categoryValue"),n),vt(i.get("rootElements"),r)}})),this.execute("shape.create",(function(t){var n=kr(t.context.shape);if(Ar(n,"bpmn:Group")&&!n.categoryValueRef){var i=Vl(a(),e);n.categoryValueRef=i}})),this.revert("shape.create",(function(e){var t=e.context.shape;Ar(t,"bpmn:Group")&&(s(t),delete kr(t).categoryValueRef)})),i.on("moddleCopy.canCopyProperty",2e3,(function(t){var n,i=t.property;if(Ar(i,"bpmn:CategoryValue"))return n=Vl(a(),e),o.copyElement(i,n)}))}function Mu(e,t,n,i){var r,o,a,s;return 0==(r=(i.y-n.y)*(t.x-e.x)-(i.x-n.x)*(t.y-e.y))?null:(o=e.y-n.y,a=e.x-n.x,s=((i.x-n.x)*o-(i.y-n.y)*a)/r,{x:Math.round(e.x+s*(t.x-e.x)),y:Math.round(e.y+s*(t.y-e.y))})}function Du(e){function t(e,t,n){var i,r={x:n.x,y:n.y-50},o={x:n.x-50,y:n.y},a=Mu(e,t,n,r),s=Mu(e,t,n,o);i=a&&s?Bu(a,n)>Bu(s,n)?s:a:a||s,e.original=i}e.on("bpmnElement.added",(function(e){var n,i,r=e.element;r.waypoints&&(t((i=(n=r).waypoints)[0],i[1],cn(n.source)),t(i[i.length-1],i[i.length-2],cn(n.target)))}))}function Bu(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Nu(e){Ka.call(this,e);var t=["bpmn:Participant","bpmn:Lane"];this.executed(["shape.move","shape.create","shape.resize"],(function(e){var n=kr(e.context.shape);Ha(n,t)&&!n.di.get("isHorizontal")&&n.di.set("isHorizontal",!0)}))}function Ou(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}function ju(e){return Math.atan((e[1].y-e[0].y)/(e[1].x-e[0].x))}function Lu(e,t){var n=t[0],i=t[1],r={x:i.x-n.x,y:i.y-n.y},o=function(e,t,n){var i=[{n:e[0]-n[0],lambda:t[0]},{n:e[1]-n[1],lambda:t[1]}];return-(i[0].n*t[0]+i[1].n*t[1])/(i[0].lambda*t[0]+i[1].lambda*t[1])}([n.x,n.y],[r.x,r.y],[e.x,e.y]);return{x:n.x+o*r.x,y:n.y+o*r.y}}function Iu(e,t){var n=Lu(e,t);return Ou({x:n.x-e.x,y:n.y-e.y})}function zu(e,t){return Ou({x:e.x-t.x,y:e.y-t.y})}ku.$inject=["bpmnFactory","canvas","elementRegistry","eventBus","injector","moddleCopy"],n(ku,Ka),Du.$inject=["eventBus"],Nu.$inject=["eventBus"],n(Nu,Ka);var Fu=Math.sqrt,$u=Math.min,Hu=Math.max,Gu=Math.abs;function Wu(e){return Math.pow(e,2)}function Vu(e,t){return Fu(Wu(e.x-t.x)+Wu(e.y-t.y))}function Uu(e,t,n,i){var r=t.x-e.x,o=t.y-e.y,a=n.x-e.x,s=n.y-e.y,c=r*r+o*o,p=(r*a+o*s)/c,l=p*p-(a*a+s*s-i*i)/c;if(l<0&&l>-1e-6&&(l=0),l<0)return[];var u=Fu(l),h=-p+u,d=-p-u,f={x:e.x-r*h,y:e.y-o*h};return 0===l?[f]:[f,{x:e.x-r*d,y:e.y-o*d}].filter((function(n){return function(e,t,n){return qu(e.x,t.x,n.x)&&qu(e.y,t.y,n.y)}(n,e,t)}))}function qu(e,t,n){return e>=$u(t,n)-Ku&&e<=Hu(t,n)+Ku}var Ku=.1;function Yu(e,t){return Gu(e.x-t.x)<=Ku&&Gu(e.y-t.y)<=Ku}function Xu(e,t,n,i){var r=0,o=0,a=function(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}(e),s=function(e,t){var n,i,r,o,a,s,c,p,l,u,h,d,f=0;for(f=0;f<t.length-1;f++){if(Yu(n=t[f],i=t[f+1])?s=[n]:(r=Vu(e,n),o=Vu(e,i),s=Uu(n,i,e,$u(r,o))),s.length<1)throw new Error("expected between [1, 2] circle -> line intersections");1===s.length&&(c={type:"bendpoint",position:s[0],segmentIndex:f,bendpointIndex:Yu(n,s[0])?f:f+1}),2===s.length&&(h=s[0],d=s[1],c={type:"segment",position:a={x:(h.x+d.x)/2,y:(h.y+d.y)/2},segmentIndex:f,relativeLocation:Vu(n,a)/Vu(n,i)}),p=Vu(c.position,e),(!u||l>p)&&(u=c,l=p)}return u}(a,n),c=s.segmentIndex,p=function(e,t,n,i){var r=n.segmentIndex,o=t.length-e.length;if(i.segmentMove){var a=i.segmentMove.segmentStartIndex,s=i.segmentMove.newSegmentStartIndex;return r===a?s:r>=s?r+o<s?s:r+o:r}if(i.bendpointMove){var c,p=i.bendpointMove.insert,l=i.bendpointMove.bendpointIndex;return 0===o?r:(r>=l&&(c=p?r+1:r-1),r<l&&(c=r,p&&"bendpoint"!==n.type&&l-1===r&&Zu(t,l)<n.relativeLocation&&c++),c)}return 0===o?r:i.connectionStart?0===r?0:null:i.connectionEnd&&r===e.length-2?t.length-2:null}(n,t,s,i);if(null===p)return{x:r,y:o};if(p<0||p>t.length-2)return{x:r,y:o};var l,u,h=Qu(n,c),d=Qu(t,p),f=s.position,m=function(e,t){var n=zu(e[0],e[1]),i=zu(e[0],t);return 0===n?0:i/n}(h,f),v=(l=d,u=ju(h),ju(l)-u);if("bendpoint"===s.type){var y=t.length-n.length,g=s.bendpointIndex,b=n[g];if(-1!==t.indexOf(b))return{x:r,y:o};if(0===y){var x=t[g];return{x:x.x-s.position.x,y:x.y-s.position.y}}y<0&&0!==g&&g<n.length-1&&(m=Zu(n,g))}var _,E,w=(d[1].x-d[0].x)*m+d[0].x,S=(d[1].y-d[0].y)*m+d[0].y,C=(_={x:a.x-f.x,y:a.y-f.y},(E=v)?{x:Math.cos(E)*_.x-Math.sin(E)*_.y,y:Math.sin(E)*_.x+Math.cos(E)*_.y}:_);return on({x:r=w+C.x-a.x,y:o=S+C.y-a.y})}function Zu(e,t){var n=zu(e[t-1],e[t]);return n/(n+zu(e[t],e[t+1]))}function Qu(e,t){return[e[t],e[t+1]]}function Ju(e,t,n){var i=ca(t),r=ca(n),o=pa(e,i),a=o.x*(n.width/t.width),s=o.y*(n.height/t.height);return on({x:r.x+a,y:r.y+s})}function eh(e,t,n){var i=ca(e),r=ca(t),o=ca(n),a=pa(e,i),s=pa(i,r),c=function(e,t,n){var i=an(t),r=an(n);if(function(e,t){return function(e,t){return e.right!==t.right&&e.left!==t.left}(e,t)||function(e,t){return e.top!==t.top&&e.bottom!==t.bottom}(e,t)}(i,r))return null;var o,a,s=pn(t,e);if("top"===s)o={x:0,y:r.bottom-i.bottom};else if("bottom"===s)o={x:0,y:r.top-i.top};else if("right"===s)o={x:r.left-i.left,y:0};else{if("left"!==s)return null;o={x:r.right-i.right,y:0}}if(a={x:e.x+o.x,y:e.y+o.y},pn(n,a)!==s)return null;return o}(i,t,n);if(c)return c;var p=s.x*(n.width/t.width),l=s.y*(n.height/t.height),u=o.x+p,h=o.y+l;return on({x:u+a.x-e.x,y:h+a.y-e.y})}var th={width:90,height:20},nh="name",ih="text";function rh(e,t,n,i){Ka.call(this,e),this.postExecute("element.updateProperties",(function(e){var n=e.context,r=n.element,o=n.properties;if(nh in o&&t.updateLabel(r,o.name),ih in o&&Ar(r,"bpmn:TextAnnotation")){var a=i.getTextAnnotationBounds({x:r.x,y:r.y,width:r.width,height:r.height},o.text||"");t.updateLabel(r,o.text,a)}})),this.postExecute(["shape.create","connection.create"],(function(e){var n=e.context;if(!1!==(n.hints||{}).createElementsBehavior){var r=n.shape||n.connection,o=r.businessObject;if(!so(r)&&io(r)&&Or(r)){var a=ao(r),s=i.getExternalLabelBounds(th,Or(r));t.createLabel(r,a,{id:o.id+"_label",businessObject:o,width:s.width,height:s.height})}}})),this.postExecute("shape.delete",(function(e){var n=e.context,i=n.labelTarget,r=n.hints||{};i&&!1!==r.unsetLabel&&t.updateLabel(i,null,null,{removeShape:!1})})),this.postExecute(["label.create"],(function(e){var t,i=e.context.shape;i.labelTarget&&Ar(i.labelTarget||i,"bpmn:BaseElement")&&((t=i.businessObject.di).label||(t.label=n.create("bpmndi:BPMNLabel",{bounds:n.create("dc:Bounds")})),F(t.label.bounds,{x:i.x,y:i.y,width:i.width,height:i.height}))})),this.postExecute(["connection.layout","connection.updateWaypoints"],(function(e){var n=e.context;if(!1!==(n.hints||{}).labelBehavior){var i,r=n.connection.label;r&&r.parent&&(i=function(e){var t=e.context,n=t.connection,i=n.label,r=F({},t.hints),o=t.newWaypoints||n.waypoints,a=t.oldWaypoints;return void 0===r.startChanged&&(r.startChanged=!!r.connectionStart),void 0===r.endChanged&&(r.endChanged=!!r.connectionEnd),Xu(i,o,a,r)}(e),t.moveShape(r,i))}})),this.postExecute(["shape.replace"],(function(e){var t=e.context,n=t.newShape,i=t.oldShape,r=kr(n);r&&io(r)&&i.label&&n.label&&(n.label.x=i.label.x,n.label.y=i.label.y)})),this.postExecute("shape.resize",(function(e){var n,i=e.context,r=i.shape,o=i.newBounds,a=i.oldBounds;if(ro(r)){var s=r.label,c=oh(function(e,t){if(!t.length)return;var n=function(e,t){return M(t.map((function(t){return{line:t,distance:Iu(e,t)}})),"distance")[0].line}(e,t);return Lu(e,n)}(cn(s),[[{x:(n=a).x,y:n.y},{x:n.x+(n.width||0),y:n.y}],[{x:n.x+(n.width||0),y:n.y},{x:n.x+(n.width||0),y:n.y+(n.height||0)}],[{x:n.x,y:n.y+(n.height||0)},{x:n.x+(n.width||0),y:n.y+(n.height||0)}],[{x:n.x,y:n.y},{x:n.x,y:n.y+(n.height||0)}]]),a,o);t.moveShape(s,c)}}))}function oh(e,t,n){return on(pa(Ju(e,t,n),e))}function ah(e,t,n){var i=uh(e),r=hh(i,t),o=i[0];return r.length?r[r.length-1]:Ju(o.original||o,n,t)}function sh(e,t,n){var i=uh(e),r=hh(i,t),o=i[i.length-1];return r.length?r[0]:Ju(o.original||o,n,t)}function ch(e,t,n){var i=uh(e),r=lh(t,n),o=i[0];return Ju(o.original||o,r,t)}function ph(e,t,n){var i=uh(e),r=lh(t,n),o=i[i.length-1];return Ju(o.original||o,r,t)}function lh(e,t){return{x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}}function uh(e){var t=e.waypoints;if(!t.length)throw new Error("connection#"+e.id+": no waypoints");return t}function hh(e,t){return g(S(e,dh),(function(e){return function(e,t){return"intersect"===pn(t,e,1)}(e,t)}))}function dh(e){return e.original||e}function fh(e,t){Ka.call(this,e),this.postExecute("shape.replace",(function(e){var n=e.oldShape,i=e.newShape;if(function(e,t){return Ar(e,"bpmn:Participant")&&Mr(e)&&Ar(t,"bpmn:Participant")&&!Mr(t)}(n,i)){var r,o,a,s,c=(o=ct([r=n],!1),a=[],s=[],o.forEach((function(e){e!==r&&(e.incoming.forEach((function(e){Ar(e,"bpmn:MessageFlow")&&a.push(e)})),e.outgoing.forEach((function(e){Ar(e,"bpmn:MessageFlow")&&s.push(e)})))}),[]),{incoming:a,outgoing:s});c.incoming.forEach((function(e){var r=sh(e,i,n);t.reconnectEnd(e,i,r)})),c.outgoing.forEach((function(e){var r=ah(e,i,n);t.reconnectStart(e,i,r)}))}}),!0)}n(rh,Ka),rh.$inject=["eventBus","modeling","bpmnFactory","textRenderer"],fh.$inject=["eventBus","modeling"],n(fh,Ka);function mh(e,t,n){e.on(["shape.move.rejected","create.rejected"],(function(e){var i,r,o,a=e.context,s=a.shape;Ar(a.target,"bpmn:Collaboration")&&Ar(s,"bpmn:FlowNode")&&(i=e,r=n("flow elements must be children of pools/participants"),t.add({position:{x:i.x+5,y:i.y+5},type:"error",timeout:o||2e3,html:"<div>"+r+"</div>"}))}))}function vh(e,t,n,i){Ka.call(this,e);var r=i.get("dragging",!1);function o(e){var i,r,o=e.source,a=e.target;e.parent&&(Ar(e,"bpmn:SequenceFlow")&&(n.canConnectSequenceFlow(o,a)||(r=!0),n.canConnectMessageFlow(o,a)&&(i="bpmn:MessageFlow")),Ar(e,"bpmn:MessageFlow")&&(n.canConnectMessageFlow(o,a)||(r=!0),n.canConnectSequenceFlow(o,a)&&(i="bpmn:SequenceFlow")),Ar(e,"bpmn:Association")&&!n.canConnectAssociation(o,a)&&(r=!0),r&&t.removeConnection(e),i&&t.connect(o,a,{type:i,waypoints:e.waypoints.slice()}))}this.postExecuted("elements.move",(function(e){b(e.closure.allConnections,o)}),!0),this.preExecute("connection.reconnect",(function(e){var i,o,a=e.context,s=a.connection,c=a.newSource||s.source,p=a.newTarget||s.target;(i=n.canConnect(c,p))&&i.type!==s.type&&(o=t.connect(c,p,{type:i.type,waypoints:s.waypoints.slice()}),t.removeConnection(s),a.connection=o,r&&function(e,t){var n,i=r.context(),o=i&&i.payload.previousSelection;if(!o||!o.length)return;if(-1===(n=o.indexOf(e)))return;o.splice(n,1,t)}(s,o))})),this.postExecuted("element.updateProperties",(function(e){var n,i=e.context,r=i.properties,o=i.element,a=o.businessObject;r.default&&(n=y(o.outgoing,D({id:o.businessObject.default.id})))&&t.updateProperties(n,{conditionExpression:void 0}),r.conditionExpression&&a.sourceRef.default===a&&t.updateProperties(o.source,{default:void 0})}))}function yh(e,t){Ka.call(this,e),this.preExecute("shape.delete",(function(e){var t=e.shape,n=t.parent;Ar(t,"bpmn:Participant")&&(e.collaborationRoot=n)}),!0),this.postExecute("shape.delete",(function(e){var n=e.collaborationRoot;n&&!n.businessObject.participants.length&&t.makeProcess()}),!0)}function gh(e,t,n,i,r,o){i.invoke(Ka,this),this._bpmnReplace=e,this._elementRegistry=n,this._selection=o,this.postExecuted(["elements.create"],500,(function(e){var n=e.context,i=n.parent,r=n.elements,o=t.canReplace(r,i);o&&this.replaceElements(r,o.replacements)}),this),this.postExecuted(["elements.move"],500,(function(e){var n=e.context,i=n.newParent,r=n.newHost,o=[];b(n.closure.topLevel,(function(e){o=Dr(e)?o.concat(e.children):o.concat(e)})),1===o.length&&r&&(i=r);var a=t.canReplace(o,i);a&&this.replaceElements(o,a.replacements,r)}),this),this.postExecute(["shape.replace"],1500,(function(e){var n,i=e.context,r=i.oldShape,o=i.newShape,a=r.attachers;a&&a.length&&(n=t.canReplace(a,o),this.replaceElements(a,n.replacements))}),this),this.postExecuted(["shape.replace"],1500,(function(e){var t=e.context,n=t.oldShape,i=t.newShape;r.unclaimId(n.businessObject.id,n.businessObject),r.updateProperties(i,{id:n.id})}))}mh.$inject=["eventBus","tooltips","translate"],n(vh,Ka),vh.$inject=["eventBus","modeling","bpmnRules","injector"],yh.$inject=["eventBus","modeling"],n(yh,Ka),n(gh,Ka),gh.prototype.replaceElements=function(e,t){var n=this._elementRegistry,i=this._bpmnReplace,r=this._selection;b(t,(function(t){var r={type:t.newElementType},o=n.get(t.oldElementId),a=e.indexOf(o);e[a]=i.replaceElement(o,r,{select:!1})})),t&&r.select(e)},gh.$inject=["bpmnReplace","bpmnRules","elementRegistry","injector","modeling","selection"];var bh=300,xh=60,_h={width:300,height:150},Eh={width:140,height:120},wh={width:50,height:30};function Sh(e){e.on("resize.start",1500,(function(e){var t=e.context,n=t.shape,i=t.direction,r=t.balanced;(Ar(n,"bpmn:Lane")||Ar(n,"bpmn:Participant"))&&(t.resizeConstraints=function(e,t,n){var i=Wp(e),r=!0,o=!0,a=Hp(i,[i]),s=an(e),c={},p={};/e/.test(t)?p.right=s.left+bh:/w/.test(t)&&(p.left=s.right-bh);return a.forEach((function(e){var i=an(e);/n/.test(t)&&(i.top<s.top-10&&(r=!1),n&&Ch(s.top-i.bottom)<10&&kh(c,"top",i.top+xh),Ch(s.top-i.top)<5&&Ah(p,"top",i.bottom-xh)),/s/.test(t)&&(i.bottom>s.bottom+10&&(o=!1),n&&Ch(s.bottom-i.top)<10&&Ah(c,"bottom",i.bottom-xh),Ch(s.bottom-i.bottom)<5&&kh(p,"bottom",i.top+xh))})),i.children.filter((function(e){return!e.hidden&&!e.waypoints&&(Ar(e,"bpmn:FlowElement")||Ar(e,"bpmn:Artifact"))})).forEach((function(e){var n=an(e);r&&/n/.test(t)&&Ah(p,"top",n.top-20),/e/.test(t)&&kh(p,"right",n.right+20),o&&/s/.test(t)&&kh(p,"bottom",n.bottom+20),/w/.test(t)&&Ah(p,"left",n.left-50)})),{min:p,max:c}}(n,i,r)),Ar(n,"bpmn:Participant")&&(t.minDimensions=_h),Ar(n,"bpmn:SubProcess")&&Mr(n)&&(t.minDimensions=Eh),Ar(n,"bpmn:TextAnnotation")&&(t.minDimensions=wh)}))}Sh.$inject=["eventBus"];var Ch=Math.abs,Th=Math.min,Rh=Math.max;function Ph(e,t,n,i){var r=e[t];e[t]=void 0===r?n:i(n,r)}function Ah(e,t,n){return Ph(e,t,n,Th)}function kh(e,t,n){return Ph(e,t,n,Rh)}function Mh(e,t){e.on("resize.start",1501,(function(e){var t=e.context,n=t.shape;(Ar(n,"bpmn:Lane")||Ar(n,"bpmn:Participant"))&&(t.balanced=!xo(e))})),e.on("resize.end",1001,(function(e){var n=e.context,i=n.shape,r=n.canExecute,o=n.newBounds;if(Ar(i,"bpmn:Lane")||Ar(i,"bpmn:Participant"))return r&&(o=rn(o),t.resizeLane(i,o,n.balanced)),!1}))}function Dh(e,t,n){Ka.call(this,e),this.preExecute("shape.delete",(function(e){var i=e.context.shape;if(1===i.incoming.length&&1===i.outgoing.length){var r=i.incoming[0],o=i.outgoing[0];if(Ar(r,"bpmn:SequenceFlow")&&Ar(o,"bpmn:SequenceFlow")&&t.canConnect(r.source,o.target,r)){var a=function(e,t){var n=Mu(Bh(e[e.length-2]),Bh(e[e.length-1]),Bh(t[1]),Bh(t[0]));return n?[].concat(e.slice(0,e.length-1),[n],t.slice(1)):[Bh(e[0]),Bh(t[t.length-1])]}(r.waypoints,o.waypoints);n.reconnectEnd(r,o.target,a)}}}))}function Bh(e){return e.original||e}Mh.$inject=["eventBus","modeling"],n(Dh,Ka),Dh.$inject=["eventBus","bpmnRules","modeling"];var Nh=Math.max;function Oh(e){e.on("spaceTool.getMinDimensions",(function(e){var t=e.shapes,n=e.axis,i=e.start,r={};return b(t,(function(e){var t=e.id;Ar(e,"bpmn:Participant")&&(!function(e){return"x"===e}(n)?r[t]={width:_h.width,height:jh(e,i)}:r[t]=_h),Ar(e,"bpmn:SubProcess")&&Mr(e)&&(r[t]=Eh),Ar(e,"bpmn:TextAnnotation")&&(r[t]=wh)})),r}))}function jh(e,t){var n;return Gp(e).length?(n=function(e,t){var n,i=Gp(e);return n=Lh(i,t),e.height-n.height+xh}(e,t),Nh(_h.height,n)):_h.height}function Lh(e,t){var n,i,r;for(n=0;n<e.length;n++)if(t>=(i=e[n]).y&&t<=i.y+i.height)return(r=Gp(i)).length?Lh(r,t):i}function Ih(e,t){e.invoke(Ka,this),this.postExecuted("shape.replace",(function(e){var n=e.context.oldShape,i=e.context.newShape;if(Ar(i,"bpmn:SubProcess")&&Ar(n,"bpmn:Task")&&Mr(i)){var r,o={x:(r=i).x+r.width/6,y:r.y+r.height/2};t.createShape({type:"bpmn:StartEvent"},o,i)}}))}Oh.$inject=["eventBus"],Ih.$inject=["injector","modeling"],n(Ih,Ka);function zh(e,t,n,i){Ka.call(this,e),this.executed(["shape.toggleCollapse"],500,(function(e){var t,n=e.context.shape;Ar(n,"bpmn:SubProcess")&&(n.collapsed?kr(n).di.isExpanded=!1:((t=n.children).length&&t.forEach((function(e){"label"!==e.type||e.businessObject.name||(e.hidden=!0)})),kr(n).di.isExpanded=!0))})),this.reverted(["shape.toggleCollapse"],500,(function(e){var t=e.context.shape;t.collapsed?kr(t).di.isExpanded=!1:kr(t).di.isExpanded=!0})),this.postExecuted(["shape.toggleCollapse"],500,(function(e){var i,r=e.context.shape,o=t._getDefaultSize(r);i=r.collapsed?function(e,t){return{x:e.x+(e.width-t.width)/2,y:e.y+(e.height-t.height)/2,width:t.width,height:t.height}}(r,o):function(e,t){var n,i,r=e.children,o=t;return(n=Ip((i=r,i.filter((function(e){return!e.hidden}))).concat([e])))?(o.width=Math.max(n.width,o.width),o.height=Math.max(n.height,o.height),o.x=n.x+(n.width-o.width)/2,o.y=n.y+(n.height-o.height)/2):(o.x=e.x+(e.width-o.width)/2,o.y=e.y+(e.height-o.height)/2),o}(r,o),n.resizeShape(r,i,null,{autoResize:!r.collapsed&&"nwse"})}))}function Fh(e,t,n,i){t.invoke(Ka,this),this.preExecute("shape.delete",(function(e){var t=e.context.shape,r=t.businessObject;so(t)||(Ar(t,"bpmn:Participant")&&Mr(t)&&n.ids.unclaim(r.processRef.id),i.unclaimId(r.id,r))})),this.preExecute("connection.delete",(function(e){var t=e.context.connection.businessObject;i.unclaimId(t.id,t)})),this.preExecute("canvas.updateRoot",(function(){var t=e.getRootElement(),i=t.businessObject;Ar(t,"bpmn:Collaboration")&&n.ids.unclaim(i.id)}))}n(zh,Ka),zh.$inject=["eventBus","elementFactory","modeling"],n(Fh,Ka),Fh.$inject=["canvas","injector","moddle","modeling"];function $h(e,t,n){var i;function r(){if(!i)throw new Error(n("out of bounds release"));return i}Ka.call(this,e);var o=["spaceTool","lane.add","lane.resize","lane.split","elements.create","elements.delete","elements.move","shape.create","shape.delete","shape.move","shape.resize"];this.preExecute(o,5e3,(function(e){(i=i||new Hh).enter()})),this.postExecuted(o,500,(function(e){!function(){if(!i)throw new Error(n("out of bounds release"));var e=i.leave();e&&(t.updateLaneRefs(i.flowNodes,i.lanes),i=null)}()})),this.preExecute(["shape.create","shape.move","shape.delete","shape.resize"],(function(e){var t=e.context.shape,n=r();t.labelTarget||(Ar(t,"bpmn:Lane")&&n.addLane(t),Ar(t,"bpmn:FlowNode")&&n.addFlowNode(t))}))}function Hh(){this.flowNodes=[],this.lanes=[],this.counter=0,this.addLane=function(e){this.lanes.push(e)},this.addFlowNode=function(e){this.flowNodes.push(e)},this.enter=function(){this.counter++},this.leave=function(){return this.counter--,!this.counter}}function Gh(e,t){Ka.call(this,e),this.preExecute("connection.delete",(function(e){var n=e.context.connection,i=n.source;(function(e,t){if(!Ar(e,"bpmn:SequenceFlow"))return!1;var n=kr(t),i=kr(e);return n.get("default")===i})(n,i)&&t.updateProperties(i,{default:null})}))}$h.$inject=["eventBus","modeling","translate"],n($h,Ka),n(Gh,Ka),Gh.$inject=["eventBus","modeling"];var Wh={__init__:["adaptiveLabelPositioningBehavior","appendBehavior","associationBehavior","attachEventBehavior","boundaryEventBehavior","rootElementReferenceBehavior","createBehavior","fixHoverBehavior","createDataObjectBehavior","createParticipantBehavior","dataStoreBehavior","dataInputAssociationBehavior","deleteLaneBehavior","detachEventBehavior","dropOnFlowBehavior","eventBasedGatewayBehavior","groupBehavior","importDockingFix","isHorizontalFix","labelBehavior","messageFlowBehavior","modelingFeedback","removeElementBehavior","removeParticipantBehavior","replaceConnectionBehavior","replaceElementBehaviour","resizeBehavior","resizeLaneBehavior","toggleElementCollapseBehaviour","spaceToolBehavior","subProcessStartEventBehavior","unclaimIdBehavior","unsetDefaultFlowBehavior","updateFlowNodeRefsBehavior"],adaptiveLabelPositioningBehavior:["type",tu],appendBehavior:["type",iu],associationBehavior:["type",ru],attachEventBehavior:["type",ou],boundaryEventBehavior:["type",su],rootElementReferenceBehavior:["type",cu],createBehavior:["type",pu],fixHoverBehavior:["type",uu],createDataObjectBehavior:["type",hu],createParticipantBehavior:["type",vu],dataInputAssociationBehavior:["type",gu],dataStoreBehavior:["type",_u],deleteLaneBehavior:["type",Eu],detachEventBehavior:["type",wu],dropOnFlowBehavior:["type",Cu],eventBasedGatewayBehavior:["type",Pu],groupBehavior:["type",ku],importDockingFix:["type",Du],isHorizontalFix:["type",Nu],labelBehavior:["type",rh],messageFlowBehavior:["type",fh],modelingFeedback:["type",mh],replaceConnectionBehavior:["type",vh],removeParticipantBehavior:["type",yh],replaceElementBehaviour:["type",gh],resizeBehavior:["type",Sh],resizeLaneBehavior:["type",Mh],removeElementBehavior:["type",Dh],toggleElementCollapseBehaviour:["type",zh],spaceToolBehavior:["type",Oh],subProcessStartEventBehavior:["type",Ih],unclaimIdBehavior:["type",Fh],updateFlowNodeRefsBehavior:["type",$h],unsetDefaultFlowBehavior:["type",Gh]};function Vh(e,t){var n=pn(e,t,-15);return"intersect"!==n?n:null}function Uh(e){Za.call(this,e)}function qh(e){return!e||so(e)}function Kh(e){do{if(Ar(e,"bpmn:Process"))return kr(e);if(Ar(e,"bpmn:Participant"))return kr(e).processRef||kr(e)}while(e=e.parent)}function Yh(e){return Ar(e,"bpmn:TextAnnotation")}function Xh(e){return Ar(e,"bpmn:Group")&&!e.labelTarget}function Zh(e){return Ar(e,"bpmn:BoundaryEvent")&&ed(e,"bpmn:CompensateEventDefinition")}function Qh(e){return kr(e).isForCompensation}function Jh(e){for(var t=e;t=t.parent;){if(Ar(t,"bpmn:FlowElementsContainer"))return kr(t);if(Ar(t,"bpmn:Participant"))return kr(t).processRef}return null}function ed(e,t){return!!y(kr(e).eventDefinitions||[],(function(e){return Ar(e,t)}))}function td(e,t){return(kr(e).eventDefinitions||[]).every((function(e){return Ar(e,t)}))}function nd(e){return Ar(e,"bpmn:ReceiveTask")||Ar(e,"bpmn:IntermediateCatchEvent")&&(ed(e,"bpmn:MessageEventDefinition")||ed(e,"bpmn:TimerEventDefinition")||ed(e,"bpmn:ConditionalEventDefinition")||ed(e,"bpmn:SignalEventDefinition"))}function id(e){return e.waypoints}function rd(e,t){return-1!==function(e){for(var t=[];e;)(e=e.parent)&&t.push(e);return t}(t).indexOf(e)}function od(e,t,n){if(qh(e)||qh(t))return null;if(!Ar(n,"bpmn:DataAssociation")){if(gd(e,t))return{type:"bpmn:MessageFlow"};if(bd(e,t))return{type:"bpmn:SequenceFlow"}}var i=xd(e,t);return i||(Zh(e)&&Qh(t)?{type:"bpmn:Association",associationDirection:"One"}:!!yd(e,t)&&{type:"bpmn:Association"})}function ad(e,t,n){return!(!so(e)&&!Xh(e))||!(Ar(t,"bpmn:Participant")&&!Mr(t))&&(Ar(e,"bpmn:Participant")?Ar(t,"bpmn:Process")||Ar(t,"bpmn:Collaboration"):Ha(e,["bpmn:DataInput","bpmn:DataOutput"])&&e.parent?t===e.parent:Ar(e,"bpmn:Lane")?Ar(t,"bpmn:Participant")||Ar(t,"bpmn:Lane"):!(Ar(e,"bpmn:BoundaryEvent")&&(i=e,!kr(i).cancelActivity||!pd(i)&&!ld(i)))&&(Ar(e,"bpmn:FlowElement")&&!Ar(e,"bpmn:DataStoreReference")?Ar(t,"bpmn:FlowElementsContainer")?Mr(t):Ha(t,["bpmn:Participant","bpmn:Lane"]):Ar(e,"bpmn:DataStoreReference")&&Ar(t,"bpmn:Collaboration")?w(kr(t).get("participants"),(function(e){return!!e.get("processRef")})):Ha(e,["bpmn:Artifact","bpmn:DataAssociation","bpmn:DataStoreReference"])?Ha(t,["bpmn:Collaboration","bpmn:Lane","bpmn:Participant","bpmn:Process","bpmn:SubProcess"]):!!Ar(e,"bpmn:MessageFlow")&&(Ar(t,"bpmn:Collaboration")||e.source.parent==t||e.target.parent==t)));var i}function sd(e){return Ar(e,"bpmn:Lane")}function cd(e){return!!function(e){return!so(e)&&Ar(e,"bpmn:BoundaryEvent")}(e)||(!(!Ar(e,"bpmn:IntermediateThrowEvent")||!pd(e))||Ar(e,"bpmn:IntermediateCatchEvent")&&ld(e))}function pd(e){var t=kr(e);return t&&!(t.eventDefinitions&&t.eventDefinitions.length)}function ld(e){return ud(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])}function ud(e,t){return t.some((function(t){return ed(e,t)}))}function hd(e,t,n,i){if(Array.isArray(e)||(e=[e]),1!==e.length)return!1;var r=e[0];return!so(r)&&(!!cd(r)&&(!Dr(t)&&(!(!Ar(t,"bpmn:Activity")||Qh(t))&&(!(i&&!Vh(i,t))&&(!function(e){return Ar(e,"bpmn:ReceiveTask")&&y(e.incoming,(function(e){return Ar(e.source,"bpmn:EventBasedGateway")}))}(t)&&"attach")))))}function dd(e,t,n){if(!t)return!1;var i={replacements:[]};return b(e,(function(e){Dr(t)||Ar(e,"bpmn:StartEvent")&&"label"!==e.type&&ad(e,t)&&(function(e){return e&&!1!==kr(e).isInterrupting}(e)||i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),(function(e){return Br(e,"bpmn:ErrorEventDefinition")}(e)||function(e){return Br(e,"bpmn:EscalationEventDefinition")}(e)||function(e){return Br(e,"bpmn:CompensateEventDefinition")}(e))&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),ud(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])&&Ar(t,"bpmn:SubProcess")&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"})),Ar(t,"bpmn:Transaction")||ed(e,"bpmn:CancelEventDefinition")&&"label"!==e.type&&(Ar(e,"bpmn:EndEvent")&&ad(e,t)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:EndEvent"}),Ar(e,"bpmn:BoundaryEvent")&&hd(e,t,0,n)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:BoundaryEvent"}))})),!!i.replacements.length&&i}function fd(e,t){return!w(e,sd)&&(!t||e.every((function(e){return ad(e,t)})))}function md(e,t,n,i){return!!t&&(!(!so(e)&&!Xh(e))||n!==t&&((!n||!rd(n,t))&&(ad(e,t)||_d(e,t))))}function vd(e,t){return Ar(e,"bpmn:SubProcess")?Mr(e)&&(!t||t.width>=100&&t.height>=80):Ar(e,"bpmn:Lane")?!t||t.width>=130&&t.height>=60:Ar(e,"bpmn:Participant")?!t||t.width>=250&&t.height>=50:!!Yh(e)||!!Xh(e)}function yd(e,t){return!id(e)&&!id(t)&&(!(!Zh(e)||!Qh(t))||!rd(t,e)&&!rd(e,t)&&(!!function(e,t){var n=Yh(e),i=Yh(t);return(n||i)&&n!==i}(e,t)||!!xd(e,t)))}function gd(e,t){return!(Sd(e)&&!Sd(t))&&(Ar(i=e,"bpmn:InteractionNode")&&!Ar(i,"bpmn:BoundaryEvent")&&(!Ar(i,"bpmn:Event")||Ar(i,"bpmn:ThrowEvent")&&td(i,"bpmn:MessageEventDefinition"))&&function(e){return Ar(e,"bpmn:InteractionNode")&&!Qh(e)&&(!Ar(e,"bpmn:Event")||Ar(e,"bpmn:CatchEvent")&&td(e,"bpmn:MessageEventDefinition"))&&!(Ar(e,"bpmn:BoundaryEvent")&&!ed(e,"bpmn:MessageEventDefinition"))}(t)&&(n=t,!(Kh(e)===Kh(n))));var n,i}function bd(e,t){return!(nd(t)&&t.incoming.length>0&&(n=t.incoming,(n=n||[]).some(wd))&&!Ar(e,"bpmn:EventBasedGateway"))&&(Ar(r=e,"bpmn:FlowNode")&&!Ar(r,"bpmn:EndEvent")&&!Dr(r)&&!(Ar(r,"bpmn:IntermediateThrowEvent")&&ed(r,"bpmn:LinkEventDefinition"))&&!Zh(r)&&!Qh(r)&&function(e){return Ar(e,"bpmn:FlowNode")&&!Ar(e,"bpmn:StartEvent")&&!Ar(e,"bpmn:BoundaryEvent")&&!Dr(e)&&!(Ar(e,"bpmn:IntermediateCatchEvent")&&ed(e,"bpmn:LinkEventDefinition"))&&!Qh(e)}(t)&&(i=t,Jh(e)===Jh(i))&&!(Ar(e,"bpmn:EventBasedGateway")&&!nd(t)));var n,i,r}function xd(e,t){return Ha(e,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&Ha(t,["bpmn:Activity","bpmn:ThrowEvent"])?{type:"bpmn:DataInputAssociation"}:!(!Ha(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])||!Ha(e,["bpmn:Activity","bpmn:CatchEvent"]))&&{type:"bpmn:DataOutputAssociation"}}function _d(e,t,n){if(!t)return!1;if(Array.isArray(e)){if(1!==e.length)return!1;e=e[0]}return t.source!==e&&t.target!==e&&(Ha(t,["bpmn:SequenceFlow","bpmn:MessageFlow"])&&!so(t)&&Ar(e,"bpmn:FlowNode")&&!Ar(e,"bpmn:BoundaryEvent")&&ad(e,t.parent))}function Ed(e,t){return!!so(t)||!(Ar(t,"bpmn:Lane")&&!function(e,t){return e&&t&&-1!==e.indexOf(t)}(e,t.parent))}function wd(e){if(e&&e.source)return Ar(e.source,"bpmn:EventBasedGateway")}function Sd(e){return Ga(e,"bpmn:Process")||Ga(e,"bpmn:Collaboration")}n(Uh,Za),Uh.$inject=["eventBus"],Uh.prototype.init=function(){this.addRule("connection.start",(function(e){return function(e){if(qh(e))return null;return Ha(e,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference","bpmn:Group","bpmn:TextAnnotation"])}(e.source)})),this.addRule("connection.create",(function(e){var t=e.source,n=e.target,i=e.hints||{},r=i.targetParent;if(i.targetAttach)return!1;r&&(n.parent=r);try{return od(t,n)}finally{r&&(n.parent=null)}})),this.addRule("connection.reconnect",(function(e){var t=e.connection;return od(e.source,e.target,t)})),this.addRule("connection.updateWaypoints",(function(e){return{type:e.connection.type}})),this.addRule("shape.resize",(function(e){return vd(e.shape,e.newBounds)})),this.addRule("elements.create",(function(e){var t=e.elements,n=e.position,i=e.target;return!(id(i)&&!_d(t,i))&&E(t,(function(e){return id(e)?od(e.source,e.target,e):e.host?hd(e,e.host,null,n):md(e,i,null)}))})),this.addRule("elements.move",(function(e){var t=e.target,n=e.shapes,i=e.position;return hd(n,t,null,i)||dd(n,t,i)||fd(n,t)||_d(n,t)})),this.addRule("shape.create",(function(e){return md(e.shape,e.target,e.source,e.position)})),this.addRule("shape.attach",(function(e){return hd(e.shape,e.target,null,e.position)})),this.addRule("element.copy",(function(e){var t=e.element;return Ed(e.elements,t)}))},Uh.prototype.canConnectMessageFlow=gd,Uh.prototype.canConnectSequenceFlow=bd,Uh.prototype.canConnectDataAssociation=xd,Uh.prototype.canConnectAssociation=yd,Uh.prototype.canMove=fd,Uh.prototype.canAttach=hd,Uh.prototype.canReplace=dd,Uh.prototype.canDrop=ad,Uh.prototype.canInsert=_d,Uh.prototype.canCreate=md,Uh.prototype.canConnect=od,Uh.prototype.canResize=vd,Uh.prototype.canCopy=Ed;var Cd={__depends__:[hs],__init__:["bpmnRules"],bpmnRules:["type",Uh]};function Td(e,t){e.on("saveXML.start",2e3,(function(){var e,n,i=t.getRootElement(),r=kr(i).di;e=g(e=ct([i],!1),(function(e){return e!==i&&!e.labelTarget})),n=S(e,Lr),r.set("planeElement",n)}))}Td.$inject=["eventBus","canvas"];var Rd={__init__:["bpmnDiOrdering"],bpmnDiOrdering:["type",Td]};function Pd(e){Ka.call(this,e);var t=this;this.preExecute(["shape.create","connection.create"],(function(e){var n=e.context,i=n.shape||n.connection,r=n.parent,o=t.getOrdering(i,r);o&&(void 0!==o.parent&&(n.parent=o.parent),n.parentIndex=o.index)})),this.preExecute(["shape.move","connection.move"],(function(e){var n=e.context,i=n.shape||n.connection,r=n.newParent||i.parent,o=t.getOrdering(i,r);o&&(void 0!==o.parent&&(n.newParent=o.parent),n.newParentIndex=o.index)}))}function Ad(e,t,n){Pd.call(this,e);var i=[{type:"bpmn:SubProcess",order:{level:6}},{type:"bpmn:SequenceFlow",order:{level:3,containers:["bpmn:Participant","bpmn:FlowElementsContainer"]}},{type:"bpmn:DataAssociation",order:{level:9,containers:["bpmn:Collaboration","bpmn:Process"]}},{type:"bpmn:MessageFlow",order:{level:9,containers:["bpmn:Collaboration"]}},{type:"bpmn:Association",order:{level:6,containers:["bpmn:Participant","bpmn:FlowElementsContainer","bpmn:Collaboration"]}},{type:"bpmn:BoundaryEvent",order:{level:8}},{type:"bpmn:Group",order:{level:10,containers:["bpmn:Collaboration","bpmn:Process"]}},{type:"bpmn:FlowElement",order:{level:5}},{type:"bpmn:Participant",order:{level:-2}},{type:"bpmn:Lane",order:{level:-1}}];function r(e){var t=e.order;if(t||(e.order=t=function(e){if(e.labelTarget)return{level:10};var t=y(i,(function(t){return Ha(e,[t.type])}));return t&&t.order||{level:1}}(e)),!t)throw new Error("no order for <"+e.id+">");return t}this.getOrdering=function(e,n){if(e.labelTarget)return{parent:t.getRootElement(),index:-1};var i=r(e);i.containers&&(n=function(e,t,n){for(var i=t;i&&!Ha(i,n);)i=i.parent;if(!i)throw new Error("no parent for <"+e.id+"> in <"+(t&&t.id)+">");return i}(e,n,i.containers));var o=n.children.indexOf(e),a=function(e,t){t=N(t);var n=u(e)?-1:void 0;return b(e,(function(e,i){if(t(e,i))return n=i,!1})),n}(n.children,(function(t){return!(!e.labelTarget&&t.labelTarget)&&i.level<r(t).level}));return-1!==a&&-1!==o&&o<a&&(a-=1),{index:a,parent:n}}}Pd.prototype.getOrdering=function(e,t){return null},n(Pd,Ka),Ad.$inject=["eventBus","canvas","translate"],n(Ad,Pd);var kd={__depends__:[to],__init__:["bpmnOrderingProvider"],bpmnOrderingProvider:["type",Ad]};function Md(e,t){this._handlerMap={},this._stack=[],this._stackIdx=-1,this._currentExecution={actions:[],dirty:[],trigger:null},this._injector=t,this._eventBus=e,this._uid=1,e.on(["diagram.destroy","diagram.clear"],(function(){this.clear(!1)}),this)}Md.$inject=["eventBus","injector"],Md.prototype.execute=function(e,t){if(!e)throw new Error("command required");this._currentExecution.trigger="execute";var n={command:e,context:t};this._pushAction(n),this._internalExecute(n),this._popAction(n)},Md.prototype.canExecute=function(e,t){var n={command:e,context:t},i=this._getHandler(e),r=this._fire(e,"canExecute",n);if(void 0===r){if(!i)return!1;i.canExecute&&(r=i.canExecute(t))}return r},Md.prototype.clear=function(e){this._stack.length=0,this._stackIdx=-1,!1!==e&&this._fire("changed",{trigger:"clear"})},Md.prototype.undo=function(){var e,t=this._getUndoAction();if(t){for(this._currentExecution.trigger="undo",this._pushAction(t);t&&(this._internalUndo(t),(e=this._getUndoAction())&&e.id===t.id);)t=e;this._popAction()}},Md.prototype.redo=function(){var e,t=this._getRedoAction();if(t){for(this._currentExecution.trigger="redo",this._pushAction(t);t&&(this._internalExecute(t,!0),(e=this._getRedoAction())&&e.id===t.id);)t=e;this._popAction()}},Md.prototype.register=function(e,t){this._setHandler(e,t)},Md.prototype.registerHandler=function(e,t){if(!e||!t)throw new Error("command and handlerCls must be defined");var n=this._injector.instantiate(t);this.register(e,n)},Md.prototype.canUndo=function(){return!!this._getUndoAction()},Md.prototype.canRedo=function(){return!!this._getRedoAction()},Md.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]},Md.prototype._getUndoAction=function(){return this._stack[this._stackIdx]},Md.prototype._internalUndo=function(e){var t=this,n=e.command,i=e.context,r=this._getHandler(n);this._atomicDo((function(){t._fire(n,"revert",e),r.revert&&t._markDirty(r.revert(i)),t._revertedAction(e),t._fire(n,"reverted",e)}))},Md.prototype._fire=function(e,t,n){arguments.length<3&&(n=t,t=null);var i,r,o,a=t?[e+"."+t,t]:[e];for(n=this._eventBus.createEvent(n),i=0;(r=a[i])&&(o=this._eventBus.fire("commandStack."+r,n),!n.cancelBubble);i++);return o},Md.prototype._createId=function(){return this._uid++},Md.prototype._atomicDo=function(e){var t=this._currentExecution;t.atomic=!0;try{e()}finally{t.atomic=!1}},Md.prototype._internalExecute=function(e,t){var n=this,i=e.command,r=e.context,o=this._getHandler(i);if(!o)throw new Error("no command handler registered for <"+i+">");this._pushAction(e),t||(this._fire(i,"preExecute",e),o.preExecute&&o.preExecute(r),this._fire(i,"preExecuted",e)),this._atomicDo((function(){n._fire(i,"execute",e),o.execute&&n._markDirty(o.execute(r)),n._executedAction(e,t),n._fire(i,"executed",e)})),t||(this._fire(i,"postExecute",e),o.postExecute&&o.postExecute(r),this._fire(i,"postExecuted",e)),this._popAction(e)},Md.prototype._pushAction=function(e){var t=this._currentExecution,n=t.actions,i=n[0];if(t.atomic)throw new Error("illegal invocation in <execute> or <revert> phase (action: "+e.command+")");e.id||(e.id=i&&i.id||this._createId()),n.push(e)},Md.prototype._popAction=function(){var e=this._currentExecution,t=e.trigger,n=e.actions,i=e.dirty;n.pop(),n.length||(this._eventBus.fire("elements.changed",{elements:A("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:t}),e.trigger=null)},Md.prototype._markDirty=function(e){var t=this._currentExecution;e&&(e=u(e)?e:[e],t.dirty=t.dirty.concat(e))},Md.prototype._executedAction=function(e,t){var n=++this._stackIdx;t||this._stack.splice(n,this._stack.length,e)},Md.prototype._revertedAction=function(e){this._stackIdx--},Md.prototype._getHandler=function(e){return this._handlerMap[e]},Md.prototype._setHandler=function(e,t){if(!e||!t)throw new Error("command and handler required");if(this._handlerMap[e])throw new Error("overriding handler for command <"+e+">");this._handlerMap[e]=t};var Dd={commandStack:["type",Md]},Bd=new Oo("tt");function Nd(e,t){e.style.display=!1===t?"none":""}var Od=".djs-tooltip";function jd(e,t){var n,i;this._eventBus=e,this._canvas=t,this._ids=Bd,this._tooltipDefaults={show:{minZoom:.7,maxZoom:5}},this._tooltips={},this._tooltipRoot=(n=t.getContainer(),i=ce('<div class="djs-tooltip-container" style="position: absolute; width: 0; height: 0;" />'),n.insertBefore(i,n.firstChild),i);var r=this;se.bind(this._tooltipRoot,Od,"mousedown",(function(e){e.stopPropagation()})),se.bind(this._tooltipRoot,Od,"mouseover",(function(e){r.trigger("mouseover",e)})),se.bind(this._tooltipRoot,Od,"mouseout",(function(e){r.trigger("mouseout",e)})),this._init()}jd.$inject=["eventBus","canvas"],jd.prototype.add=function(e){if(!e.position)throw new Error("must specifiy tooltip position");if(!e.html)throw new Error("must specifiy tooltip html");var t=this._ids.next();return e=F({},this._tooltipDefaults,e,{id:t}),this._addTooltip(e),e.timeout&&this.setTimeout(e),t},jd.prototype.trigger=function(e,t){var n=t.delegateTarget||t.target,i=this.get(G(n,"data-tooltip-id"));i&&("mouseover"===e&&i.timeout&&this.clearTimeout(i),"mouseout"===e&&i.timeout&&(i.timeout=1e3,this.setTimeout(i)))},jd.prototype.get=function(e){return"string"!=typeof e&&(e=e.id),this._tooltips[e]},jd.prototype.clearTimeout=function(e){if(e=this.get(e)){var t=e.removeTimer;t&&(clearTimeout(t),e.removeTimer=null)}},jd.prototype.setTimeout=function(e){if(e=this.get(e)){this.clearTimeout(e);var t=this;e.removeTimer=setTimeout((function(){t.remove(e)}),e.timeout)}},jd.prototype.remove=function(e){var t=this.get(e);t&&(de(t.html),de(t.htmlContainer),delete t.htmlContainer,delete this._tooltips[t.id])},jd.prototype.show=function(){Nd(this._tooltipRoot)},jd.prototype.hide=function(){Nd(this._tooltipRoot,!1)},jd.prototype._updateRoot=function(e){var t=e.scale||1,n=e.scale||1,i="matrix("+t+",0,0,"+n+","+-1*e.x*t+","+-1*e.y*n+")";this._tooltipRoot.style.transform=i,this._tooltipRoot.style["-ms-transform"]=i},jd.prototype._addTooltip=function(e){var t,n=e.id,i=e.html,r=this._tooltipRoot;i.get&&i.constructor.prototype.jquery&&(i=i.get(0)),m(i)&&(i=ce(i)),(t=ce('<div data-tooltip-id="'+n+'" class="'+'djs-tooltip" style="position: absolute">')).appendChild(i),e.type&&K(t).add("djs-tooltip-"+e.type),e.className&&K(t).add(e.className),e.htmlContainer=t,r.appendChild(t),this._tooltips[n]=e,this._updateTooltip(e)},jd.prototype._updateTooltip=function(e){var t,n,i,r=e.position,o=e.htmlContainer;t=o,n=r.x,i=r.y,F(t.style,{left:n+"px",top:i+"px"})},jd.prototype._updateTooltipVisibilty=function(e){b(this._tooltips,(function(t){var n=t.show,i=t.htmlContainer,r=!0;n&&((n.minZoom>e.scale||n.maxZoom<e.scale)&&(r=!1),Nd(i,r))}))},jd.prototype._init=function(){var e=this;this._eventBus.on("canvas.viewbox.changing",(function(t){e.hide()})),this._eventBus.on("canvas.viewbox.changed",(function(t){var n;n=t.viewbox,e._updateRoot(n),e._updateTooltipVisibilty(n),e.show()}))};var Ld={__init__:["tooltips"],tooltips:["type",jd]};function Id(e,t){if("function"!=typeof t)throw new Error("removeFn iterator must be a function");if(e){for(var n;n=e[0];)t(n);return e}}function zd(e,t,n){Ka.call(this,t);var i=e.get("movePreview",!1);t.on("shape.move.start",1400,(function(e){var t=e.context,n=t.shapes,i=t.validatedShapes;t.shapes=Fd(n),t.validatedShapes=Fd(i)})),i&&t.on("shape.move.start",250,(function(e){var t=e.context,n=t.shapes,r=[];b(n,(function(e){b(e.labels,(function(n){n.hidden||-1!==t.shapes.indexOf(n)||r.push(n),e.labelTarget&&r.push(e)}))})),b(r,(function(e){i.makeDraggable(t,e,!0)}))})),this.preExecuted("elements.move",1400,(function(e){var t=e.context.closure,n=t.enclosedElements,i=[];b(n,(function(e){b(e.labels,(function(e){n[e.id]||i.push(e)}))})),t.addAll(i)})),this.preExecute(["connection.delete","shape.delete"],(function(e){var t=e.context;Id((t.connection||t.shape).labels,(function(e){n.removeShape(e,{nested:!0})}))})),this.execute("shape.delete",(function(e){var t=e.context,n=t.shape,i=n.labelTarget;i&&(t.labelTargetIndex=yt(i.labels,n),t.labelTarget=i,n.labelTarget=null)})),this.revert("shape.delete",(function(e){var t=e.context,n=t.shape,i=t.labelTarget,r=t.labelTargetIndex;i&&(vt(i.labels,n,r),n.labelTarget=i)}))}function Fd(e){return g(e,(function(t){return-1===e.indexOf(t.labelTarget)}))}n(zd,Ka),zd.$inject=["injector","eventBus","modeling"];var $d={__init__:["labelSupport"],labelSupport:["type",zd]},Hd="attach-ok";function Gd(e,t,n,i,r){Ka.call(this,t);var o=e.get("movePreview",!1);t.on("shape.move.start",1401,(function(e){var t,n,i=e.context,r=i.shapes,o=i.validatedShapes;i.shapes=(n=Wd(t=r),k("id",t,n)),i.validatedShapes=function(e){var t=P(e,"id");return g(e,(function(e){for(;e;){if(e.host&&t[e.host.id])return!1;e=e.parent}return!0}))}(o)})),o&&t.on("shape.move.start",251,(function(e){var t=e.context;b(Wd(t.shapes),(function(e){o.makeDraggable(t,e,!0),b(e.labels,(function(e){o.makeDraggable(t,e,!0)}))}))})),o&&t.on("shape.move.start",(function(e){var i=e.context.shapes;if(1===i.length){var r=i[0].host;r&&(n.addMarker(r,Hd),t.once(["shape.move.out","shape.move.cleanup"],(function(){n.removeMarker(r,Hd)})))}})),this.preExecuted("elements.move",1401,(function(e){var t=e.context,n=t.closure;b(Wd(t.shapes),(function(e){n.add(e,n.topLevel[e.host.id])}))})),this.postExecuted("elements.move",(function(e){var t=e.context,n=t.shapes,i=t.newHost;i&&1!==n.length||b(i?n:g(n,(function(e){var t,i=e.host;return function(e){return!!e.host}(e)&&(t=i,!(-1!==n.indexOf(t)))})),(function(e){r.updateAttachment(e,i)}))})),this.postExecuted("elements.move",(function(e){b(e.context.shapes,(function(e){b(e.attachers,(function(e){b(e.outgoing.slice(),(function(e){i.allowed("connection.reconnect",{connection:e,source:e.source,target:e.target})||r.removeConnection(e)})),b(e.incoming.slice(),(function(e){i.allowed("connection.reconnect",{connection:e,source:e.source,target:e.target})||r.removeConnection(e)}))}))}))})),this.postExecute("shape.create",(function(e){var t=e.context,n=t.shape,i=t.host;i&&r.updateAttachment(n,i)})),this.postExecute("shape.replace",(function(e){var t=e.context,n=t.oldShape,o=t.newShape;Id(n.attachers,(function(e){"attach"===i.allowed("elements.move",{target:o,shapes:[e]})?r.updateAttachment(e,o):r.removeShape(e)})),o.attachers.length&&b(o.attachers,(function(e){var t=eh(e,n,o);r.moveShape(e,t,e.parent)}))})),this.postExecute("shape.resize",(function(e){var t=e.context,n=t.shape,i=t.oldBounds,o=t.newBounds,a=n.attachers;!1!==(t.hints||{}).attachSupport&&b(a,(function(e){var t=eh(e,i,o);r.moveShape(e,t,e.parent),b(e.labels,(function(e){r.moveShape(e,t,e.parent)}))}))})),this.preExecute("shape.delete",(function(e){var t=e.context.shape;Id(t.attachers,(function(e){r.removeShape(e)})),t.host&&r.updateAttachment(t,null)}))}function Wd(e){return o(S(e,(function(e){return e.attachers||[]})))}n(Gd,Ka),Gd.$inject=["injector","eventBus","canvas","rules","modeling"];var Vd={__depends__:[hs],__init__:["attachSupport"],attachSupport:["type",Gd]};function Ud(e,t){this._eventBus=e,this._dragging=t,this._tools=[],this._active=null}Ud.$inject=["eventBus","dragging"],Ud.prototype.registerTool=function(e,t){var n=this._tools;if(!t)throw new Error('A tool has to be registered with it\'s "events"');n.push(e),this.bindEvents(e,t)},Ud.prototype.isActive=function(e){return e&&this._active===e},Ud.prototype.length=function(e){return this._tools.length},Ud.prototype.setActive=function(e){var t=this._eventBus;this._active!==e&&(this._active=e,t.fire("tool-manager.update",{tool:e}))},Ud.prototype.bindEvents=function(e,t){var n=this._eventBus,i=this._dragging,r=[];n.on(t.tool+".init",(function(t){if(!t.context.reactivate&&this.isActive(e))return this.setActive(null),void i.cancel();this.setActive(e)}),this),b(t,(function(e){r.push(e+".ended"),r.push(e+".canceled")})),n.on(r,250,(function(e){this._active&&(function(e){var t=e.originalEvent&&e.originalEvent.target;return t&&ee(t,'.group[data-group="tools"]')}(e)||this.setActive(null))}),this)};var qd={__depends__:[ss],__init__:["toolManager"],toolManager:["type",Ud]};function Kd(e,t){return-1!==e.indexOf(t)}var Yd=Math.abs,Xd=Math.round,Zd={x:"width",y:"height"},Qd="crosshair",Jd={n:"top",w:"left",s:"bottom",e:"right"},ef={n:"s",w:"e",s:"n",e:"w"};function tf(e,t,n,i,r,o,a){this._canvas=e,this._dragging=t,this._eventBus=n,this._modeling=i,this._rules=r,this._toolManager=o,this._mouse=a;var s=this;o.registerTool("space",{tool:"spaceTool.selection",dragging:"spaceTool"}),n.on("spaceTool.selection.end",(function(e){n.once("spaceTool.selection.ended",(function(){s.activateMakeSpace(e.originalEvent)}))})),n.on("spaceTool.move",1500,(function(e){var t=e.context,n=t.initialized;n||(n=t.initialized=s.init(e,t)),n&&rf(e)})),n.on("spaceTool.end",(function(e){var t=e.context,i=t.axis,r=t.direction,o=t.movingShapes,a=t.resizingShapes,c=t.start;if(t.initialized){rf(e);var p={x:0,y:0};p[i]=Xd(e["d"+i]),s.makeSpace(o,a,p,r,c),n.once("spaceTool.ended",(function(e){s.activateSelection(e.originalEvent,!0,!0)}))}}))}function nf(e){return{top:e.top-20,right:e.right+20,bottom:e.bottom+20,left:e.left-20}}function rf(e){var t,n,i=e.context.spaceToolConstraints;i&&(d(i.left)&&(t=Math.max(e.x,i.left),e.dx=e.dx+t-e.x,e.x=t),d(i.right)&&(t=Math.min(e.x,i.right),e.dx=e.dx+t-e.x,e.x=t),d(i.top)&&(n=Math.max(e.y,i.top),e.dy=e.dy+n-e.y,e.y=n),d(i.bottom)&&(n=Math.min(e.y,i.bottom),e.dy=e.dy+n-e.y,e.y=n))}function of(e,t){return-1!==e.indexOf(t)}function af(e){return!!e.waypoints}function sf(e){return!!e.labelTarget}tf.$inject=["canvas","dragging","eventBus","modeling","rules","toolManager","mouse"],tf.prototype.activateSelection=function(e,t,n){this._dragging.init(e,"spaceTool.selection",{autoActivate:t,cursor:Qd,data:{context:{reactivate:n}},trapClick:!1})},tf.prototype.activateMakeSpace=function(e){this._dragging.init(e,"spaceTool",{autoActivate:!0,cursor:Qd,data:{context:{}}})},tf.prototype.makeSpace=function(e,t,n,i,r){return this._modeling.createSpace(e,t,n,i,r)},tf.prototype.init=function(e,t){var n=Yd(e.dx)>Yd(e.dy)?"x":"y",i=e["d"+n],r=e[n]-i;if(Yd(i)<5)return!1;i<0&&(i*=-1),xo(e)&&(i*=-1);var o=function(e,t){if("x"===e){if(t>0)return"e";if(t<0)return"w"}if("y"===e){if(t>0)return"s";if(t<0)return"n"}return null}(n,i),a=ct(this._canvas.getRootElement(),!0),s=this.calculateAdjustments(a,n,i,r);return F(t,s,{axis:n,direction:o,spaceToolConstraints:function(e,t,n,i,r){var o=e.movingShapes,a=e.resizingShapes;if(!a.length)return;var s,c,p={};return b(a,(function(e){var l,u,h,f=an(e),m=g(e.children,(function(e){return!(af(e)||sf(e)||of(o,e)||of(a,e))})),v=g(e.children,(function(e){return!af(e)&&!sf(e)&&of(o,e)}));m.length&&(u=nf(an(pt(m))),l=i-f[Jd[n]]+u[Jd[n]],"n"===n?p.bottom=c=d(c)?Math.min(c,l):l:"w"===n?p.right=c=d(c)?Math.min(c,l):l:"s"===n?p.top=s=d(s)?Math.max(s,l):l:"e"===n&&(p.left=s=d(s)?Math.max(s,l):l)),v.length&&(h=nf(an(pt(v))),l=i-h[Jd[ef[n]]]+f[Jd[ef[n]]],"n"===n?p.bottom=c=d(c)?Math.min(c,l):l:"w"===n?p.right=c=d(c)?Math.min(c,l):l:"s"===n?p.top=s=d(s)?Math.max(s,l):l:"e"===n&&(p.left=s=d(s)?Math.max(s,l):l));var y=r&&r[e.id];y&&("n"===n?(l=i+e[Zd[t]]-y[Zd[t]],p.bottom=c=d(c)?Math.min(c,l):l):"w"===n?(l=i+e[Zd[t]]-y[Zd[t]],p.right=c=d(c)?Math.min(c,l):l):"s"===n?(l=i-e[Zd[t]]+y[Zd[t]],p.top=s=d(s)?Math.max(s,l):l):"e"===n&&(l=i-e[Zd[t]]+y[Zd[t]],p.left=s=d(s)?Math.max(s,l):l))})),p}(s,n,o,r,this._eventBus.fire("spaceTool.getMinDimensions",{axis:n,direction:o,shapes:s.resizingShapes,start:r})),start:r}),oa("resize-"+("x"===n?"ew":"ns")),!0},tf.prototype.calculateAdjustments=function(e,t,n,i){var r=this._rules,o=[],a=[];return b(e,(function(e){if(e.parent&&!af(e)){var s=e[t],c=s+e[Zd[t]];return n>0&&s>i||n<0&&c<i?o.push(e):s<i&&c>i&&r.allowed("shape.resize",{shape:e})?a.push(e):void 0}})),{movingShapes:o,resizingShapes:a}},tf.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},tf.prototype.isActive=function(){var e=this._dragging.context();return e&&/^spaceTool/.test(e.prefix)};var cf="djs-dragging",pf="djs-resizing",lf=Math.max;function uf(e,t,n,i,r){function o(e,t){b(e,(function(e){r.addDragger(e,t),n.addMarker(e,cf)}))}e.on("spaceTool.selection.start",(function(e){var t=n.getLayer("space"),r=e.context,o="M 0,-10000 L 0,10000",a="M -10000,0 L 10000,0",s=Me("g");ge(s,i.cls("djs-crosshair-group",["no-events"])),me(t,s);var c=Me("path");ge(c,"d",o),we(c).add("djs-crosshair"),me(s,c);var p=Me("path");ge(p,"d",a),we(p).add("djs-crosshair"),me(s,p),r.crosshairGroup=s})),e.on("spaceTool.selection.move",(function(e){Vn(e.context.crosshairGroup,e.x,e.y)})),e.on("spaceTool.selection.cleanup",(function(e){var t=e.context.crosshairGroup;t&&Ce(t)})),e.on("spaceTool.move",250,(function(e){var a=e.context,s=a.line,c=a.axis,p=a.movingShapes,l=a.resizingShapes;if(a.initialized){if(!a.dragGroup){var u=n.getLayer("space");ge(s=Me("path"),"d","M0,0 L0,0"),we(s).add("djs-crosshair"),me(u,s),a.line=s;var h=Me("g");ge(h,i.cls("djs-drag-group",["no-events"])),me(n.getActiveLayer(),h),o(p,h),o(a.movingConnections=t.filter((function(e){var t=!1;b(p,(function(n){b(n.outgoing,(function(n){e===n&&(t=!0)}))}));var n=!1;b(p,(function(t){b(t.incoming,(function(t){e===t&&(n=!0)}))}));var i=!1;b(l,(function(t){b(t.outgoing,(function(t){e===t&&(i=!0)}))}));var r=!1;return b(l,(function(t){b(t.incoming,(function(t){e===t&&(r=!0)}))})),function(e){return e.waypoints}(e)&&(t||i)&&(n||r)})),h),a.dragGroup=h}if(!a.frameGroup){var d=Me("g");ge(d,i.cls("djs-frame-group",["no-events"])),me(n.getActiveLayer(),d);var f=[];b(l,(function(e){var t=r.addFrame(e,d),i=t.getBBox();f.push({element:t,initialBounds:i}),n.addMarker(e,pf)})),a.frameGroup=d,a.frames=f}ge(s,{d:{x:"M"+e.x+", -10000 L"+e.x+", 10000",y:"M -10000, "+e.y+" L 10000, "+e.y}[c]});var m={x:e.dx,y:e.dy};m[{x:"y",y:"x"}[a.axis]]=0,Vn(a.dragGroup,m.x,m.y),b(a.frames,(function(e){var t,n,i=e.element,r=e.initialBounds;"e"===a.direction?ge(i,{width:lf(r.width+m.x,5)}):ge(i,{width:t=lf(r.width-m.x,5),x:r.x+r.width-t}),"s"===a.direction?ge(i,{height:lf(r.height+m.y,5)}):ge(i,{height:n=lf(r.height-m.y,5),y:r.y+r.height-n})}))}})),e.on("spaceTool.cleanup",(function(e){var t=e.context,i=t.movingShapes,r=t.movingConnections,o=t.resizingShapes,a=t.line,s=t.dragGroup,c=t.frameGroup;b(i,(function(e){n.removeMarker(e,cf)})),b(r,(function(e){n.removeMarker(e,cf)})),s&&(Ce(a),Ce(s)),b(o,(function(e){n.removeMarker(e,pf)})),c&&Ce(c)}))}uf.$inject=["eventBus","elementRegistry","canvas","styles","previewSupport"];var hf={__init__:["spaceToolPreview"],__depends__:[ss,hs,qd,Rc,Uc],spaceTool:["type",tf],spaceToolPreview:["type",uf]};function df(e){this._model=e}function ff(e,t,n,i){Ka.call(this,e),this._bpmnFactory=t,this._translate=i;var r=this;function o(e){b(e.context.oldRoot.children,(function(e){Ar(e,"bpmn:BaseElement")&&r.updateParent(e)}))}function a(e){var t=e.context.shape;Ar(t,"bpmn:BaseElement")&&r.updateBounds(t)}function s(e){r.updateConnection(e.context)}function c(e){r.updateConnectionWaypoints(e.context.connection)}function p(e){r.updateAttachment(e.context)}this.executed(["connection.layout","connection.create"],(function(e){var t,i=e.context,r=i.hints||{};i.cropped||!1===r.createElementsBehavior||((t=i.connection).waypoints=n.getCroppedWaypoints(t),i.cropped=!0)})),this.reverted(["connection.layout"],(function(e){delete e.context.cropped})),this.executed(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],mf((function(e){var t=e.context;r.updateParent(t.shape||t.connection,t.oldParent)}))),this.reverted(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],mf((function(e){var t=e.context,n=t.shape||t.connection,i=t.parent||t.newParent;r.updateParent(n,i)}))),this.executed(["canvas.updateRoot"],o),this.reverted(["canvas.updateRoot"],o),this.executed(["shape.move","shape.create","shape.resize"],mf((function(e){"label"!==e.context.shape.type&&a(e)}))),this.reverted(["shape.move","shape.create","shape.resize"],mf((function(e){"label"!==e.context.shape.type&&a(e)}))),e.on("shape.changed",(function(e){"label"===e.element.type&&a({context:{shape:e.element}})})),this.executed(["connection.create","connection.move","connection.delete","connection.reconnect"],mf(s)),this.reverted(["connection.create","connection.move","connection.delete","connection.reconnect"],mf(s)),this.executed(["connection.layout","connection.move","connection.updateWaypoints"],mf(c)),this.reverted(["connection.layout","connection.move","connection.updateWaypoints"],mf(c)),this.executed("connection.reconnect",mf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=kr(n),a=kr(i),s=kr(r);o.conditionExpression&&!Ha(s,["bpmn:Activity","bpmn:ExclusiveGateway","bpmn:InclusiveGateway"])&&(t.oldConditionExpression=o.conditionExpression,delete o.conditionExpression),i!==r&&a.default===o&&(t.oldDefault=a.default,delete a.default)}))),this.reverted("connection.reconnect",mf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=kr(n),a=kr(i),s=kr(r);t.oldConditionExpression&&(o.conditionExpression=t.oldConditionExpression),t.oldDefault&&(a.default=t.oldDefault,delete s.default)}))),this.executed(["element.updateAttachment"],mf(p)),this.reverted(["element.updateAttachment"],mf(p))}function mf(e){return function(t){var n=t.context;Ar(n.shape||n.connection,"bpmn:BaseElement")&&e(t)}}function vf(e,t,n){zn.call(this),this._bpmnFactory=e,this._moddle=t,this._translate=n}function yf(e,t,n){e[n]=t[n],delete t[n]}function gf(e,t){this._modeling=e,this._canvas=t}function bf(e){this._modeling=e}function xf(e,t){this._canvas=e,this._layouter=t}df.$inject=["moddle"],df.prototype._needsId=function(e){return Ha(e,["bpmn:RootElement","bpmn:FlowElement","bpmn:MessageFlow","bpmn:DataAssociation","bpmn:Artifact","bpmn:Participant","bpmn:Lane","bpmn:LaneSet","bpmn:Process","bpmn:Collaboration","bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane","bpmn:Property","bpmn:CategoryValue"])},df.prototype._ensureId=function(e){var t;e.id?this._model.ids.claim(e.id,e):(t=Ar(e,"bpmn:Activity")?"Activity":Ar(e,"bpmn:Event")?"Event":Ar(e,"bpmn:Gateway")?"Gateway":Ha(e,["bpmn:SequenceFlow","bpmn:MessageFlow"])?"Flow":(e.$type||"").replace(/^[^:]*:/g,""),t+="_",!e.id&&this._needsId(e)&&(e.id=this._model.ids.nextPrefixed(t,e)))},df.prototype.create=function(e,t){var n=this._model.create(e,t||{});return this._ensureId(n),n},df.prototype.createDiLabel=function(){return this.create("bpmndi:BPMNLabel",{bounds:this.createDiBounds()})},df.prototype.createDiShape=function(e,t,n){return this.create("bpmndi:BPMNShape",F({bpmnElement:e,bounds:this.createDiBounds(t)},n))},df.prototype.createDiBounds=function(e){return this.create("dc:Bounds",e)},df.prototype.createDiWaypoints=function(e){var t=this;return S(e,(function(e){return t.createDiWaypoint(e)}))},df.prototype.createDiWaypoint=function(e){return this.create("dc:Point",$(e,["x","y"]))},df.prototype.createDiEdge=function(e,t,n){return this.create("bpmndi:BPMNEdge",F({bpmnElement:e,waypoint:this.createDiWaypoints(t)},n))},df.prototype.createDiPlane=function(e){return this.create("bpmndi:BPMNPlane",{bpmnElement:e})},n(ff,Ka),ff.$inject=["eventBus","bpmnFactory","connectionDocking","translate"],ff.prototype.updateAttachment=function(e){var t=e.shape,n=t.businessObject,i=t.host;n.attachedToRef=i&&i.businessObject},ff.prototype.updateParent=function(e,t){if(!(e instanceof jn||Ar(e,"bpmn:DataStoreReference")&&e.parent&&Ar(e.parent,"bpmn:Collaboration"))){var n=e.parent,i=e.businessObject,r=n&&n.businessObject,o=r&&r.di;Ar(e,"bpmn:FlowNode")&&this.updateFlowNodeRefs(i,r,t&&t.businessObject),Ar(e,"bpmn:DataOutputAssociation")&&(r=e.source?e.source.businessObject:null),Ar(e,"bpmn:DataInputAssociation")&&(r=e.target?e.target.businessObject:null),this.updateSemanticParent(i,r),Ar(e,"bpmn:DataObjectReference")&&i.dataObjectRef&&this.updateSemanticParent(i.dataObjectRef,r),this.updateDiParent(i.di,o)}},ff.prototype.updateBounds=function(e){var t=e.businessObject.di,n=e instanceof jn?this._getLabel(t):t,i=n.bounds;i||(i=this._bpmnFactory.createDiBounds(),n.set("bounds",i)),F(i,{x:e.x,y:e.y,width:e.width,height:e.height})},ff.prototype.updateFlowNodeRefs=function(e,t,n){n!==t&&(Ar(n,"bpmn:Lane")&&mt(n.get("flowNodeRef"),e),Ar(t,"bpmn:Lane")&&vt(t.get("flowNodeRef"),e))},ff.prototype.updateDiConnection=function(e,t,n){e.sourceElement&&e.sourceElement.bpmnElement!==t&&(e.sourceElement=t&&t.di),e.targetElement&&e.targetElement.bpmnElement!==n&&(e.targetElement=n&&n.di)},ff.prototype.updateDiParent=function(e,t){if(t&&!Ar(t,"bpmndi:BPMNPlane")&&(t=t.$parent),e.$parent!==t){var n=(t||e.$parent).get("planeElement");t?(n.push(e),e.$parent=t):(mt(n,e),e.$parent=null)}},ff.prototype.getLaneSet=function(e){var t,n;return Ar(e,"bpmn:Lane")?((t=e.childLaneSet)||(t=this._bpmnFactory.create("bpmn:LaneSet"),e.childLaneSet=t,t.$parent=e),t):(Ar(e,"bpmn:Participant")&&(e=e.processRef),(t=(n=e.get("laneSets"))[0])||((t=this._bpmnFactory.create("bpmn:LaneSet")).$parent=e,n.push(t)),t)},ff.prototype.updateSemanticParent=function(e,t,n){var i,r=this._translate;if(e.$parent!==t&&(!Ar(e,"bpmn:DataInput")&&!Ar(e,"bpmn:DataOutput")||(Ar(t,"bpmn:Participant")&&"processRef"in t&&(t=t.processRef),!("ioSpecification"in t)||t.ioSpecification!==e.$parent))){if(Ar(e,"bpmn:Lane"))t&&(t=this.getLaneSet(t)),i="lanes";else if(Ar(e,"bpmn:FlowElement")){if(t)if(Ar(t,"bpmn:Participant"))t=t.processRef;else if(Ar(t,"bpmn:Lane"))do{t=t.$parent.$parent}while(Ar(t,"bpmn:Lane"));i="flowElements"}else if(Ar(e,"bpmn:Artifact")){for(;t&&!Ar(t,"bpmn:Process")&&!Ar(t,"bpmn:SubProcess")&&!Ar(t,"bpmn:Collaboration");){if(Ar(t,"bpmn:Participant")){t=t.processRef;break}t=t.$parent}i="artifacts"}else if(Ar(e,"bpmn:MessageFlow"))i="messageFlows";else if(Ar(e,"bpmn:Participant")){i="participants";var o,a=e.processRef;a&&(o=function(e){for(;e&&!Ar(e,"bpmn:Definitions");)e=e.$parent;return e}(e.$parent||t),e.$parent&&(mt(o.get("rootElements"),a),a.$parent=null),t&&(vt(o.get("rootElements"),a),a.$parent=o))}else Ar(e,"bpmn:DataOutputAssociation")?i="dataOutputAssociations":Ar(e,"bpmn:DataInputAssociation")&&(i="dataInputAssociations");if(!i)throw new Error(r("no parent for {element} in {parent}",{element:e.id,parent:t.id}));var s;if(e.$parent&&mt(s=e.$parent.get(i),e),t?((s=t.get(i)).push(e),e.$parent=t):e.$parent=null,n){var c=n.get(i);mt(s,e),t&&(c||(c=[],t.set(i,c)),c.push(e))}}},ff.prototype.updateConnectionWaypoints=function(e){e.businessObject.di.set("waypoint",this._bpmnFactory.createDiWaypoints(e.waypoints))},ff.prototype.updateConnection=function(e){var t,n=e.connection,i=kr(n),r=kr(n.source),o=kr(n.target);if(Ar(i,"bpmn:DataAssociation"))Ar(i,"bpmn:DataInputAssociation")?(i.get("sourceRef")[0]=r,t=e.parent||e.newParent||o,this.updateSemanticParent(i,o,t)):Ar(i,"bpmn:DataOutputAssociation")&&(t=e.parent||e.newParent||r,this.updateSemanticParent(i,r,t),i.targetRef=o);else{var a=Ar(i,"bpmn:SequenceFlow");i.sourceRef!==r&&(a&&(mt(i.sourceRef&&i.sourceRef.get("outgoing"),i),r&&r.get("outgoing")&&r.get("outgoing").push(i)),i.sourceRef=r),i.targetRef!==o&&(a&&(mt(i.targetRef&&i.targetRef.get("incoming"),i),o&&o.get("incoming")&&o.get("incoming").push(i)),i.targetRef=o)}this.updateConnectionWaypoints(n),this.updateDiConnection(i.di,r,o)},ff.prototype._getLabel=function(e){return e.label||(e.label=this._bpmnFactory.createDiLabel()),e.label},n(vf,zn),vf.$inject=["bpmnFactory","moddle","translate"],vf.prototype.baseCreate=zn.prototype.create,vf.prototype.create=function(e,t){return"label"===e?this.baseCreate(e,F({type:"label"},no,t)):this.createBpmnElement(e,t)},vf.prototype.createBpmnElement=function(e,t){var n,i,r,o=this._translate,a=(t=t||{}).businessObject;if(!a){if(!t.type)throw new Error(o("no shape type specified"));a=this._bpmnFactory.create(t.type)}return a.di||(a.di="root"===e?this._bpmnFactory.createDiPlane(a,[],{id:a.id+"_di"}):"connection"===e?this._bpmnFactory.createDiEdge(a,[],{id:a.id+"_di"}):this._bpmnFactory.createDiShape(a,{},{id:a.id+"_di"})),Ar(a,"bpmn:Group")&&(t=F({isFrame:!0},t)),t.di&&(F(a.di,t.di),delete t.di),function(e,t,n){b(n,(function(n){void 0!==t[n]&&yf(e,t,n)}))}(a,t,["processRef","isInterrupting","associationDirection","isForCompensation"]),t.isExpanded&&yf(a.di,t,"isExpanded"),Ar(a,"bpmn:ExclusiveGateway")&&(a.di.isMarkerVisible=!0),t.eventDefinitionType&&(i=a.get("eventDefinitions")||[],r=this._bpmnFactory.create(t.eventDefinitionType,t.eventDefinitionAttrs),"bpmn:ConditionalEventDefinition"===t.eventDefinitionType&&(r.condition=this._bpmnFactory.create("bpmn:FormalExpression")),i.push(r),r.$parent=a,a.eventDefinitions=i,delete t.eventDefinitionType),n=this._getDefaultSize(a),t=F({businessObject:a,id:a.id},n,t),this.baseCreate(e,t)},vf.prototype._getDefaultSize=function(e){return Ar(e,"bpmn:SubProcess")?Mr(e)?{width:350,height:200}:{width:100,height:80}:Ar(e,"bpmn:Task")?{width:100,height:80}:Ar(e,"bpmn:Gateway")?{width:50,height:50}:Ar(e,"bpmn:Event")?{width:36,height:36}:Ar(e,"bpmn:Participant")?Mr(e)?{width:600,height:250}:{width:400,height:60}:Ar(e,"bpmn:Lane")?{width:400,height:100}:Ar(e,"bpmn:DataObjectReference")?{width:36,height:50}:Ar(e,"bpmn:DataStoreReference")?{width:50,height:50}:Ar(e,"bpmn:TextAnnotation")?{width:100,height:30}:Ar(e,"bpmn:Group")?{width:300,height:300}:{width:100,height:80}},vf.prototype.createParticipantShape=function(e){return h(e)||(e={isExpanded:e}),!1!==(e=F({type:"bpmn:Participant"},e||{})).isExpanded&&(e.processRef=this._bpmnFactory.create("bpmn:Process")),this.createShape(e)},gf.$inject=["modeling","canvas"],gf.prototype.preExecute=function(e){var t=this._modeling,n=e.elements,i=e.alignment;b(n,(function(e){var n={x:0,y:0};i.left?n.x=i.left-e.x:i.right?n.x=i.right-e.width-e.x:i.center?n.x=i.center-Math.round(e.width/2)-e.x:i.top?n.y=i.top-e.y:i.bottom?n.y=i.bottom-e.height-e.y:i.middle&&(n.y=i.middle-Math.round(e.height/2)-e.y),t.moveElements([e],n,e.parent)}))},gf.prototype.postExecute=function(e){},bf.$inject=["modeling"],bf.prototype.preExecute=function(e){var t=e.source;if(!t)throw new Error("source required");var n=e.target||t.parent,i=e.shape,r=e.hints||{};i=e.shape=this._modeling.createShape(i,e.position,n,{attach:r.attach}),e.shape=i},bf.prototype.postExecute=function(e){var t,n,i=e.hints||{};t=e.source,n=e.shape,w(t.outgoing,(function(e){return e.target===n}))||(i.connectionTarget===e.source?this._modeling.connect(e.shape,e.source,e.connection):this._modeling.connect(e.source,e.shape,e.connection))},xf.$inject=["canvas","layouter"],xf.prototype.execute=function(e){var t=e.connection,n=e.source,i=e.target,r=e.parent,o=e.parentIndex,a=e.hints;if(!n||!i)throw new Error("source and target required");if(!r)throw new Error("parent required");return t.source=n,t.target=i,t.waypoints||(t.waypoints=this._layouter.layoutConnection(t,a)),this._canvas.addConnection(t,r,o),t},xf.prototype.revert=function(e){var t=e.connection;return this._canvas.removeConnection(t),t.source=null,t.target=null,t};var _f=Math.round;function Ef(e){this._modeling=e}function wf(e){return!!e.waypoints}Ef.$inject=["modeling"],Ef.prototype.preExecute=function(e){var t=e.elements,n=e.parent,i=e.parentIndex,r=e.position,o=e.hints,a=this._modeling;b(t,(function(e){d(e.x)||(e.x=0),d(e.y)||(e.y=0)}));var s=pt(t);b(t,(function(e){wf(e)&&(e.waypoints=S(e.waypoints,(function(e){return{x:_f(e.x-s.x-s.width/2+r.x),y:_f(e.y-s.y-s.height/2+r.y)}}))),F(e,{x:_f(e.x-s.x-s.width/2+r.x),y:_f(e.y-s.y-s.height/2+r.y)})}));var c=rt(t),p={};b(t,(function(e){if(wf(e))p[e.id]=d(i)?a.createConnection(p[e.source.id],p[e.target.id],i,e,e.parent||n,o):a.createConnection(p[e.source.id],p[e.target.id],e,e.parent||n,o);else{var t=F({},o);-1===c.indexOf(e)&&(t.autoResize=!1),p[e.id]=d(i)?a.createShape(e,$(e,["x","y","width","height"]),e.parent||n,i,t):a.createShape(e,$(e,["x","y","width","height"]),e.parent||n,t)}})),e.elements=R(p)};var Sf=Math.round;function Cf(e){this._canvas=e}function Tf(e){Cf.call(this,e)}Cf.$inject=["canvas"],Cf.prototype.execute=function(e){var t=e.shape,n=e.position,i=e.parent,r=e.parentIndex;if(!i)throw new Error("parent required");if(!n)throw new Error("position required");return void 0!==n.width?F(t,n):F(t,{x:n.x-Sf(t.width/2),y:n.y-Sf(t.height/2)}),this._canvas.addShape(t,i,r),t},Cf.prototype.revert=function(e){var t=e.shape;return this._canvas.removeShape(t),t},n(Tf,Cf),Tf.$inject=["canvas"];var Rf=Cf.prototype.execute;Tf.prototype.execute=function(e){var t=e.shape;return function(e){["width","height"].forEach((function(t){void 0===e[t]&&(e[t]=0)}))}(t),t.labelTarget=e.labelTarget,Rf.call(this,e)};var Pf=Cf.prototype.revert;function Af(e,t){this._canvas=e,this._modeling=t}function kf(e,t){this._modeling=e,this._elementRegistry=t}function Mf(e,t){this._canvas=e,this._modeling=t}function Df(e){this._modeling=e}Tf.prototype.revert=function(e){return e.shape.labelTarget=null,Pf.call(this,e)},Af.$inject=["canvas","modeling"],Af.prototype.execute=function(e){var t=e.connection,n=t.parent;return e.parent=n,e.parentIndex=yt(n.children,t),e.source=t.source,e.target=t.target,this._canvas.removeConnection(t),t.source=null,t.target=null,t},Af.prototype.revert=function(e){var t=e.connection,n=e.parent,i=e.parentIndex;return t.source=e.source,t.target=e.target,vt(n.children,t,i),this._canvas.addConnection(t,n),t},kf.$inject=["modeling","elementRegistry"],kf.prototype.postExecute=function(e){var t=this._modeling,n=this._elementRegistry;b(e.elements,(function(e){n.get(e.id)&&(e.waypoints?t.removeConnection(e):t.removeShape(e))}))},Mf.$inject=["canvas","modeling"],Mf.prototype.preExecute=function(e){var t=this._modeling,n=e.shape;Id(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),Id(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})})),Id(n.children,(function(e){e.waypoints?t.removeConnection(e,{nested:!0}):t.removeShape(e,{nested:!0})}))},Mf.prototype.execute=function(e){var t=this._canvas,n=e.shape,i=n.parent;return e.oldParent=i,e.oldParentIndex=yt(i.children,n),t.removeShape(n),n},Mf.prototype.revert=function(e){var t=this._canvas,n=e.shape,i=e.oldParent,r=e.oldParentIndex;return vt(i.children,n,r),t.addShape(n,i),n},Df.$inject=["modeling"];var Bf={x:"y",y:"x"};function Nf(e,t){this._layouter=e,this._canvas=t}function Of(){}function jf(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}function Lf(e){this._modeling=e}function If(e){this._helper=new Lf(e)}function zf(e){this._modeling=e,this._helper=new Lf(e)}function Ff(e){this._modeling=e}function $f(e){return e.original||e}function Hf(e,t){this._modeling=e,this._rules=t}function Gf(e){this._modeling=e}function Wf(e){this._modeling=e}function Vf(e){return F({},e)}function Uf(e){switch(e){case"n":return"y";case"w":return"x";case"s":return"y";case"e":return"x"}}function qf(e,t,n){var i=Uf(n);return/e|s/.test(n)?e[i]>t:/n|w/.test(n)?e[i]<t:void 0}function Kf(e,t){return-1!==e.indexOf(t)}function Yf(e){this._modeling=e}function Xf(e){var t={};return b(e,(function(e){t[e.id]=e.hidden,e.children&&(t=F({},t,Xf(e.children)))})),t}function Zf(e,t){var n=[];return b(e,(function(e){e.hidden=t,n=n.concat(e),e.children&&(n=n.concat(Zf(e.children,e.collapsed||t)))})),n}function Qf(e,t){var n=[];return b(e,(function(e){e.hidden=t[e.id],n=n.concat(e),e.children&&(n=n.concat(Qf(e.children,t)))})),n}function Jf(e){this._modeling=e}function em(e,t){return mt(e&&e.attachers,t)}function tm(e,t,n){if(e){var i=e.attachers;i||(e.attachers=i=[]),vt(i,t,n)}}function nm(){}function im(e,t,n){this._eventBus=e,this._elementFactory=t,this._commandStack=n;var i=this;e.on("diagram.init",(function(){i.registerHandlers(n)}))}function rm(e){this._elementRegistry=e}function om(e,t){b(t,(function(t,n){e.set(n,t)}))}Df.prototype.preExecute=function(e){var t=this._modeling,n=e.groups,i=e.axis,r=e.dimension;function o(e,t){e.range.min=Math.min(t[i],e.range.min),e.range.max=Math.max(t[i]+t[r],e.range.max)}function a(e){return e[i]+e[r]/2}function s(e){return e.length-1}function c(e){return e.max-e.min}var p,l,u=n[0],h=s(n),d=n[h],f=0;b(n,(function(e,p){var l,u,d;e.elements.length<2?p&&p!==n.length-1&&(o(e,e.elements[0]),f+=c(e.range)):(u=(l=M(e.elements,i))[0],p===h&&(u=l[s(l)]),d=a(u),e.range=null,b(l,(function(n){!function(e,n){var r={y:0};r[i]=e-a(n),r[i]&&(r[Bf[i]]=0,t.moveElements([n],r,n.parent))}(d,n),null!==e.range?o(e,n):e.range={min:n[i],max:n[i]+n[r]}})),p&&p!==n.length-1&&(f+=c(e.range)))})),l=Math.abs(d.range.min-u.range.max),(p=Math.round((l-f)/(n.length-1)))<n.length-1||b(n,(function(e,o){var a,s={};e!==u&&e!==d&&(a=n[o-1],e.range.max=0,b(e.elements,(function(n,o){s[Bf[i]]=0,s[i]=a.range.max-n[i]+p,e.range.min!==n[i]&&(s[i]+=n[i]-e.range.min),s[i]&&t.moveElements([n],s,n.parent),e.range.max=Math.max(n[i]+n[r],o?e.range.max:0)})))}))},Df.prototype.postExecute=function(e){},Nf.$inject=["layouter","canvas"],Nf.prototype.execute=function(e){var t=e.connection;return F(e,{oldWaypoints:t.waypoints}),t.waypoints=this._layouter.layoutConnection(t,e.hints),t},Nf.prototype.revert=function(e){var t=e.connection;return t.waypoints=e.oldWaypoints,t},Of.prototype.execute=function(e){var t=e.connection,n=e.delta,i=e.newParent||t.parent,r=e.newParentIndex,o=t.parent;return e.oldParent=o,e.oldParentIndex=mt(o.children,t),vt(i.children,t,r),t.parent=i,b(t.waypoints,(function(e){e.x+=n.x,e.y+=n.y,e.original&&(e.original.x+=n.x,e.original.y+=n.y)})),t},Of.prototype.revert=function(e){var t=e.connection,n=t.parent,i=e.oldParent,r=e.oldParentIndex,o=e.delta;return mt(n.children,t),vt(i.children,t,r),t.parent=i,b(t.waypoints,(function(e){e.x-=o.x,e.y-=o.y,e.original&&(e.original.x-=o.x,e.original.y-=o.y)})),t},jf.prototype.add=function(e,t){return this.addAll([e],t)},jf.prototype.addAll=function(e,t){return F(this,function(e,t,n){c(t)&&(t=!0),h(t)&&(n=t,t=!0);var i=ht((n=n||{}).allShapes),r=ht(n.allConnections),o=ht(n.enclosedElements),a=ht(n.enclosedConnections),s=ht(n.topLevel,t&&P(e,(function(e){return e.id})));function p(e){s[e.source.id]&&s[e.target.id]&&(s[e.id]=[e]),i[e.source.id]&&i[e.target.id]&&(a[e.id]=o[e.id]=e),r[e.id]=e}return st(e,(function(e){if(o[e.id]=e,!e.waypoints)return i[e.id]=e,b(e.incoming,p),b(e.outgoing,p),e.children;a[e.id]=r[e.id]=e})),{allShapes:i,allConnections:r,topLevel:s,enclosedConnections:a,enclosedElements:o}}(e,!!t,this)),this},Lf.prototype.moveRecursive=function(e,t,n){return e?this.moveClosure(this.getClosure(e),t,n):[]},Lf.prototype.moveClosure=function(e,t,n,i,r){var o=this._modeling,a=e.allShapes,s=e.allConnections,c=e.enclosedConnections,p=e.topLevel,l=!1;r&&r.parent===n&&(l=!0),b(a,(function(e){o.moveShape(e,t,p[e.id]&&!l&&n,{recurse:!1,layout:!1})})),b(s,(function(e){var i=!!a[e.source.id],r=!!a[e.target.id];c[e.id]&&i&&r?o.moveConnection(e,t,p[e.id]&&!l&&n):o.layoutConnection(e,{connectionStart:i&&ch(e,e.source,t),connectionEnd:r&&ph(e,e.target,t)})}))},Lf.prototype.getClosure=function(e){return(new jf).addAll(e,!0)},If.$inject=["modeling"],If.prototype.preExecute=function(e){e.closure=this._helper.getClosure(e.shapes)},If.prototype.postExecute=function(e){var t,n=e.hints;n&&n.primaryShape&&(t=n.primaryShape,n.oldParent=t.parent),this._helper.moveClosure(e.closure,e.delta,e.newParent,e.newHost,t)},zf.$inject=["modeling"],zf.prototype.execute=function(e){var t=e.shape,n=e.delta,i=e.newParent||t.parent,r=e.newParentIndex,o=t.parent;return e.oldBounds=$(t,["x","y","width","height"]),e.oldParent=o,e.oldParentIndex=mt(o.children,t),vt(i.children,t,r),F(t,{parent:i,x:t.x+n.x,y:t.y+n.y}),t},zf.prototype.postExecute=function(e){var t=e.shape,n=e.delta,i=e.hints,r=this._modeling;!1!==i.layout&&(b(t.incoming,(function(e){r.layoutConnection(e,{connectionEnd:ph(e,t,n)})})),b(t.outgoing,(function(e){r.layoutConnection(e,{connectionStart:ch(e,t,n)})}))),!1!==i.recurse&&this.moveChildren(e)},zf.prototype.revert=function(e){var t=e.shape,n=e.oldParent,i=e.oldParentIndex,r=e.delta;return vt(n.children,t,i),F(t,{parent:n,x:t.x-r.x,y:t.y-r.y}),t},zf.prototype.moveChildren=function(e){var t=e.delta,n=e.shape;this._helper.moveRecursive(n.children,t,null)},zf.prototype.getNewParent=function(e){return e.newParent||e.shape.parent},Ff.$inject=["modeling"],Ff.prototype.execute=function(e){var t=e.newSource,n=e.newTarget,i=e.connection,r=e.dockingOrPoints;if(!t&&!n)throw new Error("newSource or newTarget required");return u(r)&&(e.oldWaypoints=i.waypoints,i.waypoints=r),t&&(e.oldSource=i.source,i.source=t),n&&(e.oldTarget=i.target,i.target=n),i},Ff.prototype.postExecute=function(e){var t=e.connection,n=e.newSource,i=e.newTarget,r=e.dockingOrPoints,o=e.hints||{},a={};o.connectionStart&&(a.connectionStart=o.connectionStart),o.connectionEnd&&(a.connectionEnd=o.connectionEnd),!1!==o.layoutConnection&&(!n||i&&"source"!==o.docking||(a.connectionStart=a.connectionStart||$f(u(r)?r[0]:r)),!i||n&&"target"!==o.docking||(a.connectionEnd=a.connectionEnd||$f(u(r)?r[r.length-1]:r)),o.newWaypoints&&(a.waypoints=o.newWaypoints),this._modeling.layoutConnection(t,a))},Ff.prototype.revert=function(e){var t=e.oldSource,n=e.oldTarget,i=e.oldWaypoints,r=e.connection;return t&&(r.source=t),n&&(r.target=n),i&&(r.waypoints=i),r},Hf.$inject=["modeling","rules"],Hf.prototype.preExecute=function(e){var t,n=this,i=this._modeling,r=this._rules,o=e.oldShape,a=e.newData,s=e.hints||{};function c(e,t,n){return r.allowed("connection.reconnect",{connection:n,source:e,target:t})}var p,l={x:a.x,y:a.y},u={x:o.x,y:o.y,width:o.width,height:o.height};t=e.newShape=e.newShape||n.createShape(a,l,o.parent,s),o.host&&i.updateAttachment(t,o.host),!1!==s.moveChildren&&(p=o.children.slice(),i.moveElements(p,{x:0,y:0},t,s));var h=o.incoming.slice(),d=o.outgoing.slice();b(h,(function(e){c(e.source,t,e)&&n.reconnectEnd(e,t,sh(e,t,u),s)})),b(d,(function(e){var i=e.target;c(t,i,e)&&n.reconnectStart(e,t,ah(e,t,u),s)}))},Hf.prototype.postExecute=function(e){var t=e.oldShape;this._modeling.removeShape(t)},Hf.prototype.execute=function(e){},Hf.prototype.revert=function(e){},Hf.prototype.createShape=function(e,t,n,i){return this._modeling.createShape(e,t,n,i)},Hf.prototype.reconnectStart=function(e,t,n,i){this._modeling.reconnectStart(e,t,n,i)},Hf.prototype.reconnectEnd=function(e,t,n,i){this._modeling.reconnectEnd(e,t,n,i)},Gf.$inject=["modeling"],Gf.prototype.execute=function(e){var t=e.shape,n=e.newBounds,i=e.minBounds;if(void 0===n.x||void 0===n.y||void 0===n.width||void 0===n.height)throw new Error("newBounds must have {x, y, width, height} properties");if(i&&(n.width<i.width||n.height<i.height))throw new Error("width and height cannot be less than minimum height and width");if(!i&&n.width<10||n.height<10)throw new Error("width and height cannot be less than 10px");return e.oldBounds={width:t.width,height:t.height,x:t.x,y:t.y},F(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Gf.prototype.postExecute=function(e){var t=this._modeling,n=e.shape,i=e.oldBounds;!1!==(e.hints||{}).layout&&(b(n.incoming,(function(e){t.layoutConnection(e,{connectionEnd:sh(e,n,i)})})),b(n.outgoing,(function(e){t.layoutConnection(e,{connectionStart:ah(e,n,i)})})))},Gf.prototype.revert=function(e){var t=e.shape,n=e.oldBounds;return F(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Wf.$inject=["modeling"],Wf.prototype.preExecute=function(e){var t=e.delta,n=e.direction,i=e.movingShapes,r=e.resizingShapes,o=e.start,a={};this.moveShapes(i,t),b(r,(function(e){a[e.id]=function(e){return{x:e.x,y:e.y,height:e.height,width:e.width}}(e)})),this.resizeShapes(r,t,n),this.updateConnectionWaypoints(function(e,t){var n=[];return b(e.concat(t),(function(i){var r=i.incoming,o=i.outgoing;b(r.concat(o),(function(i){var r=i.source,o=i.target;(Kd(e,r)||Kd(e,o)||Kd(t,r)||Kd(t,o))&&(Kd(n,i)||n.push(i))}))})),n}(i,r),t,n,o,i,r,a)},Wf.prototype.execute=function(){},Wf.prototype.revert=function(){},Wf.prototype.moveShapes=function(e,t){var n=this;b(e,(function(e){n._modeling.moveShape(e,t,null,{autoResize:!1,layout:!1,recurse:!1})}))},Wf.prototype.resizeShapes=function(e,t,n){var i=this;b(e,(function(e){var r=function(e,t,n){var i=e.x,r=e.y,o=e.width,a=e.height,s=n.x,c=n.y;switch(t){case"n":return{x:i,y:r+c,width:o,height:a-c};case"s":return{x:i,y:r,width:o,height:a+c};case"w":return{x:i+s,y:r,width:o-s,height:a};case"e":return{x:i,y:r,width:o+s,height:a};default:throw new Error("unknown direction: "+t)}}(e,n,t);i._modeling.resizeShape(e,r,null,{attachSupport:!1,autoResize:!1,layout:!1})}))},Wf.prototype.updateConnectionWaypoints=function(e,t,n,i,r,o,a){var s=this,c=r.concat(o);b(e,(function(e){var p=e.source,l=e.target,u=function(e){return S(e.waypoints,(function(e){return(e=Vf(e)).original&&(e.original=Vf(e.original)),e}))}(e),h=Uf(n),d={labelBehavior:!1};Kf(c,p)&&Kf(c,l)?(u=S(u,(function(e){return qf(e,i,n)&&(e[h]=e[h]+t[h]),e.original&&qf(e.original,i,n)&&(e.original[h]=e.original[h]+t[h]),e})),s._modeling.updateWaypoints(e,u,{labelBehavior:!1})):(Kf(c,p)||Kf(c,l))&&(Kf(r,p)?d.connectionStart=ch(e,p,t):Kf(r,l)?d.connectionEnd=ph(e,l,t):Kf(o,p)?d.connectionStart=ah(e,p,a[p.id]):Kf(o,l)&&(d.connectionEnd=sh(e,l,a[l.id])),s._modeling.layoutConnection(e,d))}))},Yf.$inject=["modeling"],Yf.prototype.execute=function(e){var t=e.shape,n=t.children;e.oldChildrenVisibility=Xf(n),t.collapsed=!t.collapsed;var i=Zf(n,t.collapsed);return[t].concat(i)},Yf.prototype.revert=function(e){var t=e.shape,n=e.oldChildrenVisibility,i=Qf(t.children,n);return t.collapsed=!t.collapsed,[t].concat(i)},Jf.$inject=["modeling"],Jf.prototype.execute=function(e){var t=e.shape,n=e.newHost,i=t.host;return e.oldHost=i,e.attacherIdx=em(i,t),tm(n,t),t.host=n,t},Jf.prototype.revert=function(e){var t=e.shape,n=e.newHost,i=e.oldHost,r=e.attacherIdx;return t.host=i,em(n,t),tm(i,t,r),t},nm.prototype.execute=function(e){var t=e.connection,n=e.newWaypoints;return e.oldWaypoints=t.waypoints,t.waypoints=n,t},nm.prototype.revert=function(e){var t=e.connection,n=e.oldWaypoints;return t.waypoints=n,t},im.$inject=["eventBus","elementFactory","commandStack"],im.prototype.getHandlers=function(){return{"shape.append":bf,"shape.create":Cf,"shape.delete":Mf,"shape.move":zf,"shape.resize":Gf,"shape.replace":Hf,"shape.toggleCollapse":Yf,spaceTool:Wf,"label.create":Tf,"connection.create":xf,"connection.delete":Af,"connection.move":Of,"connection.layout":Nf,"connection.updateWaypoints":nm,"connection.reconnect":Ff,"elements.create":Ef,"elements.move":If,"elements.delete":kf,"elements.distribute":Df,"elements.align":gf,"element.updateAttachment":Jf}},im.prototype.registerHandlers=function(e){b(this.getHandlers(),(function(t,n){e.registerHandler(n,t)}))},im.prototype.moveShape=function(e,t,n,i,r){"object"==typeof i&&(r=i,i=null);var o={shape:e,delta:t,newParent:n,newParentIndex:i,hints:r||{}};this._commandStack.execute("shape.move",o)},im.prototype.updateAttachment=function(e,t){var n={shape:e,newHost:t};this._commandStack.execute("element.updateAttachment",n)},im.prototype.moveElements=function(e,t,n,i){var r,o=(i=i||{}).attach,a=n;!0===o?(r=n,a=n.parent):!1===o&&(r=null);var s={shapes:e,delta:t,newParent:a,newHost:r,hints:i};this._commandStack.execute("elements.move",s)},im.prototype.moveConnection=function(e,t,n,i,r){"object"==typeof i&&(r=i,i=void 0);var o={connection:e,delta:t,newParent:n,newParentIndex:i,hints:r||{}};this._commandStack.execute("connection.move",o)},im.prototype.layoutConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.layout",n)},im.prototype.createConnection=function(e,t,n,i,r,o){"object"==typeof n&&(o=r,r=i,i=n,n=void 0);var a={source:e,target:t,parent:r,parentIndex:n,connection:i=this._create("connection",i),hints:o};return this._commandStack.execute("connection.create",a),a.connection},im.prototype.createShape=function(e,t,n,i,r){"number"!=typeof i&&(r=i,i=void 0);var o,a,s=(r=r||{}).attach;e=this._create("shape",e),s?(o=n.parent,a=n):o=n;var c={position:t,shape:e,parent:o,parentIndex:i,host:a,hints:r};return this._commandStack.execute("shape.create",c),c.shape},im.prototype.createElements=function(e,t,n,i,r){u(e)||(e=[e]),"number"!=typeof i&&(r=i,i=void 0);var o={position:t,elements:e,parent:n,parentIndex:i,hints:r=r||{}};return this._commandStack.execute("elements.create",o),o.elements},im.prototype.createLabel=function(e,t,n,i){n=this._create("label",n);var r={labelTarget:e,position:t,parent:i||e.parent,shape:n};return this._commandStack.execute("label.create",r),r.shape},im.prototype.appendShape=function(e,t,n,i,r){r=r||{};var o={source:e,position:n,target:i,shape:t=this._create("shape",t),connection:r.connection,connectionParent:r.connectionParent,hints:r};return this._commandStack.execute("shape.append",o),o.shape},im.prototype.removeElements=function(e){var t={elements:e};this._commandStack.execute("elements.delete",t)},im.prototype.distributeElements=function(e,t,n){var i={groups:e,axis:t,dimension:n};this._commandStack.execute("elements.distribute",i)},im.prototype.removeShape=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.delete",n)},im.prototype.removeConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.delete",n)},im.prototype.replaceShape=function(e,t,n){var i={oldShape:e,newData:t,hints:n||{}};return this._commandStack.execute("shape.replace",i),i.newShape},im.prototype.alignElements=function(e,t){var n={elements:e,alignment:t};this._commandStack.execute("elements.align",n)},im.prototype.resizeShape=function(e,t,n,i){var r={shape:e,newBounds:t,minBounds:n,hints:i};this._commandStack.execute("shape.resize",r)},im.prototype.createSpace=function(e,t,n,i,r){var o={delta:n,direction:i,movingShapes:e,resizingShapes:t,start:r};this._commandStack.execute("spaceTool",o)},im.prototype.updateWaypoints=function(e,t,n){var i={connection:e,newWaypoints:t,hints:n||{}};this._commandStack.execute("connection.updateWaypoints",i)},im.prototype.reconnect=function(e,t,n,i,r){var o={connection:e,newSource:t,newTarget:n,dockingOrPoints:i,hints:r||{}};this._commandStack.execute("connection.reconnect",o)},im.prototype.reconnectStart=function(e,t,n,i){i||(i={}),this.reconnect(e,t,e.target,n,F(i,{docking:"source"}))},im.prototype.reconnectEnd=function(e,t,n,i){i||(i={}),this.reconnect(e,e.source,t,n,F(i,{docking:"target"}))},im.prototype.connect=function(e,t,n,i){return this.createConnection(e,t,n||{},e.parent,i)},im.prototype._create=function(e,t){return t instanceof Bn?t:this._elementFactory.create(e,t)},im.prototype.toggleCollapse=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.toggleCollapse",n)},rm.$inject=["elementRegistry"],rm.prototype.execute=function(e){var t=e.element,n=e.moddleElement,i=e.properties;if(!n)throw new Error("<moddleElement> required");var r=e.changed||this.getVisualReferences(n).concat(t),o=e.oldProperties||function(e,t){return _(t,(function(t,n){return t[n]=e.get(n),t}),{})}(n,C(i));return om(n,i),e.oldProperties=o,e.changed=r,r},rm.prototype.revert=function(e){var t=e.oldProperties,n=e.moddleElement,i=e.changed;return om(n,t),i},rm.prototype.getVisualReferences=function(e){var t=this._elementRegistry;return Ar(e,"bpmn:DataObject")?function(e,t){return t.filter((function(t){return Ar(t,"bpmn:DataObjectReference")&&kr(t).dataObjectRef===e}))}(e,t):[]};var am="default",sm="id",cm="di",pm={width:0,height:0};function lm(e,t,n,i,r){this._elementRegistry=e,this._moddle=t,this._translate=n,this._modeling=i,this._textRenderer=r}function um(e,t){return sm in e&&e.id!==t.id}function hm(e,t){b(t,(function(t,n){n!==cm?e.set(n,t):e.di&&function(e,t){b(t,(function(t,n){e.set(n,t)}))}(e.di,t)}))}lm.$inject=["elementRegistry","moddle","translate","modeling","textRenderer"],lm.prototype.execute=function(e){var t=e.element,n=[t],i=this._translate;if(!t)throw new Error(i("element required"));var r=this._elementRegistry,o=this._moddle.ids,a=t.businessObject,s=function(e){var t=F({},e);return dm.forEach((function(n){n in e&&(t[n]=kr(t[n]))})),t}(e.properties),c=e.oldProperties||function(e,t){return _(C(t),(function(n,i){return n[i]=i!==cm?e.get(i):function(e,t){return _(t,(function(t,n){return t[n]=e.get(n),t}),{})}(e.di,C(t.di)),n}),{})}(a,s);return um(s,a)&&(o.unclaim(a.id),r.updateId(t,s.id),o.claim(s.id,a)),am in s&&(s.default&&n.push(r.get(s.default.id)),a.default&&n.push(r.get(a.default.id))),hm(a,s),e.oldProperties=c,e.changed=n,n},lm.prototype.postExecute=function(e){var t=e.element.label,n=t&&kr(t).name;if(n){var i=this._textRenderer.getExternalLabelBounds(t,n);this._modeling.resizeShape(t,i,pm)}},lm.prototype.revert=function(e){var t=e.element,n=e.properties,i=e.oldProperties,r=t.businessObject,o=this._elementRegistry,a=this._moddle.ids;return hm(r,i),um(n,r)&&(a.unclaim(n.id),o.updateId(t,i.id),a.claim(i.id,r)),e.changed};var dm=["default"];function fm(e,t){this._canvas=e,this._modeling=t}function mm(e,t){this._modeling=e,this._spaceTool=t}function vm(e,t){this._modeling=e,this._translate=t}function ym(e,t){this._modeling=e,this._spaceTool=t}fm.$inject=["canvas","modeling"],fm.prototype.execute=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,r=t.getRootElement(),o=r.businessObject,a=o.$parent,s=o.di;t.setRootElement(n,!0),vt(a.rootElements,i),i.$parent=a,mt(a.rootElements,o),o.$parent=null,o.di=null,s.bpmnElement=i,i.di=s,e.oldRoot=r},fm.prototype.revert=function(e){var t=this._canvas,n=e.newRoot.businessObject,i=e.oldRoot,r=i.businessObject,o=n.$parent,a=n.di;t.setRootElement(i,!0),mt(o.rootElements,n),n.$parent=null,vt(o.rootElements,r),r.$parent=o,n.di=null,a.bpmnElement=r,r.di=a},mm.$inject=["modeling","spaceTool"],mm.prototype.preExecute=function(e){var t=this._spaceTool,n=this._modeling,i=e.shape,r=e.location,o=Wp(i),a=o===i,s=a?i:i.parent;Gp(s).length||n.createShape({type:"bpmn:Lane"},{x:i.x+$p,y:i.y,width:i.width-$p,height:i.height},s);var c=[];st(o,(function(e){return c.push(e),e.label&&c.push(e.label),e===i?[]:g(e.children,(function(e){return e!==i}))}));var p="top"===r?-120:120,l="top"===r?i.y:i.y+i.height,u=l+("top"===r?10:-10),h="top"===r?"n":"s",d=t.calculateAdjustments(c,"y",p,u);t.makeSpace(d.movingShapes,d.resizingShapes,{x:0,y:p},h,u),e.newLane=n.createShape({type:"bpmn:Lane"},{x:i.x+(a?$p:0),y:l-("top"===r?120:0),width:i.width-(a?$p:0),height:120},s)},vm.$inject=["modeling","translate"],vm.prototype.preExecute=function(e){var t=this._modeling,n=this._translate,i=e.shape,r=e.count,o=Gp(i),a=o.length;if(a>r)throw new Error(n("more than {count} child lanes",{count:r}));var s,c,p,l,u,h=Math.round(i.height/r);for(u=0;u<r;u++)s=i.y+u*h,c=u===r-1?i.height-h*u:h,p={x:i.x+$p,y:s,width:i.width-$p,height:c},u<a?t.resizeShape(o[u],p):(l={type:"bpmn:Lane"},t.createShape(l,p,i))},ym.$inject=["modeling","spaceTool"],ym.prototype.preExecute=function(e){var t=e.shape,n=e.newBounds;!1!==e.balanced?this.resizeBalanced(t,n):this.resizeSpace(t,n)},ym.prototype.resizeBalanced=function(e,t){var n=this._modeling,i=Vp(e,t);n.resizeShape(e,t),i.forEach((function(e){n.resizeShape(e.shape,e.newBounds)}))},ym.prototype.resizeSpace=function(e,t){var n,i,r,o,a,s=this._spaceTool,c=an(e),p=Np(an(t),c),l=Wp(e),u=[],h=[];st(l,(function(e){return u.push(e),(Ar(e,"bpmn:Lane")||Ar(e,"bpmn:Participant"))&&h.push(e),e.children})),(p.bottom||p.top)&&(n=p.bottom||p.top,i=e.y+(p.bottom?e.height:0)+(p.bottom?-10:10),r=p.bottom?"s":"n",o=p.top>0||p.bottom<0?-n:n,a=s.calculateAdjustments(u,"y",o,i),s.makeSpace(a.movingShapes,a.resizingShapes,{x:0,y:n},r)),(p.left||p.right)&&(n=p.right||p.left,i=e.x+(p.right?e.width:0)+(p.right?-10:100),r=p.right?"e":"w",o=p.left>0||p.right<0?-n:n,a=s.calculateAdjustments(h,"x",o,i),s.makeSpace(a.movingShapes,a.resizingShapes,{x:n,y:0},r))};var gm="flowNodeRef",bm="lanes";function xm(e){this._elementRegistry=e}function _m(e){this._moddle=e}xm.$inject=["elementRegistry"],xm.prototype.computeUpdates=function(e,t){var n=[],i=[],r={},o=[];function a(e){-1===n.indexOf(e)&&(o.push(e),n.push(e))}function s(e){return e.parent?function(e){var t=Wp(e);return r[t.id]||(r[t.id]=Hp(t)),r[t.id]}(e).filter((function(t){return n=e,i=an(t),r=n.x+n.width/2,o=n.y+n.height/2,r>i.left&&r<i.right&&o>i.top&&o<i.bottom;var n,i,r,o})).map((function(e){return e.businessObject})):[]}return t.forEach((function(e){var t=Wp(e);t&&-1===n.indexOf(t)&&(t.children.filter((function(e){return Ar(e,"bpmn:FlowNode")})).forEach(a),n.push(t))})),e.forEach(a),o.forEach((function(e){var t=e.businessObject,n=t.get(bm).slice(),r=s(e);i.push({flowNode:t,remove:n,add:r})})),t.forEach((function(e){var t=e.businessObject;e.parent||t.get(gm).forEach((function(e){i.push({flowNode:e,remove:[t],add:[]})}))})),i},xm.prototype.execute=function(e){var t=e.updates;t||(t=e.updates=this.computeUpdates(e.flowNodeShapes,e.laneShapes)),t.forEach((function(e){var t=e.flowNode,n=t.get(bm);e.remove.forEach((function(e){mt(n,e),mt(e.get(gm),t)})),e.add.forEach((function(e){vt(n,e),vt(e.get(gm),t)}))}))},xm.prototype.revert=function(e){e.updates.forEach((function(e){var t=e.flowNode,n=t.get(bm);e.add.forEach((function(e){mt(n,e),mt(e.get(gm),t)})),e.remove.forEach((function(e){vt(n,e),vt(e.get(gm),t)}))}))},_m.$inject=["moddle"],_m.prototype.execute=function(e){var t=this._moddle.ids,n=e.id,i=e.element;e.claiming?t.claim(n,i):t.unclaim(n)},_m.prototype.revert=function(e){var t=this._moddle.ids,n=e.id,i=e.element;e.claiming?t.unclaim(n):t.claim(n,i)};var Em={fill:void 0,stroke:void 0};function wm(e){this._commandStack=e,this._normalizeColor=function(e){if(e){if(m(e)){var t=function(e){var t=document.createElement("canvas").getContext("2d");return t.fillStyle="transparent",t.fillStyle=e,/^#[0-9a-fA-F]{6}$/.test(t.fillStyle)?t.fillStyle:null}(e);if(t)return t}throw new Error("invalid color value: "+e)}}}wm.$inject=["commandStack"],wm.prototype.postExecute=function(e){var t=e.elements,n=e.colors||Em,i=this,r={};"fill"in n&&F(r,{"background-color":this._normalizeColor(n.fill)}),"stroke"in n&&F(r,{"border-color":this._normalizeColor(n.stroke)}),b(t,(function(e){var t=function(e){return!!e.waypoints}(e)?$(r,["border-color"]):r;!function(e){"border-color"in e&&(e.stroke=e["border-color"]);"background-color"in e&&(e.fill=e["background-color"])}(t),e.labelTarget?i._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:e.businessObject.di.label,properties:{color:r["background-color"]}}):i._commandStack.execute("element.updateProperties",{element:e,properties:{di:t}})}))};var Sm={width:0,height:0};function Cm(e,t){function n(e,t){var n=e.label||e,i=e.labelTarget||e;return function(e,t,n){var i=e.businessObject,r=Nr(i);r&&("categoryValueRef"===r?i.categoryValueRef.value=t:i[r]=t)}(n,t),[n,i]}this.preExecute=function(t){var n=t.element,i=n.businessObject,r=t.newLabel;if(!so(n)&&io(n)&&!ro(n)&&!Tm(r)){var o=ao(n);o={x:o.x,y:o.y+7},e.createLabel(n,o,{id:i.id+"_label",businessObject:i})}},this.execute=function(e){return e.oldLabel=Or(e.element),n(e.element,e.newLabel)},this.revert=function(e){return n(e.element,e.oldLabel)},this.postExecute=function(n){var i=n.element,r=i.label||i,o=n.newLabel,a=n.newBounds,s=n.hints||{};if(so(r)||Ar(r,"bpmn:TextAnnotation"))if(so(r)&&Tm(o))!1!==s.removeShape&&e.removeShape(r,{unsetLabel:!1});else{var c=Or(r);void 0===a&&(a=t.getExternalLabelBounds(r,c)),a&&e.resizeShape(r,a,Sm)}}}function Tm(e){return!e||!e.trim()}function Rm(e,t,n,i){im.call(this,e,t,n),this._bpmnRules=i}function Pm(){}Cm.$inject=["modeling","textRenderer"],n(Rm,im),Rm.$inject=["eventBus","elementFactory","commandStack","bpmnRules"],Rm.prototype.getHandlers=function(){var e=im.prototype.getHandlers.call(this);return e["element.updateModdleProperties"]=rm,e["element.updateProperties"]=lm,e["canvas.updateRoot"]=fm,e["lane.add"]=mm,e["lane.resize"]=ym,e["lane.split"]=vm,e["lane.updateRefs"]=xm,e["id.updateClaim"]=_m,e["element.setColor"]=wm,e["element.updateLabel"]=Cm,e},Rm.prototype.updateLabel=function(e,t,n,i){this._commandStack.execute("element.updateLabel",{element:e,newLabel:t,newBounds:n,hints:i||{}})},Rm.prototype.connect=function(e,t,n,i){var r=this._bpmnRules;if(n||(n=r.canConnect(e,t)),n)return this.createConnection(e,t,n,e.parent,i)},Rm.prototype.updateModdleProperties=function(e,t,n){this._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:t,properties:n})},Rm.prototype.updateProperties=function(e,t){this._commandStack.execute("element.updateProperties",{element:e,properties:t})},Rm.prototype.resizeLane=function(e,t,n){this._commandStack.execute("lane.resize",{shape:e,newBounds:t,balanced:n})},Rm.prototype.addLane=function(e,t){var n={shape:e,location:t};return this._commandStack.execute("lane.add",n),n.newLane},Rm.prototype.splitLane=function(e,t){this._commandStack.execute("lane.split",{shape:e,count:t})},Rm.prototype.makeCollaboration=function(){var e=this._create("root",{type:"bpmn:Collaboration"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},Rm.prototype.updateLaneRefs=function(e,t){this._commandStack.execute("lane.updateRefs",{flowNodeShapes:e,laneShapes:t})},Rm.prototype.makeProcess=function(){var e={newRoot:this._create("root",{type:"bpmn:Process"})};this._commandStack.execute("canvas.updateRoot",e)},Rm.prototype.claimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t,claiming:!0})},Rm.prototype.unclaimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t})},Rm.prototype.setColor=function(e,t){e.length||(e=[e]),this._commandStack.execute("element.setColor",{elements:e,colors:t})},Pm.prototype.layoutConnection=function(e,t){return[(t=t||{}).connectionStart||cn(t.source||e.source),t.connectionEnd||cn(t.target||e.target)]};var Am=Math.round,km={"h:h":20,"v:v":20,"h:v":-10,"v:h":-10};function Mm(e,t,n){var i,r,o,a=pn(t,e,5),s=n.split(":")[0],c=Am((t.x-e.x)/2+e.x),p=Am((t.y-e.y)/2+e.y),l=(o=a,{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/left|right/,v:/top|bottom/}[s].test(o)),u=/h|r|l/.test(s),h=!1;return l?(i=u?{x:c,y:e.y}:{x:e.x,y:p},r=u?"h:h":"v:v"):(r=u?"h:v":"v:h",function(e,t){return!{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/./,v:/./}[t].test(e)}(a,s)?u?(h=p===e.y,i={x:e.x+20*(/l/.test(s)?-1:1),y:h?p+20:p}):i={x:(h=c===e.x)?c+20:c,y:e.y+20*(/t/.test(s)?-1:1)}:i={x:c,y:p}),{waypoints:Bm(e,i,r).concat(i),directions:r,turnNextDirections:h}}function Dm(e){return e.split(":").reverse().join(":")}function Bm(e,t,n){if(!function(e){return e&&/^h|v|t|r|b|l:h|v|t|r|b|l$/.test(e)}(n=n||"h:h"))throw new Error("unknown directions: <"+n+">: must be specified as <start>:<end> with start/end in { h,v,t,r,b,l }");if(Im(n)){var i=function(e,t,n){return Mm(e,t,n)}(e,t,n),r=function(e,t,n){var i=Mm(t,e,Dm(n));return{waypoints:i.waypoints.slice().reverse(),directions:Dm(i.directions),turnNextDirections:i.turnNextDirections}}(e,t,n),o=function(e,t){var n=e.directions.split(":")[1],i=t.directions.split(":")[0];e.turnNextDirections&&(n="h"==n?"v":"h"),t.turnNextDirections&&(i="h"==i?"v":"h");var r=n+":"+i;return{waypoints:Bm(e.waypoints[e.waypoints.length-1],t.waypoints[0],r),directions:r}}(i,r);return[].concat(i.waypoints,o.waypoints,r.waypoints)}return function(e,t,n){var i=Am((t.x-e.x)/2+e.x),r=Am((t.y-e.y)/2+e.y);if("h:v"===n)return[{x:t.x,y:e.y}];if("v:h"===n)return[{x:e.x,y:t.y}];if("h:h"===n)return[{x:i,y:e.y},{x:i,y:t.y}];if("v:v"===n)return[{x:e.x,y:r},{x:t.x,y:r}];throw new Error("invalid directions: can only handle varians of [hv]:[hv]")}(e,t,n)}function Nm(e,t,n,i,r){var o=x(r&&r.preferredLayouts||[],"straight")[0]||"h:h",a=pn(e,t,km[o]||0),s=function(e,t){if(Im(t))return t;switch(e){case"intersect":return"t:t";case"top":case"bottom":return"v:v";case"left":case"right":return"h:h";default:return t}}(a,o);n=n||cn(e),i=i||cn(t);var c=s.split(":");return function(e,t,n){var i=Bm(e,t,n);return i.unshift(e),i.push(t),Fm(i)}(zm(n,e,c[0],function(e){return{top:"bottom",bottom:"top",left:"right",right:"left","top-left":"bottom-right","bottom-right":"top-left","top-right":"bottom-left","bottom-left":"top-right"}[e]}(a)),zm(i,t,c[1],a),s)}function Om(e,t,n,i,r,o){var a;return u(n)&&(r=n,o=i,n=cn(e),i=cn(t)),r=r||[],(a=-1!==(o=F({preferredLayouts:[]},o)).preferredLayouts.indexOf("straight")&&function(e,t,n,i,r){var o,a,s={};if(a=pn(e,t),!/^(top|bottom|left|right)$/.test(a))return null;/top|bottom/.test(a)&&(o="x");/left|right/.test(a)&&(o="y");return"target"===r.preserveDocking?jm(o,i,e)?(s[o]=i[o],[{x:void 0!==s.x?s.x:n.x,y:void 0!==s.y?s.y:n.y,original:{x:void 0!==s.x?s.x:n.x,y:void 0!==s.y?s.y:n.y}},{x:i.x,y:i.y}]):null:jm(o,n,t)?(s[o]=n[o],[{x:n.x,y:n.y},{x:void 0!==s.x?s.x:i.x,y:void 0!==s.y?s.y:i.y,original:{x:void 0!==s.x?s.x:i.x,y:void 0!==s.y?s.y:i.y}}]):null}(e,t,n,i,o))||(a=o.connectionEnd&&function(e,t,n,i){var r=i.slice().reverse();return(r=Lm(e,t,n,r))?r.reverse():null}(t,e,i,r))?a:(a=o.connectionStart&&Lm(e,t,n,r))||(!o.connectionStart&&!o.connectionEnd&&r&&r.length?r:Nm(e,t,n,i,o))}function jm(e,t,n){return function(e,t,n){return e>=t&&e<=n}(t[e],n[e],n[e]+n[{x:"width",y:"height"}[e]])}function Lm(e,t,n,i){if(function(e){return e.length<3||!(e.length>4)&&!!y(e,(function(t,n){var i=e[n-1];return i&>(t,i)<3}))}(i))return null;var r,o=i[0],a=i.slice();return a[0]=n,a[1]=function(e,t,n){switch(xt(t,e)){case"v":return{x:n.x,y:e.y};case"h":return{x:e.x,y:n.y}}return{x:e.x,y:e.y}}(a[1],o,n),(r=function(e,t,n){var i;for(i=e.length-2;0!==i;i--)if(_t(e[i],t,20)||_t(e[i],n,20))return e.slice(i);return e}(a,e,t))!==a&&(a=Lm(e,t,n,r)),a&&xt(a)?null:a}function Im(e){return e&&/t|r|b|l/.test(e)}function zm(e,t,n,i){if("h"===n&&(n=/left/.test(i)?"l":"r"),"v"===n&&(n=/top/.test(i)?"t":"b"),"t"===n)return{original:e,x:e.x,y:t.y};if("r"===n)return{original:e,x:t.x+t.width,y:e.y};if("b"===n)return{original:e,x:e.x,y:t.y+t.height};if("l"===n)return{original:e,x:t.x,y:e.y};throw new Error("unexpected dockingDirection: <"+n+">")}function Fm(e){return e.reduce((function(t,n,i){return bt(t[t.length-1],e[i+1],n,0)||t.push(n),t}),[])}var $m={top:"bottom","top-right":"bottom-left","top-left":"bottom-right",right:"left",bottom:"top","bottom-right":"top-left","bottom-left":"top-right",left:"right"},Hm={top:"t",right:"r",bottom:"b",left:"l"};function Gm(){}function Wm(e,t){return Ar(t,"bpmn:Participant")?"source":Ar(e,"bpmn:Participant")?"target":Km(t)?"source":Km(e)||Ar(t,"bpmn:Event")?"target":Ar(e,"bpmn:Event")?"source":null}function Vm(e){return Km(e)?"target":"source"}function Um(e,t){return e?e.original||e:cn(t)}function qm(e,t){return Ar(t,"bpmn:Activity")&&Ar(e,"bpmn:BoundaryEvent")&&t.businessObject.isForCompensation}function Km(e){return Ar(e,"bpmn:SubProcess")&&Mr(e)}function Ym(e,t){return e===t}function Xm(e){var t=/right|left/.exec(e);return t&&t[0]}function Zm(e){var t=/top|bottom/.exec(e);return t&&t[0]}function Qm(e){return"right"===e||"left"===e}function Jm(e,t){var n=t.waypoints,i=n&&n.length&&pn(n[0],e);return"top"===i?["t:r"]:"right"===i?["r:b"]:"left"===i?["l:t"]:["b:l"]}function ev(e,t,n){var i,r,o=cn(e),a=cn(t),s=(r=(i=e).host,pn(cn(i),r,-10)),c=Ym(e.host,t),p=-1!==["top","right","bottom","left"].indexOf(s),l=pn(a,o,{x:e.width/2+t.width/2,y:e.height/2+t.height/2});return c?function(e,t,n,i,r){var o,a=t?e:Zm(e),s=Hm[a];o=t?Qm(e)?tv("y",n,i,r)?"h":"b":tv("x",n,i,r)?"v":"l":"v";return[s+":"+o]}(s,p,e,t,n):[function(e,t,n){if(n)return Hm[e];if(Ym(Zm(e),Zm(t))||(i=Xm(e),r=Xm(t),$m[i]===r))return Hm[Zm(e)];var i,r;return Hm[Xm(e)]}(s,l,p)+":"+function(e,t,n){if(n)return Qm(e)?(i=t,r=Xm(e),o=$m[r],-1!==i.indexOf(o)||Ym(e,t)?"h":"v"):function(e,t){var n=Zm(e),i=$m[n];return-1!==t.indexOf(i)}(e,t)||Ym(e,t)?"v":"h";var i,r,o;return Qm(t)||Ym(Zm(e),Zm(t))&&Xm(t)?"h":"v"}(s,l,p)]}function tv(e,t,n,i){return!(nv(e,i,n,40)||nv(e,i,{x:n.x+n.width,y:n.y+n.height},40)||nv(e,i,cn(t),40))}function nv(e,t,n,i){return Math.abs(t[e]-n[e])<i}function iv(e){return F({original:e.point.original||e.point},e.actual)}function rv(e,t){this._elementRegistry=e,this._graphicsFactory=t}n(Gm,Pm),Gm.prototype.layoutConnection=function(e,t){t||(t={});var n,i,r=t.source||e.source,o=t.target||e.target,a=t.waypoints||e.waypoints,s=t.connectionStart,c=t.connectionEnd;return s||(s=Um(a&&a[0],r)),c||(c=Um(a&&a[a.length-1],o)),(Ar(e,"bpmn:Association")||Ar(e,"bpmn:DataAssociation"))&&a&&!qm(r,o)?[].concat([s],a.slice(1,-1),[c]):(Ar(e,"bpmn:MessageFlow")?n=function(e,t){return{preferredLayouts:["straight","v:v"],preserveDocking:Wm(e,t)}}(r,o):(Ar(e,"bpmn:SequenceFlow")||qm(r,o))&&(n=r===o?{preferredLayouts:Jm(r,e)}:Ar(r,"bpmn:BoundaryEvent")?{preferredLayouts:ev(r,o,c)}:Km(r)||Km(o)?function(e){return{preferredLayouts:["straight","h:h"],preserveDocking:Vm(e)}}(r):Ar(r,"bpmn:Gateway")?{preferredLayouts:["v:h"]}:Ar(o,"bpmn:Gateway")?{preferredLayouts:["h:v"]}:{preferredLayouts:["h:h"]}),n&&(i=Fm(Om(r,o,s,c,a,n=F(n,t)))),i||[s,c])},rv.$inject=["elementRegistry","graphicsFactory"],rv.prototype.getCroppedWaypoints=function(e,t,n){t=t||e.source,n=n||e.target;var i=this.getDockingPoint(e,t,!0),r=this.getDockingPoint(e,n),o=e.waypoints.slice(i.idx+1,r.idx);return o.unshift(iv(i)),o.push(iv(r)),o},rv.prototype.getDockingPoint=function(e,t,n){var i,r,o=e.waypoints;return{point:r=o[i=n?0:o.length-1],actual:this._getIntersection(t,e,n)||r,idx:i}},rv.prototype._getIntersection=function(e,t,n){return ln(this._getShapePath(e),this._getConnectionPath(t),n)},rv.prototype._getConnectionPath=function(e){return this._graphicsFactory.getConnectionPath(e)},rv.prototype._getShapePath=function(e){return this._graphicsFactory.getShapePath(e)},rv.prototype._getGfx=function(e){return this._elementRegistry.getGraphics(e)};var ov={__init__:["modeling","bpmnUpdater"],__depends__:[Wh,Cd,Rd,kd,dp,Dd,Ld,$d,Vd,No,Bl,hf],bpmnFactory:["type",df],bpmnUpdater:["type",ff],elementFactory:["type",vf],modeling:["type",Rm],layouter:["type",Gm],connectionDocking:["type",rv]},av=Math.round;function sv(e,t,n,i,r){function o(e,t,n,i){return r.allowed("elements.move",{shapes:e,delta:t,position:n,target:i})}function a(e,n,i,r){if(h(i)&&(r=i,i=!1),!n.waypoints&&n.parent){var o=function(e){return{x:e.x+av(e.width/2),y:e.y+av(e.height/2)}}(n);return t.init(e,o,"shape.move",{cursor:"grabbing",autoActivate:i,data:{shape:n,context:r||{}}}),!0}}e.on("shape.move.start",1500,(function(e){var t=e.context,n=e.shape,r=i.get().slice();-1===r.indexOf(n)&&(r=[n]),F(t,{shapes:r=function(e){var t=P(e,"id");return g(e,(function(e){for(;e=e.parent;)if(t[e.id])return!1;return!0}))}(r),validatedShapes:r,shape:n})})),e.on("shape.move.start",1250,(function(e){var t=e.context,n=t.validatedShapes;if(!(t.canExecute=o(n)))return!1})),e.on("shape.move.move",500,(function(e){var t,n=e.context,i=n.validatedShapes,r=e.hover,a={x:e.dx,y:e.dy};t=o(i,a,{x:e.x,y:e.y},r),n.delta=a,n.canExecute=t,n.target=null!==t?r:null})),e.on("shape.move.end",(function(e){var t=e.context,i=t.delta,r=t.canExecute,o="attach"===r,a=t.shapes;if(!1===r)return!1;i.x=av(i.x),i.y=av(i.y),0===i.x&&0===i.y||n.moveElements(a,i,t.target,{primaryShape:t.shape,attach:o})})),e.on("element.mousedown",(function(e){if(bo(e)){var t=mo(e);if(!t)throw new Error("must supply DOM mousedown event");return a(t,e.element)}})),this.start=a}sv.$inject=["eventBus","dragging","modeling","selection","rules"];var cv="djs-dragging",pv="drop-ok",lv="drop-not-ok",uv="new-parent",hv="attach-ok";function dv(e,t,n,i){function r(e){return function(e){return g(e,(function(t){return!function(e){return e.waypoints}(t)||y(e,D({id:t.source.id}))&&y(e,D({id:t.target.id}))}))}(a(e))}function a(e){var t=ct(e,!0),n=S(t,(function(e){return(e.incoming||[]).concat(e.outgoing||[])}));return o(t.concat(n))}function s(e,n){[hv,pv,lv,uv].forEach((function(i){i===n?t.addMarker(e,i):t.removeMarker(e,i)}))}e.on("shape.move.start",499,(function(e){var s=e.context,c=s.shapes,p=s.allDraggedElements,l=r(c);if(!s.dragGroup){var u=Me("g");ge(u,n.cls("djs-drag-group",["no-events"])),me(t.getActiveLayer(),u),s.dragGroup=u}l.forEach((function(e){i.addDragger(e,s.dragGroup)})),b(p=p?o([p,a(c)]):a(c),(function(e){t.addMarker(e,cv)})),s.allDraggedElements=p,s.differentParents=1!==T(P(c,(function(e){return e.parent&&e.parent.id})))})),e.on("shape.move.move",499,(function(e){var t=e.context,n=t.dragGroup,i=t.target,r=t.shape.parent,o=t.canExecute;i&&("attach"===o?s(i,hv):t.canExecute&&i&&i.id!==r.id?s(i,uv):s(i,t.canExecute?pv:lv)),Vn(n,e.dx,e.dy)})),e.on(["shape.move.out","shape.move.cleanup"],(function(e){var t=e.context.target;t&&s(t,null)})),e.on("shape.move.cleanup",(function(e){var n=e.context,i=n.allDraggedElements,r=n.dragGroup;b(i,(function(e){t.removeMarker(e,cv)})),r&&Ce(r)})),this.makeDraggable=function(e,n,r){i.addDragger(n,e.dragGroup),r&&t.addMarker(n,cv),e.allDraggedElements?e.allDraggedElements.push(n):e.allDraggedElements=[n]}}dv.$inject=["eventBus","canvas","styles","previewSupport"];var fv={__depends__:[Co,No,Ro,hs,ss,Rc],__init__:["move","movePreview"],move:["type",sv],movePreview:["type",dv]},mv=".djs-palette-toggle",vv=".entry",yv="open",gv="two-column";function bv(e,t){this._eventBus=e,this._canvas=t;var n=this;e.on("tool-manager.update",(function(e){var t=e.tool;n.updateToolHighlight(t)})),e.on("i18n.changed",(function(){n._update()})),e.on("diagram.init",(function(){n._diagramInitialized=!0,n._rebuild()}))}function xv(e,t){var n=t.getPaletteEntries();return f(n)?n(e):(b(n,(function(t,n){e[n]=t})),e)}bv.$inject=["eventBus","canvas"],bv.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("palette.getProviders",e,(function(e){e.providers.push(t)})),this._rebuild()},bv.prototype.getEntries=function(){return this._getProviders().reduce(xv,{})},bv.prototype._rebuild=function(){this._diagramInitialized&&(this._getProviders().length&&(this._container||this._init(),this._update()))},bv.prototype._init=function(){var e=this,t=this._eventBus,n=this._getParentContainer(),i=this._container=ce(bv.HTML_MARKUP);n.appendChild(i),K(n).add("djs-palette-shown"),se.bind(i,".djs-palette-toggle, .entry","click",(function(t){var n=t.delegateTarget;if(J(n,mv))return e.toggle();e.trigger("click",t)})),re.bind(i,"mousedown",(function(e){e.stopPropagation()})),se.bind(i,vv,"dragstart",(function(t){e.trigger("dragstart",t)})),t.on("canvas.resized",this._layoutChanged,this),t.fire("palette.create",{container:i})},bv.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(t),t.providers},bv.prototype._toggleState=function(e){e=e||{};var t,n=this._getParentContainer(),i=this._container,r=this._eventBus,o=K(i),a=K(n);t="twoColumn"in e?e.twoColumn:this._needsCollapse(n.clientHeight,this._entries||{}),o.toggle(gv,t),a.toggle("djs-palette-two-column",t),"open"in e&&(o.toggle(yv,e.open),a.toggle("djs-palette-open",e.open)),r.fire("palette.changed",{twoColumn:t,open:this.isOpen()})},bv.prototype._update=function(){var e=ue(".djs-palette-entries",this._container),t=this._entries=this.getEntries();X(e),b(t,(function(t,n){var i=t.group||"default",r=ue("[data-group="+i+"]",e);r||(r=ce('<div class="group" data-group="'+i+'"></div>'),e.appendChild(r));var o=t.html||(t.separator?'<hr class="separator" />':'<div class="entry" draggable="true"></div>'),a=ce(o);r.appendChild(a),t.separator||(G(a,"data-action",n),t.title&&G(a,"title",t.title),t.className&&function(e,t){var n=K(e);(u(t)?t:t.split(/\s+/g)).forEach((function(e){n.add(e)}))}(a,t.className),t.imageUrl&&a.appendChild(ce('<img src="'+t.imageUrl+'">')))})),this.open()},bv.prototype.trigger=function(e,t,n){var i,r,o,a=this._entries,s=t.delegateTarget||t.target;if(!s)return t.preventDefault();(i=a[G(s,"data-action")])&&(r=i.action,o=t.originalEvent||t,f(r)?"click"===e&&r(o,n):r[e]&&r[e](o,n),t.preventDefault())},bv.prototype._layoutChanged=function(){this._toggleState({})},bv.prototype._needsCollapse=function(e,t){return e<46*Object.keys(t).length+50},bv.prototype.close=function(){this._toggleState({open:!1,twoColumn:!1})},bv.prototype.open=function(){this._toggleState({open:!0})},bv.prototype.toggle=function(e){this.isOpen()?this.close():this.open()},bv.prototype.isActiveTool=function(e){return e&&this._activeTool===e},bv.prototype.updateToolHighlight=function(e){var t;this._toolsContainer||(t=ue(".djs-palette-entries",this._container),this._toolsContainer=ue("[data-group=tools]",t)),b(this._toolsContainer.children,(function(t){var n=t.getAttribute("data-action");if(n){var i=K(t);n=n.replace("-tool",""),i.contains("entry")&&n===e?i.add("highlighted-entry"):i.remove("highlighted-entry")}}))},bv.prototype.isOpen=function(){return K(this._container).has(yv)},bv.prototype._getParentContainer=function(){return this._canvas.getContainer()},bv.HTML_MARKUP='<div class="djs-palette"><div class="djs-palette-entries"></div><div class="djs-palette-toggle"></div></div>';var _v={__init__:["palette"],palette:["type",bv]},Ev="crosshair";function wv(e,t,n,i,r,o,a){this._selection=r,this._dragging=n,this._mouse=a;var s=this,c=function(e){var n,i=t.getActiveLayer();ge(n=e.frame=Me("rect"),{class:"djs-lasso-overlay",width:1,height:1,x:0,y:0}),me(i,n)},p=function(e){var t=e.frame,n=e.bbox;ge(t,{x:n.x,y:n.y,width:n.width,height:n.height})},l=function(e){e.frame&&Ce(e.frame)};o.registerTool("lasso",{tool:"lasso.selection",dragging:"lasso"}),e.on("lasso.selection.end",(function(t){var n=t.originalEvent.target;(t.hover||n instanceof SVGElement)&&e.once("lasso.selection.ended",(function(){s.activateLasso(t.originalEvent,!0)}))})),e.on("lasso.end",(function(e){var t=Sv(e),n=i.filter((function(e){return e}));s.select(n,t)})),e.on("lasso.start",(function(e){var t=e.context;t.bbox=Sv(e),c(t)})),e.on("lasso.move",(function(e){var t=e.context;t.bbox=Sv(e),p(t)})),e.on("lasso.cleanup",(function(e){var t=e.context;l(t)})),e.on("element.mousedown",1500,(function(e){if(_o(e))return s.activateLasso(e.originalEvent),!0}))}function Sv(e){var t={x:e.x-e.dx,y:e.y-e.dy},n={x:e.x,y:e.y};return t.x<=n.x&&t.y<n.y||t.x<n.x&&t.y<=n.y?{x:t.x,y:t.y,width:n.x-t.x,height:n.y-t.y}:t.x>=n.x&&t.y<n.y||t.x>n.x&&t.y<=n.y?{x:n.x,y:t.y,width:t.x-n.x,height:n.y-t.y}:t.x<=n.x&&t.y>n.y||t.x<n.x&&t.y>=n.y?{x:t.x,y:n.y,width:n.x-t.x,height:t.y-n.y}:t.x>=n.x&&t.y>n.y||t.x>n.x&&t.y>=n.y?{x:n.x,y:n.y,width:t.x-n.x,height:t.y-n.y}:{x:n.x,y:n.y,width:0,height:0}}wv.$inject=["eventBus","canvas","dragging","elementRegistry","selection","toolManager","mouse"],wv.prototype.activateLasso=function(e,t){this._dragging.init(e,"lasso",{autoActivate:t,cursor:Ev,data:{context:{}}})},wv.prototype.activateSelection=function(e,t){this._dragging.init(e,"lasso.selection",{trapClick:!1,autoActivate:t,cursor:Ev,data:{context:{}}})},wv.prototype.select=function(e,t){var n=function(e,t){var n={};return b(e,(function(e){var i=e;i.waypoints&&(i=pt(i)),!d(t.y)&&i.x>t.x&&(n[e.id]=e),!d(t.x)&&i.y>t.y&&(n[e.id]=e),i.x>t.x&&i.y>t.y&&(d(t.width)&&d(t.height)&&i.width+i.x<t.width+t.x&&i.height+i.y<t.height+t.y?n[e.id]=e:d(t.width)&&d(t.height)||(n[e.id]=e))})),n}(e,t);this._selection.select(R(n))},wv.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},wv.prototype.isActive=function(){var e=this._dragging.context();return e&&/^lasso/.test(e.prefix)};var Cv={__depends__:[qd,Uc],__init__:["lassoTool"],lassoTool:["type",wv]},Tv=1500,Rv="grab";function Pv(e,t,n,i,r,o){this._dragging=n,this._mouse=o;var a=this,s=i.get("keyboard",!1);r.registerTool("hand",{tool:"hand",dragging:"hand.move"}),e.on("element.mousedown",Tv,(function(e){if(xo(e))return a.activateMove(e.originalEvent,!0),!1})),s&&s.addListener(Tv,(function(e){if(Av(e.keyEvent)&&!a.isActive()){var t=a._mouse.getLastMoveEvent();a.activateMove(t,!!t)}}),"keyboard.keydown"),s&&s.addListener(Tv,(function(e){Av(e.keyEvent)&&a.isActive()&&a.toggle()}),"keyboard.keyup"),e.on("hand.end",(function(t){var n=t.originalEvent.target;if(!(t.hover||n instanceof SVGElement))return!1;e.once("hand.ended",(function(){a.activateMove(t.originalEvent,{reactivate:!0})}))})),e.on("hand.move.move",(function(e){var n=t.viewbox().scale;t.scroll({dx:e.dx*n,dy:e.dy*n})})),e.on("hand.move.end",(function(t){var n=t.context.reactivate;return!xo(t)&&n&&e.once("hand.move.ended",(function(e){a.activateHand(e.originalEvent,!0,!0)})),!1}))}function Av(e){return Wo(" ",e)}Pv.$inject=["eventBus","canvas","dragging","injector","toolManager","mouse"],Pv.prototype.activateMove=function(e,t,n){"object"==typeof t&&(n=t,t=!1),this._dragging.init(e,"hand.move",{autoActivate:t,cursor:Rv,data:{context:n||{}}})},Pv.prototype.activateHand=function(e,t,n){this._dragging.init(e,"hand",{trapClick:!1,autoActivate:t,cursor:Rv,data:{context:{reactivate:n}}})},Pv.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateHand(e,!!e)},Pv.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^(hand|hand\.move)$/.test(e.prefix)};var kv={__depends__:[qd,Uc],__init__:["handTool"],handTool:["type",Pv]},Mv="connect-ok",Dv="connect-not-ok";function Bv(e,t,n,i,r,o,a){var s=this;this._dragging=t,this._rules=o,this._mouse=a,r.registerTool("global-connect",{tool:"global-connect",dragging:"global-connect.drag"}),e.on("global-connect.hover",(function(e){var t=e.context,n=e.hover,r=t.canStartConnect=s.canStartConnect(n);null!==r&&(t.startTarget=n,i.addMarker(n,r?Mv:Dv))})),e.on(["global-connect.out","global-connect.cleanup"],(function(e){var t=e.context.startTarget,n=e.context.canStartConnect;t&&i.removeMarker(t,n?Mv:Dv)})),e.on(["global-connect.ended"],(function(t){var i=t.context.startTarget,r={x:t.x,y:t.y};if(s.canStartConnect(i))return e.once("element.out",(function(){e.once(["connect.ended","connect.canceled"],(function(){e.fire("global-connect.drag.ended")})),n.start(null,i,r)})),!1}))}Bv.$inject=["eventBus","dragging","connect","canvas","toolManager","rules","mouse"],Bv.prototype.start=function(e,t){this._dragging.init(e,"global-connect",{autoActivate:t,trapClick:!1,data:{context:{}}})},Bv.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();return this.start(e,!!e)},Bv.prototype.isActive=function(){var e=this._dragging.context();return e&&/^global-connect/.test(e.prefix)},Bv.prototype.canStartConnect=function(e){return this._rules.allowed("connection.start",{source:e})};var Nv={__depends__:[uc,hs,ss,qd,Uc],globalConnect:["type",Bv]};function Ov(e,t,n,i,r,o,a,s){this._palette=e,this._create=t,this._elementFactory=n,this._spaceTool=i,this._lassoTool=r,this._handTool=o,this._globalConnect=a,this._translate=s,e.registerProvider(this)}Ov.$inject=["palette","create","elementFactory","spaceTool","lassoTool","handTool","globalConnect","translate"],Ov.prototype.getPaletteEntries=function(e){var t={},n=this._create,i=this._elementFactory,r=this._spaceTool,o=this._lassoTool,a=this._handTool,s=this._globalConnect,c=this._translate;function p(e,t,r,o,a){function s(t){var r=i.createShape(F({type:e},a));a&&(r.businessObject.di.isExpanded=a.isExpanded),n.start(t,r)}var p=e.replace(/^bpmn:/,"");return{group:t,className:r,title:o||c("Create {type}",{type:p}),action:{dragstart:s,click:s}}}function l(e){var t=i.createShape({type:"bpmn:SubProcess",x:0,y:0,isExpanded:!0}),r=i.createShape({type:"bpmn:StartEvent",x:40,y:82,parent:t});n.start(e,[t,r],{hints:{autoSelect:[t]}})}function u(e){n.start(e,i.createParticipantShape())}return F(t,{"hand-tool":{group:"tools",className:"bpmn-icon-hand-tool",title:c("Activate the hand tool"),action:{click:function(e){a.activateHand(e)}}},"lasso-tool":{group:"tools",className:"bpmn-icon-lasso-tool",title:c("Activate the lasso tool"),action:{click:function(e){o.activateSelection(e)}}},"space-tool":{group:"tools",className:"bpmn-icon-space-tool",title:c("Activate the create/remove space tool"),action:{click:function(e){r.activateSelection(e)}}},"global-connect-tool":{group:"tools",className:"bpmn-icon-connection-multi",title:c("Activate the global connect tool"),action:{click:function(e){s.start(e)}}},"tool-separator":{group:"tools",separator:!0},"create.start-event":p("bpmn:StartEvent","event","bpmn-icon-start-event-none",c("Create StartEvent")),"create.intermediate-event":p("bpmn:IntermediateThrowEvent","event","bpmn-icon-intermediate-event-none",c("Create Intermediate/Boundary Event")),"create.end-event":p("bpmn:EndEvent","event","bpmn-icon-end-event-none",c("Create EndEvent")),"create.exclusive-gateway":p("bpmn:ExclusiveGateway","gateway","bpmn-icon-gateway-none",c("Create Gateway")),"create.task":p("bpmn:Task","activity","bpmn-icon-task",c("Create Task")),"create.data-object":p("bpmn:DataObjectReference","data-object","bpmn-icon-data-object",c("Create DataObjectReference")),"create.data-store":p("bpmn:DataStoreReference","data-store","bpmn-icon-data-store",c("Create DataStoreReference")),"create.subprocess-expanded":{group:"activity",className:"bpmn-icon-subprocess-expanded",title:c("Create expanded SubProcess"),action:{dragstart:l,click:l}},"create.participant-expanded":{group:"collaboration",className:"bpmn-icon-participant",title:c("Create Pool/Participant"),action:{dragstart:u,click:u}},"create.group":p("bpmn:Group","artifact","bpmn-icon-group",c("Create Group"))}),t};var jv={__depends__:[_v,Ic,hf,Cv,kv,Nv,to],__init__:["paletteProvider"],paletteProvider:["type",Ov]};function Lv(e,t,n,i,r){Ka.call(this,e),e.on("shape.move.move",250,(function(e){var o=e.context,a=o.canExecute;o.visualReplacements||(o.visualReplacements={}),a&&a.replacements?function(e){b(e.canExecute.replacements,(function(o){var a=o.oldElementId,s={type:o.newElementType};if(!e.visualReplacements[a]){var c=t.get(a);F(s,{x:c.x,y:c.y});var p=n.createShape(s);i.addShape(p,c.parent);var l=ue('[data-element-id="'+Ss(c.id)+'"]',e.dragGroup);l&&ge(l,{display:"none"});var u=r.addDragger(p,e.dragGroup);e.visualReplacements[a]=u,i.removeShape(p)}}))}(o):function(e){var t=e.visualReplacements;b(t,(function(n,i){var r=ue('[data-element-id="'+Ss(i)+'"]',e.dragGroup);r&&ge(r,{display:"inline"}),n.remove(),t[i]&&delete t[i]}))}(o)}))}Lv.$inject=["eventBus","elementRegistry","elementFactory","canvas","previewSupport"],n(Lv,Ka);var Iv={__depends__:[Rc],__init__:["bpmnReplacePreview"],bpmnReplacePreview:["type",Lv]},zv=40,Fv=["x","y"],$v=Math.abs;function Hv(e){e.on(["connect.hover","connect.move","connect.end"],1250,(function(e){var t=e.context,n=t.canExecute,i=t.start,r=t.hover,o=t.source,a=t.target;e.originalEvent&&Go(e.originalEvent)||(t.initialConnectionStart||(t.initialConnectionStart=t.connectionStart),n&&r&&function(e,t,n){Fv.forEach((function(i){var r=Vv(i,t);e[i]<t[i]+n?ec(e,i,t[i]+n):e[i]>t[i]+r-n&&ec(e,i,t[i]+r-n)}))}(e,r,function(e){return Ar(e,"bpmn:Task")?10:20}(r)),r&&function(e,t){return w(t,(function(t){return Wv(e,t)}))}(n,["bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:SequenceFlow"])?(t.connectionStart=Qs(i),Ha(r,["bpmn:Event","bpmn:Gateway"])&&Gv(e,Qs(r)),Ha(r,["bpmn:Task","bpmn:SubProcess"])&&function(e,t){var n=Qs(t);Fv.forEach((function(i){(function(e,t,n){return e[n]>t[n]+20&&e[n]<t[n]+Vv(n,t)-20})(e,t,i)&&ec(e,i,n[i])}))}(e,r),Ar(o,"bpmn:BoundaryEvent")&&a===o.host&&function(e){var t=e.context,n=t.source,i=t.target;if(function(e){var t=e.hover,n=e.source;return t&&n&&t===n}(t))return;var r=Qs(n),o=pn(r,i,-10),a=[];/top|bottom/.test(o)&&a.push("x");/left|right/.test(o)&&a.push("y");a.forEach((function(t){var n,i=e[t];$v(i-r[t])<zv&&(n=i>r[t]?r[t]+zv:r[t]-zv,ec(e,t,n))}))}(e)):Wv(n,"bpmn:MessageFlow")?(Ar(i,"bpmn:Event")&&(t.connectionStart=Qs(i)),Ar(r,"bpmn:Event")&&Gv(e,Qs(r))):t.connectionStart=t.initialConnectionStart)}))}function Gv(e,t){ec(e,"x",t.x),ec(e,"y",t.y)}function Wv(e,t){return e&&e.type===t}function Vv(e,t){return"x"===e?t.width:t.height}function Uv(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}function qv(e){this._snapValues={}}Hv.$inject=["eventBus"],Uv.prototype.getSnapOrigin=function(e){return this._snapOrigins[e]},Uv.prototype.setSnapOrigin=function(e,t){this._snapOrigins[e]=t,-1===this._snapLocations.indexOf(e)&&this._snapLocations.push(e)},Uv.prototype.addDefaultSnap=function(e,t){var n=this._defaultSnaps[e];n||(n=this._defaultSnaps[e]=[]),n.push(t)},Uv.prototype.getSnapLocations=function(){return this._snapLocations},Uv.prototype.setSnapLocations=function(e){this._snapLocations=e},Uv.prototype.pointsForTarget=function(e){var t=e.id||e,n=this._targets[t];return n||(n=this._targets[t]=new qv).initDefaults(this._defaultSnaps),n},qv.prototype.add=function(e,t){var n=this._snapValues[e];n||(n=this._snapValues[e]={x:[],y:[]}),-1===n.x.indexOf(t.x)&&n.x.push(t.x),-1===n.y.indexOf(t.y)&&n.y.push(t.y)},qv.prototype.snap=function(e,t,n,i){var r=this._snapValues[t];return r&&function(e,t,n){var i,r;for(n=void 0===n?10:n,i=0;i<t.length;i++)if(r=t[i],Ks(r-e)<=n)return r}(e[n],r[n],i)},qv.prototype.initDefaults=function(e){var t=this;b(e||{},(function(e,n){b(e,(function(e){t.add(n,e)}))}))};function Kv(e,t,n){var i=this;this._elementRegistry=e,t.on(["create.start","shape.move.start"],(function(e){i.initSnap(e)})),t.on(["create.move","create.end","shape.move.move","shape.move.end"],1250,(function(e){var t=e.context,r=t.shape,o=t.snapContext,a=t.target;if((!e.originalEvent||!Go(e.originalEvent))&&!Js(e)&&a){var s=o.pointsForTarget(a);s.initialized||((s=i.addSnapTargetPoints(s,r,a)).initialized=!0),n.snap(e,s)}})),t.on(["create.cleanup","shape.move.cleanup"],(function(){n.hide()}))}function Yv(e){return!!e.labelTarget}Kv.$inject=["elementRegistry","eventBus","snapping"],Kv.prototype.initSnap=function(e){var t,n=this._elementRegistry,i=e.context,r=i.shape,o=i.snapContext;o||(o=i.snapContext=new Uv);var a=(t=n.get(r.id)?Qs(r,e):{x:e.x+Qs(r).x,y:e.y+Qs(r).y}).x-r.width/2,s=t.y-r.height/2,c=t.x+r.width/2,p=t.y+r.height/2;return o.setSnapOrigin("mid",{x:t.x-e.x,y:t.y-e.y}),Yv(r)||(o.setSnapOrigin("top-left",{x:a-e.x,y:s-e.y}),o.setSnapOrigin("bottom-right",{x:c-e.x,y:p-e.y})),o},Kv.prototype.addSnapTargetPoints=function(e,t,n){return b(this.getSnapTargets(t,n),(function(n){if(Yv(n))Yv(t)&&e.add("mid",Qs(n));else if(n.waypoints){if(n.waypoints.length<3)return;b(n.waypoints.slice(1,-1),(function(t){e.add("mid",t)}))}else{e.add("mid",Qs(n))}})),d(t.x)&&d(t.y)?(this._elementRegistry.get(t.id)&&e.add("mid",Qs(t)),e):e},Kv.prototype.getSnapTargets=function(e,t){return tc(t).filter((function(e){return!e.hidden}))};function Xv(e,t){t.invoke(Kv,this),e.on(["create.move","create.end"],1500,Zv),e.on(["create.move","create.end","shape.move.move","shape.move.end"],1500,(function(e){var t=e.context,n=t.canExecute,i=t.target;n&&("attach"===n||n.attach)&&!Js(e)&&function(e,t){var n,i=an(t),r=Vh(e,t),o=e.context.shape;n=o.parent?{x:0,y:0}:cn(o);/top/.test(r)?ec(e,"y",i.top-n.y):/bottom/.test(r)&&ec(e,"y",i.bottom-n.y);/left/.test(r)?ec(e,"x",i.left-n.x):/right/.test(r)&&ec(e,"x",i.right-n.x)}(e,i)}))}function Zv(e){var t=e.context.createConstraints;if(t){var n=t.top,i=t.right,r=t.bottom,o=t.left;(o&&o>=e.x||i&&i<=e.x)&&ec(e,"x",e.x),(n&&n>=e.y||r&&r<=e.y)&&ec(e,"y",e.y)}}function Qv(e,t){return-1!==e.indexOf(t)}function Jv(e,t,n){return t?{x:e.x-n.x,y:e.y-n.y}:{x:e.x,y:e.y}}n(Xv,Kv),Xv.$inject=["eventBus","injector"],Xv.prototype.initSnap=function(e){var t=Kv.prototype.initSnap.call(this,e),n=e.shape,i=!!this._elementRegistry.get(n.id);return b(n.outgoing,(function(n){var r=n.waypoints[0];r=r.original||r,t.setSnapOrigin(n.id+"-docking",Jv(r,i,e))})),b(n.incoming,(function(n){var r=n.waypoints[n.waypoints.length-1];r=r.original||r,t.setSnapOrigin(n.id+"-docking",Jv(r,i,e))})),Ar(n,"bpmn:Participant")&&t.setSnapLocations(["top-left","bottom-right","mid"]),t},Xv.prototype.addSnapTargetPoints=function(e,t,n){Kv.prototype.addSnapTargetPoints.call(this,e,t,n);var i=this.getSnapTargets(t,n);b(i,(function(n){var i;(function(e){if(Ar(e,"bpmn:SubProcess")&&Mr(e))return!0;return Ar(e,"bpmn:Participant")}(n)||(i="bpmn:TextAnnotation",[t,n].every((function(e){return Ar(e,i)}))))&&(e.add("top-left",Xs(n)),e.add("bottom-right",Zs(n)))}));var r=this._elementRegistry;return b(t.incoming,(function(n){if(r.get(t.id)){Qv(i,n.source)||e.add("mid",cn(n.source));var o=n.waypoints[0];e.add(n.id+"-docking",o.original||o)}})),b(t.outgoing,(function(n){if(r.get(t.id)){Qv(i,n.target)||e.add("mid",cn(n.target));var o=n.waypoints[n.waypoints.length-1];e.add(n.id+"-docking",o.original||o)}})),Ar(n,"bpmn:SequenceFlow")&&(e=this.addSnapTargetPoints(e,t,n.parent)),e},Xv.prototype.getSnapTargets=function(e,t){return Kv.prototype.getSnapTargets.call(this,e,t).filter((function(e){return!Ar(e,"bpmn:Lane")}))};function ey(e,t){var n=this;e.on(["resize.start"],(function(e){n.initSnap(e)})),e.on(["resize.move","resize.end"],1250,(function(e){var i=e.context,r=i.shape,o=r.parent,a=i.direction,s=i.snapContext;if(!(e.originalEvent&&Go(e.originalEvent)||Js(e))){var c=s.pointsForTarget(o);c.initialized||((c=n.addSnapTargetPoints(c,r,o,a)).initialized=!0),function(e){return"n"===e||"s"===e}(a)&&ec(e,"x",e.x),function(e){return"e"===e||"w"===e}(a)&&ec(e,"y",e.y),t.snap(e,c)}})),e.on(["resize.cleanup"],(function(){t.hide()}))}function ty(e,t){var n=cn(e),i=an(e),r={x:n.x,y:n.y};return-1!==t.indexOf("n")?r.y=i.top:-1!==t.indexOf("s")&&(r.y=i.bottom),-1!==t.indexOf("e")?r.x=i.right:-1!==t.indexOf("w")&&(r.x=i.left),r}ey.prototype.initSnap=function(e){var t=e.context,n=t.shape,i=t.direction,r=t.snapContext;r||(r=t.snapContext=new Uv);var o=ty(n,i);return r.setSnapOrigin("corner",{x:o.x-e.x,y:o.y-e.y}),r},ey.prototype.addSnapTargetPoints=function(e,t,n,i){return b(this.getSnapTargets(t,n),(function(t){e.add("corner",Zs(t)),e.add("corner",Xs(t))})),e.add("corner",ty(t,i)),e},ey.$inject=["eventBus","snapping"],ey.prototype.getSnapTargets=function(e,t){return tc(t).filter((function(t){return!(n=t,i=e,n.host===i||function(e){return!!e.waypoints}(t)||function(e){return!!e.hidden}(t)||function(e){return!!e.labelTarget}(t));var n,i}))};function ny(e){this._canvas=e,this._asyncHide=L(I(this.hide,this),1e3)}ny.$inject=["canvas"],ny.prototype.snap=function(e,t){var n=e.context.snapContext,i=n.getSnapLocations(),r={x:Js(e,"x"),y:Js(e,"y")};b(i,(function(i){var o=n.getSnapOrigin(i),a={x:e.x+o.x,y:e.y+o.y};if(b(["x","y"],(function(e){var n;r[e]||void 0!==(n=t.snap(a,i,e,7))&&(r[e]={value:n,originValue:n-o[e]})})),r.x&&r.y)return!1})),this.showSnapLine("vertical",r.x&&r.x.value),this.showSnapLine("horizontal",r.y&&r.y.value),b(["x","y"],(function(t){var n=r[t];h(n)&&ec(e,t,n.originValue)}))},ny.prototype._createLine=function(e){var t=this._canvas.getLayer("snap"),n=Me("path");return ge(n,{d:"M0,0 L0,0"}),we(n).add("djs-snap-line"),me(t,n),{update:function(t){d(t)?ge(n,"horizontal"===e?{d:"M-100000,"+t+" L+100000,"+t,display:""}:{d:"M "+t+",-100000 L "+t+", +100000",display:""}):ge(n,{display:"none"})}}},ny.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}},ny.prototype.showSnapLine=function(e,t){var n=this.getSnapLine(e);n&&n.update(t),this._asyncHide()},ny.prototype.getSnapLine=function(e){return this._snapLines||this._createSnapLines(),this._snapLines[e]},ny.prototype.hide=function(){b(this._snapLines,(function(e){e.update()}))};var iy={__depends__:[{__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",Kv],resizeSnapping:["type",ey],snapping:["type",ny]}],__init__:["connectSnapping","createMoveSnapping"],connectSnapping:["type",Hv],createMoveSnapping:["type",Xv]};function ry(e,t,n,i){this._open=!1,this._results=[],this._eventMaps=[],this._canvas=e,this._eventBus=t,this._overlays=n,this._selection=i,this._container=ce(ry.BOX_HTML),this._searchInput=ue(ry.INPUT_SELECTOR,this._container),this._resultsContainer=ue(ry.RESULTS_CONTAINER_SELECTOR,this._container),this._canvas.getContainer().appendChild(this._container),t.on(["canvas.destroy","diagram.destroy"],this.close,this)}function oy(e,t,n){var i=function(e){var t="";return e.forEach((function(e){e.matched?t+='<strong class="'+ry.RESULT_HIGHLIGHT_CLASS+'">'+Ts(e.matched)+"</strong>":t+=Ts(e.normal)})),""!==t?t:null}(t),r=ce(n);r.innerHTML=i,e.appendChild(r)}ry.$inject=["canvas","eventBus","overlays","selection"],ry.prototype._bindEvents=function(){var e=this;function t(t,n,i,r){e._eventMaps.push({el:t,type:i,listener:se.bind(t,n,i,r)})}t(document,"html","click",(function(t){e.close()})),t(this._container,ry.INPUT_SELECTOR,"click",(function(e){e.stopPropagation(),e.delegateTarget.focus()})),t(this._container,ry.RESULT_SELECTOR,"mouseover",(function(t){t.stopPropagation(),e._scrollToNode(t.delegateTarget),e._preselect(t.delegateTarget)})),t(this._container,ry.RESULT_SELECTOR,"click",(function(t){t.stopPropagation(),e._select(t.delegateTarget)})),t(this._container,ry.INPUT_SELECTOR,"keydown",(function(e){38===e.keyCode&&e.preventDefault(),40===e.keyCode&&e.preventDefault()})),t(this._container,ry.INPUT_SELECTOR,"keyup",(function(t){if(27===t.keyCode)return e.close();if(13===t.keyCode){var n=e._getCurrentResult();return n?e._select(n):e.close()}return 38===t.keyCode?e._scrollToDirection(!0):40===t.keyCode?e._scrollToDirection():void(37!==t.keyCode&&39!==t.keyCode&&e._search(t.delegateTarget.value))}))},ry.prototype._unbindEvents=function(){this._eventMaps.forEach((function(e){se.unbind(e.el,e.type,e.listener)}))},ry.prototype._search=function(e){var t=this;if(this._clearResults(),e&&""!==e){var n=this._searchProvider.find(e);if(n.length){n.forEach((function(e){var n=e.element.id,i=t._createResultNode(e,n);t._results[n]={element:e.element,node:i}}));var i=ue(ry.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}}},ry.prototype._scrollToDirection=function(e){var t=this._getCurrentResult();if(t){var n=e?t.previousElementSibling:t.nextElementSibling;n&&(this._scrollToNode(n),this._preselect(n))}},ry.prototype._scrollToNode=function(e){if(e&&e!==this._getCurrentResult()){var t=e.offsetTop,n=this._resultsContainer.scrollTop,i=t-this._resultsContainer.clientHeight+e.clientHeight;t<n?this._resultsContainer.scrollTop=t:n<i&&(this._resultsContainer.scrollTop=i)}},ry.prototype._clearResults=function(){X(this._resultsContainer),this._results=[],this._resetOverlay(),this._eventBus.fire("searchPad.cleared")},ry.prototype._getCurrentResult=function(){return ue(ry.RESULT_SELECTED_SELECTOR,this._resultsContainer)},ry.prototype._createResultNode=function(e,t){var n=ce(ry.RESULT_HTML);return e.primaryTokens.length>0&&oy(n,e.primaryTokens,ry.RESULT_PRIMARY_HTML),oy(n,e.secondaryTokens,ry.RESULT_SECONDARY_HTML),G(n,ry.RESULT_ID_ATTRIBUTE,t),this._resultsContainer.appendChild(n),n},ry.prototype.registerProvider=function(e){this._searchProvider=e},ry.prototype.open=function(){if(!this._searchProvider)throw new Error("no search provider registered");this.isOpen()||(this._bindEvents(),this._open=!0,K(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))},ry.prototype.close=function(){this.isOpen()&&(this._unbindEvents(),this._open=!1,K(this._container).remove("open"),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._resetOverlay(),this._eventBus.fire("searchPad.closed"))},ry.prototype.toggle=function(){this.isOpen()?this.close():this.open()},ry.prototype.isOpen=function(){return this._open},ry.prototype._preselect=function(e){var t=this._getCurrentResult();if(e!==t){t&&K(t).remove(ry.RESULT_SELECTED_CLASS);var n=G(e,ry.RESULT_ID_ATTRIBUTE),i=this._results[n].element;K(e).add(ry.RESULT_SELECTED_CLASS),this._resetOverlay(i),this._canvas.scrollToElement(i,{top:400}),this._selection.select(i),this._eventBus.fire("searchPad.preselected",i)}},ry.prototype._select=function(e){var t=G(e,ry.RESULT_ID_ATTRIBUTE),n=this._results[t].element;this.close(),this._resetOverlay(),this._canvas.scrollToElement(n,{top:400}),this._selection.select(n),this._eventBus.fire("searchPad.selected",n)},ry.prototype._resetOverlay=function(e){if(this._overlayId&&this._overlays.remove(this._overlayId),e){var t=function(e){var t=6,n=e.width+2*t,i=e.height+2*t,r=["width: "+n+"px","height: "+i+"px"].join("; ");return{position:{bottom:i-t,right:n-t},show:!0,html:'<div style="'+r+'" class="'+ry.OVERLAY_CLASS+'"></div>'}}(pt(e));this._overlayId=this._overlays.add(e,t)}},ry.CONTAINER_SELECTOR=".djs-search-container",ry.INPUT_SELECTOR=".djs-search-input input",ry.RESULTS_CONTAINER_SELECTOR=".djs-search-results",ry.RESULT_SELECTOR=".djs-search-result",ry.RESULT_SELECTED_CLASS="djs-search-result-selected",ry.RESULT_SELECTED_SELECTOR="."+ry.RESULT_SELECTED_CLASS,ry.RESULT_ID_ATTRIBUTE="data-result-id",ry.RESULT_HIGHLIGHT_CLASS="djs-search-highlight",ry.OVERLAY_CLASS="djs-search-overlay",ry.BOX_HTML='<div class="djs-search-container djs-draggable djs-scrollable"><div class="djs-search-input"><input type="text"/></div><div class="djs-search-results"></div></div>',ry.RESULT_HTML='<div class="djs-search-result"></div>',ry.RESULT_PRIMARY_HTML='<div class="djs-search-result-primary"></div>',ry.RESULT_SECONDARY_HTML='<p class="djs-search-result-secondary"></p>';var ay={__depends__:[$o,No],searchPad:["type",ry]};function sy(e,t,n){this._elementRegistry=e,this._canvas=n,t.registerProvider(this)}function cy(e){return g(e,(function(e){return!!e.matched})).length>0}function py(e,t){var n=[],i=e;if(!e)return n;e=e.toLowerCase(),t=t.toLowerCase();var r=e.indexOf(t);return r>-1?(0!==r&&n.push({normal:i.substr(0,r)}),n.push({matched:i.substr(r,t.length)}),t.length+r<e.length&&n.push({normal:i.substr(t.length+r,e.length)})):n.push({normal:i}),n}sy.$inject=["elementRegistry","searchPad","canvas"],sy.prototype.find=function(e){var t=this._canvas.getRootElement(),n=this._elementRegistry.filter((function(e){return!e.labelTarget}));return n=g(n,(function(e){return e!==t})),n=M(n=g(n=S(n,(function(t){return{primaryTokens:py(Or(t),e),secondaryTokens:py(t.id,e),element:t}})),(function(e){return cy(e.primaryTokens)||cy(e.secondaryTokens)})),(function(e){return Or(e.element)+e.element.id}))};var ly={__depends__:[ay],__init__:["bpmnSearch"],bpmnSearch:["type",sy]};function uy(e){Pr.call(this,e)}return n(uy,Pr),uy.Viewer=Ho,uy.NavigatedViewer=ga,uy.prototype.createDiagram=gr((function(){return this.importXML('<?xml version="1.0" encoding="UTF-8"?><bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" targetNamespace="http://bpmn.io/schema/bpmn" id="Definitions_1"><bpmn:process id="Process_1" isExecutable="false"><bpmn:startEvent id="StartEvent_1"/></bpmn:process><bpmndi:BPMNDiagram id="BPMNDiagram_1"><bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"><bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"><dc:Bounds height="36.0" width="36.0" x="173.0" y="102.0"/></bpmndi:BPMNShape></bpmndi:BPMNPlane></bpmndi:BPMNDiagram></bpmn:definitions>')})),uy.prototype._interactionModules=[ia,ua,Ra,ya],uy.prototype._modelingModules=[Ba,qa,ls,es,oc,uc,dc,Kp,op,Ic,Jp,ol,bl,_l,wl,Ml,Ql,ov,fv,jv,Iv,Wl,iy,ly],uy.prototype._modules=[].concat(Ho.prototype._modules,uy.prototype._interactionModules,uy.prototype._modelingModules),uy}));
|