bpmn-js 18.0.0 → 18.1.0

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.
@@ -1,5 +1,5 @@
1
- /*! bpmn-js - bpmn-modeler v18.0.0 | Copyright (c) 2014-present, camunda Services GmbH | bpmn.io/license */
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";function e(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}var t=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 n(e){if(!(this instanceof n))return new n(e);e=e||[128,36,1],this._seed=e.length?t.rack(e[0],e[1],e[2]):e}function i(e){return Array.prototype.concat.apply([],e)}n.prototype.next=function(e){return this._seed(e||!0)},n.prototype.nextPrefixed=function(e,t){var n;do{n=e+this.next(!0)}while(this.assigned(n));return this.claim(n,t),n},n.prototype.claim=function(e,t){this._seed.set(e,t||!0)},n.prototype.assigned=function(e){return this._seed.get(e)||!1},n.prototype.unclaim=function(e){delete this._seed.hats[e]},n.prototype.clear=function(){var e,t=this._seed.hats;for(e in t)this.unclaim(e)};const r=Object.prototype.toString,o=Object.prototype.hasOwnProperty;function a(e){return void 0===e}function s(e){return void 0!==e}function c(e){return null==e}function p(e){return"[object Array]"===r.call(e)}function l(e){return"[object Object]"===r.call(e)}function u(e){return"[object Number]"===r.call(e)}function h(e){const t=r.call(e);return"[object Function]"===t||"[object AsyncFunction]"===t||"[object GeneratorFunction]"===t||"[object AsyncGeneratorFunction]"===t||"[object Proxy]"===t}function d(e){return"[object String]"===r.call(e)}function f(e,t){return o.call(e,t)}function m(e,t){const n=B(t);let i;return v(e,(function(e,t){if(n(e,t))return i=e,!1})),i}function y(e,t){const n=B(t);let i=p(e)?-1:void 0;return v(e,(function(e,t){if(n(e,t))return i=t,!1})),i}function g(e,t){const n=B(t);let i=[];return v(e,(function(e,t){n(e,t)&&i.push(e)})),i}function v(e,t){let n,i;if(a(e))return;const r=p(e)?N:D;for(let o in e)if(f(e,o)&&(n=e[o],i=t(n,r(o)),!1===i))return n}function _(e,t){if(a(e))return[];!function(e){if(!p(e))throw new Error("must supply array")}(e);const n=B(t);return e.filter((function(e,t){return!n(e,t)}))}function b(e,t,n){return v(e,(function(e,i){n=t(n,e,i)})),n}function x(e,t){return!!b(e,(function(e,n,i){return e&&t(n,i)}),!0)}function w(e,t){return!!m(e,t)}function E(e,t){let n=[];return v(e,(function(e,i){n.push(t(e,i))})),n}function S(e){return e&&Object.keys(e)||[]}function C(e){return E(e,(e=>e))}function k(e,t,n={}){return t=T(t),v(e,(function(e){let i=t(e)||"_",r=n[i];r||(r=n[i]=[]),r.push(e)})),n}function R(e,...t){e=T(e);let n={};return v(t,(t=>k(t,e,n))),E(n,(function(e,t){return e[0]}))}const P=R;function A(e,t){t=T(t);let n=[];return v(e,(function(e,i){let r=t(e,i),o={d:r,v:e};for(var a=0;a<n.length;a++){let{d:e}=n[a];if(r<e)return void n.splice(a,0,o)}n.push(o)})),E(n,(e=>e.v))}function M(e){return function(t){return x(e,(function(e,n){return t[n]===e}))}}function T(e){return h(e)?e:t=>t[e]}function B(e){return h(e)?e:t=>t===e}function D(e){return e}function N(e){return Number(e)}function j(e,t){let n,i,r,o;function a(n){let a=Date.now(),p=n?0:o+t-a;if(p>0)return s(p);e.apply(r,i),c()}function s(e){n=setTimeout(a,e)}function c(){n&&clearTimeout(n),n=o=i=r=void 0}function p(...e){o=Date.now(),i=e,r=this,n||s(t)}return p.flush=function(){n&&a(!0),c()},p.cancel=c,p}function O(e,t){return e.bind(t)}function L(e,...t){return Object.assign(e,...t)}function $(e,t){let n={},i=Object(e);return v(t,(function(t){t in i&&(n[t]=e[t])})),n}function I(e,t){let n={};return v(Object(e),(function(e,i){-1===t.indexOf(i)&&(n[i]=e)})),n}function F(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}const z=Object.prototype.toString,H=Object.prototype.hasOwnProperty;function V(e,t){return H.call(e,t)}function G(e,t){let n,i;if(void 0===e)return;const r=function(e){return"[object Array]"===z.call(e)}(e)?U:W;for(let o in e)if(V(e,o)&&(n=e[o],i=t(n,r(o)),!1===i))return n}function W(e){return e}function U(e){return Number(e)}function q(e,...t){const n=e.style;return G(t,(function(e){e&&G(e,(function(e,t){n[t]=e}))})),e}function K(e,t,n){return 2==arguments.length?e.getAttribute(t):null===n?e.removeAttribute(t):(e.setAttribute(t,n),e)}const Y=Object.prototype.toString;function X(e){return new Z(e)}function Z(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function Q(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function J(e,t,n){var i=n?e:e.parentNode;return i&&"function"==typeof i.closest&&i.closest(t)||null}Z.prototype.add=function(e){return this.list.add(e),this},Z.prototype.remove=function(e){return"[object RegExp]"==Y.call(e)?this.removeMatching(e):(this.list.remove(e),this)},Z.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Z.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Z.prototype.array=function(){return Array.from(this.list)},Z.prototype.has=Z.prototype.contains=function(e){return this.list.contains(e)};var ee,te,ne,ie={};function re(){ee=window.addEventListener?"addEventListener":"attachEvent",te=window.removeEventListener?"removeEventListener":"detachEvent",ne="addEventListener"!==ee?"on":""}var oe=F({__proto__:null,bind:ie.bind=function(e,t,n,i){return ee||re(),e[ee](ne+t,n,i||!1),n},unbind:ie.unbind=function(e,t,n,i){return te||re(),e[te](ne+t,n,i||!1),n},default:ie},[ie]),ae=["focus","blur"];var se,ce={bind:function(e,t,n,i,r){return-1!==ae.indexOf(n)&&(r=!0),oe.bind(e,n,(function(n){var r=n.target||n.srcElement;n.delegateTarget=J(r,t,!0),n.delegateTarget&&i.call(e,n)}),r)},unbind:function(e,t,n,i){return-1!==ae.indexOf(t)&&(i=!0),oe.unbind(e,t,n,i)}},pe=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=Object.prototype.hasOwnProperty.call(ue,i)?ue[i]:ue._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},le=!1;"undefined"!=typeof document&&((se=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',le=!se.getElementsByTagName("link").length,se=void 0);var ue={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:le?[1,"X<div>","</div>"]:[0,"",""]};ue.td=ue.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],ue.option=ue.optgroup=[1,'<select multiple="multiple">',"</select>"],ue.thead=ue.tbody=ue.colgroup=ue.caption=ue.tfoot=[1,"<table>","</table>"],ue.polyline=ue.ellipse=ue.polygon=ue.circle=ue.text=ue.line=ue.path=ue.rect=ue.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var he=pe;function de(e,t){return e&&"function"==typeof e.matches&&e.matches(t)||!1}function fe(e,t){return(t=t||document).querySelector(e)}function me(e,t){return(t=t||document).querySelectorAll(e)}function ye(e){e.parentNode&&e.parentNode.removeChild(e)}function ge(e,t){return function(e,t){t.appendChild(function(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch(e){}return e}(e,t))}(t,e),e}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 _e(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 be(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);_e(e,t,n)}else!function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)_e(e,i,t[i])}(e,t);return e}const xe=Object.prototype.toString;function we(e){return new Ee(e)}function Ee(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function Se(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Ce(e){return e.cloneNode(!0)}Ee.prototype.add=function(e){return this.list.add(e),this},Ee.prototype.remove=function(e){return"[object RegExp]"==xe.call(e)?this.removeMatching(e):(this.list.remove(e),this)},Ee.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Ee.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Ee.prototype.array=function(){return Array.from(this.list)},Ee.prototype.has=Ee.prototype.contains=function(e){return this.list.contains(e)};var ke="http://www.w3.org/2000/svg",Re='<svg xmlns="'+ke+'"';function Pe(e){var t=!1;"<svg"===e.substring(0,4)?-1===e.indexOf(ke)&&(e=Re+e.substring(4)):(e=Re+">"+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 Ae(e,t){var n;return"<"===(e=e.trim()).charAt(0)?(n=Pe(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(ke,e),t&&be(n,t),n}var Me=null;function Te(){return null===Me&&(Me=Ae("svg")),Me}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 De(e){return Te().createSVGTransform()}var Ne=/([&<>]{1})/g,je=/([\n\r"]{1})/g,Oe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"'"};function Le(e,t){return e.replace(t,(function(e,t){return Oe[t]||t}))}function $e(e,t){var n,i,r,o,a;switch(e.nodeType){case 3:t.push(Le(e.textContent,Ne));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,'="',Le(o.value,je),'"');if(e.hasChildNodes()){for(t.push(">"),n=0,i=(a=e.childNodes).length;n<i;++n)$e(a.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("\x3c!--",Le(e.nodeValue,Ne),"--\x3e");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function Ie(e,t){return function(e){for(var t=e.firstChild,n=[];t;)$e(t,n),t=t.nextSibling;return n.join("")}(e)}function Fe(e){var t=e.parentNode;return t&&t.removeChild(e),e}function ze(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function He(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(ze(e,i))}(n,t)),n.consolidate()}const Ve=/^class[ {]/;function Ge(e){return Array.isArray(e)}function We(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ue(...e){1===e.length&&Ge(e[0])&&(e=e[0]);const t=(e=[...e]).pop();return t.$inject=e,t}const qe=/constructor\s*[^(]*\(\s*([^)]*)\)/m,Ke=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,Ye=/\/\*([^*]*)\*\//m;function Xe(e){if("function"!=typeof e)throw new Error(`Cannot annotate "${e}". Expected a function!`);const t=e.toString().match(function(e){return Ve.test(e.toString())}(e)?qe:Ke);if(!t)return[];const n=t[1]||t[2];return n&&n.split(",").map((e=>{const t=e.match(Ye);return(t&&t[1]||e).trim()}))||[]}function Ze(e,t){const n=t||{get:function(e,t){if(i.push(e),!1===t)return null;throw s(`No provider for "${e}"!`)}},i=[],r=this._providers=Object.create(n._providers||null),o=this._instances=Object.create(null),a=o.injector=this,s=function(e){const t=i.join(" -> ");return i.length=0,new Error(t?`${e} (Resolving: ${t})`:e)};function c(e,t){if(!r[e]&&e.includes(".")){const t=e.split(".");let n=c(t.shift());for(;t.length;)n=n[t.shift()];return n}if(We(o,e))return o[e];if(We(r,e)){if(-1!==i.indexOf(e))throw i.push(e),s("Cannot resolve circular dependency!");return i.push(e),o[e]=r[e][0](r[e][1]),i.pop(),o[e]}return n.get(e,t)}function p(e,t){if(void 0===t&&(t={}),"function"!=typeof e){if(!Ge(e))throw s(`Cannot invoke "${e}". Expected a function!`);e=Ue(e.slice())}return{fn:e,dependencies:(e.$inject||Xe(e)).map((e=>We(t,e)?t[e]:c(e)))}}function l(e){const{fn:t,dependencies:n}=p(e);return new(Function.prototype.bind.call(t,null,...n))}function u(e,t,n){const{fn:i,dependencies:r}=p(e,n);return i.apply(t,r)}function h(e){return Ue((t=>e.get(t)))}function d(e,t){if(t&&t.length){const n=Object.create(null),i=Object.create(null),o=[],a=[],s=[];let c,p,l,u;for(let e in r)c=r[e],-1!==t.indexOf(e)&&("private"===c[2]?(p=o.indexOf(c[3]),-1===p?(l=c[3].createChild([],t),u=h(l),o.push(c[3]),a.push(l),s.push(u),n[e]=[u,e,"private",l]):n[e]=[s[p],e,"private",a[p]]):n[e]=[c[2],c[1]],i[e]=!0),"factory"!==c[2]&&"type"!==c[2]||!c[1].$scope||t.forEach((t=>{-1!==c[1].$scope.indexOf(t)&&(n[e]=[c[2],c[1]],i[t]=!0)}));t.forEach((e=>{if(!i[e])throw new Error('No provider for "'+e+'". Cannot use provider from the parent!')})),e.unshift(n)}return new Ze(e,a)}const f={factory:u,type:l,value:function(e){return e}};function m(e,t){const n=e.__init__||[];return function(){n.forEach((e=>{"string"==typeof e?t.get(e):t.invoke(e)}))}}function y(e){const t=e.__exports__;if(t){const n=e.__modules__,i=Object.keys(e).reduce(((t,n)=>("__exports__"!==n&&"__modules__"!==n&&"__init__"!==n&&"__depends__"!==n&&(t[n]=e[n]),t)),Object.create(null)),o=d((n||[]).concat(i)),a=Ue((function(e){return o.get(e)}));t.forEach((function(e){r[e]=[a,e,"private",o]}));const s=(e.__init__||[]).slice();return s.unshift((function(){o.init()})),m(e=Object.assign({},e,{__init__:s}),o)}return Object.keys(e).forEach((function(t){if("__init__"===t||"__depends__"===t)return;const n=e[t];if("private"===n[2])return void(r[t]=n);const i=n[0],o=n[1];r[t]=[f[i],Qe(i,o),i]})),m(e,a)}function g(e,t){return-1!==e.indexOf(t)||-1!==(e=(t.__depends__||[]).reduce(g,e)).indexOf(t)?e:e.concat(t)}this.get=c,this.invoke=u,this.instantiate=l,this.createChild=d,this.init=function(e){const t=e.reduce(g,[]).map(y);let n=!1;return function(){n||(n=!0,t.forEach((e=>e())))}}(e)}function Qe(e,t){return"value"!==e&&Ge(t)&&(t=Ue(t.slice())),t}function Je(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 et(e){return e.flat().join(",").replace(/,?([A-z]),?/g,"$1")}function tt(e){return["L",e.x,e.y]}function nt(e,t){const n=e.length,i=[(r=e[0],["M",r.x,r.y])];var r,o,a,s;for(let r=1;r<n;r++){const n=e[r-1],c=e[r],p=e[r+1];if(!p||!t){i.push(tt(c));continue}const l=Math.min(t,rt(c.x-n.x,c.y-n.y),rt(p.x-c.x,p.y-c.y));if(!l){i.push(tt(c));continue}const u=it(c,n,l),h=it(c,n,.5*l),d=it(c,p,l),f=it(c,p,.5*l);i.push(tt(u)),i.push((a=f,s=d,["C",(o=h).x,o.y,a.x,a.y,s.x,s.y]))}return i}function it(e,t,n){const i=t.x-e.x,r=t.y-e.y,o=n/rt(i,r);return{x:e.x+i*o,y:e.y+r*o}}function rt(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))}function ot(e,t,n){u(t)&&(n=t,t=null),t||(t={});const i=Ae("path",t);return u(n)&&(i.dataset.cornerRadius=String(n)),at(i,e)}function at(e,t){return be(e,{d:et(nt(t,parseInt(e.dataset.cornerRadius,10)||0))}),e}function st(e){return g(e,(function(t){return!m(e,(function(e){return e!==t&&ct(t,e)}))}))}function ct(e,t){if(t){if(e===t)return t;if(e.parent)return ct(e.parent,t)}}function pt(e,t,n){var i=!n||-1===e.indexOf(t);return i&&e.push(t),i}function lt(e,t,n){n=n||0,p(e)||(e=[e]),v(e,(function(e,i){var r=t(e,i,n);p(r)&&r.length&&lt(r,t,n+1)}))}function ut(e,t){return function(e,t){var n=[],i=[];return lt(e,(function(e,r,o){pt(n,e,t);var a=e.children;if(a&&pt(i,a,t))return a})),n}(e,!t)}function ht(e,t){var n,i,r,o;return t=!!t,p(e)||(e=[e]),v(e,(function(e){var a=e;e.waypoints&&!t&&(a=ht(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 dt(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}function ft(e){return!(!e||!e.isFrame)}function mt(e,t){return L({},e||{},t||{})}Je.prototype.canRender=function(e){},Je.prototype.drawShape=function(e,t){},Je.prototype.drawConnection=function(e,t){},Je.prototype.getShapePath=function(e){},Je.prototype.getConnectionPath=function(e){};function yt(e,t){Je.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})}e(yt,Je),yt.prototype.canRender=function(){return!0},yt.prototype.drawShape=function(e,t,n){var i=Ae("rect");return be(i,{x:0,y:0,width:t.width||0,height:t.height||0}),ft(t)?be(i,L({},this.FRAME_STYLE,n||{})):be(i,L({},this.SHAPE_STYLE,n||{})),ge(e,i),i},yt.prototype.drawConnection=function(e,t,n){var i=ot(t.waypoints,L({},this.CONNECTION_STYLE,n||{}));return ge(e,i),i},yt.prototype.getShapePath=function(e){var t=e.x,n=e.y,i=e.width;return et([["M",t,n],["l",i,0],["l",0,e.height],["l",-i,0],["z"]])},yt.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 et(r)},yt.$inject=["eventBus","styles"];var gt={__init__:["defaultRenderer"],defaultRenderer:["type",yt],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 L(this.style(t,n),{class:e})},this.style=function(t,n){p(t)||n||(n=t,t=[]);var i=b(t,(function(t,n){return L(t,e[n]||{})}),{});return n?L(i,n):i},this.computeStyle=function(e,n,i){return p(n)||(i=n,n=[]),t.style(n||[],L({},i,e||{}))}}]};function vt(e,t){if(!e||!t)return-1;var n=e.indexOf(t);return-1!==n&&e.splice(n,1),n}function _t(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 bt(e,t){return e&&t?e.indexOf(t):-1}function xt(e,t){return e&&t?Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)):-1}function wt(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=xt(e,t);return Math.abs(r/o)<=i}function Et(e,t){var n=Array.from(arguments).flat();const i={x:"v",y:"h"};for(const[e,t]of Object.entries(i))if(St(e,n))return t;return!1}function St(e,t){const n=t[0];return x(t,(function(t){return Math.abs(n[e]-t[e])<=2}))}function Ct(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 kt(e,t){return{x:Math.round(e.x+(t.x-e.x)/2),y:Math.round(e.y+(t.y-e.y)/2)}}
1
+ /*! bpmn-js - bpmn-modeler v18.1.0 | Copyright (c) 2014-present, camunda Services GmbH | bpmn.io/license */
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";function e(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}var t=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 n(e){if(!(this instanceof n))return new n(e);e=e||[128,36,1],this._seed=e.length?t.rack(e[0],e[1],e[2]):e}function i(e){return Array.prototype.concat.apply([],e)}n.prototype.next=function(e){return this._seed(e||!0)},n.prototype.nextPrefixed=function(e,t){var n;do{n=e+this.next(!0)}while(this.assigned(n));return this.claim(n,t),n},n.prototype.claim=function(e,t){this._seed.set(e,t||!0)},n.prototype.assigned=function(e){return this._seed.get(e)||!1},n.prototype.unclaim=function(e){delete this._seed.hats[e]},n.prototype.clear=function(){var e,t=this._seed.hats;for(e in t)this.unclaim(e)};const r=Object.prototype.toString,o=Object.prototype.hasOwnProperty;function a(e){return void 0===e}function s(e){return void 0!==e}function c(e){return null==e}function p(e){return"[object Array]"===r.call(e)}function l(e){return"[object Object]"===r.call(e)}function u(e){return"[object Number]"===r.call(e)}function h(e){const t=r.call(e);return"[object Function]"===t||"[object AsyncFunction]"===t||"[object GeneratorFunction]"===t||"[object AsyncGeneratorFunction]"===t||"[object Proxy]"===t}function d(e){return"[object String]"===r.call(e)}function f(e,t){return o.call(e,t)}function m(e,t){const n=B(t);let i;return v(e,(function(e,t){if(n(e,t))return i=e,!1})),i}function y(e,t){const n=B(t);let i=p(e)?-1:void 0;return v(e,(function(e,t){if(n(e,t))return i=t,!1})),i}function g(e,t){const n=B(t);let i=[];return v(e,(function(e,t){n(e,t)&&i.push(e)})),i}function v(e,t){let n,i;if(a(e))return;const r=p(e)?N:D;for(let o in e)if(f(e,o)&&(n=e[o],i=t(n,r(o)),!1===i))return n}function _(e,t){if(a(e))return[];!function(e){if(!p(e))throw new Error("must supply array")}(e);const n=B(t);return e.filter((function(e,t){return!n(e,t)}))}function b(e,t,n){return v(e,(function(e,i){n=t(n,e,i)})),n}function x(e,t){return!!b(e,(function(e,n,i){return e&&t(n,i)}),!0)}function w(e,t){return!!m(e,t)}function E(e,t){let n=[];return v(e,(function(e,i){n.push(t(e,i))})),n}function S(e){return e&&Object.keys(e)||[]}function C(e){return E(e,(e=>e))}function k(e,t,n={}){return t=T(t),v(e,(function(e){let i=t(e)||"_",r=n[i];r||(r=n[i]=[]),r.push(e)})),n}function R(e,...t){e=T(e);let n={};return v(t,(t=>k(t,e,n))),E(n,(function(e,t){return e[0]}))}const P=R;function A(e,t){t=T(t);let n=[];return v(e,(function(e,i){let r=t(e,i),o={d:r,v:e};for(var a=0;a<n.length;a++){let{d:e}=n[a];if(r<e)return void n.splice(a,0,o)}n.push(o)})),E(n,(e=>e.v))}function M(e){return function(t){return x(e,(function(e,n){return t[n]===e}))}}function T(e){return h(e)?e:t=>t[e]}function B(e){return h(e)?e:t=>t===e}function D(e){return e}function N(e){return Number(e)}function j(e,t){let n,i,r,o;function a(n){let a=Date.now(),p=n?0:o+t-a;if(p>0)return s(p);e.apply(r,i),c()}function s(e){n=setTimeout(a,e)}function c(){n&&clearTimeout(n),n=o=i=r=void 0}function p(...e){o=Date.now(),i=e,r=this,n||s(t)}return p.flush=function(){n&&a(!0),c()},p.cancel=c,p}function O(e,t){return e.bind(t)}function L(e,...t){return Object.assign(e,...t)}function $(e,t){let n={},i=Object(e);return v(t,(function(t){t in i&&(n[t]=e[t])})),n}function I(e,t){let n={};return v(Object(e),(function(e,i){-1===t.indexOf(i)&&(n[i]=e)})),n}function F(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}const z=Object.prototype.toString,H=Object.prototype.hasOwnProperty;function V(e,t){return H.call(e,t)}function G(e,t){let n,i;if(void 0===e)return;const r=function(e){return"[object Array]"===z.call(e)}(e)?U:W;for(let o in e)if(V(e,o)&&(n=e[o],i=t(n,r(o)),!1===i))return n}function W(e){return e}function U(e){return Number(e)}function q(e,...t){const n=e.style;return G(t,(function(e){e&&G(e,(function(e,t){n[t]=e}))})),e}function K(e,t,n){return 2==arguments.length?e.getAttribute(t):null===n?e.removeAttribute(t):(e.setAttribute(t,n),e)}const Y=Object.prototype.toString;function X(e){return new Z(e)}function Z(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function Q(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function J(e,t,n){var i=n?e:e.parentNode;return i&&"function"==typeof i.closest&&i.closest(t)||null}Z.prototype.add=function(e){return this.list.add(e),this},Z.prototype.remove=function(e){return"[object RegExp]"==Y.call(e)?this.removeMatching(e):(this.list.remove(e),this)},Z.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Z.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Z.prototype.array=function(){return Array.from(this.list)},Z.prototype.has=Z.prototype.contains=function(e){return this.list.contains(e)};var ee,te,ne,ie={};function re(){ee=window.addEventListener?"addEventListener":"attachEvent",te=window.removeEventListener?"removeEventListener":"detachEvent",ne="addEventListener"!==ee?"on":""}var oe=F({__proto__:null,bind:ie.bind=function(e,t,n,i){return ee||re(),e[ee](ne+t,n,i||!1),n},unbind:ie.unbind=function(e,t,n,i){return te||re(),e[te](ne+t,n,i||!1),n},default:ie},[ie]),ae=["focus","blur"];var se,ce={bind:function(e,t,n,i,r){return-1!==ae.indexOf(n)&&(r=!0),oe.bind(e,n,(function(n){var r=n.target||n.srcElement;n.delegateTarget=J(r,t,!0),n.delegateTarget&&i.call(e,n)}),r)},unbind:function(e,t,n,i){return-1!==ae.indexOf(t)&&(i=!0),oe.unbind(e,t,n,i)}},pe=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=Object.prototype.hasOwnProperty.call(ue,i)?ue[i]:ue._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},le=!1;"undefined"!=typeof document&&((se=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',le=!se.getElementsByTagName("link").length,se=void 0);var ue={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:le?[1,"X<div>","</div>"]:[0,"",""]};ue.td=ue.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],ue.option=ue.optgroup=[1,'<select multiple="multiple">',"</select>"],ue.thead=ue.tbody=ue.colgroup=ue.caption=ue.tfoot=[1,"<table>","</table>"],ue.polyline=ue.ellipse=ue.polygon=ue.circle=ue.text=ue.line=ue.path=ue.rect=ue.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var he=pe;function de(e,t){return e&&"function"==typeof e.matches&&e.matches(t)||!1}function fe(e,t){return(t=t||document).querySelector(e)}function me(e,t){return(t=t||document).querySelectorAll(e)}function ye(e){e.parentNode&&e.parentNode.removeChild(e)}function ge(e,t){return function(e,t){t.appendChild(function(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch(e){}return e}(e,t))}(t,e),e}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 _e(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 be(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);_e(e,t,n)}else!function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)_e(e,i,t[i])}(e,t);return e}const xe=Object.prototype.toString;function we(e){return new Ee(e)}function Ee(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function Se(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Ce(e){return e.cloneNode(!0)}Ee.prototype.add=function(e){return this.list.add(e),this},Ee.prototype.remove=function(e){return"[object RegExp]"==xe.call(e)?this.removeMatching(e):(this.list.remove(e),this)},Ee.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Ee.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Ee.prototype.array=function(){return Array.from(this.list)},Ee.prototype.has=Ee.prototype.contains=function(e){return this.list.contains(e)};var ke="http://www.w3.org/2000/svg",Re='<svg xmlns="'+ke+'"';function Pe(e){var t=!1;"<svg"===e.substring(0,4)?-1===e.indexOf(ke)&&(e=Re+e.substring(4)):(e=Re+">"+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 Ae(e,t){var n;return"<"===(e=e.trim()).charAt(0)?(n=Pe(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(ke,e),t&&be(n,t),n}var Me=null;function Te(){return null===Me&&(Me=Ae("svg")),Me}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 De(e){return Te().createSVGTransform()}var Ne=/([&<>]{1})/g,je=/([\n\r"]{1})/g,Oe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"'"};function Le(e,t){return e.replace(t,(function(e,t){return Oe[t]||t}))}function $e(e,t){var n,i,r,o,a;switch(e.nodeType){case 3:t.push(Le(e.textContent,Ne));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,'="',Le(o.value,je),'"');if(e.hasChildNodes()){for(t.push(">"),n=0,i=(a=e.childNodes).length;n<i;++n)$e(a.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("\x3c!--",Le(e.nodeValue,Ne),"--\x3e");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function Ie(e,t){return function(e){for(var t=e.firstChild,n=[];t;)$e(t,n),t=t.nextSibling;return n.join("")}(e)}function Fe(e){var t=e.parentNode;return t&&t.removeChild(e),e}function ze(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function He(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(ze(e,i))}(n,t)),n.consolidate()}const Ve=/^class[ {]/;function Ge(e){return Array.isArray(e)}function We(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ue(...e){1===e.length&&Ge(e[0])&&(e=e[0]);const t=(e=[...e]).pop();return t.$inject=e,t}const qe=/constructor\s*[^(]*\(\s*([^)]*)\)/m,Ke=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,Ye=/\/\*([^*]*)\*\//m;function Xe(e){if("function"!=typeof e)throw new Error(`Cannot annotate "${e}". Expected a function!`);const t=e.toString().match(function(e){return Ve.test(e.toString())}(e)?qe:Ke);if(!t)return[];const n=t[1]||t[2];return n&&n.split(",").map((e=>{const t=e.match(Ye);return(t&&t[1]||e).trim()}))||[]}function Ze(e,t){const n=t||{get:function(e,t){if(i.push(e),!1===t)return null;throw s(`No provider for "${e}"!`)}},i=[],r=this._providers=Object.create(n._providers||null),o=this._instances=Object.create(null),a=o.injector=this,s=function(e){const t=i.join(" -> ");return i.length=0,new Error(t?`${e} (Resolving: ${t})`:e)};function c(e,t){if(!r[e]&&e.includes(".")){const t=e.split(".");let n=c(t.shift());for(;t.length;)n=n[t.shift()];return n}if(We(o,e))return o[e];if(We(r,e)){if(-1!==i.indexOf(e))throw i.push(e),s("Cannot resolve circular dependency!");return i.push(e),o[e]=r[e][0](r[e][1]),i.pop(),o[e]}return n.get(e,t)}function p(e,t){if(void 0===t&&(t={}),"function"!=typeof e){if(!Ge(e))throw s(`Cannot invoke "${e}". Expected a function!`);e=Ue(e.slice())}return{fn:e,dependencies:(e.$inject||Xe(e)).map((e=>We(t,e)?t[e]:c(e)))}}function l(e){const{fn:t,dependencies:n}=p(e);return new(Function.prototype.bind.call(t,null,...n))}function u(e,t,n){const{fn:i,dependencies:r}=p(e,n);return i.apply(t,r)}function h(e){return Ue((t=>e.get(t)))}function d(e,t){if(t&&t.length){const n=Object.create(null),i=Object.create(null),o=[],a=[],s=[];let c,p,l,u;for(let e in r)c=r[e],-1!==t.indexOf(e)&&("private"===c[2]?(p=o.indexOf(c[3]),-1===p?(l=c[3].createChild([],t),u=h(l),o.push(c[3]),a.push(l),s.push(u),n[e]=[u,e,"private",l]):n[e]=[s[p],e,"private",a[p]]):n[e]=[c[2],c[1]],i[e]=!0),"factory"!==c[2]&&"type"!==c[2]||!c[1].$scope||t.forEach((t=>{-1!==c[1].$scope.indexOf(t)&&(n[e]=[c[2],c[1]],i[t]=!0)}));t.forEach((e=>{if(!i[e])throw new Error('No provider for "'+e+'". Cannot use provider from the parent!')})),e.unshift(n)}return new Ze(e,a)}const f={factory:u,type:l,value:function(e){return e}};function m(e,t){const n=e.__init__||[];return function(){n.forEach((e=>{"string"==typeof e?t.get(e):t.invoke(e)}))}}function y(e){const t=e.__exports__;if(t){const n=e.__modules__,i=Object.keys(e).reduce(((t,n)=>("__exports__"!==n&&"__modules__"!==n&&"__init__"!==n&&"__depends__"!==n&&(t[n]=e[n]),t)),Object.create(null)),o=d((n||[]).concat(i)),a=Ue((function(e){return o.get(e)}));t.forEach((function(e){r[e]=[a,e,"private",o]}));const s=(e.__init__||[]).slice();return s.unshift((function(){o.init()})),m(e=Object.assign({},e,{__init__:s}),o)}return Object.keys(e).forEach((function(t){if("__init__"===t||"__depends__"===t)return;const n=e[t];if("private"===n[2])return void(r[t]=n);const i=n[0],o=n[1];r[t]=[f[i],Qe(i,o),i]})),m(e,a)}function g(e,t){return-1!==e.indexOf(t)||-1!==(e=(t.__depends__||[]).reduce(g,e)).indexOf(t)?e:e.concat(t)}this.get=c,this.invoke=u,this.instantiate=l,this.createChild=d,this.init=function(e){const t=e.reduce(g,[]).map(y);let n=!1;return function(){n||(n=!0,t.forEach((e=>e())))}}(e)}function Qe(e,t){return"value"!==e&&Ge(t)&&(t=Ue(t.slice())),t}function Je(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 et(e){return e.flat().join(",").replace(/,?([A-Za-z]),?/g,"$1")}function tt(e){return["L",e.x,e.y]}function nt(e,t){const n=e.length,i=[(r=e[0],["M",r.x,r.y])];var r,o,a,s;for(let r=1;r<n;r++){const n=e[r-1],c=e[r],p=e[r+1];if(!p||!t){i.push(tt(c));continue}const l=Math.min(t,rt(c.x-n.x,c.y-n.y),rt(p.x-c.x,p.y-c.y));if(!l){i.push(tt(c));continue}const u=it(c,n,l),h=it(c,n,.5*l),d=it(c,p,l),f=it(c,p,.5*l);i.push(tt(u)),i.push((a=f,s=d,["C",(o=h).x,o.y,a.x,a.y,s.x,s.y]))}return i}function it(e,t,n){const i=t.x-e.x,r=t.y-e.y,o=n/rt(i,r);return{x:e.x+i*o,y:e.y+r*o}}function rt(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))}function ot(e,t,n){u(t)&&(n=t,t=null),t||(t={});const i=Ae("path",t);return u(n)&&(i.dataset.cornerRadius=String(n)),at(i,e)}function at(e,t){return be(e,{d:et(nt(t,parseInt(e.dataset.cornerRadius,10)||0))}),e}function st(e){return g(e,(function(t){return!m(e,(function(e){return e!==t&&ct(t,e)}))}))}function ct(e,t){if(t){if(e===t)return t;if(e.parent)return ct(e.parent,t)}}function pt(e,t,n){var i=!n||-1===e.indexOf(t);return i&&e.push(t),i}function lt(e,t,n){n=n||0,p(e)||(e=[e]),v(e,(function(e,i){var r=t(e,i,n);p(r)&&r.length&&lt(r,t,n+1)}))}function ut(e,t){return function(e,t){var n=[],i=[];return lt(e,(function(e,r,o){pt(n,e,t);var a=e.children;if(a&&pt(i,a,t))return a})),n}(e,!t)}function ht(e,t){var n,i,r,o;return t=!!t,p(e)||(e=[e]),v(e,(function(e){var a=e;e.waypoints&&!t&&(a=ht(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 dt(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}function ft(e){return!(!e||!e.isFrame)}function mt(e,t){return L({},e||{},t||{})}Je.prototype.canRender=function(e){},Je.prototype.drawShape=function(e,t){},Je.prototype.drawConnection=function(e,t){},Je.prototype.getShapePath=function(e){},Je.prototype.getConnectionPath=function(e){};function yt(e,t){Je.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})}e(yt,Je),yt.prototype.canRender=function(){return!0},yt.prototype.drawShape=function(e,t,n){var i=Ae("rect");return be(i,{x:0,y:0,width:t.width||0,height:t.height||0}),ft(t)?be(i,L({},this.FRAME_STYLE,n||{})):be(i,L({},this.SHAPE_STYLE,n||{})),ge(e,i),i},yt.prototype.drawConnection=function(e,t,n){var i=ot(t.waypoints,L({},this.CONNECTION_STYLE,n||{}));return ge(e,i),i},yt.prototype.getShapePath=function(e){var t=e.x,n=e.y,i=e.width;return et([["M",t,n],["l",i,0],["l",0,e.height],["l",-i,0],["z"]])},yt.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 et(r)},yt.$inject=["eventBus","styles"];var gt={__init__:["defaultRenderer"],defaultRenderer:["type",yt],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 L(this.style(t,n),{class:e})},this.style=function(t,n){p(t)||n||(n=t,t=[]);var i=b(t,(function(t,n){return L(t,e[n]||{})}),{});return n?L(i,n):i},this.computeStyle=function(e,n,i){return p(n)||(i=n,n=[]),t.style(n||[],L({},i,e||{}))}}]};function vt(e,t){if(!e||!t)return-1;var n=e.indexOf(t);return-1!==n&&e.splice(n,1),n}function _t(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 bt(e,t){return e&&t?e.indexOf(t):-1}function xt(e,t){return e&&t?Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)):-1}function wt(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=xt(e,t);return Math.abs(r/o)<=i}function Et(e,t){var n=Array.from(arguments).flat();const i={x:"v",y:"h"};for(const[e,t]of Object.entries(i))if(St(e,n))return t;return!1}function St(e,t){const n=t[0];return x(t,(function(t){return Math.abs(n[e]-t[e])<=2}))}function Ct(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 kt(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).
5
5
  *
@@ -194,4 +194,4 @@ function(e){const t=he('<a href="http://bpmn.io" target="_blank" class="bjs-powe
194
194
  searchFn=${this._search}
195
195
  ...${{...o}}
196
196
  />
197
- `,this._current.container)},Mc.prototype.open=function(e,t,n,i){if(!e)throw new Error("target is missing");if(!t)throw new Error("providers for <"+t+"> not found");if(!n)throw new Error("position is missing");this.isOpen()&&this.close();const{entries:r,headerEntries:o,emptyPlaceholder:a}=this._getContext(e,t);this._current={position:n,providerId:t,target:e,entries:r,headerEntries:o,emptyPlaceholder:a,container:this._createContainer({provider:t}),options:i},this._emit("open"),this._bindAutoClose(),this._render()},Mc.prototype.refresh=function(){if(!this.isOpen())return;const{target:e,providerId:t}=this._current,{entries:n,headerEntries:i,emptyPlaceholder:r}=this._getContext(e,t);this._current={...this._current,entries:n,headerEntries:i,emptyPlaceholder:r},this._emit("refresh"),this._render()},Mc.prototype._getContext=function(e,t){const n=this._getProviders(t);if(!n||!n.length)throw new Error("provider for <"+t+"> not found");const i=this._getEntries(e,n),r=this._getHeaderEntries(e,n);return{entries:i,headerEntries:r,emptyPlaceholder:this._getEmptyPlaceholder(n),empty:!(Object.keys(i).length||Object.keys(r).length)}},Mc.prototype.close=function(){this.isOpen()&&(this._emit("close"),this.reset(),this._canvas.restoreFocus(),this._current=null)},Mc.prototype.reset=function(){const e=this._current.container;Gs(null,e),ye(e)},Mc.prototype._emit=function(e,t){this._eventBus.fire(`popupMenu.${e}`,t)},Mc.prototype._onOpened=function(){this._emit("opened")},Mc.prototype._onClosed=function(){this._emit("closed")},Mc.prototype._createContainer=function(e){var t=this._canvas.getContainer();const n=he(`<div class="djs-popup-parent djs-scrollable" data-popup=${e.provider}></div>`);return t.appendChild(n),n},Mc.prototype._bindAutoClose=function(){this._eventBus.once(Ac,this.close,this)},Mc.prototype._unbindAutoClose=function(){this._eventBus.off(Ac,this.close,this)},Mc.prototype._updateScale=function(){var e,t,n=this._canvas.zoom(),i=this._config.scale,r=n;return!0!==i&&(!1===i?(e=1,t=1):(e=i.min,t=i.max),s(e)&&n<e&&(r=e),s(t)&&n>t&&(r=t)),r},Mc.prototype._ensureVisible=function(e,t){var n=document.documentElement.getBoundingClientRect(),i=e.getBoundingClientRect(),r={},o=t.x,a=t.y;return t.x+i.width>n.width&&(r.x=!0),t.y+i.height>n.height&&(r.y=!0),r.x&&r.y?(o=t.x-i.width,a=t.y-i.height):r.x?(o=t.x-i.width,a=t.y):r.y&&t.y<i.height?(o=t.x,a=10):r.y&&(o=t.x,a=t.y-i.height),t.y<n.top&&(a=t.y+i.height),{x:o,y:a}},Mc.prototype.isEmpty=function(e,t){if(!e)throw new Error("target is missing");if(!t)throw new Error("provider ID is missing");const n=this._getProviders(t);return!n||!n.length||this._getContext(e,t).empty},Mc.prototype.registerProvider=function(e,t,n){n||(n=t,t=1e3),this._eventBus.on("popupMenu.getProviders."+e,t,(function(e){e.providers.push(n)}))},Mc.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"popupMenu.getProviders."+e,providers:[]});return this._eventBus.fire(t),t.providers},Mc.prototype._getEntries=function(e,t){var n={};return v(t,(function(t){if(t.getPopupMenuEntries){var i=t.getPopupMenuEntries(e);h(i)?n=i(n):v(i,(function(e,t){n[t]=e}))}else v(t.getEntries(e),(function(e){var t=e.id;if(!t)throw new Error("entry ID is missing");n[t]=I(e,["id"])}))})),n},Mc.prototype._getHeaderEntries=function(e,t){var n={};return v(t,(function(t){if(t.getPopupMenuHeaderEntries){var i=t.getPopupMenuHeaderEntries(e);h(i)?n=i(n):v(i,(function(e,t){n[t]=e}))}else{if(!t.getHeaderEntries)return;v(t.getHeaderEntries(e),(function(e){var t=e.id;if(!t)throw new Error("entry ID is missing");n[t]=I(e,["id"])}))}})),n},Mc.prototype._getEmptyPlaceholder=function(e){const t=e.find((e=>h(e.getEmptyPlaceholder)));return t&&t.getEmptyPlaceholder()},Mc.prototype.isOpen=function(){return!!this._current},Mc.prototype.trigger=function(e,t,n="click"){if(e.preventDefault(),!t){let n=K(J(e.delegateTarget||e.target,".entry",!0),"data-id");t={id:n,...this._getEntry(n)}}const i=t.action;if(!1!==this._emit("trigger",{entry:t,event:e}))if(h(i)){if("click"===n)return i(e,t)}else if(i[n])return i[n](e,t)},Mc.prototype._getEntry=function(e){var t=this._current.entries[e]||this._current.headerEntries[e];if(!t)throw new Error("entry not found");return t};var jc={search:["value",function(e,t,n){const{keys:i}=n,r=t.trim().toLowerCase().split(/\s+/);return e.flatMap((e=>{const t=function(e,t,n){const{matchedWords:i,tokens:r}=n.reduce(((n,i)=>{const r=e[i],{tokens:o,matchedWords:a}=function(e,t){if(!e)return{tokens:[],matchedWords:{}};const n=[],i={},r=t.map(Nc).flatMap((e=>["(?<wordStart>\\b"+e+")",e])).join("|"),o=new RegExp(r,"ig");let a,s=0;for(;a=o.exec(e);){const[t]=a;a.index>s&&n.push({value:e.slice(s,a.index),index:s}),n.push({value:t,index:a.index,match:!0,wordStart:!!a.groups.wordStart,start:0===a.index}),i[t.toLowerCase()]=!0,s=a.index+t.length}s<e.length&&n.push({value:e.slice(s),index:s});return{tokens:n,matchedWords:i}}(r,t);return{tokens:{...n.tokens,[i]:o},matchedWords:{...n.matchedWords,...a}}}),{matchedWords:{},tokens:{}});if(Object.keys(i).length!==t.length)return null;return r}(e,r,i);return t?{item:e,tokens:t}:[]})).sort(function(e){return(t,n)=>{for(const i of e){const e=Tc(t.tokens[i],n.tokens[i]);if(0!==e)return e;const r=Dc(t.item[i],n.item[i]);if(0!==r)return r}return 0}}(i))}]},Oc={__depends__:[jc],__init__:["popupMenu"],popupMenu:["type",Mc]},Lc={align:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2000 2000">\n <line x1="200" y1="150" x2="200" y2="1850" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="500" y="150" width="1300" height="700" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="500" y="1150" width="700" height="700" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',bottom:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="150" y1="1650" x2="1650" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="150" y="350" width="600" height="1300" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="1050" y="850" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',center:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="900" y1="150" x2="900" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="250" y="150" width="1300" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="500" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',left:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="100" y1="150" x2="100" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="100" y="150" width="1300" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="100" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',right:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="1650" y1="150" x2="1650" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="350" y="150" width="1300" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="850" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',top:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="150" y1="150" x2="1650" y2="150" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="150" y="150" width="600" height="1300" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="1050" y="150" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',middle:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="150" y1="900" x2="1650" y2="900" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="150" y="250" width="600" height="1300" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="1050" y="500" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>'};function $c(e,t,n,i){e.registerProvider(900,this),this._contextPad=e,this._popupMenu=t,this._translate=n,this._canvas=i}$c.$inject=["contextPad","popupMenu","translate","canvas"],$c.prototype.getMultiElementContextPadEntries=function(e){var t={};return this._isAllowed(e)&&L(t,this._getEntries(e)),t},$c.prototype._isAllowed=function(e){return!this._popupMenu.isEmpty(e,"align-elements")},$c.prototype._getEntries=function(){var e=this;return{"align-elements":{group:"align-elements",title:e._translate("Align elements"),html:`<div class="entry">${Lc.align}</div>`,action:{click:function(t,n){var i=e._getMenuPosition(n);L(i,{cursor:{x:t.x,y:t.y}}),e._popupMenu.open(n,"align-elements",i)}}}}},$c.prototype._getMenuPosition=function(e){var t=this._contextPad.getPad(e).html.getBoundingClientRect();return{x:t.left,y:t.bottom+5}};var Ic=["left","center","right","top","middle","bottom"];function Fc(e,t,n,i){this._alignElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",this)}function zc(e){To.call(this,e),this.init()}function Hc(e){zc.call(this,e)}Fc.$inject=["popupMenu","alignElements","translate","rules"],Fc.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&L(t,this._getEntries(e)),t},Fc.prototype._isAllowed=function(e){return this._rules.allowed("elements.align",{elements:e})},Fc.prototype._getEntries=function(e){var t=this._alignElements,n=this._translate,i=this._popupMenu,r={};return v(Ic,(function(o){r["align-elements-"+o]={group:"align",title:n("Align elements "+o),className:"bjs-align-elements-menu-entry",imageHtml:Lc[o],action:function(){t.trigger(e,o),i.close()}}})),r},zc.$inject=["eventBus"],e(zc,To),zc.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)}))},zc.prototype.init=function(){},Hc.$inject=["eventBus"],e(Hc,zc),Hc.prototype.init=function(){this.addRule("elements.align",(function(e){var t=g(e.elements,(function(e){return!(e.waypoints||e.host||e.labelTarget)}));return!((t=st(t)).length<2)&&t}))};var Vc={__depends__:[ns,ms,Oc],__init__:["alignElementsContextPadProvider","alignElementsMenuProvider","bpmnAlignElements"],alignElementsContextPadProvider:["type",$c],alignElementsMenuProvider:["type",Fc],bpmnAlignElements:["type",Hc]};function Gc(e,t,n,i){for(var r;r=Uc(e,n,t);)n=i(t,n,r);return n}function Wc(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 Uc(e,t,n){var i={x:t.x-n.width/2,y:t.y-n.height/2,width:n.width,height:n.height},r=function(e){var t=qc(e);e.host&&(t=t.concat(qc(e.host)));e.attachers&&(t=t.concat(e.attachers.reduce((function(e,t){return e.concat(qc(t))}),[])));return t}(e);return m(r,(function(e){return e!==n&&"intersect"===fn(e,i,10)}))}function qc(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 Kc(){return!0}function Yc(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=dn(e),o=ln(e);return{x:o.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 Xc(e,t){e.on("autoPlace.end",500,(function(e){t.select(e.shape)}))}Yc.$inject=["eventBus","modeling","canvas"],Xc.$inject=["eventBus","selection"];var Zc={__init__:["autoPlaceSelectionBehavior"],autoPlace:["type",Yc],autoPlaceSelectionBehavior:["type",Xc]};function Qc(e,t){for(d(t)&&(t=[t]);e=e.parent;)if(yr(e,t))return e;return null}function Jc(e,t){var n=Qc(e,"bpmn:Process");if(n)return!0;var i,r=["bpmn:Participant","bpmn:Lane"];if(n=Qc(e,r))return Or(n);if(yr(e,r))return Or(e);for(i=gr(e);i&&!mr(i,"bpmn:Process");i=i.$parent);if(!t)return!0;var o=t.find((function(e){var t=gr(e);return t&&t.get("processRef")===i}));return!o||Or(o)}function ep(e,t,n){var i=Jc(e,n);return mr(t,"bpmn:TextAnnotation")?function(e,t,n){var i=ln(e),r=n?{x:i.right+t.width/2,y:i.top-50-t.height/2}:{x:i.right+50+t.width/2,y:i.bottom+t.height/2};an(e)&&(r=dn(e),n?(r.x+=100,r.y-=50):(r.x+=100,r.y+=50));var o={margin:n?-30:30,minDistance:20},a=n?{y:o}:{x:o};return Gc(e,t,r,Wc(a))}(e,t,i):yr(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])?function(e,t,n){var i=ln(e),r=n?{x:i.right-10+t.width/2,y:i.bottom+40+t.width/2}:{x:i.left-40-t.width/2,y:i.bottom-10+t.height/2},o={margin:30,minDistance:30},a=n?{x:o}:{y:o};return Gc(e,t,r,Wc(a))}(e,t,i):mr(t,"bpmn:FlowNode")?function(e,t,n){var i=ln(e),r=dn(e),o=n?{directionHint:"e",minDistance:80,baseOrientation:"left",boundaryOrientation:"top",start:"top",end:"bottom"}:{directionHint:"s",minDistance:90,baseOrientation:"top",boundaryOrientation:"left",start:"left",end:"right"},a=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?ln(e).top-ln(t).bottom:"center"===s?ln(e).top-dn(t).y:ln(e).top-ln(t).top:"w"===i?"start"===s?ln(e).left-ln(t).right:"center"===s?ln(e).left-dn(t).x:ln(e).left-ln(t).left:"s"===i?"start"===s?ln(t).top-ln(e).bottom:"center"===s?dn(t).y-ln(e).bottom:ln(t).bottom-ln(e).bottom:"start"===s?ln(t).left-ln(e).right:"center"===s?dn(t).x-ln(e).right:ln(t).right-ln(e).right}r||(r=Kc);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}})),u=b(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}),{});return u.distance||n}(e,{filter:function(e){return mr(e,"bpmn:SequenceFlow")},direction:o.directionHint}),s=30,c=o.minDistance,p=o.baseOrientation;mr(e,"bpmn:BoundaryEvent")&&-1!==(p=fn(e,e.host,-25)).indexOf(o.boundaryOrientation)&&(s*=-1);var l=n?{x:i.right+a+t.width/2,y:r.y+tp(p,c,o)}:{x:r.x+tp(p,c,o),y:i.bottom+a+t.height/2},u={margin:s,minDistance:c},h=n?{y:u}:{x:u};return Gc(e,t,l,Wc(h))}(e,t,i):void 0}function tp(e,t,n){return e.includes(n.start)?-1*t:e.includes(n.end)?t:0}function np(e,t){e.on("autoPlace",(function(e){var n=e.shape;return ep(e.source,n,t)}))}np.$inject=["eventBus","elementRegistry"];var ip={__depends__:[Zc],__init__:["bpmnAutoPlace"],bpmnAutoPlace:["type",np]};function rp(e,t,n,r){To.call(this,e),this._elementRegistry=t,this._modeling=n,this._rules=r;var o=this;this.postExecuted(["shape.create"],(function(e){var t=e.context,n=t.hints||{},i=t.shape,r=t.parent||t.newParent;!1!==n.autoResize&&o._expand([i],r)})),this.postExecuted(["elements.move"],(function(e){var t=e.context,n=i(C(t.closure.topLevel)),r=t.hints,a=!r||r.autoResize;!1!==a&&v(k(n,(function(e){return e.parent.id})),(function(e,t){p(a)&&(e=e.filter((function(e){return m(a,M({id:e.id}))}))),o._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||o._expand(i.children||[],i)})),this.postExecuted(["shape.resize"],(function(e){var t=e.context,n=t.hints,i=t.shape,r=i.parent;n&&!1===n.autoResize||r&&o._expand([i],r)}))}function op(e){e.invoke(rp,this)}function ap(e){zc.call(this,e);var t=this;this.addRule("element.autoResize",(function(e){return t.canResize(e.elements,e.target)}))}function sp(e,t){ap.call(this,e),this._modeling=t}rp.$inject=["eventBus","elementRegistry","modeling","rules"],e(rp,To),rp.prototype._getOptimalBounds=function(e,t){var n=this.getOffset(t),i=this.getPadding(t),r=ln(ht(e)),o=ln(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),un(L({},o,a))},rp.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=ln(e),t=ln(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)}}},rp.prototype.getOffset=function(e){return{top:60,bottom:60,left:100,right:100}},rp.prototype.getPadding=function(e){return{top:2,bottom:2,left:15,right:15}},rp.prototype.resize=function(e,t,n){this._modeling.resizeShape(e,t,null,n)},op.$inject=["injector"],e(op,rp),op.prototype.resize=function(e,t,n){mr(e,"bpmn:Participant")?this._modeling.resizeLane(e,t,null,n):this._modeling.resizeShape(e,t,null,n)},ap.$inject=["eventBus"],e(ap,zc),ap.prototype.canResize=function(e,t){return!1},e(sp,ap),sp.$inject=["eventBus","modeling"],sp.prototype.canResize=function(e,t){if(mr(t.di,"bpmndi:BPMNPlane"))return!1;if(!mr(t,"bpmn:Participant")&&!mr(t,"bpmn:Lane")&&!mr(t,"bpmn:SubProcess"))return!1;var n=!0;return v(e,(function(e){(mr(e,"bpmn:Lane")||sn(e))&&(n=!1)})),n};var cp={__init__:["bpmnAutoResize","bpmnAutoResizeProvider"],bpmnAutoResize:["type",op],bpmnAutoResizeProvider:["type",sp]};function pp(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=ia(e),function(e){return J(e,"svg, .djs-element",!0)}(document.elementFromPoint(t.x,t.y))}}pp.$inject=["elementRegistry","eventBus","injector"];var lp={__init__:["hoverFix"],hoverFix:["type",pp]},up=Math.round,hp="djs-drag-active";function dp(e){e.preventDefault()}function fp(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(L({},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=ia(e),h=za(u,l),d=r.localStart,f=a(u),y=za(f,d);if(!r.active&&(i||(o=h,Math.sqrt(Math.pow(o.x,2)+Math.pow(o.y,2))>r.threshold))){if(L(c,{x:up(d.x+p.x),y:up(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&&La(r.cursor),t.addMarker(t.getRootElement(),hp)}na(e),r.active&&(L(c,{x:up(f.x+p.x),y:up(f.y+p.y),dx:up(y.x),dy:up(y.y)},{originalEvent:e}),s("move"))}function p(e){var t=!0;r.active&&(e&&(r.payload.originalEvent=e,na(e)),t=s("end")),!1===t&&s("rejected"),s("ended",y(!0!==t))}function l(e){ka("Escape",e)&&(dp(e),m())}function u(t){var n;r.active&&(n=Ia(e),setTimeout(n,400),dp(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=y(e),n&&s("canceled",t)}}function y(o){var a,y;s("cleanup"),$a(),y=r.trapClick?u:p,oe.unbind(document,"mousemove",c),oe.unbind(document,"dragstart",dp),oe.unbind(document,"selectstart",dp),oe.unbind(document,"mousedown",y,!0),oe.unbind(document,"mouseup",y,!0),oe.unbind(document,"keyup",l),oe.unbind(document,"touchstart",h,!0),oe.unbind(document,"touchcancel",m,!0),oe.unbind(document,"touchmove",c,!0),oe.unbind(document,"touchend",p,!0),e.off("element.hover",d),e.off("element.out",f),t.removeMarker(t.getRootElement(),hp);var g=r.payload.previousSelection;return!1!==o&&g&&!n.get().length&&function(e){var t=e.filter((function(e){return i.get(e.id)}));t.length&&n.select(t)}(g),a=r,r=null,a}e.on("diagram.destroy",m),this.init=function(t,n,i,y){r&&m(!1),"string"==typeof n&&(y=i,i=n,n=null);var g,v,_,b,x,w=(y=L({},o,y||{})).data||{};b=y.trapClick?u:p,t?(g=ta(t)||t,v=ia(t),na(t),"dragstart"===g.type&&dp(g)):(g=null,v={x:0,y:0}),_=a(v),n||(n=_),x=function(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent}(g),r=L({prefix:i,data:w,payload:{},globalStart:v,displacement:za(n,_),localStart:_,isTouch:x},y),y.manual||(x?(oe.bind(document,"touchstart",h,!0),oe.bind(document,"touchcancel",m,!0),oe.bind(document,"touchmove",c,!0),oe.bind(document,"touchend",p,!0)):(oe.bind(document,"mousemove",c),oe.bind(document,"dragstart",dp),oe.bind(document,"selectstart",dp),oe.bind(document,"mousedown",b,!0),oe.bind(document,"mouseup",b,!0)),oe.bind(document,"keyup",l),e.on("element.hover",d),e.on("element.out",f)),s("init"),y.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){L(o,e)}}fp.$inject=["eventBus","canvas","selection","elementRegistry"];var mp={__depends__:[lp,_a],dragging:["type",fp]};function yp(e,t,n){this._canvas=n,this._opts=L({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 gp(e,t,n){return t<e&&e<n}yp.$inject=["config.autoScroll","eventBus","canvas"],yp.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++)gp(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))},yp.prototype.stopScroll=function(){clearTimeout(this._scrolling)},yp.prototype.setOptions=function(e){this._opts=L({},this._opts,e)},yp.prototype._toBorderPoint=function(e){var t=this._canvas._container.getBoundingClientRect(),n=ia(e.originalEvent);return{x:n.x-t.left,y:n.y-t.top}};var vp={__depends__:[mp],__init__:["autoScroll"],autoScroll:["type",yp]};function _p(e){this._commandStack=e.get("commandStack",!1)}_p.$inject=["injector"],_p.prototype.allowed=function(e,t){var n=!0,i=this._commandStack;return i&&(n=i.canExecute(e,t)),void 0===n||n};var bp={__init__:["rules"],rules:["type",_p]},xp=Math.round,wp=Math.max;function Ep(e,t){return function(e,t){var n,i;for(n=0;i=e[n];n++)if(xt(i,t)<=10)return{point:e[n],bendpoint:!0,index:n};return null}(e,t)||function(e,t){var n,i,r=Qt(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=wp(o.segment2,a.segment2)-1],bendpoint:!0,index:i}:{point:{x:xp(o.x+a.x)/2,y:xp(o.y+a.y)/2},index:o.segment2}:{point:{x:xp(o.x),y:xp(o.y)},index:o.segment2}:null}(e,t)}function Sp(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}function Cp(e){return Math.atan((e[1].y-e[0].y)/(e[1].x-e[0].x))}function kp(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 Rp(e,t){var n=kp(e,t);return Sp({x:n.x-e.x,y:n.y-e.y})}function Pp(e,t){return Sp({x:e.x-t.x,y:e.y-t.y})}var Ap="djs-bendpoint",Mp="djs-segment-dragger";function Tp(e,t,n){var i=function(e,t){var n,i=ia(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);return Ep(t,i)}function Bp(e,t){var n=Ae("g");we(n).add(Ap),ge(e,n);var i=Ae("circle");be(i,{cx:0,cy:0,r:4}),we(i).add("djs-visual"),ge(n,i);var r=Ae("circle");return be(r,{cx:0,cy:0,r:10}),we(r).add("djs-hit"),ge(n,r),t&&we(n).add(t),n}function Dp(e,t,n,i){var r=Ae("g");ge(e,r);var o=function(e,t,n){var i=t.x-e.x,r=t.y-e.y;return jp("h"===n?i:r)}(t,n,i),a=Ae("rect");be(a,{x:-9,y:-3,width:18,height:6}),we(a).add("djs-visual"),ge(r,a);var s=Ae("rect");return be(s,{x:-o/2,y:-8.5,width:o,height:17}),we(s).add("djs-hit"),ge(r,s),Wn(r,"v"===i?90:0),r}function Np(e,t,n){var i=Ae("g"),r=kt(t,n),o=Et(t,n);return ge(e,i),Dp(i,t,n,o),we(i).add(Mp),we(i).add("h"===o?"horizontal":"vertical"),Gn(i,r.x,r.y),i}function jp(e){return Math.abs(Math.round(2*e/3))}function Op(e,t){var n=function(e,t){for(var n,i=t.waypoints,r=1/0,o=0;o<i.length-1;o++){var a=Rp(e,[i[o],i[o+1]]);a<r&&(r=a,n=o)}return[i[n],i[n+1]]}(e,t);return kp(e,n)}function Lp(e,t,n,i,r){function o(e,n){var o,a=n.waypoints,s=Tp(t,a,e);if(s)return o=function(e,t){var n,i,r=e.waypoints;return t.index<=0||t.bendpoint?null:(i=Et((n={start:r[t.index-1],end:r[t.index]}).start,n.end))?jp("h"===i?n.end.x-n.start.x:n.end.y-n.start.y)/2:null}(n,s),!function(e,t,n){var i,r,o,a,s,c,p=e.index,l=e.point;return!(p<=0||e.bendpoint)&&(o=kt(i=t[p-1],r=t[p]),a=Et(i,r),s=Math.abs(l.x-o.x),c=Math.abs(l.y-o.y),a&&s<=n&&c<=n)}(s,a,o)?i.start(e,n,s.index,!s.bendpoint):r.start(e,n,s.index),!0}function a(e,t,i){oe.bind(e,t,(function(e){n.triggerMouseEvent(t,e,i),e.stopPropagation()}))}function s(e,n){var i=t.getLayer("overlays"),r=fe('.djs-bendpoints[data-element-id="'+jo(e.id)+'"]',i);return!r&&n&&(be(r=Ae("g"),{"data-element-id":e.id}),we(r).add("djs-bendpoints"),ge(i,r),a(r,"mousedown",e),a(r,"click",e),a(r,"dblclick",e)),r}function c(e,t){return fe('.djs-segment-dragger[data-segment-idx="'+e+'"]',t)}function p(e,t){t.waypoints.forEach((function(t,n){var i=Bp(e);ge(e,i),Gn(i,t.x,t.y)})),Bp(e,"floating")}function l(e,t){for(var n,i,r,o=t.waypoints,s=1;s<o.length;s++)Et(n=o[s-1],i=o[s])&&(be(r=Np(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){v(me("."+Mp,e),(function(e){Fe(e)}))}(t),function(e){v(me("."+Ap,e),(function(e){Fe(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=kt(a,s),u=Et(a,s);o&&(i=function(e){return fe(".djs-visual",e)}(o),r={x:p.x-l.x,y:p.y-l.y},"v"===u&&(r={x:r.y,y:r.x}),Gn(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&&Fe(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=Tp(t,o,e.originalEvent)))return;!function(e,t){var n=fe(".floating",e),i=t.point;n&&Gn(n,i.x,i.y)}(n,i),i.bendpoint||d(n,i,o)}})),e.on("element.mousedown",(function(e){if(aa(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&&be(i,{"data-element-id":n})}})),this.addHandles=u,this.updateHandles=h,this.getBendpointsContainer=s,this.getSegmentDragger=c}Lp.$inject=["eventBus","canvas","interactionEvents","bendpointMove","connectionSegmentMove"];var $p=Math.round,Ip="reconnectStart",Fp="reconnectEnd",zp="updateWaypoints";function Hp(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?zp:Fp:Ip)===zp?"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===zp?"connection.updateWaypoints":"connection.reconnect";if(t=n.allowed=r.allowed(p,{connection:i,source:c===Ip?s:o,target:c===Fp?s:a}))return n.source=c===Ip?s:o,void(n.target=c===Fp?s:a);!1===t&&(t=n.allowed=r.allowed(p,{connection:i,source:c===Fp?s:a,target:c===Ip?s:o})),t&&(n.source=c===Fp?s:a,n.target=c===Ip?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!==zp&&(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:$p(e.x),y:$p(e.y)};if(!n)return!1;l===zp?(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===xt(t,i=e[r+1])||wt(n,i,t)?e.splice(r,1):r++;return e}(s),u)):(l===Ip?(u.docking="source",Vp(t)&&(u.docking="target",u.newWaypoints=s.reverse())):l===Fp&&(u.docking="target",Vp(t)&&(u.docking="source",u.newWaypoints=s.reverse())),o.reconnect(r,c,p,h,u))}),this)}function Vp(e){var t=e.hover,n=e.source,i=e.target,r=e.type;return r===Ip?t&&i&&t===i&&n!==i:r===Fp?t&&n&&t===n&&n!==i:void 0}Hp.$inject=["injector","eventBus","canvas","dragging","rules","modeling"],Hp.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 Gp="updateWaypoints",Wp="connect-ok",Up="connect-not-ok",qp="connect-hover",Kp="djs-updating",Yp="djs-dragging";function Xp(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=Bp(i.getLayer("overlays"))).add("djs-dragging"),i.addMarker(r,Yp),i.addMarker(r,Kp)})),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,qp),o===Gp)return;n?(i.removeMarker(r,Up),i.addMarker(r,Wp)):!1===n&&(i.removeMarker(r,Wp),i.addMarker(r,Up))}})),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,qp),i.removeMarker(n,r?Wp:Up))})),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?Vp(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?Vp(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===Gp&&(h=e.cropWaypoints(p,h)),m.waypoints=h,r.drawPreview(n,i,m)),Gn(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,Fe(o),i.removeMarker(n,Kp),i.removeMarker(n,Yp),a&&(i.removeMarker(a,Wp),i.removeMarker(a,s?Wp:Up)),r&&r.cleanUp(t)}))}Xp.$inject=["bendpointMove","injector","eventBus","canvas"];var Zp="connect-hover",Qp="djs-updating";function Jp(e,t,n){return el(e,t,e[t]+n)}function el(e,t,n){return{x:"x"===t?n:e.x,y:"y"===t?n:e.y}}function tl(e){return"x"===e?"y":"x"}function nl(e,t,n){var i,r;return e.original?e.original:(i=dn(t),el(e,r=tl(n),i[r]))}function il(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 el(t,i,Math.min(Math.max(o+20,e[i]),r-20))}(n,i[e.segmentStartIndex+t],i[e.segmentEndIndex+t],tl(e.axis));Gn(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=Tp(n,h,e);(a=Et(d,f))&&(s="v"===a?"x":"y",0===l&&(d=nl(d,t.source,s)),u===h.length-1&&(f=nl(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=Np(r,t.segmentStart,t.segmentEnd),we(t.draggerGfx).add("djs-dragging"),n.addMarker(i,Qp)})),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=Jp(l,h,e["d"+h]),m=Jp(u,h,e["d"+h]),y=d.length,g=0;d[o]=f,d[a]=m,o<2&&(t=fn(r.source,f),1===o?"intersect"===t&&(d.shift(),d[0]=f,g--):"intersect"!==t&&(d.unshift(l),g++)),a>y-3&&(n=fn(r.target,m),a===y-2?"intersect"===n&&(d.pop(),d[d.length-1]=m):"intersect"!==n&&d.push(u)),i.newWaypoints=r.waypoints=s(r,d),p(i,g,e),i.newSegmentStartIndex=o+g,c(e)})),t.on("connectionSegment.move.hover",(function(e){e.context.hover=e.hover,n.addMarker(e.hover,Zp)})),t.on(["connectionSegment.move.out","connectionSegment.move.cleanup"],(function(e){var t=e.context.hover;t&&n.removeMarker(t,Zp)})),t.on("connectionSegment.move.cleanup",(function(e){var t=e.context,i=t.connection;t.draggerGfx&&Fe(t.draggerGfx),n.removeMarker(i,Qp)})),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;i=i.map((function(e){return{original:e.original,x:Math.round(e.x),y:Math.round(e.y)}}));var a=function(e,t){var n=0,i=e.filter((function(i,r){return!wt(e[r-1],e[r+1],i)||(n=r<=t?n-1:n,!1)}));return{waypoints:i,segmentOffset:n}}(i,r),c=s(n,a.waypoints),p=a.segmentOffset,l={segmentMove:{segmentStartIndex:t.segmentStartIndex,newSegmentStartIndex:r+p}};o.updateWaypoints(n,c,l)}))}il.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];var rl=Math.abs,ol=Math.round;function al(e){return{x:e.x,y:e.y}}function sl(e){return{x:e.x+e.width,y:e.y+e.height}}function cl(e,t){return!e||isNaN(e.x)||isNaN(e.y)?t:{x:ol(e.x+e.width/2),y:ol(e.y+e.height/2)}}function pl(e,t){var n=e.snapped;return!!n&&("string"==typeof t?n[t]:n.x&&n.y)}function ll(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 ul(e){return e.children||[]}var hl=Math.abs,dl=Math.round;function fl(e){function t(e,t){if(p(e)){for(var n=e.length;n--;)if(hl(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,t){return e.waypoints?Op(t,e):e.width?{x:dl(e.width/2+e.x),y:dl(e.height/2+e.y)}:void 0}e.on("connectionSegment.move.move",1500,(function(e){var i,r,o=function(e){var t=e.context,i=t.snapPoints,r=t.connection,o=r.waypoints,a=t.segmentStart,s=t.segmentStartIndex,c=t.segmentEnd,p=t.segmentEndIndex,l=t.axis;if(i)return i;var u=[o[s-1],a,c,o[p+1]];return s<2&&u.unshift(n(r.source,e)),p>o.length-3&&u.unshift(n(r.target,e)),t.snapPoints=i={horizontal:[],vertical:[]},v(u,(function(e){e&&(e=e.original||e,"y"===l&&i.horizontal.push(e.y),"x"===l&&i.vertical.push(e.x))})),i}(e),a=e.x,s=e.y;if(o){var c=a-(i=t(o.vertical,a)),p=s-(r=t(o.horizontal,s));L(e,{dx:e.dx-c,dy:e.dy-p,x:i,y:r}),(c||-1!==o.vertical.indexOf(a))&&ll(e,"x",i),(p||-1!==o.horizontal.indexOf(s))&&ll(e,"y",r)}})),e.on(["connect.hover","connect.move","connect.end"],1500,(function(e){var t=e.context.hover,i=t&&n(t,e);an(t)&&i&&i.x&&i.y&&(ll(e,"x",i.x),ll(e,"y",i.y))})),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:[]},v(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,e),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));L(e,{dx:e.dx-u,dy:e.dy-h,x:e.x-u,y:e.y-h}),(u||-1!==a.vertical.indexOf(p))&&ll(e,"x",i),(h||-1!==a.horizontal.indexOf(l))&&ll(e,"y",r)}}))}fl.$inject=["eventBus"];var ml={__depends__:[mp,bp],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",Lp],bendpointMove:["type",Hp],bendpointMovePreview:["type",Xp],connectionSegmentMove:["type",il],bendpointSnapping:["type",fl]};function yl(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,!c(t=n.canExecute=r(i,o))){if(!1!==t)return n.source=i,void(n.target=o);c(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:gl(t)?o:r,connectionEnd:gl(t)?r:o};l(i)&&(c=i),t.connection=n.connect(a,s,c,p)})),this.start=function(e,n,i,r){l(i)||(r=i,i=dn(n)),t.init(e,"connect",{autoActivate:r,data:{shape:n,context:{start:n,connectionStart:i}}})}}function gl(e){var t=e.hover,n=e.source,i=e.target;return t&&n&&t===n&&n!==i}yl.$inject=["eventBus","dragging","modeling","rules"];var vl="connect-ok",_l="connect-not-ok";function bl(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;gl(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?vl:_l)})),t.on(["connect.out","connect.cleanup"],1100,(function(e){var t=e.hover;t&&(n.removeMarker(t,vl),n.removeMarker(t,_l))})),i&&t.on("connect.cleanup",(function(e){i.cleanUp(e.context)}))}bl.$inject=["injector","eventBus","canvas"];var xl={__depends__:[_a,bp,mp],__init__:["connectPreview"],connect:["type",yl],connectPreview:["type",bl]};function wl(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)}wl.$inject=["injector","canvas","graphicsFactory","elementFactory"],wl.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,y=this;a||(a=e.connectionPreviewGfx=this.createConnectionPreviewGfx()),Se(a),s||(s=e.getConnection=(r=function(e,t,n){return y.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?dn(c):u,p?dn(p):h]),this._connectionDocking&&(c||p)&&!f&&(i.waypoints=this._connectionDocking.getCroppedWaypoints(i,c,p)),this._graphicsFactory.drawConnection(a,i,{stroke:"var(--element-dragger-color)"})):!m&&this.drawNoopPreview(a,n)},wl.prototype.drawNoopPreview=function(e,t){var n=t.source,i=t.target,r=t.connectionStart||dn(n),o=t.connectionEnd||dn(i),a=this.cropWaypoints(r,o,n,i);ge(e,this.createNoopConnection(a[0],a[1]))},wl.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&&mn(o,s,!0)||e,t=i&&mn(a,s,!1)||t]},wl.prototype.cleanUp=function(e){e&&e.connectionPreviewGfx&&Fe(e.connectionPreviewGfx)},wl.prototype.getConnection=function(e){var t=function(e){return l(e)?e:{}}(e);return this._elementFactory.createConnection(t)},wl.prototype.createConnectionPreviewGfx=function(){var e=Ae("g");return be(e,{pointerEvents:"none"}),we(e).add("djs-dragger"),ge(this._canvas.getActiveLayer(),e),e},wl.prototype.createNoopConnection=function(e,t){return ot([e,t],{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"})};var El={__init__:["connectionPreview"],connectionPreview:["type",wl]};const Sl=new wo("ps");var Cl=["marker-start","marker-mid","marker-end"],kl=["circle","ellipse","line","path","polygon","polyline","path","rect"];function Rl(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._styles=i}Rl.$inject=["elementRegistry","eventBus","canvas","styles"],Rl.prototype.cleanUp=function(){console.warn("PreviewSupport#cleanUp is deprecated and will be removed in future versions. You do not need to manually clean up previews anymore. cf. https://github.com/bpmn-io/diagram-js/pull/906")},Rl.prototype.getGfx=function(e){return this._elementRegistry.getGraphics(e)},Rl.prototype.addDragger=function(e,t,n,i="djs-dragger"){var r=Ce(n=n||this.getGfx(e)),o=n.getBoundingClientRect();return this._cloneMarkers(Hn(r),i),be(r,this._styles.cls(i,[],{x:o.top,y:o.left})),ge(t,r),be(r,"data-preview-support-element-id",e.id),r},Rl.prototype.addFrame=function(e,t){var n=Ae("rect",{class:"djs-resize-overlay",width:e.width,height:e.height,x:e.x,y:e.y});return ge(t,n),be(n,"data-preview-support-element-id",e.id),n},Rl.prototype._cloneMarkers=function(e,t="djs-dragger",n=e){var i=this;e.childNodes&&e.childNodes.forEach((e=>{i._cloneMarkers(e,t,n)})),function(e){return-1!==kl.indexOf(e.nodeName)}(e)&&Cl.forEach((function(r){if(be(e,r)){var o=function(e,t,n){var i=(r=be(e,t),r.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]);var r;return fe("marker#"+i,n||document)}(e,r,i._canvas.getContainer());o&&i._cloneMarker(n,e,o,r,t)}}))},Rl.prototype._cloneMarker=function(e,t,n,i,r="djs-dragger"){var o=[n.id,r,Sl.next()].join("-"),a=fe("marker#"+n.id,e);e=e||this._canvas._svg;var s=a||Ce(n);s.id=o,we(s).add(r);var c=fe(":scope > defs",e);c||ge(e,c=Ae("defs")),ge(c,s),be(t,i,"url(#"+s.id+")")};var Pl={__init__:["previewSupport"],previewSupport:["type",Rl]};const Al="complex-preview";class Ml{constructor(e,t,n){this._canvas=e,this._graphicsFactory=t,this._previewSupport=n,this._markers=[]}create(e){this.cleanUp();const{created:t=[],moved:n=[],removed:i=[],resized:r=[]}=e,o=this._canvas.getLayer(Al);t.filter((e=>!function(e){return e.hidden}(e))).forEach((e=>{let t;an(e)?(t=this._graphicsFactory._createContainer("connection",Ae("g")),this._graphicsFactory.drawConnection(Hn(t),e)):(t=this._graphicsFactory._createContainer("shape",Ae("g")),this._graphicsFactory.drawShape(Hn(t),e),Gn(t,e.x,e.y)),this._previewSupport.addDragger(e,o,t)})),n.forEach((({element:e,delta:t})=>{this._previewSupport.addDragger(e,o,void 0,"djs-dragging"),this._canvas.addMarker(e,"djs-element-hidden"),this._markers.push([e,"djs-element-hidden"]);const n=this._previewSupport.addDragger(e,o);an(e)?Gn(n,t.x,t.y):Gn(n,e.x+t.x,e.y+t.y)})),i.forEach((e=>{this._previewSupport.addDragger(e,o,void 0,"djs-dragging"),this._canvas.addMarker(e,"djs-element-hidden"),this._markers.push([e,"djs-element-hidden"])})),r.forEach((({shape:e,bounds:t})=>{this._canvas.addMarker(e,"djs-hidden"),this._markers.push([e,"djs-hidden"]),this._previewSupport.addDragger(e,o,void 0,"djs-dragging");const n=this._graphicsFactory._createContainer("shape",Ae("g"));this._graphicsFactory.drawShape(Hn(n),e,{width:t.width,height:t.height}),Gn(n,t.x,t.y),this._previewSupport.addDragger(e,o,n)}))}cleanUp(){Se(this._canvas.getLayer(Al)),this._markers.forEach((([e,t])=>this._canvas.removeMarker(e,t))),this._markers=[]}show(){this._canvas.showLayer(Al)}hide(){this._canvas.hideLayer(Al)}}Ml.$inject=["canvas","graphicsFactory","previewSupport"];var Tl={__depends__:[Pl],__init__:["complexPreview"],complexPreview:["type",Ml]},Bl=["top","bottom","left","right"],Dl=10;function Nl(e,t){function n(e){if(zr(e)&&!an(e)){var n=function(e){var t=dn(e.label),n=dn(e),i=jl(n,t);if(r=i,-1===Bl.indexOf(r))return;var r;var o=function(e){var t=dn(e),n=[].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 jl(t,e)}));return n}(e);if(e.host){var a=function(e){var t,n=e.host,i=dn(e),r=fn(i,n);t=r.indexOf("-")>=0?r.split("-"):[r];var o=Bl.filter((function(e){return-1===t.indexOf(e)}));return o}(e);o=o.concat(a)}var s=Bl.filter((function(e){return-1===o.indexOf(e)}));if(-1!==s.indexOf(i))return;return s[0]}(e);n&&function(e,n){var i=dn(e),r=e.label,o=dn(r);if(!r.parent)return;var a,s=ln(e);switch(n){case"top":a={x:i.x,y:s.top-Dl-r.height/2};break;case"left":a={x:s.left-Dl-r.width/2,y:i.y};break;case"bottom":a={x:i.x,y:s.bottom+Dl+r.height/2};break;case"right":a={x:s.right+Dl+r.width/2,y:i.y}}var c=za(a,o);t.moveShape(r,c)}(e,n)}}To.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 jl(e,t){return fn(t,e,5)}function Ol(e){To.call(this,e),this.preExecute("shape.append",(function(e){var t=e.source,n=e.shape;e.position||(mr(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 Ll(e,t){e.invoke(To,this),this.postExecute("shape.move",(function(e){var n=e.newParent,i=e.shape;v(g(i.incoming.concat(i.outgoing),(function(e){return mr(e,"bpmn:Association")})),(function(e){t.moveConnection(e,{x:0,y:0},n)}))}),!0)}e(Nl,To),Nl.$inject=["eventBus","modeling"],e(Ol,To),Ol.$inject=["eventBus"],e(Ll,To),Ll.$inject=["injector","modeling"];function $l(e,t){t.invoke(To,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 Il(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];Il(r,i)&&(e.shapes=[n._replaceShape(r,i)])}}),!0)}function Il(e,t){return!sn(e)&&yr(e,["bpmn:IntermediateThrowEvent","bpmn:IntermediateCatchEvent"])&&!!t}function Fl(e,t){function n(e){return g(e.attachers,(function(e){return mr(e,"bpmn:BoundaryEvent")}))}To.call(this,e),this.postExecute("connection.create",(function(e){var i=e.context.source,r=e.context.target,o=n(r);mr(i,"bpmn:EventBasedGateway")&&mr(r,"bpmn:ReceiveTask")&&o.length>0&&t.removeElements(o)})),this.postExecute("connection.reconnect",(function(e){var i=e.context.oldSource,r=e.context.newSource;mr(i,"bpmn:Gateway")&&mr(r,"bpmn:EventBasedGateway")&&v(r.outgoing,(function(e){var i=e.target,r=n(i);mr(i,"bpmn:ReceiveTask")&&r.length>0&&t.removeElements(r)}))}))}function zl(e,t,n){function i(e){t.updateProperties(e,{isForCompensation:!0})}function r(e){t.updateProperties(e,{isForCompensation:void 0})}To.call(this,e),this.preExecute("shape.replace",(function(e){const{newData:n,oldShape:i}=e;if(Vl(e.oldShape)&&"bpmn:CompensateEventDefinition"!==n.eventDefinitionType||"bpmn:BoundaryEvent"!==n.type){const t=i.outgoing.find((({target:e})=>Hl(e)));t&&t.target&&(e._connectionTarget=t.target)}else if(!Vl(e.oldShape)&&"bpmn:CompensateEventDefinition"===n.eventDefinitionType&&"bpmn:BoundaryEvent"===n.type){const n=i.outgoing.find((({target:e})=>Gl(e)));n&&n.target&&(e._connectionTarget=n.target),function(e){const n=e.outgoing.filter((e=>mr(e,"bpmn:SequenceFlow")));t.removeElements(n)}(i)}}),!0),this.postExecuted("shape.replace",(function(e){const{_connectionTarget:n,newShape:i}=e;n&&t.connect(i,n)}),!0),this.preExecute("connection.create",(function(e){const n=e.connection,r=e.source,o=e.target;Vl(r)&&Gl(o)&&(i(o),function(e,n){const i=e.outgoing.filter((e=>mr(e,"bpmn:Association"))),r=i.filter((e=>Hl(e.target)&&!n.includes(e)));r.forEach((e=>t.removeConnection(e)))}(r,[n]))}),!0),this.postExecuted("connection.delete",(function(e){const t=e.source,n=e.target;Vl(t)&&Hl(n)&&r(n)}),!0),this.postExecuted("connection.reconnect",(function(e){const t=e.newTarget,n=e.oldSource,o=e.oldTarget;if(o!==t){const e=n;Hl(o)&&r(o),Vl(e)&&Gl(t)&&i(t)}}),!0),this.postExecuted("element.updateProperties",(function(e){const{element:i}=e;Hl(i)?(function(e){for(const i of e.incoming)n.canConnect(i.source,e)||t.removeConnection(i);for(const i of e.outgoing)n.canConnect(e,i.target)||t.removeConnection(i)}(i),function(e){const n=e.attachers.slice();if(!n.length)return;t.removeElements(n)}(i)):Gl(i)&&function(e){const n=e.incoming.filter((e=>Vl(e.source)));t.removeElements(n)}(i)}),!0)}function Hl(e){const t=gr(e);return t&&t.get("isForCompensation")}function Vl(e){return e&&mr(e,"bpmn:BoundaryEvent")&&$r(e,"bpmn:CompensateEventDefinition")}function Gl(e){return e&&mr(e,"bpmn:Activity")&&!Lr(e)}function Wl(e){e.invoke(To,this),this.preExecute("shape.create",1500,(function(e){var t=e.context,n=t.parent,i=t.shape;mr(n,"bpmn:Lane")&&!mr(i,"bpmn:Lane")&&(t.parent=Qc(n,"bpmn:Participant"))}))}function Ul(e,t){To.call(this,e),this.preExecute("shape.create",(function(e){var n=e.context.shape;if(mr(n,"bpmn:DataObjectReference")&&"label"!==n.type){var i=t.create("bpmn:DataObject");n.businessObject.dataObjectRef=i}}))}$l.$inject=["bpmnReplace","injector"],e($l,To),$l.prototype._replaceShape=function(e,t){var n,i=(n=gr(e).eventDefinitions)&&n[0],r={type:"bpmn:BoundaryEvent",host:t};return i&&(r.eventDefinitionType=i.$type),this._bpmnReplace.replaceElement(e,r,{layoutConnection:!1})},Fl.$inject=["eventBus","modeling"],e(Fl,To),e(zl,To),zl.$inject=["eventBus","modeling","bpmnRules"],Wl.$inject=["injector"],e(Wl,To),Ul.$inject=["eventBus","bpmnFactory"],e(Ul,To);var ql=20,Kl=20,Yl=2e3;function Xl(e,t,n){function i(){var t=e.getRootElement();return mr(t,"bpmn:Collaboration")?t:n.makeCollaboration()}To.call(this,t),t.on(["create.start","shape.move.start"],Yl,(function(t){var n=t.context,i=n.shape,r=e.getRootElement();if(mr(i,"bpmn:Participant")&&mr(r,"bpmn:Process")&&r.children.length){var o=r.children.filter((function(e){return!mr(e,"bpmn:Group")&&!sn(e)&&!an(e)}));if(o.length){var a=ht(o),s=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);L(i,s),n.createConstraints=function(e,t){return t=ln(t),{bottom:t.top+e.height/2-Kl,left:t.right-e.width/2+ql,top:t.bottom-e.height/2+Kl,right:t.left+e.width/2-ql-30}}(i,a)}}})),t.on("create.start",Yl,(function(n){var i=n.context.shape,r=e.getRootElement(),o=e.getGraphics(r);function a(e){e.element=r,e.gfx=o}mr(i,"bpmn:Participant")&&mr(r,"bpmn:Process")&&(t.on("element.hover",Yl,a),t.once("create.cleanup",(function(){t.off("element.hover",a)})))})),this.preExecute("elements.create",Yl,(function(e){var t,n=e.elements,r=e.parent,o=function(e){return m(e,(function(e){return mr(e,"bpmn:Participant")}))}(n);o&&mr(r,"bpmn:Process")&&(e.parent=i(),(t=e.hints=e.hints||{}).participant=o,t.process=r,t.processRef=gr(o).get("processRef"))}),!0),this.preExecute("shape.create",(function(e){var t=e.parent,n=e.shape;mr(n,"bpmn:Participant")&&mr(t,"bpmn:Process")&&(e.parent=i(),e.process=t,e.processRef=gr(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||gr(i).set("processRef",gr(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||gr(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)}Xl.$inject=["canvas","eventBus","modeling"],e(Xl,To);var Zl="__targetRef_placeholder";function Ql(e,t){function n(e,n){var i=e.get("properties"),r=m(i,(function(e){return e.name===Zl}));return!r&&n&&_t(i,r=t.create("bpmn:Property",{name:Zl})),r}function i(e,t){var i=n(e);i&&(function(e,t,n){return m(e.get("dataInputAssociations"),(function(e){return e!==n&&e.targetRef===t}))}(e,i,t)||vt(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}To.call(this,e),this.executed(["connection.create","connection.delete","connection.move","connection.reconnect"],Jl(r)),this.reverted(["connection.create","connection.delete","connection.move","connection.reconnect"],Jl(r))}function Jl(e){return function(t){if(mr(t.context.connection,"bpmn:DataInputAssociation"))return e(t)}}function eu(e){this._bpmnUpdater=e}function tu(e,t,n,i){function r(e){return e.children.filter((function(e){return mr(e,"bpmn:DataStoreReference")&&!e.labelTarget}))}function o(e,i){var r=e.businessObject||e;if(i=i||n.filter((function(e){return mr(e,"bpmn:Participant")&&gr(e).processRef}))[0]){var o=i.businessObject||i;t.execute("dataStore.updateContainment",{dataStoreBo:r,dataStoreDi:vr(e),newSemanticParent:o.processRef||o,newDiParent:vr(i)})}}To.call(this,i),t.registerHandler("dataStore.updateContainment",eu),this.preExecute("shape.create",(function(e){var t=e.context,n=t.shape;mr(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 mr(e,"bpmn:DataStoreReference")})).length&&(t.hints||(t.hints={}),t.hints.autoResize=n.filter((function(e){return!mr(e,"bpmn:DataStoreReference")})))})),this.postExecute("shape.create",(function(e){var t=e.context.shape,n=t.parent;mr(t,"bpmn:DataStoreReference")&&"label"!==t.type&&mr(n,"bpmn:Collaboration")&&o(t)})),this.postExecute("shape.move",(function(e){var t=e.context,n=t.shape,i=t.oldParent,r=n.parent;mr(i,"bpmn:Collaboration")||mr(n,"bpmn:DataStoreReference")&&"label"!==n.type&&mr(r,"bpmn:Collaboration")&&o(n,mr(i,"bpmn:Participant")?i:function(e,t){for(;e.parent;){if(mr(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();yr(n,["bpmn:Participant","bpmn:SubProcess"])&&mr(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){mr(i,"bpmn:Process")&&o(e,i)}))}))}Ql.$inject=["eventBus","bpmnFactory"],e(Ql,To),eu.$inject=["bpmnUpdater"],eu.prototype.execute=function(e){var t=e.dataStoreBo,n=e.dataStoreDi,i=e.newSemanticParent,r=e.newDiParent;return e.oldSemanticParent=t.$parent,e.oldDiParent=n.$parent,this._bpmnUpdater.updateSemanticParent(t,i),this._bpmnUpdater.updateDiParent(n,r),[]},eu.prototype.revert=function(e){var t=e.dataStoreBo,n=e.dataStoreDi,i=e.oldSemanticParent,r=e.oldDiParent;return this._bpmnUpdater.updateSemanticParent(t,i),this._bpmnUpdater.updateDiParent(n,r),[]},tu.$inject=["canvas","commandStack","elementRegistry","eventBus"],e(tu,To);var nu=Math.max,iu=Math.min;function ru(e,t){return{top:e.top-t.top,right:e.right-t.right,bottom:e.bottom-t.bottom,left:e.left-t.left}}function ou(e,t,n){var i=t[e],r=n.min&&n.min[e],o=n.max&&n.max[e];return u(r)&&(i=(/top|left/.test(e)?iu:nu)(i,r)),u(o)&&(i=(/top|left/.test(e)?nu:iu)(i,o)),i}function au(e,t){return void 0!==e?e:20}function su(e){return!e.waypoints&&"label"!==e.type}function cu(e,t){var n;if((n=void 0===e.length?g(e.children,su):e).length)return function(e,t){var n,i,r,o;return"object"==typeof t?(n=au(t.left),i=au(t.right),r=au(t.top),o=au(t.bottom)):n=i=r=o=au(t),{x:e.x-n,y:e.y-r,width:e.width+n+i,height:e.height+r+o}}(ht(n),t)}var pu=Math.abs;var lu=["bpmn:Participant","bpmn:Process","bpmn:SubProcess"],uu=30;function hu(e,t){return t=t||[],e.children.filter((function(e){mr(e,"bpmn:Lane")&&(hu(e,t),t.push(e))})),t}function du(e){return e.children.filter((function(e){return mr(e,"bpmn:Lane")}))}function fu(e){return Qc(e,lu)||e}function mu(e,t){var n=fu(e),i=hu(n,mr(n,"bpmn:Process")?[]:[n]),r=ln(e),o=ln(t),a=function(e,t){return ru(ln(t),ln(e))}(e,t),s=[],c=Or(e);return i.forEach((function(t){if(t!==e){var n,i,p=c?0:a.top,l=c?a.right:0,u=c?0:a.bottom,h=c?a.left:0,d=ln(t);a.top&&(pu(d.bottom-r.top)<10&&(u=o.top-d.bottom),pu(d.top-r.top)<5&&(p=o.top-d.top)),a.left&&(pu(d.right-r.left)<10&&(l=o.left-d.right),pu(d.left-r.left)<5&&(h=o.left-d.left)),a.bottom&&(pu(d.top-r.bottom)<10&&(p=o.bottom-d.top),pu(d.bottom-r.bottom)<5&&(u=o.bottom-d.bottom)),a.right&&(pu(d.left-r.right)<10&&(h=o.right-d.left),pu(d.right-r.right)<5&&(l=o.right-d.right)),(p||l||u||h)&&s.push({shape:t,newBounds:(n=t,i={top:p,right:l,bottom:u,left:h},{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 yu(e,t){To.call(this,e),this.postExecuted("shape.delete",500,(function(e){var n=e.context,i=n.hints,r=n.shape,o=n.oldParent;mr(r,"bpmn:Lane")&&(i&&i.nested||function(e,n){var i,r,o,a,s,c=Or(e),p=du(n),l=[],u=[],h=[],d=[];lt(p,(function(t){return c?t.y>e.y?u.push(t):l.push(t):t.x>e.x?d.push(t):h.push(t),t.children})),p.length&&(i=c?u.length&&l.length?e.height/2:e.height:d.length&&h.length?e.width/2:e.width,l.length&&(r=t.calculateAdjustments(l,"y",i,e.y-10),t.makeSpace(r.movingShapes,r.resizingShapes,{x:0,y:i},"s")),u.length&&(o=t.calculateAdjustments(u,"y",-i,e.y+e.height+10),t.makeSpace(o.movingShapes,o.resizingShapes,{x:0,y:-i},"n")),h.length&&(a=t.calculateAdjustments(h,"x",i,e.x-10),t.makeSpace(a.movingShapes,a.resizingShapes,{x:i,y:0},"e")),d.length&&(s=t.calculateAdjustments(d,"x",-i,e.x+e.width+10),t.makeSpace(s.movingShapes,s.resizingShapes,{x:-i,y:0},"w")))}(r,o))}))}yu.$inject=["eventBus","spaceTool"],e(yu,To);function gu(e,t){t.invoke(To,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",500,(function(e){var t=e.elements;t.filter((function(e){return vu(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;vu(e,(o=a,-1!==t.indexOf(o)?a:i))&&(t[r]=n._replaceShape(e))}))}),!0)}function vu(e,t){return!sn(e)&&mr(e,"bpmn:BoundaryEvent")&&!t}function _u(e,t,n){function i(e,i,r){var o,a,s,c,p,l,h,d,f=i.waypoints,m=e.outgoing.slice(),y=e.incoming.slice(),v=Ep(f,d=u(r.width)?dn(r):r);if(v){if(o=f.slice(0,v.index),a=f.slice(v.index+(v.bendpoint?1:0)),!o.length||!a.length)return;s=v.bendpoint?f[v.index]:d,1!==o.length&&bu(e,o[o.length-1])||o.push(xu(s)),1!==a.length&&bu(e,a[0])||a.unshift(xu(s))}c=i.source,p=i.target,t.canConnect(c,e,i)&&(n.reconnectEnd(i,e,o||d),l=i),t.canConnect(e,p,i)&&(l?h=n.connect(e,p,{type:i.type,waypoints:a}):(n.reconnectStart(i,e,a||d),h=i));var _=[].concat(l&&g(y,(function(e){return e.source===l.source}))||[],h&&g(m,(function(e){return e.target===h.target}))||[]);_.length&&n.removeElements(_)}To.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=dn(o),s={x:a.x+r.x,y:a.y+r.y},c=m(n.children,(function(e){return t.canInsert(i,e)&&Ep(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 bu(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 xu(e){return L({},e)}function wu(e,t){To.call(this,e),this.preExecuted("connection.create",(function(e){var n=e.context,i=n.connection,r=n.source,o=n.target,a=n.hints;if((!a||!1!==a.createElementsBehavior)&&Eu(i)){(mr(r,"bpmn:EventBasedGateway")?o.incoming.filter((e=>e!==i&&Eu(e))):o.incoming.filter((e=>e!==i&&Eu(e)&&mr(e.source,"bpmn:EventBasedGateway")))).forEach((function(e){t.removeConnection(e)}))}})),this.preExecuted("shape.replace",(function(e){var n=e.context.newShape;mr(n,"bpmn:EventBasedGateway")&&n.outgoing.filter(Eu).reduce((function(e,t){return e.includes(t.target)?e:e.concat(t.target)}),[]).forEach((function(e){e.incoming.filter(Eu).forEach((function(i){const r=e.incoming.filter(Eu).filter((function(e){return e.source===n}));(i.source!==n||r.length>1)&&t.removeConnection(i)}))}))}))}function Eu(e){return mr(e,"bpmn:SequenceFlow")}gu.$inject=["bpmnReplace","injector"],e(gu,To),gu.prototype._replaceShape=function(e){var t,n,i=(n=gr(e).eventDefinitions)&&n[0];return t=i?{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:i.$type}:{type:"bpmn:IntermediateThrowEvent"},this._bpmnReplace.replaceElement(e,t,{layoutConnection:!1})},e(_u,To),_u.$inject=["eventBus","bpmnRules","modeling"],wu.$inject=["eventBus","modeling"],e(wu,To);var Su=1500;function Cu(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"],Su,(function(t){var i=t.context.shape||t.shape,r=t.hover;mr(r,"bpmn:Lane")&&!yr(i,["bpmn:Lane","bpmn:Participant"])&&(t.hover=fu(r),t.hoverGfx=e.getGraphics(t.hover));var o=n.getRootElement();r!==o&&(i.labelTarget||yr(i,["bpmn:Group","bpmn:TextAnnotation"]))&&(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"],Su,(function(t){var n=t.hover;mr(n,"bpmn:Lane")&&(t.hover=fu(n)||n,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["bendpoint.move.hover"],Su,(function(t){var n=t.context,i=t.hover,r=n.type;mr(i,"bpmn:Lane")&&/reconnect/.test(r)&&(t.hover=fu(i)||i,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["connect.start"],Su,(function(e){var t=e.context,n=t.start;mr(n,"bpmn:Lane")&&(t.start=fu(n)||n)})),t.on("shape.move.start",2e3,(function(e){var t=e.shape;mr(t,"bpmn:Lane")&&(e.shape=fu(t)||t)})),t.on("spaceTool.move",2e3,(function(e){var t=e.hover;t&&mr(t,"bpmn:Lane")&&(e.hover=fu(t))}))}Cu.$inject=["elementRegistry","eventBus","canvas"];function ku(e,t,n,i,r,o){function a(e,t,i){var r=n.filter((function(e){return mr(e,"bpmn:Group")})).filter((function(e){return e.businessObject!==i}));t&&!function(e,t){return e.some((function(e){var n=gr(e);return(n.categoryValueRef&&n.categoryValueRef.$parent)===t}))}(r,t)&&function(e){var t=e.$parent;t&&(vt(t.get("rootElements"),e),e.$parent=null)}(t),e&&!function(e,t){return e.some((function(e){return gr(e).categoryValueRef===t}))}(r,e)&&function(e){var t=e.$parent;t&&(vt(t.get("categoryValue"),e),e.$parent=null)}(e)}function s(e,n){return function(e,t,n){return _t(t.get("categoryValue"),e),e.$parent=t,_t(n.get("rootElements"),t),t.$parent=n,e}(e,n,t.getDefinitions())}function c(n,i){var r=gr(n),o=r.categoryValueRef;o||(o=r.categoryValueRef=i.categoryValue=i.categoryValue||function(e){return e.create("bpmn:CategoryValue")}(e));var a=o.$parent;a||(a=o.$parent=i.category=i.category||function(e){return e.create("bpmn:Category")}(e)),s(o,a,t.getDefinitions())}function p(e,t){var n=t.category,i=t.categoryValue,r=gr(e);i?(r.categoryValueRef=null,a(i,n,r)):a(null,r.categoryValueRef.$parent,r)}function l(t,n){var i=e.create(t.$type);return o.copyElement(t,i,null,n)}r.invoke(To,this),this.execute("label.create",(function(e){var t=e.context,n=t.labelTarget;mr(n,"bpmn:Group")&&c(n,t)})),this.revert("label.create",(function(e){var t=e.context,n=t.labelTarget;mr(n,"bpmn:Group")&&p(n,t)})),this.execute("shape.delete",(function(e){var t=e.context,n=t.shape,i=gr(n);if(mr(n,"bpmn:Group")&&!n.labelTarget){var r=t.categoryValue=i.categoryValueRef;r&&(a(r,t.category=r.$parent,i),i.categoryValueRef=null)}})),this.reverted("shape.delete",(function(e){var t=e.context,n=t.shape;if(mr(n,"bpmn:Group")&&!n.labelTarget){var i=t.category,r=t.categoryValue,o=gr(n);r&&(o.categoryValueRef=r,s(r,i))}})),this.execute("shape.create",(function(e){var t=e.context,n=t.shape;mr(n,"bpmn:Group")&&!n.labelTarget&&gr(n).categoryValueRef&&c(n,t)})),this.reverted("shape.create",(function(e){var t=e.context,n=t.shape;mr(n,"bpmn:Group")&&!n.labelTarget&&gr(n).categoryValueRef&&p(n,t)})),i.on("copyPaste.copyElement",770,(function(e){var t=e.descriptor,n=e.element;if(mr(n,"bpmn:Group")&&!n.labelTarget){var i=gr(n);if(i.categoryValueRef){var r=i.categoryValueRef;t.categoryValue=l(r,!0),r.$parent&&(t.category=l(r.$parent,!0))}}})),i.on("copyPaste.pasteElement",770,(function(e){var t=e.descriptor,n=t.businessObject,i=t.categoryValue,r=t.category;i&&(i=n.categoryValueRef=l(i)),r&&(i.$parent=l(r)),delete t.category,delete t.categoryValue}))}function Ru(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 Pu(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=Ru(e,t,n,r),s=Ru(e,t,n,o);i=a&&s?Au(a,n)>Au(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],dn(n.source)),t(i[i.length-1],i[i.length-2],dn(n.target)))}))}function Au(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Mu(e){To.call(this,e);var t=["bpmn:Participant","bpmn:Lane"];this.executed(["shape.move","shape.create","shape.resize"],(function(e){var n=e.context.shape,i=gr(n),r=vr(n);if(yr(i,t)){var o=r.get("isHorizontal");void 0===o&&(o=!0),r.set("isHorizontal",o)}}))}ku.$inject=["bpmnFactory","bpmnjs","elementRegistry","eventBus","injector","moddleCopy"],e(ku,To),Pu.$inject=["eventBus"],Mu.$inject=["eventBus"],e(Mu,To);var Tu=Math.sqrt,Bu=Math.min,Du=Math.max,Nu=Math.abs;function ju(e){return Math.pow(e,2)}function Ou(e,t){return Tu(ju(e.x-t.x)+ju(e.y-t.y))}function Lu(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=Tu(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 $u(e.x,t.x,n.x)&&$u(e.y,t.y,n.y)}(n,e,t)}))}function $u(e,t,n){return e>=Bu(t,n)-Iu&&e<=Du(t,n)+Iu}var Iu=.1;function Fu(e,t){return Nu(e.x-t.x)<=Iu&&Nu(e.y-t.y)<=Iu}function zu(e,t,n,i){var r=0,o=0,a={point:e,delta:{x:0,y:0}},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(Fu(n=t[f],i=t[f+1])?s=[n]:(r=Ou(e,n),o=Ou(e,i),s=Lu(n,i,e,Bu(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:Fu(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:Ou(n,a)/Ou(n,i)}),p=Ou(c.position,e),(!u||l>p)&&(u=c,l=p)}return u}(e,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&&Hu(t,l)<n.relativeLocation&&c++),c)}return 0===o?r:i.connectionStart&&0===r?0:i.connectionEnd&&r===e.length-2?t.length-2:Math.floor((t.length-2)/2)}(n,t,s,i);if(p<0||p>t.length-2||null===p)return a;var l,u,h=Vu(n,c),d=Vu(t,p),f=s.position,m=function(e,t){var n=Pp(e[0],e[1]),i=Pp(e[0],t);return 0===n?0:i/n}(h,f),y=(l=d,u=Cp(h),Cp(l)-u);if("bendpoint"===s.type){var g=t.length-n.length,v=s.bendpointIndex,_=n[v];if(-1!==t.indexOf(_))return a;if(0===g){var b=t[v];return{delta:{x:r=b.x-s.position.x,y:o=b.y-s.position.y},point:{x:e.x+r,y:e.y+o}}}g<0&&0!==v&&v<n.length-1&&(m=Hu(n,v))}var x,w,E={x:(d[1].x-d[0].x)*m+d[0].x,y:(d[1].y-d[0].y)*m+d[0].y},S=(x={x:e.x-f.x,y:e.y-f.y},(w=y)?{x:Math.cos(w)*x.x-Math.sin(w)*x.y,y:Math.sin(w)*x.x+Math.cos(w)*x.y}:x);return r=E.x+S.x-e.x,o=E.y+S.y-e.y,{point:pn(E),delta:pn({x:r,y:o})}}function Hu(e,t){var n=Pp(e[t-1],e[t]);return n/(n+Pp(e[t],e[t+1]))}function Vu(e,t){return[e[t],e[t+1]]}function Gu(e,t,n){var i=Fa(t),r=Fa(n),o=za(e,i),a=o.x*(n.width/t.width),s=o.y*(n.height/t.height);return pn({x:r.x+a,y:r.y+s})}function Wu(e,t,n){var i=Fa(e),r=Fa(t),o=Fa(n),a=za(e,i),s=za(i,r),c=function(e,t,n){var i=ln(t),r=ln(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,c=fn(t,e);if("top"===c)o={x:0,y:r.bottom-i.bottom};else if("bottom"===c)o={x:0,y:r.top-i.top};else if("right"===c)o={x:r.left-i.left,y:0};else{if("left"!==c)return null;o={x:r.right-i.right,y:0}}if(a={x:e.x+o.x,y:e.y+o.y},s=fn(n,a),s!==c)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 pn({x:u+a.x-e.x,y:h+a.y-e.y})}var Uu="name",qu="text";function Ku(e,t,n,i){function r(e){var n=e.context,r=n.element,o=n.properties;if(Uu in o&&t.updateLabel(r,o[Uu]),qu in o&&mr(r,"bpmn:TextAnnotation")){var a=i.getTextAnnotationBounds({x:r.x,y:r.y,width:r.width,height:r.height},o[qu]||"");t.updateLabel(r,o.text,a)}}function o(e){var t=e.context,n=t.connection,i=n.label,r=L({},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),function(e,t,n,i){return zu(dn(e),t,n,i).delta}(i,o,a,r)}To.call(this,e),this.postExecute("element.updateProperties",r),this.postExecute("element.updateModdleProperties",(e=>{gr(e.context.element)===e.context.moddleElement&&r(e)})),this.postExecute(["shape.create","connection.create"],(function(e){var n=e.context;if(!1!==(n.hints||{}).createElementsBehavior){var i=n.shape||n.connection;!sn(i)&&Fr(i)&&Wr(i)&&t.updateLabel(i,Wr(i))}})),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(["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=o(e),t.moveShape(r,i))}})),this.postExecute(["shape.replace"],(function(e){var t=e.context,n=t.newShape,i=t.oldShape,r=gr(n);r&&Fr(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(zr(r)){var s=r.label,c=function(e,t){if(!t.length)return;var n=function(e,t){var n=t.map((function(t){return{line:t,distance:Rp(e,t)}}));return A(n,"distance")[0].line}(e,t);return kp(e,n)}(dn(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)}]]),p=Yu(c,a,o);t.moveShape(s,p)}}))}function Yu(e,t,n){return pn(za(Gu(e,t,n),e))}function Xu(e,t){function n(e,t){var n=e.context,i=n.connection,r=L({},n.hints),o=n.newWaypoints||i.waypoints,a=n.oldWaypoints;return void 0===r.startChanged&&(r.startChanged=!!r.connectionStart),void 0===r.endChanged&&(r.endChanged=!!r.connectionEnd),function(e,t,n,i){return zu(e,t,n,i).point}(t,o,a,r)}To.call(this,e),this.postExecute(["connection.layout","connection.updateWaypoints"],(function(e){var i=e.context.connection,r=i.outgoing;i.incoming.forEach((function(i){var r=i.waypoints[i.waypoints.length-1],o=n(e,r),a=[].concat(i.waypoints.slice(0,-1),[o]);t.updateWaypoints(i,a)})),r.forEach((function(i){var r=i.waypoints[0],o=n(e,r),a=[].concat([o],i.waypoints.slice(1));t.updateWaypoints(i,a)}))})),this.postExecute(["connection.move"],(function(e){var n=e.context,i=n.connection,r=i.outgoing,o=i.incoming,a=n.delta;o.forEach((function(e){var n=e.waypoints[e.waypoints.length-1],i={x:n.x+a.x,y:n.y+a.y},r=[].concat(e.waypoints.slice(0,-1),[i]);t.updateWaypoints(e,r)})),r.forEach((function(e){var n=e.waypoints[0],i={x:n.x+a.x,y:n.y+a.y},r=[].concat([i],e.waypoints.slice(1));t.updateWaypoints(e,r)}))}))}function Zu(e,t,n){var i=nh(e),r=ih(i,t),o=i[0];return r.length?r[r.length-1]:Gu(o.original||o,n,t)}function Qu(e,t,n){var i=nh(e),r=ih(i,t),o=i[i.length-1];return r.length?r[0]:Gu(o.original||o,n,t)}function Ju(e,t,n){var i=nh(e),r=th(t,n),o=i[0];return Gu(o.original||o,r,t)}function eh(e,t,n){var i=nh(e),r=th(t,n),o=i[i.length-1];return Gu(o.original||o,r,t)}function th(e,t){return{x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}}function nh(e){var t=e.waypoints;if(!t.length)throw new Error("connection#"+e.id+": no waypoints");return t}function ih(e,t){return g(E(e,rh),(function(e){return function(e,t){return"intersect"===fn(t,e,1)}(e,t)}))}function rh(e){return e.original||e}function oh(e,t){To.call(this,e),this.postExecute("shape.replace",(function(e){var n=e.oldShape,i=e.newShape;if(function(e,t){return mr(e,"bpmn:Participant")&&jr(e)&&mr(t,"bpmn:Participant")&&!jr(t)}(n,i)){var r,o,a,s,c=(o=ut([r=n],!1),a=[],s=[],o.forEach((function(e){e!==r&&(e.incoming.forEach((function(e){mr(e,"bpmn:MessageFlow")&&a.push(e)})),e.outgoing.forEach((function(e){mr(e,"bpmn:MessageFlow")&&s.push(e)})))}),[]),{incoming:a,outgoing:s});c.incoming.forEach((function(e){var r=Qu(e,i,n);t.reconnectEnd(e,i,r)})),c.outgoing.forEach((function(e){var r=Zu(e,i,n);t.reconnectStart(e,i,r)}))}}),!0)}e(Ku,To),Ku.$inject=["eventBus","modeling","bpmnFactory","textRenderer"],e(Xu,To),Xu.$inject=["eventBus","modeling"],oh.$inject=["eventBus","modeling"],e(oh,To);const ah=["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:EscalationEventDefinition","bpmn:ConditionalEventDefinition","bpmn:SignalEventDefinition"];function sh(e){const t=gr(e);if(!(mr(t,"bpmn:BoundaryEvent")||mr(t,"bpmn:StartEvent")&&Lr(t.$parent)))return!1;const n=t.get("eventDefinitions");return!(!n||!n.length)&&ah.some((e=>mr(n[0],e)))}function ch(e){return mr(e,"bpmn:BoundaryEvent")?"cancelActivity":"isInterrupting"}function ph(e,t){e.invoke(To,this),this.postExecuted("shape.replace",(function(e){const n=e.context.oldShape,i=e.context.newShape,r=e.context.hints;if(!sh(i))return;const o=ch(i);if(r.targetElement&&void 0!==r.targetElement[o])return;const a=gr(n).get(o);a!==gr(i).get(o)&&t.updateProperties(i,{[o]:a})}))}function lh(e,t){To.call(this,e),this.preExecute("shape.resize",(function(e){var n=e.shape,i=vr(n),r=i&&i.get("label");r&&r.get("bounds")&&t.updateModdleProperties(n,r,{bounds:void 0})}),!0)}function uh(e,t,n){To.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(mr(r,"bpmn:SequenceFlow")&&mr(o,"bpmn:SequenceFlow")&&t.canConnect(r.source,o.target,r)){var a=function(e,t){var n=Ru(hh(e[e.length-2]),hh(e[e.length-1]),hh(t[1]),hh(t[0]));return n?[].concat(e.slice(0,e.length-1),[n],t.slice(1)):[hh(e[0]),hh(t[t.length-1])]}(r.waypoints,o.waypoints);n.reconnectEnd(r,o.target,a)}}}))}function hh(e){return e.original||e}function dh(e,t){To.call(this,e),this.preExecute("shape.delete",(function(e){var t=e.shape,n=t.parent;mr(t,"bpmn:Participant")&&(e.collaborationRoot=n)}),!0),this.postExecute("shape.delete",(function(e){var n=e.collaborationRoot;if(n&&!n.businessObject.participants.length){var i=t.makeProcess(),r=n.children.slice();t.moveElements(r,{x:0,y:0},i)}}),!0)}function fh(e,t,n,i){To.call(this,e);var r=i.get("dragging",!1);function o(e){var i,r,o=e.source,a=e.target;e.parent&&(mr(e,"bpmn:SequenceFlow")&&(n.canConnectSequenceFlow(o,a)||(r=!0),n.canConnectMessageFlow(o,a)&&(i="bpmn:MessageFlow")),mr(e,"bpmn:MessageFlow")&&(n.canConnectMessageFlow(o,a)||(r=!0),n.canConnectSequenceFlow(o,a)&&(i="bpmn:SequenceFlow")),r&&t.removeConnection(e),i&&t.connect(o,a,{type:i,waypoints:e.waypoints.slice()}))}this.postExecuted("elements.move",(function(e){v(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,associationDirection:i.associationDirection,waypoints:s.waypoints.slice()}),s.parent&&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=m(o.outgoing,M({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 mh(e,t,n,i,r,o){i.invoke(To,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=b(r,(function(e,n){var r=t.canReplace([n],n.host||n.parent||i);return r?e.concat(r.replacements):e}),[]);o.length&&this._replaceElements(r,o)}),this),this.postExecuted(["elements.move"],500,(function(e){var n=e.context,i=n.newParent,r=n.newHost,o=[];v(n.closure.topLevel,(function(e){o=Lr(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})}))}ph.$inject=["injector","modeling"],e(ph,To),e(lh,To),lh.$inject=["eventBus","modeling"],e(uh,To),uh.$inject=["eventBus","bpmnRules","modeling"],dh.$inject=["eventBus","modeling"],e(dh,To),e(fh,To),fh.$inject=["eventBus","modeling","bpmnRules","injector"],e(mh,To),mh.prototype._replaceElements=function(e,t){var n=this._elementRegistry,i=this._bpmnReplace,r=this._selection;v(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)},mh.$inject=["bpmnReplace","bpmnRules","elementRegistry","injector","modeling","selection"];var yh={width:140,height:120},gh={width:300,height:60},vh={width:60,height:300},_h={width:300,height:150},bh={width:150,height:300},xh={width:140,height:120},wh={width:50,height:30};function Eh(e){e.on("resize.start",1500,(function(e){var t=e.context,n=t.shape,i=t.direction,r=t.balanced;(mr(n,"bpmn:Lane")||mr(n,"bpmn:Participant"))&&(t.resizeConstraints=function(e,t,n){var i=fu(e),r=!0,o=!0,a=hu(i,[i]),s=ln(e),c={},p={},l=Or(e),u=l?gh:vh;/n/.test(t)?p.top=s.bottom-u.height:/e/.test(t)?p.right=s.left+u.width:/s/.test(t)?p.bottom=s.top+u.height:/w/.test(t)&&(p.left=s.right-u.width);a.forEach((function(e){var i=ln(e);l?(i.top<s.top-10&&(r=!1),i.bottom>s.bottom+10&&(o=!1)):(i.left<s.left-10&&(r=!1),i.right>s.right+10&&(o=!1)),/n/.test(t)&&(n&&Sh(s.top-i.bottom)<10&&Ah(c,"top",i.top+u.height),Sh(s.top-i.top)<5&&Ph(p,"top",i.bottom-u.height)),/e/.test(t)&&(n&&Sh(s.right-i.left)<10&&Ph(c,"right",i.right-u.width),Sh(s.right-i.right)<5&&Ah(p,"right",i.left+u.width)),/s/.test(t)&&(n&&Sh(s.bottom-i.top)<10&&Ph(c,"bottom",i.bottom-u.height),Sh(s.bottom-i.bottom)<5&&Ah(p,"bottom",i.top+u.height)),/w/.test(t)&&(n&&Sh(s.left-i.right)<10&&Ah(c,"left",i.left+u.width),Sh(s.left-i.left)<5&&Ph(p,"left",i.right-u.width))}));var h=i.children.filter((function(e){return!e.hidden&&!e.waypoints&&(mr(e,"bpmn:FlowElement")||mr(e,"bpmn:Artifact"))})),d=l?Mh:Th;return h.forEach((function(e){var n=ln(e);!/n/.test(t)||l&&!r||Ph(p,"top",n.top-d.top),/e/.test(t)&&(l||o)&&Ah(p,"right",n.right+d.right),!/s/.test(t)||l&&!o||Ah(p,"bottom",n.bottom+d.bottom),/w/.test(t)&&(l||r)&&Ph(p,"left",n.left-d.left)})),{min:p,max:c}}(n,i,r)),mr(n,"bpmn:SubProcess")&&jr(n)&&(t.minDimensions=xh),mr(n,"bpmn:TextAnnotation")&&(t.minDimensions=wh)}))}Eh.$inject=["eventBus"];var Sh=Math.abs,Ch=Math.min,kh=Math.max;function Rh(e,t,n,i){var r=e[t];e[t]=void 0===r?n:i(n,r)}function Ph(e,t,n){return Rh(e,t,n,Ch)}function Ah(e,t,n){return Rh(e,t,n,kh)}var Mh={top:20,left:50,right:20,bottom:20},Th={top:50,left:20,right:20,bottom:20};function Bh(e,t){e.on("resize.start",1501,(function(e){var t=e.context,n=t.shape;(mr(n,"bpmn:Lane")||mr(n,"bpmn:Participant"))&&(t.balanced=!sa(e))})),e.on("resize.end",1001,(function(e){var n=e.context,i=n.shape,r=n.canExecute,o=n.newBounds;if(mr(i,"bpmn:Lane")||mr(i,"bpmn:Participant"))return r&&(o=cn(o),t.resizeLane(i,o,n.balanced)),!1}))}Bh.$inject=["eventBus","modeling"];function Dh(e,t,n,i,r){function o(e){return yr(e,["bpmn:ReceiveTask","bpmn:SendTask"])||function(e,t){p(t)||(t=[t]);return w(t,(function(t){return $r(e,t)}))}(e,["bpmn:ErrorEventDefinition","bpmn:EscalationEventDefinition","bpmn:MessageEventDefinition","bpmn:SignalEventDefinition"])}function a(t){return!!m(e.getDefinitions().get("rootElements"),M({id:t.id}))}function s(e){return mr(e,"bpmn:ErrorEventDefinition")?"errorRef":mr(e,"bpmn:EscalationEventDefinition")?"escalationRef":mr(e,"bpmn:MessageEventDefinition")?"messageRef":mr(e,"bpmn:SignalEventDefinition")?"signalRef":void 0}function c(e){if(yr(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.get("messageRef");var t=e.get("eventDefinitions")[0];return t.get(s(t))}n.invoke(To,this),this.executed(["shape.create","element.updateProperties","element.updateModdleProperties"],(function(t){var n=t.shape||t.element;if(o(n)){var i=c(gr(n));i&&!a(i)&&(_t(e.getDefinitions().get("rootElements"),i),t.addedRootElement=i)}}),!0),this.reverted(["shape.create","element.updateProperties","element.updateModdleProperties"],(function(t){var n=t.addedRootElement;n&&vt(e.getDefinitions().get("rootElements"),n)}),!0),t.on("copyPaste.copyElement",(function(e){var t=e.descriptor,n=e.element;if(!n.labelTarget&&o(n)){var i=c(gr(n));i&&(t.referencedRootElement=i)}})),t.on("copyPaste.pasteElement",500,(function(e){var t=e.descriptor,n=t.businessObject,o=t.referencedRootElement;o&&(a(o)||(o=i.copyElement(o,r.create(o.$type))),function(e,t){if(yr(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.set("messageRef",t);var n=e.get("eventDefinitions")[0];n.set(s(n),t)}(n,o),delete t.referencedRootElement)}))}Dh.$inject=["bpmnjs","eventBus","injector","moddleCopy","bpmnFactory"],e(Dh,To);var Nh=Math.max;function jh(e){e.on("spaceTool.getMinDimensions",(function(e){var t=e.shapes,n=e.axis,i=e.start,r={};return v(t,(function(e){var t=e.id;mr(e,"bpmn:Participant")&&(r[t]=function(e,t,n){var i=Or(e);if(r=e,!du(r).length)return i?_h:bh;var r;var o=function(e){return"x"===e}(t),a={};a=o?i?_h:{width:Lh(e,n,o),height:bh.height}:i?{width:_h.width,height:Oh(e,n,o)}:bh;return a}(e,n,i)),mr(e,"bpmn:Lane")&&(r[t]=Or(e)?gh:vh),mr(e,"bpmn:SubProcess")&&jr(e)&&(r[t]=xh),mr(e,"bpmn:TextAnnotation")&&(r[t]=wh),mr(e,"bpmn:Group")&&(r[t]=yh)})),r}))}function Oh(e,t,n){var i;return i=function(e,t,n){var i,r=du(e);return i=$h(r,t,n),e.height-i.height+gh.height}(e,t,n),Nh(_h.height,i)}function Lh(e,t,n){var i;return i=function(e,t,n){var i,r=du(e);return i=$h(r,t,n),e.width-i.width+vh.width}(e,t,n),Nh(bh.width,i)}function $h(e,t,n){var i,r,o;for(i=0;i<e.length;i++)if(r=e[i],!n&&t>=r.y&&t<=r.y+r.height||n&&t>=r.x&&t<=r.x+r.width)return(o=du(r)).length?$h(o,t,n):r}jh.$inject=["eventBus"];var Ih=180,Fh=160;function zh(e,t,n,i,r,o,a){To.call(this,t),this._canvas=e,this._eventBus=t,this._modeling=n,this._elementFactory=i,this._bpmnFactory=r,this._bpmnjs=o,this._elementRegistry=a;var s=this;function c(e){return mr(e,"bpmn:SubProcess")&&!jr(e)}function p(t){var n=t.shape,i=t.newRootElement,r=gr(n);i=s._addDiagram(i||r),t.newRootElement=e.addRootElement(i)}function l(t){var n=gr(t.shape);s._removeDiagram(n);var i=t.newRootElement=a.get(Fo(n));e.removeRootElement(i)}this.executed("shape.create",(function(e){c(e.shape)&&p(e)}),!0),this.postExecuted("shape.create",(function(e){var t=e.shape,n=e.newRootElement;n&&t.children&&(s._showRecursively(t.children),s._moveChildrenToShape(t,n))}),!0),this.reverted("shape.create",(function(e){c(e.shape)&&l(e)}),!0),this.preExecuted("shape.delete",(function(e){var t=e.shape;if(c(t)){var i=a.get(Fo(t));i&&n.removeElements(i.children.slice())}}),!0),this.executed("shape.delete",(function(e){c(e.shape)&&l(e)}),!0),this.reverted("shape.delete",(function(e){c(e.shape)&&p(e)}),!0),this.preExecuted("shape.replace",(function(t){var n=t.oldShape,i=t.newShape;c(n)&&c(i)&&(t.oldRoot=e.removeRootElement(Fo(n)))}),!0),this.postExecuted("shape.replace",(function(t){var i=t.newShape,r=t.oldRoot,o=e.findRoot(Fo(i));if(r&&o){var a=r.children;n.moveElements(a,{x:0,y:0},o)}}),!0),this.executed("element.updateProperties",(function(e){var t=e.element;if(mr(t,"bpmn:SubProcess")){var n=e.properties,i=e.oldProperties.id,r=n.id;if(i!==r){if(Ho(t))return a.updateId(t,zo(r)),void a.updateId(i,r);a.get(zo(i))&&a.updateId(zo(i),zo(r))}}}),!0),this.reverted("element.updateProperties",(function(e){var t=e.element;if(mr(t,"bpmn:SubProcess")){var n=e.properties,i=e.oldProperties.id,r=n.id;if(i!==r){if(Ho(t))return a.updateId(t,zo(i)),void a.updateId(r,i);var o=a.get(zo(r));o&&a.updateId(o,zo(i))}}}),!0),t.on("element.changed",(function(e){var n=e.element;if(Ho(n)){var i=n,r=a.get(Io(i));r&&r!==i&&t.fire("element.changed",{element:r})}})),this.executed("shape.toggleCollapse",400,(function(e){var t=e.shape;mr(t,"bpmn:SubProcess")&&(jr(t)?l(e):(p(e),s._showRecursively(t.children)))}),!0),this.reverted("shape.toggleCollapse",400,(function(e){var t=e.shape;mr(t,"bpmn:SubProcess")&&(jr(t)?l(e):(p(e),s._showRecursively(t.children)))}),!0),this.postExecuted("shape.toggleCollapse",600,(function(e){var t=e.shape;if(mr(t,"bpmn:SubProcess")){var n=e.newRootElement;n&&(jr(t)?s._moveChildrenToShape(n,t):s._moveChildrenToShape(t,n))}}),!0),t.on("copyPaste.createTree",(function(e){var t=e.element,n=e.children;if(c(t)){var i=Fo(t),r=a.get(i);r&&n.push.apply(n,r.children)}})),t.on("copyPaste.copyElement",(function(e){var t=e.descriptor,n=e.element,i=e.elements,r=n.parent;if(mr(vr(r),"bpmndi:BPMNPlane")){var o=Io(r),a=m(i,(function(e){return e.id===o}));a&&(t.parent=a.id)}})),t.on("copyPaste.pasteElement",(function(e){var t=e.descriptor;t.parent&&(c(t.parent)||t.parent.hidden)&&(t.hidden=!0)}))}function Hh(e,t){e.invoke(To,this),this.postExecuted("shape.replace",(function(e){var n=e.context.oldShape,i=e.context.newShape;if(mr(i,"bpmn:SubProcess")&&(mr(n,"bpmn:Task")||mr(n,"bpmn:CallActivity"))&&jr(i)){var r,o={x:(r=i).x+r.width/6,y:r.y+r.height/2};t.createShape({type:"bpmn:StartEvent"},o,i)}}))}function Vh(e){To.call(this,e),this.preExecute("connection.create",(function(e){const{target:t}=e;mr(t,"bpmn:TextAnnotation")&&(e.parent=t.parent)}),!0),this.preExecute(["shape.create","shape.resize","elements.move"],(function(e){const t=e.shapes||[e.shape];1===t.length&&mr(t[0],"bpmn:TextAnnotation")&&(e.hints=e.hints||{},e.hints.autoResize=!1)}),!0)}function Gh(e,t){To.call(this,e),this.postExecuted("shape.toggleCollapse",1500,(function(e){var n=e.shape;if(!jr(n)){var i=ut(n);i.forEach((function(e){var t=e.incoming.slice(),n=e.outgoing.slice();v(t,(function(e){r(e,!0)})),v(n,(function(e){r(e,!1)}))}))}function r(e,r){-1!==i.indexOf(e.source)&&-1!==i.indexOf(e.target)||(r?t.reconnectEnd(e,n,dn(n)):t.reconnectStart(e,n,dn(n)))}}),!0)}e(zh,To),zh.prototype._moveChildrenToShape=function(e,t){var n,i=this._modeling,r=e.children;if(r){var o=(r=r.concat(r.reduce((function(t,n){return n.label&&n.label.parent!==e?t.concat(n.label):t}),[]))).filter((function(e){return!e.hidden}));if(o.length){var a=ht(o);if(t.x){var s=dn(t),c=dn(a);n={x:s.x-c.x,y:s.y-c.y}}else n={x:Ih-a.x,y:Fh-a.y};i.moveElements(r,n,t,{autoResize:!1})}else i.moveElements(r,{x:0,y:0},t,{autoResize:!1})}},zh.prototype._showRecursively=function(e,t){var n=this,i=[];return e.forEach((function(e){e.hidden=!!t,i=i.concat(e),e.children&&(i=i.concat(n._showRecursively(e.children,e.collapsed||t)))})),i},zh.prototype._addDiagram=function(e){var t=this._bpmnjs.getDefinitions().diagrams;return e.businessObject||(e=this._createNewDiagram(e)),t.push(e.di.$parent),e},zh.prototype._createNewDiagram=function(e){var t=this._bpmnFactory,n=this._elementFactory,i=t.create("bpmndi:BPMNPlane",{bpmnElement:e}),r=t.create("bpmndi:BPMNDiagram",{plane:i});return i.$parent=r,n.createRoot({id:Fo(e),type:e.$type,di:i,businessObject:e,collapsed:!0})},zh.prototype._removeDiagram=function(e){var t=this._bpmnjs.getDefinitions().diagrams,n=m(t,(function(t){return t.plane.bpmnElement.id===e.id}));return t.splice(t.indexOf(n),1),n},zh.$inject=["canvas","eventBus","modeling","elementFactory","bpmnFactory","bpmnjs","elementRegistry"],Hh.$inject=["injector","modeling"],e(Hh,To),e(Vh,To),Vh.$inject=["eventBus"],e(Gh,To),Gh.$inject=["eventBus","modeling"];function Wh(e,t,n){To.call(this,e),this.executed(["shape.toggleCollapse"],500,(function(e){var t,n=e.context.shape;mr(n,"bpmn:SubProcess")&&(n.collapsed?vr(n).isExpanded=!1:((t=n.children).length&&t.forEach((function(e){"label"!==e.type||e.businessObject.name||(e.hidden=!0)})),vr(n).isExpanded=!0))})),this.reverted(["shape.toggleCollapse"],500,(function(e){var t=e.context.shape;t.collapsed?vr(t).isExpanded=!1:vr(t).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,o=e.children,a=t;return n=(r=o,r.filter((function(e){return!e.hidden}))).concat([e]),(i=cu(n))?(a.width=Math.max(i.width,a.width),a.height=Math.max(i.height,a.height),a.x=i.x+(i.width-a.width)/2,a.y=i.y+(i.height-a.height)/2):(a.x=e.x+(e.width-a.width)/2,a.y=e.y+(e.height-a.height)/2),a}(r,o),n.resizeShape(r,i,null,{autoResize:!r.collapsed&&"nwse"})}))}function Uh(e,t,n,i){t.invoke(To,this),this.preExecute("shape.delete",(function(e){var t=e.context.shape,r=t.businessObject;sn(t)||(mr(t,"bpmn:Participant")&&jr(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;mr(t,"bpmn:Collaboration")&&n.ids.unclaim(i.id)}))}function qh(e,t){To.call(this,e),this.preExecute("connection.delete",(function(e){var n=e.context.connection,i=n.source;(function(e,t){if(!mr(e,"bpmn:SequenceFlow"))return!1;var n=gr(t),i=gr(e);return n.get("default")===i})(n,i)&&t.updateProperties(i,{default:null})}))}e(Wh,To),Wh.$inject=["eventBus","elementFactory","modeling"],e(Uh,To),Uh.$inject=["canvas","injector","moddle","modeling"],e(qh,To),qh.$inject=["eventBus","modeling"];function Kh(e,t){var n;function i(){if(!n)throw new Error("out of bounds release");return n}To.call(this,e);var r=["spaceTool","lane.add","lane.resize","lane.split","elements.create","elements.delete","elements.move","shape.create","shape.delete","shape.move","shape.resize"];this.preExecute(r,5e3,(function(e){(n=n||new Yh).enter()})),this.postExecuted(r,500,(function(e){!function(){if(!n)throw new Error("out of bounds release");var e=n.leave();e&&(t.updateLaneRefs(n.flowNodes,n.lanes),n=null)}()})),this.preExecute(["shape.create","shape.move","shape.delete","shape.resize"],(function(e){var t=e.context.shape,n=i();t.labelTarget||(mr(t,"bpmn:Lane")&&n.addLane(t),mr(t,"bpmn:FlowNode")&&n.addFlowNode(t))}))}function Yh(){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 Xh(e,t){To.call(this,e),this.postExecuted("elements.create",(function(e){const n=e.context.elements;for(const e of n)Zh(e)&&!Qh(e)&&t.updateProperties(e,{isForCompensation:void 0})}))}function Zh(e){const t=gr(e);return t&&t.isForCompensation}function Qh(e){return e.incoming.filter((e=>function(e){return e&&mr(e,"bpmn:BoundaryEvent")&&$r(e,"bpmn:CompensateEventDefinition")}(e.source))).length>0}Kh.$inject=["eventBus","modeling"],e(Kh,To),e(Xh,To),Xh.$inject=["eventBus","modeling"];var Jh={__init__:["adaptiveLabelPositioningBehavior","appendBehavior","associationBehavior","attachEventBehavior","boundaryEventBehavior","compensateBoundaryEventBehaviour","createBehavior","createDataObjectBehavior","createParticipantBehavior","dataInputAssociationBehavior","dataStoreBehavior","deleteLaneBehavior","detachEventBehavior","dropOnFlowBehavior","eventBasedGatewayBehavior","fixHoverBehavior","groupBehavior","importDockingFix","isHorizontalFix","labelBehavior","layoutConnectionBehavior","messageFlowBehavior","nonInterruptingBehavior","removeElementBehavior","removeEmbeddedLabelBoundsBehavior","removeParticipantBehavior","replaceConnectionBehavior","replaceElementBehaviour","resizeBehavior","resizeLaneBehavior","rootElementReferenceBehavior","spaceToolBehavior","subProcessPlaneBehavior","subProcessStartEventBehavior","textAnnotationBehavior","toggleCollapseConnectionBehaviour","toggleElementCollapseBehaviour","unclaimIdBehavior","updateFlowNodeRefsBehavior","unsetDefaultFlowBehavior","setCompensationActivityAfterPasteBehavior"],adaptiveLabelPositioningBehavior:["type",Nl],appendBehavior:["type",Ol],associationBehavior:["type",Ll],attachEventBehavior:["type",$l],boundaryEventBehavior:["type",Fl],compensateBoundaryEventBehaviour:["type",zl],createBehavior:["type",Wl],createDataObjectBehavior:["type",Ul],createParticipantBehavior:["type",Xl],dataInputAssociationBehavior:["type",Ql],dataStoreBehavior:["type",tu],deleteLaneBehavior:["type",yu],detachEventBehavior:["type",gu],dropOnFlowBehavior:["type",_u],eventBasedGatewayBehavior:["type",wu],fixHoverBehavior:["type",Cu],groupBehavior:["type",ku],importDockingFix:["type",Pu],isHorizontalFix:["type",Mu],labelBehavior:["type",Ku],layoutConnectionBehavior:["type",Xu],messageFlowBehavior:["type",oh],nonInterruptingBehavior:["type",ph],removeElementBehavior:["type",uh],removeEmbeddedLabelBoundsBehavior:["type",lh],removeParticipantBehavior:["type",dh],replaceConnectionBehavior:["type",fh],replaceElementBehaviour:["type",mh],resizeBehavior:["type",Eh],resizeLaneBehavior:["type",Bh],rootElementReferenceBehavior:["type",Dh],spaceToolBehavior:["type",jh],subProcessPlaneBehavior:["type",zh],subProcessStartEventBehavior:["type",Hh],textAnnotationBehavior:["type",Vh],toggleCollapseConnectionBehaviour:["type",Gh],toggleElementCollapseBehaviour:["type",Wh],unclaimIdBehavior:["type",Uh],unsetDefaultFlowBehavior:["type",qh],updateFlowNodeRefsBehavior:["type",Kh],setCompensationActivityAfterPasteBehavior:["type",Xh]};function ed(e,t){var n=fn(e,t,-15);return"intersect"!==n?n:null}function td(e){zc.call(this,e)}function nd(e){return!e||sn(e)}function id(e){do{if(mr(e,"bpmn:Process"))return gr(e);if(mr(e,"bpmn:Participant"))return gr(e).processRef||gr(e)}while(e=e.parent)}function rd(e){return mr(e,"bpmn:TextAnnotation")}function od(e){return mr(e,"bpmn:Group")&&!e.labelTarget}function ad(e){return mr(e,"bpmn:BoundaryEvent")&&ld(e,"bpmn:CompensateEventDefinition")}function sd(e){return gr(e).isForCompensation}function cd(e){for(var t=e;t=t.parent;){if(mr(t,"bpmn:FlowElementsContainer"))return gr(t);if(mr(t,"bpmn:Participant"))return gr(t).processRef}return null}function pd(e,t){return cd(e)===cd(t)}function ld(e,t){return!!m(gr(e).eventDefinitions||[],(function(e){return mr(e,t)}))}function ud(e,t){return(gr(e).eventDefinitions||[]).every((function(e){return mr(e,t)}))}function hd(e,t){var n=function(e){for(var t=[];e;)(e=e.parent)&&t.push(e);return t}(t);return-1!==n.indexOf(e)}function dd(e,t,n){if(nd(e)||nd(t))return null;if(!mr(n,"bpmn:DataAssociation")){if(Rd(e,t))return{type:"bpmn:MessageFlow"};if(Pd(e,t))return{type:"bpmn:SequenceFlow"}}var i=Ad(e,t);return i||(kd(e,t)?{type:"bpmn:Association",associationDirection:"One"}:!!Cd(e,t)&&{type:"bpmn:Association",associationDirection:"None"})}function fd(e,t){return!(!sn(e)&&!od(e))||!(mr(t,"bpmn:Participant")&&!jr(t))&&(mr(e,"bpmn:Participant")?mr(t,"bpmn:Process")||mr(t,"bpmn:Collaboration"):yr(e,["bpmn:DataInput","bpmn:DataOutput"])&&e.parent?t===e.parent:mr(e,"bpmn:Lane")?mr(t,"bpmn:Participant")||mr(t,"bpmn:Lane"):!(mr(e,"bpmn:BoundaryEvent")&&!function(e){return gr(e).cancelActivity&&(gd(e)||vd(e))}(e))&&(mr(e,"bpmn:FlowElement")&&!mr(e,"bpmn:DataStoreReference")?mr(t,"bpmn:FlowElementsContainer")?jr(t):yr(t,["bpmn:Participant","bpmn:Lane"]):mr(e,"bpmn:DataStoreReference")&&mr(t,"bpmn:Collaboration")?w(gr(t).get("participants"),(function(e){return!!e.get("processRef")})):yr(e,["bpmn:Artifact","bpmn:DataAssociation","bpmn:DataStoreReference"])?yr(t,["bpmn:Collaboration","bpmn:Lane","bpmn:Participant","bpmn:Process","bpmn:SubProcess"]):!!mr(e,"bpmn:MessageFlow")&&(mr(t,"bpmn:Collaboration")||e.source.parent==t||e.target.parent==t)))}function md(e){return mr(e,"bpmn:Lane")}function yd(e){return!!function(e){return!sn(e)&&mr(e,"bpmn:BoundaryEvent")}(e)||(!(!mr(e,"bpmn:IntermediateThrowEvent")||!gd(e))||mr(e,"bpmn:IntermediateCatchEvent")&&vd(e))}function gd(e){var t=gr(e);return t&&!(t.eventDefinitions&&t.eventDefinitions.length)}function vd(e){return _d(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])}function _d(e,t){return t.some((function(t){return ld(e,t)}))}function bd(e,t,n,i){if(Array.isArray(e)||(e=[e]),1!==e.length)return!1;var r=e[0];return!sn(r)&&(!!yd(r)&&(!Lr(t)&&(!(!mr(t,"bpmn:Activity")||sd(t))&&(!(i&&!ed(i,t))&&(!function(e){return mr(e,"bpmn:ReceiveTask")&&m(e.incoming,(function(e){return mr(e.source,"bpmn:EventBasedGateway")}))}(t)&&"attach")))))}function xd(e,t,n){if(!t)return!1;var i={replacements:[]};return v(e,(function(e){Lr(t)||mr(e,"bpmn:StartEvent")&&"label"!==e.type&&fd(e,t)&&(function(e){return e&&!1!==gr(e).isInterrupting}(e)||i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),(function(e){return $r(e,"bpmn:ErrorEventDefinition")}(e)||function(e){return $r(e,"bpmn:EscalationEventDefinition")}(e)||function(e){return $r(e,"bpmn:CompensateEventDefinition")}(e))&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),_d(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])&&mr(t,"bpmn:SubProcess")&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"})),mr(t,"bpmn:Transaction")||ld(e,"bpmn:CancelEventDefinition")&&"label"!==e.type&&(mr(e,"bpmn:EndEvent")&&fd(e,t)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:EndEvent"}),mr(e,"bpmn:BoundaryEvent")&&bd(e,t,0,n)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:BoundaryEvent"}))})),!!i.replacements.length&&i}function wd(e,t){return!w(e,md)&&(!t||e.every((function(e){return fd(e,t)})))}function Ed(e,t,n,i){return!!t&&(!(!sn(e)&&!od(e))||!function(e,t){return e===t}(n,t)&&((!n||!hd(n,t))&&(fd(e,t)||Md(e,t))))}function Sd(e,t){return mr(e,"bpmn:SubProcess")?jr(e)&&(!t||t.width>=100&&t.height>=80):!!mr(e,"bpmn:Lane")||(!!mr(e,"bpmn:Participant")||(!!rd(e)||!!od(e)))}function Cd(e,t){return!hd(t,e)&&!hd(e,t)&&(!!function(e,t){var n=rd(e),i=rd(t);return(n||i)&&n!==i}(e,t)||!!Ad(e,t))}function kd(e,t){return pd(e,t)&&ad(e)&&mr(t,"bpmn:Activity")&&(n=e,!t.attachers.includes(n))&&!Lr(t);var n}function Rd(e,t){return!(Bd(e)&&!Bd(t))&&(mr(n=e,"bpmn:InteractionNode")&&!mr(n,"bpmn:BoundaryEvent")&&(!mr(n,"bpmn:Event")||mr(n,"bpmn:ThrowEvent")&&ud(n,"bpmn:MessageEventDefinition"))&&function(e){return mr(e,"bpmn:InteractionNode")&&!sd(e)&&(!mr(e,"bpmn:Event")||mr(e,"bpmn:CatchEvent")&&ud(e,"bpmn:MessageEventDefinition"))&&!(mr(e,"bpmn:BoundaryEvent")&&!ld(e,"bpmn:MessageEventDefinition"))}(t)&&!function(e,t){return id(e)===id(t)}(e,t));var n}function Pd(e,t){return mr(n=e,"bpmn:FlowNode")&&!mr(n,"bpmn:EndEvent")&&!Lr(n)&&!(mr(n,"bpmn:IntermediateThrowEvent")&&ld(n,"bpmn:LinkEventDefinition"))&&!ad(n)&&!sd(n)&&function(e){return mr(e,"bpmn:FlowNode")&&!mr(e,"bpmn:StartEvent")&&!mr(e,"bpmn:BoundaryEvent")&&!Lr(e)&&!(mr(e,"bpmn:IntermediateCatchEvent")&&ld(e,"bpmn:LinkEventDefinition"))&&!sd(e)}(t)&&pd(e,t)&&!(mr(e,"bpmn:EventBasedGateway")&&!function(e){return mr(e,"bpmn:ReceiveTask")||mr(e,"bpmn:IntermediateCatchEvent")&&(ld(e,"bpmn:MessageEventDefinition")||ld(e,"bpmn:TimerEventDefinition")||ld(e,"bpmn:ConditionalEventDefinition")||ld(e,"bpmn:SignalEventDefinition"))}(t));var n}function Ad(e,t){return yr(e,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&yr(t,["bpmn:Activity","bpmn:ThrowEvent"])?{type:"bpmn:DataInputAssociation"}:!(!yr(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])||!yr(e,["bpmn:Activity","bpmn:CatchEvent"]))&&{type:"bpmn:DataOutputAssociation"}}function Md(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&&(yr(t,["bpmn:SequenceFlow","bpmn:MessageFlow"])&&!sn(t)&&mr(e,"bpmn:FlowNode")&&!mr(e,"bpmn:BoundaryEvent")&&fd(e,t.parent))}function Td(e,t){return!!sn(t)||!(mr(t,"bpmn:Lane")&&!function(e,t){return e&&t&&-1!==e.indexOf(t)}(e,t.parent))}function Bd(e){return Qc(e,"bpmn:Process")||Qc(e,"bpmn:Collaboration")}e(td,zc),td.$inject=["eventBus"],td.prototype.init=function(){this.addRule("connection.start",(function(e){return function(e){if(nd(e))return null;return yr(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 dd(t,n)}finally{r&&(n.parent=null)}})),this.addRule("connection.reconnect",(function(e){var t=e.connection;return dd(e.source,e.target,t)})),this.addRule("connection.updateWaypoints",(function(e){return{type:e.connection.type}})),this.addRule("shape.resize",(function(e){return Sd(e.shape,e.newBounds)})),this.addRule("elements.create",(function(e){var t=e.elements,n=e.position,i=e.target;return!(an(i)&&!Md(t,i))&&x(t,(function(e){return an(e)?dd(e.source,e.target,e):e.host?bd(e,e.host,null,n):Ed(e,i,null)}))})),this.addRule("elements.move",(function(e){var t=e.target,n=e.shapes,i=e.position;return bd(n,t,null,i)||xd(n,t,i)||wd(n,t)||Md(n,t)})),this.addRule("shape.create",(function(e){return Ed(e.shape,e.target,e.source,e.position)})),this.addRule("shape.attach",(function(e){return bd(e.shape,e.target,null,e.position)})),this.addRule("element.copy",(function(e){var t=e.element;return Td(e.elements,t)}))},td.prototype.canConnectMessageFlow=Rd,td.prototype.canConnectSequenceFlow=Pd,td.prototype.canConnectDataAssociation=Ad,td.prototype.canConnectAssociation=Cd,td.prototype.canConnectCompensationAssociation=kd,td.prototype.canMove=wd,td.prototype.canAttach=bd,td.prototype.canReplace=xd,td.prototype.canDrop=fd,td.prototype.canInsert=Md,td.prototype.canCreate=Ed,td.prototype.canConnect=dd,td.prototype.canResize=Sd,td.prototype.canCopy=Td;var Dd={__depends__:[bp],__init__:["bpmnRules"],bpmnRules:["type",td]};function Nd(e,t){e.on("saveXML.start",2e3,(function(){v(t.getRootElements(),(function(e){var t,n=vr(e);t=E(g(ut([e],!1),(function(t){return t!==e&&!t.labelTarget})),vr),n.set("planeElement",t)}))}))}Nd.$inject=["eventBus","canvas"];var jd={__init__:["bpmnDiOrdering"],bpmnDiOrdering:["type",Nd]};function Od(e){To.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 Ld(e,t){Od.call(this,e);var n=[{type:"bpmn:SubProcess",order:{level:6}},{type:"bpmn:SequenceFlow",order:{level:9,containers:["bpmn:Participant","bpmn:FlowElementsContainer"]}},{type:"bpmn:DataAssociation",order:{level:9,containers:["bpmn:Collaboration","bpmn:FlowElementsContainer"]}},{type:"bpmn:TextAnnotation",order:{level:9}},{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:FlowElementsContainer"]}},{type:"bpmn:FlowElement",order:{level:5}},{type:"bpmn:Participant",order:{level:-2}},{type:"bpmn:Lane",order:{level:-1}}];function i(e){var t=e.order;if(t||(e.order=t=function(e){if(e.labelTarget)return{level:10};var t=m(n,(function(t){return yr(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||mr(e,"bpmn:TextAnnotation"))return{parent:t.findRoot(n)||t.getRootElement(),index:-1};var r=i(e);r.containers&&(n=function(e,t,n){for(var i=t;i&&!yr(i,n);)i=i.parent;if(!i)throw new Error(`no parent for <${e.id}> in <${t&&t.id}>`);return i}(e,n,r.containers));var o=n.children.indexOf(e),a=y(n.children,(function(t){return!(!e.labelTarget&&t.labelTarget)&&r.level<i(t).level}));return-1!==a&&-1!==o&&o<a&&(a-=1),{index:a,parent:n}}}Od.prototype.getOrdering=function(e,t){return null},e(Od,To),Ld.$inject=["eventBus","canvas"],e(Ld,Od);var $d={__init__:["bpmnOrderingProvider"],bpmnOrderingProvider:["type",Ld]};function Id(){}Id.prototype.get=function(){return this._data},Id.prototype.set=function(e){this._data=e},Id.prototype.clear=function(){var e=this._data;return delete this._data,e},Id.prototype.isEmpty=function(){return!this._data};var Fd={clipboard:["type",Id]},zd="drop-ok",Hd="drop-not-ok",Vd="attach-ok",Gd="new-parent",Wd="create";function Ud(e,t,n,i,r){function o(t,n){[Vd,zd,Hd,Gd].forEach((function(i){i===n?e.addMarker(t,i):e.removeMarker(t,i)}))}function a(){var e=t.context();e&&e.prefix===Wd&&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);qd(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=m(e=g(e,(function(t){var n=t.labelTarget;return!(t.parent||sn(t)&&-1!==e.indexOf(n))})),(function(e){return!an(e)})),s=!1,c=!1,p=!1;Kd(e)&&(s=r.allowed("shape.attach",{position:n,shape:a,target:t})),s||(p=Kd(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,Vd):o(i,p?Gd:Hd))})),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;qd(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}):m(o=i.createElements(o,u,a,L({},l,{attach:c})),(function(e){return!an(e)})),L(t,{elements:o,shape:r}),L(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){p(n)||(n=[n]);var r=m(n,(function(e){return!an(e)}));if(r){i=L({elements:n,hints:{},shape:r},i||{}),v(n,(function(e){u(e.x)||(e.x=0),u(e.y)||(e.y=0)}));var o=ht(g(n,(function(e){return!e.hidden})));v(n,(function(e){an(e)&&(e.waypoints=E(e.waypoints,(function(e){return{x:e.x-o.x-o.width/2,y:e.y-o.y-o.height/2}}))),L(e,{x:e.x-o.x-o.width/2,y:e.y-o.y-o.height/2})})),t.init(e,Wd,{cursor:"grabbing",autoActivate:!0,data:{shape:r,elements:n,context:i}})}}}function qd(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 Kd(e){return e&&1===e.length&&!an(e[0])}Ud.$inject=["canvas","dragging","eventBus","modeling","rules"];function Yd(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=Ae("g");be(t,r.cls("djs-drag-group",["no-events"]));var o=Ae("g");return e.forEach((function(e){var r;e.hidden||(e.waypoints?(r=n._createContainer("connection",o),n.drawConnection(Hn(r),e)):(r=n._createContainer("shape",o),n.drawShape(Hn(r),e),Gn(r,e.x,e.y)),i.addDragger(e,t,r))})),t}(s)),o?(c.parentNode||ge(e.getActiveLayer(),c),Gn(c,t.x,t.y)):Fe(c)})),t.on("create.cleanup",(function(e){var t=e.context.dragGroup;t&&Fe(t)}))}Yd.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];var Xd={__depends__:[mp,Pl,bp,_a],__init__:["create","createPreview"],create:["type",Ud],createPreview:["type",Yd]};function Zd(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)}))}Zd.$inject=["eventBus"],Zd.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 Qd={__init__:["mouse"],mouse:["type",Zd]};function Jd(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;var r=m(i,(function(e){return e===n.parent}));r&&(t.parent=n.parent.id),function(e){return!!e.host}(n)&&(t.priority=2,t.host=n.host.id),an(n)&&(t.priority=3,t.source=n.source.id,t.target=n.target.id,t.waypoints=function(e){return E(e.waypoints,(function(e){return(e=ef(e)).original&&(e.original=ef(e.original)),e}))}(n)),sn(n)&&(t.priority=4,t.labelTarget=n.labelTarget.id),v(["x","y","width","height"],(function(e){u(n[e])&&(t[e]=n[e])})),t.hidden=n.hidden,t.collapsed=n.collapsed})),r.on("copyPaste.pasteElements",(function(e){L(e.hints,{createElementsBehavior:!1})}))}function ef(e){return L({},e)}function tf(e,t){var n=t.indexOf(e);return-1===n?t:t.splice(n,1)}Jd.$inject=["canvas","create","clipboard","elementFactory","eventBus","modeling","mouse","rules"],Jd.prototype.copy=function(e){var t,n;return p(e)||(e=e?[e]:[]),n=!1===(t=this._eventBus.fire("copyPaste.canCopyElements",{elements:e}))?{}:this.createTree(p(t)?t:e),this._clipboard.set(n),this._eventBus.fire("copyPaste.elementsCopied",{elements:e,tree:n}),n},Jd.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||{}})}},Jd.prototype._paste=function(e,t,n,i){v(e,(function(e){u(e.x)||(e.x=0),u(e.y)||(e.y=0)}));var r=ht(e);return v(e,(function(e){an(e)&&(e.waypoints=E(e.waypoints,(function(e){return{x:e.x-r.x-r.width/2,y:e.y-r.y-r.height/2}}))),L(e,{x:e.x-r.x-r.width/2,y:e.y-r.y-r.height/2})})),this._modeling.createElements(e,n,t,L({},i))},Jd.prototype._createElements=function(e){var t=this,n=this._eventBus,i={},r=[];return v(e,(function(e,o){v(e=A(e,"priority"),(function(e){var o,a=L({},I(e,["priority"]));return i[e.parent]?a.parent=i[e.parent]:delete a.parent,n.fire("copyPaste.pasteElement",{cache:i,descriptor:a}),an(a)?(a.source=i[e.source],a.target=i[e.target],o=i[e.id]=t.createConnection(a),void r.push(o)):sn(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},Jd.prototype.createConnection=function(e){return this._elementFactory.createConnection(I(e,["id"]))},Jd.prototype.createLabel=function(e){return this._elementFactory.createLabel(I(e,["id"]))},Jd.prototype.createShape=function(e){return this._elementFactory.createShape(I(e,["id"]))},Jd.prototype.hasRelations=function(e,t){var n,i;return!(an(e)&&(n=m(t,M({id:e.source.id})),i=m(t,M({id:e.target.id})),!n||!i))&&!(sn(e)&&!m(t,M({id:e.labelTarget.id})))},Jd.prototype.createTree=function(e){var t=this._rules,n=this,i={},r=[];function o(e,t){var n=m(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),r.push({element:n.element,depth:t})):r.push({element:e,depth:t})}return lt(st(e),(function(e,t,i){if(!sn(e)){v(e.labels,(function(e){o(e,i)})),v([e.attachers,e.incoming,e.outgoing],(function(e){e&&e.length&&v(e,(function(e){v(e.labels,(function(e){o(e,i)})),o(e,i)}))})),o(e,i);var r=[];return e.children&&(r=e.children.slice()),n._eventBus.fire("copyPaste.createTree",{element:e,children:r}),r}})),e=E(r,(function(e){return e.element})),r=E(r,(function(t){return t.descriptor={},n._eventBus.fire("copyPaste.copyElement",{descriptor:t.descriptor,element:t.element,elements:e}),t})),r=A(r,(function(e){return e.descriptor.priority})),e=E(r,(function(e){return e.element})),v(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)?tf(r.element,e):(i[o]||(i[o]=[]),i[o].push(r.descriptor)):tf(r.element,e)})),i};var nf={__depends__:[Fd,Xd,Qd,bp],__init__:["copyPaste"],copyPaste:["type",Jd]};function rf(e,t,n){p(n)||(n=[n]),v(n,(function(n){a(e[n])||(t[n]=e[n])}))}function of(e,t,n){function i(t,i){var r=e.create(t.$type);return n.copyElement(t,r,null,i)}t.on("copyPaste.copyElement",750,(function(e){var t=e.descriptor,n=e.element,r=gr(n);if(sn(n))return t;var o=t.businessObject=i(r,!0),a=t.di=i(vr(n),!0);a.bpmnElement=o,rf(o,t,"name"),rf(a,t,"isExpanded"),r.default&&(t.default=r.default.id)}));var r="-bpmn-js-refs";t.on("copyPaste.pasteElement",(function(e){var t=e.cache,n=e.descriptor,r=n.businessObject,o=n.di;if(sn(n))return n.businessObject=gr(t[n.labelTarget]),void(n.di=vr(t[n.labelTarget]));r=n.businessObject=i(r),(o=n.di=i(o)).bpmnElement=r,rf(n,r,["isExpanded","name"]),n.type=r.$type})),t.on("copyPaste.copyElement",750,(function(e){var t=e.descriptor,n=e.element;if(mr(n,"bpmn:Participant")){var r=gr(n);r.processRef&&(t.processRef=i(r.processRef,!0))}})),t.on("copyPaste.pasteElement",(function(e){var t=e.descriptor,n=t.processRef;n&&(t.processRef=i(n))})),t.on("copyPaste.pasteElement",750,(function(e){var t=e.cache;!function(e,t){e[r]=t}(t,function(e,t,n){var i=gr(e);return e.default&&(n[e.default]={element:i,property:"default"}),e.host&&(gr(e).attachedToRef=gr(t[e.host])),I(n,b(n,(function(t,n,r){var o=n.element,a=n.property;return r===e.id&&(o.set(a,i),t.push(e.id)),t}),[]))}(e.descriptor,t,function(e){return e[r]=e[r]||{}}(t)))}))}of.$inject=["bpmnFactory","eventBus","moddleCopy"];var af=["artifacts","dataInputAssociations","dataOutputAssociations","default","flowElements","lanes","incoming","outgoing","categoryValue"];function sf(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 A(t,(function(e){return"extensionElements"===e}))})),e.on("moddleCopy.canCopyProperty",(function(e){var t=e.parent,n=l(t)&&t.$descriptor,i=e.propertyName;return(!i||-1===af.indexOf(i))&&(!(i&&n&&!m(n.properties,M({name:i})))&&void 0)})),e.on("moddleCopy.canSetCopiedProperty",(function(e){var t,n,i=e.property;if(n="bpmn:ExtensionElements",(t=i)&&h(t.$instanceOf)&&t.$instanceOf(n)&&(!i.values||!i.values.length))return!1}))}function cf(e,t){return b(e.properties,(function(e,n){return t&&n.default?e:e.concat(n.name)}),[])}sf.$inject=["eventBus","bpmnFactory","moddle"],sf.prototype.copyElement=function(e,t,n,i=!1){var r=this;n&&!p(n)&&(n=[n]),n=n||cf(e.$descriptor);var o=this._eventBus.fire("moddleCopy.canCopyProperties",{propertyNames:n,sourceElement:e,targetElement:t,clone:i});return!1===o||(p(o)&&(n=o),v(n,(function(n){var o;f(e,n)&&(o=e.get(n));var a=r.copyProperty(o,t,n,i);s(a)&&(!1!==r._eventBus.fire("moddleCopy.canSetCopiedProperty",{parent:t,property:a,propertyName:n})&&t.set(n,a))}))),t},sf.prototype.copyProperty=function(e,t,n,i=!1){var r=this,o=this._eventBus.fire("moddleCopy.canCopyProperty",{parent:t,property:e,propertyName:n,clone:i});if(!1!==o){if(o)return l(o)&&o.$type&&!o.$parent&&(o.$parent=t),o;var a=this._moddle.getPropertyDescriptor(t,n);if(!a.isReference){if(a.isId)return e&&this._copyId(e,t,i);if(p(e))return b(e,(function(e,a){return(o=r.copyProperty(a,t,n,i))?e.concat(o):e}),[]);if(l(e)&&e.$type){if(this._moddle.getElementDescriptor(e).isGeneric)return;return(o=r._bpmnFactory.create(e.$type)).$parent=t,o=r.copyElement(e,o,null,i)}return e}}},sf.prototype._copyId=function(e,t,n=!1){return n?e:this._moddle.ids.assigned(e)?void 0:(this._moddle.ids.claim(e,t),e)};var pf={__depends__:[nf],__init__:["bpmnCopyPaste","moddleCopy"],bpmnCopyPaste:["type",of],moddleCopy:["type",sf]},lf=Math.round;function uf(e,t){this._modeling=e,this._eventBus=t}function hf(e,t){t.on("replace.end",500,(function(t){const{newElement:n,hints:i={}}=t;!1!==i.select&&e.select(n)}))}uf.$inject=["modeling","eventBus"],uf.prototype.replaceElement=function(e,t,n){if(e.waypoints)return null;var i=this._modeling,r=this._eventBus;r.fire("replace.start",{element:e,attrs:t,hints:n});var o=t.width||e.width,a=t.height||e.height,s=t.x||e.x,c=t.y||e.y,p=lf(s+o/2),l=lf(c+a/2),u=i.replaceShape(e,L({},t,{x:p,y:l,width:o,height:a}),n);return r.fire("replace.end",{element:e,newElement:u,hints:n}),u},hf.$inject=["selection","eventBus"];var df={__init__:["replace","replaceSelectionBehavior"],replaceSelectionBehavior:["type",hf],replace:["type",uf]};var ff=["cancelActivity","instantiate","eventGatewayType","triggeredByEvent","isInterrupting"];function mf(e,t,n,i,r,o){this.replaceElement=function(s,c,l){l=l||{};var u=c.type,h=s.businessObject;if(yf(h)&&"bpmn:SubProcess"===u&&function(e,t){var n=e&&f(e,"collapsed")?e.collapsed:!jr(e);return n!==(t&&(f(t,"collapsed")||f(t,"isExpanded"))?f(t,"collapsed")?t.collapsed:!t.isExpanded:n)}(s,c))return i.toggleCollapse(s),s;var d=e.create(u),m={type:u,businessObject:d,di:{}};"bpmn:ExclusiveGateway"===u&&(m.di.isMarkerVisible=!0),function(e,t,n){p(n)||(n=[n]),v(n,(function(n){a(e[n])||(t[n]=e[n])}))}(s.di,m.di,["fill","stroke","background-color","border-color","color"]);var y=function(e,t){return e.filter((function(e){return t.includes(e)}))}(cf(h.$descriptor),cf(d.$descriptor,!0));L(d,$(c,ff));var _=g(y,(function(e){return"eventDefinitions"===e?gf(s,c.eventDefinitionType):"loopCharacteristics"===e?!Lr(d):!f(d,e)&&(("processRef"!==e||!1!==c.isExpanded)&&("triggeredByEvent"!==e&&("isForCompensation"!==e||!Lr(d))))}));if(d=n.copyElement(h,d,_),c.eventDefinitionType&&(gf(d,c.eventDefinitionType)||(m.eventDefinitionType=c.eventDefinitionType,m.eventDefinitionAttrs=c.eventDefinitionAttrs)),mr(h,"bpmn:Activity")){if(yf(h))m.isExpanded=jr(s);else if(c&&f(c,"isExpanded")){m.isExpanded=c.isExpanded;var b=t.getDefaultSize(d,{isExpanded:m.isExpanded});m.width=b.width,m.height=b.height,m.x=s.x-(m.width-s.width)/2,m.y=s.y-(m.height-s.height)/2}jr(s)&&!mr(h,"bpmn:Task")&&m.isExpanded&&(m.width=s.width,m.height=s.height)}if(yf(h)&&!yf(d)&&(l.moveChildren=!1),mr(h,"bpmn:Participant")){!0===c.isExpanded?d.processRef=e.create("bpmn:Process"):l.moveChildren=!1;var x=Or(s);vr(s).isHorizontal||(vr(m).isHorizontal=x),m.width=x?s.width:t.getDefaultSize(m).width,m.height=x?t.getDefaultSize(m).height:s.height}return o.allowed("shape.resize",{shape:d})||(m.height=t.getDefaultSize(m).height,m.width=t.getDefaultSize(m).width),d.name=h.name,yr(h,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&yr(d,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&(d.default=h.default),c.host&&!mr(h,"bpmn:BoundaryEvent")&&mr(d,"bpmn:BoundaryEvent")&&(m.host=c.host),"bpmn:DataStoreReference"!==m.type&&"bpmn:DataObjectReference"!==m.type||(m.x=s.x+(s.width-m.width)/2),r.replaceElement(s,m,{...l,targetElement:c})}}function yf(e){return mr(e,"bpmn:SubProcess")}function gf(e,t){var n=gr(e);return t&&n.get("eventDefinitions").some((function(e){return mr(e,t)}))}mf.$inject=["bpmnFactory","elementFactory","moddleCopy","modeling","replace","rules"];var vf={__depends__:[pf,df,_a],bpmnReplace:["type",mf]};function _f(e){this._eventBus=e,this._tools=[],this._active=null}_f.$inject=["eventBus"],_f.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)},_f.prototype.isActive=function(e){return e&&this._active===e},_f.prototype.length=function(e){return this._tools.length},_f.prototype.setActive=function(e){var t=this._eventBus;this._active!==e&&(this._active=e,t.fire("tool-manager.update",{tool:e}))},_f.prototype.bindEvents=function(e,t){var n=this._eventBus,i=[];n.on(t.tool+".init",(function(t){t.context.reactivate||!this.isActive(e)?this.setActive(e):this.setActive(null)}),this),v(t,(function(e){i.push(e+".ended"),i.push(e+".canceled")})),n.on(i,250,(function(e){this._active&&(function(e){var t=e.originalEvent&&e.originalEvent.target;return t&&J(t,'.group[data-group="tools"]')}(e)||this.setActive(null))}),this)};var bf={__depends__:[mp],__init__:["toolManager"],toolManager:["type",_f]};function xf(e,t){return-1!==e.indexOf(t)}var wf=Math.abs,Ef=Math.round,Sf={x:"width",y:"height"},Cf="crosshair",kf={n:"top",w:"left",s:"bottom",e:"right"},Rf={n:"s",w:"e",s:"n",e:"w"};function Pf(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&&Mf(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){Mf(e);var p={x:0,y:0};p[i]=Ef(e["d"+i]),s.makeSpace(o,a,p,r,c),n.once("spaceTool.ended",(function(e){s.activateSelection(e.originalEvent,!0,!0)}))}}))}function Af(e){return{top:e.top-20,right:e.right+20,bottom:e.bottom+20,left:e.left-20}}function Mf(e){var t,n,i=e.context.spaceToolConstraints;i&&(u(i.left)&&(t=Math.max(e.x,i.left),e.dx=e.dx+t-e.x,e.x=t),u(i.right)&&(t=Math.min(e.x,i.right),e.dx=e.dx+t-e.x,e.x=t),u(i.top)&&(n=Math.max(e.y,i.top),e.dy=e.dy+n-e.y,e.y=n),u(i.bottom)&&(n=Math.min(e.y,i.bottom),e.dy=e.dy+n-e.y,e.y=n))}function Tf(e,t){return-1!==e.indexOf(t)}Pf.$inject=["canvas","dragging","eventBus","modeling","rules","toolManager","mouse"],Pf.prototype.activateSelection=function(e,t,n){this._dragging.init(e,"spaceTool.selection",{autoActivate:t,cursor:Cf,data:{context:{reactivate:n}},trapClick:!1})},Pf.prototype.activateMakeSpace=function(e){this._dragging.init(e,"spaceTool",{autoActivate:!0,cursor:Cf,data:{context:{}}})},Pf.prototype.makeSpace=function(e,t,n,i,r){return this._modeling.createSpace(e,t,n,i,r)},Pf.prototype.init=function(e,t){var n=wf(e.dx)>wf(e.dy)?"x":"y",i=e["d"+n],r=e[n]-i;if(wf(i)<5)return!1;i<0&&(i*=-1),sa(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=this._canvas.getRootElement();!ca(e)&&e.hover&&(a=e.hover);var s=[...ut(a,!0),...a.attachers||[]],c=this.calculateAdjustments(s,n,i,r),p=function(e,t,n,i,r){var o=e.movingShapes,a=e.resizingShapes;if(!a.length)return;var s,c,p={};return v(a,(function(e){var l,h,d,f,m,y,v=e.attachers,_=e.children,b=ln(e),x=g(_,(function(e){return!(an(e)||sn(e)||Tf(o,e)||Tf(a,e))})),w=g(_,(function(e){return!an(e)&&!sn(e)&&Tf(o,e)})),E=[],S=[];x.length&&(h=Af(ln(ht(x))),l=i-b[kf[n]]+h[kf[n]],"n"===n?p.bottom=c=u(c)?Math.min(c,l):l:"w"===n?p.right=c=u(c)?Math.min(c,l):l:"s"===n?p.top=s=u(s)?Math.max(s,l):l:"e"===n&&(p.left=s=u(s)?Math.max(s,l):l)),w.length&&(d=Af(ln(ht(w))),l=i-d[kf[Rf[n]]]+b[kf[Rf[n]]],"n"===n?p.bottom=c=u(c)?Math.min(c,l):l:"w"===n?p.right=c=u(c)?Math.min(c,l):l:"s"===n?p.top=s=u(s)?Math.max(s,l):l:"e"===n&&(p.left=s=u(s)?Math.max(s,l):l)),v&&v.length&&(v.forEach((function(e){Tf(o,e)?E.push(e):S.push(e)})),E.length&&(f=ln(ht(E.map(dn))),m=b[kf[Rf[n]]]-(f[kf[Rf[n]]]-i)),S.length&&(y=ln(ht(S.map(dn)))[kf[n]]-(b[kf[n]]-i)),"n"===n?(l=Math.min(m||1/0,y||1/0),p.bottom=c=u(c)?Math.min(c,l):l):"w"===n?(l=Math.min(m||1/0,y||1/0),p.right=c=u(c)?Math.min(c,l):l):"s"===n?(l=Math.max(m||-1/0,y||-1/0),p.top=s=u(s)?Math.max(s,l):l):"e"===n&&(l=Math.max(m||-1/0,y||-1/0),p.left=s=u(s)?Math.max(s,l):l));var C=r&&r[e.id];C&&("n"===n?(l=i+e[Sf[t]]-C[Sf[t]],p.bottom=c=u(c)?Math.min(c,l):l):"w"===n?(l=i+e[Sf[t]]-C[Sf[t]],p.right=c=u(c)?Math.min(c,l):l):"s"===n?(l=i-e[Sf[t]]+C[Sf[t]],p.top=s=u(s)?Math.max(s,l):l):"e"===n&&(l=i-e[Sf[t]]+C[Sf[t]],p.left=s=u(s)?Math.max(s,l):l))})),p}(c,n,o,r,this._eventBus.fire("spaceTool.getMinDimensions",{axis:n,direction:o,shapes:c.resizingShapes,start:r}));return L(t,c,{axis:n,direction:o,spaceToolConstraints:p,start:r}),La("resize-"+("x"===n?"ew":"ns")),!0},Pf.prototype.calculateAdjustments=function(e,t,n,i){var r=this._rules,o=[],a=[],s=[],c=[];function p(e){o.includes(e)||o.push(e);var t=e.label;t&&!o.includes(t)&&o.push(t)}v(e,(function(e){if(e.parent&&!sn(e))if(an(e))c.push(e);else{var o=e[t],l=o+e[Sf[t]];if(function(e){return!!e.host}(e)&&(n>0&&dn(e)[t]>i||n<0&&dn(e)[t]<i))s.push(e);else{var u;if(!(n>0&&o>i||n<0&&l<i))return o<i&&l>i&&r.allowed("shape.resize",{shape:e})?(u=e,void(a.includes(u)||a.push(u))):void 0;p(e)}}})),v(o,(function(e){var t=e.attachers;t&&v(t,(function(e){p(e)}))}));var l=o.concat(a);return v(s,(function(e){var t=e.host;Tf(l,t)&&p(e)})),l=o.concat(a),v(c,(function(e){var t=e.source,n=e.target,i=e.label;Tf(l,t)&&Tf(l,n)&&i&&p(i)})),{movingShapes:o,resizingShapes:a}},Pf.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},Pf.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^spaceTool/.test(e.prefix)};var Bf="djs-dragging",Df="djs-resizing",Nf=Math.max;function jf(e,t,n,i,r){function o(e,t){v(e,(function(e){r.addDragger(e,t),n.addMarker(e,Bf)}))}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=Ae("g");be(s,i.cls("djs-crosshair-group",["no-events"])),ge(t,s);var c=Ae("path");be(c,"d",o),we(c).add("djs-crosshair"),ge(s,c);var p=Ae("path");be(p,"d",a),we(p).add("djs-crosshair"),ge(s,p),r.crosshairGroup=s})),e.on("spaceTool.selection.move",(function(e){Gn(e.context.crosshairGroup,e.x,e.y)})),e.on("spaceTool.selection.cleanup",(function(e){var t=e.context.crosshairGroup;t&&Fe(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");be(s=Ae("path"),"d","M0,0 L0,0"),we(s).add("djs-crosshair"),ge(u,s),a.line=s;var h=Ae("g");be(h,i.cls("djs-drag-group",["no-events"])),ge(n.getActiveLayer(),h),o(p,h),o(a.movingConnections=t.filter((function(e){var t=!1;v(p,(function(n){v(n.outgoing,(function(n){e===n&&(t=!0)}))}));var n=!1;v(p,(function(t){v(t.incoming,(function(t){e===t&&(n=!0)}))}));var i=!1;v(l,(function(t){v(t.outgoing,(function(t){e===t&&(i=!0)}))}));var r=!1;return v(l,(function(t){v(t.incoming,(function(t){e===t&&(r=!0)}))})),an(e)&&(t||i)&&(n||r)})),h),a.dragGroup=h}if(!a.frameGroup){var d=Ae("g");be(d,i.cls("djs-frame-group",["no-events"])),ge(n.getActiveLayer(),d);var f=[];v(l,(function(e){var t=r.addFrame(e,d),i=t.getBBox();f.push({element:t,initialBounds:i}),n.addMarker(e,Df)})),a.frameGroup=d,a.frames=f}be(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,Gn(a.dragGroup,m.x,m.y),v(a.frames,(function(e){var t,n,i=e.element,r=e.initialBounds;"e"===a.direction?be(i,{width:Nf(r.width+m.x,5)}):be(i,{width:t=Nf(r.width-m.x,5),x:r.x+r.width-t}),"s"===a.direction?be(i,{height:Nf(r.height+m.y,5)}):be(i,{height:n=Nf(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;v(i,(function(e){n.removeMarker(e,Bf)})),v(r,(function(e){n.removeMarker(e,Bf)})),s&&(Fe(a),Fe(s)),v(o,(function(e){n.removeMarker(e,Df)})),c&&Fe(c)}))}jf.$inject=["eventBus","elementRegistry","canvas","styles","previewSupport"];var Of={__init__:["spaceToolPreview"],__depends__:[mp,bp,bf,Pl,Qd],spaceTool:["type",Pf],spaceToolPreview:["type",jf]};function Lf(e){e.invoke(Pf,this)}Lf.$inject=["injector"],e(Lf,Pf),Lf.prototype.calculateAdjustments=function(e,t,n,i){var r=Pf.prototype.calculateAdjustments.call(this,e,t,n,i);return r.resizingShapes=r.resizingShapes.filter((function(e){return!mr(e,"bpmn:TextAnnotation")&&(!function(e){return mr(e,"bpmn:Participant")&&!gr(e).processRef}(e)||!("y"===t&&Or(e)||"x"===t&&!Or(e)))})),r};var $f={__depends__:[Of],spaceTool:["type",Lf]};function If(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)}If.$inject=["eventBus","injector"],If.prototype.execute=function(e,t){if(!e)throw new Error("command required");this._currentExecution.trigger="execute";const n={command:e,context:t};this._pushAction(n),this._internalExecute(n),this._popAction()},If.prototype.canExecute=function(e,t){const n={command:e,context:t},i=this._getHandler(e);let r=this._fire(e,"canExecute",n);if(void 0===r){if(!i)return!1;i.canExecute&&(r=i.canExecute(t))}return r},If.prototype.clear=function(e){this._stack.length=0,this._stackIdx=-1,!1!==e&&this._fire("changed",{trigger:"clear"})},If.prototype.undo=function(){let e,t=this._getUndoAction();if(t){for(this._currentExecution.trigger="undo",this._pushAction(t);t&&(this._internalUndo(t),e=this._getUndoAction(),e&&e.id===t.id);)t=e;this._popAction()}},If.prototype.redo=function(){let e,t=this._getRedoAction();if(t){for(this._currentExecution.trigger="redo",this._pushAction(t);t&&(this._internalExecute(t,!0),e=this._getRedoAction(),e&&e.id===t.id);)t=e;this._popAction()}},If.prototype.register=function(e,t){this._setHandler(e,t)},If.prototype.registerHandler=function(e,t){if(!e||!t)throw new Error("command and handlerCls must be defined");const n=this._injector.instantiate(t);this.register(e,n)},If.prototype.canUndo=function(){return!!this._getUndoAction()},If.prototype.canRedo=function(){return!!this._getRedoAction()},If.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]},If.prototype._getUndoAction=function(){return this._stack[this._stackIdx]},If.prototype._internalUndo=function(e){const t=e.command,n=e.context,i=this._getHandler(t);this._atomicDo((()=>{this._fire(t,"revert",e),i.revert&&this._markDirty(i.revert(n)),this._revertedAction(e),this._fire(t,"reverted",e)}))},If.prototype._fire=function(e,t,n){arguments.length<3&&(n=t,t=null);const i=t?[e+"."+t,t]:[e];let r;n=this._eventBus.createEvent(n);for(const e of i)if(r=this._eventBus.fire("commandStack."+e,n),n.cancelBubble)break;return r},If.prototype._createId=function(){return this._uid++},If.prototype._atomicDo=function(e){const t=this._currentExecution;t.atomic=!0;try{e()}finally{t.atomic=!1}},If.prototype._internalExecute=function(e,t){const n=e.command,i=e.context,r=this._getHandler(n);if(!r)throw new Error("no command handler registered for <"+n+">");this._pushAction(e),t||(this._fire(n,"preExecute",e),r.preExecute&&r.preExecute(i),this._fire(n,"preExecuted",e)),this._atomicDo((()=>{this._fire(n,"execute",e),r.execute&&this._markDirty(r.execute(i)),this._executedAction(e,t),this._fire(n,"executed",e)})),t||(this._fire(n,"postExecute",e),r.postExecute&&r.postExecute(i),this._fire(n,"postExecuted",e)),this._popAction()},If.prototype._pushAction=function(e){const 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)},If.prototype._popAction=function(){const e=this._currentExecution,t=e.trigger,n=e.actions,i=e.dirty;n.pop(),n.length||(this._eventBus.fire("elements.changed",{elements:R("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:t}),e.trigger=null)},If.prototype._markDirty=function(e){const t=this._currentExecution;e&&(e=p(e)?e:[e],t.dirty=t.dirty.concat(e))},If.prototype._executedAction=function(e,t){const n=++this._stackIdx;t||this._stack.splice(n,this._stack.length,e)},If.prototype._revertedAction=function(e){this._stackIdx--},If.prototype._getHandler=function(e){return this._handlerMap[e]},If.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 Ff={commandStack:["type",If]};function zf(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 Hf(e,t,n){To.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=Vf(n),t.validatedShapes=Vf(i)})),i&&t.on("shape.move.start",250,(function(e){var t=e.context,n=t.shapes,r=[];v(n,(function(e){v(e.labels,(function(n){n.hidden||-1!==t.shapes.indexOf(n)||r.push(n),e.labelTarget&&r.push(e)}))})),v(r,(function(e){i.makeDraggable(t,e,!0)}))})),this.preExecuted("elements.move",1400,(function(e){var t=e.context.closure,n=t.enclosedElements,i=[];v(n,(function(e){v(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;zf((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=bt(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&&(_t(i.labels,n,r),n.labelTarget=i)}))}function Vf(e){return g(e,(function(t){return-1===e.indexOf(t.labelTarget)}))}e(Hf,To),Hf.$inject=["injector","eventBus","modeling"];var Gf={__init__:["labelSupport"],labelSupport:["type",Hf]},Wf="attach-ok";function Uf(e,t,n,i,r){To.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=qf(t=r),P("id",t,n)),i.validatedShapes=function(e){var t=k(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;v(qf(t.shapes),(function(e){o.makeDraggable(t,e,!0),v(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,Wf),t.once(["shape.move.out","shape.move.cleanup"],(function(){n.removeMarker(r,Wf)})))}})),this.preExecuted("elements.move",1401,(function(e){var t=e.context,n=t.closure;v(qf(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||v(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){v(e.context.shapes,(function(e){v(e.attachers,(function(e){v(e.outgoing.slice(),(function(e){i.allowed("connection.reconnect",{connection:e,source:e.source,target:e.target})||r.removeConnection(e)})),v(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;zf(n.attachers,(function(e){"attach"===i.allowed("elements.move",{target:o,shapes:[e]})?r.updateAttachment(e,o):r.removeShape(e)})),o.attachers.length&&v(o.attachers,(function(e){var t=Wu(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&&v(a,(function(e){var t=Wu(e,i,o);r.moveShape(e,t,e.parent),v(e.labels,(function(e){r.moveShape(e,t,e.parent)}))}))})),this.preExecute("shape.delete",(function(e){var t=e.context.shape;zf(t.attachers,(function(e){r.removeShape(e)})),t.host&&r.updateAttachment(t,null)}))}function qf(e){return i(E(e,(function(e){return e.attachers||[]})))}e(Uf,To),Uf.$inject=["injector","eventBus","canvas","rules","modeling"];var Kf={__depends__:[bp],__init__:["attachSupport"],attachSupport:["type",Uf]};function Yf(e){this._model=e}function Xf(e,t,n){To.call(this,e),this._bpmnFactory=t;var i=this;function r(e){v(e.context.oldRoot.children,(function(e){mr(e,"bpmn:BaseElement")&&i.updateParent(e)}))}function o(e){var t=e.context.shape;mr(t,"bpmn:BaseElement")&&i.updateBounds(t)}function a(e){i.updateConnection(e.context)}function s(e){i.updateConnectionWaypoints(e.context.connection)}function c(e){i.updateAttachment(e.context)}function p(e){const{element:n}=e.context,i=Wr(n),r=vr(n),o=r&&r.get("label");Fr(n)||Ho(n)||(i&&!o?r.set("label",t.create("bpmndi:BPMNLabel")):!i&&o&&r.set("label",void 0))}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"],Zf((function(e){var t=e.context;i.updateParent(t.shape||t.connection,t.oldParent)}))),this.reverted(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],Zf((function(e){var t=e.context,n=t.shape||t.connection,r=t.parent||t.newParent;i.updateParent(n,r)}))),this.executed(["canvas.updateRoot"],r),this.reverted(["canvas.updateRoot"],r),this.executed(["shape.move","shape.create","shape.resize"],Zf((function(e){"label"!==e.context.shape.type&&o(e)}))),this.reverted(["shape.move","shape.create","shape.resize"],Zf((function(e){"label"!==e.context.shape.type&&o(e)}))),e.on("shape.changed",(function(e){"label"===e.element.type&&o({context:{shape:e.element}})})),this.executed(["connection.create","connection.move","connection.delete","connection.reconnect"],Zf(a)),this.reverted(["connection.create","connection.move","connection.delete","connection.reconnect"],Zf(a)),this.executed(["connection.layout","connection.move","connection.updateWaypoints"],Zf(s)),this.reverted(["connection.layout","connection.move","connection.updateWaypoints"],Zf(s)),this.executed("connection.reconnect",Zf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=gr(n),a=gr(i),s=gr(r);o.conditionExpression&&!yr(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",Zf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=gr(n),a=gr(i),s=gr(r);t.oldConditionExpression&&(o.conditionExpression=t.oldConditionExpression),t.oldDefault&&(a.default=t.oldDefault,delete s.default)}))),this.executed(["element.updateAttachment"],Zf(c)),this.reverted(["element.updateAttachment"],Zf(c)),this.executed("element.updateLabel",Zf(p)),this.reverted("element.updateLabel",Zf(p))}function Zf(e){return function(t){var n=t.context;mr(n.shape||n.connection||n.element,"bpmn:BaseElement")&&e(t)}}function Qf(e,t){Ln.call(this),this._bpmnFactory=e,this._moddle=t}function Jf(e,t,n){return void 0===t[n]?t:(e[n]=t[n],I(t,[n]))}function em(e,t){this._modeling=e,this._canvas=t}function tm(e){this._modeling=e}function nm(e,t){this._canvas=e,this._layouter=t}Yf.$inject=["moddle"],Yf.prototype._needsId=function(e){return yr(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"])},Yf.prototype._ensureId=function(e){var t;e.id?this._model.ids.claim(e.id,e):(t=mr(e,"bpmn:Activity")?"Activity":mr(e,"bpmn:Event")?"Event":mr(e,"bpmn:Gateway")?"Gateway":yr(e,["bpmn:SequenceFlow","bpmn:MessageFlow"])?"Flow":(e.$type||"").replace(/^[^:]*:/g,""),t+="_",!e.id&&this._needsId(e)&&(e.id=this._model.ids.nextPrefixed(t,e)))},Yf.prototype.create=function(e,t){var n=this._model.create(e,t||{});return this._ensureId(n),n},Yf.prototype.createDiLabel=function(){return this.create("bpmndi:BPMNLabel",{bounds:this.createDiBounds()})},Yf.prototype.createDiShape=function(e,t){return this.create("bpmndi:BPMNShape",L({bpmnElement:e,bounds:this.createDiBounds()},t))},Yf.prototype.createDiBounds=function(e){return this.create("dc:Bounds",e)},Yf.prototype.createDiWaypoints=function(e){var t=this;return E(e,(function(e){return t.createDiWaypoint(e)}))},Yf.prototype.createDiWaypoint=function(e){return this.create("dc:Point",$(e,["x","y"]))},Yf.prototype.createDiEdge=function(e,t){return this.create("bpmndi:BPMNEdge",L({bpmnElement:e,waypoint:this.createDiWaypoints([])},t))},Yf.prototype.createDiPlane=function(e,t){return this.create("bpmndi:BPMNPlane",L({bpmnElement:e},t))},e(Xf,To),Xf.$inject=["eventBus","bpmnFactory","connectionDocking"],Xf.prototype.updateAttachment=function(e){var t=e.shape,n=t.businessObject,i=t.host;n.attachedToRef=i&&i.businessObject},Xf.prototype.updateParent=function(e,t){if(!(sn(e)||mr(e,"bpmn:DataStoreReference")&&e.parent&&mr(e.parent,"bpmn:Collaboration"))){var n=e.parent,i=e.businessObject,r=vr(e),o=n&&n.businessObject,a=vr(n);mr(e,"bpmn:FlowNode")&&this.updateFlowNodeRefs(i,o,t&&t.businessObject),mr(e,"bpmn:DataOutputAssociation")&&(o=e.source?e.source.businessObject:null),mr(e,"bpmn:DataInputAssociation")&&(o=e.target?e.target.businessObject:null),this.updateSemanticParent(i,o),mr(e,"bpmn:DataObjectReference")&&i.dataObjectRef&&this.updateSemanticParent(i.dataObjectRef,o),this.updateDiParent(r,a)}},Xf.prototype.updateBounds=function(e){var t=vr(e),n=function(e){if(!mr(e,"bpmn:Activity"))return;var t=vr(e);if(!t)return;var n=t.get("label");if(!n)return;return n.get("bounds")}(e);if(n){var i=za(n,t.get("bounds"));L(n,{x:e.x+i.x,y:e.y+i.y})}var r=sn(e)?this._getLabel(t):t,o=r.bounds;o||(o=this._bpmnFactory.createDiBounds(),r.set("bounds",o)),L(o,{x:e.x,y:e.y,width:e.width,height:e.height})},Xf.prototype.updateFlowNodeRefs=function(e,t,n){n!==t&&(mr(n,"bpmn:Lane")&&vt(n.get("flowNodeRef"),e),mr(t,"bpmn:Lane")&&_t(t.get("flowNodeRef"),e))},Xf.prototype.updateDiConnection=function(e,t,n){var i=vr(e),r=vr(t),o=vr(n);i.sourceElement&&i.sourceElement.bpmnElement!==gr(t)&&(i.sourceElement=t&&r),i.targetElement&&i.targetElement.bpmnElement!==gr(n)&&(i.targetElement=n&&o)},Xf.prototype.updateDiParent=function(e,t){if(t&&!mr(t,"bpmndi:BPMNPlane")&&(t=t.$parent),e.$parent!==t){var n=(t||e.$parent).get("planeElement");t?(n.push(e),e.$parent=t):(vt(n,e),e.$parent=null)}},Xf.prototype.getLaneSet=function(e){var t,n;return mr(e,"bpmn:Lane")?((t=e.childLaneSet)||(t=this._bpmnFactory.create("bpmn:LaneSet"),e.childLaneSet=t,t.$parent=e),t):(mr(e,"bpmn:Participant")&&(e=e.processRef),(t=(n=e.get("laneSets"))[0])||((t=this._bpmnFactory.create("bpmn:LaneSet")).$parent=e,n.push(t)),t)},Xf.prototype.updateSemanticParent=function(e,t,n){var i;if(e.$parent!==t&&(!mr(e,"bpmn:DataInput")&&!mr(e,"bpmn:DataOutput")||(mr(t,"bpmn:Participant")&&"processRef"in t&&(t=t.processRef),!("ioSpecification"in t)||t.ioSpecification!==e.$parent))){if(mr(e,"bpmn:Lane"))t&&(t=this.getLaneSet(t)),i="lanes";else if(mr(e,"bpmn:FlowElement")){if(t)if(mr(t,"bpmn:Participant"))t=t.processRef;else if(mr(t,"bpmn:Lane"))do{t=t.$parent.$parent}while(mr(t,"bpmn:Lane"));i="flowElements"}else if(mr(e,"bpmn:Artifact")){for(;t&&!mr(t,"bpmn:Process")&&!mr(t,"bpmn:SubProcess")&&!mr(t,"bpmn:Collaboration");){if(mr(t,"bpmn:Participant")){t=t.processRef;break}t=t.$parent}i="artifacts"}else if(mr(e,"bpmn:MessageFlow"))i="messageFlows";else if(mr(e,"bpmn:Participant")){i="participants";var r,o=e.processRef;o&&(r=function(e){for(;e&&!mr(e,"bpmn:Definitions");)e=e.$parent;return e}(e.$parent||t),e.$parent&&(vt(r.get("rootElements"),o),o.$parent=null),t&&(_t(r.get("rootElements"),o),o.$parent=r))}else mr(e,"bpmn:DataOutputAssociation")?i="dataOutputAssociations":mr(e,"bpmn:DataInputAssociation")&&(i="dataInputAssociations");if(!i)throw new Error(`no parent for <${e.id}> in <${t.id}>`);var a;if(e.$parent&&vt(a=e.$parent.get(i),e),t?((a=t.get(i)).push(e),e.$parent=t):e.$parent=null,n){var s=n.get(i);vt(a,e),t&&(s||(s=[],t.set(i,s)),s.push(e))}}},Xf.prototype.updateConnectionWaypoints=function(e){vr(e).set("waypoint",this._bpmnFactory.createDiWaypoints(e.waypoints))},Xf.prototype.updateConnection=function(e){var t,n=e.connection,i=gr(n),r=n.source,o=gr(r),a=n.target,s=gr(n.target);if(mr(i,"bpmn:DataAssociation"))mr(i,"bpmn:DataInputAssociation")?(i.get("sourceRef")[0]=o,t=e.parent||e.newParent||s,this.updateSemanticParent(i,s,t)):mr(i,"bpmn:DataOutputAssociation")&&(t=e.parent||e.newParent||o,this.updateSemanticParent(i,o,t),i.targetRef=s);else{var c=mr(i,"bpmn:SequenceFlow");i.sourceRef!==o&&(c&&(vt(i.sourceRef&&i.sourceRef.get("outgoing"),i),o&&o.get("outgoing")&&o.get("outgoing").push(i)),i.sourceRef=o),i.targetRef!==s&&(c&&(vt(i.targetRef&&i.targetRef.get("incoming"),i),s&&s.get("incoming")&&s.get("incoming").push(i)),i.targetRef=s)}this.updateConnectionWaypoints(n),this.updateDiConnection(n,r,a)},Xf.prototype._getLabel=function(e){return e.label||(e.label=this._bpmnFactory.createDiLabel()),e.label},e(Qf,Ln),Qf.$inject=["bpmnFactory","moddle"],Qf.prototype._baseCreate=Ln.prototype.create,Qf.prototype.create=function(e,t){if("label"===e){var n=t.di||this._bpmnFactory.createDiLabel();return this._baseCreate(e,L({type:"label",di:n},Ir,t))}return this.createElement(e,t)},Qf.prototype.createElement=function(e,t){var n,i,r,o=(t=L({},t||{})).businessObject,a=t.di;if(!o){if(!t.type)throw new Error("no shape type specified");hr(o=this._bpmnFactory.create(t.type))}if(!yr(a,["bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane"])){var c=L({},a||{},{id:o.id+"_di"});a="root"===e?this._bpmnFactory.createDiPlane(o,c):"connection"===e?this._bpmnFactory.createDiEdge(o,c):this._bpmnFactory.createDiShape(o,c)}return mr(o,"bpmn:Group")&&(t=L({isFrame:!0},t)),t=function(e,t,n){return v(n,(function(n){t=Jf(e,t,n)})),t}(o,t,["processRef","isInterrupting","associationDirection","isForCompensation"]),t.isExpanded&&(t=Jf(a,t,"isExpanded")),yr(o,["bpmn:Lane","bpmn:Participant"])&&(t=Jf(a,t,"isHorizontal")),mr(o,"bpmn:SubProcess")&&(t.collapsed=!jr(o,a)),mr(o,"bpmn:ExclusiveGateway")&&(f(a,"isMarkerVisible")?void 0===a.isMarkerVisible&&(a.isMarkerVisible=!1):a.isMarkerVisible=!0),s(t.triggeredByEvent)&&(o.triggeredByEvent=t.triggeredByEvent,delete t.triggeredByEvent),s(t.cancelActivity)&&(o.cancelActivity=t.cancelActivity,delete t.cancelActivity),t.eventDefinitionType&&(i=o.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=o,o.eventDefinitions=i,delete t.eventDefinitionType),n=this.getDefaultSize(o,a),t=L({id:o.id},n,t,{businessObject:o,di:a}),this._baseCreate(e,t)},Qf.prototype.getDefaultSize=function(e,t){var n=gr(e);if(t=t||vr(e),mr(n,"bpmn:SubProcess"))return jr(n,t)?{width:350,height:200}:{width:100,height:80};if(mr(n,"bpmn:Task"))return{width:100,height:80};if(mr(n,"bpmn:Gateway"))return{width:50,height:50};if(mr(n,"bpmn:Event"))return{width:36,height:36};if(mr(n,"bpmn:Participant")){var i=void 0===t.isHorizontal||!0===t.isHorizontal;return jr(n,t)?i?{width:600,height:250}:{width:250,height:600}:i?{width:400,height:60}:{width:60,height:400}}return mr(n,"bpmn:Lane")?{width:400,height:100}:mr(n,"bpmn:DataObjectReference")?{width:36,height:50}:mr(n,"bpmn:DataStoreReference")?{width:50,height:50}:mr(n,"bpmn:TextAnnotation")?{width:100,height:30}:mr(n,"bpmn:Group")?{width:300,height:300}:{width:100,height:80}},Qf.prototype.createParticipantShape=function(e){return l(e)||(e={isExpanded:e}),!1!==(e=L({type:"bpmn:Participant"},e||{})).isExpanded&&(e.processRef=this._bpmnFactory.create("bpmn:Process")),this.createShape(e)},em.$inject=["modeling","canvas"],em.prototype.preExecute=function(e){var t=this._modeling,n=e.elements,i=e.alignment;v(n,(function(e){var n={x:0,y:0};s(i.left)?n.x=i.left-e.x:s(i.right)?n.x=i.right-e.width-e.x:s(i.center)?n.x=i.center-Math.round(e.width/2)-e.x:s(i.top)?n.y=i.top-e.y:s(i.bottom)?n.y=i.bottom-e.height-e.y:s(i.middle)&&(n.y=i.middle-Math.round(e.height/2)-e.y),t.moveElements([e],n,e.parent)}))},em.prototype.postExecute=function(e){},tm.$inject=["modeling"],tm.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},tm.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))},nm.$inject=["canvas","layouter"],nm.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},nm.prototype.revert=function(e){var t=e.connection;return this._canvas.removeConnection(t),t.source=null,t.target=null,t};var im=Math.round;function rm(e){this._modeling=e}rm.$inject=["modeling"],rm.prototype.preExecute=function(e){var t=e.elements,n=e.parent,i=e.parentIndex,r=e.position,o=e.hints,a=this._modeling;v(t,(function(e){u(e.x)||(e.x=0),u(e.y)||(e.y=0)}));var s=ht(g(t,(function(e){return!e.hidden})));v(t,(function(e){an(e)&&(e.waypoints=E(e.waypoints,(function(e){return{x:im(e.x-s.x-s.width/2+r.x),y:im(e.y-s.y-s.height/2+r.y)}}))),L(e,{x:im(e.x-s.x-s.width/2+r.x),y:im(e.y-s.y-s.height/2+r.y)})}));var c=st(t),p={};v(t,(function(e){if(an(e))p[e.id]=u(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=L({},o);-1===c.indexOf(e)&&(t.autoResize=!1),sn(e)&&(t=I(t,["attach"])),p[e.id]=u(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=C(p)};var om=Math.round;function am(e){this._canvas=e}function sm(e){am.call(this,e)}am.$inject=["canvas"],am.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?L(t,n):L(t,{x:n.x-om(t.width/2),y:n.y-om(t.height/2)}),this._canvas.addShape(t,i,r),t},am.prototype.revert=function(e){var t=e.shape;return this._canvas.removeShape(t),t},e(sm,am),sm.$inject=["canvas"];var cm=am.prototype.execute;sm.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,cm.call(this,e)};var pm=am.prototype.revert;function lm(e,t){this._canvas=e,this._modeling=t}function um(e,t){this._modeling=e,this._elementRegistry=t}function hm(e,t){this._canvas=e,this._modeling=t}function dm(e){this._modeling=e}sm.prototype.revert=function(e){return e.shape.labelTarget=null,pm.call(this,e)},lm.$inject=["canvas","modeling"],lm.prototype.preExecute=function(e){var t=this._modeling,n=e.connection;zf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),zf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})}))},lm.prototype.execute=function(e){var t=e.connection,n=t.parent;return e.parent=n,e.parentIndex=bt(n.children,t),e.source=t.source,e.target=t.target,this._canvas.removeConnection(t),t.source=null,t.target=null,t},lm.prototype.revert=function(e){var t=e.connection,n=e.parent,i=e.parentIndex;return t.source=e.source,t.target=e.target,_t(n.children,t,i),this._canvas.addConnection(t,n),t},um.$inject=["modeling","elementRegistry"],um.prototype.postExecute=function(e){var t=this._modeling,n=this._elementRegistry;v(e.elements,(function(e){n.get(e.id)&&(e.waypoints?t.removeConnection(e):t.removeShape(e))}))},hm.$inject=["canvas","modeling"],hm.prototype.preExecute=function(e){var t=this._modeling,n=e.shape;zf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),zf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})})),zf(n.children,(function(e){an(e)?t.removeConnection(e,{nested:!0}):t.removeShape(e,{nested:!0})}))},hm.prototype.execute=function(e){var t=this._canvas,n=e.shape,i=n.parent;return e.oldParent=i,e.oldParentIndex=bt(i.children,n),t.removeShape(n),n},hm.prototype.revert=function(e){var t=this._canvas,n=e.shape,i=e.oldParent,r=e.oldParentIndex;return _t(i.children,n,r),t.addShape(n,i),n},dm.$inject=["modeling"];var fm={x:"y",y:"x"};function mm(e,t){this._layouter=e,this._canvas=t}function ym(){}function gm(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}function vm(e){this._modeling=e}function _m(e){this._helper=new vm(e)}function bm(e){this._modeling=e,this._helper=new vm(e)}function xm(e){this._modeling=e}function wm(e){return e.original||e}function Em(e,t){this._modeling=e,this._rules=t}function Sm(e){this._modeling=e}function Cm(e){this._modeling=e}function km(e){return L({},e)}function Rm(e){switch(e){case"n":case"s":return"y";case"w":case"e":return"x"}}function Pm(e,t,n){var i=Rm(n);return/e|s/.test(n)?e[i]>t:/n|w/.test(n)?e[i]<t:void 0}function Am(e,t){return-1!==e.indexOf(t)}function Mm(e){this._modeling=e}function Tm(e){var t={};return v(e,(function(e){t[e.id]=e.hidden,e.children&&(t=L({},t,Tm(e.children)))})),t}function Bm(e,t){var n=[];return v(e,(function(e){e.hidden=t,n=n.concat(e),e.children&&(n=n.concat(Bm(e.children,e.collapsed||t)))})),n}function Dm(e,t){var n=[];return v(e,(function(e){e.hidden=t[e.id],n=n.concat(e),e.children&&(n=n.concat(Dm(e.children,t)))})),n}function Nm(e){this._modeling=e}function jm(e,t){return vt(e&&e.attachers,t)}function Om(e,t,n){if(e){var i=e.attachers;i||(e.attachers=i=[]),_t(i,t,n)}}function Lm(){}function $m(e,t,n){this._eventBus=e,this._elementFactory=t,this._commandStack=n;var i=this;e.on("diagram.init",(function(){i.registerHandlers(n)}))}function Im(e){this._elementRegistry=e}function Fm(e,t){v(t,(function(t,n){e.set(n,t)}))}dm.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;v(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=A(e.elements,i))[0],p===h&&(u=l[s(l)]),d=a(u),e.range=null,v(l,(function(n){!function(e,n){var r={y:0};r[i]=e-a(n),r[i]&&(r[fm[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||v(n,(function(e,o){var a,s={};e!==u&&e!==d&&(a=n[o-1],e.range.max=0,v(e.elements,(function(n,o){s[fm[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)})))}))},dm.prototype.postExecute=function(e){},mm.$inject=["layouter","canvas"],mm.prototype.execute=function(e){var t=e.connection;return L(e,{oldWaypoints:t.waypoints}),t.waypoints=this._layouter.layoutConnection(t,e.hints),t},mm.prototype.revert=function(e){var t=e.connection;return t.waypoints=e.oldWaypoints,t},ym.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=vt(o.children,t),_t(i.children,t,r),t.parent=i,v(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},ym.prototype.revert=function(e){var t=e.connection,n=t.parent,i=e.oldParent,r=e.oldParentIndex,o=e.delta;return vt(n.children,t),_t(i.children,t,r),t.parent=i,v(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},gm.prototype.add=function(e,t){return this.addAll([e],t)},gm.prototype.addAll=function(e,t){var n=function(e,t,n){a(t)&&(t=!0),l(t)&&(n=t,t=!0);var i=mt((n=n||{}).allShapes),r=mt(n.allConnections),o=mt(n.enclosedElements),s=mt(n.enclosedConnections),c=mt(n.topLevel,t&&k(e,(function(e){return e.id})));function p(e){c[e.source.id]&&c[e.target.id]&&(c[e.id]=[e]),i[e.source.id]&&i[e.target.id]&&(s[e.id]=o[e.id]=e),r[e.id]=e}return lt(e,(function(e){if(o[e.id]=e,!e.waypoints)return i[e.id]=e,v(e.incoming,p),v(e.outgoing,p),e.children;s[e.id]=r[e.id]=e})),{allShapes:i,allConnections:r,topLevel:c,enclosedConnections:s,enclosedElements:o}}(e,!!t,this);return L(this,n),this},vm.prototype.moveRecursive=function(e,t,n){return e?this.moveClosure(this.getClosure(e),t,n):[]},vm.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),v(a,(function(e){o.moveShape(e,t,p[e.id]&&!l&&n,{recurse:!1,layout:!1})})),v(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&&Ju(e,e.source,t),connectionEnd:r&&eh(e,e.target,t)})}))},vm.prototype.getClosure=function(e){return(new gm).addAll(e,!0)},_m.$inject=["modeling"],_m.prototype.preExecute=function(e){e.closure=this._helper.getClosure(e.shapes)},_m.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)},bm.$inject=["modeling"],bm.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=vt(o.children,t),_t(i.children,t,r),L(t,{parent:i,x:t.x+n.x,y:t.y+n.y}),t},bm.prototype.postExecute=function(e){var t=e.shape,n=e.delta,i=e.hints,r=this._modeling;!1!==i.layout&&(v(t.incoming,(function(e){r.layoutConnection(e,{connectionEnd:eh(e,t,n)})})),v(t.outgoing,(function(e){r.layoutConnection(e,{connectionStart:Ju(e,t,n)})}))),!1!==i.recurse&&this.moveChildren(e)},bm.prototype.revert=function(e){var t=e.shape,n=e.oldParent,i=e.oldParentIndex,r=e.delta;return _t(n.children,t,i),L(t,{parent:n,x:t.x-r.x,y:t.y-r.y}),t},bm.prototype.moveChildren=function(e){var t=e.delta,n=e.shape;this._helper.moveRecursive(n.children,t,null)},bm.prototype.getNewParent=function(e){return e.newParent||e.shape.parent},xm.$inject=["modeling"],xm.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 p(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},xm.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||wm(p(r)?r[0]:r)),!i||n&&"target"!==o.docking||(a.connectionEnd=a.connectionEnd||wm(p(r)?r[r.length-1]:r)),o.newWaypoints&&(a.waypoints=o.newWaypoints),this._modeling.layoutConnection(t,a))},xm.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},Em.$inject=["modeling","rules"],Em.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();v(h,(function(e){c(e.source,t,e)&&n.reconnectEnd(e,t,Qu(e,t,u),s)})),v(d,(function(e){var i=e.target;c(t,i,e)&&n.reconnectStart(e,t,Zu(e,t,u),s)}))},Em.prototype.postExecute=function(e){var t=e.oldShape;this._modeling.removeShape(t)},Em.prototype.execute=function(e){},Em.prototype.revert=function(e){},Em.prototype.createShape=function(e,t,n,i){return this._modeling.createShape(e,t,n,i)},Em.prototype.reconnectStart=function(e,t,n,i){this._modeling.reconnectStart(e,t,n,i)},Em.prototype.reconnectEnd=function(e,t,n,i){this._modeling.reconnectEnd(e,t,n,i)},Sm.$inject=["modeling"],Sm.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},L(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Sm.prototype.postExecute=function(e){var t=this._modeling,n=e.shape,i=e.oldBounds;!1!==(e.hints||{}).layout&&(v(n.incoming,(function(e){t.layoutConnection(e,{connectionEnd:Qu(e,n,i)})})),v(n.outgoing,(function(e){t.layoutConnection(e,{connectionStart:Zu(e,n,i)})})))},Sm.prototype.revert=function(e){var t=e.shape,n=e.oldBounds;return L(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Cm.$inject=["modeling"],Cm.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),v(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 v(e.concat(t),(function(i){var r=i.incoming,o=i.outgoing;v(r.concat(o),(function(i){var r=i.source,o=i.target;(xf(e,r)||xf(e,o)||xf(t,r)||xf(t,o))&&(xf(n,i)||n.push(i))}))})),n}(i,r),t,n,o,i,r,a)},Cm.prototype.execute=function(){},Cm.prototype.revert=function(){},Cm.prototype.moveShapes=function(e,t){var n=this;v(e,(function(e){n._modeling.moveShape(e,t,null,{autoResize:!1,layout:!1,recurse:!1})}))},Cm.prototype.resizeShapes=function(e,t,n){var i=this;v(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})}))},Cm.prototype.updateConnectionWaypoints=function(e,t,n,i,r,o,a){var s=this,c=r.concat(o);v(e,(function(e){var p=e.source,l=e.target,u=function(e){return E(e.waypoints,(function(e){return(e=km(e)).original&&(e.original=km(e.original)),e}))}(e),h=Rm(n),d={};Am(c,p)&&Am(c,l)?(u=E(u,(function(e){return Pm(e,i,n)&&(e[h]=e[h]+t[h]),e.original&&Pm(e.original,i,n)&&(e.original[h]=e.original[h]+t[h]),e})),s._modeling.updateWaypoints(e,u,{labelBehavior:!1})):(Am(c,p)||Am(c,l))&&(Am(r,p)?d.connectionStart=Ju(e,p,t):Am(r,l)?d.connectionEnd=eh(e,l,t):Am(o,p)?d.connectionStart=Zu(e,p,a[p.id]):Am(o,l)&&(d.connectionEnd=Qu(e,l,a[l.id])),s._modeling.layoutConnection(e,d))}))},Mm.$inject=["modeling"],Mm.prototype.execute=function(e){var t=e.shape,n=t.children;e.oldChildrenVisibility=Tm(n),t.collapsed=!t.collapsed;var i=Bm(n,t.collapsed);return[t].concat(i)},Mm.prototype.revert=function(e){var t=e.shape,n=e.oldChildrenVisibility,i=Dm(t.children,n);return t.collapsed=!t.collapsed,[t].concat(i)},Nm.$inject=["modeling"],Nm.prototype.execute=function(e){var t=e.shape,n=e.newHost,i=t.host;return e.oldHost=i,e.attacherIdx=jm(i,t),Om(n,t),t.host=n,t},Nm.prototype.revert=function(e){var t=e.shape,n=e.newHost,i=e.oldHost,r=e.attacherIdx;return t.host=i,jm(n,t),Om(i,t,r),t},Lm.prototype.execute=function(e){var t=e.connection,n=e.newWaypoints;return e.oldWaypoints=t.waypoints,t.waypoints=n,t},Lm.prototype.revert=function(e){var t=e.connection,n=e.oldWaypoints;return t.waypoints=n,t},$m.$inject=["eventBus","elementFactory","commandStack"],$m.prototype.getHandlers=function(){return{"shape.append":tm,"shape.create":am,"shape.delete":hm,"shape.move":bm,"shape.resize":Sm,"shape.replace":Em,"shape.toggleCollapse":Mm,spaceTool:Cm,"label.create":sm,"connection.create":nm,"connection.delete":lm,"connection.move":ym,"connection.layout":mm,"connection.updateWaypoints":Lm,"connection.reconnect":xm,"elements.create":rm,"elements.move":_m,"elements.delete":um,"elements.distribute":dm,"elements.align":em,"element.updateAttachment":Nm}},$m.prototype.registerHandlers=function(e){v(this.getHandlers(),(function(t,n){e.registerHandler(n,t)}))},$m.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)},$m.prototype.updateAttachment=function(e,t){var n={shape:e,newHost:t};this._commandStack.execute("element.updateAttachment",n)},$m.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)},$m.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)},$m.prototype.layoutConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.layout",n)},$m.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},$m.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},$m.prototype.createElements=function(e,t,n,i,r){p(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},$m.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},$m.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},$m.prototype.removeElements=function(e){var t={elements:e};this._commandStack.execute("elements.delete",t)},$m.prototype.distributeElements=function(e,t,n){var i={groups:e,axis:t,dimension:n};this._commandStack.execute("elements.distribute",i)},$m.prototype.removeShape=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.delete",n)},$m.prototype.removeConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.delete",n)},$m.prototype.replaceShape=function(e,t,n){var i={oldShape:e,newData:t,hints:n||{}};return this._commandStack.execute("shape.replace",i),i.newShape},$m.prototype.alignElements=function(e,t){var n={elements:e,alignment:t};this._commandStack.execute("elements.align",n)},$m.prototype.resizeShape=function(e,t,n,i){var r={shape:e,newBounds:t,minBounds:n,hints:i};this._commandStack.execute("shape.resize",r)},$m.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)},$m.prototype.updateWaypoints=function(e,t,n){var i={connection:e,newWaypoints:t,hints:n||{}};this._commandStack.execute("connection.updateWaypoints",i)},$m.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)},$m.prototype.reconnectStart=function(e,t,n,i){i||(i={}),this.reconnect(e,t,e.target,n,L(i,{docking:"source"}))},$m.prototype.reconnectEnd=function(e,t,n,i){i||(i={}),this.reconnect(e,e.source,t,n,L(i,{docking:"target"}))},$m.prototype.connect=function(e,t,n,i){return this.createConnection(e,t,n||{},e.parent,i)},$m.prototype._create=function(e,t){return t instanceof Tn?t:this._elementFactory.create(e,t)},$m.prototype.toggleCollapse=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.toggleCollapse",n)},Im.$inject=["elementRegistry"],Im.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 b(t,(function(t,n){return t[n]=e.get(n),t}),{})}(n,S(i));return Fm(n,i),e.oldProperties=o,e.changed=r,r},Im.prototype.revert=function(e){var t=e.oldProperties,n=e.moddleElement,i=e.changed;return Fm(n,t),i},Im.prototype._getVisualReferences=function(e){var t=this._elementRegistry;return mr(e,"bpmn:DataObject")?function(e,t){return t.filter((function(t){return mr(t,"bpmn:DataObjectReference")&&gr(t).dataObjectRef===e}))}(e,t):[]};var zm="default",Hm="id",Vm="di",Gm={width:0,height:0};function Wm(e,t,n,i){this._elementRegistry=e,this._moddle=t,this._modeling=n,this._textRenderer=i}function Um(e,t){return Hm in e&&e[Hm]!==t[Hm]}function qm(e,t){var n=e.businessObject,i=vr(e);v(t,(function(e,t){t!==Vm?n.set(t,e):i&&function(e,t){v(t,(function(t,n){e.set(n,t)}))}(i,e)}))}Wm.$inject=["elementRegistry","moddle","modeling","textRenderer"],Wm.prototype.execute=function(e){var t=e.element,n=[t];if(!t)throw new Error("element required");var i=this._elementRegistry,r=this._moddle.ids,o=t.businessObject,a=function(e){var t=L({},e);return Km.forEach((function(n){n in e&&(t[n]=gr(t[n]))})),t}(e.properties),s=e.oldProperties||function(e,t){var n=S(t),i=e.businessObject,r=vr(e);return b(n,(function(e,n){return e[n]=n!==Vm?i.get(n):function(e,t){return b(t,(function(t,n){return t[n]=e&&e.get(n),t}),{})}(r,S(t.di)),e}),{})}(t,a);return Um(a,o)&&(r.unclaim(o[Hm]),i.updateId(t,a[Hm]),r.claim(a[Hm],o)),zm in a&&(a[zm]&&n.push(i.get(a[zm].id)),o[zm]&&n.push(i.get(o[zm].id))),qm(t,a),e.oldProperties=s,e.changed=n,n},Wm.prototype.postExecute=function(e){var t=e.element.label,n=t&&gr(t).name;if(n){var i=this._textRenderer.getExternalLabelBounds(t,n);this._modeling.resizeShape(t,i,Gm)}},Wm.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 qm(t,i),Um(n,r)&&(a.unclaim(n[Hm]),o.updateId(t,i[Hm]),a.claim(i[Hm],r)),e.changed};var Km=["default"];function Ym(e,t){this._canvas=e,this._modeling=t}function Xm(e,t){this._modeling=e,this._spaceTool=t}function Zm(e){this._modeling=e}function Qm(e,t){this._modeling=e,this._spaceTool=t}Ym.$inject=["canvas","modeling"],Ym.prototype.execute=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,r=t.getRootElement(),o=r.businessObject,a=o.$parent,s=vr(r);return t.setRootElement(n),t.removeRootElement(r),_t(a.rootElements,i),i.$parent=a,vt(a.rootElements,o),o.$parent=null,r.di=null,s.bpmnElement=i,n.di=s,e.oldRoot=r,[]},Ym.prototype.revert=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,r=e.oldRoot,o=r.businessObject,a=i.$parent,s=vr(n);return t.setRootElement(r),t.removeRootElement(n),vt(a.rootElements,i),i.$parent=null,_t(a.rootElements,o),o.$parent=a,n.di=null,s.bpmnElement=o,r.di=s,[]},Xm.$inject=["modeling","spaceTool"],Xm.prototype.preExecute=function(e){var t=this._spaceTool,n=this._modeling,i=e.shape,r=e.location,o=fu(i),a=o===i,s=a?i:i.parent,c=du(s),p=Or(i);if(p?"left"===r?r="top":"right"===r&&(r="bottom"):"top"===r?r="left":"bottom"===r&&(r="right"),!c.length){var l=p?{x:i.x+uu,y:i.y,width:i.width-uu,height:i.height}:{x:i.x,y:i.y+uu,width:i.width,height:i.height-uu};n.createShape({type:"bpmn:Lane",isHorizontal:p},l,s)}var u,h,d,f,m,y=[];lt(o,(function(e){return y.push(e),e.label&&y.push(e.label),e===i?[]:g(e.children,(function(e){return e!==i}))})),"top"===r?(u=-120,d=(h=i.y)+10,f="n",m="y"):"left"===r?(u=-120,d=(h=i.x)+10,f="w",m="x"):"bottom"===r?(u=120,d=(h=i.y+i.height)-10,f="s",m="y"):"right"===r&&(u=120,d=(h=i.x+i.width)-10,f="e",m="x");var v=t.calculateAdjustments(y,m,u,d),_=p?{x:0,y:u}:{x:u,y:0};t.makeSpace(v.movingShapes,v.resizingShapes,_,f,d);var b=p?{x:i.x+(a?uu:0),y:h-("top"===r?120:0),width:i.width-(a?uu:0),height:120}:{x:h-("left"===r?120:0),y:i.y+(a?uu:0),width:120,height:i.height-(a?uu:0)};e.newLane=n.createShape({type:"bpmn:Lane",isHorizontal:p},b,s)},Zm.$inject=["modeling"],Zm.prototype.preExecute=function(e){var t=this._modeling,n=e.shape,i=e.count,r=du(n),o=r.length;if(o>i)throw new Error(`more than <${i}> child lanes`);var a,s,c,p,l=Or(n),u=l?n.height:n.width,h=Math.round(u/i);for(p=0;p<i;p++)a=p===i-1?u-h*p:h,s=l?{x:n.x+uu,y:n.y+p*h,width:n.width-uu,height:a}:{x:n.x+p*h,y:n.y+uu,width:a,height:n.height-uu},p<o?t.resizeShape(r[p],s):(c={type:"bpmn:Lane",isHorizontal:l},t.createShape(c,s,n))},Qm.$inject=["modeling","spaceTool"],Qm.prototype.preExecute=function(e){var t=e.shape,n=e.newBounds;!1!==e.balanced?this.resizeBalanced(t,n):this.resizeSpace(t,n)},Qm.prototype.resizeBalanced=function(e,t){var n=this._modeling,i=mu(e,t);n.resizeShape(e,t),i.forEach((function(e){n.resizeShape(e.shape,e.newBounds)}))},Qm.prototype.resizeSpace=function(e,t){var n,i,r,o,a,s=this._spaceTool,c=ln(e),p=ru(ln(t),c),l=fu(e),u=[],h=[];lt(l,(function(e){return u.push(e),(mr(e,"bpmn:Lane")||mr(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 Jm="flowNodeRef",ey="lanes";function ty(e){this._elementRegistry=e}function ny(e){this._moddle=e}ty.$inject=["elementRegistry"],ty.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){if(!e.parent)return[];var t=function(e){var t=fu(e);return r[t.id]||(r[t.id]=hu(t)),r[t.id]}(e);return t.filter((function(t){return n=e,i=ln(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=fu(e);if(t&&-1===n.indexOf(t)){var i=t.children.filter((function(e){return mr(e,"bpmn:FlowNode")}));i.forEach(a),n.push(t)}})),e.forEach(a),o.forEach((function(e){var t=e.businessObject,n=t.get(ey).slice(),r=s(e);i.push({flowNode:t,remove:n,add:r})})),t.forEach((function(e){var t=e.businessObject;e.parent||t.get(Jm).forEach((function(e){i.push({flowNode:e,remove:[t],add:[]})}))})),i},ty.prototype.execute=function(e){var t=e.updates;return t||(t=e.updates=this._computeUpdates(e.flowNodeShapes,e.laneShapes)),t.forEach((function(e){var t=e.flowNode,n=t.get(ey);e.remove.forEach((function(e){vt(n,e),vt(e.get(Jm),t)})),e.add.forEach((function(e){_t(n,e),_t(e.get(Jm),t)}))})),[]},ty.prototype.revert=function(e){return e.updates.forEach((function(e){var t=e.flowNode,n=t.get(ey);e.add.forEach((function(e){vt(n,e),vt(e.get(Jm),t)})),e.remove.forEach((function(e){_t(n,e),_t(e.get(Jm),t)}))})),[]},ny.$inject=["moddle"],ny.prototype.execute=function(e){var t=this._moddle.ids,n=e.id,i=e.element;return e.claiming?t.claim(n,i):t.unclaim(n),[]},ny.prototype.revert=function(e){var t=this._moddle.ids,n=e.id,i=e.element;return e.claiming?t.unclaim(n):t.claim(n,i),[]};var iy={fill:void 0,stroke:void 0};function ry(e){this._commandStack=e,this._normalizeColor=function(e){if(e){if(d(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}`)}}}ry.$inject=["commandStack"],ry.prototype.postExecute=function(e){var t=e.elements,n=e.colors||iy,i=this,r={};"fill"in n&&L(r,{"background-color":this._normalizeColor(n.fill)}),"stroke"in n&&L(r,{"border-color":this._normalizeColor(n.stroke)}),v(t,(function(e){var t=an(e)?$(r,["border-color"]):r,n=vr(e);if(function(e){"border-color"in e&&(e.stroke=e["border-color"]);"background-color"in e&&(e.fill=e["background-color"])}(t),sn(e))i._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:n.label,properties:{color:r["border-color"]}});else{if(!yr(n,["bpmndi:BPMNEdge","bpmndi:BPMNShape"]))return;i._commandStack.execute("element.updateProperties",{element:e,properties:{di:t}})}}))};var oy={width:0,height:0};function ay(e,t,n){function i(e,t){var n=e.label||e,i=e.labelTarget||e;return function(e,t){var n=e.businessObject,i=Gr(n);if(i)if("categoryValueRef"===i){if(!n[i])return e;n[i].value=t}else n[i]=t}(n,t),[n,i]}this.preExecute=function(t){var n=t.element,i=n.businessObject,r=t.newLabel;if(!sn(n)&&Fr(n)&&!zr(n)&&!sy(r)){var o=Vr(n);o={x:o.x,y:o.y+7},e.createLabel(n,o,{id:i.id+"_label",businessObject:i,di:n.di})}},this.execute=function(e){return e.oldLabel=Wr(e.element),i(e.element,e.newLabel)},this.revert=function(e){return i(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(sn(r)||mr(r,"bpmn:TextAnnotation"))if(sn(r)&&sy(o))!1!==s.removeShape&&e.removeShape(r,{unsetLabel:!1});else{var c=Wr(i);void 0===a&&(a=t.getExternalLabelBounds(r,c)),a&&e.resizeShape(r,a,oy)}}}function sy(e){return!e||!e.trim()}function cy(e,t,n,i){$m.call(this,e,t,n),this._bpmnRules=i}function py(){}ay.$inject=["modeling","textRenderer","bpmnFactory"],e(cy,$m),cy.$inject=["eventBus","elementFactory","commandStack","bpmnRules"],cy.prototype.getHandlers=function(){var e=$m.prototype.getHandlers.call(this);return e["element.updateModdleProperties"]=Im,e["element.updateProperties"]=Wm,e["canvas.updateRoot"]=Ym,e["lane.add"]=Xm,e["lane.resize"]=Qm,e["lane.split"]=Zm,e["lane.updateRefs"]=ty,e["id.updateClaim"]=ny,e["element.setColor"]=ry,e["element.updateLabel"]=ay,e},cy.prototype.updateLabel=function(e,t,n,i){this._commandStack.execute("element.updateLabel",{element:e,newLabel:t,newBounds:n,hints:i||{}})},cy.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)},cy.prototype.updateModdleProperties=function(e,t,n){this._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:t,properties:n})},cy.prototype.updateProperties=function(e,t){this._commandStack.execute("element.updateProperties",{element:e,properties:t})},cy.prototype.resizeLane=function(e,t,n){this._commandStack.execute("lane.resize",{shape:e,newBounds:t,balanced:n})},cy.prototype.addLane=function(e,t){var n={shape:e,location:t};return this._commandStack.execute("lane.add",n),n.newLane},cy.prototype.splitLane=function(e,t){this._commandStack.execute("lane.split",{shape:e,count:t})},cy.prototype.makeCollaboration=function(){var e=this._create("root",{type:"bpmn:Collaboration"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},cy.prototype.makeProcess=function(){var e=this._create("root",{type:"bpmn:Process"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},cy.prototype.updateLaneRefs=function(e,t){this._commandStack.execute("lane.updateRefs",{flowNodeShapes:e,laneShapes:t})},cy.prototype.claimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t,claiming:!0})},cy.prototype.unclaimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t})},cy.prototype.setColor=function(e,t){e.length||(e=[e]),this._commandStack.execute("element.setColor",{elements:e,colors:t})},py.prototype.layoutConnection=function(e,t){return[(t=t||{}).connectionStart||dn(t.source||e.source),t.connectionEnd||dn(t.target||e.target)]};var ly=Math.round,uy={"h:h":20,"v:v":20,"h:v":-10,"v:h":-10};function hy(e,t,n){var i,r,o,a=fn(t,e,5),s=n.split(":")[0],c=ly((t.x-e.x)/2+e.x),p=ly((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,d=!1;return l?(i=u?{x:c,y:e.y}:{x:e.x,y:p},r=u?"h:h":"v:v"):(h=function(e,t){return!{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/./,v:/./}[t].test(e)}(a,s),r=u?"h:v":"v:h",h?u?(d=p===e.y,i={x:e.x+20*(/l/.test(s)?-1:1),y:d?p+20:p}):i={x:(d=c===e.x)?c+20:c,y:e.y+20*(/t/.test(s)?-1:1)}:i={x:c,y:p}),{waypoints:fy(e,i,r).concat(i),directions:r,turnNextDirections:d}}function dy(e){return e.split(":").reverse().join(":")}function fy(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(_y(n)){var i=function(e,t,n){return hy(e,t,n)}(e,t,n),r=function(e,t,n){var i=hy(t,e,dy(n));return{waypoints:i.waypoints.slice().reverse(),directions:dy(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:fy(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=ly((t.x-e.x)/2+e.x),r=ly((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 my(e,t,n,i,r){var o=_(r&&r.preferredLayouts||[],"straight")[0]||"h:h",a=fn(e,t,uy[o]||0),s=function(e,t){if(_y(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||dn(e),i=i||dn(t);var c=s.split(":"),p=by(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));return function(e,t,n){var i=fy(e,t,n);return i.unshift(e),i.push(t),xy(i)}(p,by(i,t,c[1],a),s)}function yy(e,t,n,i,r,o){var a;return p(n)&&(r=n,o=i,n=dn(e),i=dn(t)),r=r||[],a=-1!==(o=L({preferredLayouts:[]},o)).preferredLayouts.indexOf("straight")&&function(e,t,n,i,r){var o,a,s={};if(a=fn(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?gy(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:gy(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||(a=o.connectionEnd&&function(e,t,n,i){var r=i.slice().reverse();return r=vy(e,t,n,r),r?r.reverse():null}(t,e,i,r),a||((a=o.connectionStart&&vy(e,t,n,r))||(!o.connectionStart&&!o.connectionEnd&&r&&r.length?r:my(e,t,n,i,o))))}function gy(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 vy(e,t,n,i){if(function(e){return e.length<3||!(e.length>4)&&!!m(e,(function(t,n){var i=e[n-1];return i&&xt(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(Et(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(Ct(e[i],t,20)||Ct(e[i],n,20))return e.slice(i);return e}(a,e,t),r!==a&&(a=vy(e,t,n,r)),a&&Et(a)?null:a}function _y(e){return e&&/t|r|b|l/.test(e)}function by(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 xy(e){return e.reduce((function(t,n,i){return wt(t[t.length-1],e[i+1],n,0)||t.push(n),t}),[])}var wy={default:["h:h"],fromGateway:["v:h"],toGateway:["h:v"],loop:{fromTop:["t:r"],fromRight:["r:b"],fromLeft:["l:t"],fromBottom:["b:l"]},boundaryLoop:{alternateHorizontalSide:"b",alternateVerticalSide:"l",default:"v"},messageFlow:["straight","v:v"],subProcess:["straight","h:h"],isHorizontal:!0},Ey={default:["v:v"],fromGateway:["h:v"],toGateway:["v:h"],loop:{fromTop:["t:l"],fromRight:["r:t"],fromLeft:["l:b"],fromBottom:["b:r"]},boundaryLoop:{alternateHorizontalSide:"t",alternateVerticalSide:"r",default:"h"},messageFlow:["straight","h:h"],subProcess:["straight","v:v"],isHorizontal:!1},Sy={top:"bottom","top-right":"bottom-left","top-left":"bottom-right",right:"left",bottom:"top","bottom-right":"top-left","bottom-left":"top-right",left:"right"},Cy={top:"t",right:"r",bottom:"b",left:"l"};function ky(e){this._elementRegistry=e}function Ry(e,t){return mr(t,"bpmn:Participant")?"source":mr(e,"bpmn:Participant")?"target":Ty(t)?"source":Ty(e)||mr(t,"bpmn:Event")?"target":mr(e,"bpmn:Event")?"source":null}function Py(e){return Ty(e)?"target":"source"}function Ay(e,t){return e?e.original||e:dn(t)}function My(e,t){return mr(t,"bpmn:Activity")&&mr(e,"bpmn:BoundaryEvent")&&t.businessObject.isForCompensation}function Ty(e){return mr(e,"bpmn:SubProcess")&&jr(e)}function By(e,t){return e===t}function Dy(e){var t=/right|left/.exec(e);return t&&t[0]}function Ny(e){var t=/top|bottom/.exec(e);return t&&t[0]}function jy(e,t){return Sy[e]===t}function Oy(e){return"right"===e||"left"===e}function Ly(e,t,n){var i=t.waypoints,r=i&&i.length&&fn(i[0],e);return"top"===r?n.loop.fromTop:"right"===r?n.loop.fromRight:"left"===r?n.loop.fromLeft:n.loop.fromBottom}function $y(e,t,n,i){var r,o,a,s,c=dn(e),p=dn(t),l=(s=(a=e).host,fn(dn(a),s,-10)),u=By(e.host,t),h=-1!==["top","right","bottom","left"].indexOf(l),d=fn(p,c,{x:e.width/2+t.width/2,y:e.height/2+t.height/2});return u?function(e,t,n,i,r,o){var a,s=t?e:o.isHorizontal?Ny(e):Dy(e),c=Cy[s];a=t?Oy(e)?Iy("y",n,i,r)?"h":o.boundaryLoop.alternateHorizontalSide:Iy("x",n,i,r)?"v":o.boundaryLoop.alternateVerticalSide:o.boundaryLoop.default;return[c+":"+a]}(l,h,e,t,n,i):(r=function(e,t,n,i){if(n)return Cy[e];var r=Ny(e),o=Dy(e),a=Ny(t),s=Dy(t);if(i){if(By(r,a)||jy(o,s))return Cy[r]}else if(By(o,s)||jy(r,a))return Cy[o];return Cy[i?o:r]}(l,d,h,i.isHorizontal),o=function(e,t,n,i){if(n)return Oy(e)?function(e,t){var n=Dy(e),i=Sy[n];return-1!==t.indexOf(i)}(e,t)||By(e,t)?"h":"v":function(e,t){var n=Ny(e),i=Sy[n];return-1!==t.indexOf(i)}(e,t)||By(e,t)?"v":"h";return i?By(Ny(e),Ny(t))?"h":"v":By(Dy(e),Dy(t))?"v":"h"}(l,d,h,i.isHorizontal),[r+":"+o])}function Iy(e,t,n,i){return!(Fy(e,i,n,40)||Fy(e,i,{x:n.x+n.width,y:n.y+n.height},40)||Fy(e,i,dn(t),40))}function Fy(e,t,n,i){return Math.abs(t[e]-n[e])<i}function zy(e){return L({original:e.point.original||e.point},e.actual)}function Hy(e,t){this._elementRegistry=e,this._graphicsFactory=t}e(ky,py),ky.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,p=this._elementRegistry;if(s||(s=Ay(a&&a[0],r)),c||(c=Ay(a&&a[a.length-1],o)),(mr(e,"bpmn:Association")||mr(e,"bpmn:DataAssociation"))&&a&&!My(r,o))return[].concat([s],a.slice(1,-1),[c]);var l=Jc(r,p)?wy:Ey;return mr(e,"bpmn:MessageFlow")?n=function(e,t,n){return{preferredLayouts:n.messageFlow,preserveDocking:Ry(e,t)}}(r,o,l):(mr(e,"bpmn:SequenceFlow")||My(r,o))&&(n=r===o?{preferredLayouts:Ly(r,e,l)}:mr(r,"bpmn:BoundaryEvent")?{preferredLayouts:$y(r,o,c,l)}:Ty(r)||Ty(o)?{preferredLayouts:l.subProcess,preserveDocking:Py(r)}:mr(r,"bpmn:Gateway")?{preferredLayouts:l.fromGateway}:mr(o,"bpmn:Gateway")?{preferredLayouts:l.toGateway}:{preferredLayouts:l.default}),n&&(i=xy(yy(r,o,s,c,a,n=L(n,t)))),i||[s,c]},ky.$inject=["elementRegistry"],Hy.$inject=["elementRegistry","graphicsFactory"],Hy.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(zy(i)),o.push(zy(r)),o},Hy.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}},Hy.prototype._getIntersection=function(e,t,n){return mn(this._getShapePath(e),this._getConnectionPath(t),n)},Hy.prototype._getConnectionPath=function(e){return this._graphicsFactory.getConnectionPath(e)},Hy.prototype._getShapePath=function(e){return this._graphicsFactory.getShapePath(e)},Hy.prototype._getGfx=function(e){return this._elementRegistry.getGraphics(e)};var Vy={__init__:["modeling","bpmnUpdater"],__depends__:[Jh,Dd,jd,$d,vf,Ff,Gf,Kf,_a,Mo,$f],bpmnFactory:["type",Yf],bpmnUpdater:["type",Xf],elementFactory:["type",Qf],modeling:["type",cy],layouter:["type",ky],connectionDocking:["type",Hy]};const Gy=Math.round;function Wy(e,t,n,i,r,o){this._complexPreview=e,this._connectionDocking=t,this._elementFactory=n,this._eventBus=i,this._layouter=r,this._rules=o}Wy.prototype.create=function(e,t,n){const i=this._complexPreview,r=this._connectionDocking,o=this._elementFactory,a=this._eventBus,s=this._layouter,p=this._rules,l=o.createShape(L({type:t},n)),u=a.fire("autoPlace",{source:e,shape:l});if(!u)return;L(l,{x:u.x-Gy(l.width/2),y:u.y-Gy(l.height/2)});const h=p.allowed("connection.create",{source:e,target:l,hints:{targetParent:e.parent}});let d=null;h&&(d=o.createConnection(h),d.waypoints=s.layoutConnection(d,{source:e,target:l}),d.waypoints=r.getCroppedWaypoints(d,e,l)),i.create({created:[l,d].filter((e=>!c(e)))})},Wy.prototype.cleanUp=function(){this._complexPreview.cleanUp()},Wy.$inject=["complexPreview","connectionDocking","elementFactory","eventBus","layouter","rules"];var Uy={__depends__:[ip,Tl,Vy],__init__:["appendPreview"],appendPreview:["type",Wy]},qy=Math.min,Ky=Math.max;function Yy(e){e.preventDefault()}function Xy(e){e.stopPropagation()}function Zy(e){this.container=e.container,this.parent=he('<div class="djs-direct-editing-parent"><div class="djs-direct-editing-content" contenteditable="true"></div></div>'),this.content=fe("[contenteditable]",this.parent),this.keyHandler=e.keyHandler||function(){},this.resizeHandler=e.resizeHandler||function(){},this.autoResize=O(this.autoResize,this),this.handlePaste=O(this.handlePaste,this)}function Qy(e,t){this._eventBus=e,this._canvas=t,this._providers=[],this._textbox=new Zy({container:t.getContainer(),keyHandler:O(this._handleKey,this),resizeHandler:O(this._handleResize,this)})}Zy.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"]);L(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 L(o.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},c),i.centerVertically&&L(o.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},c),o.innerText=n,oe.bind(o,"keydown",this.keyHandler),oe.bind(o,"mousedown",Xy),oe.bind(o,"paste",this.handlePaste),i.autoResize&&oe.bind(o,"input",this.autoResize),i.resizable&&this.resizable(t),a.appendChild(r),this.setSelection(o.lastChild,o.lastChild&&o.lastChild.length),r},Zy.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)}},Zy.prototype.insertText=function(e){e=e.replace(/\r\n|\r|\n/g,"\n"),document.execCommand("insertText",!1,e)||this._insertTextIE(e)},Zy.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&&ye(t)})),n=o,i=s+e.length}n&&void 0!==i&&setTimeout((function(){self.setSelection(n,i)}))},Zy.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})}},Zy.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=he('<div class="djs-direct-editing-resize-handle"></div>');var u=function(n){Yy(n),Xy(n);var u=qy(Ky(p+n.clientX-s,i),o),h=qy(Ky(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){Yy(e),Xy(e),oe.unbind(document,"mousemove",u,!1),oe.unbind(document,"mouseup",h,!1)};oe.bind(n,"mousedown",(function(e){Yy(e),Xy(e),s=e.clientX,c=e.clientY;var n=t.getBoundingClientRect();p=n.width,l=n.height,oe.bind(document,"mousemove",u),oe.bind(document,"mouseup",h)}))}L(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)},Zy.prototype.destroy=function(){var e=this.parent,t=this.content,n=this.resizeHandle;t.innerText="",e.removeAttribute("style"),t.removeAttribute("style"),oe.unbind(t,"keydown",this.keyHandler),oe.unbind(t,"mousedown",Xy),oe.unbind(t,"input",this.autoResize),oe.unbind(t,"paste",this.handlePaste),n&&(n.removeAttribute("style"),ye(n)),ye(e)},Zy.prototype.getValue=function(){return this.content.innerText.trim()},Zy.prototype.getSelection=function(){return window.getSelection().getRangeAt(0)},Zy.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)},Qy.$inject=["eventBus","canvas"],Qy.prototype.registerProvider=function(e){this._providers.push(e)},Qy.prototype.isActive=function(e){return!(!this._active||e&&this._active.element!==e)},Qy.prototype.cancel=function(){this._active&&(this._fire("cancel"),this.close())},Qy.prototype._fire=function(e,t){this._eventBus.fire("directEditing."+e,t||{active:this._active})},Qy.prototype.close=function(){this._textbox.destroy(),this._fire("deactivate"),this._active=null,this.resizable=void 0,this._canvas.restoreFocus&&this._canvas.restoreFocus()},Qy.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()}},Qy.prototype.getValue=function(){return this._textbox.getValue()},Qy.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())},Qy.prototype._handleResize=function(e){this._fire("resize",e)},Qy.prototype.activate=function(e){var t;this.isActive()&&this.cancel();var n=m(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 Jy={__depends__:[ha],__init__:["directEditing"],directEditing:["type",Qy]};function eg(e){return function(t){var n=t.target,i=gr(e),r=i.eventDefinitions&&i.eventDefinitions[0],o=i.$type===n.type,a=(r&&r.$type)===n.eventDefinitionType,s=!!n.triggeredByEvent==!!i.triggeredByEvent,c=void 0===n.isExpanded||n.isExpanded===jr(e);return!(o&&a&&s&&c)}}var tg=[{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"}}],ng=[{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"}}],ig=[{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"}}],rg=[{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"}}],og=[{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"}}],ag=[{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}}],sg=[{label:"Transaction",actionName:"replace-with-transaction",className:"bpmn-icon-transaction",target:{type:"bpmn:Transaction",isExpanded:!0}},{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}}],cg=sg,pg=[{label:"Task",actionName:"replace-with-task",className:"bpmn-icon-task",target:{type:"bpmn:Task"}},{label:"User task",actionName:"replace-with-user-task",className:"bpmn-icon-user",target:{type:"bpmn:UserTask"}},{label:"Service task",actionName:"replace-with-service-task",className:"bpmn-icon-service",target:{type:"bpmn:ServiceTask"}},{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:"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:"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}}],lg=[{label:"Data store reference",actionName:"replace-with-data-store-reference",className:"bpmn-icon-data-store",target:{type:"bpmn:DataStoreReference"}}],ug=[{label:"Data object reference",actionName:"replace-with-data-object-reference",className:"bpmn-icon-data-object",target:{type:"bpmn:DataObjectReference"}}],hg=[{label:"Message boundary event",actionName:"replace-with-message-boundary",className:"bpmn-icon-intermediate-event-catch-message",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:MessageEventDefinition",cancelActivity:!0}},{label:"Timer boundary event",actionName:"replace-with-timer-boundary",className:"bpmn-icon-intermediate-event-catch-timer",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:TimerEventDefinition",cancelActivity:!0}},{label:"Escalation boundary event",actionName:"replace-with-escalation-boundary",className:"bpmn-icon-intermediate-event-catch-escalation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",cancelActivity:!0}},{label:"Conditional boundary event",actionName:"replace-with-conditional-boundary",className:"bpmn-icon-intermediate-event-catch-condition",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",cancelActivity:!0}},{label:"Error boundary event",actionName:"replace-with-error-boundary",className:"bpmn-icon-intermediate-event-catch-error",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ErrorEventDefinition",cancelActivity:!0}},{label:"Cancel boundary event",actionName:"replace-with-cancel-boundary",className:"bpmn-icon-intermediate-event-catch-cancel",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:CancelEventDefinition",cancelActivity:!0}},{label:"Signal boundary event",actionName:"replace-with-signal-boundary",className:"bpmn-icon-intermediate-event-catch-signal",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:SignalEventDefinition",cancelActivity:!0}},{label:"Compensation boundary event",actionName:"replace-with-compensation-boundary",className:"bpmn-icon-intermediate-event-catch-compensation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:CompensateEventDefinition",cancelActivity:!0}},{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}}],dg=[{label:"Message start event",actionName:"replace-with-message-start",className:"bpmn-icon-start-event-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition",isInterrupting:!0}},{label:"Timer start event",actionName:"replace-with-timer-start",className:"bpmn-icon-start-event-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition",isInterrupting:!0}},{label:"Conditional start event",actionName:"replace-with-conditional-start",className:"bpmn-icon-start-event-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",isInterrupting:!0}},{label:"Signal start event",actionName:"replace-with-signal-start",className:"bpmn-icon-start-event-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition",isInterrupting:!0}},{label:"Error start event",actionName:"replace-with-error-start",className:"bpmn-icon-start-event-error",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ErrorEventDefinition",isInterrupting:!0}},{label:"Escalation start event",actionName:"replace-with-escalation-start",className:"bpmn-icon-start-event-escalation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",isInterrupting:!0}},{label:"Compensation start event",actionName:"replace-with-compensation-start",className:"bpmn-icon-start-event-compensation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:CompensateEventDefinition",isInterrupting:!0}},{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}}],fg=[{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"}],mg=[{label:"Expanded pool/participant",actionName:"replace-with-expanded-pool",className:"bpmn-icon-participant",target:{type:"bpmn:Participant",isExpanded:!0}},{label:function(e){var t="Empty pool/participant";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}}],yg={"start-event-non-interrupting":'\n <svg viewBox="0 0 2048 2048" xmlns="http://www.w3.org/2000/svg">\n <g transform="translate(0 995.64)">\n <path d="m1899 28.357c21.545 567.43-598.38 1023.5-1133.6 835.92-548.09-147.21-801.57-873.95-463.59-1330 302.62-480.3 1071.7-507.54 1407.6-49.847 122.14 153.12 190.07 348.07 189.59 543.91z" fill="none" stroke="currentColor" stroke-dasharray="418.310422, 361.2328165" stroke-linecap="round" stroke-width="100"/>\n </g>\n </svg>',"intermediate-event-non-interrupting":'\n <svg viewBox="0 0 2048 2048" xmlns="http://www.w3.org/2000/svg">\n <g transform="translate(0 995.64)" fill="none" stroke="currentColor" stroke-linecap="round">\n <circle cx="1024" cy="28.357" r="875" stroke-dasharray="418.310422, 361.2328165" stroke-width="100"/>\n <circle cx="1024" cy="28.357" r="685" stroke-dasharray="348.31044857,261.23283643" stroke-dashoffset="500" stroke-width="100"/>\n </g>\n </svg>'};function gg(e,t,n,i,r,o,a,s){this._bpmnFactory=e,this._popupMenu=t,this._modeling=n,this._moddle=i,this._bpmnReplace=r,this._rules=o,this._translate=a,this._moddleCopy=s,this._register()}gg.$inject=["bpmnFactory","popupMenu","modeling","moddle","bpmnReplace","rules","translate","moddleCopy"],gg.prototype._register=function(){this._popupMenu.registerProvider("bpmn-replace",this)},gg.prototype.getPopupMenuEntries=function(e){var t=e.businessObject,n=this._rules,i=[];if(p(e)||!n.allowed("shape.replace",{element:e}))return{};var r=eg(e);return mr(t,"bpmn:DataObjectReference")?this._createEntries(e,lg):mr(t,"bpmn:DataStoreReference")&&!mr(e.parent,"bpmn:Collaboration")?this._createEntries(e,ug):mr(t,"bpmn:StartEvent")&&!mr(t.$parent,"bpmn:SubProcess")?(i=g(tg,r),this._createEntries(e,i)):mr(t,"bpmn:Participant")?(i=g(mg,(function(t){return jr(e)!==t.target.isExpanded})),this._createEntries(e,i)):mr(t,"bpmn:StartEvent")&&Lr(t.$parent)?(i=g(dg,(function(e){var n=!1!==e.target.isInterrupting,i=t.isInterrupting===n;return r(e)||!r(e)&&!i})),this._createEntries(e,i)):mr(t,"bpmn:StartEvent")&&!Lr(t.$parent)&&mr(t.$parent,"bpmn:SubProcess")?(i=g(ng,r),this._createEntries(e,i)):mr(t,"bpmn:EndEvent")?(i=g(rg,(function(e){return!("bpmn:CancelEventDefinition"==e.target.eventDefinitionType&&!mr(t.$parent,"bpmn:Transaction"))&&r(e)})),this._createEntries(e,i)):mr(t,"bpmn:BoundaryEvent")?(i=g(hg,(function(e){var n=e.target;if("bpmn:CancelEventDefinition"==n.eventDefinitionType&&!mr(t.attachedToRef,"bpmn:Transaction"))return!1;var i=!1!==n.cancelActivity,o=t.cancelActivity==i;return r(e)||!r(e)&&!o})),this._createEntries(e,i)):mr(t,"bpmn:IntermediateCatchEvent")||mr(t,"bpmn:IntermediateThrowEvent")?(i=g(ig,r),this._createEntries(e,i)):mr(t,"bpmn:Gateway")?(i=g(og,r),this._createEntries(e,i)):mr(t,"bpmn:Transaction")?(i=g(sg,r),this._createEntries(e,i)):Lr(t)&&jr(e)?(i=g(cg,r),this._createEntries(e,i)):mr(t,"bpmn:SubProcess")&&jr(e)?(i=g(ag,r),this._createEntries(e,i)):mr(t,"bpmn:AdHocSubProcess")&&!jr(e)?(i=g(pg,(function(e){var t=e.target,n="bpmn:SubProcess"===t.type,i=!0===t.isExpanded;return eg(t)&&(!n||i)})),this._createEntries(e,i)):mr(t,"bpmn:SequenceFlow")?this._createSequenceFlowEntries(e,fg):mr(t,"bpmn:FlowNode")?(i=g(pg,r),mr(t,"bpmn:SubProcess")&&!jr(e)&&(i=g(i,(function(e){return"Sub-process (collapsed)"!==e.label}))),this._createEntries(e,i)):{}},gg.prototype.getPopupMenuHeaderEntries=function(e){var t={};return mr(e,"bpmn:Activity")&&!Lr(e)&&(t={...t,...this._getLoopCharacteristicsHeaderEntries(e)}),mr(e,"bpmn:DataObjectReference")&&(t={...t,...this._getCollectionHeaderEntries(e)}),mr(e,"bpmn:Participant")&&(t={...t,...this._getParticipantMultiplicityHeaderEntries(e)}),!mr(e,"bpmn:SubProcess")||mr(e,"bpmn:Transaction")||Lr(e)||(t={...t,...this._getAdHocHeaderEntries(e)}),sh(e)&&(t={...t,...this._getNonInterruptingHeaderEntries(e)}),t},gg.prototype._createEntries=function(e,t){var n={},i=this;return v(t,(function(t){n[t.actionName]=i._createEntry(t,e)})),n},gg.prototype._createSequenceFlowEntries=function(e,t){var n=gr(e),i={},r=this._modeling,o=this._moddle,a=this;return v(t,(function(t){switch(t.actionName){case"replace-with-default-flow":n.sourceRef.default!==n&&(mr(n.sourceRef,"bpmn:ExclusiveGateway")||mr(n.sourceRef,"bpmn:InclusiveGateway")||mr(n.sourceRef,"bpmn:ComplexGateway")||mr(n.sourceRef,"bpmn:Activity"))&&(i={...i,[t.actionName]:a._createEntry(t,e,(function(){r.updateProperties(e.source,{default:n})}))});break;case"replace-with-conditional-flow":!n.conditionExpression&&mr(n.sourceRef,"bpmn:Activity")&&(i={...i,[t.actionName]:a._createEntry(t,e,(function(){var t=o.create("bpmn:FormalExpression",{body:""});r.updateProperties(e,{conditionExpression:t})}))});break;default:mr(n.sourceRef,"bpmn:Activity")&&n.conditionExpression&&(i={...i,[t.actionName]:a._createEntry(t,e,(function(){r.updateProperties(e,{conditionExpression:void 0})}))}),(mr(n.sourceRef,"bpmn:ExclusiveGateway")||mr(n.sourceRef,"bpmn:InclusiveGateway")||mr(n.sourceRef,"bpmn:ComplexGateway")||mr(n.sourceRef,"bpmn:Activity"))&&n.sourceRef.default===n&&(i={...i,[t.actionName]:a._createEntry(t,e,(function(){r.updateProperties(e.source,{default:void 0})}))})}})),i},gg.prototype._createEntry=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,action:n}},gg.prototype._getLoopCharacteristicsHeaderEntries=function(e){var t=this,n=this._translate;function i(n,i){if(i.active)t._modeling.updateProperties(e,{loopCharacteristics:void 0});else{var r=e.businessObject.get("loopCharacteristics");r&&mr(r,i.options.loopCharacteristics)?t._modeling.updateModdleProperties(e,r,{isSequential:i.options.isSequential}):(r=t._moddle.create(i.options.loopCharacteristics,{isSequential:i.options.isSequential}),t._modeling.updateProperties(e,{loopCharacteristics:r}))}}var r,o,a,s=gr(e).loopCharacteristics;return s&&(r=s.isSequential,o=void 0===s.isSequential,a=void 0!==s.isSequential&&!s.isSequential),{"toggle-parallel-mi":{className:"bpmn-icon-parallel-mi-marker",title:n("Parallel multi-instance"),active:a,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!1}},"toggle-sequential-mi":{className:"bpmn-icon-sequential-mi-marker",title:n("Sequential multi-instance"),active:r,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!0}},"toggle-loop":{className:"bpmn-icon-loop-marker",title:n("Loop"),active:o,action:i,options:{loopCharacteristics:"bpmn:StandardLoopCharacteristics"}}}},gg.prototype._getCollectionHeaderEntries=function(e){var t=this,n=this._translate,i=e.businessObject.dataObjectRef;if(!i)return{};var r=i.isCollection;return{"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})}}}},gg.prototype._getParticipantMultiplicityHeaderEntries=function(e){var t=this,n=this._bpmnFactory,i=this._translate;var r=e.businessObject.participantMultiplicity;return{"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})}}}},gg.prototype._getAdHocHeaderEntries=function(e){var t=this._translate,n=mr(gr(e),"bpmn:AdHocSubProcess"),i=this._bpmnReplace.replaceElement;return{"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})}}}},gg.prototype._getNonInterruptingHeaderEntries=function(e){const t=this._translate,n=gr(e),i=this,r=ch(e),o=mr(e,"bpmn:BoundaryEvent")?yg["intermediate-event-non-interrupting"]:yg["start-event-non-interrupting"],a=!n[r];return{"toggle-non-interrupting":{imageHtml:o,title:t("Toggle non-interrupting"),active:a,action:function(){i._modeling.updateProperties(e,{[r]:!!a})}}}};var vg={__depends__:[Oc,vf,ip],__init__:["replaceMenuProvider"],replaceMenuProvider:["type",gg]};function _g(e,t,n,i,r,o,a,s,c,p,l,u,h){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,this._eventBus=n,this._appendPreview=h,!1!==e.autoPlace&&(this._autoPlace=t.get("autoPlace",!1)),n.on("create.end",250,(function(e){var t=e.context.shape;if(sa(e)&&i.isOpen(t)){var n=i.getEntries(t);n.replace&&n.replace.action.click(e,t)}})),n.on("contextPad.close",(function(){h.cleanUp()}))}function bg(e,t,n){var i=e.$instanceOf(t),r=!1;return v(e.eventDefinitions||[],(function(e){e.$type===n&&(r=!0)})),i&&r}_g.$inject=["config.contextPad","injector","eventBus","contextPad","modeling","elementFactory","connect","create","popupMenu","canvas","rules","translate","appendPreview"],_g.prototype.getMultiElementContextPadEntries=function(e){var t=this._modeling,n={};return this._isDeleteAllowed(e)&&L(n,{delete:{group:"edit",className:"bpmn-icon-trash",title:this._translate("Delete"),action:{click:function(e,n){t.removeElements(n.slice())}}}}),n},_g.prototype._isDeleteAllowed=function(e){var t=this._rules.allowed("elements.delete",{elements:e});return p(t)?x(e,(e=>t.includes(e))):t},_g.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._autoPlace,c=this._translate,p=this._appendPreview,l={};if("label"===e.type)return this._isDeleteAllowed([e])&&L(l,f()),l;var u=e.businessObject;function h(e,t){r.start(e,t)}function d(e,t){n.removeElements([t])}function f(){return{delete:{group:"edit",className:"bpmn-icon-trash",title:c("Delete"),action:{click:d}}}}function m(e,t,n,r){function a(t,n){var a=i.createShape(L({type:e},r));o.start(t,a,{source:n})}var c=s?function(t,n){var o=i.createShape(L({type:e},r));s.append(n,o)}:a,l=s?function(t,n){return p.create(n,e,r),()=>{p.cleanUp()}}:null;return{group:"model",className:t,title:n,action:{dragstart:a,click:c,hover:l}}}function y(e){return function(i,r){n.splitLane(r,e),t.open(r,!0)}}if(yr(u,["bpmn:Lane","bpmn:Participant"])&&jr(e)){var g=du(e);L(l,{"lane-insert-above":{group:"lane-insert-above",className:"bpmn-icon-lane-insert-above",title:c("Add lane above"),action:{click:function(e,t){n.addLane(t,"top")}}}}),g.length<2&&((Or(e)?e.height>=120:e.width>=120)&&L(l,{"lane-divide-two":{group:"lane-divide",className:"bpmn-icon-lane-divide-two",title:c("Divide into two lanes"),action:{click:y(2)}}}),(Or(e)?e.height>=180:e.width>=180)&&L(l,{"lane-divide-three":{group:"lane-divide",className:"bpmn-icon-lane-divide-three",title:c("Divide into three lanes"),action:{click:y(3)}}})),L(l,{"lane-insert-below":{group:"lane-insert-below",className:"bpmn-icon-lane-insert-below",title:c("Add lane below"),action:{click:function(e,t){n.addLane(t,"bottom")}}}})}return mr(u,"bpmn:FlowNode")&&(mr(u,"bpmn:EventBasedGateway")?L(l,{"append.receive-task":m("bpmn:ReceiveTask","bpmn-icon-receive-task",c("Append receive task")),"append.message-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-message",c("Append message intermediate catch event"),{eventDefinitionType:"bpmn:MessageEventDefinition"}),"append.timer-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-timer",c("Append timer intermediate catch event"),{eventDefinitionType:"bpmn:TimerEventDefinition"}),"append.condition-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-condition",c("Append conditional intermediate catch event"),{eventDefinitionType:"bpmn:ConditionalEventDefinition"}),"append.signal-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-signal",c("Append signal intermediate catch event"),{eventDefinitionType:"bpmn:SignalEventDefinition"})}):bg(u,"bpmn:BoundaryEvent","bpmn:CompensateEventDefinition")?L(l,{"append.compensation-activity":m("bpmn:Task","bpmn-icon-task",c("Append compensation activity"),{isForCompensation:!0})}):mr(u,"bpmn:EndEvent")||u.isForCompensation||bg(u,"bpmn:IntermediateThrowEvent","bpmn:LinkEventDefinition")||Lr(u)||L(l,{"append.end-event":m("bpmn:EndEvent","bpmn-icon-end-event-none",c("Append end event")),"append.gateway":m("bpmn:ExclusiveGateway","bpmn-icon-gateway-none",c("Append gateway")),"append.append-task":m("bpmn:Task","bpmn-icon-task",c("Append task")),"append.intermediate-event":m("bpmn:IntermediateThrowEvent","bpmn-icon-intermediate-event-none",c("Append intermediate/boundary event"))})),a.isEmpty(e,"bpmn-replace")||L(l,{replace:{group:"edit",className:"bpmn-icon-screw-wrench",title:c("Change element"),action:{click:function(e,n){var i=L(function(e){var n=t.getPad(e).html.getBoundingClientRect();return{x:n.left,y:n.bottom+5}}(n),{cursor:{x:e.x,y:e.y}});a.open(n,"bpmn-replace",i,{title:c("Change element"),width:300,search:!0})}}}}),mr(u,"bpmn:SequenceFlow")&&L(l,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation"))}),yr(u,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference"])&&L(l,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation")),connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect to other element"),action:{click:h,dragstart:h}}}),mr(u,"bpmn:TextAnnotation")&&L(l,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect using association"),action:{click:h,dragstart:h}}}),yr(u,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&L(l,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect using data input association"),action:{click:h,dragstart:h}}}),mr(u,"bpmn:Group")&&L(l,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation"))}),this._isDeleteAllowed([e])&&L(l,f()),l};var xg={__depends__:[Uy,Jy,ms,_a,xl,Xd,vg],__init__:["contextPadProvider"],contextPadProvider:["type",_g]},wg={horizontal:["x","width"],vertical:["y","height"]};function Eg(e,t){this._modeling=e,this._filters=[],this.registerFilter((function(e){var n=t.allowed("elements.distribute",{elements:e});return p(n)?n:n?e:[]}))}Eg.$inject=["modeling","rules"],Eg.prototype.registerFilter=function(e){if("function"!=typeof e)throw new Error("the filter has to be a function");this._filters.push(e)},Eg.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},Eg.prototype._filterElements=function(e){var t=this._filters,n=this._axis,i=this._dimension,r=[].concat(e);return t.length?(v(t,(function(e){r=e(r,n,i)})),r):e},Eg.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 v(A(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},Eg.prototype._setOrientation=function(e){var t=wg[e];this._axis=t[0],this._dimension=t[1]},Eg.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)},Eg.prototype._findRange=function(e){var t=e[this._axis];return{min:t+5,max:t+e[this._dimension]-5}};var Sg={__init__:["distributeElements"],distributeElements:["type",Eg]};function Cg(e){zc.call(this,e)}Cg.$inject=["eventBus"],e(Cg,zc),Cg.prototype.init=function(){this.addRule("elements.distribute",(function(e){var t=e.elements;return!((t=st(t=g(t,(function(e){var t=yr(e,["bpmn:Association","bpmn:BoundaryEvent","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:Lane","bpmn:MessageFlow","bpmn:SequenceFlow","bpmn:TextAnnotation"]);return!(e.labelTarget||t)})))).length<3)&&t}))};var kg={horizontal:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <polyline points="450 400 450 150 1350 150 1350 400" style="fill:none;stroke:currentColor;stroke-width:100;stroke-linejoin:round;"/>\n <rect x="150" y="450" width="600" height="1200" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="1050" y="450" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',vertical:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <polyline points="400 1350 150 1350 150 450 400 450" style="fill:none;stroke:currentColor;stroke-width:100;stroke-linejoin:round;"/>\n <rect x="450" y="150" width="1200" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="450" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>'};function Rg(e,t,n,i){this._distributeElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",900,this)}Rg.$inject=["popupMenu","distributeElements","translate","rules"],Rg.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&L(t,this._getEntries(e)),t},Rg.prototype._isAllowed=function(e){return this._rules.allowed("elements.distribute",{elements:e})},Rg.prototype._getEntries=function(e){var t=this._distributeElements,n=this._translate,i=this._popupMenu;return{"distribute-elements-horizontal":{group:"distribute",title:n("Distribute elements horizontally"),className:"bjs-align-elements-menu-entry",imageHtml:kg.horizontal,action:function(n,r){t.trigger(e,"horizontal"),i.close()}},"distribute-elements-vertical":{group:"distribute",title:n("Distribute elements vertically"),imageHtml:kg.vertical,action:function(n,r){t.trigger(e,"vertical"),i.close()}}}};var Pg={__depends__:[Oc,Sg],__init__:["bpmnDistributeElements","distributeElementsMenuProvider"],bpmnDistributeElements:["type",Cg],distributeElementsMenuProvider:["type",Rg]},Ag="is not a registered action";function Mg(e,t){this._actions={};var n=this;e.on("diagram.init",(function(){n._registerDefaultActions(t),e.fire("editorActions.init",{editorActions:n})}))}function Tg(e,t){return new Error(e+" "+t)}Mg.$inject=["eventBus","injector"],Mg.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),l=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();if(e.length)return 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=p(r)?r:e).length&&n.removeElements(t.slice())}})),c&&this.register("moveCanvas",(function(e){c.moveCanvas(e)})),l&&this.register("moveSelection",(function(e){l.moveSelection(e.direction,e.accelerated)}))},Mg.prototype.trigger=function(e,t){if(!this._actions[e])throw Tg(e,Ag);return this._actions[e](t)},Mg.prototype.register=function(e,t){var n=this;if("string"==typeof e)return this._registerAction(e,t);v(e,(function(e,t){n._registerAction(t,e)}))},Mg.prototype._registerAction=function(e,t){if(this.isRegistered(e))throw Tg(e,"is already registered");this._actions[e]=t},Mg.prototype.unregister=function(e){if(!this.isRegistered(e))throw Tg(e,Ag);this._actions[e]=void 0},Mg.prototype.getActions=function(){return Object.keys(this._actions)},Mg.prototype.isRegistered=function(e){return!!this._actions[e]};var Bg={__init__:["editorActions"],editorActions:["type",Mg]};function Dg(e){e.invoke(Mg,this)}e(Dg,Mg),Dg.$inject=["injector"],Dg.prototype._registerDefaultActions=function(e){Mg.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),d=e.get("contextPad",!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!mr(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=ht(i=mr(r,"bpmn:Collaboration")?n.filter((function(e){return mr(e.parent,"bpmn:Collaboration")})):n.filter((function(e){return e!==r&&!mr(e.parent,"bpmn:SubProcess")}))),h.moveElements(i,{x:-e.x,y:-e.y},r)})),i&&d&&this._registerAction("replaceElement",(function(e){d.triggerEntry("replace","click",e)}))};var Ng={__depends__:[Bg],editorActions:["type",Dg]};function jg(e){e.on(["create.init","shape.move.init"],(function(e){var t=e.context;yr(e.shape,["bpmn:Participant","bpmn:SubProcess","bpmn:TextAnnotation"])&&(t.gridSnappingContext||(t.gridSnappingContext={}),t.gridSnappingContext.snapLocation="top-left")}))}jg.$inject=["eventBus"];function Og(e,t,n){return n||(n="round"),Math[n](e/t)*t}function Lg(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&&Ca(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&&u(s[t]))return s[t];s||(s=o.snapOffset={});u(s[t])||(s[t]=0);if(!r)return s[t];n.get(r.id)||($g(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&&($g(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&&($g(t)?Fg(s)?a.x.max=c.left:a.x.min=c.right:Ig(s)?a.y.max=c.top:a.y.min=c.bottom);p&&($g(t)?Fg(s)?a.x.min=p.left:a.x.max=p.right:Ig(s)?a.y.min=p.top:a.y.max=p.bottom);return a[t]}(t,n);a&&L(i,a),pl(t,n)||r.snapEvent(t,n,i)}))}}))}function $g(e){return"x"===e}function Ig(e){return-1!==e.indexOf("n")}function Fg(e){return-1!==e.indexOf("w")}function zg(e,t){To.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;d(i)?t.newBounds=n.snapComplex(o,i):t.newBounds=n.snapSimple(r,o)}}))}Lg.prototype.snapEvent=function(e,t,n){ll(e,t,this.snapValue(e[t],n))},Lg.prototype.getGridSpacing=function(){return 10},Lg.prototype.snapValue=function(e,t){var n,i,r=0;return t&&t.offset&&(r=t.offset),e=Og(e+=r,10),t&&t.min&&u(n=t.min)&&(n=Og(n+r,10,"ceil"),e=Math.max(e,n)),t&&t.max&&u(i=t.max)&&(i=Og(i+r,10,"floor"),e=Math.min(e,i)),e-=r},Lg.prototype.isActive=function(){return this.active},Lg.prototype.setActive=function(e){this.active=e,this._eventBus.fire("gridSnapping.toggle",{active:e})},Lg.prototype.toggleActive=function(){this.setActive(!this.active)},Lg.$inject=["elementRegistry","eventBus","config.gridSnapping"],zg.$inject=["eventBus","gridSnapping","modeling"],e(zg,To),zg.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},zg.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},zg.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),L(e,o),e},zg.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),L(e,o),e};function Hg(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))}))}Hg.$inject=["eventBus","gridSnapping"];var Vg={__depends__:[{__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",zg],gridSnappingSpaceToolBehavior:["type",Hg]}],__init__:["gridSnapping"],gridSnapping:["type",Lg]};function Gg(e,t,n){e.on("autoPlace",2e3,(function(e){var i=e.source,r=dn(i),o=e.shape,a=ep(i,o,n);return["x","y"].forEach((function(e){var n={};a[e]!==r[e]&&(a[e]>r[e]?n.min=a[e]:n.max=a[e],mr(o,"bpmn:TextAnnotation")&&(!function(e){return"x"===e}(e)?n.offset=-o.height/2:n.offset=-o.width/2),a[e]=t.snapValue(a[e],n))})),a}))}Gg.$inject=["eventBus","gridSnapping","elementRegistry"];function Wg(e,t,n){t.on(["create.start","shape.move.start"],1750,(function(t){var i=t.context,r=i.shape,o=e.getRootElement();mr(r,"bpmn:Participant")&&mr(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})))}))}Wg.$inject=["canvas","eventBus","gridSnapping"];function Ug(e,t,n){To.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 qg(e,t,n){var i=Et(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=L({},t,r),n=L({},n,r)),[t,n]}Ug.$inject=["eventBus","gridSnapping","modeling"],e(Ug,To),Ug.prototype.snapMiddleSegments=function(e){var t,n=this._gridSnapping;e=e.slice();for(var i=1;i<e.length-2;i++)t=qg(n,e[i],e[i+1]),e[i]=t[0],e[i+1]=t[1];return e};var Kg={__depends__:[Vg,{__init__:["gridSnappingAutoPlaceBehavior","gridSnappingParticipantBehavior","gridSnappingLayoutConnectionBehavior"],gridSnappingAutoPlaceBehavior:["type",Gg],gridSnappingParticipantBehavior:["type",Wg],gridSnappingLayoutConnectionBehavior:["type",Ug]}],__init__:["bpmnGridSnapping"],bpmnGridSnapping:["type",jg]};function Yg(e,t){this._interactionEvents=t;var n=this;e.on(["interactionEvents.createHit","interactionEvents.updateHit"],(function(e){var t=e.element,i=e.gfx;return mr(t,"bpmn:Lane")?n._createParticipantHit(t,i):mr(t,"bpmn:Participant")?jr(t)?n._createParticipantHit(t,i):n._createDefaultHit(t,i):mr(t,"bpmn:SubProcess")?jr(t)?n._createSubProcessHit(t,i):n._createDefaultHit(t,i):void 0}))}Yg.$inject=["eventBus","interactionEvents"],Yg.prototype._createDefaultHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createDefaultHit(e,t),!0},Yg.prototype._createParticipantHit=function(e,t){this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"no-move",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height});var n=Or(e)?{width:30,height:e.height}:{width:e.width,height:30};return this._interactionEvents.createBoxHit(t,"all",n),!0},Yg.prototype._createSubProcessHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"no-move",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"all",{width:e.width,height:30}),!0};var Xg={__init__:["bpmnInteractionEvents"],bpmnInteractionEvents:["type",Yg]};function Zg(e){e.invoke(Ta,this)}e(Zg,Ta),Zg.$inject=["injector"],Zg.prototype.registerBindings=function(e,t){function n(n,i){t.isRegistered(n)&&e.addListener(i)}Ta.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})),n("replaceElement",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["r","R"],i)?(t.trigger("replaceElement",i),!0):void 0}))};var Qg={__depends__:[Ba],__init__:["keyboardBindings"],keyboardBindings:["type",Zg]},Jg={moveSpeed:1,moveSpeedAccelerated:10},ev="left",tv="right",nv="down",iv={ArrowLeft:ev,Left:ev,ArrowUp:"up",Up:"up",ArrowRight:tv,Right:tv,ArrowDown:nv,Down:nv},rv={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 ov(e,t,n,i,r){var o=this;this._config=L({},Jg,e||{}),t.addListener(1500,(function(e){var n=e.keyEvent,i=iv[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=rv[e](a);i.allowed("elements.move",{shapes:o})&&n.moveElements(o,s)}}}ov.$inject=["config.keyboardMoveSelection","keyboard","modeling","rules","selection"];var av={__depends__:[Ba,_a],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",ov]};function sv(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=ln(e);return un({top:ou("top",n,t),right:ou("right",n,t),bottom:ou("bottom",n,t),left:ou("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:ln(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=cn(r)))return;n.resizeShape(t,r)}}(e.context)}))}function cv(e,t){var n=dn(e),i=ln(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 pv(e){var t="resize-";return"n"===e||"s"===e?t+"ns":"e"===e||"w"===e?t+"ew":"nw"===e||"se"===e?t+"nwse":t+"nesw"}sv.prototype.canResize=function(e){var t=this._rules,n=$(e,["newBounds","shape","delta","direction"]);return t.allowed("shape.resize",n)},sv.prototype.activate=function(e,t,n){var i,r,o=this._dragging;if("string"==typeof n&&(n={direction:n}),!(r=(i=L({shape:t},n)).direction))throw new Error("must provide a direction (n|w|s|e|nw|se|ne|sw)");o.init(e,cv(t,r),"resize",{autoActivate:!0,cursor:pv(r),data:{shape:t,context:i}})},sv.prototype.computeMinResizeBox=function(e){var t=e.shape;return function(e,t,n,i){var r=ln(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?ln(i):o;return un({top:iu(o.top,a.top),left:iu(o.left,a.left),bottom:nu(o.bottom,a.bottom),right:nu(o.right,a.right)})}(e.direction,t,e.minDimensions||{width:10,height:10},cu(t,e.childrenBoxPadding))},sv.$inject=["eventBus","rules","modeling","dragging"];var lv="djs-resizing",uv="resize-not-ok";function hv(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,lv)),o.width>5&&be(a,{x:o.x,width:o.width}),o.height>5&&be(a,{y:o.y,height:o.height}),i.canExecute?we(a).remove(uv):we(a).add(uv)})),e.on("resize.cleanup",(function(e){var n,i;n=e.context,i=n.shape,n.frame&&Fe(n.frame),t.removeMarker(i,lv)}))}hv.$inject=["eventBus","canvas","previewSupport"];var dv=-6,fv="djs-resizer",mv=["n","w","s","e","nw","ne","se","sw"];function yv(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&&v(t,O(r.addResizer,r))})),e.on("shape.changed",(function(e){var t=e.element;n.isSelected(t)&&(r.removeResizers(),r.addResizer(t))}))}yv.prototype.makeDraggable=function(e,t,n){var i=this._resize;function r(t){aa(t)&&i.activate(t,e,n)}oe.bind(t,"mousedown",r),oe.bind(t,"touchstart",r)},yv.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=dv);-1!==e.indexOf("s")?t.y=6:-1!==e.indexOf("n")&&(t.y=dv);return t}(i),a=Ae("g");we(a).add(fv),we(a).add(fv+"-"+e.id),we(a).add(fv+"-"+i),ge(r,a);var s=Ae("rect");be(s,{x:-4+o.x,y:-4+o.y,width:8,height:8}),we(s).add(fv+"-visual"),ge(a,s);var c=Ae("rect");return be(c,{x:-10+o.x,y:-10+o.y,width:20,height:20}),we(c).add(fv+"-hit"),ge(a,c),Vn(a,t,n),a},yv.prototype.createResizer=function(e,t){var n=cv(e,t),i=this._createResizer(e,n.x,n.y,t);this.makeDraggable(e,i,t)},yv.prototype.addResizer=function(e){var t=this;!an(e)&&this._resize.canResize({shape:e})&&v(mv,(function(n){t.createResizer(e,n)}))},yv.prototype.removeResizers=function(){Se(this._getResizersParent())},yv.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")},yv.$inject=["eventBus","canvas","selection","resize"];var gv={__depends__:[bp,mp,Pl],__init__:["resize","resizePreview","resizeHandles"],resize:["type",sv],resizePreview:["type",hv],resizeHandles:["type",yv]};function vv(e,t,n,i,r,o,a){function s(e,t){(t||yr(e,["bpmn:Task","bpmn:TextAnnotation","bpmn:Participant"])||_v(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","root.set","selection.changed"],(function(){i.isActive()&&i.complete()})),e.on(["shape.remove","connection.remove"],2e3,(function(e){i.isActive(e.element)&&i.cancel()})),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 _v(e){return mr(e,"bpmn:SubProcess")&&!jr(e)}vv.$inject=["eventBus","bpmnFactory","canvas","directEditing","modeling","resizeHandles","textRenderer"],vv.prototype.activate=function(e){var t=Wr(e);if(void 0!==t){var n={text:t};L(n,this.getEditingBBox(e));var i={},r=n.style||{};return L(r,{backgroundColor:null,border:null}),(yr(e,["bpmn:Task","bpmn:Participant","bpmn:Lane","bpmn:CallActivity"])||_v(e))&&L(i,{centerVertically:!0}),Fr(e)&&(L(i,{autoResize:!0}),L(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),mr(e,"bpmn:TextAnnotation")&&(L(i,{resizable:!0,autoResize:!0}),L(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),L(n,{options:i,style:r}),n}},vv.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};if(mr(e,"bpmn:Lane")||function(e){return mr(e,"bpmn:Participant")&&jr(e)}(e)){var m=Or(e);L(a,m?{width:i.height,height:30*s,x:i.x-i.height/2+15*s,y:o-30*s/2}:{width:i.width,height:30*s}),L(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px",transform:m?"rotate(-90deg)":null})}if(function(e){return mr(e,"bpmn:Participant")&&!jr(e)}(e)){var y=Or(e);L(a,y?{width:i.width,height:i.height}:{width:i.height,height:i.width,x:r-i.height/2,y:o-i.width/2}),L(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px",transform:y?null:"rotate(-90deg)"})}(yr(e,["bpmn:Task","bpmn:CallActivity"])||_v(e))&&(L(a,{width:i.width,height:i.height}),L(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 mr(e,"bpmn:SubProcess")&&jr(e)}(e)&&(L(a,{width:i.width,x:i.x}),L(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px"}));var g=90*s,v=7*s,_=4*s;if(n.labelTarget&&(L(a,{width:g,height:i.height+v+_,x:r-g/2,y:i.y-v}),L(f,{fontSize:l+"px",lineHeight:u,paddingTop:v+"px",paddingBottom:_+"px"})),Fr(n)&&!zr(n)&&!sn(n)){var b=Vr(e),x=t.getAbsoluteBBox({x:b.x,y:b.y,width:0,height:0}),w=l+v+_;L(a,{width:g,height:w,x:x.x-g/2,y:x.y-w/2}),L(f,{fontSize:l+"px",lineHeight:u,paddingTop:v+"px",paddingBottom:_+"px"})}return mr(e,"bpmn:TextAnnotation")&&(L(a,{width:i.width,height:i.height,minWidth:30*s,minHeight:10*s}),L(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}},vv.prototype.update=function(e,t,n,i){var r,o,a;mr(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}),(a=t)&&a.trim()||(t=null),this._modeling.updateLabel(e,t,r)};var bv="djs-element-hidden",xv="djs-label-hidden";function wv(e,t,n){var i,r,o,a=this,s=t.getDefaultLayer();e.on("directEditing.activate",(function(e){var c=e.active;if(mr(i=c.element.label||c.element,"bpmn:TextAnnotation")){r=t.getAbsoluteBBox(i),o=Ae("g");var p=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:i.width,containerHeight:i.height,position:{mx:0,my:0}}),l=a.path=Ae("path");be(l,{d:p,strokeWidth:2,stroke:Ev(i)}),ge(o,l),ge(s,o),Gn(o,i.x,i.y)}mr(i,"bpmn:TextAnnotation")||i.labelTarget?t.addMarker(i,bv):(mr(i,"bpmn:Task")||mr(i,"bpmn:CallActivity")||mr(i,"bpmn:SubProcess")||mr(i,"bpmn:Participant")||mr(i,"bpmn:Lane"))&&t.addMarker(i,xv)})),e.on("directEditing.resize",(function(e){if(mr(i,"bpmn:TextAnnotation")){var t=e.height,o=e.dy,s=Math.max(i.height/r.height*(t+o),0),c=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:i.width,containerHeight:s,position:{mx:0,my:0}});be(a.path,{d:c})}})),e.on(["directEditing.complete","directEditing.cancel"],(function(e){var n=e.active;n&&(t.removeMarker(n.element.label||n.element,bv),t.removeMarker(i,xv)),i=void 0,r=void 0,o&&(Fe(o),o=void 0)}))}function Ev(e,t){return vr(e).get("stroke")||t||"black"}wv.$inject=["eventBus","canvas","pathMap"];var Sv={__depends__:[Mo,gv,Jy],__init__:["labelEditingProvider","labelEditingPreview"],labelEditingProvider:["type",vv],labelEditingPreview:["type",wv]},Cv=new wo("tt");function kv(e,t){e.style.display=!1===t?"none":""}var Rv="djs-tooltip",Pv="."+Rv;function Av(e,t){var n,i;this._eventBus=e,this._canvas=t,this._ids=Cv,this._tooltipDefaults={show:{minZoom:.7,maxZoom:5}},this._tooltips={},this._tooltipRoot=(n=t.getContainer(),q(i=he('<div class="djs-tooltip-container" />'),{position:"absolute",width:"0",height:"0"}),n.insertBefore(i,n.firstChild),i);var r=this;ce.bind(this._tooltipRoot,Pv,"mousedown",(function(e){e.stopPropagation()})),ce.bind(this._tooltipRoot,Pv,"mouseover",(function(e){r.trigger("mouseover",e)})),ce.bind(this._tooltipRoot,Pv,"mouseout",(function(e){r.trigger("mouseout",e)})),this._init()}Av.$inject=["eventBus","canvas"],Av.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=L({},this._tooltipDefaults,e,{id:t}),this._addTooltip(e),e.timeout&&this.setTimeout(e),t},Av.prototype.trigger=function(e,t){var n=t.delegateTarget||t.target,i=this.get(K(n,"data-tooltip-id"));i&&("mouseover"===e&&i.timeout&&this.clearTimeout(i),"mouseout"===e&&i.timeout&&(i.timeout=1e3,this.setTimeout(i)))},Av.prototype.get=function(e){return"string"!=typeof e&&(e=e.id),this._tooltips[e]},Av.prototype.clearTimeout=function(e){if(e=this.get(e)){var t=e.removeTimer;t&&(clearTimeout(t),e.removeTimer=null)}},Av.prototype.setTimeout=function(e){if(e=this.get(e)){this.clearTimeout(e);var t=this;e.removeTimer=setTimeout((function(){t.remove(e)}),e.timeout)}},Av.prototype.remove=function(e){var t=this.get(e);t&&(ye(t.html),ye(t.htmlContainer),delete t.htmlContainer,delete this._tooltips[t.id])},Av.prototype.show=function(){kv(this._tooltipRoot)},Av.prototype.hide=function(){kv(this._tooltipRoot,!1)},Av.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},Av.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)),d(i)&&(i=he(i)),q(t=he('<div data-tooltip-id="'+n+'" class="'+Rv+'">'),{position:"absolute"}),t.appendChild(i),e.type&&X(t).add("djs-tooltip-"+e.type),e.className&&X(t).add(e.className),e.htmlContainer=t,r.appendChild(t),this._tooltips[n]=e,this._updateTooltip(e)},Av.prototype._updateTooltip=function(e){var t=e.position;!function(e,t,n){q(e,{left:t+"px",top:n+"px"})}(e.htmlContainer,t.x,t.y)},Av.prototype._updateTooltipVisibilty=function(e){v(this._tooltips,(function(t){var n=t.show,i=t.htmlContainer,r=!0;n&&((n.minZoom>e.scale||n.maxZoom<e.scale)&&(r=!1),kv(i,r))}))},Av.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 Mv={__init__:["tooltips"],tooltips:["type",Av]};function Tv(e,t,n){e.on(["shape.move.rejected","create.rejected"],(function(e){var i,r,o=e.context,a=o.shape;mr(o.target,"bpmn:Collaboration")&&mr(a,"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:2e3,html:"<div>"+r+"</div>"}))}))}Tv.$inject=["eventBus","tooltips","translate"];var Bv={__depends__:[Mv],__init__:["modelingFeedback"],modelingFeedback:["type",Tv]};function Dv(e,t){this._eventBus=e,this.offset=5;var n=t.cls("djs-outline",["no-fill"]),i=this;function r(e){var t=Ae("rect");return be(t,L({x:0,y:0,rx:4,width:100,height:100},n)),t}e.on(["shape.added","shape.changed"],500,(function(e){var t=e.element,n=e.gfx,o=fe(".djs-outline",n);o||ge(n,o=i.getOutline(t)||r()),i.updateShapeOutline(o,t)})),e.on(["connection.added","connection.changed"],(function(e){var t=e.element,n=e.gfx,o=fe(".djs-outline",n);o||ge(n,o=r()),i.updateConnectionOutline(o,t)}))}Dv.prototype.updateShapeOutline=function(e,t){var n=!1,i=this._getProviders();i.length&&v(i,(function(i){n=n||i.updateOutline(t,e)})),n||be(e,{x:-this.offset,y:-this.offset,width:t.width+2*this.offset,height:t.height+2*this.offset})},Dv.prototype.updateConnectionOutline=function(e,t){var n=ht(t);be(e,{x:n.x-this.offset,y:n.y-this.offset,width:n.width+2*this.offset,height:n.height+2*this.offset})},Dv.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("outline.getProviders",e,(function(e){e.providers.push(t)}))},Dv.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"outline.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},Dv.prototype.getOutline=function(e){var t;return v(this._getProviders(),(function(n){h(n.getOutline)&&(t=t||n.getOutline(e))})),t},Dv.$inject=["eventBus","styles","elementRegistry"];function Nv(e,t,n){this._canvas=t;var i=this;e.on("element.changed",(function(e){n.isSelected(e.element)&&i._updateMultiSelectionOutline(n.get())})),e.on("selection.changed",(function(e){var t=e.newSelection;i._updateMultiSelectionOutline(t)}))}Nv.prototype._updateMultiSelectionOutline=function(e){var t=this._canvas.getLayer("selectionOutline");Se(t);var n=e.length>1;if(we(this._canvas.getContainer())[n?"add":"remove"]("djs-multi-select"),n){var i=function(e){return{x:e.x-6,y:e.y-6,width:e.width+12,height:e.height+12}}(ht(e)),r=Ae("rect");be(r,L({rx:3},i)),we(r).add("djs-selection-outline"),ge(t,r)}},Nv.$inject=["eventBus","canvas","selection"];var jv={__depends__:[_a],__init__:["outline","multiSelectionOutline"],outline:["type",Dv],multiSelectionOutline:["type",Nv]},Ov=Math.round;function Lv(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(l(i)&&(r=i,i=!1),!n.waypoints&&n.parent&&!we(e.target).has("djs-hit-no-move")){var o=function(e){return{x:e.x+Ov(e.width/2),y:e.y+Ov(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]),r=function(e){var t=k(e,"id");return g(e,(function(e){for(;e=e.parent;)if(t[e.id])return!1;return!0}))}(r),L(t,{shapes: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=Ov(i.x),i.y=Ov(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(aa(e)){var t=ta(e);if(!t)throw new Error("must supply DOM mousedown event");return a(t,e.element)}})),this.start=a}Lv.$inject=["eventBus","dragging","modeling","selection","rules"];var $v="djs-dragging",Iv="drop-ok",Fv="drop-not-ok",zv="new-parent",Hv="attach-ok";function Vv(e,t,n,r){function o(e){var t=function(e){var t=g(e,(function(t){return!an(t)||m(e,M({id:t.source.id}))&&m(e,M({id:t.target.id}))}));return t}(a(e));return t}function a(e){var t=ut(e,!0),n=t.flatMap((e=>(e.incoming||[]).concat(e.outgoing||[]))),i=t.concat(n);return[...new Set(i)]}function s(e,n){[Hv,Iv,Fv,zv].forEach((function(i){i===n?t.addMarker(e,i):t.removeMarker(e,i)}))}e.on("shape.move.start",499,(function(e){var s,c=e.context,p=c.shapes,l=c.allDraggedElements,u=o(p);if(!c.dragGroup){var h=Ae("g");be(h,n.cls("djs-drag-group",["no-events"])),ge(t.getActiveLayer(),h),c.dragGroup=h}u.forEach((function(e){r.addDragger(e,c.dragGroup)})),v(l=l?i([l,a(p)]):a(p),(function(e){t.addMarker(e,$v)})),c.allDraggedElements=l,c.differentParents=1!==(s=k(p,(function(e){return e.parent&&e.parent.id})),S(s).length)})),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&&r&&i.id!==r.id?s(i,zv):s(i,t.canExecute?Iv:Fv)),Gn(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;v(i,(function(e){t.removeMarker(e,$v)})),r&&Fe(r)})),this.makeDraggable=function(e,n,i){r.addDragger(n,e.dragGroup),i&&t.addMarker(n,$v),e.allDraggedElements?e.allDraggedElements.push(n):e.allDraggedElements=[n]}}Vv.$inject=["eventBus","canvas","styles","previewSupport"];var Gv={__depends__:[ha,_a,jv,bp,mp,Pl],__init__:["move","movePreview"],move:["type",Lv],movePreview:["type",Vv]},Wv=".djs-palette-toggle",Uv=".entry",qv=Wv+", "+Uv,Kv="djs-palette-",Yv="open",Xv="two-column";function Zv(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 Qv(e,t){var n=t.getPaletteEntries();return h(n)?n(e):(v(n,(function(t,n){e[n]=t})),e)}Zv.$inject=["eventBus","canvas"],Zv.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("palette.getProviders",e,(function(e){e.providers.push(t)})),this._rebuild()},Zv.prototype.getEntries=function(){return this._getProviders().reduce(Qv,{})},Zv.prototype._rebuild=function(){this._diagramInitialized&&(this._getProviders().length&&(this._container||this._init(),this._update()))},Zv.prototype._init=function(){var e=this,t=this._eventBus,n=this._getParentContainer(),i=this._container=he(Zv.HTML_MARKUP);n.appendChild(i),X(n).add(Kv+"shown"),ce.bind(i,qv,"click",(function(t){if(de(t.delegateTarget,Wv))return e.toggle();e.trigger("click",t)})),oe.bind(i,"mousedown",(function(e){e.stopPropagation()})),ce.bind(i,Uv,"dragstart",(function(t){e.trigger("dragstart",t)})),t.on("canvas.resized",this._layoutChanged,this),t.fire("palette.create",{container:i})},Zv.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(t),t.providers},Zv.prototype._toggleState=function(e){e=e||{};var t,n=this._getParentContainer(),i=this._container,r=this._eventBus,o=X(i),a=X(n);t="twoColumn"in e?e.twoColumn:this._needsCollapse(n.clientHeight,this._entries||{}),o.toggle(Xv,t),a.toggle(Kv+Xv,t),"open"in e&&(o.toggle(Yv,e.open),a.toggle(Kv+Yv,e.open)),r.fire("palette.changed",{twoColumn:t,open:this.isOpen()})},Zv.prototype._update=function(){var e=fe(".djs-palette-entries",this._container),t=this._entries=this.getEntries();Q(e),v(t,(function(t,n){var i=t.group||"default",r=fe("[data-group="+jo(i)+"]",e);r||(K(r=he('<div class="group"></div>'),"data-group",i),e.appendChild(r));var o=t.html||(t.separator?'<hr class="separator" />':'<div class="entry" draggable="true"></div>'),a=he(o);if(r.appendChild(a),!t.separator&&(K(a,"data-action",n),t.title&&K(a,"title",t.title),t.className&&function(e,t){var n=X(e);(p(t)?t:t.split(/\s+/g)).forEach((function(e){n.add(e)}))}(a,t.className),t.imageUrl)){var s=he("<img>");K(s,"src",t.imageUrl),a.appendChild(s)}})),this.open()},Zv.prototype.trigger=function(e,t,n){var i,r,o=t.delegateTarget||t.target;return o?(i=K(o,"data-action"),r=t.originalEvent||t,this.triggerEntry(i,e,r,n)):t.preventDefault()},Zv.prototype.triggerEntry=function(e,t,n,i){var r,o;if((r=this._entries[e])&&(o=r.action,!1!==this._eventBus.fire("palette.trigger",{entry:r,event:n}))){if(h(o)){if("click"===t)return o(n,i)}else if(o[t])return o[t](n,i);n.preventDefault()}},Zv.prototype._layoutChanged=function(){this._toggleState({})},Zv.prototype._needsCollapse=function(e,t){return e<46*Object.keys(t).length+50},Zv.prototype.close=function(){this._toggleState({open:!1,twoColumn:!1})},Zv.prototype.open=function(){this._toggleState({open:!0})},Zv.prototype.toggle=function(){this.isOpen()?this.close():this.open()},Zv.prototype.isActiveTool=function(e){return e&&this._activeTool===e},Zv.prototype.updateToolHighlight=function(e){var t;this._toolsContainer||(t=fe(".djs-palette-entries",this._container),this._toolsContainer=fe("[data-group=tools]",t)),v(this._toolsContainer.children,(function(t){var n=t.getAttribute("data-action");if(n){var i=X(t);n=n.replace("-tool",""),i.contains("entry")&&n===e?i.add("highlighted-entry"):i.remove("highlighted-entry")}}))},Zv.prototype.isOpen=function(){return X(this._container).has(Yv)},Zv.prototype._getParentContainer=function(){return this._canvas.getContainer()},Zv.HTML_MARKUP='<div class="djs-palette"><div class="djs-palette-entries"></div><div class="djs-palette-toggle"></div></div>';var Jv={__init__:["palette"],palette:["type",Zv]},e_="crosshair";function t_(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();be(n=e.frame=Ae("rect"),{class:"djs-lasso-overlay",width:1,height:1,x:0,y:0}),ge(i,n)},p=function(e){var t=e.frame,n=e.bbox;be(t,{x:n.x,y:n.y,width:n.width,height:n.height})},l=function(e){e.frame&&Fe(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",0,(function(e){var t=e.context,n=n_(e),r=i.filter((function(e){return e})),o=ca(e);s.select(r,n,o?t.selection:[])})),e.on("lasso.start",(function(e){var t=e.context;t.bbox=n_(e),c(t),t.selection=r.get()})),e.on("lasso.move",(function(e){var t=e.context;t.bbox=n_(e),p(t)})),e.on("lasso.cleanup",(function(e){var t=e.context;l(t)})),e.on("element.mousedown",1500,(function(e){if(ca(e))return s.activateLasso(e.originalEvent),!0}))}function n_(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}}t_.$inject=["eventBus","canvas","dragging","elementRegistry","selection","toolManager","mouse"],t_.prototype.activateLasso=function(e,t){this._dragging.init(e,"lasso",{autoActivate:t,cursor:e_,data:{context:{}}})},t_.prototype.activateSelection=function(e,t){this._dragging.init(e,"lasso.selection",{trapClick:!1,autoActivate:t,cursor:e_,data:{context:{}},keepSelection:!0})},t_.prototype.select=function(e,t,n=[]){var i=function(e,t){var n={};return v(e,(function(e){var i=e;i.waypoints&&(i=ht(i)),!u(t.y)&&i.x>t.x&&(n[e.id]=e),!u(t.x)&&i.y>t.y&&(n[e.id]=e),i.x>t.x&&i.y>t.y&&(u(t.width)&&u(t.height)&&i.width+i.x<t.width+t.x&&i.height+i.y<t.height+t.y?n[e.id]=e:u(t.width)&&u(t.height)||(n[e.id]=e))})),n}(e,t);this._selection.select([...n,...C(i)])},t_.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},t_.prototype.isActive=function(){var e=this._dragging.context();return e&&/^lasso/.test(e.prefix)};var i_={__depends__:[bf,Qd],__init__:["lassoTool"],lassoTool:["type",t_]},r_=1500,o_="grab";function a_(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",r_,(function(e){if(sa(e))return a.activateMove(e.originalEvent,!0),!1})),s&&s.addListener(r_,(function(e){if(s_(e.keyEvent)&&!a.isActive()){var t=a._mouse.getLastMoveEvent();a.activateMove(t,!!t)}}),"keyboard.keydown"),s&&s.addListener(r_,(function(e){s_(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!sa(t)&&n&&e.once("hand.move.ended",(function(e){a.activateHand(e.originalEvent,!0,!0)})),!1}))}function s_(e){return ka("Space",e)}a_.$inject=["eventBus","canvas","dragging","injector","toolManager","mouse"],a_.prototype.activateMove=function(e,t,n){"object"==typeof t&&(n=t,t=!1),this._dragging.init(e,"hand.move",{autoActivate:t,cursor:o_,data:{context:n||{}}})},a_.prototype.activateHand=function(e,t,n){this._dragging.init(e,"hand",{trapClick:!1,autoActivate:t,cursor:o_,data:{context:{reactivate:n}}})},a_.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateHand(e,!!e)},a_.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^(hand|hand\.move)$/.test(e.prefix)};var c_={__depends__:[bf,Qd],__init__:["handTool"],handTool:["type",a_]},p_="connect-ok",l_="connect-not-ok";function u_(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?p_:l_))})),e.on(["global-connect.out","global-connect.cleanup"],(function(e){var t=e.context.startTarget,n=e.context.canStartConnect;t&&i.removeMarker(t,n?p_:l_)})),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}))}u_.$inject=["eventBus","dragging","connect","canvas","toolManager","rules","mouse"],u_.prototype.start=function(e,t){this._dragging.init(e,"global-connect",{autoActivate:t,trapClick:!1,data:{context:{}}})},u_.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();return this.start(e,!!e)},u_.prototype.isActive=function(){var e=this._dragging.context();return e&&/^global-connect/.test(e.prefix)},u_.prototype.canStartConnect=function(e){return this._rules.allowed("connection.start",{source:e})};var h_={__depends__:[xl,bp,mp,bf,Qd],globalConnect:["type",u_]};function d_(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)}d_.$inject=["palette","create","elementFactory","spaceTool","lassoTool","handTool","globalConnect","translate"],d_.prototype.getPaletteEntries=function(){var e={},t=this._create,n=this._elementFactory,i=this._spaceTool,r=this._lassoTool,o=this._handTool,a=this._globalConnect,s=this._translate;function c(e,i,r,o,a){function s(i){var r=n.createShape(L({type:e},a));t.start(i,r)}return{group:i,className:r,title:o,action:{dragstart:s,click:s}}}function p(e){var i=n.createShape({type:"bpmn:SubProcess",x:0,y:0,isExpanded:!0}),r=n.createShape({type:"bpmn:StartEvent",x:40,y:82,parent:i});t.start(e,[i,r],{hints:{autoSelect:[i]}})}function l(e){t.start(e,n.createParticipantShape())}return L(e,{"hand-tool":{group:"tools",className:"bpmn-icon-hand-tool",title:s("Activate hand tool"),action:{click:function(e){o.activateHand(e)}}},"lasso-tool":{group:"tools",className:"bpmn-icon-lasso-tool",title:s("Activate lasso tool"),action:{click:function(e){r.activateSelection(e)}}},"space-tool":{group:"tools",className:"bpmn-icon-space-tool",title:s("Activate create/remove space tool"),action:{click:function(e){i.activateSelection(e)}}},"global-connect-tool":{group:"tools",className:"bpmn-icon-connection-multi",title:s("Activate global connect tool"),action:{click:function(e){a.start(e)}}},"tool-separator":{group:"tools",separator:!0},"create.start-event":c("bpmn:StartEvent","event","bpmn-icon-start-event-none",s("Create start event")),"create.intermediate-event":c("bpmn:IntermediateThrowEvent","event","bpmn-icon-intermediate-event-none",s("Create intermediate/boundary event")),"create.end-event":c("bpmn:EndEvent","event","bpmn-icon-end-event-none",s("Create end event")),"create.exclusive-gateway":c("bpmn:ExclusiveGateway","gateway","bpmn-icon-gateway-none",s("Create gateway")),"create.task":c("bpmn:Task","activity","bpmn-icon-task",s("Create task")),"create.data-object":c("bpmn:DataObjectReference","data-object","bpmn-icon-data-object",s("Create data object reference")),"create.data-store":c("bpmn:DataStoreReference","data-store","bpmn-icon-data-store",s("Create data store reference")),"create.subprocess-expanded":{group:"activity",className:"bpmn-icon-subprocess-expanded",title:s("Create expanded sub-process"),action:{dragstart:p,click:p}},"create.participant-expanded":{group:"collaboration",className:"bpmn-icon-participant",title:s("Create pool/participant"),action:{dragstart:l,click:l}},"create.group":c("bpmn:Group","artifact","bpmn-icon-group",s("Create group"))}),e};var f_={__depends__:[Jv,Xd,$f,i_,c_,h_,yo],__init__:["paletteProvider"],paletteProvider:["type",d_]};function m_(e,t,n,i,r){To.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){v(e.canExecute.replacements,(function(o){var a=o.oldElementId,s={type:o.newElementType};if(!e.visualReplacements[a]){var c=t.get(a);L(s,{x:c.x,y:c.y});var p=n.createShape(s);i.addShape(p,c.parent);var l=fe('[data-element-id="'+jo(c.id)+'"]',e.dragGroup);l&&be(l,{display:"none"});var u=r.addDragger(p,e.dragGroup);e.visualReplacements[a]=u,i.removeShape(p)}}))}(o):function(e){var t=e.visualReplacements;v(t,(function(n,i){var r=fe('[data-element-id="'+jo(i)+'"]',e.dragGroup);r&&be(r,{display:"inline"}),n.remove(),t[i]&&delete t[i]}))}(o)}))}m_.$inject=["eventBus","elementRegistry","elementFactory","canvas","previewSupport"],e(m_,To);var y_={__depends__:[Pl],__init__:["bpmnReplacePreview"],bpmnReplacePreview:["type",m_]},g_=40,v_=["x","y"],__=Math.abs;function b_(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&&Ca(e.originalEvent)||(t.initialConnectionStart||(t.initialConnectionStart=t.connectionStart),n&&r&&function(e,t,n){v_.forEach((function(i){var r=E_(i,t);e[i]<t[i]+n?ll(e,i,t[i]+n):e[i]>t[i]+r-n&&ll(e,i,t[i]+r-n)}))}(e,r,function(e){return mr(e,"bpmn:Task")?10:20}(r)),r&&function(e,t){return w(t,(function(t){return w_(e,t)}))}(n,["bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:SequenceFlow"])?(t.connectionStart=cl(i),yr(r,["bpmn:Event","bpmn:Gateway"])&&x_(e,cl(r)),yr(r,["bpmn:Task","bpmn:SubProcess"])&&function(e,t){var n=cl(t);v_.forEach((function(i){(function(e,t,n){return e[n]>t[n]+20&&e[n]<t[n]+E_(n,t)-20})(e,t,i)&&ll(e,i,n[i])}))}(e,r),mr(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=cl(n),o=fn(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];__(i-r[t])<g_&&(n=i>r[t]?r[t]+g_:r[t]-g_,ll(e,t,n))}))}(e)):w_(n,"bpmn:MessageFlow")?(mr(i,"bpmn:Event")&&(t.connectionStart=cl(i)),mr(r,"bpmn:Event")&&x_(e,cl(r))):t.connectionStart=t.initialConnectionStart)}))}function x_(e,t){ll(e,"x",t.x),ll(e,"y",t.y)}function w_(e,t){return e&&e.type===t}function E_(e,t){return"x"===e?t.width:t.height}function S_(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}function C_(){this._snapValues={}}b_.$inject=["eventBus"],S_.prototype.getSnapOrigin=function(e){return this._snapOrigins[e]},S_.prototype.setSnapOrigin=function(e,t){this._snapOrigins[e]=t,-1===this._snapLocations.indexOf(e)&&this._snapLocations.push(e)},S_.prototype.addDefaultSnap=function(e,t){var n=this._defaultSnaps[e];n||(n=this._defaultSnaps[e]=[]),n.push(t)},S_.prototype.getSnapLocations=function(){return this._snapLocations},S_.prototype.setSnapLocations=function(e){this._snapLocations=e},S_.prototype.pointsForTarget=function(e){var t=e.id||e,n=this._targets[t];return n||(n=this._targets[t]=new C_).initDefaults(this._defaultSnaps),n},C_.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)},C_.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],rl(r-e)<=n)return r}(e[n],r[n],i)},C_.prototype.initDefaults=function(e){var t=this;v(e||{},(function(e,n){v(e,(function(e){t.add(n,e)}))}))};function k_(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||!Ca(e.originalEvent))&&!pl(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()}))}k_.$inject=["elementRegistry","eventBus","snapping"],k_.prototype.initSnap=function(e){var t,n=this._elementRegistry,i=e.context,r=i.shape,o=i.snapContext;o||(o=i.snapContext=new S_);var a=(t=n.get(r.id)?cl(r,e):{x:e.x+cl(r).x,y:e.y+cl(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}),sn(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},k_.prototype.addSnapTargetPoints=function(e,t,n){return v(this.getSnapTargets(t,n),(function(n){if(sn(n))sn(t)&&e.add("mid",cl(n));else if(an(n)){if(n.waypoints.length<3)return;v(n.waypoints.slice(1,-1),(function(t){e.add("mid",t)}))}else e.add("mid",cl(n))})),u(t.x)&&u(t.y)?(this._elementRegistry.get(t.id)&&e.add("mid",cl(t)),e):e},k_.prototype.getSnapTargets=function(e,t){return ul(t).filter((function(e){return!e.hidden}))};function R_(e,t){t.invoke(k_,this),e.on(["create.move","create.end"],1500,P_),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)&&!pl(e)&&function(e,t){var n,i=ln(t),r=ed(e,t),o=e.context,a=o.shape;n=a.parent?{x:0,y:0}:dn(a);/top/.test(r)?ll(e,"y",i.top-n.y):/bottom/.test(r)&&ll(e,"y",i.bottom-n.y);/left/.test(r)?ll(e,"x",i.left-n.x):/right/.test(r)&&ll(e,"x",i.right-n.x)}(e,i)}))}function P_(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)&&ll(e,"x",e.x),(n&&n>=e.y||r&&r<=e.y)&&ll(e,"y",e.y)}}function A_(e,t){return-1!==e.indexOf(t)}function M_(e,t,n){return t?{x:e.x-n.x,y:e.y-n.y}:{x:e.x,y:e.y}}e(R_,k_),R_.$inject=["eventBus","injector"],R_.prototype.initSnap=function(e){var t=k_.prototype.initSnap.call(this,e),n=e.shape,i=!!this._elementRegistry.get(n.id);return v(n.outgoing,(function(n){var r=n.waypoints[0];r=r.original||r,t.setSnapOrigin(n.id+"-docking",M_(r,i,e))})),v(n.incoming,(function(n){var r=n.waypoints[n.waypoints.length-1];r=r.original||r,t.setSnapOrigin(n.id+"-docking",M_(r,i,e))})),mr(n,"bpmn:Participant")&&t.setSnapLocations(["top-left","bottom-right","mid"]),t},R_.prototype.addSnapTargetPoints=function(e,t,n){k_.prototype.addSnapTargetPoints.call(this,e,t,n);var i=this.getSnapTargets(t,n);v(i,(function(n){var i;(function(e){if(mr(e,"bpmn:SubProcess")&&jr(e))return!0;return mr(e,"bpmn:Participant")}(n)||(i="bpmn:TextAnnotation",[t,n].every((function(e){return mr(e,i)}))))&&(e.add("top-left",al(n)),e.add("bottom-right",sl(n)))}));var r=this._elementRegistry;return v(t.incoming,(function(n){if(r.get(t.id)){A_(i,n.source)||e.add("mid",dn(n.source));var o=n.waypoints[0];e.add(n.id+"-docking",o.original||o)}})),v(t.outgoing,(function(n){if(r.get(t.id)){A_(i,n.target)||e.add("mid",dn(n.target));var o=n.waypoints[n.waypoints.length-1];e.add(n.id+"-docking",o.original||o)}})),mr(n,"bpmn:SequenceFlow")&&(e=this.addSnapTargetPoints(e,t,n.parent)),e},R_.prototype.getSnapTargets=function(e,t){return k_.prototype.getSnapTargets.call(this,e,t).filter((function(e){return!mr(e,"bpmn:Lane")}))};function T_(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&&Ca(e.originalEvent)||pl(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)&&ll(e,"x",e.x),function(e){return"e"===e||"w"===e}(a)&&ll(e,"y",e.y),t.snap(e,c)}})),e.on(["resize.cleanup"],(function(){t.hide()}))}function B_(e,t){var n=dn(e),i=ln(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}T_.prototype.initSnap=function(e){var t=e.context,n=t.shape,i=t.direction,r=t.snapContext;r||(r=t.snapContext=new S_);var o=B_(n,i);return r.setSnapOrigin("corner",{x:o.x-e.x,y:o.y-e.y}),r},T_.prototype.addSnapTargetPoints=function(e,t,n,i){return v(this.getSnapTargets(t,n),(function(t){e.add("corner",sl(t)),e.add("corner",al(t))})),e.add("corner",B_(t,i)),e},T_.$inject=["eventBus","snapping"],T_.prototype.getSnapTargets=function(e,t){return ul(t).filter((function(t){return!(n=t,i=e,n.host===i||an(t)||function(e){return!!e.hidden}(t)||sn(t));var n,i}))};function D_(e){this._canvas=e,this._asyncHide=j(O(this.hide,this),1e3)}D_.$inject=["canvas"],D_.prototype.snap=function(e,t){var n=e.context.snapContext,i=n.getSnapLocations(),r={x:pl(e,"x"),y:pl(e,"y")};v(i,(function(i){var o=n.getSnapOrigin(i),a={x:e.x+o.x,y:e.y+o.y};if(v(["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),v(["x","y"],(function(t){var n=r[t];l(n)&&ll(e,t,n.originValue)}))},D_.prototype._createLine=function(e){var t=this._canvas.getLayer("snap"),n=Ae("path");return be(n,{d:"M0,0 L0,0"}),we(n).add("djs-snap-line"),ge(t,n),{update:function(t){u(t)?be(n,"horizontal"===e?{d:"M-100000,"+t+" L+100000,"+t,display:""}:{d:"M "+t+",-100000 L "+t+", +100000",display:""}):be(n,{display:"none"})}}},D_.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}},D_.prototype.showSnapLine=function(e,t){var n=this.getSnapLine(e);n&&n.update(t),this._asyncHide()},D_.prototype.getSnapLine=function(e){return this._snapLines||this._createSnapLines(),this._snapLines[e]},D_.prototype.hide=function(){v(this._snapLines,(function(e){e.update()}))};var N_={__depends__:[{__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",k_],resizeSnapping:["type",T_],snapping:["type",D_]}],__init__:["connectSnapping","createMoveSnapping"],connectSnapping:["type",b_],createMoveSnapping:["type",R_]};function j_(e,t,n,i){this._open=!1,this._results={},this._eventMaps=[],this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._canvas=e,this._eventBus=t,this._selection=n,this._translate=i,this._container=this._getBoxHtml(),this._searchInput=fe(j_.INPUT_SELECTOR,this._container),this._resultsContainer=fe(j_.RESULTS_CONTAINER_SELECTOR,this._container),this._canvas.getContainer().appendChild(this._container),t.on(["canvas.destroy","diagram.destroy","drag.init","elements.changed"],this.close,this)}function O_(e,t,n){var i=function(e){var t="";return e.forEach((function(e){var n=Lo(e.value||e.matched||e.normal),i=e.match||e.matched;t+=i?'<b class="'+j_.RESULT_HIGHLIGHT_CLASS+'">'+n+"</b>":n})),""!==t?t:null}(t),r=he(n);r.innerHTML=i,e.appendChild(r)}j_.$inject=["canvas","eventBus","selection","translate"],j_.prototype._bindEvents=function(){var e=this;function t(t,n,i,r){e._eventMaps.push({el:t,type:i,listener:ce.bind(t,n,i,r)})}t(document,"html","click",(function(t){e.close(!1)})),t(this._container,j_.INPUT_SELECTOR,"click",(function(e){e.stopPropagation(),e.delegateTarget.focus()})),t(this._container,j_.RESULT_SELECTOR,"mouseover",(function(t){t.stopPropagation(),e._scrollToNode(t.delegateTarget),e._preselect(t.delegateTarget)})),t(this._container,j_.RESULT_SELECTOR,"click",(function(t){t.stopPropagation(),e._select(t.delegateTarget)})),t(this._container,j_.INPUT_SELECTOR,"keydown",(function(e){ka("ArrowUp",e)&&e.preventDefault(),ka("ArrowDown",e)&&e.preventDefault()})),t(this._container,j_.INPUT_SELECTOR,"keyup",(function(t){if(ka("Escape",t))return e.close();if(ka("Enter",t)){var n=e._getCurrentResult();return n?e._select(n):e.close(!1)}return ka("ArrowUp",t)?e._scrollToDirection(!0):ka("ArrowDown",t)?e._scrollToDirection():void(ka(["ArrowLeft","ArrowRight"],t)||e._search(t.delegateTarget.value))}))},j_.prototype._unbindEvents=function(){this._eventMaps.forEach((function(e){ce.unbind(e.el,e.type,e.listener)}))},j_.prototype._search=function(e){var t=this;if(this._clearResults(),e&&""!==e){var n=this._searchProvider.find(e);if(!(n=n.filter((function(e){return!t._canvas.getRootElements().includes(e.element)}))).length)return this._clearMarkers(),void this._selection.select(null);n.forEach((function(e){var n=e.element.id,i=t._createResultNode(e,n);t._results[n]={element:e.element,node:i}}));var i=fe(j_.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}},j_.prototype._scrollToDirection=function(e){var t=this._getCurrentResult();if(t){var n=e?t.previousElementSibling:t.nextElementSibling;n&&(this._scrollToNode(n),this._preselect(n))}},j_.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)}},j_.prototype._clearResults=function(){Q(this._resultsContainer),this._results={},this._eventBus.fire("searchPad.cleared")},j_.prototype._clearMarkers=function(){for(var e in this._results)this._canvas.removeMarker(this._results[e].element,"djs-search-preselected")},j_.prototype._getCurrentResult=function(){return fe(j_.RESULT_SELECTED_SELECTOR,this._resultsContainer)},j_.prototype._createResultNode=function(e,t){var n=he(j_.RESULT_HTML);return e.primaryTokens.length>0&&O_(n,e.primaryTokens,j_.RESULT_PRIMARY_HTML),O_(n,e.secondaryTokens,j_.RESULT_SECONDARY_HTML),K(n,j_.RESULT_ID_ATTRIBUTE,t),this._resultsContainer.appendChild(n),n},j_.prototype.registerProvider=function(e){this._searchProvider=e},j_.prototype.open=function(){if(!this._searchProvider)throw new Error("no search provider registered");this.isOpen()||(this._cachedRootElement=this._canvas.getRootElement(),this._cachedSelection=this._selection.get(),this._cachedViewbox=this._canvas.viewbox(),this._bindEvents(),this._open=!0,X(this._canvas.getContainer()).add("djs-search-open"),X(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))},j_.prototype.close=function(e=!0){this.isOpen()&&(e&&(this._cachedRootElement&&this._canvas.setRootElement(this._cachedRootElement),this._cachedSelection&&this._selection.select(this._cachedSelection),this._cachedViewbox&&this._canvas.viewbox(this._cachedViewbox),this._eventBus.fire("searchPad.restored")),this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._unbindEvents(),this._open=!1,X(this._canvas.getContainer()).remove("djs-search-open"),X(this._container).remove("open"),this._clearMarkers(),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._eventBus.fire("searchPad.closed"),this._canvas.restoreFocus())},j_.prototype.toggle=function(){this.isOpen()?this.close():this.open()},j_.prototype.isOpen=function(){return this._open},j_.prototype._preselect=function(e){var t=this._getCurrentResult();if(e!==t){this._clearMarkers(),t&&X(t).remove(j_.RESULT_SELECTED_CLASS);var n=K(e,j_.RESULT_ID_ATTRIBUTE),i=this._results[n].element;X(e).add(j_.RESULT_SELECTED_CLASS),this._canvas.scrollToElement(i,{top:300}),this._selection.select(i),this._canvas.addMarker(i,"djs-search-preselected"),this._eventBus.fire("searchPad.preselected",i)}},j_.prototype._select=function(e){var t=K(e,j_.RESULT_ID_ATTRIBUTE),n=this._results[t].element;this._cachedSelection=null,this._cachedViewbox=null,this.close(!1),this._canvas.scrollToElement(n,{top:300}),this._selection.select(n),this._eventBus.fire("searchPad.selected",n)},j_.prototype._getBoxHtml=function(){const e=he(j_.BOX_HTML),t=fe(j_.INPUT_SELECTOR,e);return t&&t.setAttribute("aria-label",this._translate("Search in diagram")),e},j_.CONTAINER_SELECTOR=".djs-search-container",j_.INPUT_SELECTOR=".djs-search-input input",j_.RESULTS_CONTAINER_SELECTOR=".djs-search-results",j_.RESULT_SELECTOR=".djs-search-result",j_.RESULT_SELECTED_CLASS="djs-search-result-selected",j_.RESULT_SELECTED_SELECTOR="."+j_.RESULT_SELECTED_CLASS,j_.RESULT_ID_ATTRIBUTE="data-result-id",j_.RESULT_HIGHLIGHT_CLASS="djs-search-highlight",j_.BOX_HTML='<div class="djs-search-container djs-scrollable">\n <div class="djs-search-input">\n <svg class="djs-search-icon" width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M9.0325 8.5H9.625L13.3675 12.25L12.25 13.3675L8.5 9.625V9.0325L8.2975 8.8225C7.4425 9.5575 6.3325 10 5.125 10C2.4325 10 0.25 7.8175 0.25 5.125C0.25 2.4325 2.4325 0.25 5.125 0.25C7.8175 0.25 10 2.4325 10 5.125C10 6.3325 9.5575 7.4425 8.8225 8.2975L9.0325 8.5ZM1.75 5.125C1.75 6.9925 3.2575 8.5 5.125 8.5C6.9925 8.5 8.5 6.9925 8.5 5.125C8.5 3.2575 6.9925 1.75 5.125 1.75C3.2575 1.75 1.75 3.2575 1.75 5.125Z" fill="#22242A"/>\n </svg>\n <input type="text" spellcheck="false" />\n </div>\n <div class="djs-search-results" />\n</div>',j_.RESULT_HTML='<div class="djs-search-result"></div>',j_.RESULT_PRIMARY_HTML='<div class="djs-search-result-primary"></div>',j_.RESULT_SECONDARY_HTML='<p class="djs-search-result-secondary"></p>';var L_={__depends__:[yo,Po,_a],searchPad:["type",j_]};function $_(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._search=i,t.registerProvider(this)}function I_(e){const{item:{element:t},tokens:n}=e;return{element:t,primaryTokens:n.label,secondaryTokens:n.id}}$_.$inject=["elementRegistry","searchPad","canvas","search"],$_.prototype.find=function(e){var t=this._canvas.getRootElements(),n=this._elementRegistry.filter((function(e){return!sn(e)&&!t.includes(e)}));return this._search(n.map((e=>({element:e,label:Wr(e),id:e.id}))),e,{keys:["label","id"]}).map(I_)};var F_={__depends__:[L_,jc],__init__:["bpmnSearch"],bpmnSearch:["type",$_]};const z_={width:36,height:50},H_={width:50,height:50};function V_(e,t,n){return Ae("path",{d:e,strokeWidth:2,transform:`translate(${t.x}, ${t.y})`,...n})}function G_(e,t){this._styles=t,e.registerProvider(this)}function W_(e,t){var n;return"bpmn:DataObjectReference"===t?n=z_:"bpmn:DataStoreReference"===t&&(n=H_),e.width===n.width&&e.height===n.height}G_.$inject=["outline","styles"],G_.prototype.getOutline=function(e){const t=this._styles.cls("djs-outline",["no-fill"]);var n;if(!sn(e))return mr(e,"bpmn:Gateway")?(L((n=Ae("rect")).style,{"transform-box":"fill-box",transform:"rotate(45deg)","transform-origin":"center"}),be(n,L({x:2,y:2,rx:4,width:e.width-4,height:e.height-4},t))):yr(e,["bpmn:Task","bpmn:SubProcess","bpmn:Group","bpmn:CallActivity"])?be(n=Ae("rect"),L({x:-5,y:-5,rx:14,width:e.width+10,height:e.height+10},t)):mr(e,"bpmn:EndEvent")?be(n=Ae("circle"),L({cx:e.width/2,cy:e.height/2,r:e.width/2+5+1},t)):mr(e,"bpmn:Event")?be(n=Ae("circle"),L({cx:e.width/2,cy:e.height/2,r:e.width/2+5},t)):mr(e,"bpmn:DataObjectReference")&&W_(e,"bpmn:DataObjectReference")?n=V_("M44.7648 11.3263L36.9892 2.64074C36.0451 1.58628 34.5651 0.988708 33.1904 0.988708H5.98667C3.22688 0.988708 0.989624 3.34892 0.989624 6.26039V55.0235C0.989624 57.9349 3.22688 60.2952 5.98667 60.2952H40.966C43.7257 60.2952 45.963 57.9349 45.963 55.0235V14.9459C45.963 13.5998 45.6407 12.3048 44.7648 11.3263Z",{x:-6,y:-6},t):mr(e,"bpmn:DataStoreReference")&&W_(e,"bpmn:DataStoreReference")&&(n=V_("M1.03845 48.1347C1.03845 49.3511 1.07295 50.758 1.38342 52.064C1.69949 53.3938 2.32428 54.7154 3.56383 55.6428C6.02533 57.4841 10.1161 58.7685 14.8212 59.6067C19.5772 60.4538 25.1388 60.8738 30.6831 60.8738C36.2276 60.8738 41.7891 60.4538 46.545 59.6067C51.2504 58.7687 55.3412 57.4842 57.8028 55.6429C59.0424 54.7156 59.6673 53.3938 59.9834 52.064C60.2938 50.7579 60.3285 49.351 60.3285 48.1344V13.8415C60.3285 12.6249 60.2938 11.218 59.9834 9.91171C59.6673 8.58194 59.0423 7.2602 57.8027 6.33294C55.341 4.49168 51.2503 3.20723 46.545 2.36914C41.7891 1.522 36.2276 1.10204 30.6831 1.10205C25.1388 1.10206 19.5772 1.52206 14.8213 2.36923C10.1162 3.20734 6.02543 4.49183 3.5639 6.33314C2.32433 7.26038 1.69951 8.58206 1.38343 9.91181C1.07295 11.2179 1.03845 12.6247 1.03845 13.8411V48.1347Z",{x:-6,y:-6},t)),n},G_.prototype.updateOutline=function(e,t){if(!sn(e))return yr(e,["bpmn:SubProcess","bpmn:Group"])?(be(t,{width:e.width+10,height:e.height+10}),!0):!!yr(e,["bpmn:Event","bpmn:Gateway","bpmn:DataStoreReference","bpmn:DataObjectReference"])};var U_={__depends__:[jv],__init__:["outlineProvider"],outlineProvider:["type",G_]};function q_(e){Nr.call(this,e)}return e(q_,Nr),q_.Viewer=ba,q_.NavigatedViewer=Xa,q_.prototype.createDiagram=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>')},q_.prototype._interactionModules=[ja,Va,Ya],q_.prototype._modelingModules=[Vc,ip,vp,cp,ml,xl,El,xg,pf,Xd,Pg,Ng,Kg,Xg,Qg,av,Sv,Vy,Bv,Gv,f_,y_,gv,N_,F_,U_],q_.prototype._modules=[].concat(ba.prototype._modules,q_.prototype._interactionModules,q_.prototype._modelingModules),q_}));
197
+ `,this._current.container)},Mc.prototype.open=function(e,t,n,i){if(!e)throw new Error("target is missing");if(!t)throw new Error("providers for <"+t+"> not found");if(!n)throw new Error("position is missing");this.isOpen()&&this.close();const{entries:r,headerEntries:o,emptyPlaceholder:a}=this._getContext(e,t);this._current={position:n,providerId:t,target:e,entries:r,headerEntries:o,emptyPlaceholder:a,container:this._createContainer({provider:t}),options:i},this._emit("open"),this._bindAutoClose(),this._render()},Mc.prototype.refresh=function(){if(!this.isOpen())return;const{target:e,providerId:t}=this._current,{entries:n,headerEntries:i,emptyPlaceholder:r}=this._getContext(e,t);this._current={...this._current,entries:n,headerEntries:i,emptyPlaceholder:r},this._emit("refresh"),this._render()},Mc.prototype._getContext=function(e,t){const n=this._getProviders(t);if(!n||!n.length)throw new Error("provider for <"+t+"> not found");const i=this._getEntries(e,n),r=this._getHeaderEntries(e,n);return{entries:i,headerEntries:r,emptyPlaceholder:this._getEmptyPlaceholder(n),empty:!(Object.keys(i).length||Object.keys(r).length)}},Mc.prototype.close=function(){this.isOpen()&&(this._emit("close"),this.reset(),this._canvas.restoreFocus(),this._current=null)},Mc.prototype.reset=function(){const e=this._current.container;Gs(null,e),ye(e)},Mc.prototype._emit=function(e,t){this._eventBus.fire(`popupMenu.${e}`,t)},Mc.prototype._onOpened=function(){this._emit("opened")},Mc.prototype._onClosed=function(){this._emit("closed")},Mc.prototype._createContainer=function(e){var t=this._canvas.getContainer();const n=he(`<div class="djs-popup-parent djs-scrollable" data-popup=${e.provider}></div>`);return t.appendChild(n),n},Mc.prototype._bindAutoClose=function(){this._eventBus.once(Ac,this.close,this)},Mc.prototype._unbindAutoClose=function(){this._eventBus.off(Ac,this.close,this)},Mc.prototype._updateScale=function(){var e,t,n=this._canvas.zoom(),i=this._config.scale,r=n;return!0!==i&&(!1===i?(e=1,t=1):(e=i.min,t=i.max),s(e)&&n<e&&(r=e),s(t)&&n>t&&(r=t)),r},Mc.prototype._ensureVisible=function(e,t){var n=document.documentElement.getBoundingClientRect(),i=e.getBoundingClientRect(),r={},o=t.x,a=t.y;return t.x+i.width>n.width&&(r.x=!0),t.y+i.height>n.height&&(r.y=!0),r.x&&r.y?(o=t.x-i.width,a=t.y-i.height):r.x?(o=t.x-i.width,a=t.y):r.y&&t.y<i.height?(o=t.x,a=10):r.y&&(o=t.x,a=t.y-i.height),t.y<n.top&&(a=t.y+i.height),{x:o,y:a}},Mc.prototype.isEmpty=function(e,t){if(!e)throw new Error("target is missing");if(!t)throw new Error("provider ID is missing");const n=this._getProviders(t);return!n||!n.length||this._getContext(e,t).empty},Mc.prototype.registerProvider=function(e,t,n){n||(n=t,t=1e3),this._eventBus.on("popupMenu.getProviders."+e,t,(function(e){e.providers.push(n)}))},Mc.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"popupMenu.getProviders."+e,providers:[]});return this._eventBus.fire(t),t.providers},Mc.prototype._getEntries=function(e,t){var n={};return v(t,(function(t){if(t.getPopupMenuEntries){var i=t.getPopupMenuEntries(e);h(i)?n=i(n):v(i,(function(e,t){n[t]=e}))}else v(t.getEntries(e),(function(e){var t=e.id;if(!t)throw new Error("entry ID is missing");n[t]=I(e,["id"])}))})),n},Mc.prototype._getHeaderEntries=function(e,t){var n={};return v(t,(function(t){if(t.getPopupMenuHeaderEntries){var i=t.getPopupMenuHeaderEntries(e);h(i)?n=i(n):v(i,(function(e,t){n[t]=e}))}else{if(!t.getHeaderEntries)return;v(t.getHeaderEntries(e),(function(e){var t=e.id;if(!t)throw new Error("entry ID is missing");n[t]=I(e,["id"])}))}})),n},Mc.prototype._getEmptyPlaceholder=function(e){const t=e.find((e=>h(e.getEmptyPlaceholder)));return t&&t.getEmptyPlaceholder()},Mc.prototype.isOpen=function(){return!!this._current},Mc.prototype.trigger=function(e,t,n="click"){if(e.preventDefault(),!t){let n=K(J(e.delegateTarget||e.target,".entry",!0),"data-id");t={id:n,...this._getEntry(n)}}const i=t.action;if(!1!==this._emit("trigger",{entry:t,event:e}))if(h(i)){if("click"===n)return i(e,t)}else if(i[n])return i[n](e,t)},Mc.prototype._getEntry=function(e){var t=this._current.entries[e]||this._current.headerEntries[e];if(!t)throw new Error("entry not found");return t};var jc={search:["value",function(e,t,n){const{keys:i}=n,r=t.trim().toLowerCase().split(/\s+/);return e.flatMap((e=>{const t=function(e,t,n){const{matchedWords:i,tokens:r}=n.reduce(((n,i)=>{const r=e[i],{tokens:o,matchedWords:a}=function(e,t){if(!e)return{tokens:[],matchedWords:{}};const n=[],i={},r=t.map(Nc).flatMap((e=>["(?<wordStart>\\b"+e+")",e])).join("|"),o=new RegExp(r,"ig");let a,s=0;for(;a=o.exec(e);){const[t]=a;a.index>s&&n.push({value:e.slice(s,a.index),index:s}),n.push({value:t,index:a.index,match:!0,wordStart:!!a.groups.wordStart,start:0===a.index}),i[t.toLowerCase()]=!0,s=a.index+t.length}s<e.length&&n.push({value:e.slice(s),index:s});return{tokens:n,matchedWords:i}}(r,t);return{tokens:{...n.tokens,[i]:o},matchedWords:{...n.matchedWords,...a}}}),{matchedWords:{},tokens:{}});if(Object.keys(i).length!==t.length)return null;return r}(e,r,i);return t?{item:e,tokens:t}:[]})).sort(function(e){return(t,n)=>{for(const i of e){const e=Tc(t.tokens[i],n.tokens[i]);if(0!==e)return e;const r=Dc(t.item[i],n.item[i]);if(0!==r)return r}return 0}}(i))}]},Oc={__depends__:[jc],__init__:["popupMenu"],popupMenu:["type",Mc]},Lc={align:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2000 2000">\n <line x1="200" y1="150" x2="200" y2="1850" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="500" y="150" width="1300" height="700" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="500" y="1150" width="700" height="700" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',bottom:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="150" y1="1650" x2="1650" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="150" y="350" width="600" height="1300" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="1050" y="850" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',center:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="900" y1="150" x2="900" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="250" y="150" width="1300" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="500" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',left:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="100" y1="150" x2="100" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="100" y="150" width="1300" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="100" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',right:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="1650" y1="150" x2="1650" y2="1650" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="350" y="150" width="1300" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="850" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',top:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="150" y1="150" x2="1650" y2="150" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="150" y="150" width="600" height="1300" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="1050" y="150" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',middle:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <line x1="150" y1="900" x2="1650" y2="900" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>\n <rect x="150" y="250" width="600" height="1300" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="1050" y="500" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>'};function $c(e,t,n,i){e.registerProvider(900,this),this._contextPad=e,this._popupMenu=t,this._translate=n,this._canvas=i}$c.$inject=["contextPad","popupMenu","translate","canvas"],$c.prototype.getMultiElementContextPadEntries=function(e){var t={};return this._isAllowed(e)&&L(t,this._getEntries(e)),t},$c.prototype._isAllowed=function(e){return!this._popupMenu.isEmpty(e,"align-elements")},$c.prototype._getEntries=function(){var e=this;return{"align-elements":{group:"align-elements",title:e._translate("Align elements"),html:`<div class="entry">${Lc.align}</div>`,action:{click:function(t,n){var i=e._getMenuPosition(n);L(i,{cursor:{x:t.x,y:t.y}}),e._popupMenu.open(n,"align-elements",i)}}}}},$c.prototype._getMenuPosition=function(e){var t=this._contextPad.getPad(e).html.getBoundingClientRect();return{x:t.left,y:t.bottom+5}};var Ic=["left","center","right","top","middle","bottom"];function Fc(e,t,n,i){this._alignElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",this)}function zc(e){To.call(this,e),this.init()}function Hc(e){zc.call(this,e)}Fc.$inject=["popupMenu","alignElements","translate","rules"],Fc.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&L(t,this._getEntries(e)),t},Fc.prototype._isAllowed=function(e){return this._rules.allowed("elements.align",{elements:e})},Fc.prototype._getEntries=function(e){var t=this._alignElements,n=this._translate,i=this._popupMenu,r={};return v(Ic,(function(o){r["align-elements-"+o]={group:"align",title:n("Align elements "+o),className:"bjs-align-elements-menu-entry",imageHtml:Lc[o],action:function(){t.trigger(e,o),i.close()}}})),r},zc.$inject=["eventBus"],e(zc,To),zc.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)}))},zc.prototype.init=function(){},Hc.$inject=["eventBus"],e(Hc,zc),Hc.prototype.init=function(){this.addRule("elements.align",(function(e){var t=g(e.elements,(function(e){return!(e.waypoints||e.host||e.labelTarget)}));return!((t=st(t)).length<2)&&t}))};var Vc={__depends__:[ns,ms,Oc],__init__:["alignElementsContextPadProvider","alignElementsMenuProvider","bpmnAlignElements"],alignElementsContextPadProvider:["type",$c],alignElementsMenuProvider:["type",Fc],bpmnAlignElements:["type",Hc]};function Gc(e,t,n,i){for(var r;r=Uc(e,n,t);)n=i(t,n,r);return n}function Wc(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 Uc(e,t,n){var i={x:t.x-n.width/2,y:t.y-n.height/2,width:n.width,height:n.height},r=function(e){var t=qc(e);e.host&&(t=t.concat(qc(e.host)));e.attachers&&(t=t.concat(e.attachers.reduce((function(e,t){return e.concat(qc(t))}),[])));return t}(e);return m(r,(function(e){return e!==n&&"intersect"===fn(e,i,10)}))}function qc(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 Kc(){return!0}function Yc(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=dn(e),o=ln(e);return{x:o.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 Xc(e,t){e.on("autoPlace.end",500,(function(e){t.select(e.shape)}))}Yc.$inject=["eventBus","modeling","canvas"],Xc.$inject=["eventBus","selection"];var Zc={__init__:["autoPlaceSelectionBehavior"],autoPlace:["type",Yc],autoPlaceSelectionBehavior:["type",Xc]};function Qc(e,t){for(d(t)&&(t=[t]);e=e.parent;)if(yr(e,t))return e;return null}function Jc(e,t){var n=Qc(e,"bpmn:Process");if(n)return!0;var i,r=["bpmn:Participant","bpmn:Lane"];if(n=Qc(e,r))return Or(n);if(yr(e,r))return Or(e);for(i=gr(e);i&&!mr(i,"bpmn:Process");i=i.$parent);if(!t)return!0;var o=t.find((function(e){var t=gr(e);return t&&t.get("processRef")===i}));return!o||Or(o)}function ep(e,t,n){var i=Jc(e,n);return mr(t,"bpmn:TextAnnotation")?function(e,t,n){var i=ln(e),r=n?{x:i.right+t.width/2,y:i.top-50-t.height/2}:{x:i.right+50+t.width/2,y:i.bottom+t.height/2};an(e)&&(r=dn(e),n?(r.x+=100,r.y-=50):(r.x+=100,r.y+=50));var o={margin:n?-30:30,minDistance:20},a=n?{y:o}:{x:o};return Gc(e,t,r,Wc(a))}(e,t,i):yr(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])?function(e,t,n){var i=ln(e),r=n?{x:i.right-10+t.width/2,y:i.bottom+40+t.width/2}:{x:i.left-40-t.width/2,y:i.bottom-10+t.height/2},o={margin:30,minDistance:30},a=n?{x:o}:{y:o};return Gc(e,t,r,Wc(a))}(e,t,i):mr(t,"bpmn:FlowNode")?function(e,t,n){var i=ln(e),r=dn(e),o=n?{directionHint:"e",minDistance:80,baseOrientation:"left",boundaryOrientation:"top",start:"top",end:"bottom"}:{directionHint:"s",minDistance:90,baseOrientation:"top",boundaryOrientation:"left",start:"left",end:"right"},a=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?ln(e).top-ln(t).bottom:"center"===s?ln(e).top-dn(t).y:ln(e).top-ln(t).top:"w"===i?"start"===s?ln(e).left-ln(t).right:"center"===s?ln(e).left-dn(t).x:ln(e).left-ln(t).left:"s"===i?"start"===s?ln(t).top-ln(e).bottom:"center"===s?dn(t).y-ln(e).bottom:ln(t).bottom-ln(e).bottom:"start"===s?ln(t).left-ln(e).right:"center"===s?dn(t).x-ln(e).right:ln(t).right-ln(e).right}r||(r=Kc);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}})),u=b(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}),{});return u.distance||n}(e,{filter:function(e){return mr(e,"bpmn:SequenceFlow")},direction:o.directionHint}),s=30,c=o.minDistance,p=o.baseOrientation;mr(e,"bpmn:BoundaryEvent")&&-1!==(p=fn(e,e.host,-25)).indexOf(o.boundaryOrientation)&&(s*=-1);var l=n?{x:i.right+a+t.width/2,y:r.y+tp(p,c,o)}:{x:r.x+tp(p,c,o),y:i.bottom+a+t.height/2},u={margin:s,minDistance:c},h=n?{y:u}:{x:u};return Gc(e,t,l,Wc(h))}(e,t,i):void 0}function tp(e,t,n){return e.includes(n.start)?-1*t:e.includes(n.end)?t:0}function np(e,t){e.on("autoPlace",(function(e){var n=e.shape;return ep(e.source,n,t)}))}np.$inject=["eventBus","elementRegistry"];var ip={__depends__:[Zc],__init__:["bpmnAutoPlace"],bpmnAutoPlace:["type",np]};function rp(e,t,n,r){To.call(this,e),this._elementRegistry=t,this._modeling=n,this._rules=r;var o=this;this.postExecuted(["shape.create"],(function(e){var t=e.context,n=t.hints||{},i=t.shape,r=t.parent||t.newParent;!1!==n.autoResize&&o._expand([i],r)})),this.postExecuted(["elements.move"],(function(e){var t=e.context,n=i(C(t.closure.topLevel)),r=t.hints,a=!r||r.autoResize;!1!==a&&v(k(n,(function(e){return e.parent.id})),(function(e,t){p(a)&&(e=e.filter((function(e){return m(a,M({id:e.id}))}))),o._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||o._expand(i.children||[],i)})),this.postExecuted(["shape.resize"],(function(e){var t=e.context,n=t.hints,i=t.shape,r=i.parent;n&&!1===n.autoResize||r&&o._expand([i],r)}))}function op(e){e.invoke(rp,this)}function ap(e){zc.call(this,e);var t=this;this.addRule("element.autoResize",(function(e){return t.canResize(e.elements,e.target)}))}function sp(e,t){ap.call(this,e),this._modeling=t}rp.$inject=["eventBus","elementRegistry","modeling","rules"],e(rp,To),rp.prototype._getOptimalBounds=function(e,t){var n=this.getOffset(t),i=this.getPadding(t),r=ln(ht(e)),o=ln(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),un(L({},o,a))},rp.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=ln(e),t=ln(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)}}},rp.prototype.getOffset=function(e){return{top:60,bottom:60,left:100,right:100}},rp.prototype.getPadding=function(e){return{top:2,bottom:2,left:15,right:15}},rp.prototype.resize=function(e,t,n){this._modeling.resizeShape(e,t,null,n)},op.$inject=["injector"],e(op,rp),op.prototype.resize=function(e,t,n){mr(e,"bpmn:Participant")?this._modeling.resizeLane(e,t,null,n):this._modeling.resizeShape(e,t,null,n)},ap.$inject=["eventBus"],e(ap,zc),ap.prototype.canResize=function(e,t){return!1},e(sp,ap),sp.$inject=["eventBus","modeling"],sp.prototype.canResize=function(e,t){if(mr(t.di,"bpmndi:BPMNPlane"))return!1;if(!mr(t,"bpmn:Participant")&&!mr(t,"bpmn:Lane")&&!mr(t,"bpmn:SubProcess"))return!1;var n=!0;return v(e,(function(e){(mr(e,"bpmn:Lane")||sn(e))&&(n=!1)})),n};var cp={__init__:["bpmnAutoResize","bpmnAutoResizeProvider"],bpmnAutoResize:["type",op],bpmnAutoResizeProvider:["type",sp]};function pp(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=ia(e),function(e){return J(e,"svg, .djs-element",!0)}(document.elementFromPoint(t.x,t.y))}}pp.$inject=["elementRegistry","eventBus","injector"];var lp={__init__:["hoverFix"],hoverFix:["type",pp]},up=Math.round,hp="djs-drag-active";function dp(e){e.preventDefault()}function fp(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(L({},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=ia(e),h=za(u,l),d=r.localStart,f=a(u),y=za(f,d);if(!r.active&&(i||(o=h,Math.sqrt(Math.pow(o.x,2)+Math.pow(o.y,2))>r.threshold))){if(L(c,{x:up(d.x+p.x),y:up(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&&La(r.cursor),t.addMarker(t.getRootElement(),hp)}na(e),r.active&&(L(c,{x:up(f.x+p.x),y:up(f.y+p.y),dx:up(y.x),dy:up(y.y)},{originalEvent:e}),s("move"))}function p(e){var t=!0;r.active&&(e&&(r.payload.originalEvent=e,na(e)),t=s("end")),!1===t&&s("rejected"),s("ended",y(!0!==t))}function l(e){ka("Escape",e)&&(dp(e),m())}function u(t){var n;r.active&&(n=Ia(e),setTimeout(n,400),dp(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=y(e),n&&s("canceled",t)}}function y(o){var a,y;s("cleanup"),$a(),y=r.trapClick?u:p,oe.unbind(document,"mousemove",c),oe.unbind(document,"dragstart",dp),oe.unbind(document,"selectstart",dp),oe.unbind(document,"mousedown",y,!0),oe.unbind(document,"mouseup",y,!0),oe.unbind(document,"keyup",l),oe.unbind(document,"touchstart",h,!0),oe.unbind(document,"touchcancel",m,!0),oe.unbind(document,"touchmove",c,!0),oe.unbind(document,"touchend",p,!0),e.off("element.hover",d),e.off("element.out",f),t.removeMarker(t.getRootElement(),hp);var g=r.payload.previousSelection;return!1!==o&&g&&!n.get().length&&function(e){var t=e.filter((function(e){return i.get(e.id)}));t.length&&n.select(t)}(g),a=r,r=null,a}e.on("diagram.destroy",m),this.init=function(t,n,i,y){r&&m(!1),"string"==typeof n&&(y=i,i=n,n=null);var g,v,_,b,x,w=(y=L({},o,y||{})).data||{};b=y.trapClick?u:p,t?(g=ta(t)||t,v=ia(t),na(t),"dragstart"===g.type&&dp(g)):(g=null,v={x:0,y:0}),_=a(v),n||(n=_),x=function(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent}(g),r=L({prefix:i,data:w,payload:{},globalStart:v,displacement:za(n,_),localStart:_,isTouch:x},y),y.manual||(x?(oe.bind(document,"touchstart",h,!0),oe.bind(document,"touchcancel",m,!0),oe.bind(document,"touchmove",c,!0),oe.bind(document,"touchend",p,!0)):(oe.bind(document,"mousemove",c),oe.bind(document,"dragstart",dp),oe.bind(document,"selectstart",dp),oe.bind(document,"mousedown",b,!0),oe.bind(document,"mouseup",b,!0)),oe.bind(document,"keyup",l),e.on("element.hover",d),e.on("element.out",f)),s("init"),y.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){L(o,e)}}fp.$inject=["eventBus","canvas","selection","elementRegistry"];var mp={__depends__:[lp,_a],dragging:["type",fp]};function yp(e,t,n){this._canvas=n,this._opts=L({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 gp(e,t,n){return t<e&&e<n}yp.$inject=["config.autoScroll","eventBus","canvas"],yp.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++)gp(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))},yp.prototype.stopScroll=function(){clearTimeout(this._scrolling)},yp.prototype.setOptions=function(e){this._opts=L({},this._opts,e)},yp.prototype._toBorderPoint=function(e){var t=this._canvas._container.getBoundingClientRect(),n=ia(e.originalEvent);return{x:n.x-t.left,y:n.y-t.top}};var vp={__depends__:[mp],__init__:["autoScroll"],autoScroll:["type",yp]};function _p(e){this._commandStack=e.get("commandStack",!1)}_p.$inject=["injector"],_p.prototype.allowed=function(e,t){var n=!0,i=this._commandStack;return i&&(n=i.canExecute(e,t)),void 0===n||n};var bp={__init__:["rules"],rules:["type",_p]},xp=Math.round,wp=Math.max;function Ep(e,t){return function(e,t){var n,i;for(n=0;i=e[n];n++)if(xt(i,t)<=10)return{point:e[n],bendpoint:!0,index:n};return null}(e,t)||function(e,t){var n,i,r=Qt(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=wp(o.segment2,a.segment2)-1],bendpoint:!0,index:i}:{point:{x:xp(o.x+a.x)/2,y:xp(o.y+a.y)/2},index:o.segment2}:{point:{x:xp(o.x),y:xp(o.y)},index:o.segment2}:null}(e,t)}function Sp(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}function Cp(e){return Math.atan((e[1].y-e[0].y)/(e[1].x-e[0].x))}function kp(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 Rp(e,t){var n=kp(e,t);return Sp({x:n.x-e.x,y:n.y-e.y})}function Pp(e,t){return Sp({x:e.x-t.x,y:e.y-t.y})}var Ap="djs-bendpoint",Mp="djs-segment-dragger";function Tp(e,t,n){var i=function(e,t){var n,i=ia(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);return Ep(t,i)}function Bp(e,t){var n=Ae("g");we(n).add(Ap),ge(e,n);var i=Ae("circle");be(i,{cx:0,cy:0,r:4}),we(i).add("djs-visual"),ge(n,i);var r=Ae("circle");return be(r,{cx:0,cy:0,r:10}),we(r).add("djs-hit"),ge(n,r),t&&we(n).add(t),n}function Dp(e,t,n,i){var r=Ae("g");ge(e,r);var o=function(e,t,n){var i=t.x-e.x,r=t.y-e.y;return jp("h"===n?i:r)}(t,n,i),a=Ae("rect");be(a,{x:-9,y:-3,width:18,height:6}),we(a).add("djs-visual"),ge(r,a);var s=Ae("rect");return be(s,{x:-o/2,y:-8.5,width:o,height:17}),we(s).add("djs-hit"),ge(r,s),Wn(r,"v"===i?90:0),r}function Np(e,t,n){var i=Ae("g"),r=kt(t,n),o=Et(t,n);return ge(e,i),Dp(i,t,n,o),we(i).add(Mp),we(i).add("h"===o?"horizontal":"vertical"),Gn(i,r.x,r.y),i}function jp(e){return Math.abs(Math.round(2*e/3))}function Op(e,t){var n=function(e,t){for(var n,i=t.waypoints,r=1/0,o=0;o<i.length-1;o++){var a=Rp(e,[i[o],i[o+1]]);a<r&&(r=a,n=o)}return[i[n],i[n+1]]}(e,t);return kp(e,n)}function Lp(e,t,n,i,r){function o(e,n){var o,a=n.waypoints,s=Tp(t,a,e);if(s)return o=function(e,t){var n,i,r=e.waypoints;return t.index<=0||t.bendpoint?null:(i=Et((n={start:r[t.index-1],end:r[t.index]}).start,n.end))?jp("h"===i?n.end.x-n.start.x:n.end.y-n.start.y)/2:null}(n,s),!function(e,t,n){var i,r,o,a,s,c,p=e.index,l=e.point;return!(p<=0||e.bendpoint)&&(o=kt(i=t[p-1],r=t[p]),a=Et(i,r),s=Math.abs(l.x-o.x),c=Math.abs(l.y-o.y),a&&s<=n&&c<=n)}(s,a,o)?i.start(e,n,s.index,!s.bendpoint):r.start(e,n,s.index),!0}function a(e,t,i){oe.bind(e,t,(function(e){n.triggerMouseEvent(t,e,i),e.stopPropagation()}))}function s(e,n){var i=t.getLayer("overlays"),r=fe('.djs-bendpoints[data-element-id="'+jo(e.id)+'"]',i);return!r&&n&&(be(r=Ae("g"),{"data-element-id":e.id}),we(r).add("djs-bendpoints"),ge(i,r),a(r,"mousedown",e),a(r,"click",e),a(r,"dblclick",e)),r}function c(e,t){return fe('.djs-segment-dragger[data-segment-idx="'+e+'"]',t)}function p(e,t){t.waypoints.forEach((function(t,n){var i=Bp(e);ge(e,i),Gn(i,t.x,t.y)})),Bp(e,"floating")}function l(e,t){for(var n,i,r,o=t.waypoints,s=1;s<o.length;s++)Et(n=o[s-1],i=o[s])&&(be(r=Np(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){v(me("."+Mp,e),(function(e){Fe(e)}))}(t),function(e){v(me("."+Ap,e),(function(e){Fe(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=kt(a,s),u=Et(a,s);o&&(i=function(e){return fe(".djs-visual",e)}(o),r={x:p.x-l.x,y:p.y-l.y},"v"===u&&(r={x:r.y,y:r.x}),Gn(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&&Fe(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=Tp(t,o,e.originalEvent)))return;!function(e,t){var n=fe(".floating",e),i=t.point;n&&Gn(n,i.x,i.y)}(n,i),i.bendpoint||d(n,i,o)}})),e.on("element.mousedown",(function(e){if(aa(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&&be(i,{"data-element-id":n})}})),this.addHandles=u,this.updateHandles=h,this.getBendpointsContainer=s,this.getSegmentDragger=c}Lp.$inject=["eventBus","canvas","interactionEvents","bendpointMove","connectionSegmentMove"];var $p=Math.round,Ip="reconnectStart",Fp="reconnectEnd",zp="updateWaypoints";function Hp(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?zp:Fp:Ip)===zp?"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===zp?"connection.updateWaypoints":"connection.reconnect";if(t=n.allowed=r.allowed(p,{connection:i,source:c===Ip?s:o,target:c===Fp?s:a}))return n.source=c===Ip?s:o,void(n.target=c===Fp?s:a);!1===t&&(t=n.allowed=r.allowed(p,{connection:i,source:c===Fp?s:a,target:c===Ip?s:o})),t&&(n.source=c===Fp?s:a,n.target=c===Ip?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!==zp&&(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:$p(e.x),y:$p(e.y)};if(!n)return!1;l===zp?(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===xt(t,i=e[r+1])||wt(n,i,t)?e.splice(r,1):r++;return e}(s),u)):(l===Ip?(u.docking="source",Vp(t)&&(u.docking="target",u.newWaypoints=s.reverse())):l===Fp&&(u.docking="target",Vp(t)&&(u.docking="source",u.newWaypoints=s.reverse())),o.reconnect(r,c,p,h,u))}),this)}function Vp(e){var t=e.hover,n=e.source,i=e.target,r=e.type;return r===Ip?t&&i&&t===i&&n!==i:r===Fp?t&&n&&t===n&&n!==i:void 0}Hp.$inject=["injector","eventBus","canvas","dragging","rules","modeling"],Hp.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 Gp="updateWaypoints",Wp="connect-ok",Up="connect-not-ok",qp="connect-hover",Kp="djs-updating",Yp="djs-dragging";function Xp(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=Bp(i.getLayer("overlays"))).add("djs-dragging"),i.addMarker(r,Yp),i.addMarker(r,Kp)})),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,qp),o===Gp)return;n?(i.removeMarker(r,Up),i.addMarker(r,Wp)):!1===n&&(i.removeMarker(r,Wp),i.addMarker(r,Up))}})),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,qp),i.removeMarker(n,r?Wp:Up))})),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?Vp(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?Vp(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===Gp&&(h=e.cropWaypoints(p,h)),m.waypoints=h,r.drawPreview(n,i,m)),Gn(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,Fe(o),i.removeMarker(n,Kp),i.removeMarker(n,Yp),a&&(i.removeMarker(a,Wp),i.removeMarker(a,s?Wp:Up)),r&&r.cleanUp(t)}))}Xp.$inject=["bendpointMove","injector","eventBus","canvas"];var Zp="connect-hover",Qp="djs-updating";function Jp(e,t,n){return el(e,t,e[t]+n)}function el(e,t,n){return{x:"x"===t?n:e.x,y:"y"===t?n:e.y}}function tl(e){return"x"===e?"y":"x"}function nl(e,t,n){var i,r;return e.original?e.original:(i=dn(t),el(e,r=tl(n),i[r]))}function il(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 el(t,i,Math.min(Math.max(o+20,e[i]),r-20))}(n,i[e.segmentStartIndex+t],i[e.segmentEndIndex+t],tl(e.axis));Gn(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=Tp(n,h,e);(a=Et(d,f))&&(s="v"===a?"x":"y",0===l&&(d=nl(d,t.source,s)),u===h.length-1&&(f=nl(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=Np(r,t.segmentStart,t.segmentEnd),we(t.draggerGfx).add("djs-dragging"),n.addMarker(i,Qp)})),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=Jp(l,h,e["d"+h]),m=Jp(u,h,e["d"+h]),y=d.length,g=0;d[o]=f,d[a]=m,o<2&&(t=fn(r.source,f),1===o?"intersect"===t&&(d.shift(),d[0]=f,g--):"intersect"!==t&&(d.unshift(l),g++)),a>y-3&&(n=fn(r.target,m),a===y-2?"intersect"===n&&(d.pop(),d[d.length-1]=m):"intersect"!==n&&d.push(u)),i.newWaypoints=r.waypoints=s(r,d),p(i,g,e),i.newSegmentStartIndex=o+g,c(e)})),t.on("connectionSegment.move.hover",(function(e){e.context.hover=e.hover,n.addMarker(e.hover,Zp)})),t.on(["connectionSegment.move.out","connectionSegment.move.cleanup"],(function(e){var t=e.context.hover;t&&n.removeMarker(t,Zp)})),t.on("connectionSegment.move.cleanup",(function(e){var t=e.context,i=t.connection;t.draggerGfx&&Fe(t.draggerGfx),n.removeMarker(i,Qp)})),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;i=i.map((function(e){return{original:e.original,x:Math.round(e.x),y:Math.round(e.y)}}));var a=function(e,t){var n=0,i=e.filter((function(i,r){return!wt(e[r-1],e[r+1],i)||(n=r<=t?n-1:n,!1)}));return{waypoints:i,segmentOffset:n}}(i,r),c=s(n,a.waypoints),p=a.segmentOffset,l={segmentMove:{segmentStartIndex:t.segmentStartIndex,newSegmentStartIndex:r+p}};o.updateWaypoints(n,c,l)}))}il.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];var rl=Math.abs,ol=Math.round;function al(e){return{x:e.x,y:e.y}}function sl(e){return{x:e.x+e.width,y:e.y+e.height}}function cl(e,t){return!e||isNaN(e.x)||isNaN(e.y)?t:{x:ol(e.x+e.width/2),y:ol(e.y+e.height/2)}}function pl(e,t){var n=e.snapped;return!!n&&("string"==typeof t?n[t]:n.x&&n.y)}function ll(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 ul(e){return e.children||[]}var hl=Math.abs,dl=Math.round;function fl(e){function t(e,t){if(p(e)){for(var n=e.length;n--;)if(hl(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,t){return e.waypoints?Op(t,e):e.width?{x:dl(e.width/2+e.x),y:dl(e.height/2+e.y)}:void 0}e.on("connectionSegment.move.move",1500,(function(e){var i,r,o=function(e){var t=e.context,i=t.snapPoints,r=t.connection,o=r.waypoints,a=t.segmentStart,s=t.segmentStartIndex,c=t.segmentEnd,p=t.segmentEndIndex,l=t.axis;if(i)return i;var u=[o[s-1],a,c,o[p+1]];return s<2&&u.unshift(n(r.source,e)),p>o.length-3&&u.unshift(n(r.target,e)),t.snapPoints=i={horizontal:[],vertical:[]},v(u,(function(e){e&&(e=e.original||e,"y"===l&&i.horizontal.push(e.y),"x"===l&&i.vertical.push(e.x))})),i}(e),a=e.x,s=e.y;if(o){var c=a-(i=t(o.vertical,a)),p=s-(r=t(o.horizontal,s));L(e,{dx:e.dx-c,dy:e.dy-p,x:i,y:r}),(c||-1!==o.vertical.indexOf(a))&&ll(e,"x",i),(p||-1!==o.horizontal.indexOf(s))&&ll(e,"y",r)}})),e.on(["connect.hover","connect.move","connect.end"],1500,(function(e){var t=e.context.hover,i=t&&n(t,e);an(t)&&i&&i.x&&i.y&&(ll(e,"x",i.x),ll(e,"y",i.y))})),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:[]},v(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,e),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));L(e,{dx:e.dx-u,dy:e.dy-h,x:e.x-u,y:e.y-h}),(u||-1!==a.vertical.indexOf(p))&&ll(e,"x",i),(h||-1!==a.horizontal.indexOf(l))&&ll(e,"y",r)}}))}fl.$inject=["eventBus"];var ml={__depends__:[mp,bp],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",Lp],bendpointMove:["type",Hp],bendpointMovePreview:["type",Xp],connectionSegmentMove:["type",il],bendpointSnapping:["type",fl]};function yl(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,!c(t=n.canExecute=r(i,o))){if(!1!==t)return n.source=i,void(n.target=o);c(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:gl(t)?o:r,connectionEnd:gl(t)?r:o};l(i)&&(c=i),t.connection=n.connect(a,s,c,p)})),this.start=function(e,n,i,r){l(i)||(r=i,i=dn(n)),t.init(e,"connect",{autoActivate:r,data:{shape:n,context:{start:n,connectionStart:i}}})}}function gl(e){var t=e.hover,n=e.source,i=e.target;return t&&n&&t===n&&n!==i}yl.$inject=["eventBus","dragging","modeling","rules"];var vl="connect-ok",_l="connect-not-ok";function bl(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;gl(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?vl:_l)})),t.on(["connect.out","connect.cleanup"],1100,(function(e){var t=e.hover;t&&(n.removeMarker(t,vl),n.removeMarker(t,_l))})),i&&t.on("connect.cleanup",(function(e){i.cleanUp(e.context)}))}bl.$inject=["injector","eventBus","canvas"];var xl={__depends__:[_a,bp,mp],__init__:["connectPreview"],connect:["type",yl],connectPreview:["type",bl]};function wl(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)}wl.$inject=["injector","canvas","graphicsFactory","elementFactory"],wl.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,y=this;a||(a=e.connectionPreviewGfx=this.createConnectionPreviewGfx()),Se(a),s||(s=e.getConnection=(r=function(e,t,n){return y.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?dn(c):u,p?dn(p):h]),this._connectionDocking&&(c||p)&&!f&&(i.waypoints=this._connectionDocking.getCroppedWaypoints(i,c,p)),this._graphicsFactory.drawConnection(a,i,{stroke:"var(--element-dragger-color)"})):!m&&this.drawNoopPreview(a,n)},wl.prototype.drawNoopPreview=function(e,t){var n=t.source,i=t.target,r=t.connectionStart||dn(n),o=t.connectionEnd||dn(i),a=this.cropWaypoints(r,o,n,i);ge(e,this.createNoopConnection(a[0],a[1]))},wl.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&&mn(o,s,!0)||e,t=i&&mn(a,s,!1)||t]},wl.prototype.cleanUp=function(e){e&&e.connectionPreviewGfx&&Fe(e.connectionPreviewGfx)},wl.prototype.getConnection=function(e){var t=function(e){return l(e)?e:{}}(e);return this._elementFactory.createConnection(t)},wl.prototype.createConnectionPreviewGfx=function(){var e=Ae("g");return be(e,{pointerEvents:"none"}),we(e).add("djs-dragger"),ge(this._canvas.getActiveLayer(),e),e},wl.prototype.createNoopConnection=function(e,t){return ot([e,t],{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"})};var El={__init__:["connectionPreview"],connectionPreview:["type",wl]};const Sl=new wo("ps");var Cl=["marker-start","marker-mid","marker-end"],kl=["circle","ellipse","line","path","polygon","polyline","path","rect"];function Rl(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._styles=i}Rl.$inject=["elementRegistry","eventBus","canvas","styles"],Rl.prototype.cleanUp=function(){console.warn("PreviewSupport#cleanUp is deprecated and will be removed in future versions. You do not need to manually clean up previews anymore. cf. https://github.com/bpmn-io/diagram-js/pull/906")},Rl.prototype.getGfx=function(e){return this._elementRegistry.getGraphics(e)},Rl.prototype.addDragger=function(e,t,n,i="djs-dragger"){var r=Ce(n=n||this.getGfx(e)),o=n.getBoundingClientRect();return this._cloneMarkers(Hn(r),i),be(r,this._styles.cls(i,[],{x:o.top,y:o.left})),ge(t,r),be(r,"data-preview-support-element-id",e.id),r},Rl.prototype.addFrame=function(e,t){var n=Ae("rect",{class:"djs-resize-overlay",width:e.width,height:e.height,x:e.x,y:e.y});return ge(t,n),be(n,"data-preview-support-element-id",e.id),n},Rl.prototype._cloneMarkers=function(e,t="djs-dragger",n=e){var i=this;e.childNodes&&e.childNodes.forEach((e=>{i._cloneMarkers(e,t,n)})),function(e){return-1!==kl.indexOf(e.nodeName)}(e)&&Cl.forEach((function(r){if(be(e,r)){var o=function(e,t,n){var i=(r=be(e,t),r.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]);var r;return fe("marker#"+i,n||document)}(e,r,i._canvas.getContainer());o&&i._cloneMarker(n,e,o,r,t)}}))},Rl.prototype._cloneMarker=function(e,t,n,i,r="djs-dragger"){var o=[n.id,r,Sl.next()].join("-"),a=fe("marker#"+n.id,e);e=e||this._canvas._svg;var s=a||Ce(n);s.id=o,we(s).add(r);var c=fe(":scope > defs",e);c||ge(e,c=Ae("defs")),ge(c,s),be(t,i,"url(#"+s.id+")")};var Pl={__init__:["previewSupport"],previewSupport:["type",Rl]};const Al="complex-preview";class Ml{constructor(e,t,n){this._canvas=e,this._graphicsFactory=t,this._previewSupport=n,this._markers=[]}create(e){this.cleanUp();const{created:t=[],moved:n=[],removed:i=[],resized:r=[]}=e,o=this._canvas.getLayer(Al);t.filter((e=>!function(e){return e.hidden}(e))).forEach((e=>{let t;an(e)?(t=this._graphicsFactory._createContainer("connection",Ae("g")),this._graphicsFactory.drawConnection(Hn(t),e)):(t=this._graphicsFactory._createContainer("shape",Ae("g")),this._graphicsFactory.drawShape(Hn(t),e),Gn(t,e.x,e.y)),this._previewSupport.addDragger(e,o,t)})),n.forEach((({element:e,delta:t})=>{this._previewSupport.addDragger(e,o,void 0,"djs-dragging"),this._canvas.addMarker(e,"djs-element-hidden"),this._markers.push([e,"djs-element-hidden"]);const n=this._previewSupport.addDragger(e,o);an(e)?Gn(n,t.x,t.y):Gn(n,e.x+t.x,e.y+t.y)})),i.forEach((e=>{this._previewSupport.addDragger(e,o,void 0,"djs-dragging"),this._canvas.addMarker(e,"djs-element-hidden"),this._markers.push([e,"djs-element-hidden"])})),r.forEach((({shape:e,bounds:t})=>{this._canvas.addMarker(e,"djs-hidden"),this._markers.push([e,"djs-hidden"]),this._previewSupport.addDragger(e,o,void 0,"djs-dragging");const n=this._graphicsFactory._createContainer("shape",Ae("g"));this._graphicsFactory.drawShape(Hn(n),e,{width:t.width,height:t.height}),Gn(n,t.x,t.y),this._previewSupport.addDragger(e,o,n)}))}cleanUp(){Se(this._canvas.getLayer(Al)),this._markers.forEach((([e,t])=>this._canvas.removeMarker(e,t))),this._markers=[]}show(){this._canvas.showLayer(Al)}hide(){this._canvas.hideLayer(Al)}}Ml.$inject=["canvas","graphicsFactory","previewSupport"];var Tl={__depends__:[Pl],__init__:["complexPreview"],complexPreview:["type",Ml]},Bl=["top","bottom","left","right"],Dl=10;function Nl(e,t){function n(e){if(zr(e)&&!an(e)){var n=function(e){var t=dn(e.label),n=dn(e),i=jl(n,t);if(r=i,-1===Bl.indexOf(r))return;var r;var o=function(e){var t=dn(e),n=[].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 jl(t,e)}));return n}(e);if(e.host){var a=function(e){var t,n=e.host,i=dn(e),r=fn(i,n);t=r.indexOf("-")>=0?r.split("-"):[r];var o=Bl.filter((function(e){return-1===t.indexOf(e)}));return o}(e);o=o.concat(a)}var s=Bl.filter((function(e){return-1===o.indexOf(e)}));if(-1!==s.indexOf(i))return;return s[0]}(e);n&&function(e,n){var i=dn(e),r=e.label,o=dn(r);if(!r.parent)return;var a,s=ln(e);switch(n){case"top":a={x:i.x,y:s.top-Dl-r.height/2};break;case"left":a={x:s.left-Dl-r.width/2,y:i.y};break;case"bottom":a={x:i.x,y:s.bottom+Dl+r.height/2};break;case"right":a={x:s.right+Dl+r.width/2,y:i.y}}var c=za(a,o);t.moveShape(r,c)}(e,n)}}To.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 jl(e,t){return fn(t,e,5)}function Ol(e){To.call(this,e),this.preExecute("shape.append",(function(e){var t=e.source,n=e.shape;e.position||(mr(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 Ll(e,t){e.invoke(To,this),this.postExecute("shape.move",(function(e){var n=e.newParent,i=e.shape;v(g(i.incoming.concat(i.outgoing),(function(e){return mr(e,"bpmn:Association")})),(function(e){t.moveConnection(e,{x:0,y:0},n)}))}),!0)}e(Nl,To),Nl.$inject=["eventBus","modeling"],e(Ol,To),Ol.$inject=["eventBus"],e(Ll,To),Ll.$inject=["injector","modeling"];function $l(e,t){t.invoke(To,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 Il(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];Il(r,i)&&(e.shapes=[n._replaceShape(r,i)])}}),!0)}function Il(e,t){return!sn(e)&&yr(e,["bpmn:IntermediateThrowEvent","bpmn:IntermediateCatchEvent"])&&!!t}function Fl(e,t){function n(e){return g(e.attachers,(function(e){return mr(e,"bpmn:BoundaryEvent")}))}To.call(this,e),this.postExecute("connection.create",(function(e){var i=e.context.source,r=e.context.target,o=n(r);mr(i,"bpmn:EventBasedGateway")&&mr(r,"bpmn:ReceiveTask")&&o.length>0&&t.removeElements(o)})),this.postExecute("connection.reconnect",(function(e){var i=e.context.oldSource,r=e.context.newSource;mr(i,"bpmn:Gateway")&&mr(r,"bpmn:EventBasedGateway")&&v(r.outgoing,(function(e){var i=e.target,r=n(i);mr(i,"bpmn:ReceiveTask")&&r.length>0&&t.removeElements(r)}))}))}function zl(e,t,n){function i(e){t.updateProperties(e,{isForCompensation:!0})}function r(e){t.updateProperties(e,{isForCompensation:void 0})}To.call(this,e),this.preExecute("shape.replace",(function(e){const{newData:n,oldShape:i}=e;if(Vl(e.oldShape)&&"bpmn:CompensateEventDefinition"!==n.eventDefinitionType||"bpmn:BoundaryEvent"!==n.type){const t=i.outgoing.find((({target:e})=>Hl(e)));t&&t.target&&(e._connectionTarget=t.target)}else if(!Vl(e.oldShape)&&"bpmn:CompensateEventDefinition"===n.eventDefinitionType&&"bpmn:BoundaryEvent"===n.type){const n=i.outgoing.find((({target:e})=>Gl(e)));n&&n.target&&(e._connectionTarget=n.target),function(e){const n=e.outgoing.filter((e=>mr(e,"bpmn:SequenceFlow")));t.removeElements(n)}(i)}}),!0),this.postExecuted("shape.replace",(function(e){const{_connectionTarget:n,newShape:i}=e;n&&t.connect(i,n)}),!0),this.preExecute("connection.create",(function(e){const n=e.connection,r=e.source,o=e.target;Vl(r)&&Gl(o)&&(i(o),function(e,n){const i=e.outgoing.filter((e=>mr(e,"bpmn:Association"))),r=i.filter((e=>Hl(e.target)&&!n.includes(e)));r.forEach((e=>t.removeConnection(e)))}(r,[n]))}),!0),this.postExecuted("connection.delete",(function(e){const t=e.source,n=e.target;Vl(t)&&Hl(n)&&r(n)}),!0),this.postExecuted("connection.reconnect",(function(e){const t=e.newTarget,n=e.oldSource,o=e.oldTarget;if(o!==t){const e=n;Hl(o)&&r(o),Vl(e)&&Gl(t)&&i(t)}}),!0),this.postExecuted("element.updateProperties",(function(e){const{element:i}=e;Hl(i)?(function(e){for(const i of e.incoming)n.canConnect(i.source,e)||t.removeConnection(i);for(const i of e.outgoing)n.canConnect(e,i.target)||t.removeConnection(i)}(i),function(e){const n=e.attachers.slice();if(!n.length)return;t.removeElements(n)}(i)):Gl(i)&&function(e){const n=e.incoming.filter((e=>Vl(e.source)));t.removeElements(n)}(i)}),!0)}function Hl(e){const t=gr(e);return t&&t.get("isForCompensation")}function Vl(e){return e&&mr(e,"bpmn:BoundaryEvent")&&$r(e,"bpmn:CompensateEventDefinition")}function Gl(e){return e&&mr(e,"bpmn:Activity")&&!Lr(e)}function Wl(e){e.invoke(To,this),this.preExecute("shape.create",1500,(function(e){var t=e.context,n=t.parent,i=t.shape;mr(n,"bpmn:Lane")&&!mr(i,"bpmn:Lane")&&(t.parent=Qc(n,"bpmn:Participant"))}))}function Ul(e,t){To.call(this,e),this.preExecute("shape.create",(function(e){var n=e.context.shape;if(mr(n,"bpmn:DataObjectReference")&&"label"!==n.type){var i=t.create("bpmn:DataObject");n.businessObject.dataObjectRef=i}}))}$l.$inject=["bpmnReplace","injector"],e($l,To),$l.prototype._replaceShape=function(e,t){var n,i=(n=gr(e).eventDefinitions)&&n[0],r={type:"bpmn:BoundaryEvent",host:t};return i&&(r.eventDefinitionType=i.$type),this._bpmnReplace.replaceElement(e,r,{layoutConnection:!1})},Fl.$inject=["eventBus","modeling"],e(Fl,To),e(zl,To),zl.$inject=["eventBus","modeling","bpmnRules"],Wl.$inject=["injector"],e(Wl,To),Ul.$inject=["eventBus","bpmnFactory"],e(Ul,To);var ql=20,Kl=20,Yl=2e3;function Xl(e,t,n){function i(){var t=e.getRootElement();return mr(t,"bpmn:Collaboration")?t:n.makeCollaboration()}To.call(this,t),t.on(["create.start","shape.move.start"],Yl,(function(t){var n=t.context,i=n.shape,r=e.getRootElement();if(mr(i,"bpmn:Participant")&&mr(r,"bpmn:Process")&&r.children.length){var o=r.children.filter((function(e){return!mr(e,"bpmn:Group")&&!sn(e)&&!an(e)}));if(o.length){var a=ht(o),s=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);L(i,s),n.createConstraints=function(e,t){return t=ln(t),{bottom:t.top+e.height/2-Kl,left:t.right-e.width/2+ql,top:t.bottom-e.height/2+Kl,right:t.left+e.width/2-ql-30}}(i,a)}}})),t.on("create.start",Yl,(function(n){var i=n.context.shape,r=e.getRootElement(),o=e.getGraphics(r);function a(e){e.element=r,e.gfx=o}mr(i,"bpmn:Participant")&&mr(r,"bpmn:Process")&&(t.on("element.hover",Yl,a),t.once("create.cleanup",(function(){t.off("element.hover",a)})))})),this.preExecute("elements.create",Yl,(function(e){var t,n=e.elements,r=e.parent,o=function(e){return m(e,(function(e){return mr(e,"bpmn:Participant")}))}(n);o&&mr(r,"bpmn:Process")&&(e.parent=i(),(t=e.hints=e.hints||{}).participant=o,t.process=r,t.processRef=gr(o).get("processRef"))}),!0),this.preExecute("shape.create",(function(e){var t=e.parent,n=e.shape;mr(n,"bpmn:Participant")&&mr(t,"bpmn:Process")&&(e.parent=i(),e.process=t,e.processRef=gr(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||gr(i).set("processRef",gr(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||gr(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)}Xl.$inject=["canvas","eventBus","modeling"],e(Xl,To);var Zl="__targetRef_placeholder";function Ql(e,t){function n(e,n){var i=e.get("properties"),r=m(i,(function(e){return e.name===Zl}));return!r&&n&&_t(i,r=t.create("bpmn:Property",{name:Zl})),r}function i(e,t){var i=n(e);i&&(function(e,t,n){return m(e.get("dataInputAssociations"),(function(e){return e!==n&&e.targetRef===t}))}(e,i,t)||vt(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}To.call(this,e),this.executed(["connection.create","connection.delete","connection.move","connection.reconnect"],Jl(r)),this.reverted(["connection.create","connection.delete","connection.move","connection.reconnect"],Jl(r))}function Jl(e){return function(t){if(mr(t.context.connection,"bpmn:DataInputAssociation"))return e(t)}}function eu(e){this._bpmnUpdater=e}function tu(e,t,n,i){function r(e){return e.children.filter((function(e){return mr(e,"bpmn:DataStoreReference")&&!e.labelTarget}))}function o(e,i){var r=e.businessObject||e;if(i=i||n.filter((function(e){return mr(e,"bpmn:Participant")&&gr(e).processRef}))[0]){var o=i.businessObject||i;t.execute("dataStore.updateContainment",{dataStoreBo:r,dataStoreDi:vr(e),newSemanticParent:o.processRef||o,newDiParent:vr(i)})}}To.call(this,i),t.registerHandler("dataStore.updateContainment",eu),this.preExecute("shape.create",(function(e){var t=e.context,n=t.shape;mr(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 mr(e,"bpmn:DataStoreReference")})).length&&(t.hints||(t.hints={}),t.hints.autoResize=n.filter((function(e){return!mr(e,"bpmn:DataStoreReference")})))})),this.postExecute("shape.create",(function(e){var t=e.context.shape,n=t.parent;mr(t,"bpmn:DataStoreReference")&&"label"!==t.type&&mr(n,"bpmn:Collaboration")&&o(t)})),this.postExecute("shape.move",(function(e){var t=e.context,n=t.shape,i=t.oldParent,r=n.parent;mr(i,"bpmn:Collaboration")||mr(n,"bpmn:DataStoreReference")&&"label"!==n.type&&mr(r,"bpmn:Collaboration")&&o(n,mr(i,"bpmn:Participant")?i:function(e,t){for(;e.parent;){if(mr(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();yr(n,["bpmn:Participant","bpmn:SubProcess"])&&mr(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){mr(i,"bpmn:Process")&&o(e,i)}))}))}Ql.$inject=["eventBus","bpmnFactory"],e(Ql,To),eu.$inject=["bpmnUpdater"],eu.prototype.execute=function(e){var t=e.dataStoreBo,n=e.dataStoreDi,i=e.newSemanticParent,r=e.newDiParent;return e.oldSemanticParent=t.$parent,e.oldDiParent=n.$parent,this._bpmnUpdater.updateSemanticParent(t,i),this._bpmnUpdater.updateDiParent(n,r),[]},eu.prototype.revert=function(e){var t=e.dataStoreBo,n=e.dataStoreDi,i=e.oldSemanticParent,r=e.oldDiParent;return this._bpmnUpdater.updateSemanticParent(t,i),this._bpmnUpdater.updateDiParent(n,r),[]},tu.$inject=["canvas","commandStack","elementRegistry","eventBus"],e(tu,To);var nu=Math.max,iu=Math.min;function ru(e,t){return{top:e.top-t.top,right:e.right-t.right,bottom:e.bottom-t.bottom,left:e.left-t.left}}function ou(e,t,n){var i=t[e],r=n.min&&n.min[e],o=n.max&&n.max[e];return u(r)&&(i=(/top|left/.test(e)?iu:nu)(i,r)),u(o)&&(i=(/top|left/.test(e)?nu:iu)(i,o)),i}function au(e,t){return void 0!==e?e:20}function su(e){return!e.waypoints&&"label"!==e.type}function cu(e,t){var n;if((n=void 0===e.length?g(e.children,su):e).length)return function(e,t){var n,i,r,o;return"object"==typeof t?(n=au(t.left),i=au(t.right),r=au(t.top),o=au(t.bottom)):n=i=r=o=au(t),{x:e.x-n,y:e.y-r,width:e.width+n+i,height:e.height+r+o}}(ht(n),t)}var pu=Math.abs;var lu=["bpmn:Participant","bpmn:Process","bpmn:SubProcess"],uu=30;function hu(e,t){return t=t||[],e.children.filter((function(e){mr(e,"bpmn:Lane")&&(hu(e,t),t.push(e))})),t}function du(e){return e.children.filter((function(e){return mr(e,"bpmn:Lane")}))}function fu(e){return Qc(e,lu)||e}function mu(e,t){var n=fu(e),i=hu(n,mr(n,"bpmn:Process")?[]:[n]),r=ln(e),o=ln(t),a=function(e,t){return ru(ln(t),ln(e))}(e,t),s=[],c=Or(e);return i.forEach((function(t){if(t!==e){var n,i,p=c?0:a.top,l=c?a.right:0,u=c?0:a.bottom,h=c?a.left:0,d=ln(t);a.top&&(pu(d.bottom-r.top)<10&&(u=o.top-d.bottom),pu(d.top-r.top)<5&&(p=o.top-d.top)),a.left&&(pu(d.right-r.left)<10&&(l=o.left-d.right),pu(d.left-r.left)<5&&(h=o.left-d.left)),a.bottom&&(pu(d.top-r.bottom)<10&&(p=o.bottom-d.top),pu(d.bottom-r.bottom)<5&&(u=o.bottom-d.bottom)),a.right&&(pu(d.left-r.right)<10&&(h=o.right-d.left),pu(d.right-r.right)<5&&(l=o.right-d.right)),(p||l||u||h)&&s.push({shape:t,newBounds:(n=t,i={top:p,right:l,bottom:u,left:h},{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 yu(e,t){To.call(this,e),this.postExecuted("shape.delete",500,(function(e){var n=e.context,i=n.hints,r=n.shape,o=n.oldParent;mr(r,"bpmn:Lane")&&(i&&i.nested||function(e,n){var i,r,o,a,s,c=Or(e),p=du(n),l=[],u=[],h=[],d=[];lt(p,(function(t){return c?t.y>e.y?u.push(t):l.push(t):t.x>e.x?d.push(t):h.push(t),t.children})),p.length&&(i=c?u.length&&l.length?e.height/2:e.height:d.length&&h.length?e.width/2:e.width,l.length&&(r=t.calculateAdjustments(l,"y",i,e.y-10),t.makeSpace(r.movingShapes,r.resizingShapes,{x:0,y:i},"s")),u.length&&(o=t.calculateAdjustments(u,"y",-i,e.y+e.height+10),t.makeSpace(o.movingShapes,o.resizingShapes,{x:0,y:-i},"n")),h.length&&(a=t.calculateAdjustments(h,"x",i,e.x-10),t.makeSpace(a.movingShapes,a.resizingShapes,{x:i,y:0},"e")),d.length&&(s=t.calculateAdjustments(d,"x",-i,e.x+e.width+10),t.makeSpace(s.movingShapes,s.resizingShapes,{x:-i,y:0},"w")))}(r,o))}))}yu.$inject=["eventBus","spaceTool"],e(yu,To);function gu(e,t){t.invoke(To,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",500,(function(e){var t=e.elements;t.filter((function(e){return vu(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;vu(e,(o=a,-1!==t.indexOf(o)?a:i))&&(t[r]=n._replaceShape(e))}))}),!0)}function vu(e,t){return!sn(e)&&mr(e,"bpmn:BoundaryEvent")&&!t}function _u(e,t,n){function i(e,i,r){var o,a,s,c,p,l,h,d,f=i.waypoints,m=e.outgoing.slice(),y=e.incoming.slice(),v=Ep(f,d=u(r.width)?dn(r):r);if(v){if(o=f.slice(0,v.index),a=f.slice(v.index+(v.bendpoint?1:0)),!o.length||!a.length)return;s=v.bendpoint?f[v.index]:d,1!==o.length&&bu(e,o[o.length-1])||o.push(xu(s)),1!==a.length&&bu(e,a[0])||a.unshift(xu(s))}c=i.source,p=i.target,t.canConnect(c,e,i)&&(n.reconnectEnd(i,e,o||d),l=i),t.canConnect(e,p,i)&&(l?h=n.connect(e,p,{type:i.type,waypoints:a}):(n.reconnectStart(i,e,a||d),h=i));var _=[].concat(l&&g(y,(function(e){return e.source===l.source}))||[],h&&g(m,(function(e){return e.target===h.target}))||[]);_.length&&n.removeElements(_)}To.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=dn(o),s={x:a.x+r.x,y:a.y+r.y},c=m(n.children,(function(e){return t.canInsert(i,e)&&Ep(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 bu(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 xu(e){return L({},e)}function wu(e,t){To.call(this,e),this.preExecuted("connection.create",(function(e){var n=e.context,i=n.connection,r=n.source,o=n.target,a=n.hints;if((!a||!1!==a.createElementsBehavior)&&Eu(i)){(mr(r,"bpmn:EventBasedGateway")?o.incoming.filter((e=>e!==i&&Eu(e))):o.incoming.filter((e=>e!==i&&Eu(e)&&mr(e.source,"bpmn:EventBasedGateway")))).forEach((function(e){t.removeConnection(e)}))}})),this.preExecuted("shape.replace",(function(e){var n=e.context.newShape;mr(n,"bpmn:EventBasedGateway")&&n.outgoing.filter(Eu).reduce((function(e,t){return e.includes(t.target)?e:e.concat(t.target)}),[]).forEach((function(e){e.incoming.filter(Eu).forEach((function(i){const r=e.incoming.filter(Eu).filter((function(e){return e.source===n}));(i.source!==n||r.length>1)&&t.removeConnection(i)}))}))}))}function Eu(e){return mr(e,"bpmn:SequenceFlow")}gu.$inject=["bpmnReplace","injector"],e(gu,To),gu.prototype._replaceShape=function(e){var t,n,i=(n=gr(e).eventDefinitions)&&n[0];return t=i?{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:i.$type}:{type:"bpmn:IntermediateThrowEvent"},this._bpmnReplace.replaceElement(e,t,{layoutConnection:!1})},e(_u,To),_u.$inject=["eventBus","bpmnRules","modeling"],wu.$inject=["eventBus","modeling"],e(wu,To);var Su=1500;function Cu(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"],Su,(function(t){var i=t.context.shape||t.shape,r=t.hover;mr(r,"bpmn:Lane")&&!yr(i,["bpmn:Lane","bpmn:Participant"])&&(t.hover=fu(r),t.hoverGfx=e.getGraphics(t.hover));var o=n.getRootElement();r!==o&&(i.labelTarget||yr(i,["bpmn:Group","bpmn:TextAnnotation"]))&&(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"],Su,(function(t){var n=t.hover;mr(n,"bpmn:Lane")&&(t.hover=fu(n)||n,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["bendpoint.move.hover"],Su,(function(t){var n=t.context,i=t.hover,r=n.type;mr(i,"bpmn:Lane")&&/reconnect/.test(r)&&(t.hover=fu(i)||i,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["connect.start"],Su,(function(e){var t=e.context,n=t.start;mr(n,"bpmn:Lane")&&(t.start=fu(n)||n)})),t.on("shape.move.start",2e3,(function(e){var t=e.shape;mr(t,"bpmn:Lane")&&(e.shape=fu(t)||t)})),t.on("spaceTool.move",2e3,(function(e){var t=e.hover;t&&mr(t,"bpmn:Lane")&&(e.hover=fu(t))}))}Cu.$inject=["elementRegistry","eventBus","canvas"];function ku(e,t,n,i,r,o){function a(e,t,i){var r=n.filter((function(e){return mr(e,"bpmn:Group")})).filter((function(e){return e.businessObject!==i}));t&&!function(e,t){return e.some((function(e){var n=gr(e);return(n.categoryValueRef&&n.categoryValueRef.$parent)===t}))}(r,t)&&function(e){var t=e.$parent;t&&(vt(t.get("rootElements"),e),e.$parent=null)}(t),e&&!function(e,t){return e.some((function(e){return gr(e).categoryValueRef===t}))}(r,e)&&function(e){var t=e.$parent;t&&(vt(t.get("categoryValue"),e),e.$parent=null)}(e)}function s(e,n){return function(e,t,n){return _t(t.get("categoryValue"),e),e.$parent=t,_t(n.get("rootElements"),t),t.$parent=n,e}(e,n,t.getDefinitions())}function c(n,i){var r=gr(n),o=r.categoryValueRef;o||(o=r.categoryValueRef=i.categoryValue=i.categoryValue||function(e){return e.create("bpmn:CategoryValue")}(e));var a=o.$parent;a||(a=o.$parent=i.category=i.category||function(e){return e.create("bpmn:Category")}(e)),s(o,a,t.getDefinitions())}function p(e,t){var n=t.category,i=t.categoryValue,r=gr(e);i?(r.categoryValueRef=null,a(i,n,r)):a(null,r.categoryValueRef.$parent,r)}function l(t,n){var i=e.create(t.$type);return o.copyElement(t,i,null,n)}r.invoke(To,this),this.execute("label.create",(function(e){var t=e.context,n=t.labelTarget;mr(n,"bpmn:Group")&&c(n,t)})),this.revert("label.create",(function(e){var t=e.context,n=t.labelTarget;mr(n,"bpmn:Group")&&p(n,t)})),this.execute("shape.delete",(function(e){var t=e.context,n=t.shape,i=gr(n);if(mr(n,"bpmn:Group")&&!n.labelTarget){var r=t.categoryValue=i.categoryValueRef;r&&(a(r,t.category=r.$parent,i),i.categoryValueRef=null)}})),this.reverted("shape.delete",(function(e){var t=e.context,n=t.shape;if(mr(n,"bpmn:Group")&&!n.labelTarget){var i=t.category,r=t.categoryValue,o=gr(n);r&&(o.categoryValueRef=r,s(r,i))}})),this.execute("shape.create",(function(e){var t=e.context,n=t.shape;mr(n,"bpmn:Group")&&!n.labelTarget&&gr(n).categoryValueRef&&c(n,t)})),this.reverted("shape.create",(function(e){var t=e.context,n=t.shape;mr(n,"bpmn:Group")&&!n.labelTarget&&gr(n).categoryValueRef&&p(n,t)})),i.on("copyPaste.copyElement",770,(function(e){var t=e.descriptor,n=e.element;if(mr(n,"bpmn:Group")&&!n.labelTarget){var i=gr(n);if(i.categoryValueRef){var r=i.categoryValueRef;t.categoryValue=l(r,!0),r.$parent&&(t.category=l(r.$parent,!0))}}})),i.on("copyPaste.pasteElement",770,(function(e){var t=e.descriptor,n=t.businessObject,i=t.categoryValue,r=t.category;i&&(i=n.categoryValueRef=l(i)),r&&(i.$parent=l(r)),delete t.category,delete t.categoryValue}))}function Ru(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 Pu(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=Ru(e,t,n,r),s=Ru(e,t,n,o);i=a&&s?Au(a,n)>Au(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],dn(n.source)),t(i[i.length-1],i[i.length-2],dn(n.target)))}))}function Au(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Mu(e){To.call(this,e);var t=["bpmn:Participant","bpmn:Lane"];this.executed(["shape.move","shape.create","shape.resize"],(function(e){var n=e.context.shape,i=gr(n),r=vr(n);if(yr(i,t)){var o=r.get("isHorizontal");void 0===o&&(o=!0),r.set("isHorizontal",o)}}))}ku.$inject=["bpmnFactory","bpmnjs","elementRegistry","eventBus","injector","moddleCopy"],e(ku,To),Pu.$inject=["eventBus"],Mu.$inject=["eventBus"],e(Mu,To);var Tu=Math.sqrt,Bu=Math.min,Du=Math.max,Nu=Math.abs;function ju(e){return Math.pow(e,2)}function Ou(e,t){return Tu(ju(e.x-t.x)+ju(e.y-t.y))}function Lu(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=Tu(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 $u(e.x,t.x,n.x)&&$u(e.y,t.y,n.y)}(n,e,t)}))}function $u(e,t,n){return e>=Bu(t,n)-Iu&&e<=Du(t,n)+Iu}var Iu=.1;function Fu(e,t){return Nu(e.x-t.x)<=Iu&&Nu(e.y-t.y)<=Iu}function zu(e,t,n,i){var r=0,o=0,a={point:e,delta:{x:0,y:0}},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(Fu(n=t[f],i=t[f+1])?s=[n]:(r=Ou(e,n),o=Ou(e,i),s=Lu(n,i,e,Bu(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:Fu(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:Ou(n,a)/Ou(n,i)}),p=Ou(c.position,e),(!u||l>p)&&(u=c,l=p)}return u}(e,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&&Hu(t,l)<n.relativeLocation&&c++),c)}return 0===o?r:i.connectionStart&&0===r?0:i.connectionEnd&&r===e.length-2?t.length-2:Math.floor((t.length-2)/2)}(n,t,s,i);if(p<0||p>t.length-2||null===p)return a;var l,u,h=Vu(n,c),d=Vu(t,p),f=s.position,m=function(e,t){var n=Pp(e[0],e[1]),i=Pp(e[0],t);return 0===n?0:i/n}(h,f),y=(l=d,u=Cp(h),Cp(l)-u);if("bendpoint"===s.type){var g=t.length-n.length,v=s.bendpointIndex,_=n[v];if(-1!==t.indexOf(_))return a;if(0===g){var b=t[v];return{delta:{x:r=b.x-s.position.x,y:o=b.y-s.position.y},point:{x:e.x+r,y:e.y+o}}}g<0&&0!==v&&v<n.length-1&&(m=Hu(n,v))}var x,w,E={x:(d[1].x-d[0].x)*m+d[0].x,y:(d[1].y-d[0].y)*m+d[0].y},S=(x={x:e.x-f.x,y:e.y-f.y},(w=y)?{x:Math.cos(w)*x.x-Math.sin(w)*x.y,y:Math.sin(w)*x.x+Math.cos(w)*x.y}:x);return r=E.x+S.x-e.x,o=E.y+S.y-e.y,{point:pn(E),delta:pn({x:r,y:o})}}function Hu(e,t){var n=Pp(e[t-1],e[t]);return n/(n+Pp(e[t],e[t+1]))}function Vu(e,t){return[e[t],e[t+1]]}function Gu(e,t,n){var i=Fa(t),r=Fa(n),o=za(e,i),a=o.x*(n.width/t.width),s=o.y*(n.height/t.height);return pn({x:r.x+a,y:r.y+s})}function Wu(e,t,n){var i=Fa(e),r=Fa(t),o=Fa(n),a=za(e,i),s=za(i,r),c=function(e,t,n){var i=ln(t),r=ln(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,c=fn(t,e);if("top"===c)o={x:0,y:r.bottom-i.bottom};else if("bottom"===c)o={x:0,y:r.top-i.top};else if("right"===c)o={x:r.left-i.left,y:0};else{if("left"!==c)return null;o={x:r.right-i.right,y:0}}if(a={x:e.x+o.x,y:e.y+o.y},s=fn(n,a),s!==c)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 pn({x:u+a.x-e.x,y:h+a.y-e.y})}var Uu="name",qu="text";function Ku(e,t,n,i){function r(e){var n=e.context,r=n.element,o=n.properties;if(Uu in o&&t.updateLabel(r,o[Uu]),qu in o&&mr(r,"bpmn:TextAnnotation")){var a=i.getTextAnnotationBounds({x:r.x,y:r.y,width:r.width,height:r.height},o[qu]||"");t.updateLabel(r,o.text,a)}}function o(e){var t=e.context,n=t.connection,i=n.label,r=L({},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),function(e,t,n,i){return zu(dn(e),t,n,i).delta}(i,o,a,r)}To.call(this,e),this.postExecute("element.updateProperties",r),this.postExecute("element.updateModdleProperties",(e=>{gr(e.context.element)===e.context.moddleElement&&r(e)})),this.postExecute(["shape.create","connection.create"],(function(e){var n=e.context;if(!1!==(n.hints||{}).createElementsBehavior){var i=n.shape||n.connection;!sn(i)&&Fr(i)&&Wr(i)&&t.updateLabel(i,Wr(i))}})),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(["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=o(e),t.moveShape(r,i))}})),this.postExecute(["shape.replace"],(function(e){var t=e.context,n=t.newShape,i=t.oldShape,r=gr(n);r&&Fr(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(zr(r)){var s=r.label,c=function(e,t){if(!t.length)return;var n=function(e,t){var n=t.map((function(t){return{line:t,distance:Rp(e,t)}}));return A(n,"distance")[0].line}(e,t);return kp(e,n)}(dn(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)}]]),p=Yu(c,a,o);t.moveShape(s,p)}}))}function Yu(e,t,n){return pn(za(Gu(e,t,n),e))}function Xu(e,t){function n(e,t){var n=e.context,i=n.connection,r=L({},n.hints),o=n.newWaypoints||i.waypoints,a=n.oldWaypoints;return void 0===r.startChanged&&(r.startChanged=!!r.connectionStart),void 0===r.endChanged&&(r.endChanged=!!r.connectionEnd),function(e,t,n,i){return zu(e,t,n,i).point}(t,o,a,r)}To.call(this,e),this.postExecute(["connection.layout","connection.updateWaypoints"],(function(e){var i=e.context.connection,r=i.outgoing;i.incoming.forEach((function(i){var r=i.waypoints[i.waypoints.length-1],o=n(e,r),a=[].concat(i.waypoints.slice(0,-1),[o]);t.updateWaypoints(i,a)})),r.forEach((function(i){var r=i.waypoints[0],o=n(e,r),a=[].concat([o],i.waypoints.slice(1));t.updateWaypoints(i,a)}))})),this.postExecute(["connection.move"],(function(e){var n=e.context,i=n.connection,r=i.outgoing,o=i.incoming,a=n.delta;o.forEach((function(e){var n=e.waypoints[e.waypoints.length-1],i={x:n.x+a.x,y:n.y+a.y},r=[].concat(e.waypoints.slice(0,-1),[i]);t.updateWaypoints(e,r)})),r.forEach((function(e){var n=e.waypoints[0],i={x:n.x+a.x,y:n.y+a.y},r=[].concat([i],e.waypoints.slice(1));t.updateWaypoints(e,r)}))}))}function Zu(e,t,n){var i=nh(e),r=ih(i,t),o=i[0];return r.length?r[r.length-1]:Gu(o.original||o,n,t)}function Qu(e,t,n){var i=nh(e),r=ih(i,t),o=i[i.length-1];return r.length?r[0]:Gu(o.original||o,n,t)}function Ju(e,t,n){var i=nh(e),r=th(t,n),o=i[0];return Gu(o.original||o,r,t)}function eh(e,t,n){var i=nh(e),r=th(t,n),o=i[i.length-1];return Gu(o.original||o,r,t)}function th(e,t){return{x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}}function nh(e){var t=e.waypoints;if(!t.length)throw new Error("connection#"+e.id+": no waypoints");return t}function ih(e,t){return g(E(e,rh),(function(e){return function(e,t){return"intersect"===fn(t,e,1)}(e,t)}))}function rh(e){return e.original||e}function oh(e,t){To.call(this,e),this.postExecute("shape.replace",(function(e){var n=e.oldShape,i=e.newShape;if(function(e,t){return mr(e,"bpmn:Participant")&&jr(e)&&mr(t,"bpmn:Participant")&&!jr(t)}(n,i)){var r,o,a,s,c=(o=ut([r=n],!1),a=[],s=[],o.forEach((function(e){e!==r&&(e.incoming.forEach((function(e){mr(e,"bpmn:MessageFlow")&&a.push(e)})),e.outgoing.forEach((function(e){mr(e,"bpmn:MessageFlow")&&s.push(e)})))}),[]),{incoming:a,outgoing:s});c.incoming.forEach((function(e){var r=Qu(e,i,n);t.reconnectEnd(e,i,r)})),c.outgoing.forEach((function(e){var r=Zu(e,i,n);t.reconnectStart(e,i,r)}))}}),!0)}e(Ku,To),Ku.$inject=["eventBus","modeling","bpmnFactory","textRenderer"],e(Xu,To),Xu.$inject=["eventBus","modeling"],oh.$inject=["eventBus","modeling"],e(oh,To);const ah=["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:EscalationEventDefinition","bpmn:ConditionalEventDefinition","bpmn:SignalEventDefinition"];function sh(e){const t=gr(e);if(!(mr(t,"bpmn:BoundaryEvent")||mr(t,"bpmn:StartEvent")&&Lr(t.$parent)))return!1;const n=t.get("eventDefinitions");return!(!n||!n.length)&&ah.some((e=>mr(n[0],e)))}function ch(e){return mr(e,"bpmn:BoundaryEvent")?"cancelActivity":"isInterrupting"}function ph(e,t){e.invoke(To,this),this.postExecuted("shape.replace",(function(e){const n=e.context.oldShape,i=e.context.newShape,r=e.context.hints;if(!sh(i))return;const o=ch(i);if(r.targetElement&&void 0!==r.targetElement[o])return;const a=gr(n).get(o);a!==gr(i).get(o)&&t.updateProperties(i,{[o]:a})}))}function lh(e,t){To.call(this,e),this.preExecute("shape.resize",(function(e){var n=e.shape,i=vr(n),r=i&&i.get("label");r&&r.get("bounds")&&t.updateModdleProperties(n,r,{bounds:void 0})}),!0)}function uh(e,t,n){To.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(mr(r,"bpmn:SequenceFlow")&&mr(o,"bpmn:SequenceFlow")&&t.canConnect(r.source,o.target,r)){var a=function(e,t){var n=Ru(hh(e[e.length-2]),hh(e[e.length-1]),hh(t[1]),hh(t[0]));return n?[].concat(e.slice(0,e.length-1),[n],t.slice(1)):[hh(e[0]),hh(t[t.length-1])]}(r.waypoints,o.waypoints);n.reconnectEnd(r,o.target,a)}}}))}function hh(e){return e.original||e}function dh(e,t){To.call(this,e),this.preExecute("shape.delete",(function(e){var t=e.shape,n=t.parent;mr(t,"bpmn:Participant")&&(e.collaborationRoot=n)}),!0),this.postExecute("shape.delete",(function(e){var n=e.collaborationRoot;if(n&&!n.businessObject.participants.length){var i=t.makeProcess(),r=n.children.slice();t.moveElements(r,{x:0,y:0},i)}}),!0)}function fh(e,t,n,i){To.call(this,e);var r=i.get("dragging",!1);function o(e){var i,r,o=e.source,a=e.target;e.parent&&(mr(e,"bpmn:SequenceFlow")&&(n.canConnectSequenceFlow(o,a)||(r=!0),n.canConnectMessageFlow(o,a)&&(i="bpmn:MessageFlow")),mr(e,"bpmn:MessageFlow")&&(n.canConnectMessageFlow(o,a)||(r=!0),n.canConnectSequenceFlow(o,a)&&(i="bpmn:SequenceFlow")),r&&t.removeConnection(e),i&&t.connect(o,a,{type:i,waypoints:e.waypoints.slice()}))}this.postExecuted("elements.move",(function(e){v(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,associationDirection:i.associationDirection,waypoints:s.waypoints.slice()}),s.parent&&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=m(o.outgoing,M({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 mh(e,t,n,i,r,o){i.invoke(To,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=b(r,(function(e,n){var r=t.canReplace([n],n.host||n.parent||i);return r?e.concat(r.replacements):e}),[]);o.length&&this._replaceElements(r,o)}),this),this.postExecuted(["elements.move"],500,(function(e){var n=e.context,i=n.newParent,r=n.newHost,o=[];v(n.closure.topLevel,(function(e){o=Lr(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})}))}ph.$inject=["injector","modeling"],e(ph,To),e(lh,To),lh.$inject=["eventBus","modeling"],e(uh,To),uh.$inject=["eventBus","bpmnRules","modeling"],dh.$inject=["eventBus","modeling"],e(dh,To),e(fh,To),fh.$inject=["eventBus","modeling","bpmnRules","injector"],e(mh,To),mh.prototype._replaceElements=function(e,t){var n=this._elementRegistry,i=this._bpmnReplace,r=this._selection;v(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)},mh.$inject=["bpmnReplace","bpmnRules","elementRegistry","injector","modeling","selection"];var yh={width:140,height:120},gh={width:300,height:60},vh={width:60,height:300},_h={width:300,height:150},bh={width:150,height:300},xh={width:140,height:120},wh={width:50,height:30};function Eh(e){e.on("resize.start",1500,(function(e){var t=e.context,n=t.shape,i=t.direction,r=t.balanced;(mr(n,"bpmn:Lane")||mr(n,"bpmn:Participant"))&&(t.resizeConstraints=function(e,t,n){var i=fu(e),r=!0,o=!0,a=hu(i,[i]),s=ln(e),c={},p={},l=Or(e),u=l?gh:vh;/n/.test(t)?p.top=s.bottom-u.height:/e/.test(t)?p.right=s.left+u.width:/s/.test(t)?p.bottom=s.top+u.height:/w/.test(t)&&(p.left=s.right-u.width);a.forEach((function(e){var i=ln(e);l?(i.top<s.top-10&&(r=!1),i.bottom>s.bottom+10&&(o=!1)):(i.left<s.left-10&&(r=!1),i.right>s.right+10&&(o=!1)),/n/.test(t)&&(n&&Sh(s.top-i.bottom)<10&&Ah(c,"top",i.top+u.height),Sh(s.top-i.top)<5&&Ph(p,"top",i.bottom-u.height)),/e/.test(t)&&(n&&Sh(s.right-i.left)<10&&Ph(c,"right",i.right-u.width),Sh(s.right-i.right)<5&&Ah(p,"right",i.left+u.width)),/s/.test(t)&&(n&&Sh(s.bottom-i.top)<10&&Ph(c,"bottom",i.bottom-u.height),Sh(s.bottom-i.bottom)<5&&Ah(p,"bottom",i.top+u.height)),/w/.test(t)&&(n&&Sh(s.left-i.right)<10&&Ah(c,"left",i.left+u.width),Sh(s.left-i.left)<5&&Ph(p,"left",i.right-u.width))}));var h=i.children.filter((function(e){return!e.hidden&&!e.waypoints&&(mr(e,"bpmn:FlowElement")||mr(e,"bpmn:Artifact"))})),d=l?Mh:Th;return h.forEach((function(e){var n=ln(e);!/n/.test(t)||l&&!r||Ph(p,"top",n.top-d.top),/e/.test(t)&&(l||o)&&Ah(p,"right",n.right+d.right),!/s/.test(t)||l&&!o||Ah(p,"bottom",n.bottom+d.bottom),/w/.test(t)&&(l||r)&&Ph(p,"left",n.left-d.left)})),{min:p,max:c}}(n,i,r)),mr(n,"bpmn:SubProcess")&&jr(n)&&(t.minDimensions=xh),mr(n,"bpmn:TextAnnotation")&&(t.minDimensions=wh)}))}Eh.$inject=["eventBus"];var Sh=Math.abs,Ch=Math.min,kh=Math.max;function Rh(e,t,n,i){var r=e[t];e[t]=void 0===r?n:i(n,r)}function Ph(e,t,n){return Rh(e,t,n,Ch)}function Ah(e,t,n){return Rh(e,t,n,kh)}var Mh={top:20,left:50,right:20,bottom:20},Th={top:50,left:20,right:20,bottom:20};function Bh(e,t){e.on("resize.start",1501,(function(e){var t=e.context,n=t.shape;(mr(n,"bpmn:Lane")||mr(n,"bpmn:Participant"))&&(t.balanced=!sa(e))})),e.on("resize.end",1001,(function(e){var n=e.context,i=n.shape,r=n.canExecute,o=n.newBounds;if(mr(i,"bpmn:Lane")||mr(i,"bpmn:Participant"))return r&&(o=cn(o),t.resizeLane(i,o,n.balanced)),!1}))}Bh.$inject=["eventBus","modeling"];function Dh(e,t,n,i,r){function o(e){return yr(e,["bpmn:ReceiveTask","bpmn:SendTask"])||function(e,t){p(t)||(t=[t]);return w(t,(function(t){return $r(e,t)}))}(e,["bpmn:ErrorEventDefinition","bpmn:EscalationEventDefinition","bpmn:MessageEventDefinition","bpmn:SignalEventDefinition"])}function a(t){return!!m(e.getDefinitions().get("rootElements"),M({id:t.id}))}function s(e){return mr(e,"bpmn:ErrorEventDefinition")?"errorRef":mr(e,"bpmn:EscalationEventDefinition")?"escalationRef":mr(e,"bpmn:MessageEventDefinition")?"messageRef":mr(e,"bpmn:SignalEventDefinition")?"signalRef":void 0}function c(e){if(yr(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.get("messageRef");var t=e.get("eventDefinitions")[0];return t.get(s(t))}n.invoke(To,this),this.executed(["shape.create","element.updateProperties","element.updateModdleProperties"],(function(t){var n=t.shape||t.element;if(o(n)){var i=c(gr(n));i&&!a(i)&&(_t(e.getDefinitions().get("rootElements"),i),t.addedRootElement=i)}}),!0),this.reverted(["shape.create","element.updateProperties","element.updateModdleProperties"],(function(t){var n=t.addedRootElement;n&&vt(e.getDefinitions().get("rootElements"),n)}),!0),t.on("copyPaste.copyElement",(function(e){var t=e.descriptor,n=e.element;if(!n.labelTarget&&o(n)){var i=c(gr(n));i&&(t.referencedRootElement=i)}})),t.on("copyPaste.pasteElement",500,(function(e){var t=e.descriptor,n=t.businessObject,o=t.referencedRootElement;o&&(a(o)||(o=i.copyElement(o,r.create(o.$type))),function(e,t){if(yr(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.set("messageRef",t);var n=e.get("eventDefinitions")[0];n.set(s(n),t)}(n,o),delete t.referencedRootElement)}))}Dh.$inject=["bpmnjs","eventBus","injector","moddleCopy","bpmnFactory"],e(Dh,To);var Nh=Math.max;function jh(e){e.on("spaceTool.getMinDimensions",(function(e){var t=e.shapes,n=e.axis,i=e.start,r={};return v(t,(function(e){var t=e.id;mr(e,"bpmn:Participant")&&(r[t]=function(e,t,n){var i=Or(e);if(r=e,!du(r).length)return i?_h:bh;var r;var o=function(e){return"x"===e}(t),a={};a=o?i?_h:{width:Lh(e,n,o),height:bh.height}:i?{width:_h.width,height:Oh(e,n,o)}:bh;return a}(e,n,i)),mr(e,"bpmn:Lane")&&(r[t]=Or(e)?gh:vh),mr(e,"bpmn:SubProcess")&&jr(e)&&(r[t]=xh),mr(e,"bpmn:TextAnnotation")&&(r[t]=wh),mr(e,"bpmn:Group")&&(r[t]=yh)})),r}))}function Oh(e,t,n){var i;return i=function(e,t,n){var i,r=du(e);return i=$h(r,t,n),e.height-i.height+gh.height}(e,t,n),Nh(_h.height,i)}function Lh(e,t,n){var i;return i=function(e,t,n){var i,r=du(e);return i=$h(r,t,n),e.width-i.width+vh.width}(e,t,n),Nh(bh.width,i)}function $h(e,t,n){var i,r,o;for(i=0;i<e.length;i++)if(r=e[i],!n&&t>=r.y&&t<=r.y+r.height||n&&t>=r.x&&t<=r.x+r.width)return(o=du(r)).length?$h(o,t,n):r}jh.$inject=["eventBus"];var Ih=180,Fh=160;function zh(e,t,n,i,r,o,a){To.call(this,t),this._canvas=e,this._eventBus=t,this._modeling=n,this._elementFactory=i,this._bpmnFactory=r,this._bpmnjs=o,this._elementRegistry=a;var s=this;function c(e){return mr(e,"bpmn:SubProcess")&&!jr(e)}function p(t){var n=t.shape,i=t.newRootElement,r=gr(n);i=s._addDiagram(i||r),t.newRootElement=e.addRootElement(i)}function l(t){var n=gr(t.shape);s._removeDiagram(n);var i=t.newRootElement=a.get(Fo(n));e.removeRootElement(i)}this.executed("shape.create",(function(e){c(e.shape)&&p(e)}),!0),this.postExecuted("shape.create",(function(e){var t=e.shape,n=e.newRootElement;n&&t.children&&(s._showRecursively(t.children),s._moveChildrenToShape(t,n))}),!0),this.reverted("shape.create",(function(e){c(e.shape)&&l(e)}),!0),this.preExecuted("shape.delete",(function(e){var t=e.shape;if(c(t)){var i=a.get(Fo(t));i&&n.removeElements(i.children.slice())}}),!0),this.executed("shape.delete",(function(e){c(e.shape)&&l(e)}),!0),this.reverted("shape.delete",(function(e){c(e.shape)&&p(e)}),!0),this.preExecuted("shape.replace",(function(t){var n=t.oldShape,i=t.newShape;c(n)&&c(i)&&(t.oldRoot=e.removeRootElement(Fo(n)))}),!0),this.postExecuted("shape.replace",(function(t){var i=t.newShape,r=t.oldRoot,o=e.findRoot(Fo(i));if(r&&o){var a=r.children;n.moveElements(a,{x:0,y:0},o)}}),!0),this.executed("element.updateProperties",(function(e){var t=e.element;if(mr(t,"bpmn:SubProcess")){var n=e.properties,i=e.oldProperties.id,r=n.id;if(i!==r){if(Ho(t))return a.updateId(t,zo(r)),void a.updateId(i,r);a.get(zo(i))&&a.updateId(zo(i),zo(r))}}}),!0),this.reverted("element.updateProperties",(function(e){var t=e.element;if(mr(t,"bpmn:SubProcess")){var n=e.properties,i=e.oldProperties.id,r=n.id;if(i!==r){if(Ho(t))return a.updateId(t,zo(i)),void a.updateId(r,i);var o=a.get(zo(r));o&&a.updateId(o,zo(i))}}}),!0),t.on("element.changed",(function(e){var n=e.element;if(Ho(n)){var i=n,r=a.get(Io(i));r&&r!==i&&t.fire("element.changed",{element:r})}})),this.executed("shape.toggleCollapse",400,(function(e){var t=e.shape;mr(t,"bpmn:SubProcess")&&(jr(t)?l(e):(p(e),s._showRecursively(t.children)))}),!0),this.reverted("shape.toggleCollapse",400,(function(e){var t=e.shape;mr(t,"bpmn:SubProcess")&&(jr(t)?l(e):(p(e),s._showRecursively(t.children)))}),!0),this.postExecuted("shape.toggleCollapse",600,(function(e){var t=e.shape;if(mr(t,"bpmn:SubProcess")){var n=e.newRootElement;n&&(jr(t)?s._moveChildrenToShape(n,t):s._moveChildrenToShape(t,n))}}),!0),t.on("copyPaste.createTree",(function(e){var t=e.element,n=e.children;if(c(t)){var i=Fo(t),r=a.get(i);r&&n.push.apply(n,r.children)}})),t.on("copyPaste.copyElement",(function(e){var t=e.descriptor,n=e.element,i=e.elements,r=n.parent;if(mr(vr(r),"bpmndi:BPMNPlane")){var o=Io(r),a=m(i,(function(e){return e.id===o}));a&&(t.parent=a.id)}})),t.on("copyPaste.pasteElement",(function(e){var t=e.descriptor;t.parent&&(c(t.parent)||t.parent.hidden)&&(t.hidden=!0)}))}function Hh(e,t){e.invoke(To,this),this.postExecuted("shape.replace",(function(e){var n=e.context.oldShape,i=e.context.newShape;if(mr(i,"bpmn:SubProcess")&&(mr(n,"bpmn:Task")||mr(n,"bpmn:CallActivity"))&&jr(i)){var r,o={x:(r=i).x+r.width/6,y:r.y+r.height/2};t.createShape({type:"bpmn:StartEvent"},o,i)}}))}function Vh(e){To.call(this,e),this.preExecute("connection.create",(function(e){const{target:t}=e;mr(t,"bpmn:TextAnnotation")&&(e.parent=t.parent)}),!0),this.preExecute(["shape.create","shape.resize","elements.move"],(function(e){const t=e.shapes||[e.shape];1===t.length&&mr(t[0],"bpmn:TextAnnotation")&&(e.hints=e.hints||{},e.hints.autoResize=!1)}),!0)}function Gh(e,t){To.call(this,e),this.postExecuted("shape.toggleCollapse",1500,(function(e){var n=e.shape;if(!jr(n)){var i=ut(n);i.forEach((function(e){var t=e.incoming.slice(),n=e.outgoing.slice();v(t,(function(e){r(e,!0)})),v(n,(function(e){r(e,!1)}))}))}function r(e,r){-1!==i.indexOf(e.source)&&-1!==i.indexOf(e.target)||(r?t.reconnectEnd(e,n,dn(n)):t.reconnectStart(e,n,dn(n)))}}),!0)}e(zh,To),zh.prototype._moveChildrenToShape=function(e,t){var n,i=this._modeling,r=e.children;if(r){var o=(r=r.concat(r.reduce((function(t,n){return n.label&&n.label.parent!==e?t.concat(n.label):t}),[]))).filter((function(e){return!e.hidden}));if(o.length){var a=ht(o);if(t.x){var s=dn(t),c=dn(a);n={x:s.x-c.x,y:s.y-c.y}}else n={x:Ih-a.x,y:Fh-a.y};i.moveElements(r,n,t,{autoResize:!1})}else i.moveElements(r,{x:0,y:0},t,{autoResize:!1})}},zh.prototype._showRecursively=function(e,t){var n=this,i=[];return e.forEach((function(e){e.hidden=!!t,i=i.concat(e),e.children&&(i=i.concat(n._showRecursively(e.children,e.collapsed||t)))})),i},zh.prototype._addDiagram=function(e){var t=this._bpmnjs.getDefinitions().diagrams;return e.businessObject||(e=this._createNewDiagram(e)),t.push(e.di.$parent),e},zh.prototype._createNewDiagram=function(e){var t=this._bpmnFactory,n=this._elementFactory,i=t.create("bpmndi:BPMNPlane",{bpmnElement:e}),r=t.create("bpmndi:BPMNDiagram",{plane:i});return i.$parent=r,n.createRoot({id:Fo(e),type:e.$type,di:i,businessObject:e,collapsed:!0})},zh.prototype._removeDiagram=function(e){var t=this._bpmnjs.getDefinitions().diagrams,n=m(t,(function(t){return t.plane.bpmnElement.id===e.id}));return t.splice(t.indexOf(n),1),n},zh.$inject=["canvas","eventBus","modeling","elementFactory","bpmnFactory","bpmnjs","elementRegistry"],Hh.$inject=["injector","modeling"],e(Hh,To),e(Vh,To),Vh.$inject=["eventBus"],e(Gh,To),Gh.$inject=["eventBus","modeling"];function Wh(e,t,n){To.call(this,e),this.executed(["shape.toggleCollapse"],500,(function(e){var t,n=e.context.shape;mr(n,"bpmn:SubProcess")&&(n.collapsed?vr(n).isExpanded=!1:((t=n.children).length&&t.forEach((function(e){"label"!==e.type||e.businessObject.name||(e.hidden=!0)})),vr(n).isExpanded=!0))})),this.reverted(["shape.toggleCollapse"],500,(function(e){var t=e.context.shape;t.collapsed?vr(t).isExpanded=!1:vr(t).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,o=e.children,a=t;return n=(r=o,r.filter((function(e){return!e.hidden}))).concat([e]),(i=cu(n))?(a.width=Math.max(i.width,a.width),a.height=Math.max(i.height,a.height),a.x=i.x+(i.width-a.width)/2,a.y=i.y+(i.height-a.height)/2):(a.x=e.x+(e.width-a.width)/2,a.y=e.y+(e.height-a.height)/2),a}(r,o),n.resizeShape(r,i,null,{autoResize:!r.collapsed&&"nwse"})}))}function Uh(e,t,n,i){t.invoke(To,this),this.preExecute("shape.delete",(function(e){var t=e.context.shape,r=t.businessObject;sn(t)||(mr(t,"bpmn:Participant")&&jr(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;mr(t,"bpmn:Collaboration")&&n.ids.unclaim(i.id)}))}function qh(e,t){To.call(this,e),this.preExecute("connection.delete",(function(e){var n=e.context.connection,i=n.source;(function(e,t){if(!mr(e,"bpmn:SequenceFlow"))return!1;var n=gr(t),i=gr(e);return n.get("default")===i})(n,i)&&t.updateProperties(i,{default:null})}))}e(Wh,To),Wh.$inject=["eventBus","elementFactory","modeling"],e(Uh,To),Uh.$inject=["canvas","injector","moddle","modeling"],e(qh,To),qh.$inject=["eventBus","modeling"];function Kh(e,t){var n;function i(){if(!n)throw new Error("out of bounds release");return n}To.call(this,e);var r=["spaceTool","lane.add","lane.resize","lane.split","elements.create","elements.delete","elements.move","shape.create","shape.delete","shape.move","shape.resize"];this.preExecute(r,5e3,(function(e){(n=n||new Yh).enter()})),this.postExecuted(r,500,(function(e){!function(){if(!n)throw new Error("out of bounds release");var e=n.leave();e&&(t.updateLaneRefs(n.flowNodes,n.lanes),n=null)}()})),this.preExecute(["shape.create","shape.move","shape.delete","shape.resize"],(function(e){var t=e.context.shape,n=i();t.labelTarget||(mr(t,"bpmn:Lane")&&n.addLane(t),mr(t,"bpmn:FlowNode")&&n.addFlowNode(t))}))}function Yh(){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 Xh(e,t){To.call(this,e),this.postExecuted("elements.create",(function(e){const n=e.context.elements;for(const e of n)Zh(e)&&!Qh(e)&&t.updateProperties(e,{isForCompensation:void 0})}))}function Zh(e){const t=gr(e);return t&&t.isForCompensation}function Qh(e){return e.incoming.filter((e=>function(e){return e&&mr(e,"bpmn:BoundaryEvent")&&$r(e,"bpmn:CompensateEventDefinition")}(e.source))).length>0}Kh.$inject=["eventBus","modeling"],e(Kh,To),e(Xh,To),Xh.$inject=["eventBus","modeling"];var Jh={__init__:["adaptiveLabelPositioningBehavior","appendBehavior","associationBehavior","attachEventBehavior","boundaryEventBehavior","compensateBoundaryEventBehaviour","createBehavior","createDataObjectBehavior","createParticipantBehavior","dataInputAssociationBehavior","dataStoreBehavior","deleteLaneBehavior","detachEventBehavior","dropOnFlowBehavior","eventBasedGatewayBehavior","fixHoverBehavior","groupBehavior","importDockingFix","isHorizontalFix","labelBehavior","layoutConnectionBehavior","messageFlowBehavior","nonInterruptingBehavior","removeElementBehavior","removeEmbeddedLabelBoundsBehavior","removeParticipantBehavior","replaceConnectionBehavior","replaceElementBehaviour","resizeBehavior","resizeLaneBehavior","rootElementReferenceBehavior","spaceToolBehavior","subProcessPlaneBehavior","subProcessStartEventBehavior","textAnnotationBehavior","toggleCollapseConnectionBehaviour","toggleElementCollapseBehaviour","unclaimIdBehavior","updateFlowNodeRefsBehavior","unsetDefaultFlowBehavior","setCompensationActivityAfterPasteBehavior"],adaptiveLabelPositioningBehavior:["type",Nl],appendBehavior:["type",Ol],associationBehavior:["type",Ll],attachEventBehavior:["type",$l],boundaryEventBehavior:["type",Fl],compensateBoundaryEventBehaviour:["type",zl],createBehavior:["type",Wl],createDataObjectBehavior:["type",Ul],createParticipantBehavior:["type",Xl],dataInputAssociationBehavior:["type",Ql],dataStoreBehavior:["type",tu],deleteLaneBehavior:["type",yu],detachEventBehavior:["type",gu],dropOnFlowBehavior:["type",_u],eventBasedGatewayBehavior:["type",wu],fixHoverBehavior:["type",Cu],groupBehavior:["type",ku],importDockingFix:["type",Pu],isHorizontalFix:["type",Mu],labelBehavior:["type",Ku],layoutConnectionBehavior:["type",Xu],messageFlowBehavior:["type",oh],nonInterruptingBehavior:["type",ph],removeElementBehavior:["type",uh],removeEmbeddedLabelBoundsBehavior:["type",lh],removeParticipantBehavior:["type",dh],replaceConnectionBehavior:["type",fh],replaceElementBehaviour:["type",mh],resizeBehavior:["type",Eh],resizeLaneBehavior:["type",Bh],rootElementReferenceBehavior:["type",Dh],spaceToolBehavior:["type",jh],subProcessPlaneBehavior:["type",zh],subProcessStartEventBehavior:["type",Hh],textAnnotationBehavior:["type",Vh],toggleCollapseConnectionBehaviour:["type",Gh],toggleElementCollapseBehaviour:["type",Wh],unclaimIdBehavior:["type",Uh],unsetDefaultFlowBehavior:["type",qh],updateFlowNodeRefsBehavior:["type",Kh],setCompensationActivityAfterPasteBehavior:["type",Xh]};function ed(e,t){var n=fn(e,t,-15);return"intersect"!==n?n:null}function td(e){zc.call(this,e)}function nd(e){return!e||sn(e)}function id(e){do{if(mr(e,"bpmn:Process"))return gr(e);if(mr(e,"bpmn:Participant"))return gr(e).processRef||gr(e)}while(e=e.parent)}function rd(e){return mr(e,"bpmn:TextAnnotation")}function od(e){return mr(e,"bpmn:Group")&&!e.labelTarget}function ad(e){return mr(e,"bpmn:BoundaryEvent")&&ld(e,"bpmn:CompensateEventDefinition")}function sd(e){return gr(e).isForCompensation}function cd(e){for(var t=e;t=t.parent;){if(mr(t,"bpmn:FlowElementsContainer"))return gr(t);if(mr(t,"bpmn:Participant"))return gr(t).processRef}return null}function pd(e,t){return cd(e)===cd(t)}function ld(e,t){return!!m(gr(e).eventDefinitions||[],(function(e){return mr(e,t)}))}function ud(e,t){return(gr(e).eventDefinitions||[]).every((function(e){return mr(e,t)}))}function hd(e,t){var n=function(e){for(var t=[];e;)(e=e.parent)&&t.push(e);return t}(t);return-1!==n.indexOf(e)}function dd(e,t,n){if(nd(e)||nd(t))return null;if(!mr(n,"bpmn:DataAssociation")){if(Rd(e,t))return{type:"bpmn:MessageFlow"};if(Pd(e,t))return{type:"bpmn:SequenceFlow"}}var i=Ad(e,t);return i||(kd(e,t)?{type:"bpmn:Association",associationDirection:"One"}:!!Cd(e,t)&&{type:"bpmn:Association",associationDirection:"None"})}function fd(e,t){return!(!sn(e)&&!od(e))||!(mr(t,"bpmn:Participant")&&!jr(t))&&(mr(e,"bpmn:Participant")?mr(t,"bpmn:Process")||mr(t,"bpmn:Collaboration"):yr(e,["bpmn:DataInput","bpmn:DataOutput"])&&e.parent?t===e.parent:mr(e,"bpmn:Lane")?mr(t,"bpmn:Participant")||mr(t,"bpmn:Lane"):!(mr(e,"bpmn:BoundaryEvent")&&!function(e){return gr(e).cancelActivity&&(gd(e)||vd(e))}(e))&&(mr(e,"bpmn:FlowElement")&&!mr(e,"bpmn:DataStoreReference")?mr(t,"bpmn:FlowElementsContainer")?jr(t):yr(t,["bpmn:Participant","bpmn:Lane"]):mr(e,"bpmn:DataStoreReference")&&mr(t,"bpmn:Collaboration")?w(gr(t).get("participants"),(function(e){return!!e.get("processRef")})):yr(e,["bpmn:Artifact","bpmn:DataAssociation","bpmn:DataStoreReference"])?yr(t,["bpmn:Collaboration","bpmn:Lane","bpmn:Participant","bpmn:Process","bpmn:SubProcess"]):!!mr(e,"bpmn:MessageFlow")&&(mr(t,"bpmn:Collaboration")||e.source.parent==t||e.target.parent==t)))}function md(e){return mr(e,"bpmn:Lane")}function yd(e){return!!function(e){return!sn(e)&&mr(e,"bpmn:BoundaryEvent")}(e)||(!(!mr(e,"bpmn:IntermediateThrowEvent")||!gd(e))||mr(e,"bpmn:IntermediateCatchEvent")&&vd(e))}function gd(e){var t=gr(e);return t&&!(t.eventDefinitions&&t.eventDefinitions.length)}function vd(e){return _d(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])}function _d(e,t){return t.some((function(t){return ld(e,t)}))}function bd(e,t,n,i){if(Array.isArray(e)||(e=[e]),1!==e.length)return!1;var r=e[0];return!sn(r)&&(!!yd(r)&&(!Lr(t)&&(!(!mr(t,"bpmn:Activity")||sd(t))&&(!(i&&!ed(i,t))&&(!function(e){return mr(e,"bpmn:ReceiveTask")&&m(e.incoming,(function(e){return mr(e.source,"bpmn:EventBasedGateway")}))}(t)&&"attach")))))}function xd(e,t,n){if(!t)return!1;var i={replacements:[]};return v(e,(function(e){Lr(t)||mr(e,"bpmn:StartEvent")&&"label"!==e.type&&fd(e,t)&&(function(e){return e&&!1!==gr(e).isInterrupting}(e)||i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),(function(e){return $r(e,"bpmn:ErrorEventDefinition")}(e)||function(e){return $r(e,"bpmn:EscalationEventDefinition")}(e)||function(e){return $r(e,"bpmn:CompensateEventDefinition")}(e))&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),_d(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])&&mr(t,"bpmn:SubProcess")&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"})),mr(t,"bpmn:Transaction")||ld(e,"bpmn:CancelEventDefinition")&&"label"!==e.type&&(mr(e,"bpmn:EndEvent")&&fd(e,t)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:EndEvent"}),mr(e,"bpmn:BoundaryEvent")&&bd(e,t,0,n)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:BoundaryEvent"}))})),!!i.replacements.length&&i}function wd(e,t){return!w(e,md)&&(!t||e.every((function(e){return fd(e,t)})))}function Ed(e,t,n,i){return!!t&&(!(!sn(e)&&!od(e))||!function(e,t){return e===t}(n,t)&&((!n||!hd(n,t))&&(fd(e,t)||Md(e,t))))}function Sd(e,t){return mr(e,"bpmn:SubProcess")?jr(e)&&(!t||t.width>=100&&t.height>=80):!!mr(e,"bpmn:Lane")||(!!mr(e,"bpmn:Participant")||(!!rd(e)||!!od(e)))}function Cd(e,t){return!hd(t,e)&&!hd(e,t)&&(!!function(e,t){var n=rd(e),i=rd(t);return(n||i)&&n!==i}(e,t)||!!Ad(e,t))}function kd(e,t){return pd(e,t)&&ad(e)&&mr(t,"bpmn:Activity")&&(n=e,!t.attachers.includes(n))&&!Lr(t);var n}function Rd(e,t){return!(Bd(e)&&!Bd(t))&&(mr(n=e,"bpmn:InteractionNode")&&!mr(n,"bpmn:BoundaryEvent")&&(!mr(n,"bpmn:Event")||mr(n,"bpmn:ThrowEvent")&&ud(n,"bpmn:MessageEventDefinition"))&&function(e){return mr(e,"bpmn:InteractionNode")&&!sd(e)&&(!mr(e,"bpmn:Event")||mr(e,"bpmn:CatchEvent")&&ud(e,"bpmn:MessageEventDefinition"))&&!(mr(e,"bpmn:BoundaryEvent")&&!ld(e,"bpmn:MessageEventDefinition"))}(t)&&!function(e,t){return id(e)===id(t)}(e,t));var n}function Pd(e,t){return mr(n=e,"bpmn:FlowNode")&&!mr(n,"bpmn:EndEvent")&&!Lr(n)&&!(mr(n,"bpmn:IntermediateThrowEvent")&&ld(n,"bpmn:LinkEventDefinition"))&&!ad(n)&&!sd(n)&&function(e){return mr(e,"bpmn:FlowNode")&&!mr(e,"bpmn:StartEvent")&&!mr(e,"bpmn:BoundaryEvent")&&!Lr(e)&&!(mr(e,"bpmn:IntermediateCatchEvent")&&ld(e,"bpmn:LinkEventDefinition"))&&!sd(e)}(t)&&pd(e,t)&&!(mr(e,"bpmn:EventBasedGateway")&&!function(e){return mr(e,"bpmn:ReceiveTask")||mr(e,"bpmn:IntermediateCatchEvent")&&(ld(e,"bpmn:MessageEventDefinition")||ld(e,"bpmn:TimerEventDefinition")||ld(e,"bpmn:ConditionalEventDefinition")||ld(e,"bpmn:SignalEventDefinition"))}(t));var n}function Ad(e,t){return yr(e,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&yr(t,["bpmn:Activity","bpmn:ThrowEvent"])?{type:"bpmn:DataInputAssociation"}:!(!yr(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])||!yr(e,["bpmn:Activity","bpmn:CatchEvent"]))&&{type:"bpmn:DataOutputAssociation"}}function Md(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&&(yr(t,["bpmn:SequenceFlow","bpmn:MessageFlow"])&&!sn(t)&&mr(e,"bpmn:FlowNode")&&!mr(e,"bpmn:BoundaryEvent")&&fd(e,t.parent))}function Td(e,t){return!!sn(t)||!(mr(t,"bpmn:Lane")&&!function(e,t){return e&&t&&-1!==e.indexOf(t)}(e,t.parent))}function Bd(e){return Qc(e,"bpmn:Process")||Qc(e,"bpmn:Collaboration")}e(td,zc),td.$inject=["eventBus"],td.prototype.init=function(){this.addRule("connection.start",(function(e){return function(e){if(nd(e))return null;return yr(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 dd(t,n)}finally{r&&(n.parent=null)}})),this.addRule("connection.reconnect",(function(e){var t=e.connection;return dd(e.source,e.target,t)})),this.addRule("connection.updateWaypoints",(function(e){return{type:e.connection.type}})),this.addRule("shape.resize",(function(e){return Sd(e.shape,e.newBounds)})),this.addRule("elements.create",(function(e){var t=e.elements,n=e.position,i=e.target;return!(an(i)&&!Md(t,i))&&x(t,(function(e){return an(e)?dd(e.source,e.target,e):e.host?bd(e,e.host,null,n):Ed(e,i,null)}))})),this.addRule("elements.move",(function(e){var t=e.target,n=e.shapes,i=e.position;return bd(n,t,null,i)||xd(n,t,i)||wd(n,t)||Md(n,t)})),this.addRule("shape.create",(function(e){return Ed(e.shape,e.target,e.source,e.position)})),this.addRule("shape.attach",(function(e){return bd(e.shape,e.target,null,e.position)})),this.addRule("element.copy",(function(e){var t=e.element;return Td(e.elements,t)}))},td.prototype.canConnectMessageFlow=Rd,td.prototype.canConnectSequenceFlow=Pd,td.prototype.canConnectDataAssociation=Ad,td.prototype.canConnectAssociation=Cd,td.prototype.canConnectCompensationAssociation=kd,td.prototype.canMove=wd,td.prototype.canAttach=bd,td.prototype.canReplace=xd,td.prototype.canDrop=fd,td.prototype.canInsert=Md,td.prototype.canCreate=Ed,td.prototype.canConnect=dd,td.prototype.canResize=Sd,td.prototype.canCopy=Td;var Dd={__depends__:[bp],__init__:["bpmnRules"],bpmnRules:["type",td]};function Nd(e,t){e.on("saveXML.start",2e3,(function(){v(t.getRootElements(),(function(e){var t,n=vr(e);t=E(g(ut([e],!1),(function(t){return t!==e&&!t.labelTarget})),vr),n.set("planeElement",t)}))}))}Nd.$inject=["eventBus","canvas"];var jd={__init__:["bpmnDiOrdering"],bpmnDiOrdering:["type",Nd]};function Od(e){To.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 Ld(e,t){Od.call(this,e);var n=[{type:"bpmn:SubProcess",order:{level:6}},{type:"bpmn:SequenceFlow",order:{level:9,containers:["bpmn:Participant","bpmn:FlowElementsContainer"]}},{type:"bpmn:DataAssociation",order:{level:9,containers:["bpmn:Collaboration","bpmn:FlowElementsContainer"]}},{type:"bpmn:TextAnnotation",order:{level:9}},{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:FlowElementsContainer"]}},{type:"bpmn:FlowElement",order:{level:5}},{type:"bpmn:Participant",order:{level:-2}},{type:"bpmn:Lane",order:{level:-1}}];function i(e){var t=e.order;if(t||(e.order=t=function(e){if(e.labelTarget)return{level:10};var t=m(n,(function(t){return yr(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||mr(e,"bpmn:TextAnnotation"))return{parent:t.findRoot(n)||t.getRootElement(),index:-1};var r=i(e);r.containers&&(n=function(e,t,n){for(var i=t;i&&!yr(i,n);)i=i.parent;if(!i)throw new Error(`no parent for <${e.id}> in <${t&&t.id}>`);return i}(e,n,r.containers));var o=n.children.indexOf(e),a=y(n.children,(function(t){return!(!e.labelTarget&&t.labelTarget)&&r.level<i(t).level}));return-1!==a&&-1!==o&&o<a&&(a-=1),{index:a,parent:n}}}Od.prototype.getOrdering=function(e,t){return null},e(Od,To),Ld.$inject=["eventBus","canvas"],e(Ld,Od);var $d={__init__:["bpmnOrderingProvider"],bpmnOrderingProvider:["type",Ld]};function Id(){}Id.prototype.get=function(){return this._data},Id.prototype.set=function(e){this._data=e},Id.prototype.clear=function(){var e=this._data;return delete this._data,e},Id.prototype.isEmpty=function(){return!this._data};var Fd={clipboard:["type",Id]},zd="drop-ok",Hd="drop-not-ok",Vd="attach-ok",Gd="new-parent",Wd="create";function Ud(e,t,n,i,r){function o(t,n){[Vd,zd,Hd,Gd].forEach((function(i){i===n?e.addMarker(t,i):e.removeMarker(t,i)}))}function a(){var e=t.context();e&&e.prefix===Wd&&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);qd(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=m(e=g(e,(function(t){var n=t.labelTarget;return!(t.parent||sn(t)&&-1!==e.indexOf(n))})),(function(e){return!an(e)})),s=!1,c=!1,p=!1;Kd(e)&&(s=r.allowed("shape.attach",{position:n,shape:a,target:t})),s||(p=Kd(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,Vd):o(i,p?Gd:Hd))})),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;qd(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}):m(o=i.createElements(o,u,a,L({},l,{attach:c})),(function(e){return!an(e)})),L(t,{elements:o,shape:r}),L(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){p(n)||(n=[n]);var r=m(n,(function(e){return!an(e)}));if(r){i=L({elements:n,hints:{},shape:r},i||{}),v(n,(function(e){u(e.x)||(e.x=0),u(e.y)||(e.y=0)}));var o=ht(g(n,(function(e){return!e.hidden})));v(n,(function(e){an(e)&&(e.waypoints=E(e.waypoints,(function(e){return{x:e.x-o.x-o.width/2,y:e.y-o.y-o.height/2}}))),L(e,{x:e.x-o.x-o.width/2,y:e.y-o.y-o.height/2})})),t.init(e,Wd,{cursor:"grabbing",autoActivate:!0,data:{shape:r,elements:n,context:i}})}}}function qd(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 Kd(e){return e&&1===e.length&&!an(e[0])}Ud.$inject=["canvas","dragging","eventBus","modeling","rules"];function Yd(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=Ae("g");be(t,r.cls("djs-drag-group",["no-events"]));var o=Ae("g");return e.forEach((function(e){var r;e.hidden||(e.waypoints?(r=n._createContainer("connection",o),n.drawConnection(Hn(r),e)):(r=n._createContainer("shape",o),n.drawShape(Hn(r),e),Gn(r,e.x,e.y)),i.addDragger(e,t,r))})),t}(s)),o?(c.parentNode||ge(e.getActiveLayer(),c),Gn(c,t.x,t.y)):Fe(c)})),t.on("create.cleanup",(function(e){var t=e.context.dragGroup;t&&Fe(t)}))}Yd.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];var Xd={__depends__:[mp,Pl,bp,_a],__init__:["create","createPreview"],create:["type",Ud],createPreview:["type",Yd]};function Zd(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)}))}Zd.$inject=["eventBus"],Zd.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 Qd={__init__:["mouse"],mouse:["type",Zd]};function Jd(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;var r=m(i,(function(e){return e===n.parent}));r&&(t.parent=n.parent.id),function(e){return!!e.host}(n)&&(t.priority=2,t.host=n.host.id),an(n)&&(t.priority=3,t.source=n.source.id,t.target=n.target.id,t.waypoints=function(e){return E(e.waypoints,(function(e){return(e=ef(e)).original&&(e.original=ef(e.original)),e}))}(n)),sn(n)&&(t.priority=4,t.labelTarget=n.labelTarget.id),v(["x","y","width","height"],(function(e){u(n[e])&&(t[e]=n[e])})),t.hidden=n.hidden,t.collapsed=n.collapsed})),r.on("copyPaste.pasteElements",(function(e){L(e.hints,{createElementsBehavior:!1})}))}function ef(e){return L({},e)}function tf(e,t){var n=t.indexOf(e);return-1===n?t:t.splice(n,1)}Jd.$inject=["canvas","create","clipboard","elementFactory","eventBus","modeling","mouse","rules"],Jd.prototype.copy=function(e){var t,n;return p(e)||(e=e?[e]:[]),n=!1===(t=this._eventBus.fire("copyPaste.canCopyElements",{elements:e}))?{}:this.createTree(p(t)?t:e),this._clipboard.set(n),this._eventBus.fire("copyPaste.elementsCopied",{elements:e,tree:n}),n},Jd.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||{}})}},Jd.prototype._paste=function(e,t,n,i){v(e,(function(e){u(e.x)||(e.x=0),u(e.y)||(e.y=0)}));var r=ht(e);return v(e,(function(e){an(e)&&(e.waypoints=E(e.waypoints,(function(e){return{x:e.x-r.x-r.width/2,y:e.y-r.y-r.height/2}}))),L(e,{x:e.x-r.x-r.width/2,y:e.y-r.y-r.height/2})})),this._modeling.createElements(e,n,t,L({},i))},Jd.prototype._createElements=function(e){var t=this,n=this._eventBus,i={},r=[];return v(e,(function(e,o){v(e=A(e,"priority"),(function(e){var o,a=L({},I(e,["priority"]));return i[e.parent]?a.parent=i[e.parent]:delete a.parent,n.fire("copyPaste.pasteElement",{cache:i,descriptor:a}),an(a)?(a.source=i[e.source],a.target=i[e.target],o=i[e.id]=t.createConnection(a),void r.push(o)):sn(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},Jd.prototype.createConnection=function(e){return this._elementFactory.createConnection(I(e,["id"]))},Jd.prototype.createLabel=function(e){return this._elementFactory.createLabel(I(e,["id"]))},Jd.prototype.createShape=function(e){return this._elementFactory.createShape(I(e,["id"]))},Jd.prototype.hasRelations=function(e,t){var n,i;return!(an(e)&&(n=m(t,M({id:e.source.id})),i=m(t,M({id:e.target.id})),!n||!i))&&!(sn(e)&&!m(t,M({id:e.labelTarget.id})))},Jd.prototype.createTree=function(e){var t=this._rules,n=this,i={},r=[];function o(e,t){var n=m(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),r.push({element:n.element,depth:t})):r.push({element:e,depth:t})}return lt(st(e),(function(e,t,i){if(!sn(e)){v(e.labels,(function(e){o(e,i)})),v([e.attachers,e.incoming,e.outgoing],(function(e){e&&e.length&&v(e,(function(e){v(e.labels,(function(e){o(e,i)})),o(e,i)}))})),o(e,i);var r=[];return e.children&&(r=e.children.slice()),n._eventBus.fire("copyPaste.createTree",{element:e,children:r}),r}})),e=E(r,(function(e){return e.element})),r=E(r,(function(t){return t.descriptor={},n._eventBus.fire("copyPaste.copyElement",{descriptor:t.descriptor,element:t.element,elements:e}),t})),r=A(r,(function(e){return e.descriptor.priority})),e=E(r,(function(e){return e.element})),v(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)?tf(r.element,e):(i[o]||(i[o]=[]),i[o].push(r.descriptor)):tf(r.element,e)})),i};var nf={__depends__:[Fd,Xd,Qd,bp],__init__:["copyPaste"],copyPaste:["type",Jd]};function rf(e,t,n){p(n)||(n=[n]),v(n,(function(n){a(e[n])||(t[n]=e[n])}))}function of(e,t,n){function i(t,i){var r=e.create(t.$type);return n.copyElement(t,r,null,i)}t.on("copyPaste.copyElement",750,(function(e){var t=e.descriptor,n=e.element,r=gr(n);if(sn(n))return t;var o=t.businessObject=i(r,!0),a=t.di=i(vr(n),!0);a.bpmnElement=o,rf(o,t,"name"),rf(a,t,"isExpanded"),r.default&&(t.default=r.default.id)}));var r="-bpmn-js-refs";t.on("copyPaste.pasteElement",(function(e){var t=e.cache,n=e.descriptor,r=n.businessObject,o=n.di;if(sn(n))return n.businessObject=gr(t[n.labelTarget]),void(n.di=vr(t[n.labelTarget]));r=n.businessObject=i(r),(o=n.di=i(o)).bpmnElement=r,rf(n,r,["isExpanded","name"]),n.type=r.$type})),t.on("copyPaste.copyElement",750,(function(e){var t=e.descriptor,n=e.element;if(mr(n,"bpmn:Participant")){var r=gr(n);r.processRef&&(t.processRef=i(r.processRef,!0))}})),t.on("copyPaste.pasteElement",(function(e){var t=e.descriptor,n=t.processRef;n&&(t.processRef=i(n))})),t.on("copyPaste.pasteElement",750,(function(e){var t=e.cache;!function(e,t){e[r]=t}(t,function(e,t,n){var i=gr(e);return e.default&&(n[e.default]={element:i,property:"default"}),e.host&&(gr(e).attachedToRef=gr(t[e.host])),I(n,b(n,(function(t,n,r){var o=n.element,a=n.property;return r===e.id&&(o.set(a,i),t.push(e.id)),t}),[]))}(e.descriptor,t,function(e){return e[r]=e[r]||{}}(t)))}))}of.$inject=["bpmnFactory","eventBus","moddleCopy"];var af=["artifacts","dataInputAssociations","dataOutputAssociations","default","flowElements","lanes","incoming","outgoing","categoryValue"];function sf(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 A(t,(function(e){return"extensionElements"===e}))})),e.on("moddleCopy.canCopyProperty",(function(e){var t=e.parent,n=l(t)&&t.$descriptor,i=e.propertyName;return(!i||-1===af.indexOf(i))&&(!(i&&n&&!m(n.properties,M({name:i})))&&void 0)})),e.on("moddleCopy.canSetCopiedProperty",(function(e){var t,n,i=e.property;if(n="bpmn:ExtensionElements",(t=i)&&h(t.$instanceOf)&&t.$instanceOf(n)&&(!i.values||!i.values.length))return!1}))}function cf(e,t){return b(e.properties,(function(e,n){return t&&n.default?e:e.concat(n.name)}),[])}sf.$inject=["eventBus","bpmnFactory","moddle"],sf.prototype.copyElement=function(e,t,n,i=!1){var r=this;n&&!p(n)&&(n=[n]),n=n||cf(e.$descriptor);var o=this._eventBus.fire("moddleCopy.canCopyProperties",{propertyNames:n,sourceElement:e,targetElement:t,clone:i});return!1===o||(p(o)&&(n=o),v(n,(function(n){var o;f(e,n)&&(o=e.get(n));var a=r.copyProperty(o,t,n,i);s(a)&&(!1!==r._eventBus.fire("moddleCopy.canSetCopiedProperty",{parent:t,property:a,propertyName:n})&&t.set(n,a))}))),t},sf.prototype.copyProperty=function(e,t,n,i=!1){var r=this,o=this._eventBus.fire("moddleCopy.canCopyProperty",{parent:t,property:e,propertyName:n,clone:i});if(!1!==o){if(o)return l(o)&&o.$type&&!o.$parent&&(o.$parent=t),o;var a=this._moddle.getPropertyDescriptor(t,n);if(!a.isReference){if(a.isId)return e&&this._copyId(e,t,i);if(p(e))return b(e,(function(e,a){return(o=r.copyProperty(a,t,n,i))?e.concat(o):e}),[]);if(l(e)&&e.$type){if(this._moddle.getElementDescriptor(e).isGeneric)return;return(o=r._bpmnFactory.create(e.$type)).$parent=t,o=r.copyElement(e,o,null,i)}return e}}},sf.prototype._copyId=function(e,t,n=!1){return n?e:this._moddle.ids.assigned(e)?void 0:(this._moddle.ids.claim(e,t),e)};var pf={__depends__:[nf],__init__:["bpmnCopyPaste","moddleCopy"],bpmnCopyPaste:["type",of],moddleCopy:["type",sf]},lf=Math.round;function uf(e,t){this._modeling=e,this._eventBus=t}function hf(e,t){t.on("replace.end",500,(function(t){const{newElement:n,hints:i={}}=t;!1!==i.select&&e.select(n)}))}uf.$inject=["modeling","eventBus"],uf.prototype.replaceElement=function(e,t,n){if(e.waypoints)return null;var i=this._modeling,r=this._eventBus;r.fire("replace.start",{element:e,attrs:t,hints:n});var o=t.width||e.width,a=t.height||e.height,s=t.x||e.x,c=t.y||e.y,p=lf(s+o/2),l=lf(c+a/2),u=i.replaceShape(e,L({},t,{x:p,y:l,width:o,height:a}),n);return r.fire("replace.end",{element:e,newElement:u,hints:n}),u},hf.$inject=["selection","eventBus"];var df={__init__:["replace","replaceSelectionBehavior"],replaceSelectionBehavior:["type",hf],replace:["type",uf]};var ff=["cancelActivity","instantiate","eventGatewayType","triggeredByEvent","isInterrupting"];function mf(e,t,n,i,r,o){this.replaceElement=function(s,c,l){l=l||{};var u=c.type,h=s.businessObject;if(yf(h)&&"bpmn:SubProcess"===u&&function(e,t){var n=e&&f(e,"collapsed")?e.collapsed:!jr(e);return n!==(t&&(f(t,"collapsed")||f(t,"isExpanded"))?f(t,"collapsed")?t.collapsed:!t.isExpanded:n)}(s,c))return i.toggleCollapse(s),s;var d=e.create(u),m={type:u,businessObject:d,di:{}};"bpmn:ExclusiveGateway"===u&&(m.di.isMarkerVisible=!0),function(e,t,n){p(n)||(n=[n]),v(n,(function(n){a(e[n])||(t[n]=e[n])}))}(s.di,m.di,["fill","stroke","background-color","border-color","color"]);var y=function(e,t){return e.filter((function(e){return t.includes(e)}))}(cf(h.$descriptor),cf(d.$descriptor,!0));L(d,$(c,ff));var _=g(y,(function(e){return"eventDefinitions"===e?gf(s,c.eventDefinitionType):"loopCharacteristics"===e?!Lr(d):!f(d,e)&&(("processRef"!==e||!1!==c.isExpanded)&&("triggeredByEvent"!==e&&("isForCompensation"!==e||!Lr(d))))}));if(d=n.copyElement(h,d,_),c.eventDefinitionType&&(gf(d,c.eventDefinitionType)||(m.eventDefinitionType=c.eventDefinitionType,m.eventDefinitionAttrs=c.eventDefinitionAttrs)),mr(h,"bpmn:Activity")){if(yf(h))m.isExpanded=jr(s);else if(c&&f(c,"isExpanded")){m.isExpanded=c.isExpanded;var b=t.getDefaultSize(d,{isExpanded:m.isExpanded});m.width=b.width,m.height=b.height,m.x=s.x-(m.width-s.width)/2,m.y=s.y-(m.height-s.height)/2}jr(s)&&!mr(h,"bpmn:Task")&&m.isExpanded&&(m.width=s.width,m.height=s.height)}if(yf(h)&&!yf(d)&&(l.moveChildren=!1),mr(h,"bpmn:Participant")){!0===c.isExpanded?d.processRef=e.create("bpmn:Process"):l.moveChildren=!1;var x=Or(s);vr(s).isHorizontal||(vr(m).isHorizontal=x),m.width=x?s.width:t.getDefaultSize(m).width,m.height=x?t.getDefaultSize(m).height:s.height}return o.allowed("shape.resize",{shape:d})||(m.height=t.getDefaultSize(m).height,m.width=t.getDefaultSize(m).width),d.name=h.name,yr(h,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&yr(d,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&(d.default=h.default),c.host&&!mr(h,"bpmn:BoundaryEvent")&&mr(d,"bpmn:BoundaryEvent")&&(m.host=c.host),"bpmn:DataStoreReference"!==m.type&&"bpmn:DataObjectReference"!==m.type||(m.x=s.x+(s.width-m.width)/2),r.replaceElement(s,m,{...l,targetElement:c})}}function yf(e){return mr(e,"bpmn:SubProcess")}function gf(e,t){var n=gr(e);return t&&n.get("eventDefinitions").some((function(e){return mr(e,t)}))}mf.$inject=["bpmnFactory","elementFactory","moddleCopy","modeling","replace","rules"];var vf={__depends__:[pf,df,_a],bpmnReplace:["type",mf]};function _f(e){this._eventBus=e,this._tools=[],this._active=null}_f.$inject=["eventBus"],_f.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)},_f.prototype.isActive=function(e){return e&&this._active===e},_f.prototype.length=function(e){return this._tools.length},_f.prototype.setActive=function(e){var t=this._eventBus;this._active!==e&&(this._active=e,t.fire("tool-manager.update",{tool:e}))},_f.prototype.bindEvents=function(e,t){var n=this._eventBus,i=[];n.on(t.tool+".init",(function(t){t.context.reactivate||!this.isActive(e)?this.setActive(e):this.setActive(null)}),this),v(t,(function(e){i.push(e+".ended"),i.push(e+".canceled")})),n.on(i,250,(function(e){this._active&&(function(e){var t=e.originalEvent&&e.originalEvent.target;return t&&J(t,'.group[data-group="tools"]')}(e)||this.setActive(null))}),this)};var bf={__depends__:[mp],__init__:["toolManager"],toolManager:["type",_f]};function xf(e,t){return-1!==e.indexOf(t)}var wf=Math.abs,Ef=Math.round,Sf={x:"width",y:"height"},Cf="crosshair",kf={n:"top",w:"left",s:"bottom",e:"right"},Rf={n:"s",w:"e",s:"n",e:"w"};function Pf(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&&Mf(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){Mf(e);var p={x:0,y:0};p[i]=Ef(e["d"+i]),s.makeSpace(o,a,p,r,c),n.once("spaceTool.ended",(function(e){s.activateSelection(e.originalEvent,!0,!0)}))}}))}function Af(e){return{top:e.top-20,right:e.right+20,bottom:e.bottom+20,left:e.left-20}}function Mf(e){var t,n,i=e.context.spaceToolConstraints;i&&(u(i.left)&&(t=Math.max(e.x,i.left),e.dx=e.dx+t-e.x,e.x=t),u(i.right)&&(t=Math.min(e.x,i.right),e.dx=e.dx+t-e.x,e.x=t),u(i.top)&&(n=Math.max(e.y,i.top),e.dy=e.dy+n-e.y,e.y=n),u(i.bottom)&&(n=Math.min(e.y,i.bottom),e.dy=e.dy+n-e.y,e.y=n))}function Tf(e,t){return-1!==e.indexOf(t)}Pf.$inject=["canvas","dragging","eventBus","modeling","rules","toolManager","mouse"],Pf.prototype.activateSelection=function(e,t,n){this._dragging.init(e,"spaceTool.selection",{autoActivate:t,cursor:Cf,data:{context:{reactivate:n}},trapClick:!1})},Pf.prototype.activateMakeSpace=function(e){this._dragging.init(e,"spaceTool",{autoActivate:!0,cursor:Cf,data:{context:{}}})},Pf.prototype.makeSpace=function(e,t,n,i,r){return this._modeling.createSpace(e,t,n,i,r)},Pf.prototype.init=function(e,t){var n=wf(e.dx)>wf(e.dy)?"x":"y",i=e["d"+n],r=e[n]-i;if(wf(i)<5)return!1;i<0&&(i*=-1),sa(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=this._canvas.getRootElement();!ca(e)&&e.hover&&(a=e.hover);var s=[...ut(a,!0),...a.attachers||[]],c=this.calculateAdjustments(s,n,i,r),p=function(e,t,n,i,r){var o=e.movingShapes,a=e.resizingShapes;if(!a.length)return;var s,c,p={};return v(a,(function(e){var l,h,d,f,m,y,v=e.attachers,_=e.children,b=ln(e),x=g(_,(function(e){return!(an(e)||sn(e)||Tf(o,e)||Tf(a,e))})),w=g(_,(function(e){return!an(e)&&!sn(e)&&Tf(o,e)})),E=[],S=[];x.length&&(h=Af(ln(ht(x))),l=i-b[kf[n]]+h[kf[n]],"n"===n?p.bottom=c=u(c)?Math.min(c,l):l:"w"===n?p.right=c=u(c)?Math.min(c,l):l:"s"===n?p.top=s=u(s)?Math.max(s,l):l:"e"===n&&(p.left=s=u(s)?Math.max(s,l):l)),w.length&&(d=Af(ln(ht(w))),l=i-d[kf[Rf[n]]]+b[kf[Rf[n]]],"n"===n?p.bottom=c=u(c)?Math.min(c,l):l:"w"===n?p.right=c=u(c)?Math.min(c,l):l:"s"===n?p.top=s=u(s)?Math.max(s,l):l:"e"===n&&(p.left=s=u(s)?Math.max(s,l):l)),v&&v.length&&(v.forEach((function(e){Tf(o,e)?E.push(e):S.push(e)})),E.length&&(f=ln(ht(E.map(dn))),m=b[kf[Rf[n]]]-(f[kf[Rf[n]]]-i)),S.length&&(y=ln(ht(S.map(dn)))[kf[n]]-(b[kf[n]]-i)),"n"===n?(l=Math.min(m||1/0,y||1/0),p.bottom=c=u(c)?Math.min(c,l):l):"w"===n?(l=Math.min(m||1/0,y||1/0),p.right=c=u(c)?Math.min(c,l):l):"s"===n?(l=Math.max(m||-1/0,y||-1/0),p.top=s=u(s)?Math.max(s,l):l):"e"===n&&(l=Math.max(m||-1/0,y||-1/0),p.left=s=u(s)?Math.max(s,l):l));var C=r&&r[e.id];C&&("n"===n?(l=i+e[Sf[t]]-C[Sf[t]],p.bottom=c=u(c)?Math.min(c,l):l):"w"===n?(l=i+e[Sf[t]]-C[Sf[t]],p.right=c=u(c)?Math.min(c,l):l):"s"===n?(l=i-e[Sf[t]]+C[Sf[t]],p.top=s=u(s)?Math.max(s,l):l):"e"===n&&(l=i-e[Sf[t]]+C[Sf[t]],p.left=s=u(s)?Math.max(s,l):l))})),p}(c,n,o,r,this._eventBus.fire("spaceTool.getMinDimensions",{axis:n,direction:o,shapes:c.resizingShapes,start:r}));return L(t,c,{axis:n,direction:o,spaceToolConstraints:p,start:r}),La("resize-"+("x"===n?"ew":"ns")),!0},Pf.prototype.calculateAdjustments=function(e,t,n,i){var r=this._rules,o=[],a=[],s=[],c=[];function p(e){o.includes(e)||o.push(e);var t=e.label;t&&!o.includes(t)&&o.push(t)}v(e,(function(e){if(e.parent&&!sn(e))if(an(e))c.push(e);else{var o=e[t],l=o+e[Sf[t]];if(function(e){return!!e.host}(e)&&(n>0&&dn(e)[t]>i||n<0&&dn(e)[t]<i))s.push(e);else{var u;if(!(n>0&&o>i||n<0&&l<i))return o<i&&l>i&&r.allowed("shape.resize",{shape:e})?(u=e,void(a.includes(u)||a.push(u))):void 0;p(e)}}})),v(o,(function(e){var t=e.attachers;t&&v(t,(function(e){p(e)}))}));var l=o.concat(a);return v(s,(function(e){var t=e.host;Tf(l,t)&&p(e)})),l=o.concat(a),v(c,(function(e){var t=e.source,n=e.target,i=e.label;Tf(l,t)&&Tf(l,n)&&i&&p(i)})),{movingShapes:o,resizingShapes:a}},Pf.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},Pf.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^spaceTool/.test(e.prefix)};var Bf="djs-dragging",Df="djs-resizing",Nf=Math.max;function jf(e,t,n,i,r){function o(e,t){v(e,(function(e){r.addDragger(e,t),n.addMarker(e,Bf)}))}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=Ae("g");be(s,i.cls("djs-crosshair-group",["no-events"])),ge(t,s);var c=Ae("path");be(c,"d",o),we(c).add("djs-crosshair"),ge(s,c);var p=Ae("path");be(p,"d",a),we(p).add("djs-crosshair"),ge(s,p),r.crosshairGroup=s})),e.on("spaceTool.selection.move",(function(e){Gn(e.context.crosshairGroup,e.x,e.y)})),e.on("spaceTool.selection.cleanup",(function(e){var t=e.context.crosshairGroup;t&&Fe(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");be(s=Ae("path"),"d","M0,0 L0,0"),we(s).add("djs-crosshair"),ge(u,s),a.line=s;var h=Ae("g");be(h,i.cls("djs-drag-group",["no-events"])),ge(n.getActiveLayer(),h),o(p,h),o(a.movingConnections=t.filter((function(e){var t=!1;v(p,(function(n){v(n.outgoing,(function(n){e===n&&(t=!0)}))}));var n=!1;v(p,(function(t){v(t.incoming,(function(t){e===t&&(n=!0)}))}));var i=!1;v(l,(function(t){v(t.outgoing,(function(t){e===t&&(i=!0)}))}));var r=!1;return v(l,(function(t){v(t.incoming,(function(t){e===t&&(r=!0)}))})),an(e)&&(t||i)&&(n||r)})),h),a.dragGroup=h}if(!a.frameGroup){var d=Ae("g");be(d,i.cls("djs-frame-group",["no-events"])),ge(n.getActiveLayer(),d);var f=[];v(l,(function(e){var t=r.addFrame(e,d),i=t.getBBox();f.push({element:t,initialBounds:i}),n.addMarker(e,Df)})),a.frameGroup=d,a.frames=f}be(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,Gn(a.dragGroup,m.x,m.y),v(a.frames,(function(e){var t,n,i=e.element,r=e.initialBounds;"e"===a.direction?be(i,{width:Nf(r.width+m.x,5)}):be(i,{width:t=Nf(r.width-m.x,5),x:r.x+r.width-t}),"s"===a.direction?be(i,{height:Nf(r.height+m.y,5)}):be(i,{height:n=Nf(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;v(i,(function(e){n.removeMarker(e,Bf)})),v(r,(function(e){n.removeMarker(e,Bf)})),s&&(Fe(a),Fe(s)),v(o,(function(e){n.removeMarker(e,Df)})),c&&Fe(c)}))}jf.$inject=["eventBus","elementRegistry","canvas","styles","previewSupport"];var Of={__init__:["spaceToolPreview"],__depends__:[mp,bp,bf,Pl,Qd],spaceTool:["type",Pf],spaceToolPreview:["type",jf]};function Lf(e){e.invoke(Pf,this)}Lf.$inject=["injector"],e(Lf,Pf),Lf.prototype.calculateAdjustments=function(e,t,n,i){var r=Pf.prototype.calculateAdjustments.call(this,e,t,n,i);return r.resizingShapes=r.resizingShapes.filter((function(e){return!mr(e,"bpmn:TextAnnotation")&&(!function(e){return mr(e,"bpmn:Participant")&&!gr(e).processRef}(e)||!("y"===t&&Or(e)||"x"===t&&!Or(e)))})),r};var $f={__depends__:[Of],spaceTool:["type",Lf]};function If(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)}If.$inject=["eventBus","injector"],If.prototype.execute=function(e,t){if(!e)throw new Error("command required");this._currentExecution.trigger="execute";const n={command:e,context:t};this._pushAction(n),this._internalExecute(n),this._popAction()},If.prototype.canExecute=function(e,t){const n={command:e,context:t},i=this._getHandler(e);let r=this._fire(e,"canExecute",n);if(void 0===r){if(!i)return!1;i.canExecute&&(r=i.canExecute(t))}return r},If.prototype.clear=function(e){this._stack.length=0,this._stackIdx=-1,!1!==e&&this._fire("changed",{trigger:"clear"})},If.prototype.undo=function(){let e,t=this._getUndoAction();if(t){for(this._currentExecution.trigger="undo",this._pushAction(t);t&&(this._internalUndo(t),e=this._getUndoAction(),e&&e.id===t.id);)t=e;this._popAction()}},If.prototype.redo=function(){let e,t=this._getRedoAction();if(t){for(this._currentExecution.trigger="redo",this._pushAction(t);t&&(this._internalExecute(t,!0),e=this._getRedoAction(),e&&e.id===t.id);)t=e;this._popAction()}},If.prototype.register=function(e,t){this._setHandler(e,t)},If.prototype.registerHandler=function(e,t){if(!e||!t)throw new Error("command and handlerCls must be defined");const n=this._injector.instantiate(t);this.register(e,n)},If.prototype.canUndo=function(){return!!this._getUndoAction()},If.prototype.canRedo=function(){return!!this._getRedoAction()},If.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]},If.prototype._getUndoAction=function(){return this._stack[this._stackIdx]},If.prototype._internalUndo=function(e){const t=e.command,n=e.context,i=this._getHandler(t);this._atomicDo((()=>{this._fire(t,"revert",e),i.revert&&this._markDirty(i.revert(n)),this._revertedAction(e),this._fire(t,"reverted",e)}))},If.prototype._fire=function(e,t,n){arguments.length<3&&(n=t,t=null);const i=t?[e+"."+t,t]:[e];let r;n=this._eventBus.createEvent(n);for(const e of i)if(r=this._eventBus.fire("commandStack."+e,n),n.cancelBubble)break;return r},If.prototype._createId=function(){return this._uid++},If.prototype._atomicDo=function(e){const t=this._currentExecution;t.atomic=!0;try{e()}finally{t.atomic=!1}},If.prototype._internalExecute=function(e,t){const n=e.command,i=e.context,r=this._getHandler(n);if(!r)throw new Error("no command handler registered for <"+n+">");this._pushAction(e),t||(this._fire(n,"preExecute",e),r.preExecute&&r.preExecute(i),this._fire(n,"preExecuted",e)),this._atomicDo((()=>{this._fire(n,"execute",e),r.execute&&this._markDirty(r.execute(i)),this._executedAction(e,t),this._fire(n,"executed",e)})),t||(this._fire(n,"postExecute",e),r.postExecute&&r.postExecute(i),this._fire(n,"postExecuted",e)),this._popAction()},If.prototype._pushAction=function(e){const 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)},If.prototype._popAction=function(){const e=this._currentExecution,t=e.trigger,n=e.actions,i=e.dirty;n.pop(),n.length||(this._eventBus.fire("elements.changed",{elements:R("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:t}),e.trigger=null)},If.prototype._markDirty=function(e){const t=this._currentExecution;e&&(e=p(e)?e:[e],t.dirty=t.dirty.concat(e))},If.prototype._executedAction=function(e,t){const n=++this._stackIdx;t||this._stack.splice(n,this._stack.length,e)},If.prototype._revertedAction=function(e){this._stackIdx--},If.prototype._getHandler=function(e){return this._handlerMap[e]},If.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 Ff={commandStack:["type",If]};function zf(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 Hf(e,t,n){To.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=Vf(n),t.validatedShapes=Vf(i)})),i&&t.on("shape.move.start",250,(function(e){var t=e.context,n=t.shapes,r=[];v(n,(function(e){v(e.labels,(function(n){n.hidden||-1!==t.shapes.indexOf(n)||r.push(n),e.labelTarget&&r.push(e)}))})),v(r,(function(e){i.makeDraggable(t,e,!0)}))})),this.preExecuted("elements.move",1400,(function(e){var t=e.context.closure,n=t.enclosedElements,i=[];v(n,(function(e){v(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;zf((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=bt(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&&(_t(i.labels,n,r),n.labelTarget=i)}))}function Vf(e){return g(e,(function(t){return-1===e.indexOf(t.labelTarget)}))}e(Hf,To),Hf.$inject=["injector","eventBus","modeling"];var Gf={__init__:["labelSupport"],labelSupport:["type",Hf]},Wf="attach-ok";function Uf(e,t,n,i,r){To.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=qf(t=r),P("id",t,n)),i.validatedShapes=function(e){var t=k(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;v(qf(t.shapes),(function(e){o.makeDraggable(t,e,!0),v(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,Wf),t.once(["shape.move.out","shape.move.cleanup"],(function(){n.removeMarker(r,Wf)})))}})),this.preExecuted("elements.move",1401,(function(e){var t=e.context,n=t.closure;v(qf(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||v(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){v(e.context.shapes,(function(e){v(e.attachers,(function(e){v(e.outgoing.slice(),(function(e){i.allowed("connection.reconnect",{connection:e,source:e.source,target:e.target})||r.removeConnection(e)})),v(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;zf(n.attachers,(function(e){"attach"===i.allowed("elements.move",{target:o,shapes:[e]})?r.updateAttachment(e,o):r.removeShape(e)})),o.attachers.length&&v(o.attachers,(function(e){var t=Wu(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&&v(a,(function(e){var t=Wu(e,i,o);r.moveShape(e,t,e.parent),v(e.labels,(function(e){r.moveShape(e,t,e.parent)}))}))})),this.preExecute("shape.delete",(function(e){var t=e.context.shape;zf(t.attachers,(function(e){r.removeShape(e)})),t.host&&r.updateAttachment(t,null)}))}function qf(e){return i(E(e,(function(e){return e.attachers||[]})))}e(Uf,To),Uf.$inject=["injector","eventBus","canvas","rules","modeling"];var Kf={__depends__:[bp],__init__:["attachSupport"],attachSupport:["type",Uf]};function Yf(e){this._model=e}function Xf(e,t,n){To.call(this,e),this._bpmnFactory=t;var i=this;function r(e){v(e.context.oldRoot.children,(function(e){mr(e,"bpmn:BaseElement")&&i.updateParent(e)}))}function o(e){var t=e.context.shape;mr(t,"bpmn:BaseElement")&&i.updateBounds(t)}function a(e){i.updateConnection(e.context)}function s(e){i.updateConnectionWaypoints(e.context.connection)}function c(e){i.updateAttachment(e.context)}function p(e){const{element:n}=e.context,i=Wr(n),r=vr(n),o=r&&r.get("label");Fr(n)||Ho(n)||(i&&!o?r.set("label",t.create("bpmndi:BPMNLabel")):!i&&o&&r.set("label",void 0))}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"],Zf((function(e){var t=e.context;i.updateParent(t.shape||t.connection,t.oldParent)}))),this.reverted(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],Zf((function(e){var t=e.context,n=t.shape||t.connection,r=t.parent||t.newParent;i.updateParent(n,r)}))),this.executed(["canvas.updateRoot"],r),this.reverted(["canvas.updateRoot"],r),this.executed(["shape.move","shape.create","shape.resize"],Zf((function(e){"label"!==e.context.shape.type&&o(e)}))),this.reverted(["shape.move","shape.create","shape.resize"],Zf((function(e){"label"!==e.context.shape.type&&o(e)}))),e.on("shape.changed",(function(e){"label"===e.element.type&&o({context:{shape:e.element}})})),this.executed(["connection.create","connection.move","connection.delete","connection.reconnect"],Zf(a)),this.reverted(["connection.create","connection.move","connection.delete","connection.reconnect"],Zf(a)),this.executed(["connection.layout","connection.move","connection.updateWaypoints"],Zf(s)),this.reverted(["connection.layout","connection.move","connection.updateWaypoints"],Zf(s)),this.executed("connection.reconnect",Zf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=gr(n),a=gr(i),s=gr(r);o.conditionExpression&&!yr(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",Zf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=gr(n),a=gr(i),s=gr(r);t.oldConditionExpression&&(o.conditionExpression=t.oldConditionExpression),t.oldDefault&&(a.default=t.oldDefault,delete s.default)}))),this.executed(["element.updateAttachment"],Zf(c)),this.reverted(["element.updateAttachment"],Zf(c)),this.executed("element.updateLabel",Zf(p)),this.reverted("element.updateLabel",Zf(p))}function Zf(e){return function(t){var n=t.context;mr(n.shape||n.connection||n.element,"bpmn:BaseElement")&&e(t)}}function Qf(e,t){Ln.call(this),this._bpmnFactory=e,this._moddle=t}function Jf(e,t,n){return void 0===t[n]?t:(e[n]=t[n],I(t,[n]))}function em(e,t){this._modeling=e,this._canvas=t}function tm(e){this._modeling=e}function nm(e,t){this._canvas=e,this._layouter=t}Yf.$inject=["moddle"],Yf.prototype._needsId=function(e){return yr(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"])},Yf.prototype._ensureId=function(e){var t;e.id?this._model.ids.claim(e.id,e):(t=mr(e,"bpmn:Activity")?"Activity":mr(e,"bpmn:Event")?"Event":mr(e,"bpmn:Gateway")?"Gateway":yr(e,["bpmn:SequenceFlow","bpmn:MessageFlow"])?"Flow":(e.$type||"").replace(/^[^:]*:/g,""),t+="_",!e.id&&this._needsId(e)&&(e.id=this._model.ids.nextPrefixed(t,e)))},Yf.prototype.create=function(e,t){var n=this._model.create(e,t||{});return this._ensureId(n),n},Yf.prototype.createDiLabel=function(){return this.create("bpmndi:BPMNLabel",{bounds:this.createDiBounds()})},Yf.prototype.createDiShape=function(e,t){return this.create("bpmndi:BPMNShape",L({bpmnElement:e,bounds:this.createDiBounds()},t))},Yf.prototype.createDiBounds=function(e){return this.create("dc:Bounds",e)},Yf.prototype.createDiWaypoints=function(e){var t=this;return E(e,(function(e){return t.createDiWaypoint(e)}))},Yf.prototype.createDiWaypoint=function(e){return this.create("dc:Point",$(e,["x","y"]))},Yf.prototype.createDiEdge=function(e,t){return this.create("bpmndi:BPMNEdge",L({bpmnElement:e,waypoint:this.createDiWaypoints([])},t))},Yf.prototype.createDiPlane=function(e,t){return this.create("bpmndi:BPMNPlane",L({bpmnElement:e},t))},e(Xf,To),Xf.$inject=["eventBus","bpmnFactory","connectionDocking"],Xf.prototype.updateAttachment=function(e){var t=e.shape,n=t.businessObject,i=t.host;n.attachedToRef=i&&i.businessObject},Xf.prototype.updateParent=function(e,t){if(!(sn(e)||mr(e,"bpmn:DataStoreReference")&&e.parent&&mr(e.parent,"bpmn:Collaboration"))){var n=e.parent,i=e.businessObject,r=vr(e),o=n&&n.businessObject,a=vr(n);mr(e,"bpmn:FlowNode")&&this.updateFlowNodeRefs(i,o,t&&t.businessObject),mr(e,"bpmn:DataOutputAssociation")&&(o=e.source?e.source.businessObject:null),mr(e,"bpmn:DataInputAssociation")&&(o=e.target?e.target.businessObject:null),this.updateSemanticParent(i,o),mr(e,"bpmn:DataObjectReference")&&i.dataObjectRef&&this.updateSemanticParent(i.dataObjectRef,o),this.updateDiParent(r,a)}},Xf.prototype.updateBounds=function(e){var t=vr(e),n=function(e){if(!mr(e,"bpmn:Activity"))return;var t=vr(e);if(!t)return;var n=t.get("label");if(!n)return;return n.get("bounds")}(e);if(n){var i=za(n,t.get("bounds"));L(n,{x:e.x+i.x,y:e.y+i.y})}var r=sn(e)?this._getLabel(t):t,o=r.bounds;o||(o=this._bpmnFactory.createDiBounds(),r.set("bounds",o)),L(o,{x:e.x,y:e.y,width:e.width,height:e.height})},Xf.prototype.updateFlowNodeRefs=function(e,t,n){n!==t&&(mr(n,"bpmn:Lane")&&vt(n.get("flowNodeRef"),e),mr(t,"bpmn:Lane")&&_t(t.get("flowNodeRef"),e))},Xf.prototype.updateDiConnection=function(e,t,n){var i=vr(e),r=vr(t),o=vr(n);i.sourceElement&&i.sourceElement.bpmnElement!==gr(t)&&(i.sourceElement=t&&r),i.targetElement&&i.targetElement.bpmnElement!==gr(n)&&(i.targetElement=n&&o)},Xf.prototype.updateDiParent=function(e,t){if(t&&!mr(t,"bpmndi:BPMNPlane")&&(t=t.$parent),e.$parent!==t){var n=(t||e.$parent).get("planeElement");t?(n.push(e),e.$parent=t):(vt(n,e),e.$parent=null)}},Xf.prototype.getLaneSet=function(e){var t,n;return mr(e,"bpmn:Lane")?((t=e.childLaneSet)||(t=this._bpmnFactory.create("bpmn:LaneSet"),e.childLaneSet=t,t.$parent=e),t):(mr(e,"bpmn:Participant")&&(e=e.processRef),(t=(n=e.get("laneSets"))[0])||((t=this._bpmnFactory.create("bpmn:LaneSet")).$parent=e,n.push(t)),t)},Xf.prototype.updateSemanticParent=function(e,t,n){var i;if(e.$parent!==t&&(!mr(e,"bpmn:DataInput")&&!mr(e,"bpmn:DataOutput")||(mr(t,"bpmn:Participant")&&"processRef"in t&&(t=t.processRef),!("ioSpecification"in t)||t.ioSpecification!==e.$parent))){if(mr(e,"bpmn:Lane"))t&&(t=this.getLaneSet(t)),i="lanes";else if(mr(e,"bpmn:FlowElement")){if(t)if(mr(t,"bpmn:Participant"))t=t.processRef;else if(mr(t,"bpmn:Lane"))do{t=t.$parent.$parent}while(mr(t,"bpmn:Lane"));i="flowElements"}else if(mr(e,"bpmn:Artifact")){for(;t&&!mr(t,"bpmn:Process")&&!mr(t,"bpmn:SubProcess")&&!mr(t,"bpmn:Collaboration");){if(mr(t,"bpmn:Participant")){t=t.processRef;break}t=t.$parent}i="artifacts"}else if(mr(e,"bpmn:MessageFlow"))i="messageFlows";else if(mr(e,"bpmn:Participant")){i="participants";var r,o=e.processRef;o&&(r=function(e){for(;e&&!mr(e,"bpmn:Definitions");)e=e.$parent;return e}(e.$parent||t),e.$parent&&(vt(r.get("rootElements"),o),o.$parent=null),t&&(_t(r.get("rootElements"),o),o.$parent=r))}else mr(e,"bpmn:DataOutputAssociation")?i="dataOutputAssociations":mr(e,"bpmn:DataInputAssociation")&&(i="dataInputAssociations");if(!i)throw new Error(`no parent for <${e.id}> in <${t.id}>`);var a;if(e.$parent&&vt(a=e.$parent.get(i),e),t?((a=t.get(i)).push(e),e.$parent=t):e.$parent=null,n){var s=n.get(i);vt(a,e),t&&(s||(s=[],t.set(i,s)),s.push(e))}}},Xf.prototype.updateConnectionWaypoints=function(e){vr(e).set("waypoint",this._bpmnFactory.createDiWaypoints(e.waypoints))},Xf.prototype.updateConnection=function(e){var t,n=e.connection,i=gr(n),r=n.source,o=gr(r),a=n.target,s=gr(n.target);if(mr(i,"bpmn:DataAssociation"))mr(i,"bpmn:DataInputAssociation")?(i.get("sourceRef")[0]=o,t=e.parent||e.newParent||s,this.updateSemanticParent(i,s,t)):mr(i,"bpmn:DataOutputAssociation")&&(t=e.parent||e.newParent||o,this.updateSemanticParent(i,o,t),i.targetRef=s);else{var c=mr(i,"bpmn:SequenceFlow");i.sourceRef!==o&&(c&&(vt(i.sourceRef&&i.sourceRef.get("outgoing"),i),o&&o.get("outgoing")&&o.get("outgoing").push(i)),i.sourceRef=o),i.targetRef!==s&&(c&&(vt(i.targetRef&&i.targetRef.get("incoming"),i),s&&s.get("incoming")&&s.get("incoming").push(i)),i.targetRef=s)}this.updateConnectionWaypoints(n),this.updateDiConnection(n,r,a)},Xf.prototype._getLabel=function(e){return e.label||(e.label=this._bpmnFactory.createDiLabel()),e.label},e(Qf,Ln),Qf.$inject=["bpmnFactory","moddle"],Qf.prototype._baseCreate=Ln.prototype.create,Qf.prototype.create=function(e,t){if("label"===e){var n=t.di||this._bpmnFactory.createDiLabel();return this._baseCreate(e,L({type:"label",di:n},Ir,t))}return this.createElement(e,t)},Qf.prototype.createElement=function(e,t){var n,i,r,o=(t=L({},t||{})).businessObject,a=t.di;if(!o){if(!t.type)throw new Error("no shape type specified");hr(o=this._bpmnFactory.create(t.type))}if(!yr(a,["bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane"])){var c=L({},a||{},{id:o.id+"_di"});a="root"===e?this._bpmnFactory.createDiPlane(o,c):"connection"===e?this._bpmnFactory.createDiEdge(o,c):this._bpmnFactory.createDiShape(o,c)}return mr(o,"bpmn:Group")&&(t=L({isFrame:!0},t)),t=function(e,t,n){return v(n,(function(n){t=Jf(e,t,n)})),t}(o,t,["processRef","isInterrupting","associationDirection","isForCompensation"]),t.isExpanded&&(t=Jf(a,t,"isExpanded")),yr(o,["bpmn:Lane","bpmn:Participant"])&&(t=Jf(a,t,"isHorizontal")),mr(o,"bpmn:SubProcess")&&(t.collapsed=!jr(o,a)),mr(o,"bpmn:ExclusiveGateway")&&(f(a,"isMarkerVisible")?void 0===a.isMarkerVisible&&(a.isMarkerVisible=!1):a.isMarkerVisible=!0),s(t.triggeredByEvent)&&(o.triggeredByEvent=t.triggeredByEvent,delete t.triggeredByEvent),s(t.cancelActivity)&&(o.cancelActivity=t.cancelActivity,delete t.cancelActivity),t.eventDefinitionType&&(i=o.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=o,o.eventDefinitions=i,delete t.eventDefinitionType),n=this.getDefaultSize(o,a),t=L({id:o.id},n,t,{businessObject:o,di:a}),this._baseCreate(e,t)},Qf.prototype.getDefaultSize=function(e,t){var n=gr(e);if(t=t||vr(e),mr(n,"bpmn:SubProcess"))return jr(n,t)?{width:350,height:200}:{width:100,height:80};if(mr(n,"bpmn:Task"))return{width:100,height:80};if(mr(n,"bpmn:Gateway"))return{width:50,height:50};if(mr(n,"bpmn:Event"))return{width:36,height:36};if(mr(n,"bpmn:Participant")){var i=void 0===t.isHorizontal||!0===t.isHorizontal;return jr(n,t)?i?{width:600,height:250}:{width:250,height:600}:i?{width:400,height:60}:{width:60,height:400}}return mr(n,"bpmn:Lane")?{width:400,height:100}:mr(n,"bpmn:DataObjectReference")?{width:36,height:50}:mr(n,"bpmn:DataStoreReference")?{width:50,height:50}:mr(n,"bpmn:TextAnnotation")?{width:100,height:30}:mr(n,"bpmn:Group")?{width:300,height:300}:{width:100,height:80}},Qf.prototype.createParticipantShape=function(e){return l(e)||(e={isExpanded:e}),!1!==(e=L({type:"bpmn:Participant"},e||{})).isExpanded&&(e.processRef=this._bpmnFactory.create("bpmn:Process")),this.createShape(e)},em.$inject=["modeling","canvas"],em.prototype.preExecute=function(e){var t=this._modeling,n=e.elements,i=e.alignment;v(n,(function(e){var n={x:0,y:0};s(i.left)?n.x=i.left-e.x:s(i.right)?n.x=i.right-e.width-e.x:s(i.center)?n.x=i.center-Math.round(e.width/2)-e.x:s(i.top)?n.y=i.top-e.y:s(i.bottom)?n.y=i.bottom-e.height-e.y:s(i.middle)&&(n.y=i.middle-Math.round(e.height/2)-e.y),t.moveElements([e],n,e.parent)}))},em.prototype.postExecute=function(e){},tm.$inject=["modeling"],tm.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},tm.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))},nm.$inject=["canvas","layouter"],nm.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},nm.prototype.revert=function(e){var t=e.connection;return this._canvas.removeConnection(t),t.source=null,t.target=null,t};var im=Math.round;function rm(e){this._modeling=e}rm.$inject=["modeling"],rm.prototype.preExecute=function(e){var t=e.elements,n=e.parent,i=e.parentIndex,r=e.position,o=e.hints,a=this._modeling;v(t,(function(e){u(e.x)||(e.x=0),u(e.y)||(e.y=0)}));var s=ht(g(t,(function(e){return!e.hidden})));v(t,(function(e){an(e)&&(e.waypoints=E(e.waypoints,(function(e){return{x:im(e.x-s.x-s.width/2+r.x),y:im(e.y-s.y-s.height/2+r.y)}}))),L(e,{x:im(e.x-s.x-s.width/2+r.x),y:im(e.y-s.y-s.height/2+r.y)})}));var c=st(t),p={};v(t,(function(e){if(an(e))p[e.id]=u(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=L({},o);-1===c.indexOf(e)&&(t.autoResize=!1),sn(e)&&(t=I(t,["attach"])),p[e.id]=u(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=C(p)};var om=Math.round;function am(e){this._canvas=e}function sm(e){am.call(this,e)}am.$inject=["canvas"],am.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?L(t,n):L(t,{x:n.x-om(t.width/2),y:n.y-om(t.height/2)}),this._canvas.addShape(t,i,r),t},am.prototype.revert=function(e){var t=e.shape;return this._canvas.removeShape(t),t},e(sm,am),sm.$inject=["canvas"];var cm=am.prototype.execute;sm.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,cm.call(this,e)};var pm=am.prototype.revert;function lm(e,t){this._canvas=e,this._modeling=t}function um(e,t){this._modeling=e,this._elementRegistry=t}function hm(e,t){this._canvas=e,this._modeling=t}function dm(e){this._modeling=e}sm.prototype.revert=function(e){return e.shape.labelTarget=null,pm.call(this,e)},lm.$inject=["canvas","modeling"],lm.prototype.preExecute=function(e){var t=this._modeling,n=e.connection;zf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),zf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})}))},lm.prototype.execute=function(e){var t=e.connection,n=t.parent;return e.parent=n,e.parentIndex=bt(n.children,t),e.source=t.source,e.target=t.target,this._canvas.removeConnection(t),t.source=null,t.target=null,t},lm.prototype.revert=function(e){var t=e.connection,n=e.parent,i=e.parentIndex;return t.source=e.source,t.target=e.target,_t(n.children,t,i),this._canvas.addConnection(t,n),t},um.$inject=["modeling","elementRegistry"],um.prototype.postExecute=function(e){var t=this._modeling,n=this._elementRegistry;v(e.elements,(function(e){n.get(e.id)&&(e.waypoints?t.removeConnection(e):t.removeShape(e))}))},hm.$inject=["canvas","modeling"],hm.prototype.preExecute=function(e){var t=this._modeling,n=e.shape;zf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),zf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})})),zf(n.children,(function(e){an(e)?t.removeConnection(e,{nested:!0}):t.removeShape(e,{nested:!0})}))},hm.prototype.execute=function(e){var t=this._canvas,n=e.shape,i=n.parent;return e.oldParent=i,e.oldParentIndex=bt(i.children,n),t.removeShape(n),n},hm.prototype.revert=function(e){var t=this._canvas,n=e.shape,i=e.oldParent,r=e.oldParentIndex;return _t(i.children,n,r),t.addShape(n,i),n},dm.$inject=["modeling"];var fm={x:"y",y:"x"};function mm(e,t){this._layouter=e,this._canvas=t}function ym(){}function gm(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}function vm(e){this._modeling=e}function _m(e){this._helper=new vm(e)}function bm(e){this._modeling=e,this._helper=new vm(e)}function xm(e){this._modeling=e}function wm(e){return e.original||e}function Em(e,t){this._modeling=e,this._rules=t}function Sm(e){this._modeling=e}function Cm(e){this._modeling=e}function km(e){return L({},e)}function Rm(e){switch(e){case"n":case"s":return"y";case"w":case"e":return"x"}}function Pm(e,t,n){var i=Rm(n);return/e|s/.test(n)?e[i]>t:/n|w/.test(n)?e[i]<t:void 0}function Am(e,t){return-1!==e.indexOf(t)}function Mm(e){this._modeling=e}function Tm(e){var t={};return v(e,(function(e){t[e.id]=e.hidden,e.children&&(t=L({},t,Tm(e.children)))})),t}function Bm(e,t){var n=[];return v(e,(function(e){e.hidden=t,n=n.concat(e),e.children&&(n=n.concat(Bm(e.children,e.collapsed||t)))})),n}function Dm(e,t){var n=[];return v(e,(function(e){e.hidden=t[e.id],n=n.concat(e),e.children&&(n=n.concat(Dm(e.children,t)))})),n}function Nm(e){this._modeling=e}function jm(e,t){return vt(e&&e.attachers,t)}function Om(e,t,n){if(e){var i=e.attachers;i||(e.attachers=i=[]),_t(i,t,n)}}function Lm(){}function $m(e,t,n){this._eventBus=e,this._elementFactory=t,this._commandStack=n;var i=this;e.on("diagram.init",(function(){i.registerHandlers(n)}))}function Im(e){this._elementRegistry=e}function Fm(e,t){v(t,(function(t,n){e.set(n,t)}))}dm.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;v(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=A(e.elements,i))[0],p===h&&(u=l[s(l)]),d=a(u),e.range=null,v(l,(function(n){!function(e,n){var r={y:0};r[i]=e-a(n),r[i]&&(r[fm[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||v(n,(function(e,o){var a,s={};e!==u&&e!==d&&(a=n[o-1],e.range.max=0,v(e.elements,(function(n,o){s[fm[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)})))}))},dm.prototype.postExecute=function(e){},mm.$inject=["layouter","canvas"],mm.prototype.execute=function(e){var t=e.connection;return L(e,{oldWaypoints:t.waypoints}),t.waypoints=this._layouter.layoutConnection(t,e.hints),t},mm.prototype.revert=function(e){var t=e.connection;return t.waypoints=e.oldWaypoints,t},ym.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=vt(o.children,t),_t(i.children,t,r),t.parent=i,v(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},ym.prototype.revert=function(e){var t=e.connection,n=t.parent,i=e.oldParent,r=e.oldParentIndex,o=e.delta;return vt(n.children,t),_t(i.children,t,r),t.parent=i,v(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},gm.prototype.add=function(e,t){return this.addAll([e],t)},gm.prototype.addAll=function(e,t){var n=function(e,t,n){a(t)&&(t=!0),l(t)&&(n=t,t=!0);var i=mt((n=n||{}).allShapes),r=mt(n.allConnections),o=mt(n.enclosedElements),s=mt(n.enclosedConnections),c=mt(n.topLevel,t&&k(e,(function(e){return e.id})));function p(e){c[e.source.id]&&c[e.target.id]&&(c[e.id]=[e]),i[e.source.id]&&i[e.target.id]&&(s[e.id]=o[e.id]=e),r[e.id]=e}return lt(e,(function(e){if(o[e.id]=e,!e.waypoints)return i[e.id]=e,v(e.incoming,p),v(e.outgoing,p),e.children;s[e.id]=r[e.id]=e})),{allShapes:i,allConnections:r,topLevel:c,enclosedConnections:s,enclosedElements:o}}(e,!!t,this);return L(this,n),this},vm.prototype.moveRecursive=function(e,t,n){return e?this.moveClosure(this.getClosure(e),t,n):[]},vm.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),v(a,(function(e){o.moveShape(e,t,p[e.id]&&!l&&n,{recurse:!1,layout:!1})})),v(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&&Ju(e,e.source,t),connectionEnd:r&&eh(e,e.target,t)})}))},vm.prototype.getClosure=function(e){return(new gm).addAll(e,!0)},_m.$inject=["modeling"],_m.prototype.preExecute=function(e){e.closure=this._helper.getClosure(e.shapes)},_m.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)},bm.$inject=["modeling"],bm.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=vt(o.children,t),_t(i.children,t,r),L(t,{parent:i,x:t.x+n.x,y:t.y+n.y}),t},bm.prototype.postExecute=function(e){var t=e.shape,n=e.delta,i=e.hints,r=this._modeling;!1!==i.layout&&(v(t.incoming,(function(e){r.layoutConnection(e,{connectionEnd:eh(e,t,n)})})),v(t.outgoing,(function(e){r.layoutConnection(e,{connectionStart:Ju(e,t,n)})}))),!1!==i.recurse&&this.moveChildren(e)},bm.prototype.revert=function(e){var t=e.shape,n=e.oldParent,i=e.oldParentIndex,r=e.delta;return _t(n.children,t,i),L(t,{parent:n,x:t.x-r.x,y:t.y-r.y}),t},bm.prototype.moveChildren=function(e){var t=e.delta,n=e.shape;this._helper.moveRecursive(n.children,t,null)},bm.prototype.getNewParent=function(e){return e.newParent||e.shape.parent},xm.$inject=["modeling"],xm.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 p(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},xm.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||wm(p(r)?r[0]:r)),!i||n&&"target"!==o.docking||(a.connectionEnd=a.connectionEnd||wm(p(r)?r[r.length-1]:r)),o.newWaypoints&&(a.waypoints=o.newWaypoints),this._modeling.layoutConnection(t,a))},xm.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},Em.$inject=["modeling","rules"],Em.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();v(h,(function(e){c(e.source,t,e)&&n.reconnectEnd(e,t,Qu(e,t,u),s)})),v(d,(function(e){var i=e.target;c(t,i,e)&&n.reconnectStart(e,t,Zu(e,t,u),s)}))},Em.prototype.postExecute=function(e){var t=e.oldShape;this._modeling.removeShape(t)},Em.prototype.execute=function(e){},Em.prototype.revert=function(e){},Em.prototype.createShape=function(e,t,n,i){return this._modeling.createShape(e,t,n,i)},Em.prototype.reconnectStart=function(e,t,n,i){this._modeling.reconnectStart(e,t,n,i)},Em.prototype.reconnectEnd=function(e,t,n,i){this._modeling.reconnectEnd(e,t,n,i)},Sm.$inject=["modeling"],Sm.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},L(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Sm.prototype.postExecute=function(e){var t=this._modeling,n=e.shape,i=e.oldBounds;!1!==(e.hints||{}).layout&&(v(n.incoming,(function(e){t.layoutConnection(e,{connectionEnd:Qu(e,n,i)})})),v(n.outgoing,(function(e){t.layoutConnection(e,{connectionStart:Zu(e,n,i)})})))},Sm.prototype.revert=function(e){var t=e.shape,n=e.oldBounds;return L(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Cm.$inject=["modeling"],Cm.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),v(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 v(e.concat(t),(function(i){var r=i.incoming,o=i.outgoing;v(r.concat(o),(function(i){var r=i.source,o=i.target;(xf(e,r)||xf(e,o)||xf(t,r)||xf(t,o))&&(xf(n,i)||n.push(i))}))})),n}(i,r),t,n,o,i,r,a)},Cm.prototype.execute=function(){},Cm.prototype.revert=function(){},Cm.prototype.moveShapes=function(e,t){var n=this;v(e,(function(e){n._modeling.moveShape(e,t,null,{autoResize:!1,layout:!1,recurse:!1})}))},Cm.prototype.resizeShapes=function(e,t,n){var i=this;v(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})}))},Cm.prototype.updateConnectionWaypoints=function(e,t,n,i,r,o,a){var s=this,c=r.concat(o);v(e,(function(e){var p=e.source,l=e.target,u=function(e){return E(e.waypoints,(function(e){return(e=km(e)).original&&(e.original=km(e.original)),e}))}(e),h=Rm(n),d={};Am(c,p)&&Am(c,l)?(u=E(u,(function(e){return Pm(e,i,n)&&(e[h]=e[h]+t[h]),e.original&&Pm(e.original,i,n)&&(e.original[h]=e.original[h]+t[h]),e})),s._modeling.updateWaypoints(e,u,{labelBehavior:!1})):(Am(c,p)||Am(c,l))&&(Am(r,p)?d.connectionStart=Ju(e,p,t):Am(r,l)?d.connectionEnd=eh(e,l,t):Am(o,p)?d.connectionStart=Zu(e,p,a[p.id]):Am(o,l)&&(d.connectionEnd=Qu(e,l,a[l.id])),s._modeling.layoutConnection(e,d))}))},Mm.$inject=["modeling"],Mm.prototype.execute=function(e){var t=e.shape,n=t.children;e.oldChildrenVisibility=Tm(n),t.collapsed=!t.collapsed;var i=Bm(n,t.collapsed);return[t].concat(i)},Mm.prototype.revert=function(e){var t=e.shape,n=e.oldChildrenVisibility,i=Dm(t.children,n);return t.collapsed=!t.collapsed,[t].concat(i)},Nm.$inject=["modeling"],Nm.prototype.execute=function(e){var t=e.shape,n=e.newHost,i=t.host;return e.oldHost=i,e.attacherIdx=jm(i,t),Om(n,t),t.host=n,t},Nm.prototype.revert=function(e){var t=e.shape,n=e.newHost,i=e.oldHost,r=e.attacherIdx;return t.host=i,jm(n,t),Om(i,t,r),t},Lm.prototype.execute=function(e){var t=e.connection,n=e.newWaypoints;return e.oldWaypoints=t.waypoints,t.waypoints=n,t},Lm.prototype.revert=function(e){var t=e.connection,n=e.oldWaypoints;return t.waypoints=n,t},$m.$inject=["eventBus","elementFactory","commandStack"],$m.prototype.getHandlers=function(){return{"shape.append":tm,"shape.create":am,"shape.delete":hm,"shape.move":bm,"shape.resize":Sm,"shape.replace":Em,"shape.toggleCollapse":Mm,spaceTool:Cm,"label.create":sm,"connection.create":nm,"connection.delete":lm,"connection.move":ym,"connection.layout":mm,"connection.updateWaypoints":Lm,"connection.reconnect":xm,"elements.create":rm,"elements.move":_m,"elements.delete":um,"elements.distribute":dm,"elements.align":em,"element.updateAttachment":Nm}},$m.prototype.registerHandlers=function(e){v(this.getHandlers(),(function(t,n){e.registerHandler(n,t)}))},$m.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)},$m.prototype.updateAttachment=function(e,t){var n={shape:e,newHost:t};this._commandStack.execute("element.updateAttachment",n)},$m.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)},$m.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)},$m.prototype.layoutConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.layout",n)},$m.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},$m.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},$m.prototype.createElements=function(e,t,n,i,r){p(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},$m.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},$m.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},$m.prototype.removeElements=function(e){var t={elements:e};this._commandStack.execute("elements.delete",t)},$m.prototype.distributeElements=function(e,t,n){var i={groups:e,axis:t,dimension:n};this._commandStack.execute("elements.distribute",i)},$m.prototype.removeShape=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.delete",n)},$m.prototype.removeConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.delete",n)},$m.prototype.replaceShape=function(e,t,n){var i={oldShape:e,newData:t,hints:n||{}};return this._commandStack.execute("shape.replace",i),i.newShape},$m.prototype.alignElements=function(e,t){var n={elements:e,alignment:t};this._commandStack.execute("elements.align",n)},$m.prototype.resizeShape=function(e,t,n,i){var r={shape:e,newBounds:t,minBounds:n,hints:i};this._commandStack.execute("shape.resize",r)},$m.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)},$m.prototype.updateWaypoints=function(e,t,n){var i={connection:e,newWaypoints:t,hints:n||{}};this._commandStack.execute("connection.updateWaypoints",i)},$m.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)},$m.prototype.reconnectStart=function(e,t,n,i){i||(i={}),this.reconnect(e,t,e.target,n,L(i,{docking:"source"}))},$m.prototype.reconnectEnd=function(e,t,n,i){i||(i={}),this.reconnect(e,e.source,t,n,L(i,{docking:"target"}))},$m.prototype.connect=function(e,t,n,i){return this.createConnection(e,t,n||{},e.parent,i)},$m.prototype._create=function(e,t){return t instanceof Tn?t:this._elementFactory.create(e,t)},$m.prototype.toggleCollapse=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.toggleCollapse",n)},Im.$inject=["elementRegistry"],Im.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 b(t,(function(t,n){return t[n]=e.get(n),t}),{})}(n,S(i));return Fm(n,i),e.oldProperties=o,e.changed=r,r},Im.prototype.revert=function(e){var t=e.oldProperties,n=e.moddleElement,i=e.changed;return Fm(n,t),i},Im.prototype._getVisualReferences=function(e){var t=this._elementRegistry;return mr(e,"bpmn:DataObject")?function(e,t){return t.filter((function(t){return mr(t,"bpmn:DataObjectReference")&&gr(t).dataObjectRef===e}))}(e,t):[]};var zm="default",Hm="id",Vm="di",Gm={width:0,height:0};function Wm(e,t,n,i){this._elementRegistry=e,this._moddle=t,this._modeling=n,this._textRenderer=i}function Um(e,t){return Hm in e&&e[Hm]!==t[Hm]}function qm(e,t){var n=e.businessObject,i=vr(e);v(t,(function(e,t){t!==Vm?n.set(t,e):i&&function(e,t){v(t,(function(t,n){e.set(n,t)}))}(i,e)}))}Wm.$inject=["elementRegistry","moddle","modeling","textRenderer"],Wm.prototype.execute=function(e){var t=e.element,n=[t];if(!t)throw new Error("element required");var i=this._elementRegistry,r=this._moddle.ids,o=t.businessObject,a=function(e){var t=L({},e);return Km.forEach((function(n){n in e&&(t[n]=gr(t[n]))})),t}(e.properties),s=e.oldProperties||function(e,t){var n=S(t),i=e.businessObject,r=vr(e);return b(n,(function(e,n){return e[n]=n!==Vm?i.get(n):function(e,t){return b(t,(function(t,n){return t[n]=e&&e.get(n),t}),{})}(r,S(t.di)),e}),{})}(t,a);return Um(a,o)&&(r.unclaim(o[Hm]),i.updateId(t,a[Hm]),r.claim(a[Hm],o)),zm in a&&(a[zm]&&n.push(i.get(a[zm].id)),o[zm]&&n.push(i.get(o[zm].id))),qm(t,a),e.oldProperties=s,e.changed=n,n},Wm.prototype.postExecute=function(e){var t=e.element.label,n=t&&gr(t).name;if(n){var i=this._textRenderer.getExternalLabelBounds(t,n);this._modeling.resizeShape(t,i,Gm)}},Wm.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 qm(t,i),Um(n,r)&&(a.unclaim(n[Hm]),o.updateId(t,i[Hm]),a.claim(i[Hm],r)),e.changed};var Km=["default"];function Ym(e,t){this._canvas=e,this._modeling=t}function Xm(e,t){this._modeling=e,this._spaceTool=t}function Zm(e){this._modeling=e}function Qm(e,t){this._modeling=e,this._spaceTool=t}Ym.$inject=["canvas","modeling"],Ym.prototype.execute=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,r=t.getRootElement(),o=r.businessObject,a=o.$parent,s=vr(r);return t.setRootElement(n),t.removeRootElement(r),_t(a.rootElements,i),i.$parent=a,vt(a.rootElements,o),o.$parent=null,r.di=null,s.bpmnElement=i,n.di=s,e.oldRoot=r,[]},Ym.prototype.revert=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,r=e.oldRoot,o=r.businessObject,a=i.$parent,s=vr(n);return t.setRootElement(r),t.removeRootElement(n),vt(a.rootElements,i),i.$parent=null,_t(a.rootElements,o),o.$parent=a,n.di=null,s.bpmnElement=o,r.di=s,[]},Xm.$inject=["modeling","spaceTool"],Xm.prototype.preExecute=function(e){var t=this._spaceTool,n=this._modeling,i=e.shape,r=e.location,o=fu(i),a=o===i,s=a?i:i.parent,c=du(s),p=Or(i);if(p?"left"===r?r="top":"right"===r&&(r="bottom"):"top"===r?r="left":"bottom"===r&&(r="right"),!c.length){var l=p?{x:i.x+uu,y:i.y,width:i.width-uu,height:i.height}:{x:i.x,y:i.y+uu,width:i.width,height:i.height-uu};n.createShape({type:"bpmn:Lane",isHorizontal:p},l,s)}var u,h,d,f,m,y=[];lt(o,(function(e){return y.push(e),e.label&&y.push(e.label),e===i?[]:g(e.children,(function(e){return e!==i}))})),"top"===r?(u=-120,d=(h=i.y)+10,f="n",m="y"):"left"===r?(u=-120,d=(h=i.x)+10,f="w",m="x"):"bottom"===r?(u=120,d=(h=i.y+i.height)-10,f="s",m="y"):"right"===r&&(u=120,d=(h=i.x+i.width)-10,f="e",m="x");var v=t.calculateAdjustments(y,m,u,d),_=p?{x:0,y:u}:{x:u,y:0};t.makeSpace(v.movingShapes,v.resizingShapes,_,f,d);var b=p?{x:i.x+(a?uu:0),y:h-("top"===r?120:0),width:i.width-(a?uu:0),height:120}:{x:h-("left"===r?120:0),y:i.y+(a?uu:0),width:120,height:i.height-(a?uu:0)};e.newLane=n.createShape({type:"bpmn:Lane",isHorizontal:p},b,s)},Zm.$inject=["modeling"],Zm.prototype.preExecute=function(e){var t=this._modeling,n=e.shape,i=e.count,r=du(n),o=r.length;if(o>i)throw new Error(`more than <${i}> child lanes`);var a,s,c,p,l=Or(n),u=l?n.height:n.width,h=Math.round(u/i);for(p=0;p<i;p++)a=p===i-1?u-h*p:h,s=l?{x:n.x+uu,y:n.y+p*h,width:n.width-uu,height:a}:{x:n.x+p*h,y:n.y+uu,width:a,height:n.height-uu},p<o?t.resizeShape(r[p],s):(c={type:"bpmn:Lane",isHorizontal:l},t.createShape(c,s,n))},Qm.$inject=["modeling","spaceTool"],Qm.prototype.preExecute=function(e){var t=e.shape,n=e.newBounds;!1!==e.balanced?this.resizeBalanced(t,n):this.resizeSpace(t,n)},Qm.prototype.resizeBalanced=function(e,t){var n=this._modeling,i=mu(e,t);n.resizeShape(e,t),i.forEach((function(e){n.resizeShape(e.shape,e.newBounds)}))},Qm.prototype.resizeSpace=function(e,t){var n,i,r,o,a,s=this._spaceTool,c=ln(e),p=ru(ln(t),c),l=fu(e),u=[],h=[];lt(l,(function(e){return u.push(e),(mr(e,"bpmn:Lane")||mr(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 Jm="flowNodeRef",ey="lanes";function ty(e){this._elementRegistry=e}function ny(e){this._moddle=e}ty.$inject=["elementRegistry"],ty.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){if(!e.parent)return[];var t=function(e){var t=fu(e);return r[t.id]||(r[t.id]=hu(t)),r[t.id]}(e);return t.filter((function(t){return n=e,i=ln(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=fu(e);if(t&&-1===n.indexOf(t)){var i=t.children.filter((function(e){return mr(e,"bpmn:FlowNode")}));i.forEach(a),n.push(t)}})),e.forEach(a),o.forEach((function(e){var t=e.businessObject,n=t.get(ey).slice(),r=s(e);i.push({flowNode:t,remove:n,add:r})})),t.forEach((function(e){var t=e.businessObject;e.parent||t.get(Jm).forEach((function(e){i.push({flowNode:e,remove:[t],add:[]})}))})),i},ty.prototype.execute=function(e){var t=e.updates;return t||(t=e.updates=this._computeUpdates(e.flowNodeShapes,e.laneShapes)),t.forEach((function(e){var t=e.flowNode,n=t.get(ey);e.remove.forEach((function(e){vt(n,e),vt(e.get(Jm),t)})),e.add.forEach((function(e){_t(n,e),_t(e.get(Jm),t)}))})),[]},ty.prototype.revert=function(e){return e.updates.forEach((function(e){var t=e.flowNode,n=t.get(ey);e.add.forEach((function(e){vt(n,e),vt(e.get(Jm),t)})),e.remove.forEach((function(e){_t(n,e),_t(e.get(Jm),t)}))})),[]},ny.$inject=["moddle"],ny.prototype.execute=function(e){var t=this._moddle.ids,n=e.id,i=e.element;return e.claiming?t.claim(n,i):t.unclaim(n),[]},ny.prototype.revert=function(e){var t=this._moddle.ids,n=e.id,i=e.element;return e.claiming?t.unclaim(n):t.claim(n,i),[]};var iy={fill:void 0,stroke:void 0};function ry(e){this._commandStack=e,this._normalizeColor=function(e){if(e){if(d(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}`)}}}ry.$inject=["commandStack"],ry.prototype.postExecute=function(e){var t=e.elements,n=e.colors||iy,i=this,r={};"fill"in n&&L(r,{"background-color":this._normalizeColor(n.fill)}),"stroke"in n&&L(r,{"border-color":this._normalizeColor(n.stroke)}),v(t,(function(e){var t=an(e)?$(r,["border-color"]):r,n=vr(e);if(function(e){"border-color"in e&&(e.stroke=e["border-color"]);"background-color"in e&&(e.fill=e["background-color"])}(t),sn(e))i._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:n.label,properties:{color:r["border-color"]}});else{if(!yr(n,["bpmndi:BPMNEdge","bpmndi:BPMNShape"]))return;i._commandStack.execute("element.updateProperties",{element:e,properties:{di:t}})}}))};var oy={width:0,height:0};function ay(e,t,n){function i(e,t){var n=e.label||e,i=e.labelTarget||e;return function(e,t){var n=e.businessObject,i=Gr(n);if(i)if("categoryValueRef"===i){if(!n[i])return e;n[i].value=t}else n[i]=t}(n,t),[n,i]}this.preExecute=function(t){var n=t.element,i=n.businessObject,r=t.newLabel;if(!sn(n)&&Fr(n)&&!zr(n)&&!sy(r)){var o=Vr(n);o={x:o.x,y:o.y+7},e.createLabel(n,o,{id:i.id+"_label",businessObject:i,di:n.di})}},this.execute=function(e){return e.oldLabel=Wr(e.element),i(e.element,e.newLabel)},this.revert=function(e){return i(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(sn(r)||mr(r,"bpmn:TextAnnotation"))if(sn(r)&&sy(o))!1!==s.removeShape&&e.removeShape(r,{unsetLabel:!1});else{var c=Wr(i);void 0===a&&(a=t.getExternalLabelBounds(r,c)),a&&e.resizeShape(r,a,oy)}}}function sy(e){return!e||!e.trim()}function cy(e,t,n,i){$m.call(this,e,t,n),this._bpmnRules=i}function py(){}ay.$inject=["modeling","textRenderer","bpmnFactory"],e(cy,$m),cy.$inject=["eventBus","elementFactory","commandStack","bpmnRules"],cy.prototype.getHandlers=function(){var e=$m.prototype.getHandlers.call(this);return e["element.updateModdleProperties"]=Im,e["element.updateProperties"]=Wm,e["canvas.updateRoot"]=Ym,e["lane.add"]=Xm,e["lane.resize"]=Qm,e["lane.split"]=Zm,e["lane.updateRefs"]=ty,e["id.updateClaim"]=ny,e["element.setColor"]=ry,e["element.updateLabel"]=ay,e},cy.prototype.updateLabel=function(e,t,n,i){this._commandStack.execute("element.updateLabel",{element:e,newLabel:t,newBounds:n,hints:i||{}})},cy.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)},cy.prototype.updateModdleProperties=function(e,t,n){this._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:t,properties:n})},cy.prototype.updateProperties=function(e,t){this._commandStack.execute("element.updateProperties",{element:e,properties:t})},cy.prototype.resizeLane=function(e,t,n){this._commandStack.execute("lane.resize",{shape:e,newBounds:t,balanced:n})},cy.prototype.addLane=function(e,t){var n={shape:e,location:t};return this._commandStack.execute("lane.add",n),n.newLane},cy.prototype.splitLane=function(e,t){this._commandStack.execute("lane.split",{shape:e,count:t})},cy.prototype.makeCollaboration=function(){var e=this._create("root",{type:"bpmn:Collaboration"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},cy.prototype.makeProcess=function(){var e=this._create("root",{type:"bpmn:Process"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},cy.prototype.updateLaneRefs=function(e,t){this._commandStack.execute("lane.updateRefs",{flowNodeShapes:e,laneShapes:t})},cy.prototype.claimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t,claiming:!0})},cy.prototype.unclaimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t})},cy.prototype.setColor=function(e,t){e.length||(e=[e]),this._commandStack.execute("element.setColor",{elements:e,colors:t})},py.prototype.layoutConnection=function(e,t){return[(t=t||{}).connectionStart||dn(t.source||e.source),t.connectionEnd||dn(t.target||e.target)]};var ly=Math.round,uy={"h:h":20,"v:v":20,"h:v":-10,"v:h":-10};function hy(e,t,n){var i,r,o,a=fn(t,e,5),s=n.split(":")[0],c=ly((t.x-e.x)/2+e.x),p=ly((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,d=!1;return l?(i=u?{x:c,y:e.y}:{x:e.x,y:p},r=u?"h:h":"v:v"):(h=function(e,t){return!{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/./,v:/./}[t].test(e)}(a,s),r=u?"h:v":"v:h",h?u?(d=p===e.y,i={x:e.x+20*(/l/.test(s)?-1:1),y:d?p+20:p}):i={x:(d=c===e.x)?c+20:c,y:e.y+20*(/t/.test(s)?-1:1)}:i={x:c,y:p}),{waypoints:fy(e,i,r).concat(i),directions:r,turnNextDirections:d}}function dy(e){return e.split(":").reverse().join(":")}function fy(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(_y(n)){var i=function(e,t,n){return hy(e,t,n)}(e,t,n),r=function(e,t,n){var i=hy(t,e,dy(n));return{waypoints:i.waypoints.slice().reverse(),directions:dy(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:fy(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=ly((t.x-e.x)/2+e.x),r=ly((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 my(e,t,n,i,r){var o=_(r&&r.preferredLayouts||[],"straight")[0]||"h:h",a=fn(e,t,uy[o]||0),s=function(e,t){if(_y(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||dn(e),i=i||dn(t);var c=s.split(":"),p=by(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));return function(e,t,n){var i=fy(e,t,n);return i.unshift(e),i.push(t),xy(i)}(p,by(i,t,c[1],a),s)}function yy(e,t,n,i,r,o){var a;return p(n)&&(r=n,o=i,n=dn(e),i=dn(t)),r=r||[],a=-1!==(o=L({preferredLayouts:[]},o)).preferredLayouts.indexOf("straight")&&function(e,t,n,i,r){var o,a,s={};if(a=fn(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?gy(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:gy(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||(a=o.connectionEnd&&function(e,t,n,i){var r=i.slice().reverse();return r=vy(e,t,n,r),r?r.reverse():null}(t,e,i,r),a||((a=o.connectionStart&&vy(e,t,n,r))||(!o.connectionStart&&!o.connectionEnd&&r&&r.length?r:my(e,t,n,i,o))))}function gy(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 vy(e,t,n,i){if(function(e){return e.length<3||!(e.length>4)&&!!m(e,(function(t,n){var i=e[n-1];return i&&xt(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(Et(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(Ct(e[i],t,20)||Ct(e[i],n,20))return e.slice(i);return e}(a,e,t),r!==a&&(a=vy(e,t,n,r)),a&&Et(a)?null:a}function _y(e){return e&&/t|r|b|l/.test(e)}function by(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 xy(e){return e.reduce((function(t,n,i){return wt(t[t.length-1],e[i+1],n,0)||t.push(n),t}),[])}var wy={default:["h:h"],fromGateway:["v:h"],toGateway:["h:v"],loop:{fromTop:["t:r"],fromRight:["r:b"],fromLeft:["l:t"],fromBottom:["b:l"]},boundaryLoop:{alternateHorizontalSide:"b",alternateVerticalSide:"l",default:"v"},messageFlow:["straight","v:v"],subProcess:["straight","h:h"],isHorizontal:!0},Ey={default:["v:v"],fromGateway:["h:v"],toGateway:["v:h"],loop:{fromTop:["t:l"],fromRight:["r:t"],fromLeft:["l:b"],fromBottom:["b:r"]},boundaryLoop:{alternateHorizontalSide:"t",alternateVerticalSide:"r",default:"h"},messageFlow:["straight","h:h"],subProcess:["straight","v:v"],isHorizontal:!1},Sy={top:"bottom","top-right":"bottom-left","top-left":"bottom-right",right:"left",bottom:"top","bottom-right":"top-left","bottom-left":"top-right",left:"right"},Cy={top:"t",right:"r",bottom:"b",left:"l"};function ky(e){this._elementRegistry=e}function Ry(e,t){return mr(t,"bpmn:Participant")?"source":mr(e,"bpmn:Participant")?"target":Ty(t)?"source":Ty(e)||mr(t,"bpmn:Event")?"target":mr(e,"bpmn:Event")?"source":null}function Py(e){return Ty(e)?"target":"source"}function Ay(e,t){return e?e.original||e:dn(t)}function My(e,t){return mr(t,"bpmn:Activity")&&mr(e,"bpmn:BoundaryEvent")&&t.businessObject.isForCompensation}function Ty(e){return mr(e,"bpmn:SubProcess")&&jr(e)}function By(e,t){return e===t}function Dy(e){var t=/right|left/.exec(e);return t&&t[0]}function Ny(e){var t=/top|bottom/.exec(e);return t&&t[0]}function jy(e,t){return Sy[e]===t}function Oy(e){return"right"===e||"left"===e}function Ly(e,t,n){var i=t.waypoints,r=i&&i.length&&fn(i[0],e);return"top"===r?n.loop.fromTop:"right"===r?n.loop.fromRight:"left"===r?n.loop.fromLeft:n.loop.fromBottom}function $y(e,t,n,i){var r,o,a,s,c=dn(e),p=dn(t),l=(s=(a=e).host,fn(dn(a),s,-10)),u=By(e.host,t),h=-1!==["top","right","bottom","left"].indexOf(l),d=fn(p,c,{x:e.width/2+t.width/2,y:e.height/2+t.height/2});return u?function(e,t,n,i,r,o){var a,s=t?e:o.isHorizontal?Ny(e):Dy(e),c=Cy[s];a=t?Oy(e)?Iy("y",n,i,r)?"h":o.boundaryLoop.alternateHorizontalSide:Iy("x",n,i,r)?"v":o.boundaryLoop.alternateVerticalSide:o.boundaryLoop.default;return[c+":"+a]}(l,h,e,t,n,i):(r=function(e,t,n,i){if(n)return Cy[e];var r=Ny(e),o=Dy(e),a=Ny(t),s=Dy(t);if(i){if(By(r,a)||jy(o,s))return Cy[r]}else if(By(o,s)||jy(r,a))return Cy[o];return Cy[i?o:r]}(l,d,h,i.isHorizontal),o=function(e,t,n,i){if(n)return Oy(e)?function(e,t){var n=Dy(e),i=Sy[n];return-1!==t.indexOf(i)}(e,t)||By(e,t)?"h":"v":function(e,t){var n=Ny(e),i=Sy[n];return-1!==t.indexOf(i)}(e,t)||By(e,t)?"v":"h";return i?By(Ny(e),Ny(t))?"h":"v":By(Dy(e),Dy(t))?"v":"h"}(l,d,h,i.isHorizontal),[r+":"+o])}function Iy(e,t,n,i){return!(Fy(e,i,n,40)||Fy(e,i,{x:n.x+n.width,y:n.y+n.height},40)||Fy(e,i,dn(t),40))}function Fy(e,t,n,i){return Math.abs(t[e]-n[e])<i}function zy(e){return L({original:e.point.original||e.point},e.actual)}function Hy(e,t){this._elementRegistry=e,this._graphicsFactory=t}e(ky,py),ky.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,p=this._elementRegistry;if(s||(s=Ay(a&&a[0],r)),c||(c=Ay(a&&a[a.length-1],o)),(mr(e,"bpmn:Association")||mr(e,"bpmn:DataAssociation"))&&a&&!My(r,o))return[].concat([s],a.slice(1,-1),[c]);var l=Jc(r,p)?wy:Ey;return mr(e,"bpmn:MessageFlow")?n=function(e,t,n){return{preferredLayouts:n.messageFlow,preserveDocking:Ry(e,t)}}(r,o,l):(mr(e,"bpmn:SequenceFlow")||My(r,o))&&(n=r===o?{preferredLayouts:Ly(r,e,l)}:mr(r,"bpmn:BoundaryEvent")?{preferredLayouts:$y(r,o,c,l)}:Ty(r)||Ty(o)?{preferredLayouts:l.subProcess,preserveDocking:Py(r)}:mr(r,"bpmn:Gateway")?{preferredLayouts:l.fromGateway}:mr(o,"bpmn:Gateway")?{preferredLayouts:l.toGateway}:{preferredLayouts:l.default}),n&&(i=xy(yy(r,o,s,c,a,n=L(n,t)))),i||[s,c]},ky.$inject=["elementRegistry"],Hy.$inject=["elementRegistry","graphicsFactory"],Hy.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(zy(i)),o.push(zy(r)),o},Hy.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}},Hy.prototype._getIntersection=function(e,t,n){return mn(this._getShapePath(e),this._getConnectionPath(t),n)},Hy.prototype._getConnectionPath=function(e){return this._graphicsFactory.getConnectionPath(e)},Hy.prototype._getShapePath=function(e){return this._graphicsFactory.getShapePath(e)},Hy.prototype._getGfx=function(e){return this._elementRegistry.getGraphics(e)};var Vy={__init__:["modeling","bpmnUpdater"],__depends__:[Jh,Dd,jd,$d,vf,Ff,Gf,Kf,_a,Mo,$f],bpmnFactory:["type",Yf],bpmnUpdater:["type",Xf],elementFactory:["type",Qf],modeling:["type",cy],layouter:["type",ky],connectionDocking:["type",Hy]};const Gy=Math.round;function Wy(e,t,n,i,r,o){this._complexPreview=e,this._connectionDocking=t,this._elementFactory=n,this._eventBus=i,this._layouter=r,this._rules=o}Wy.prototype.create=function(e,t,n){const i=this._complexPreview,r=this._connectionDocking,o=this._elementFactory,a=this._eventBus,s=this._layouter,p=this._rules,l=o.createShape(L({type:t},n)),u=a.fire("autoPlace",{source:e,shape:l});if(!u)return;L(l,{x:u.x-Gy(l.width/2),y:u.y-Gy(l.height/2)});const h=p.allowed("connection.create",{source:e,target:l,hints:{targetParent:e.parent}});let d=null;h&&(d=o.createConnection(h),d.waypoints=s.layoutConnection(d,{source:e,target:l}),d.waypoints=r.getCroppedWaypoints(d,e,l)),i.create({created:[l,d].filter((e=>!c(e)))})},Wy.prototype.cleanUp=function(){this._complexPreview.cleanUp()},Wy.$inject=["complexPreview","connectionDocking","elementFactory","eventBus","layouter","rules"];var Uy={__depends__:[ip,Tl,Vy],__init__:["appendPreview"],appendPreview:["type",Wy]},qy=Math.min,Ky=Math.max;function Yy(e){e.preventDefault()}function Xy(e){e.stopPropagation()}function Zy(e){this.container=e.container,this.parent=he('<div class="djs-direct-editing-parent"><div class="djs-direct-editing-content" contenteditable="true"></div></div>'),this.content=fe("[contenteditable]",this.parent),this.keyHandler=e.keyHandler||function(){},this.resizeHandler=e.resizeHandler||function(){},this.autoResize=O(this.autoResize,this),this.handlePaste=O(this.handlePaste,this)}function Qy(e,t){this._eventBus=e,this._canvas=t,this._providers=[],this._textbox=new Zy({container:t.getContainer(),keyHandler:O(this._handleKey,this),resizeHandler:O(this._handleResize,this)})}Zy.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"]);L(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 L(o.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},c),i.centerVertically&&L(o.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},c),o.innerText=n,oe.bind(o,"keydown",this.keyHandler),oe.bind(o,"mousedown",Xy),oe.bind(o,"paste",this.handlePaste),i.autoResize&&oe.bind(o,"input",this.autoResize),i.resizable&&this.resizable(t),a.appendChild(r),this.setSelection(o.lastChild,o.lastChild&&o.lastChild.length),r},Zy.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)}},Zy.prototype.insertText=function(e){e=e.replace(/\r\n|\r|\n/g,"\n"),document.execCommand("insertText",!1,e)||this._insertTextIE(e)},Zy.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&&ye(t)})),n=o,i=s+e.length}n&&void 0!==i&&setTimeout((function(){self.setSelection(n,i)}))},Zy.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})}},Zy.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=he('<div class="djs-direct-editing-resize-handle"></div>');var u=function(n){Yy(n),Xy(n);var u=qy(Ky(p+n.clientX-s,i),o),h=qy(Ky(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){Yy(e),Xy(e),oe.unbind(document,"mousemove",u,!1),oe.unbind(document,"mouseup",h,!1)};oe.bind(n,"mousedown",(function(e){Yy(e),Xy(e),s=e.clientX,c=e.clientY;var n=t.getBoundingClientRect();p=n.width,l=n.height,oe.bind(document,"mousemove",u),oe.bind(document,"mouseup",h)}))}L(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)},Zy.prototype.destroy=function(){var e=this.parent,t=this.content,n=this.resizeHandle;t.innerText="",e.removeAttribute("style"),t.removeAttribute("style"),oe.unbind(t,"keydown",this.keyHandler),oe.unbind(t,"mousedown",Xy),oe.unbind(t,"input",this.autoResize),oe.unbind(t,"paste",this.handlePaste),n&&(n.removeAttribute("style"),ye(n)),ye(e)},Zy.prototype.getValue=function(){return this.content.innerText.trim()},Zy.prototype.getSelection=function(){return window.getSelection().getRangeAt(0)},Zy.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)},Qy.$inject=["eventBus","canvas"],Qy.prototype.registerProvider=function(e){this._providers.push(e)},Qy.prototype.isActive=function(e){return!(!this._active||e&&this._active.element!==e)},Qy.prototype.cancel=function(){this._active&&(this._fire("cancel"),this.close())},Qy.prototype._fire=function(e,t){this._eventBus.fire("directEditing."+e,t||{active:this._active})},Qy.prototype.close=function(){this._textbox.destroy(),this._fire("deactivate"),this._active=null,this.resizable=void 0,this._canvas.restoreFocus&&this._canvas.restoreFocus()},Qy.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()}},Qy.prototype.getValue=function(){return this._textbox.getValue()},Qy.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())},Qy.prototype._handleResize=function(e){this._fire("resize",e)},Qy.prototype.activate=function(e){var t;this.isActive()&&this.cancel();var n=m(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 Jy={__depends__:[ha],__init__:["directEditing"],directEditing:["type",Qy]};function eg(e){return function(t){var n=t.target,i=gr(e),r=i.eventDefinitions&&i.eventDefinitions[0],o=i.$type===n.type,a=(r&&r.$type)===n.eventDefinitionType,s=!!n.triggeredByEvent==!!i.triggeredByEvent,c=void 0===n.isExpanded||n.isExpanded===jr(e);return!(o&&a&&s&&c)}}var tg=[{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"}}],ng=[{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"}}],ig=[{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"}}],rg=[{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"}}],og=[{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"}}],ag=[{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}}],sg=[{label:"Transaction",actionName:"replace-with-transaction",className:"bpmn-icon-transaction",target:{type:"bpmn:Transaction",isExpanded:!0}},{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}}],cg=sg,pg=[{label:"Task",actionName:"replace-with-task",className:"bpmn-icon-task",target:{type:"bpmn:Task"}},{label:"User task",actionName:"replace-with-user-task",className:"bpmn-icon-user",target:{type:"bpmn:UserTask"}},{label:"Service task",actionName:"replace-with-service-task",className:"bpmn-icon-service",target:{type:"bpmn:ServiceTask"}},{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:"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:"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}}],lg=[{label:"Data store reference",actionName:"replace-with-data-store-reference",className:"bpmn-icon-data-store",target:{type:"bpmn:DataStoreReference"}}],ug=[{label:"Data object reference",actionName:"replace-with-data-object-reference",className:"bpmn-icon-data-object",target:{type:"bpmn:DataObjectReference"}}],hg=[{label:"Message boundary event",actionName:"replace-with-message-boundary",className:"bpmn-icon-intermediate-event-catch-message",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:MessageEventDefinition",cancelActivity:!0}},{label:"Timer boundary event",actionName:"replace-with-timer-boundary",className:"bpmn-icon-intermediate-event-catch-timer",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:TimerEventDefinition",cancelActivity:!0}},{label:"Escalation boundary event",actionName:"replace-with-escalation-boundary",className:"bpmn-icon-intermediate-event-catch-escalation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",cancelActivity:!0}},{label:"Conditional boundary event",actionName:"replace-with-conditional-boundary",className:"bpmn-icon-intermediate-event-catch-condition",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",cancelActivity:!0}},{label:"Error boundary event",actionName:"replace-with-error-boundary",className:"bpmn-icon-intermediate-event-catch-error",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ErrorEventDefinition",cancelActivity:!0}},{label:"Cancel boundary event",actionName:"replace-with-cancel-boundary",className:"bpmn-icon-intermediate-event-catch-cancel",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:CancelEventDefinition",cancelActivity:!0}},{label:"Signal boundary event",actionName:"replace-with-signal-boundary",className:"bpmn-icon-intermediate-event-catch-signal",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:SignalEventDefinition",cancelActivity:!0}},{label:"Compensation boundary event",actionName:"replace-with-compensation-boundary",className:"bpmn-icon-intermediate-event-catch-compensation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:CompensateEventDefinition",cancelActivity:!0}},{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}}],dg=[{label:"Message start event",actionName:"replace-with-message-start",className:"bpmn-icon-start-event-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition",isInterrupting:!0}},{label:"Timer start event",actionName:"replace-with-timer-start",className:"bpmn-icon-start-event-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition",isInterrupting:!0}},{label:"Conditional start event",actionName:"replace-with-conditional-start",className:"bpmn-icon-start-event-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",isInterrupting:!0}},{label:"Signal start event",actionName:"replace-with-signal-start",className:"bpmn-icon-start-event-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition",isInterrupting:!0}},{label:"Error start event",actionName:"replace-with-error-start",className:"bpmn-icon-start-event-error",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ErrorEventDefinition",isInterrupting:!0}},{label:"Escalation start event",actionName:"replace-with-escalation-start",className:"bpmn-icon-start-event-escalation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",isInterrupting:!0}},{label:"Compensation start event",actionName:"replace-with-compensation-start",className:"bpmn-icon-start-event-compensation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:CompensateEventDefinition",isInterrupting:!0}},{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}}],fg=[{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"}],mg=[{label:"Expanded pool/participant",actionName:"replace-with-expanded-pool",className:"bpmn-icon-participant",target:{type:"bpmn:Participant",isExpanded:!0}},{label:function(e){var t="Empty pool/participant";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}}],yg={"start-event-non-interrupting":'\n <svg viewBox="0 0 2048 2048" xmlns="http://www.w3.org/2000/svg">\n <g transform="translate(0 995.64)">\n <path d="m1899 28.357c21.545 567.43-598.38 1023.5-1133.6 835.92-548.09-147.21-801.57-873.95-463.59-1330 302.62-480.3 1071.7-507.54 1407.6-49.847 122.14 153.12 190.07 348.07 189.59 543.91z" fill="none" stroke="currentColor" stroke-dasharray="418.310422, 361.2328165" stroke-linecap="round" stroke-width="100"/>\n </g>\n </svg>',"intermediate-event-non-interrupting":'\n <svg viewBox="0 0 2048 2048" xmlns="http://www.w3.org/2000/svg">\n <g transform="translate(0 995.64)" fill="none" stroke="currentColor" stroke-linecap="round">\n <circle cx="1024" cy="28.357" r="875" stroke-dasharray="418.310422, 361.2328165" stroke-width="100"/>\n <circle cx="1024" cy="28.357" r="685" stroke-dasharray="348.31044857,261.23283643" stroke-dashoffset="500" stroke-width="100"/>\n </g>\n </svg>'};function gg(e,t,n,i,r,o,a,s){this._bpmnFactory=e,this._popupMenu=t,this._modeling=n,this._moddle=i,this._bpmnReplace=r,this._rules=o,this._translate=a,this._moddleCopy=s,this._register()}gg.$inject=["bpmnFactory","popupMenu","modeling","moddle","bpmnReplace","rules","translate","moddleCopy"],gg.prototype._register=function(){this._popupMenu.registerProvider("bpmn-replace",this)},gg.prototype.getPopupMenuEntries=function(e){var t=e.businessObject,n=this._rules,i=[];if(p(e)||!n.allowed("shape.replace",{element:e}))return{};var r=eg(e);return mr(t,"bpmn:DataObjectReference")?this._createEntries(e,lg):mr(t,"bpmn:DataStoreReference")&&!mr(e.parent,"bpmn:Collaboration")?this._createEntries(e,ug):mr(t,"bpmn:StartEvent")&&!mr(t.$parent,"bpmn:SubProcess")?(i=g(tg,r),this._createEntries(e,i)):mr(t,"bpmn:Participant")?(i=g(mg,(function(t){return jr(e)!==t.target.isExpanded})),this._createEntries(e,i)):mr(t,"bpmn:StartEvent")&&Lr(t.$parent)?(i=g(dg,(function(e){var n=!1!==e.target.isInterrupting,i=t.isInterrupting===n;return r(e)||!r(e)&&!i})),this._createEntries(e,i)):mr(t,"bpmn:StartEvent")&&!Lr(t.$parent)&&mr(t.$parent,"bpmn:SubProcess")?(i=g(ng,r),this._createEntries(e,i)):mr(t,"bpmn:EndEvent")?(i=g(rg,(function(e){return!("bpmn:CancelEventDefinition"==e.target.eventDefinitionType&&!mr(t.$parent,"bpmn:Transaction"))&&r(e)})),this._createEntries(e,i)):mr(t,"bpmn:BoundaryEvent")?(i=g(hg,(function(e){var n=e.target;if("bpmn:CancelEventDefinition"==n.eventDefinitionType&&!mr(t.attachedToRef,"bpmn:Transaction"))return!1;var i=!1!==n.cancelActivity,o=t.cancelActivity==i;return r(e)||!r(e)&&!o})),this._createEntries(e,i)):mr(t,"bpmn:IntermediateCatchEvent")||mr(t,"bpmn:IntermediateThrowEvent")?(i=g(ig,r),this._createEntries(e,i)):mr(t,"bpmn:Gateway")?(i=g(og,r),this._createEntries(e,i)):mr(t,"bpmn:Transaction")?(i=g(sg,r),this._createEntries(e,i)):Lr(t)&&jr(e)?(i=g(cg,r),this._createEntries(e,i)):mr(t,"bpmn:SubProcess")&&jr(e)?(i=g(ag,r),this._createEntries(e,i)):mr(t,"bpmn:AdHocSubProcess")&&!jr(e)?(i=g(pg,(function(e){var t=e.target,n="bpmn:SubProcess"===t.type,i=!0===t.isExpanded;return eg(t)&&(!n||i)})),this._createEntries(e,i)):mr(t,"bpmn:SequenceFlow")?this._createSequenceFlowEntries(e,fg):mr(t,"bpmn:FlowNode")?(i=g(pg,r),mr(t,"bpmn:SubProcess")&&!jr(e)&&(i=g(i,(function(e){return"Sub-process (collapsed)"!==e.label}))),this._createEntries(e,i)):{}},gg.prototype.getPopupMenuHeaderEntries=function(e){var t={};return mr(e,"bpmn:Activity")&&!Lr(e)&&(t={...t,...this._getLoopCharacteristicsHeaderEntries(e)}),mr(e,"bpmn:DataObjectReference")&&(t={...t,...this._getCollectionHeaderEntries(e)}),mr(e,"bpmn:Participant")&&(t={...t,...this._getParticipantMultiplicityHeaderEntries(e)}),!mr(e,"bpmn:SubProcess")||mr(e,"bpmn:Transaction")||Lr(e)||(t={...t,...this._getAdHocHeaderEntries(e)}),sh(e)&&(t={...t,...this._getNonInterruptingHeaderEntries(e)}),t},gg.prototype._createEntries=function(e,t){var n={},i=this;return v(t,(function(t){n[t.actionName]=i._createEntry(t,e)})),n},gg.prototype._createSequenceFlowEntries=function(e,t){var n=gr(e),i={},r=this._modeling,o=this._moddle,a=this;return v(t,(function(t){switch(t.actionName){case"replace-with-default-flow":n.sourceRef.default!==n&&(mr(n.sourceRef,"bpmn:ExclusiveGateway")||mr(n.sourceRef,"bpmn:InclusiveGateway")||mr(n.sourceRef,"bpmn:ComplexGateway")||mr(n.sourceRef,"bpmn:Activity"))&&(i={...i,[t.actionName]:a._createEntry(t,e,(function(){r.updateProperties(e.source,{default:n})}))});break;case"replace-with-conditional-flow":!n.conditionExpression&&mr(n.sourceRef,"bpmn:Activity")&&(i={...i,[t.actionName]:a._createEntry(t,e,(function(){var t=o.create("bpmn:FormalExpression",{body:""});r.updateProperties(e,{conditionExpression:t})}))});break;default:mr(n.sourceRef,"bpmn:Activity")&&n.conditionExpression&&(i={...i,[t.actionName]:a._createEntry(t,e,(function(){r.updateProperties(e,{conditionExpression:void 0})}))}),(mr(n.sourceRef,"bpmn:ExclusiveGateway")||mr(n.sourceRef,"bpmn:InclusiveGateway")||mr(n.sourceRef,"bpmn:ComplexGateway")||mr(n.sourceRef,"bpmn:Activity"))&&n.sourceRef.default===n&&(i={...i,[t.actionName]:a._createEntry(t,e,(function(){r.updateProperties(e.source,{default:void 0})}))})}})),i},gg.prototype._createEntry=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,action:n}},gg.prototype._getLoopCharacteristicsHeaderEntries=function(e){var t=this,n=this._translate;function i(n,i){if(i.active)t._modeling.updateProperties(e,{loopCharacteristics:void 0});else{var r=e.businessObject.get("loopCharacteristics");r&&mr(r,i.options.loopCharacteristics)?t._modeling.updateModdleProperties(e,r,{isSequential:i.options.isSequential}):(r=t._moddle.create(i.options.loopCharacteristics,{isSequential:i.options.isSequential}),t._modeling.updateProperties(e,{loopCharacteristics:r}))}}var r,o,a,s=gr(e).loopCharacteristics;return s&&(r=s.isSequential,o=void 0===s.isSequential,a=void 0!==s.isSequential&&!s.isSequential),{"toggle-parallel-mi":{className:"bpmn-icon-parallel-mi-marker",title:n("Parallel multi-instance"),active:a,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!1}},"toggle-sequential-mi":{className:"bpmn-icon-sequential-mi-marker",title:n("Sequential multi-instance"),active:r,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!0}},"toggle-loop":{className:"bpmn-icon-loop-marker",title:n("Loop"),active:o,action:i,options:{loopCharacteristics:"bpmn:StandardLoopCharacteristics"}}}},gg.prototype._getCollectionHeaderEntries=function(e){var t=this,n=this._translate,i=e.businessObject.dataObjectRef;if(!i)return{};var r=i.isCollection;return{"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})}}}},gg.prototype._getParticipantMultiplicityHeaderEntries=function(e){var t=this,n=this._bpmnFactory,i=this._translate;var r=e.businessObject.participantMultiplicity;return{"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})}}}},gg.prototype._getAdHocHeaderEntries=function(e){var t=this._translate,n=mr(gr(e),"bpmn:AdHocSubProcess"),i=this._bpmnReplace.replaceElement;return{"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})}}}},gg.prototype._getNonInterruptingHeaderEntries=function(e){const t=this._translate,n=gr(e),i=this,r=ch(e),o=mr(e,"bpmn:BoundaryEvent")?yg["intermediate-event-non-interrupting"]:yg["start-event-non-interrupting"],a=!n[r];return{"toggle-non-interrupting":{imageHtml:o,title:t("Toggle non-interrupting"),active:a,action:function(){i._modeling.updateProperties(e,{[r]:!!a})}}}};var vg={__depends__:[Oc,vf,ip],__init__:["replaceMenuProvider"],replaceMenuProvider:["type",gg]};function _g(e,t,n,i,r,o,a,s,c,p,l,u,h){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,this._eventBus=n,this._appendPreview=h,!1!==e.autoPlace&&(this._autoPlace=t.get("autoPlace",!1)),n.on("create.end",250,(function(e){var t=e.context.shape;if(sa(e)&&i.isOpen(t)){var n=i.getEntries(t);n.replace&&n.replace.action.click(e,t)}})),n.on("contextPad.close",(function(){h.cleanUp()}))}function bg(e,t,n){var i=e.$instanceOf(t),r=!1;return v(e.eventDefinitions||[],(function(e){e.$type===n&&(r=!0)})),i&&r}_g.$inject=["config.contextPad","injector","eventBus","contextPad","modeling","elementFactory","connect","create","popupMenu","canvas","rules","translate","appendPreview"],_g.prototype.getMultiElementContextPadEntries=function(e){var t=this._modeling,n={};return this._isDeleteAllowed(e)&&L(n,{delete:{group:"edit",className:"bpmn-icon-trash",title:this._translate("Delete"),action:{click:function(e,n){t.removeElements(n.slice())}}}}),n},_g.prototype._isDeleteAllowed=function(e){var t=this._rules.allowed("elements.delete",{elements:e});return p(t)?x(e,(e=>t.includes(e))):t},_g.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._autoPlace,c=this._translate,p=this._appendPreview,l={};if("label"===e.type)return this._isDeleteAllowed([e])&&L(l,f()),l;var u=e.businessObject;function h(e,t){r.start(e,t)}function d(e,t){n.removeElements([t])}function f(){return{delete:{group:"edit",className:"bpmn-icon-trash",title:c("Delete"),action:{click:d}}}}function m(e,t,n,r){function a(t,n){var a=i.createShape(L({type:e},r));o.start(t,a,{source:n})}var c=s?function(t,n){var o=i.createShape(L({type:e},r));s.append(n,o)}:a,l=s?function(t,n){return p.create(n,e,r),()=>{p.cleanUp()}}:null;return{group:"model",className:t,title:n,action:{dragstart:a,click:c,hover:l}}}function y(e){return function(i,r){n.splitLane(r,e),t.open(r,!0)}}if(yr(u,["bpmn:Lane","bpmn:Participant"])&&jr(e)){var g=du(e);L(l,{"lane-insert-above":{group:"lane-insert-above",className:"bpmn-icon-lane-insert-above",title:c("Add lane above"),action:{click:function(e,t){n.addLane(t,"top")}}}}),g.length<2&&((Or(e)?e.height>=120:e.width>=120)&&L(l,{"lane-divide-two":{group:"lane-divide",className:"bpmn-icon-lane-divide-two",title:c("Divide into two lanes"),action:{click:y(2)}}}),(Or(e)?e.height>=180:e.width>=180)&&L(l,{"lane-divide-three":{group:"lane-divide",className:"bpmn-icon-lane-divide-three",title:c("Divide into three lanes"),action:{click:y(3)}}})),L(l,{"lane-insert-below":{group:"lane-insert-below",className:"bpmn-icon-lane-insert-below",title:c("Add lane below"),action:{click:function(e,t){n.addLane(t,"bottom")}}}})}return mr(u,"bpmn:FlowNode")&&(mr(u,"bpmn:EventBasedGateway")?L(l,{"append.receive-task":m("bpmn:ReceiveTask","bpmn-icon-receive-task",c("Append receive task")),"append.message-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-message",c("Append message intermediate catch event"),{eventDefinitionType:"bpmn:MessageEventDefinition"}),"append.timer-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-timer",c("Append timer intermediate catch event"),{eventDefinitionType:"bpmn:TimerEventDefinition"}),"append.condition-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-condition",c("Append conditional intermediate catch event"),{eventDefinitionType:"bpmn:ConditionalEventDefinition"}),"append.signal-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-signal",c("Append signal intermediate catch event"),{eventDefinitionType:"bpmn:SignalEventDefinition"})}):bg(u,"bpmn:BoundaryEvent","bpmn:CompensateEventDefinition")?L(l,{"append.compensation-activity":m("bpmn:Task","bpmn-icon-task",c("Append compensation activity"),{isForCompensation:!0})}):mr(u,"bpmn:EndEvent")||u.isForCompensation||bg(u,"bpmn:IntermediateThrowEvent","bpmn:LinkEventDefinition")||Lr(u)||L(l,{"append.end-event":m("bpmn:EndEvent","bpmn-icon-end-event-none",c("Append end event")),"append.gateway":m("bpmn:ExclusiveGateway","bpmn-icon-gateway-none",c("Append gateway")),"append.append-task":m("bpmn:Task","bpmn-icon-task",c("Append task")),"append.intermediate-event":m("bpmn:IntermediateThrowEvent","bpmn-icon-intermediate-event-none",c("Append intermediate/boundary event"))})),a.isEmpty(e,"bpmn-replace")||L(l,{replace:{group:"edit",className:"bpmn-icon-screw-wrench",title:c("Change element"),action:{click:function(e,n){var i=L(function(e){var n=t.getPad(e).html.getBoundingClientRect();return{x:n.left,y:n.bottom+5}}(n),{cursor:{x:e.x,y:e.y}});a.open(n,"bpmn-replace",i,{title:c("Change element"),width:300,search:!0})}}}}),mr(u,"bpmn:SequenceFlow")&&L(l,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation"))}),yr(u,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference"])&&L(l,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation")),connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect to other element"),action:{click:h,dragstart:h}}}),mr(u,"bpmn:TextAnnotation")&&L(l,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect using association"),action:{click:h,dragstart:h}}}),yr(u,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&L(l,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect using data input association"),action:{click:h,dragstart:h}}}),mr(u,"bpmn:Group")&&L(l,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation"))}),this._isDeleteAllowed([e])&&L(l,f()),l};var xg={__depends__:[Uy,Jy,ms,_a,xl,Xd,vg],__init__:["contextPadProvider"],contextPadProvider:["type",_g]},wg={horizontal:["x","width"],vertical:["y","height"]};function Eg(e,t){this._modeling=e,this._filters=[],this.registerFilter((function(e){var n=t.allowed("elements.distribute",{elements:e});return p(n)?n:n?e:[]}))}Eg.$inject=["modeling","rules"],Eg.prototype.registerFilter=function(e){if("function"!=typeof e)throw new Error("the filter has to be a function");this._filters.push(e)},Eg.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},Eg.prototype._filterElements=function(e){var t=this._filters,n=this._axis,i=this._dimension,r=[].concat(e);return t.length?(v(t,(function(e){r=e(r,n,i)})),r):e},Eg.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 v(A(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},Eg.prototype._setOrientation=function(e){var t=wg[e];this._axis=t[0],this._dimension=t[1]},Eg.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)},Eg.prototype._findRange=function(e){var t=e[this._axis];return{min:t+5,max:t+e[this._dimension]-5}};var Sg={__init__:["distributeElements"],distributeElements:["type",Eg]};function Cg(e){zc.call(this,e)}Cg.$inject=["eventBus"],e(Cg,zc),Cg.prototype.init=function(){this.addRule("elements.distribute",(function(e){var t=e.elements;return!((t=st(t=g(t,(function(e){var t=yr(e,["bpmn:Association","bpmn:BoundaryEvent","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:Lane","bpmn:MessageFlow","bpmn:SequenceFlow","bpmn:TextAnnotation"]);return!(e.labelTarget||t)})))).length<3)&&t}))};var kg={horizontal:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <polyline points="450 400 450 150 1350 150 1350 400" style="fill:none;stroke:currentColor;stroke-width:100;stroke-linejoin:round;"/>\n <rect x="150" y="450" width="600" height="1200" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="1050" y="450" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>',vertical:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">\n <polyline points="400 1350 150 1350 150 450 400 450" style="fill:none;stroke:currentColor;stroke-width:100;stroke-linejoin:round;"/>\n <rect x="450" y="150" width="1200" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>\n <rect x="450" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>\n </svg>'};function Rg(e,t,n,i){this._distributeElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",900,this)}Rg.$inject=["popupMenu","distributeElements","translate","rules"],Rg.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&L(t,this._getEntries(e)),t},Rg.prototype._isAllowed=function(e){return this._rules.allowed("elements.distribute",{elements:e})},Rg.prototype._getEntries=function(e){var t=this._distributeElements,n=this._translate,i=this._popupMenu;return{"distribute-elements-horizontal":{group:"distribute",title:n("Distribute elements horizontally"),className:"bjs-align-elements-menu-entry",imageHtml:kg.horizontal,action:function(n,r){t.trigger(e,"horizontal"),i.close()}},"distribute-elements-vertical":{group:"distribute",title:n("Distribute elements vertically"),imageHtml:kg.vertical,action:function(n,r){t.trigger(e,"vertical"),i.close()}}}};var Pg={__depends__:[Oc,Sg],__init__:["bpmnDistributeElements","distributeElementsMenuProvider"],bpmnDistributeElements:["type",Cg],distributeElementsMenuProvider:["type",Rg]},Ag="is not a registered action";function Mg(e,t){this._actions={};var n=this;e.on("diagram.init",(function(){n._registerDefaultActions(t),e.fire("editorActions.init",{editorActions:n})}))}function Tg(e,t){return new Error(e+" "+t)}Mg.$inject=["eventBus","injector"],Mg.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),l=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();if(e.length)return 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=p(r)?r:e).length&&n.removeElements(t.slice())}})),c&&this.register("moveCanvas",(function(e){c.moveCanvas(e)})),l&&this.register("moveSelection",(function(e){l.moveSelection(e.direction,e.accelerated)}))},Mg.prototype.trigger=function(e,t){if(!this._actions[e])throw Tg(e,Ag);return this._actions[e](t)},Mg.prototype.register=function(e,t){var n=this;if("string"==typeof e)return this._registerAction(e,t);v(e,(function(e,t){n._registerAction(t,e)}))},Mg.prototype._registerAction=function(e,t){if(this.isRegistered(e))throw Tg(e,"is already registered");this._actions[e]=t},Mg.prototype.unregister=function(e){if(!this.isRegistered(e))throw Tg(e,Ag);this._actions[e]=void 0},Mg.prototype.getActions=function(){return Object.keys(this._actions)},Mg.prototype.isRegistered=function(e){return!!this._actions[e]};var Bg={__init__:["editorActions"],editorActions:["type",Mg]};function Dg(e){e.invoke(Mg,this)}e(Dg,Mg),Dg.$inject=["injector"],Dg.prototype._registerDefaultActions=function(e){Mg.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),d=e.get("contextPad",!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!mr(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=ht(i=mr(r,"bpmn:Collaboration")?n.filter((function(e){return mr(e.parent,"bpmn:Collaboration")})):n.filter((function(e){return e!==r&&!mr(e.parent,"bpmn:SubProcess")}))),h.moveElements(i,{x:-e.x,y:-e.y},r)})),i&&d&&this._registerAction("replaceElement",(function(e){d.triggerEntry("replace","click",e)}))};var Ng={__depends__:[Bg],editorActions:["type",Dg]};function jg(e){e.on(["create.init","shape.move.init"],(function(e){var t=e.context;yr(e.shape,["bpmn:Participant","bpmn:SubProcess","bpmn:TextAnnotation"])&&(t.gridSnappingContext||(t.gridSnappingContext={}),t.gridSnappingContext.snapLocation="top-left")}))}jg.$inject=["eventBus"];function Og(e,t,n){return n||(n="round"),Math[n](e/t)*t}function Lg(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&&Ca(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&&u(s[t]))return s[t];s||(s=o.snapOffset={});u(s[t])||(s[t]=0);if(!r)return s[t];n.get(r.id)||($g(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&&($g(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&&($g(t)?Fg(s)?a.x.max=c.left:a.x.min=c.right:Ig(s)?a.y.max=c.top:a.y.min=c.bottom);p&&($g(t)?Fg(s)?a.x.min=p.left:a.x.max=p.right:Ig(s)?a.y.min=p.top:a.y.max=p.bottom);return a[t]}(t,n);a&&L(i,a),pl(t,n)||r.snapEvent(t,n,i)}))}}))}function $g(e){return"x"===e}function Ig(e){return-1!==e.indexOf("n")}function Fg(e){return-1!==e.indexOf("w")}function zg(e,t){To.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;d(i)?t.newBounds=n.snapComplex(o,i):t.newBounds=n.snapSimple(r,o)}}))}Lg.prototype.snapEvent=function(e,t,n){ll(e,t,this.snapValue(e[t],n))},Lg.prototype.getGridSpacing=function(){return 10},Lg.prototype.snapValue=function(e,t){var n,i,r=0;return t&&t.offset&&(r=t.offset),e=Og(e+=r,10),t&&t.min&&u(n=t.min)&&(n=Og(n+r,10,"ceil"),e=Math.max(e,n)),t&&t.max&&u(i=t.max)&&(i=Og(i+r,10,"floor"),e=Math.min(e,i)),e-=r},Lg.prototype.isActive=function(){return this.active},Lg.prototype.setActive=function(e){this.active=e,this._eventBus.fire("gridSnapping.toggle",{active:e})},Lg.prototype.toggleActive=function(){this.setActive(!this.active)},Lg.$inject=["elementRegistry","eventBus","config.gridSnapping"],zg.$inject=["eventBus","gridSnapping","modeling"],e(zg,To),zg.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},zg.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},zg.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),L(e,o),e},zg.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),L(e,o),e};function Hg(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))}))}Hg.$inject=["eventBus","gridSnapping"];var Vg={__depends__:[{__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",zg],gridSnappingSpaceToolBehavior:["type",Hg]}],__init__:["gridSnapping"],gridSnapping:["type",Lg]};function Gg(e,t,n){e.on("autoPlace",2e3,(function(e){var i=e.source,r=dn(i),o=e.shape,a=ep(i,o,n);return["x","y"].forEach((function(e){var n={};a[e]!==r[e]&&(a[e]>r[e]?n.min=a[e]:n.max=a[e],mr(o,"bpmn:TextAnnotation")&&(!function(e){return"x"===e}(e)?n.offset=-o.height/2:n.offset=-o.width/2),a[e]=t.snapValue(a[e],n))})),a}))}Gg.$inject=["eventBus","gridSnapping","elementRegistry"];function Wg(e,t,n){t.on(["create.start","shape.move.start"],1750,(function(t){var i=t.context,r=i.shape,o=e.getRootElement();mr(r,"bpmn:Participant")&&mr(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})))}))}Wg.$inject=["canvas","eventBus","gridSnapping"];function Ug(e,t,n){To.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 qg(e,t,n){var i=Et(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=L({},t,r),n=L({},n,r)),[t,n]}Ug.$inject=["eventBus","gridSnapping","modeling"],e(Ug,To),Ug.prototype.snapMiddleSegments=function(e){var t,n=this._gridSnapping;e=e.slice();for(var i=1;i<e.length-2;i++)t=qg(n,e[i],e[i+1]),e[i]=t[0],e[i+1]=t[1];return e};var Kg={__depends__:[Vg,{__init__:["gridSnappingAutoPlaceBehavior","gridSnappingParticipantBehavior","gridSnappingLayoutConnectionBehavior"],gridSnappingAutoPlaceBehavior:["type",Gg],gridSnappingParticipantBehavior:["type",Wg],gridSnappingLayoutConnectionBehavior:["type",Ug]}],__init__:["bpmnGridSnapping"],bpmnGridSnapping:["type",jg]};function Yg(e,t){this._interactionEvents=t;var n=this;e.on(["interactionEvents.createHit","interactionEvents.updateHit"],(function(e){var t=e.element,i=e.gfx;return mr(t,"bpmn:Lane")?n._createParticipantHit(t,i):mr(t,"bpmn:Participant")?jr(t)?n._createParticipantHit(t,i):n._createDefaultHit(t,i):mr(t,"bpmn:SubProcess")?jr(t)?n._createSubProcessHit(t,i):n._createDefaultHit(t,i):void 0}))}Yg.$inject=["eventBus","interactionEvents"],Yg.prototype._createDefaultHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createDefaultHit(e,t),!0},Yg.prototype._createParticipantHit=function(e,t){this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"no-move",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height});var n=Or(e)?{width:30,height:e.height}:{width:e.width,height:30};return this._interactionEvents.createBoxHit(t,"all",n),!0},Yg.prototype._createSubProcessHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"no-move",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"all",{width:e.width,height:30}),!0};var Xg={__init__:["bpmnInteractionEvents"],bpmnInteractionEvents:["type",Yg]};function Zg(e){e.invoke(Ta,this)}e(Zg,Ta),Zg.$inject=["injector"],Zg.prototype.registerBindings=function(e,t){function n(n,i){t.isRegistered(n)&&e.addListener(i)}Ta.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})),n("replaceElement",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["r","R"],i)?(t.trigger("replaceElement",i),!0):void 0}))};var Qg={__depends__:[Ba],__init__:["keyboardBindings"],keyboardBindings:["type",Zg]},Jg={moveSpeed:1,moveSpeedAccelerated:10},ev="left",tv="right",nv="down",iv={ArrowLeft:ev,Left:ev,ArrowUp:"up",Up:"up",ArrowRight:tv,Right:tv,ArrowDown:nv,Down:nv},rv={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 ov(e,t,n,i,r){var o=this;this._config=L({},Jg,e||{}),t.addListener(1500,(function(e){var n=e.keyEvent,i=iv[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=rv[e](a);i.allowed("elements.move",{shapes:o})&&n.moveElements(o,s)}}}ov.$inject=["config.keyboardMoveSelection","keyboard","modeling","rules","selection"];var av={__depends__:[Ba,_a],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",ov]};function sv(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=ln(e);return un({top:ou("top",n,t),right:ou("right",n,t),bottom:ou("bottom",n,t),left:ou("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:ln(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=cn(r)))return;n.resizeShape(t,r)}}(e.context)}))}function cv(e,t){var n=dn(e),i=ln(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 pv(e){var t="resize-";return"n"===e||"s"===e?t+"ns":"e"===e||"w"===e?t+"ew":"nw"===e||"se"===e?t+"nwse":t+"nesw"}sv.prototype.canResize=function(e){var t=this._rules,n=$(e,["newBounds","shape","delta","direction"]);return t.allowed("shape.resize",n)},sv.prototype.activate=function(e,t,n){var i,r,o=this._dragging;if("string"==typeof n&&(n={direction:n}),!(r=(i=L({shape:t},n)).direction))throw new Error("must provide a direction (n|w|s|e|nw|se|ne|sw)");o.init(e,cv(t,r),"resize",{autoActivate:!0,cursor:pv(r),data:{shape:t,context:i}})},sv.prototype.computeMinResizeBox=function(e){var t=e.shape;return function(e,t,n,i){var r=ln(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?ln(i):o;return un({top:iu(o.top,a.top),left:iu(o.left,a.left),bottom:nu(o.bottom,a.bottom),right:nu(o.right,a.right)})}(e.direction,t,e.minDimensions||{width:10,height:10},cu(t,e.childrenBoxPadding))},sv.$inject=["eventBus","rules","modeling","dragging"];var lv="djs-resizing",uv="resize-not-ok";function hv(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,lv)),o.width>5&&be(a,{x:o.x,width:o.width}),o.height>5&&be(a,{y:o.y,height:o.height}),i.canExecute?we(a).remove(uv):we(a).add(uv)})),e.on("resize.cleanup",(function(e){var n,i;n=e.context,i=n.shape,n.frame&&Fe(n.frame),t.removeMarker(i,lv)}))}hv.$inject=["eventBus","canvas","previewSupport"];var dv=-6,fv="djs-resizer",mv=["n","w","s","e","nw","ne","se","sw"];function yv(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&&v(t,O(r.addResizer,r))})),e.on("shape.changed",(function(e){var t=e.element;n.isSelected(t)&&(r.removeResizers(),r.addResizer(t))}))}yv.prototype.makeDraggable=function(e,t,n){var i=this._resize;function r(t){aa(t)&&i.activate(t,e,n)}oe.bind(t,"mousedown",r),oe.bind(t,"touchstart",r)},yv.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=dv);-1!==e.indexOf("s")?t.y=6:-1!==e.indexOf("n")&&(t.y=dv);return t}(i),a=Ae("g");we(a).add(fv),we(a).add(fv+"-"+e.id),we(a).add(fv+"-"+i),ge(r,a);var s=Ae("rect");be(s,{x:-4+o.x,y:-4+o.y,width:8,height:8}),we(s).add(fv+"-visual"),ge(a,s);var c=Ae("rect");return be(c,{x:-10+o.x,y:-10+o.y,width:20,height:20}),we(c).add(fv+"-hit"),ge(a,c),Vn(a,t,n),a},yv.prototype.createResizer=function(e,t){var n=cv(e,t),i=this._createResizer(e,n.x,n.y,t);this.makeDraggable(e,i,t)},yv.prototype.addResizer=function(e){var t=this;!an(e)&&this._resize.canResize({shape:e})&&v(mv,(function(n){t.createResizer(e,n)}))},yv.prototype.removeResizers=function(){Se(this._getResizersParent())},yv.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")},yv.$inject=["eventBus","canvas","selection","resize"];var gv={__depends__:[bp,mp,Pl],__init__:["resize","resizePreview","resizeHandles"],resize:["type",sv],resizePreview:["type",hv],resizeHandles:["type",yv]};function vv(e,t,n,i,r,o,a){function s(e,t){(t||yr(e,["bpmn:Task","bpmn:TextAnnotation","bpmn:Participant"])||_v(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","root.set","selection.changed"],(function(){i.isActive()&&i.complete()})),e.on(["shape.remove","connection.remove"],2e3,(function(e){i.isActive(e.element)&&i.cancel()})),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 _v(e){return mr(e,"bpmn:SubProcess")&&!jr(e)}vv.$inject=["eventBus","bpmnFactory","canvas","directEditing","modeling","resizeHandles","textRenderer"],vv.prototype.activate=function(e){var t=Wr(e);if(void 0!==t){var n={text:t};L(n,this.getEditingBBox(e));var i={},r=n.style||{};return L(r,{backgroundColor:null,border:null}),(yr(e,["bpmn:Task","bpmn:Participant","bpmn:Lane","bpmn:CallActivity"])||_v(e))&&L(i,{centerVertically:!0}),Fr(e)&&(L(i,{autoResize:!0}),L(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),mr(e,"bpmn:TextAnnotation")&&(L(i,{resizable:!0,autoResize:!0}),L(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),L(n,{options:i,style:r}),n}},vv.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};if(mr(e,"bpmn:Lane")||function(e){return mr(e,"bpmn:Participant")&&jr(e)}(e)){var m=Or(e);L(a,m?{width:i.height,height:30*s,x:i.x-i.height/2+15*s,y:o-30*s/2}:{width:i.width,height:30*s}),L(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px",transform:m?"rotate(-90deg)":null})}if(function(e){return mr(e,"bpmn:Participant")&&!jr(e)}(e)){var y=Or(e);L(a,y?{width:i.width,height:i.height}:{width:i.height,height:i.width,x:r-i.height/2,y:o-i.width/2}),L(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px",transform:y?null:"rotate(-90deg)"})}(yr(e,["bpmn:Task","bpmn:CallActivity"])||_v(e))&&(L(a,{width:i.width,height:i.height}),L(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 mr(e,"bpmn:SubProcess")&&jr(e)}(e)&&(L(a,{width:i.width,x:i.x}),L(f,{fontSize:h+"px",lineHeight:d,paddingTop:7*s+"px",paddingBottom:7*s+"px",paddingLeft:5*s+"px",paddingRight:5*s+"px"}));var g=90*s,v=7*s,_=4*s;if(n.labelTarget&&(L(a,{width:g,height:i.height+v+_,x:r-g/2,y:i.y-v}),L(f,{fontSize:l+"px",lineHeight:u,paddingTop:v+"px",paddingBottom:_+"px"})),Fr(n)&&!zr(n)&&!sn(n)){var b=Vr(e),x=t.getAbsoluteBBox({x:b.x,y:b.y,width:0,height:0}),w=l+v+_;L(a,{width:g,height:w,x:x.x-g/2,y:x.y-w/2}),L(f,{fontSize:l+"px",lineHeight:u,paddingTop:v+"px",paddingBottom:_+"px"})}return mr(e,"bpmn:TextAnnotation")&&(L(a,{width:i.width,height:i.height,minWidth:30*s,minHeight:10*s}),L(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}},vv.prototype.update=function(e,t,n,i){var r,o,a;mr(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}),(a=t)&&a.trim()||(t=null),this._modeling.updateLabel(e,t,r)};var bv="djs-element-hidden",xv="djs-label-hidden";function wv(e,t,n){var i,r,o,a=this,s=t.getDefaultLayer();e.on("directEditing.activate",(function(e){var c=e.active;if(mr(i=c.element.label||c.element,"bpmn:TextAnnotation")){r=t.getAbsoluteBBox(i),o=Ae("g");var p=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:i.width,containerHeight:i.height,position:{mx:0,my:0}}),l=a.path=Ae("path");be(l,{d:p,strokeWidth:2,stroke:Ev(i)}),ge(o,l),ge(s,o),Gn(o,i.x,i.y)}mr(i,"bpmn:TextAnnotation")||i.labelTarget?t.addMarker(i,bv):(mr(i,"bpmn:Task")||mr(i,"bpmn:CallActivity")||mr(i,"bpmn:SubProcess")||mr(i,"bpmn:Participant")||mr(i,"bpmn:Lane"))&&t.addMarker(i,xv)})),e.on("directEditing.resize",(function(e){if(mr(i,"bpmn:TextAnnotation")){var t=e.height,o=e.dy,s=Math.max(i.height/r.height*(t+o),0),c=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:i.width,containerHeight:s,position:{mx:0,my:0}});be(a.path,{d:c})}})),e.on(["directEditing.complete","directEditing.cancel"],(function(e){var n=e.active;n&&(t.removeMarker(n.element.label||n.element,bv),t.removeMarker(i,xv)),i=void 0,r=void 0,o&&(Fe(o),o=void 0)}))}function Ev(e,t){return vr(e).get("stroke")||t||"black"}wv.$inject=["eventBus","canvas","pathMap"];var Sv={__depends__:[Mo,gv,Jy],__init__:["labelEditingProvider","labelEditingPreview"],labelEditingProvider:["type",vv],labelEditingPreview:["type",wv]},Cv=new wo("tt");function kv(e,t){e.style.display=!1===t?"none":""}var Rv="djs-tooltip",Pv="."+Rv;function Av(e,t){var n,i;this._eventBus=e,this._canvas=t,this._ids=Cv,this._tooltipDefaults={show:{minZoom:.7,maxZoom:5}},this._tooltips={},this._tooltipRoot=(n=t.getContainer(),q(i=he('<div class="djs-tooltip-container" />'),{position:"absolute",width:"0",height:"0"}),n.insertBefore(i,n.firstChild),i);var r=this;ce.bind(this._tooltipRoot,Pv,"mousedown",(function(e){e.stopPropagation()})),ce.bind(this._tooltipRoot,Pv,"mouseover",(function(e){r.trigger("mouseover",e)})),ce.bind(this._tooltipRoot,Pv,"mouseout",(function(e){r.trigger("mouseout",e)})),this._init()}Av.$inject=["eventBus","canvas"],Av.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=L({},this._tooltipDefaults,e,{id:t}),this._addTooltip(e),e.timeout&&this.setTimeout(e),t},Av.prototype.trigger=function(e,t){var n=t.delegateTarget||t.target,i=this.get(K(n,"data-tooltip-id"));i&&("mouseover"===e&&i.timeout&&this.clearTimeout(i),"mouseout"===e&&i.timeout&&(i.timeout=1e3,this.setTimeout(i)))},Av.prototype.get=function(e){return"string"!=typeof e&&(e=e.id),this._tooltips[e]},Av.prototype.clearTimeout=function(e){if(e=this.get(e)){var t=e.removeTimer;t&&(clearTimeout(t),e.removeTimer=null)}},Av.prototype.setTimeout=function(e){if(e=this.get(e)){this.clearTimeout(e);var t=this;e.removeTimer=setTimeout((function(){t.remove(e)}),e.timeout)}},Av.prototype.remove=function(e){var t=this.get(e);t&&(ye(t.html),ye(t.htmlContainer),delete t.htmlContainer,delete this._tooltips[t.id])},Av.prototype.show=function(){kv(this._tooltipRoot)},Av.prototype.hide=function(){kv(this._tooltipRoot,!1)},Av.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},Av.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)),d(i)&&(i=he(i)),q(t=he('<div data-tooltip-id="'+n+'" class="'+Rv+'">'),{position:"absolute"}),t.appendChild(i),e.type&&X(t).add("djs-tooltip-"+e.type),e.className&&X(t).add(e.className),e.htmlContainer=t,r.appendChild(t),this._tooltips[n]=e,this._updateTooltip(e)},Av.prototype._updateTooltip=function(e){var t=e.position;!function(e,t,n){q(e,{left:t+"px",top:n+"px"})}(e.htmlContainer,t.x,t.y)},Av.prototype._updateTooltipVisibilty=function(e){v(this._tooltips,(function(t){var n=t.show,i=t.htmlContainer,r=!0;n&&((n.minZoom>e.scale||n.maxZoom<e.scale)&&(r=!1),kv(i,r))}))},Av.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 Mv={__init__:["tooltips"],tooltips:["type",Av]};function Tv(e,t,n){e.on(["shape.move.rejected","create.rejected"],(function(e){var i,r,o=e.context,a=o.shape;mr(o.target,"bpmn:Collaboration")&&mr(a,"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:2e3,html:"<div>"+r+"</div>"}))}))}Tv.$inject=["eventBus","tooltips","translate"];var Bv={__depends__:[Mv],__init__:["modelingFeedback"],modelingFeedback:["type",Tv]};function Dv(e,t){this._eventBus=e,this.offset=5;var n=t.cls("djs-outline",["no-fill"]),i=this;function r(e){var t=Ae("rect");return be(t,L({x:0,y:0,rx:4,width:100,height:100},n)),t}e.on(["shape.added","shape.changed"],500,(function(e){var t=e.element,n=e.gfx,o=fe(".djs-outline",n);o||ge(n,o=i.getOutline(t)||r()),i.updateShapeOutline(o,t)})),e.on(["connection.added","connection.changed"],(function(e){var t=e.element,n=e.gfx,o=fe(".djs-outline",n);o||ge(n,o=r()),i.updateConnectionOutline(o,t)}))}Dv.prototype.updateShapeOutline=function(e,t){var n=!1,i=this._getProviders();i.length&&v(i,(function(i){n=n||i.updateOutline(t,e)})),n||be(e,{x:-this.offset,y:-this.offset,width:t.width+2*this.offset,height:t.height+2*this.offset})},Dv.prototype.updateConnectionOutline=function(e,t){var n=ht(t);be(e,{x:n.x-this.offset,y:n.y-this.offset,width:n.width+2*this.offset,height:n.height+2*this.offset})},Dv.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("outline.getProviders",e,(function(e){e.providers.push(t)}))},Dv.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"outline.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},Dv.prototype.getOutline=function(e){var t;return v(this._getProviders(),(function(n){h(n.getOutline)&&(t=t||n.getOutline(e))})),t},Dv.$inject=["eventBus","styles","elementRegistry"];function Nv(e,t,n){this._canvas=t;var i=this;e.on("element.changed",(function(e){n.isSelected(e.element)&&i._updateMultiSelectionOutline(n.get())})),e.on("selection.changed",(function(e){var t=e.newSelection;i._updateMultiSelectionOutline(t)}))}Nv.prototype._updateMultiSelectionOutline=function(e){var t=this._canvas.getLayer("selectionOutline");Se(t);var n=e.length>1;if(we(this._canvas.getContainer())[n?"add":"remove"]("djs-multi-select"),n){var i=function(e){return{x:e.x-6,y:e.y-6,width:e.width+12,height:e.height+12}}(ht(e)),r=Ae("rect");be(r,L({rx:3},i)),we(r).add("djs-selection-outline"),ge(t,r)}},Nv.$inject=["eventBus","canvas","selection"];var jv={__depends__:[_a],__init__:["outline","multiSelectionOutline"],outline:["type",Dv],multiSelectionOutline:["type",Nv]},Ov=Math.round;function Lv(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(l(i)&&(r=i,i=!1),!n.waypoints&&n.parent&&!we(e.target).has("djs-hit-no-move")){var o=function(e){return{x:e.x+Ov(e.width/2),y:e.y+Ov(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]),r=function(e){var t=k(e,"id");return g(e,(function(e){for(;e=e.parent;)if(t[e.id])return!1;return!0}))}(r),L(t,{shapes: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=Ov(i.x),i.y=Ov(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(aa(e)){var t=ta(e);if(!t)throw new Error("must supply DOM mousedown event");return a(t,e.element)}})),this.start=a}Lv.$inject=["eventBus","dragging","modeling","selection","rules"];var $v="djs-dragging",Iv="drop-ok",Fv="drop-not-ok",zv="new-parent",Hv="attach-ok";function Vv(e,t,n,r){function o(e){var t=function(e){var t=g(e,(function(t){return!an(t)||m(e,M({id:t.source.id}))&&m(e,M({id:t.target.id}))}));return t}(a(e));return t}function a(e){var t=ut(e,!0),n=t.flatMap((e=>(e.incoming||[]).concat(e.outgoing||[]))),i=t.concat(n);return[...new Set(i)]}function s(e,n){[Hv,Iv,Fv,zv].forEach((function(i){i===n?t.addMarker(e,i):t.removeMarker(e,i)}))}e.on("shape.move.start",499,(function(e){var s,c=e.context,p=c.shapes,l=c.allDraggedElements,u=o(p);if(!c.dragGroup){var h=Ae("g");be(h,n.cls("djs-drag-group",["no-events"])),ge(t.getActiveLayer(),h),c.dragGroup=h}u.forEach((function(e){r.addDragger(e,c.dragGroup)})),v(l=l?i([l,a(p)]):a(p),(function(e){t.addMarker(e,$v)})),c.allDraggedElements=l,c.differentParents=1!==(s=k(p,(function(e){return e.parent&&e.parent.id})),S(s).length)})),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&&r&&i.id!==r.id?s(i,zv):s(i,t.canExecute?Iv:Fv)),Gn(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;v(i,(function(e){t.removeMarker(e,$v)})),r&&Fe(r)})),this.makeDraggable=function(e,n,i){r.addDragger(n,e.dragGroup),i&&t.addMarker(n,$v),e.allDraggedElements?e.allDraggedElements.push(n):e.allDraggedElements=[n]}}Vv.$inject=["eventBus","canvas","styles","previewSupport"];var Gv={__depends__:[ha,_a,jv,bp,mp,Pl],__init__:["move","movePreview"],move:["type",Lv],movePreview:["type",Vv]},Wv=".djs-palette-toggle",Uv=".entry",qv=Wv+", "+Uv,Kv="djs-palette-",Yv="open",Xv="two-column";function Zv(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 Qv(e,t){var n=t.getPaletteEntries();return h(n)?n(e):(v(n,(function(t,n){e[n]=t})),e)}Zv.$inject=["eventBus","canvas"],Zv.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("palette.getProviders",e,(function(e){e.providers.push(t)})),this._rebuild()},Zv.prototype.getEntries=function(){return this._getProviders().reduce(Qv,{})},Zv.prototype._rebuild=function(){this._diagramInitialized&&(this._getProviders().length&&(this._container||this._init(),this._update()))},Zv.prototype._init=function(){var e=this,t=this._eventBus,n=this._getParentContainer(),i=this._container=he(Zv.HTML_MARKUP);n.appendChild(i),X(n).add(Kv+"shown"),ce.bind(i,qv,"click",(function(t){if(de(t.delegateTarget,Wv))return e.toggle();e.trigger("click",t)})),oe.bind(i,"mousedown",(function(e){e.stopPropagation()})),ce.bind(i,Uv,"dragstart",(function(t){e.trigger("dragstart",t)})),t.on("canvas.resized",this._layoutChanged,this),t.fire("palette.create",{container:i})},Zv.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(t),t.providers},Zv.prototype._toggleState=function(e){e=e||{};var t,n=this._getParentContainer(),i=this._container,r=this._eventBus,o=X(i),a=X(n);t="twoColumn"in e?e.twoColumn:this._needsCollapse(n.clientHeight,this._entries||{}),o.toggle(Xv,t),a.toggle(Kv+Xv,t),"open"in e&&(o.toggle(Yv,e.open),a.toggle(Kv+Yv,e.open)),r.fire("palette.changed",{twoColumn:t,open:this.isOpen()})},Zv.prototype._update=function(){var e=fe(".djs-palette-entries",this._container),t=this._entries=this.getEntries();Q(e),v(t,(function(t,n){var i=t.group||"default",r=fe("[data-group="+jo(i)+"]",e);r||(K(r=he('<div class="group"></div>'),"data-group",i),e.appendChild(r));var o=t.html||(t.separator?'<hr class="separator" />':'<div class="entry" draggable="true"></div>'),a=he(o);if(r.appendChild(a),!t.separator&&(K(a,"data-action",n),t.title&&K(a,"title",t.title),t.className&&function(e,t){var n=X(e);(p(t)?t:t.split(/\s+/g)).forEach((function(e){n.add(e)}))}(a,t.className),t.imageUrl)){var s=he("<img>");K(s,"src",t.imageUrl),a.appendChild(s)}})),this.open()},Zv.prototype.trigger=function(e,t,n){var i,r,o=t.delegateTarget||t.target;return o?(i=K(o,"data-action"),r=t.originalEvent||t,this.triggerEntry(i,e,r,n)):t.preventDefault()},Zv.prototype.triggerEntry=function(e,t,n,i){var r,o;if((r=this._entries[e])&&(o=r.action,!1!==this._eventBus.fire("palette.trigger",{entry:r,event:n}))){if(h(o)){if("click"===t)return o(n,i)}else if(o[t])return o[t](n,i);n.preventDefault()}},Zv.prototype._layoutChanged=function(){this._toggleState({})},Zv.prototype._needsCollapse=function(e,t){return e<46*Object.keys(t).length+50},Zv.prototype.close=function(){this._toggleState({open:!1,twoColumn:!1})},Zv.prototype.open=function(){this._toggleState({open:!0})},Zv.prototype.toggle=function(){this.isOpen()?this.close():this.open()},Zv.prototype.isActiveTool=function(e){return e&&this._activeTool===e},Zv.prototype.updateToolHighlight=function(e){var t;this._toolsContainer||(t=fe(".djs-palette-entries",this._container),this._toolsContainer=fe("[data-group=tools]",t)),v(this._toolsContainer.children,(function(t){var n=t.getAttribute("data-action");if(n){var i=X(t);n=n.replace("-tool",""),i.contains("entry")&&n===e?i.add("highlighted-entry"):i.remove("highlighted-entry")}}))},Zv.prototype.isOpen=function(){return X(this._container).has(Yv)},Zv.prototype._getParentContainer=function(){return this._canvas.getContainer()},Zv.HTML_MARKUP='<div class="djs-palette"><div class="djs-palette-entries"></div><div class="djs-palette-toggle"></div></div>';var Jv={__init__:["palette"],palette:["type",Zv]},e_="crosshair";function t_(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();be(n=e.frame=Ae("rect"),{class:"djs-lasso-overlay",width:1,height:1,x:0,y:0}),ge(i,n)},p=function(e){var t=e.frame,n=e.bbox;be(t,{x:n.x,y:n.y,width:n.width,height:n.height})},l=function(e){e.frame&&Fe(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",0,(function(e){var t=e.context,n=n_(e),r=i.filter((function(e){return e})),o=ca(e);s.select(r,n,o?t.selection:[])})),e.on("lasso.start",(function(e){var t=e.context;t.bbox=n_(e),c(t),t.selection=r.get()})),e.on("lasso.move",(function(e){var t=e.context;t.bbox=n_(e),p(t)})),e.on("lasso.cleanup",(function(e){var t=e.context;l(t)})),e.on("element.mousedown",1500,(function(e){if(ca(e))return s.activateLasso(e.originalEvent),!0}))}function n_(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}}t_.$inject=["eventBus","canvas","dragging","elementRegistry","selection","toolManager","mouse"],t_.prototype.activateLasso=function(e,t){this._dragging.init(e,"lasso",{autoActivate:t,cursor:e_,data:{context:{}}})},t_.prototype.activateSelection=function(e,t){this._dragging.init(e,"lasso.selection",{trapClick:!1,autoActivate:t,cursor:e_,data:{context:{}},keepSelection:!0})},t_.prototype.select=function(e,t,n=[]){var i=function(e,t){var n={};return v(e,(function(e){var i=e;i.waypoints&&(i=ht(i)),!u(t.y)&&i.x>t.x&&(n[e.id]=e),!u(t.x)&&i.y>t.y&&(n[e.id]=e),i.x>t.x&&i.y>t.y&&(u(t.width)&&u(t.height)&&i.width+i.x<t.width+t.x&&i.height+i.y<t.height+t.y?n[e.id]=e:u(t.width)&&u(t.height)||(n[e.id]=e))})),n}(e,t);this._selection.select([...n,...C(i)])},t_.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},t_.prototype.isActive=function(){var e=this._dragging.context();return e&&/^lasso/.test(e.prefix)};var i_={__depends__:[bf,Qd],__init__:["lassoTool"],lassoTool:["type",t_]},r_=1500,o_="grab";function a_(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",r_,(function(e){if(sa(e))return a.activateMove(e.originalEvent,!0),!1})),s&&s.addListener(r_,(function(e){if(s_(e.keyEvent)&&!a.isActive()){var t=a._mouse.getLastMoveEvent();a.activateMove(t,!!t)}}),"keyboard.keydown"),s&&s.addListener(r_,(function(e){s_(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!sa(t)&&n&&e.once("hand.move.ended",(function(e){a.activateHand(e.originalEvent,!0,!0)})),!1}))}function s_(e){return ka("Space",e)}a_.$inject=["eventBus","canvas","dragging","injector","toolManager","mouse"],a_.prototype.activateMove=function(e,t,n){"object"==typeof t&&(n=t,t=!1),this._dragging.init(e,"hand.move",{autoActivate:t,cursor:o_,data:{context:n||{}}})},a_.prototype.activateHand=function(e,t,n){this._dragging.init(e,"hand",{trapClick:!1,autoActivate:t,cursor:o_,data:{context:{reactivate:n}}})},a_.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateHand(e,!!e)},a_.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^(hand|hand\.move)$/.test(e.prefix)};var c_={__depends__:[bf,Qd],__init__:["handTool"],handTool:["type",a_]},p_="connect-ok",l_="connect-not-ok";function u_(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?p_:l_))})),e.on(["global-connect.out","global-connect.cleanup"],(function(e){var t=e.context.startTarget,n=e.context.canStartConnect;t&&i.removeMarker(t,n?p_:l_)})),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}))}u_.$inject=["eventBus","dragging","connect","canvas","toolManager","rules","mouse"],u_.prototype.start=function(e,t){this._dragging.init(e,"global-connect",{autoActivate:t,trapClick:!1,data:{context:{}}})},u_.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();return this.start(e,!!e)},u_.prototype.isActive=function(){var e=this._dragging.context();return e&&/^global-connect/.test(e.prefix)},u_.prototype.canStartConnect=function(e){return this._rules.allowed("connection.start",{source:e})};var h_={__depends__:[xl,bp,mp,bf,Qd],globalConnect:["type",u_]};function d_(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)}d_.$inject=["palette","create","elementFactory","spaceTool","lassoTool","handTool","globalConnect","translate"],d_.prototype.getPaletteEntries=function(){var e={},t=this._create,n=this._elementFactory,i=this._spaceTool,r=this._lassoTool,o=this._handTool,a=this._globalConnect,s=this._translate;function c(e,i,r,o,a){function s(i){var r=n.createShape(L({type:e},a));t.start(i,r)}return{group:i,className:r,title:o,action:{dragstart:s,click:s}}}function p(e){var i=n.createShape({type:"bpmn:SubProcess",x:0,y:0,isExpanded:!0}),r=n.createShape({type:"bpmn:StartEvent",x:40,y:82,parent:i});t.start(e,[i,r],{hints:{autoSelect:[i]}})}function l(e){t.start(e,n.createParticipantShape())}return L(e,{"hand-tool":{group:"tools",className:"bpmn-icon-hand-tool",title:s("Activate hand tool"),action:{click:function(e){o.activateHand(e)}}},"lasso-tool":{group:"tools",className:"bpmn-icon-lasso-tool",title:s("Activate lasso tool"),action:{click:function(e){r.activateSelection(e)}}},"space-tool":{group:"tools",className:"bpmn-icon-space-tool",title:s("Activate create/remove space tool"),action:{click:function(e){i.activateSelection(e)}}},"global-connect-tool":{group:"tools",className:"bpmn-icon-connection-multi",title:s("Activate global connect tool"),action:{click:function(e){a.start(e)}}},"tool-separator":{group:"tools",separator:!0},"create.start-event":c("bpmn:StartEvent","event","bpmn-icon-start-event-none",s("Create start event")),"create.intermediate-event":c("bpmn:IntermediateThrowEvent","event","bpmn-icon-intermediate-event-none",s("Create intermediate/boundary event")),"create.end-event":c("bpmn:EndEvent","event","bpmn-icon-end-event-none",s("Create end event")),"create.exclusive-gateway":c("bpmn:ExclusiveGateway","gateway","bpmn-icon-gateway-none",s("Create gateway")),"create.task":c("bpmn:Task","activity","bpmn-icon-task",s("Create task")),"create.data-object":c("bpmn:DataObjectReference","data-object","bpmn-icon-data-object",s("Create data object reference")),"create.data-store":c("bpmn:DataStoreReference","data-store","bpmn-icon-data-store",s("Create data store reference")),"create.subprocess-expanded":{group:"activity",className:"bpmn-icon-subprocess-expanded",title:s("Create expanded sub-process"),action:{dragstart:p,click:p}},"create.participant-expanded":{group:"collaboration",className:"bpmn-icon-participant",title:s("Create pool/participant"),action:{dragstart:l,click:l}},"create.group":c("bpmn:Group","artifact","bpmn-icon-group",s("Create group"))}),e};var f_={__depends__:[Jv,Xd,$f,i_,c_,h_,yo],__init__:["paletteProvider"],paletteProvider:["type",d_]};function m_(e,t,n,i,r){To.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){v(e.canExecute.replacements,(function(o){var a=o.oldElementId,s={type:o.newElementType};if(!e.visualReplacements[a]){var c=t.get(a);L(s,{x:c.x,y:c.y});var p=n.createShape(s);i.addShape(p,c.parent);var l=fe('[data-element-id="'+jo(c.id)+'"]',e.dragGroup);l&&be(l,{display:"none"});var u=r.addDragger(p,e.dragGroup);e.visualReplacements[a]=u,i.removeShape(p)}}))}(o):function(e){var t=e.visualReplacements;v(t,(function(n,i){var r=fe('[data-element-id="'+jo(i)+'"]',e.dragGroup);r&&be(r,{display:"inline"}),n.remove(),t[i]&&delete t[i]}))}(o)}))}m_.$inject=["eventBus","elementRegistry","elementFactory","canvas","previewSupport"],e(m_,To);var y_={__depends__:[Pl],__init__:["bpmnReplacePreview"],bpmnReplacePreview:["type",m_]},g_=40,v_=["x","y"],__=Math.abs;function b_(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&&Ca(e.originalEvent)||(t.initialConnectionStart||(t.initialConnectionStart=t.connectionStart),n&&r&&function(e,t,n){v_.forEach((function(i){var r=E_(i,t);e[i]<t[i]+n?ll(e,i,t[i]+n):e[i]>t[i]+r-n&&ll(e,i,t[i]+r-n)}))}(e,r,function(e){return mr(e,"bpmn:Task")?10:20}(r)),r&&function(e,t){return w(t,(function(t){return w_(e,t)}))}(n,["bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:SequenceFlow"])?(t.connectionStart=cl(i),yr(r,["bpmn:Event","bpmn:Gateway"])&&x_(e,cl(r)),yr(r,["bpmn:Task","bpmn:SubProcess"])&&function(e,t){var n=cl(t);v_.forEach((function(i){(function(e,t,n){return e[n]>t[n]+20&&e[n]<t[n]+E_(n,t)-20})(e,t,i)&&ll(e,i,n[i])}))}(e,r),mr(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=cl(n),o=fn(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];__(i-r[t])<g_&&(n=i>r[t]?r[t]+g_:r[t]-g_,ll(e,t,n))}))}(e)):w_(n,"bpmn:MessageFlow")?(mr(i,"bpmn:Event")&&(t.connectionStart=cl(i)),mr(r,"bpmn:Event")&&x_(e,cl(r))):t.connectionStart=t.initialConnectionStart)}))}function x_(e,t){ll(e,"x",t.x),ll(e,"y",t.y)}function w_(e,t){return e&&e.type===t}function E_(e,t){return"x"===e?t.width:t.height}function S_(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}function C_(){this._snapValues={}}b_.$inject=["eventBus"],S_.prototype.getSnapOrigin=function(e){return this._snapOrigins[e]},S_.prototype.setSnapOrigin=function(e,t){this._snapOrigins[e]=t,-1===this._snapLocations.indexOf(e)&&this._snapLocations.push(e)},S_.prototype.addDefaultSnap=function(e,t){var n=this._defaultSnaps[e];n||(n=this._defaultSnaps[e]=[]),n.push(t)},S_.prototype.getSnapLocations=function(){return this._snapLocations},S_.prototype.setSnapLocations=function(e){this._snapLocations=e},S_.prototype.pointsForTarget=function(e){var t=e.id||e,n=this._targets[t];return n||(n=this._targets[t]=new C_).initDefaults(this._defaultSnaps),n},C_.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)},C_.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],rl(r-e)<=n)return r}(e[n],r[n],i)},C_.prototype.initDefaults=function(e){var t=this;v(e||{},(function(e,n){v(e,(function(e){t.add(n,e)}))}))};function k_(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||!Ca(e.originalEvent))&&!pl(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()}))}k_.$inject=["elementRegistry","eventBus","snapping"],k_.prototype.initSnap=function(e){var t,n=this._elementRegistry,i=e.context,r=i.shape,o=i.snapContext;o||(o=i.snapContext=new S_);var a=(t=n.get(r.id)?cl(r,e):{x:e.x+cl(r).x,y:e.y+cl(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}),sn(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},k_.prototype.addSnapTargetPoints=function(e,t,n){return v(this.getSnapTargets(t,n),(function(n){if(sn(n))sn(t)&&e.add("mid",cl(n));else if(an(n)){if(n.waypoints.length<3)return;v(n.waypoints.slice(1,-1),(function(t){e.add("mid",t)}))}else e.add("mid",cl(n))})),u(t.x)&&u(t.y)?(this._elementRegistry.get(t.id)&&e.add("mid",cl(t)),e):e},k_.prototype.getSnapTargets=function(e,t){return ul(t).filter((function(e){return!e.hidden}))};function R_(e,t){t.invoke(k_,this),e.on(["create.move","create.end"],1500,P_),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)&&!pl(e)&&function(e,t){var n,i=ln(t),r=ed(e,t),o=e.context,a=o.shape;n=a.parent?{x:0,y:0}:dn(a);/top/.test(r)?ll(e,"y",i.top-n.y):/bottom/.test(r)&&ll(e,"y",i.bottom-n.y);/left/.test(r)?ll(e,"x",i.left-n.x):/right/.test(r)&&ll(e,"x",i.right-n.x)}(e,i)}))}function P_(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)&&ll(e,"x",e.x),(n&&n>=e.y||r&&r<=e.y)&&ll(e,"y",e.y)}}function A_(e,t){return-1!==e.indexOf(t)}function M_(e,t,n){return t?{x:e.x-n.x,y:e.y-n.y}:{x:e.x,y:e.y}}e(R_,k_),R_.$inject=["eventBus","injector"],R_.prototype.initSnap=function(e){var t=k_.prototype.initSnap.call(this,e),n=e.shape,i=!!this._elementRegistry.get(n.id);return v(n.outgoing,(function(n){var r=n.waypoints[0];r=r.original||r,t.setSnapOrigin(n.id+"-docking",M_(r,i,e))})),v(n.incoming,(function(n){var r=n.waypoints[n.waypoints.length-1];r=r.original||r,t.setSnapOrigin(n.id+"-docking",M_(r,i,e))})),mr(n,"bpmn:Participant")&&t.setSnapLocations(["top-left","bottom-right","mid"]),t},R_.prototype.addSnapTargetPoints=function(e,t,n){k_.prototype.addSnapTargetPoints.call(this,e,t,n);var i=this.getSnapTargets(t,n);v(i,(function(n){var i;(function(e){if(mr(e,"bpmn:SubProcess")&&jr(e))return!0;return mr(e,"bpmn:Participant")}(n)||(i="bpmn:TextAnnotation",[t,n].every((function(e){return mr(e,i)}))))&&(e.add("top-left",al(n)),e.add("bottom-right",sl(n)))}));var r=this._elementRegistry;return v(t.incoming,(function(n){if(r.get(t.id)){A_(i,n.source)||e.add("mid",dn(n.source));var o=n.waypoints[0];e.add(n.id+"-docking",o.original||o)}})),v(t.outgoing,(function(n){if(r.get(t.id)){A_(i,n.target)||e.add("mid",dn(n.target));var o=n.waypoints[n.waypoints.length-1];e.add(n.id+"-docking",o.original||o)}})),mr(n,"bpmn:SequenceFlow")&&(e=this.addSnapTargetPoints(e,t,n.parent)),e},R_.prototype.getSnapTargets=function(e,t){return k_.prototype.getSnapTargets.call(this,e,t).filter((function(e){return!mr(e,"bpmn:Lane")}))};function T_(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&&Ca(e.originalEvent)||pl(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)&&ll(e,"x",e.x),function(e){return"e"===e||"w"===e}(a)&&ll(e,"y",e.y),t.snap(e,c)}})),e.on(["resize.cleanup"],(function(){t.hide()}))}function B_(e,t){var n=dn(e),i=ln(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}T_.prototype.initSnap=function(e){var t=e.context,n=t.shape,i=t.direction,r=t.snapContext;r||(r=t.snapContext=new S_);var o=B_(n,i);return r.setSnapOrigin("corner",{x:o.x-e.x,y:o.y-e.y}),r},T_.prototype.addSnapTargetPoints=function(e,t,n,i){return v(this.getSnapTargets(t,n),(function(t){e.add("corner",sl(t)),e.add("corner",al(t))})),e.add("corner",B_(t,i)),e},T_.$inject=["eventBus","snapping"],T_.prototype.getSnapTargets=function(e,t){return ul(t).filter((function(t){return!(n=t,i=e,n.host===i||an(t)||function(e){return!!e.hidden}(t)||sn(t));var n,i}))};function D_(e){this._canvas=e,this._asyncHide=j(O(this.hide,this),1e3)}D_.$inject=["canvas"],D_.prototype.snap=function(e,t){var n=e.context.snapContext,i=n.getSnapLocations(),r={x:pl(e,"x"),y:pl(e,"y")};v(i,(function(i){var o=n.getSnapOrigin(i),a={x:e.x+o.x,y:e.y+o.y};if(v(["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),v(["x","y"],(function(t){var n=r[t];l(n)&&ll(e,t,n.originValue)}))},D_.prototype._createLine=function(e){var t=this._canvas.getLayer("snap"),n=Ae("path");return be(n,{d:"M0,0 L0,0"}),we(n).add("djs-snap-line"),ge(t,n),{update:function(t){u(t)?be(n,"horizontal"===e?{d:"M-100000,"+t+" L+100000,"+t,display:""}:{d:"M "+t+",-100000 L "+t+", +100000",display:""}):be(n,{display:"none"})}}},D_.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}},D_.prototype.showSnapLine=function(e,t){var n=this.getSnapLine(e);n&&n.update(t),this._asyncHide()},D_.prototype.getSnapLine=function(e){return this._snapLines||this._createSnapLines(),this._snapLines[e]},D_.prototype.hide=function(){v(this._snapLines,(function(e){e.update()}))};var N_={__depends__:[{__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",k_],resizeSnapping:["type",T_],snapping:["type",D_]}],__init__:["connectSnapping","createMoveSnapping"],connectSnapping:["type",b_],createMoveSnapping:["type",R_]};function j_(e,t,n,i){this._open=!1,this._results={},this._eventMaps=[],this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._canvas=e,this._eventBus=t,this._selection=n,this._translate=i,this._container=this._getBoxHtml(),this._searchInput=fe(j_.INPUT_SELECTOR,this._container),this._resultsContainer=fe(j_.RESULTS_CONTAINER_SELECTOR,this._container),this._canvas.getContainer().appendChild(this._container),t.on(["canvas.destroy","diagram.destroy","drag.init","elements.changed"],this.close,this)}function O_(e,t,n){var i=function(e){var t="";return e.forEach((function(e){var n=Lo(e.value||e.matched||e.normal),i=e.match||e.matched;t+=i?'<b class="'+j_.RESULT_HIGHLIGHT_CLASS+'">'+n+"</b>":n})),""!==t?t:null}(t),r=he(n);r.innerHTML=i,e.appendChild(r)}j_.$inject=["canvas","eventBus","selection","translate"],j_.prototype._bindEvents=function(){var e=this;function t(t,n,i,r){e._eventMaps.push({el:t,type:i,listener:ce.bind(t,n,i,r)})}t(document,"html","click",(function(t){e.close(!1)})),t(this._container,j_.INPUT_SELECTOR,"click",(function(e){e.stopPropagation(),e.delegateTarget.focus()})),t(this._container,j_.RESULT_SELECTOR,"mouseover",(function(t){t.stopPropagation(),e._scrollToNode(t.delegateTarget),e._preselect(t.delegateTarget)})),t(this._container,j_.RESULT_SELECTOR,"click",(function(t){t.stopPropagation(),e._select(t.delegateTarget)})),t(this._container,j_.INPUT_SELECTOR,"keydown",(function(e){ka("ArrowUp",e)&&e.preventDefault(),ka("ArrowDown",e)&&e.preventDefault()})),t(this._container,j_.INPUT_SELECTOR,"keyup",(function(t){if(ka("Escape",t))return e.close();if(ka("Enter",t)){var n=e._getCurrentResult();return n?e._select(n):e.close(!1)}return ka("ArrowUp",t)?e._scrollToDirection(!0):ka("ArrowDown",t)?e._scrollToDirection():void(ka(["ArrowLeft","ArrowRight"],t)||e._search(t.delegateTarget.value))}))},j_.prototype._unbindEvents=function(){this._eventMaps.forEach((function(e){ce.unbind(e.el,e.type,e.listener)}))},j_.prototype._search=function(e){var t=this;if(this._clearResults(),e&&""!==e){var n=this._searchProvider.find(e);if((n=n.filter((function(e){return!t._canvas.getRootElements().includes(e.element)}))).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=fe(j_.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}else this._selection.select(null)}},j_.prototype._scrollToDirection=function(e){var t=this._getCurrentResult();if(t){var n=e?t.previousElementSibling:t.nextElementSibling;n&&(this._scrollToNode(n),this._preselect(n))}},j_.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)}},j_.prototype._clearResults=function(){Q(this._resultsContainer),this._results={},this._eventBus.fire("searchPad.cleared")},j_.prototype._getCurrentResult=function(){return fe(j_.RESULT_SELECTED_SELECTOR,this._resultsContainer)},j_.prototype._createResultNode=function(e,t){var n=he(j_.RESULT_HTML);return e.primaryTokens.length>0&&O_(n,e.primaryTokens,j_.RESULT_PRIMARY_HTML),O_(n,e.secondaryTokens,j_.RESULT_SECONDARY_HTML),K(n,j_.RESULT_ID_ATTRIBUTE,t),this._resultsContainer.appendChild(n),n},j_.prototype.registerProvider=function(e){this._searchProvider=e},j_.prototype.open=function(){if(!this._searchProvider)throw new Error("no search provider registered");this.isOpen()||(this._cachedRootElement=this._canvas.getRootElement(),this._cachedSelection=this._selection.get(),this._cachedViewbox=this._canvas.viewbox(),this._selection.select(null),this._bindEvents(),this._open=!0,X(this._canvas.getContainer()).add("djs-search-open"),X(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))},j_.prototype.close=function(e=!0){this.isOpen()&&(e&&(this._cachedRootElement&&this._canvas.setRootElement(this._cachedRootElement),this._cachedSelection&&this._selection.select(this._cachedSelection),this._cachedViewbox&&this._canvas.viewbox(this._cachedViewbox),this._eventBus.fire("searchPad.restored")),this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._unbindEvents(),this._open=!1,X(this._canvas.getContainer()).remove("djs-search-open"),X(this._container).remove("open"),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._eventBus.fire("searchPad.closed"),this._canvas.restoreFocus())},j_.prototype.toggle=function(){this.isOpen()?this.close():this.open()},j_.prototype.isOpen=function(){return this._open},j_.prototype._preselect=function(e){var t=this._getCurrentResult();if(e!==t){t&&X(t).remove(j_.RESULT_SELECTED_CLASS);var n=K(e,j_.RESULT_ID_ATTRIBUTE),i=this._results[n].element;X(e).add(j_.RESULT_SELECTED_CLASS),this._canvas.scrollToElement(i,{top:300}),this._selection.select(i),this._eventBus.fire("searchPad.preselected",i)}},j_.prototype._select=function(e){var t=K(e,j_.RESULT_ID_ATTRIBUTE),n=this._results[t].element;this._cachedSelection=null,this._cachedViewbox=null,this.close(!1),this._canvas.scrollToElement(n,{top:300}),this._selection.select(n),this._eventBus.fire("searchPad.selected",n)},j_.prototype._getBoxHtml=function(){const e=he(j_.BOX_HTML),t=fe(j_.INPUT_SELECTOR,e);return t&&t.setAttribute("aria-label",this._translate("Search in diagram")),e},j_.CONTAINER_SELECTOR=".djs-search-container",j_.INPUT_SELECTOR=".djs-search-input input",j_.RESULTS_CONTAINER_SELECTOR=".djs-search-results",j_.RESULT_SELECTOR=".djs-search-result",j_.RESULT_SELECTED_CLASS="djs-search-result-selected",j_.RESULT_SELECTED_SELECTOR="."+j_.RESULT_SELECTED_CLASS,j_.RESULT_ID_ATTRIBUTE="data-result-id",j_.RESULT_HIGHLIGHT_CLASS="djs-search-highlight",j_.BOX_HTML='<div class="djs-search-container djs-scrollable">\n <div class="djs-search-input">\n <svg class="djs-search-icon" width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M9.0325 8.5H9.625L13.3675 12.25L12.25 13.3675L8.5 9.625V9.0325L8.2975 8.8225C7.4425 9.5575 6.3325 10 5.125 10C2.4325 10 0.25 7.8175 0.25 5.125C0.25 2.4325 2.4325 0.25 5.125 0.25C7.8175 0.25 10 2.4325 10 5.125C10 6.3325 9.5575 7.4425 8.8225 8.2975L9.0325 8.5ZM1.75 5.125C1.75 6.9925 3.2575 8.5 5.125 8.5C6.9925 8.5 8.5 6.9925 8.5 5.125C8.5 3.2575 6.9925 1.75 5.125 1.75C3.2575 1.75 1.75 3.2575 1.75 5.125Z" fill="#22242A"/>\n </svg>\n <input type="text" spellcheck="false" />\n </div>\n <div class="djs-search-results" />\n</div>',j_.RESULT_HTML='<div class="djs-search-result"></div>',j_.RESULT_PRIMARY_HTML='<div class="djs-search-result-primary"></div>',j_.RESULT_SECONDARY_HTML='<p class="djs-search-result-secondary"></p>';var L_={__depends__:[yo,Po,_a],searchPad:["type",j_]};function $_(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._search=i,t.registerProvider(this)}function I_(e){const{item:{element:t},tokens:n}=e;return{element:t,primaryTokens:n.label,secondaryTokens:n.id}}$_.$inject=["elementRegistry","searchPad","canvas","search"],$_.prototype.find=function(e){var t=this._canvas.getRootElements(),n=this._elementRegistry.filter((function(e){return!sn(e)&&!t.includes(e)}));return this._search(n.map((e=>({element:e,label:Wr(e),id:e.id}))),e,{keys:["label","id"]}).map(I_)};var F_={__depends__:[L_,jc],__init__:["bpmnSearch"],bpmnSearch:["type",$_]};const z_={width:36,height:50},H_={width:50,height:50};function V_(e,t,n){return Ae("path",{d:e,strokeWidth:2,transform:`translate(${t.x}, ${t.y})`,...n})}function G_(e,t){this._styles=t,e.registerProvider(this)}function W_(e,t){var n;return"bpmn:DataObjectReference"===t?n=z_:"bpmn:DataStoreReference"===t&&(n=H_),e.width===n.width&&e.height===n.height}G_.$inject=["outline","styles"],G_.prototype.getOutline=function(e){const t=this._styles.cls("djs-outline",["no-fill"]);var n;if(!sn(e))return mr(e,"bpmn:Gateway")?(L((n=Ae("rect")).style,{"transform-box":"fill-box",transform:"rotate(45deg)","transform-origin":"center"}),be(n,L({x:2,y:2,rx:4,width:e.width-4,height:e.height-4},t))):yr(e,["bpmn:Task","bpmn:SubProcess","bpmn:Group","bpmn:CallActivity"])?be(n=Ae("rect"),L({x:-5,y:-5,rx:14,width:e.width+10,height:e.height+10},t)):mr(e,"bpmn:EndEvent")?be(n=Ae("circle"),L({cx:e.width/2,cy:e.height/2,r:e.width/2+5+1},t)):mr(e,"bpmn:Event")?be(n=Ae("circle"),L({cx:e.width/2,cy:e.height/2,r:e.width/2+5},t)):mr(e,"bpmn:DataObjectReference")&&W_(e,"bpmn:DataObjectReference")?n=V_("M44.7648 11.3263L36.9892 2.64074C36.0451 1.58628 34.5651 0.988708 33.1904 0.988708H5.98667C3.22688 0.988708 0.989624 3.34892 0.989624 6.26039V55.0235C0.989624 57.9349 3.22688 60.2952 5.98667 60.2952H40.966C43.7257 60.2952 45.963 57.9349 45.963 55.0235V14.9459C45.963 13.5998 45.6407 12.3048 44.7648 11.3263Z",{x:-6,y:-6},t):mr(e,"bpmn:DataStoreReference")&&W_(e,"bpmn:DataStoreReference")&&(n=V_("M1.03845 48.1347C1.03845 49.3511 1.07295 50.758 1.38342 52.064C1.69949 53.3938 2.32428 54.7154 3.56383 55.6428C6.02533 57.4841 10.1161 58.7685 14.8212 59.6067C19.5772 60.4538 25.1388 60.8738 30.6831 60.8738C36.2276 60.8738 41.7891 60.4538 46.545 59.6067C51.2504 58.7687 55.3412 57.4842 57.8028 55.6429C59.0424 54.7156 59.6673 53.3938 59.9834 52.064C60.2938 50.7579 60.3285 49.351 60.3285 48.1344V13.8415C60.3285 12.6249 60.2938 11.218 59.9834 9.91171C59.6673 8.58194 59.0423 7.2602 57.8027 6.33294C55.341 4.49168 51.2503 3.20723 46.545 2.36914C41.7891 1.522 36.2276 1.10204 30.6831 1.10205C25.1388 1.10206 19.5772 1.52206 14.8213 2.36923C10.1162 3.20734 6.02543 4.49183 3.5639 6.33314C2.32433 7.26038 1.69951 8.58206 1.38343 9.91181C1.07295 11.2179 1.03845 12.6247 1.03845 13.8411V48.1347Z",{x:-6,y:-6},t)),n},G_.prototype.updateOutline=function(e,t){if(!sn(e))return yr(e,["bpmn:SubProcess","bpmn:Group"])?(be(t,{width:e.width+10,height:e.height+10}),!0):!!yr(e,["bpmn:Event","bpmn:Gateway","bpmn:DataStoreReference","bpmn:DataObjectReference"])};var U_={__depends__:[jv],__init__:["outlineProvider"],outlineProvider:["type",G_]};function q_(e){Nr.call(this,e)}return e(q_,Nr),q_.Viewer=ba,q_.NavigatedViewer=Xa,q_.prototype.createDiagram=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>')},q_.prototype._interactionModules=[ja,Va,Ya],q_.prototype._modelingModules=[Vc,ip,vp,cp,ml,xl,El,xg,pf,Xd,Pg,Ng,Kg,Xg,Qg,av,Sv,Vy,Bv,Gv,f_,y_,gv,N_,F_,U_],q_.prototype._modules=[].concat(ba.prototype._modules,q_.prototype._interactionModules,q_.prototype._modelingModules),q_}));