camunda-bpmn-js 5.2.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -99,7 +99,7 @@
99
99
  </ul>
100
100
  `))}
101
101
  </div>
102
- `}function $l(e){const{onClose:t,onSelect:n,className:i,headerEntries:r,position:o,title:s,width:l,scale:c,search:p,emptyPlaceholder:u,searchFn:h,entries:m,onOpened:f,onClosed:g}=e,y=_l((()=>!!a(p)&&m.length>5),[p,m]),[v,b]=vl(""),x=El(((e,t)=>{if(!y)return e;if(!t)return e.filter((({rank:e=0})=>e>=0));const n=e.filter((({searchable:e})=>!1!==e));return h(n,t,{keys:["label","description","search"]}).map((({item:e})=>e))}),[y]),[w,_]=vl(x(m,v)),[E,O]=vl(w[0]),P=El((e=>{E&&e.includes(E)||O(e[0]),_(e)}),[E,_,O]);bl((()=>{P(x(m,v))}),[v,m]);const k=El((e=>{let t=w.indexOf(E)+e;t<0&&(t=w.length-1),t>=w.length&&(t=0),O(w[t])}),[w,E,O]),S=El((e=>"Enter"===e.key&&E?n(e,E):"ArrowUp"===e.key?(k(-1),e.preventDefault()):"ArrowDown"===e.key?(k(1),e.preventDefault()):void 0),[n,E,k]),C=El((e=>{ge(e.target,"input")&&b((()=>e.target.value))}),[b]);bl((()=>(f(),()=>{g()})),[]);const A=_l((()=>s||r.length>0),[s,r]);return ll`
102
+ `}function $l(e){const{onClose:t,onSelect:n,className:i,headerEntries:r,position:o,title:s,width:l,scale:c,search:p,emptyPlaceholder:u,searchFn:h,entries:m,onOpened:f,onClosed:g}=e,y=_l((()=>!!a(p)&&m.length>5),[p,m]),[v,b]=vl(""),x=El(((e,t)=>{if(!y)return e;if(!t.trim())return e.filter((({rank:e=0})=>e>=0));const n=e.filter((({searchable:e})=>!1!==e));return h(n,t,{keys:["label","description","search"]}).map((({item:e})=>e))}),[y]),[w,_]=vl(x(m,v)),[E,O]=vl(w[0]),P=El((e=>{E&&e.includes(E)||O(e[0]),_(e)}),[E,_,O]);bl((()=>{P(x(m,v))}),[v,m]);const k=El((e=>{let t=w.indexOf(E)+e;t<0&&(t=w.length-1),t>=w.length&&(t=0),O(w[t])}),[w,E,O]),S=El((e=>"Enter"===e.key&&E?n(e,E):"ArrowUp"===e.key?(k(-1),e.preventDefault()):"ArrowDown"===e.key?(k(1),e.preventDefault()):void 0),[n,E,k]),C=El((e=>{ge(e.target,"input")&&b((()=>e.target.value))}),[b]);bl((()=>(f(),()=>{g()})),[]);const A=_l((()=>s||r.length>0),[s,r]);return ll`
103
103
  <${jl}
104
104
  onClose=${t}
105
105
  onKeyup=${C}
@@ -153,7 +153,7 @@
153
153
  >
154
154
  ${o}
155
155
  </div>
156
- `}var Il=["contextPad.close","canvas.viewbox.changing","commandStack.changed"];function Ll(e,t,n,i){this._eventBus=t,this._canvas=n,this._search=i,this._current=null;var r=a(e&&e.scale)?e.scale:{min:1,max:1};this._config={scale:r},t.on("diagram.destroy",(()=>{this.close()})),t.on("element.changed",(e=>{const t=this.isOpen()&&this._current.target;e.element===t&&this.refresh()}))}function ql(e,t){return zl(t)-zl(e)}function zl(e){return e.reduce(((e,t)=>e+function(e){if(!e.match)return 0;return e.start?1.37:e.wordStart?1.13:1}(t)),0)}function Vl(e="",t=""){return e.localeCompare(t)}function Fl(e){return e.replace(/[/\-\\^$*+?.()|[\]{}]/g,"\\$&")}Ll.$inject=["config.popupMenu","eventBus","canvas","search"],Ll.prototype._render=function(){const{position:e,providerId:t,entries:n,headerEntries:i,emptyPlaceholder:r,options:o}=this._current,s=Object.entries(n).map((([e,t])=>({id:e,...t}))),a=Object.entries(i).map((([e,t])=>({id:e,...t}))),l=e&&(t=>this._ensureVisible(t,e)),c=this._updateScale(this._current.container);tl(ll`
156
+ `}var Il=["contextPad.close","canvas.viewbox.changing","commandStack.changed"];function Ll(e,t,n,i){this._eventBus=t,this._canvas=n,this._search=i,this._current=null;var r=a(e&&e.scale)?e.scale:{min:1,max:1};this._config={scale:r},t.on("diagram.destroy",(()=>{this.close()})),t.on("element.changed",(e=>{const t=this.isOpen()&&this._current.target;e.element===t&&this.refresh()}))}function ql(e,t){return zl(t)-zl(e)}function zl(e){return e.reduce(((e,t)=>e+function(e){const t=Math.log(e.value.length);if(!e.match)return-.07*t;return(e.start?e.end?131.9:7.87:e.wordStart?2.19:1)*t}(t)),0)}function Vl(e="",t=""){return e.localeCompare(t)}function Fl(e){return e.replace(/[/\-\\^$*+?.()|[\]{}]/g,"\\$&")}Ll.$inject=["config.popupMenu","eventBus","canvas","search"],Ll.prototype._render=function(){const{position:e,providerId:t,entries:n,headerEntries:i,emptyPlaceholder:r,options:o}=this._current,s=Object.entries(n).map((([e,t])=>({id:e,...t}))),a=Object.entries(i).map((([e,t])=>({id:e,...t}))),l=e&&(t=>this._ensureVisible(t,e)),c=this._updateScale(this._current.container);tl(ll`
157
157
  <${$l}
158
158
  onClose=${e=>this.close(e)}
159
159
  onSelect=${(e,t,n)=>this.trigger(e,t,n)}
@@ -168,7 +168,7 @@
168
168
  searchFn=${this._search}
169
169
  ...${{...o}}
170
170
  />
171
- `,this._current.container)},Ll.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:s}=this._getContext(e,t);this._current={position:n,providerId:t,target:e,entries:r,headerEntries:o,emptyPlaceholder:s,container:this._createContainer({provider:t}),options:i},this._emit("open"),this._bindAutoClose(),this._render()},Ll.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()},Ll.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)}},Ll.prototype.close=function(){this.isOpen()&&(this._emit("close"),this.reset(),this._canvas.restoreFocus(),this._current=null)},Ll.prototype.reset=function(){const e=this._current.container;tl(null,e),be(e)},Ll.prototype._emit=function(e,t){this._eventBus.fire(`popupMenu.${e}`,t)},Ll.prototype._onOpened=function(){this._emit("opened")},Ll.prototype._onClosed=function(){this._emit("closed")},Ll.prototype._createContainer=function(e){var t=this._canvas.getContainer();const n=fe(`<div class="djs-popup-parent djs-scrollable" data-popup=${e.provider}></div>`);return t.appendChild(n),n},Ll.prototype._bindAutoClose=function(){this._eventBus.once(Il,this.close,this)},Ll.prototype._unbindAutoClose=function(){this._eventBus.off(Il,this.close,this)},Ll.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),a(e)&&n<e&&(r=e),a(t)&&n>t&&(r=t)),r},Ll.prototype._ensureVisible=function(e,t){var n=document.documentElement.getBoundingClientRect(),i=e.getBoundingClientRect(),r={},o=t.x,s=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,s=t.y-i.height):r.x?(o=t.x-i.width,s=t.y):r.y&&t.y<i.height?(o=t.x,s=10):r.y&&(o=t.x,s=t.y-i.height),t.y<n.top&&(s=t.y+i.height),{x:o,y:s}},Ll.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},Ll.prototype.registerProvider=function(e,t,n){n||(n=t,t=1e3),this._eventBus.on("popupMenu.getProviders."+e,t,(function(e){e.providers.push(n)}))},Ll.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"popupMenu.getProviders."+e,providers:[]});return this._eventBus.fire(t),t.providers},Ll.prototype._getEntries=function(e,t){var n={};return v(t,(function(t){if(t.getPopupMenuEntries){var i=t.getPopupMenuEntries(e);d(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]=q(e,["id"])}))})),n},Ll.prototype._getHeaderEntries=function(e,t){var n={};return v(t,(function(t){if(t.getPopupMenuHeaderEntries){var i=t.getPopupMenuHeaderEntries(e);d(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]=q(e,["id"])}))}})),n},Ll.prototype._getEmptyPlaceholder=function(e){const t=e.find((e=>d(e.getEmptyPlaceholder)));return t&&t.getEmptyPlaceholder()},Ll.prototype.isOpen=function(){return!!this._current},Ll.prototype.trigger=function(e,t,n="click"){if(e.preventDefault(),!t){let n=X(ee(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(d(i)){if("click"===n)return i(e,t)}else if(i[n])return i[n](e,t)},Ll.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 Hl={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:s}=function(e,t){if(!e)return{tokens:[],matchedWords:{}};const n=[],i={},r=t.map(Fl).flatMap((e=>["(?<wordStart>\\b"+e+")",e])).join("|"),o=new RegExp(r,"ig");let s,a=0;for(;s=o.exec(e);){const[t]=s;s.index>a&&n.push({value:e.slice(a,s.index),index:a}),n.push({value:t,index:s.index,match:!0,wordStart:!!s.groups.wordStart,start:0===s.index}),i[t.toLowerCase()]=!0,a=s.index+t.length}a<e.length&&n.push({value:e.slice(a),index:a});return{tokens:n,matchedWords:i}}(r,t);return{tokens:{...n.tokens,[i]:o},matchedWords:{...n.matchedWords,...s}}}),{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=ql(t.tokens[i],n.tokens[i]);if(0!==e)return e;const r=Vl(t.item[i],n.item[i]);if(0!==r)return r}return 0}}(i))}]},Ul={__depends__:[Hl],__init__:["popupMenu"],popupMenu:["type",Ll]},Wl={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 Gl(e,t,n,i){e.registerProvider(900,this),this._contextPad=e,this._popupMenu=t,this._translate=n,this._canvas=i}Gl.$inject=["contextPad","popupMenu","translate","canvas"],Gl.prototype.getMultiElementContextPadEntries=function(e){var t={};return this._isAllowed(e)&&j(t,this._getEntries(e)),t},Gl.prototype._isAllowed=function(e){return!this._popupMenu.isEmpty(e,"align-elements")},Gl.prototype._getEntries=function(){var e=this;return{"align-elements":{group:"align-elements",title:e._translate("Align elements"),html:`<div class="entry">${Wl.align}</div>`,action:{click:function(t,n){var i=e._getMenuPosition(n);j(i,{cursor:{x:t.x,y:t.y}}),e._popupMenu.open(n,"align-elements",i)}}}}},Gl.prototype._getMenuPosition=function(e){var t=this._contextPad.getPad(e).html.getBoundingClientRect();return{x:t.left,y:t.bottom+5}};var Ql=["left","center","right","top","middle","bottom"];function Xl(e,t,n,i){this._alignElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",this)}function Kl(e){Fo.call(this,e),this.init()}function Yl(e){Kl.call(this,e)}Xl.$inject=["popupMenu","alignElements","translate","rules"],Xl.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&j(t,this._getEntries(e)),t},Xl.prototype._isAllowed=function(e){return this._rules.allowed("elements.align",{elements:e})},Xl.prototype._getEntries=function(e){var t=this._alignElements,n=this._translate,i=this._popupMenu,r={};return v(Ql,(function(o){r["align-elements-"+o]={group:"align",title:n("Align elements "+o),className:"bjs-align-elements-menu-entry",imageHtml:Wl[o],action:function(){t.trigger(e,o),i.close()}}})),r},Kl.$inject=["eventBus"],e(Kl,Fo),Kl.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)}))},Kl.prototype.init=function(){},Yl.$inject=["eventBus"],e(Yl,Kl),Yl.prototype.init=function(){this.addRule("elements.align",(function(e){var t=y(e.elements,(function(e){return!(e.waypoints||e.host||e.labelTarget)}));return!((t=dt(t)).length<2)&&t}))};var Zl={__depends__:[va,Aa,Ul],__init__:["alignElementsContextPadProvider","alignElementsMenuProvider","bpmnAlignElements"],alignElementsContextPadProvider:["type",Gl],alignElementsMenuProvider:["type",Xl],bpmnAlignElements:["type",Yl]},Jl=10,ec=50,tc=250;function nc(e,t,n,i){for(var r;r=rc(e,n,t);)n=i(t,n,r);return n}function ic(e){return function(t,n,i){var r={x:n.x,y:n.y};return["x","y"].forEach((function(o){var s=e[o];if(s){var a="x"===o?"width":"height",l=s.margin,c=s.minDistance;r[o]=l<0?Math.min(i[o]+l-t[a]/2,n[o]-c+l):Math.max(i[o]+i[a]+l+t[a]/2,n[o]+c+l)}})),r}}function rc(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=oc(e);e.host&&(t=t.concat(oc(e.host)));e.attachers&&(t=t.concat(e.attachers.reduce((function(e,t){return e.concat(oc(t))}),[])));return t}(e);return f(r,(function(e){return e!==n&&"intersect"===xn(e,i,Jl)}))}function oc(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 sc(){return!0}function ac(e,t,n){e.on("autoPlace",100,(function(e){var t=e.shape;return function(e,t,n){n||(n={});var i=n.defaultDistance||ec,r=bn(e),o=gn(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}),s=t.appendShape(n,i,o,n.parent,r);return e.fire("autoPlace.end",{source:n,shape:s}),s}}function lc(e,t){e.on("autoPlace.end",500,(function(e){t.select(e.shape)}))}ac.$inject=["eventBus","modeling","canvas"],lc.$inject=["eventBus","selection"];var cc={__init__:["autoPlaceSelectionBehavior"],autoPlace:["type",ac],autoPlaceSelectionBehavior:["type",lc]};function pc(e,t){for(h(t)&&(t=[t]);e=e.parent;)if(Er(e,t))return e;return null}function uc(e,t){var n=pc(e,"bpmn:Process");if(n)return!0;var i,r=["bpmn:Participant","bpmn:Lane"];if(n=pc(e,r))return Fr(n);if(Er(e,r))return Fr(e);for(i=Or(e);i&&!_r(i,"bpmn:Process");i=i.$parent);if(!t)return!0;var o=t.find((function(e){var t=Or(e);return t&&t.get("processRef")===i}));return!o||Fr(o)}function dc(e,t,n){var i=uc(e,n);return _r(t,"bpmn:TextAnnotation")?function(e,t,n){var i=gn(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};dn(e)&&(r=bn(e),n?(r.x+=100,r.y-=50):(r.x+=100,r.y+=50));var o={margin:n?-30:30,minDistance:20},s=n?{y:o}:{x:o};return nc(e,t,r,ic(s))}(e,t,i):Er(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])?function(e,t,n){var i=gn(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},s=n?{x:o}:{y:o};return nc(e,t,r,ic(s))}(e,t,i):_r(t,"bpmn:FlowNode")?function(e,t,n){var i=gn(e),r=bn(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"},s=function(e,t){t||(t={});var n=t.defaultDistance||ec,i=t.direction||"e",r=t.filter,o=t.getWeight||function(t){return t.source===e?1:-1},s=t.maxDistance||tc,a=t.reference||"start";function l(e,t){return"n"===i?"start"===a?gn(e).top-gn(t).bottom:"center"===a?gn(e).top-bn(t).y:gn(e).top-gn(t).top:"w"===i?"start"===a?gn(e).left-gn(t).right:"center"===a?gn(e).left-bn(t).x:gn(e).left-gn(t).left:"s"===i?"start"===a?gn(t).top-gn(e).bottom:"center"===a?bn(t).y-gn(e).bottom:gn(t).bottom-gn(e).bottom:"start"===a?gn(t).left-gn(e).right:"center"===a?bn(t).x-gn(e).right:gn(t).right-gn(e).right}r||(r=sc);var c=e.incoming.filter(r).map((function(t){var n=o(t),i=n<0?l(t.source,e):l(e,t.source);return{id:t.source.id,distance:i,weight:n}})),p=e.outgoing.filter(r).map((function(t){var n=o(t),i=n>0?l(e,t.target):l(t.target,e);return{id:t.target.id,distance:i,weight:n}})),u=x(c.concat(p).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>s||(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 _r(e,"bpmn:SequenceFlow")},direction:o.directionHint}),a=30,l=o.minDistance,c=o.baseOrientation;_r(e,"bpmn:BoundaryEvent")&&-1!==(c=xn(e,e.host,-25)).indexOf(o.boundaryOrientation)&&(a*=-1);var p=n?{x:i.right+s+t.width/2,y:r.y+hc(c,l,o)}:{x:r.x+hc(c,l,o),y:i.bottom+s+t.height/2},u={margin:a,minDistance:l},d=n?{y:u}:{x:u};return nc(e,t,p,ic(d))}(e,t,i):void 0}function hc(e,t,n){return e.includes(n.start)?-1*t:e.includes(n.end)?t:0}function mc(e,t){e.on("autoPlace",(function(e){var n=e.shape;return dc(e.source,n,t)}))}mc.$inject=["eventBus","elementRegistry"];var fc={__depends__:[cc],__init__:["bpmnAutoPlace"],bpmnAutoPlace:["type",mc]};function gc(e,t,n,r){Fo.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(P(t.closure.topLevel)),r=t.hints,s=!r||r.autoResize;!1!==s&&v(k(n,(function(e){return e.parent.id})),(function(e,t){c(s)&&(e=e.filter((function(e){return f(s,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 yc(e){e.invoke(gc,this)}function vc(e){Kl.call(this,e);var t=this;this.addRule("element.autoResize",(function(e){return t.canResize(e.elements,e.target)}))}function bc(e,t){vc.call(this,e),this._modeling=t}gc.$inject=["eventBus","elementRegistry","modeling","rules"],e(gc,Fo),gc.prototype._getOptimalBounds=function(e,t){var n=this.getOffset(t),i=this.getPadding(t),r=gn(yt(e)),o=gn(t),s={};return r.top-o.top<i.top&&(s.top=r.top-n.top),r.left-o.left<i.left&&(s.left=r.left-n.left),o.right-r.right<i.right&&(s.right=r.right+n.right),o.bottom-r.bottom<i.bottom&&(s.bottom=r.bottom+n.bottom),yn(j({},o,s))},gc.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=gn(e),t=gn(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}(L(t,["x","y","width","height"]),n);this.resize(t,n,{autoResize:i});var r=t.parent;r&&this._expand([t],r)}}},gc.prototype.getOffset=function(e){return{top:60,bottom:60,left:100,right:100}},gc.prototype.getPadding=function(e){return{top:2,bottom:2,left:15,right:15}},gc.prototype.resize=function(e,t,n){this._modeling.resizeShape(e,t,null,n)},yc.$inject=["injector"],e(yc,gc),yc.prototype.resize=function(e,t,n){_r(e,"bpmn:Participant")?this._modeling.resizeLane(e,t,null,n):this._modeling.resizeShape(e,t,null,n)},vc.$inject=["eventBus"],e(vc,Kl),vc.prototype.canResize=function(e,t){return!1},e(bc,vc),bc.$inject=["eventBus","modeling"],bc.prototype.canResize=function(e,t){if(_r(t.di,"bpmndi:BPMNPlane"))return!1;if(!_r(t,"bpmn:Participant")&&!_r(t,"bpmn:Lane")&&!_r(t,"bpmn:SubProcess"))return!1;var n=!0;return v(e,(function(e){(_r(e,"bpmn:Lane")||hn(e))&&(n=!1)})),n};var xc={__init__:["bpmnAutoResize","bpmnAutoResizeProvider"],bpmnAutoResize:["type",yc],bpmnAutoResizeProvider:["type",bc]};function wc(e,t,n){var i,r,o=this,s=n.get("dragging",!1);s&&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(),s.hover({element:r,gfx:i}),s.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=fs(e),function(e){return ee(e,"svg, .djs-element",!0)}(document.elementFromPoint(t.x,t.y))}}wc.$inject=["elementRegistry","eventBus","injector"];var _c={__init__:["hoverFix"],hoverFix:["type",wc]},Ec=Math.round,Oc="djs-drag-active";function Pc(e){e.preventDefault()}function kc(e,t,n,i){var r,o={threshold:5,trapClick:!0};function s(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 a(t,n){n=n||r;var i=e.createEvent(j({},n.payload,n.data,{isTouch:n.isTouch}));return!1!==e.fire("drag."+t,i)&&e.fire(n.prefix+"."+t,i)}function l(e,i){var o,l=r.payload,c=r.displacement,p=r.globalStart,u=fs(e),d=ia(u,p),h=r.localStart,m=s(u),g=ia(m,h);if(!r.active&&(i||(o=d,Math.sqrt(Math.pow(o.x,2)+Math.pow(o.y,2))>r.threshold))){if(j(l,{x:Ec(h.x+c.x),y:Ec(h.y+c.y),dx:0,dy:0},{originalEvent:e}),!1===a("start"))return f();r.active=!0,r.keepSelection||(l.previousSelection=n.get(),n.select(null)),r.cursor&&Zs(r.cursor),t.addMarker(t.getRootElement(),Oc)}ms(e),r.active&&(j(l,{x:Ec(m.x+c.x),y:Ec(m.y+c.y),dx:Ec(g.x),dy:Ec(g.y)},{originalEvent:e}),a("move"))}function c(e){var t=!0;r.active&&(e&&(r.payload.originalEvent=e,ms(e)),t=a("end")),!1===t&&a("rejected"),a("ended",g(!0!==t))}function p(e){Is("Escape",e)&&(Pc(e),f())}function u(t){var n;r.active&&(n=ta(e),setTimeout(n,400),Pc(t)),c(t)}function d(e){l(e)}function h(e){var t=r.payload;t.hoverGfx=e.gfx,t.hover=e.element,a("hover")}function m(e){a("out");var t=r.payload;t.hoverGfx=null,t.hover=null}function f(e){var t;if(r){var n=r.active;n&&a("cancel"),t=g(e),n&&a("canceled",t)}}function g(o){var s,g;a("cleanup"),Js(),g=r.trapClick?u:c,le.unbind(document,"mousemove",l),le.unbind(document,"dragstart",Pc),le.unbind(document,"selectstart",Pc),le.unbind(document,"mousedown",g,!0),le.unbind(document,"mouseup",g,!0),le.unbind(document,"keyup",p),le.unbind(document,"touchstart",d,!0),le.unbind(document,"touchcancel",f,!0),le.unbind(document,"touchmove",l,!0),le.unbind(document,"touchend",c,!0),e.off("element.hover",h),e.off("element.out",m),t.removeMarker(t.getRootElement(),Oc);var y=r.payload.previousSelection;return!1!==o&&y&&!n.get().length&&function(e){var t=e.filter((function(e){return i.get(e.id)}));t.length&&n.select(t)}(y),s=r,r=null,s}e.on("diagram.destroy",f),this.init=function(t,n,i,g){r&&f(!1),"string"==typeof n&&(g=i,i=n,n=null);var y,v,b,x,w,_=(g=j({},o,g||{})).data||{};x=g.trapClick?u:c,t?(y=hs(t)||t,v=fs(t),ms(t),"dragstart"===y.type&&Pc(y)):(y=null,v={x:0,y:0}),b=s(v),n||(n=b),w=function(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent}(y),r=j({prefix:i,data:_,payload:{},globalStart:v,displacement:ia(n,b),localStart:b,isTouch:w},g),g.manual||(w?(le.bind(document,"touchstart",d,!0),le.bind(document,"touchcancel",f,!0),le.bind(document,"touchmove",l,!0),le.bind(document,"touchend",c,!0)):(le.bind(document,"mousemove",l),le.bind(document,"dragstart",Pc),le.bind(document,"selectstart",Pc),le.bind(document,"mousedown",x,!0),le.bind(document,"mouseup",x,!0)),le.bind(document,"keyup",p),e.on("element.hover",h),e.on("element.out",m)),a("init"),g.autoActivate&&l(t,!0)},this.move=l,this.hover=h,this.out=m,this.end=c,this.cancel=f,this.context=function(){return r},this.setOptions=function(e){j(o,e)}}kc.$inject=["eventBus","canvas","selection","elementRegistry"];var Sc={__depends__:[_c,Ts],dragging:["type",kc]};function Cc(e,t,n){this._canvas=n,this._opts=j({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 Ac(e,t,n){return t<e&&e<n}Cc.$inject=["config.autoScroll","eventBus","canvas"],Cc.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 s=0,a=0,l=0;l<4;l++)Ac(o[l],n.scrollThresholdOut[l],n.scrollThresholdIn[l])&&(0===l?s=n.scrollStep:1==l?a=n.scrollStep:2==l?s=-n.scrollStep:3==l&&(a=-n.scrollStep));0===s&&0===a||(t.scroll({dx:s,dy:a}),this._scrolling=setTimeout((function(){i.startScroll(e)}),n.scrollRepeatTimeout))},Cc.prototype.stopScroll=function(){clearTimeout(this._scrolling)},Cc.prototype.setOptions=function(e){this._opts=j({},this._opts,e)},Cc.prototype._toBorderPoint=function(e){var t=this._canvas._container.getBoundingClientRect(),n=fs(e.originalEvent);return{x:n.x-t.left,y:n.y-t.top}};var Mc={__depends__:[Sc],__init__:["autoScroll"],autoScroll:["type",Cc]};function Tc(e){this._commandStack=e.get("commandStack",!1)}Tc.$inject=["injector"],Tc.prototype.allowed=function(e,t){var n=!0,i=this._commandStack;return i&&(n=i.canExecute(e,t)),void 0===n||n};var Rc={__init__:["rules"],rules:["type",Tc]},Dc=Math.round,Nc=Math.max;var Bc=10;function $c(e,t){return function(e,t){var n,i;for(n=0;i=e[n];n++)if(kt(i,t)<=Bc)return{point:e[n],bendpoint:!0,index:n};return null}(e,t)||function(e,t){var n,i,r=on(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,Bc),(n=[],e.forEach((function(e,t){n.push([0===t?"M":"L",e.x,e.y])})),n)),o=r[0],s=r[r.length-1];return o?o!==s?o.segment2!==s.segment2?{point:e[i=Nc(o.segment2,s.segment2)-1],bendpoint:!0,index:i}:{point:{x:Dc(o.x+s.x)/2,y:Dc(o.y+s.y)/2},index:o.segment2}:{point:{x:Dc(o.x),y:Dc(o.y)},index:o.segment2}:null}(e,t)}function jc(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}function Ic(e){return Math.atan((e[1].y-e[0].y)/(e[1].x-e[0].x))}function Lc(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 qc(e,t){var n=Lc(e,t);return jc({x:n.x-e.x,y:n.y-e.y})}function zc(e,t){return jc({x:e.x-t.x,y:e.y-t.y})}var Vc="djs-bendpoint",Fc="djs-segment-dragger";function Hc(e,t,n){var i=function(e,t){var n,i=fs(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 $c(t,i)}function Uc(e,t){var n=De("g");ke(n).add(Vc),xe(e,n);var i=De("circle");Oe(i,{cx:0,cy:0,r:4}),ke(i).add("djs-visual"),xe(n,i);var r=De("circle");return Oe(r,{cx:0,cy:0,r:10}),ke(r).add("djs-hit"),xe(n,r),t&&ke(n).add(t),n}function Wc(e,t,n,i){var r=De("g");xe(e,r);var o=function(e,t,n){var i=t.x-e.x,r=t.y-e.y;return Qc("h"===n?i:r)}(t,n,i),s=De("rect");Oe(s,{x:-9,y:-3,width:18,height:6}),ke(s).add("djs-visual"),xe(r,s);var a=De("rect");return Oe(a,{x:-o/2,y:-8.5,width:o,height:17}),ke(a).add("djs-hit"),xe(r,a),Yn(r,"v"===i?90:0),r}function Gc(e,t,n){var i=De("g"),r=Rt(t,n),o=At(t,n);return xe(e,i),Wc(i,t,n,o),ke(i).add(Fc),ke(i).add("h"===o?"horizontal":"vertical"),Kn(i,r.x,r.y),i}function Qc(e){return Math.abs(Math.round(2*e/3))}function Xc(e,t){var n=function(e,t){for(var n,i=t.waypoints,r=1/0,o=0;o<i.length-1;o++){var s=qc(e,[i[o],i[o+1]]);s<r&&(r=s,n=o)}return[i[n],i[n+1]]}(e,t);return Lc(e,n)}function Kc(e,t,n,i,r){function o(e,n){var o,s=n.waypoints,a=Hc(t,s,e);if(a)return o=function(e,t){var n,i,r=e.waypoints;return t.index<=0||t.bendpoint?null:(i=At((n={start:r[t.index-1],end:r[t.index]}).start,n.end))?Qc("h"===i?n.end.x-n.start.x:n.end.y-n.start.y)/2:null}(n,a),!function(e,t,n){var i,r,o,s,a,l,c=e.index,p=e.point;return!(c<=0||e.bendpoint)&&(o=Rt(i=t[c-1],r=t[c]),s=At(i,r),a=Math.abs(p.x-o.x),l=Math.abs(p.y-o.y),s&&a<=n&&l<=n)}(a,s,o)?i.start(e,n,a.index,!a.bendpoint):r.start(e,n,a.index),!0}function s(e,t,i){le.bind(e,t,(function(e){n.triggerMouseEvent(t,e,i),e.stopPropagation()}))}function a(e,n){var i=t.getLayer("overlays"),r=ye('.djs-bendpoints[data-element-id="'+Go(e.id)+'"]',i);return!r&&n&&(Oe(r=De("g"),{"data-element-id":e.id}),ke(r).add("djs-bendpoints"),xe(i,r),s(r,"mousedown",e),s(r,"click",e),s(r,"dblclick",e)),r}function l(e,t){return ye('.djs-segment-dragger[data-segment-idx="'+e+'"]',t)}function c(e,t){t.waypoints.forEach((function(t,n){var i=Uc(e);xe(e,i),Kn(i,t.x,t.y)})),Uc(e,"floating")}function p(e,t){for(var n,i,r,o=t.waypoints,a=1;a<o.length;a++)At(n=o[a-1],i=o[a])&&(Oe(r=Gc(e,n,i),{"data-segment-idx":a}),s(r,"mousemove",t))}function u(e){var t=a(e);return t||(c(t=a(e,!0),e),p(t,e)),t}function d(e){var t=a(e);t&&(!function(e){v(ve("."+Fc,e),(function(e){He(e)}))}(t),function(e){v(ve("."+Vc,e),(function(e){He(e)}))}(t),p(t,e),c(t,e))}function h(e,t,n){var i,r,o=l(t.index,e),s=n[t.index-1],a=n[t.index],c=t.point,p=Rt(s,a),u=At(s,a);o&&(i=function(e){return ye(".djs-visual",e)}(o),r={x:c.x-p.x,y:c.y-p.y},"v"===u&&(r={x:r.y,y:r.x}),Kn(i,r.x,r.y))}e.on("connection.changed",(function(e){d(e.element)})),e.on("connection.remove",(function(e){var t=a(e.element);t&&He(t)})),e.on("element.marker.update",(function(e){var t,n=e.element;n.waypoints&&(t=u(n),e.add?ke(t).add(e.marker):ke(t).remove(e.marker))})),e.on("element.mousemove",(function(e){var n,i,r=e.element,o=r.waypoints;if(o){if(n=a(r,!0),!(i=Hc(t,o,e.originalEvent)))return;!function(e,t){var n=ye(".floating",e),i=t.point;n&&Kn(n,i.x,i.y)}(n,i),i.bendpoint||h(n,i,o)}})),e.on("element.mousedown",(function(e){if(vs(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=a(t);i&&Oe(i,{"data-element-id":n})}})),this.addHandles=u,this.updateHandles=d,this.getBendpointsContainer=a,this.getSegmentDragger=l}Kc.$inject=["eventBus","canvas","interactionEvents","bendpointMove","connectionSegmentMove"];var Yc=Math.round,Zc="reconnectStart",Jc="reconnectEnd",ep="updateWaypoints";function tp(e,t,n,i,r,o){this._injector=e,this.start=function(e,t,o,s){var a,l=n.getGraphics(t),c=t.source,p=t.target,u=t.waypoints,d=(a=s||0!==o?s||o!==u.length-1?ep:Jc:Zc)===ep?"connection.updateWaypoints":"connection.reconnect",h=r.allowed(d,{connection:t,source:c,target:p});!1===h&&(h=r.allowed(d,{connection:t,source:p,target:c})),!1!==h&&i.init(e,"bendpoint.move",{data:{connection:t,connectionGfx:l,context:{allowed:h,bendpointIndex:o,connection:t,source:c,target:p,insert:s,type:a}}})},t.on("bendpoint.move.hover",(function(e){var t,n=e.context,i=n.connection,o=i.source,s=i.target,a=e.hover,l=n.type;if(n.hover=a,a){var c=l===ep?"connection.updateWaypoints":"connection.reconnect";if(t=n.allowed=r.allowed(c,{connection:i,source:l===Zc?a:o,target:l===Jc?a:s}))return n.source=l===Zc?a:o,void(n.target=l===Jc?a:s);!1===t&&(t=n.allowed=r.allowed(c,{connection:i,source:l===Jc?a:s,target:l===Zc?a:o})),t&&(n.source=l===Jc?a:s,n.target=l===Zc?a: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!==ep&&(t.allowed=!1)})),t.on("bendpoint.move.end",(function(e){var t=e.context,n=t.allowed,i=t.bendpointIndex,r=t.connection,s=t.insert,a=r.waypoints.slice(),l=t.source,c=t.target,p=t.type,u=t.hints||{},d={x:Yc(e.x),y:Yc(e.y)};if(!n)return!1;p===ep?(s?a.splice(i,0,d):a[i]=d,u.bendpointMove={insert:s,bendpointIndex:i},a=this.cropWaypoints(r,a),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===kt(t,i=e[r+1])||St(n,i,t)?e.splice(r,1):r++;return e}(a),u)):(p===Zc?(u.docking="source",np(t)&&(u.docking="target",u.newWaypoints=a.reverse())):p===Jc&&(u.docking="target",np(t)&&(u.docking="source",u.newWaypoints=a.reverse())),o.reconnect(r,l,c,d,u))}),this)}function np(e){var t=e.hover,n=e.source,i=e.target,r=e.type;return r===Zc?t&&i&&t===i&&n!==i:r===Jc?t&&n&&t===n&&n!==i:void 0}tp.$inject=["injector","eventBus","canvas","dragging","rules","modeling"],tp.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 ip="updateWaypoints",rp="connect-ok",op="connect-not-ok",sp="connect-hover",ap="djs-updating",lp="djs-dragging";function cp(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,s=r.waypoints,a=s.slice();t.waypoints=s,o&&a.splice(n,0,{x:e.x,y:e.y}),r.waypoints=a,ke(t.draggerGfx=Uc(i.getLayer("overlays"))).add("djs-dragging"),i.addMarker(r,lp),i.addMarker(r,ap)})),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,sp),o===ip)return;n?(i.removeMarker(r,op),i.addMarker(r,rp)):!1===n&&(i.removeMarker(r,rp),i.addMarker(r,op))}})),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,sp),i.removeMarker(n,r?rp:op))})),n.on("bendpoint.move.move",(function(t){var n=t.context,i=n.allowed,o=n.bendpointIndex,s=n.draggerGfx,a=n.hover,l=n.type,c=n.connection,p=c.source,u=c.target,d=c.waypoints.slice(),h={x:t.x,y:t.y},m=n.hints||{},f={};r&&(m.connectionStart&&(f.connectionStart=m.connectionStart),m.connectionEnd&&(f.connectionEnd=m.connectionEnd),"reconnectStart"===l?np(n)?(f.connectionEnd=f.connectionEnd||h,f.source=u,f.target=a||p,d=d.reverse()):(f.connectionStart=f.connectionStart||h,f.source=a||p,f.target=u):"reconnectEnd"===l?np(n)?(f.connectionStart=f.connectionStart||h,f.source=a||u,f.target=p,d=d.reverse()):(f.connectionEnd=f.connectionEnd||h,f.source=p,f.target=a||u):(f.noCropping=!0,f.noLayout=!0,d[o]=h),l===ip&&(d=e.cropWaypoints(c,d)),f.waypoints=d,r.drawPreview(n,i,f)),Kn(s,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,s=t.hover,a=t.target,l=t.waypoints;n.waypoints=l,He(o),i.removeMarker(n,ap),i.removeMarker(n,lp),s&&(i.removeMarker(s,rp),i.removeMarker(s,a?rp:op)),r&&r.cleanUp(t)}))}cp.$inject=["bendpointMove","injector","eventBus","canvas"];var pp="connect-hover",up="djs-updating";function dp(e,t,n){return hp(e,t,e[t]+n)}function hp(e,t,n){return{x:"x"===t?n:e.x,y:"y"===t?n:e.y}}function mp(e){return"x"===e?"y":"x"}function fp(e,t,n){var i,r;return e.original?e.original:(i=bn(t),hp(e,r=mp(n),i[r]))}function gp(e,t,n,i,r,o){var s=e.get("connectionDocking",!1);function a(e,t){if(!s)return t;var n,i=e.waypoints;return e.waypoints=t,n=s.getCroppedWaypoints(e),e.waypoints=i,n}function l(e){r.update("connection",e.connection,e.connectionGfx)}function c(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 hp(t,i,Math.min(Math.max(o+20,e[i]),r-20))}(n,i[e.segmentStartIndex+t],i[e.segmentEndIndex+t],mp(e.axis));Kn(e.draggerGfx,r.x,r.y)}this.start=function(e,t,r){var o,s,a,l,c=n.getGraphics(t),p=r-1,u=r,d=t.waypoints,h=d[p],m=d[u],f=Hc(n,d,e);(s=At(h,m))&&(a="v"===s?"x":"y",0===p&&(h=fp(h,t.source,a)),u===d.length-1&&(m=fp(m,t.target,a)),o={connection:t,segmentStartIndex:p,segmentEndIndex:u,segmentStart:h,segmentEnd:m,axis:a,dragPosition:l=f?f.point:{x:(h.x+m.x)/2,y:(h.y+m.y)/2}},i.init(e,l,"connectionSegment.move",{cursor:"x"===a?"resize-ew":"resize-ns",data:{connection:t,connectionGfx:c,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=Gc(r,t.segmentStart,t.segmentEnd),ke(t.draggerGfx).add("djs-dragging"),n.addMarker(i,up)})),t.on("connectionSegment.move.move",(function(e){var t,n,i=e.context,r=i.connection,o=i.segmentStartIndex,s=i.segmentEndIndex,p=i.segmentStart,u=i.segmentEnd,d=i.axis,h=i.originalWaypoints.slice(),m=dp(p,d,e["d"+d]),f=dp(u,d,e["d"+d]),g=h.length,y=0;h[o]=m,h[s]=f,o<2&&(t=xn(r.source,m),1===o?"intersect"===t&&(h.shift(),h[0]=m,y--):"intersect"!==t&&(h.unshift(p),y++)),s>g-3&&(n=xn(r.target,f),s===g-2?"intersect"===n&&(h.pop(),h[h.length-1]=f):"intersect"!==n&&h.push(u)),i.newWaypoints=r.waypoints=a(r,h),c(i,y,e),i.newSegmentStartIndex=o+y,l(e)})),t.on("connectionSegment.move.hover",(function(e){e.context.hover=e.hover,n.addMarker(e.hover,pp)})),t.on(["connectionSegment.move.out","connectionSegment.move.cleanup"],(function(e){var t=e.context.hover;t&&n.removeMarker(t,pp)})),t.on("connectionSegment.move.cleanup",(function(e){var t=e.context,i=t.connection;t.draggerGfx&&He(t.draggerGfx),n.removeMarker(i,up)})),t.on(["connectionSegment.move.cancel","connectionSegment.move.end"],(function(e){var t=e.context;t.connection.waypoints=t.originalWaypoints,l(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 s=function(e,t){var n=0,i=e.filter((function(i,r){return!St(e[r-1],e[r+1],i)||(n=r<=t?n-1:n,!1)}));return{waypoints:i,segmentOffset:n}}(i,r),l=a(n,s.waypoints),c=s.segmentOffset,p={segmentMove:{segmentStartIndex:t.segmentStartIndex,newSegmentStartIndex:r+c}};o.updateWaypoints(n,l,p)}))}gp.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];var yp=Math.abs,vp=Math.round;function bp(e){return{x:e.x,y:e.y}}function xp(e){return{x:e.x+e.width,y:e.y+e.height}}function wp(e,t){return!e||isNaN(e.x)||isNaN(e.y)?t:{x:vp(e.x+e.width/2),y:vp(e.y+e.height/2)}}function _p(e,t){var n=e.snapped;return!!n&&("string"==typeof t?n[t]:n.x&&n.y)}function Ep(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 Op(e){return e.children||[]}var Pp=Math.abs,kp=Math.round;function Sp(e){function t(e,t){if(c(e)){for(var n=e.length;n--;)if(Pp(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?Xc(t,e):e.width?{x:kp(e.width/2+e.x),y:kp(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,s=t.segmentStart,a=t.segmentStartIndex,l=t.segmentEnd,c=t.segmentEndIndex,p=t.axis;if(i)return i;var u=[o[a-1],s,l,o[c+1]];return a<2&&u.unshift(n(r.source,e)),c>o.length-3&&u.unshift(n(r.target,e)),t.snapPoints=i={horizontal:[],vertical:[]},v(u,(function(e){e&&(e=e.original||e,"y"===p&&i.horizontal.push(e.y),"x"===p&&i.vertical.push(e.x))})),i}(e),s=e.x,a=e.y;if(o){var l=s-(i=t(o.vertical,s)),c=a-(r=t(o.horizontal,a));j(e,{dx:e.dx-l,dy:e.dy-c,x:i,y:r}),(l||-1!==o.vertical.indexOf(s))&&Ep(e,"x",i),(c||-1!==o.horizontal.indexOf(a))&&Ep(e,"y",r)}})),e.on(["connect.hover","connect.move","connect.end"],1500,(function(e){var t=e.context.hover,i=t&&n(t,e);dn(t)&&i&&i.x&&i.y&&(Ep(e,"x",i.x),Ep(e,"y",i.y))})),e.on(["bendpoint.move.move","bendpoint.move.end"],1500,(function(e){var i,r,o=e.context,s=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),a=o.hover,l=a&&n(a,e),c=e.x,p=e.y;if(s){var u=c-(i=t(l?s.vertical.concat([l.x]):s.vertical,c)),d=p-(r=t(l?s.horizontal.concat([l.y]):s.horizontal,p));j(e,{dx:e.dx-u,dy:e.dy-d,x:e.x-u,y:e.y-d}),(u||-1!==s.vertical.indexOf(c))&&Ep(e,"x",i),(d||-1!==s.horizontal.indexOf(p))&&Ep(e,"y",r)}}))}Sp.$inject=["eventBus"];var Cp={__depends__:[Sc,Rc],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",Kc],bendpointMove:["type",tp],bendpointMovePreview:["type",cp],connectionSegmentMove:["type",gp],bendpointSnapping:["type",Sp]};function Ap(e,t,n,i){function r(e,t){return i.allowed("connection.create",{source:e,target:t})}e.on("connect.hover",(function(e){var t,n=e.context,i=n.start,o=e.hover;if(n.hover=o,!l(t=n.canExecute=r(i,o))){if(!1!==t)return n.source=i,void(n.target=o);l(t=n.canExecute=r(o,i))||!1!==t&&(n.source=o,n.target=i)}})),e.on(["connect.out","connect.cleanup"],(function(e){var t=e.context;t.hover=null,t.source=null,t.target=null,t.canExecute=!1})),e.on("connect.end",(function(e){var t=e.context,i=t.canExecute,r=t.connectionStart,o={x:e.x,y:e.y},s=t.source,a=t.target;if(!i)return!1;var l=null,c={connectionStart:Mp(t)?o:r,connectionEnd:Mp(t)?r:o};p(i)&&(l=i),t.connection=n.connect(s,a,l,c)})),this.start=function(e,n,i,r){p(i)||(r=i,i=bn(n)),t.init(e,"connect",{autoActivate:r,data:{shape:n,context:{start:n,connectionStart:i}}})}}function Mp(e){var t=e.hover,n=e.source,i=e.target;return t&&n&&t===n&&n!==i}Ap.$inject=["eventBus","dragging","modeling","rules"];var Tp="connect-ok",Rp="connect-not-ok";function Dp(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,s=t.start,a=t.startPosition,l=t.target,c=t.connectionStart||a,p=t.connectionEnd||{x:e.x,y:e.y},u=c,d=p;Mp(t)&&(u=p,d=c),i.drawPreview(t,n,{source:o||s,target:l||r,connectionStart:u,connectionEnd:d})})),t.on("connect.hover",900,(function(e){var t=e.context,i=e.hover,r=t.canExecute;null!==r&&n.addMarker(i,r?Tp:Rp)})),t.on(["connect.out","connect.cleanup"],1100,(function(e){var t=e.hover;t&&(n.removeMarker(t,Tp),n.removeMarker(t,Rp))})),i&&t.on("connect.cleanup",(function(e){i.cleanUp(e.context)}))}Dp.$inject=["injector","eventBus","canvas"];var Np={__depends__:[Ts,Rc,Sc],__init__:["connectPreview"],connect:["type",Ap],connectPreview:["type",Dp]};function Bp(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)}Bp.$inject=["injector","canvas","graphicsFactory","elementFactory"],Bp.prototype.drawPreview=function(e,t,n){n=n||{};var i,r=e.connectionPreviewGfx,o=e.getConnection,s=n.source,a=n.target,l=n.waypoints,c=n.connectionStart,p=n.connectionEnd,u=n.noLayout,d=n.noCropping,h=n.noNoop,m=this;r||(r=e.connectionPreviewGfx=this.createConnectionPreviewGfx()),Ce(r),o||(o=e.getConnection=function(e){var t={};return function(n){var i=JSON.stringify(n),r=t[i];return r||(r=t[i]=e.apply(null,arguments)),r}}((function(e,t,n){return m.getConnection(e,t,n)}))),t&&(i=o(t,s,a)),i?(i.waypoints=l||[],this._layouter&&!u&&(i.waypoints=this._layouter.layoutConnection(i,{source:s,target:a,connectionStart:c,connectionEnd:p,waypoints:n.waypoints||i.waypoints})),i.waypoints&&i.waypoints.length||(i.waypoints=[s?bn(s):c,a?bn(a):p]),this._connectionDocking&&(s||a)&&!d&&(i.waypoints=this._connectionDocking.getCroppedWaypoints(i,s,a)),this._graphicsFactory.drawConnection(r,i,{stroke:"var(--element-dragger-color)"})):!h&&this.drawNoopPreview(r,n)},Bp.prototype.drawNoopPreview=function(e,t){var n=t.source,i=t.target,r=t.connectionStart||bn(n),o=t.connectionEnd||bn(i),s=this.cropWaypoints(r,o,n,i);xe(e,this.createNoopConnection(s[0],s[1]))},Bp.prototype.cropWaypoints=function(e,t,n,i){var r=this._graphicsFactory,o=n&&r.getShapePath(n),s=i&&r.getShapePath(i),a=r.getConnectionPath({waypoints:[e,t]});return[e=n&&wn(o,a,!0)||e,t=i&&wn(s,a,!1)||t]},Bp.prototype.cleanUp=function(e){e&&e.connectionPreviewGfx&&He(e.connectionPreviewGfx)},Bp.prototype.getConnection=function(e){var t=function(e){return p(e)?e:{}}(e);return this._elementFactory.createConnection(t)},Bp.prototype.createConnectionPreviewGfx=function(){var e=De("g");return Oe(e,{pointerEvents:"none"}),ke(e).add("djs-dragger"),xe(this._canvas.getActiveLayer(),e),e},Bp.prototype.createNoopConnection=function(e,t){return pt([e,t],{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"})};var $p={__init__:["connectionPreview"],connectionPreview:["type",Bp]};const jp=new No("ps");var Ip=["marker-start","marker-mid","marker-end"],Lp=["circle","ellipse","line","path","polygon","polyline","path","rect"];function qp(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._styles=i}qp.$inject=["elementRegistry","eventBus","canvas","styles"],qp.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")},qp.prototype.getGfx=function(e){return this._elementRegistry.getGraphics(e)},qp.prototype.addDragger=function(e,t,n,i="djs-dragger"){var r=Ae(n=n||this.getGfx(e)),o=n.getBoundingClientRect();return this._cloneMarkers(Qn(r),i),Oe(r,this._styles.cls(i,[],{x:o.top,y:o.left})),xe(t,r),Oe(r,"data-preview-support-element-id",e.id),r},qp.prototype.addFrame=function(e,t){var n=De("rect",{class:"djs-resize-overlay",width:e.width,height:e.height,x:e.x,y:e.y});return xe(t,n),Oe(n,"data-preview-support-element-id",e.id),n},qp.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!==Lp.indexOf(e.nodeName)}(e)&&Ip.forEach((function(r){if(Oe(e,r)){var o=function(e,t,n){var i=(r=Oe(e,t),r.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]);var r;return ye("marker#"+i,n||document)}(e,r,i._canvas.getContainer());o&&i._cloneMarker(n,e,o,r,t)}}))},qp.prototype._cloneMarker=function(e,t,n,i,r="djs-dragger"){var o=[n.id,r,jp.next()].join("-"),s=ye("marker#"+n.id,e);e=e||this._canvas._svg;var a=s||Ae(n);a.id=o,ke(a).add(r);var l=ye(":scope > defs",e);l||xe(e,l=De("defs")),xe(l,a);var c=function(e){return"url(#"+e+")"}(a.id);Oe(t,i,c)};var zp={__init__:["previewSupport"],previewSupport:["type",qp]};const Vp="complex-preview";class Fp{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(Vp);t.filter((e=>!function(e){return e.hidden}(e))).forEach((e=>{let t;dn(e)?(t=this._graphicsFactory._createContainer("connection",De("g")),this._graphicsFactory.drawConnection(Qn(t),e)):(t=this._graphicsFactory._createContainer("shape",De("g")),this._graphicsFactory.drawShape(Qn(t),e),Kn(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);dn(e)?Kn(n,t.x,t.y):Kn(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",De("g"));this._graphicsFactory.drawShape(Qn(n),e,{width:t.width,height:t.height}),Kn(n,t.x,t.y),this._previewSupport.addDragger(e,o,n)}))}cleanUp(){Ce(this._canvas.getLayer(Vp)),this._markers.forEach((([e,t])=>this._canvas.removeMarker(e,t))),this._markers=[]}show(){this._canvas.showLayer(Vp)}hide(){this._canvas.hideLayer(Vp)}}Fp.$inject=["canvas","graphicsFactory","previewSupport"];var Hp={__depends__:[zp],__init__:["complexPreview"],complexPreview:["type",Fp]},Up=["top","bottom","left","right"],Wp=10;function Gp(e,t){function n(e){if(Kr(e)&&!dn(e)){var n=function(e){var t=bn(e.label),n=bn(e),i=Qp(n,t);if(r=i,-1===Up.indexOf(r))return;var r;var o=function(e){var t=bn(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 Qp(t,e)}));return n}(e);if(e.host){var s=function(e){var t,n=e.host,i=bn(e),r=xn(i,n);t=r.indexOf("-")>=0?r.split("-"):[r];var o=Up.filter((function(e){return-1===t.indexOf(e)}));return o}(e);o=o.concat(s)}var a=Up.filter((function(e){return-1===o.indexOf(e)}));if(-1!==a.indexOf(i))return;return a[0]}(e);n&&function(e,n){var i=bn(e),r=e.label,o=bn(r);if(!r.parent)return;var s,a=gn(e);switch(n){case"top":s={x:i.x,y:a.top-Wp-r.height/2};break;case"left":s={x:a.left-Wp-r.width/2,y:i.y};break;case"bottom":s={x:i.x,y:a.bottom+Wp+r.height/2};break;case"right":s={x:a.right+Wp+r.width/2,y:i.y}}var l=ia(s,o);t.moveShape(r,l)}(e,n)}}Fo.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 Qp(e,t){return xn(t,e,5)}function Xp(e){Fo.call(this,e),this.preExecute("shape.append",(function(e){var t=e.source,n=e.shape;e.position||(_r(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 Kp(e,t){e.invoke(Fo,this),this.postExecute("shape.move",(function(e){var n=e.newParent,i=e.shape;v(y(i.incoming.concat(i.outgoing),(function(e){return _r(e,"bpmn:Association")})),(function(e){t.moveConnection(e,{x:0,y:0},n)}))}),!0)}e(Gp,Fo),Gp.$inject=["eventBus","modeling"],e(Xp,Fo),Xp.$inject=["eventBus"],e(Kp,Fo),Kp.$inject=["injector","modeling"];function Yp(e,t){t.invoke(Fo,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 Zp(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];Zp(r,i)&&(e.shapes=[n._replaceShape(r,i)])}}),!0)}function Zp(e,t){return!hn(e)&&Er(e,["bpmn:IntermediateThrowEvent","bpmn:IntermediateCatchEvent"])&&!!t}function Jp(e,t){function n(e){return y(e.attachers,(function(e){return _r(e,"bpmn:BoundaryEvent")}))}Fo.call(this,e),this.postExecute("connection.create",(function(e){var i=e.context.source,r=e.context.target,o=n(r);_r(i,"bpmn:EventBasedGateway")&&_r(r,"bpmn:ReceiveTask")&&o.length>0&&t.removeElements(o)})),this.postExecute("connection.reconnect",(function(e){var i=e.context.oldSource,r=e.context.newSource;_r(i,"bpmn:Gateway")&&_r(r,"bpmn:EventBasedGateway")&&v(r.outgoing,(function(e){var i=e.target,r=n(i);_r(i,"bpmn:ReceiveTask")&&r.length>0&&t.removeElements(r)}))}))}function eu(e,t,n){function i(e){t.updateProperties(e,{isForCompensation:!0})}function r(e){t.updateProperties(e,{isForCompensation:void 0})}Fo.call(this,e),this.preExecute("shape.replace",(function(e){const{newData:n,oldShape:i}=e;if(nu(e.oldShape)&&"bpmn:CompensateEventDefinition"!==n.eventDefinitionType||"bpmn:BoundaryEvent"!==n.type){const t=i.outgoing.find((({target:e})=>tu(e)));t&&t.target&&(e._connectionTarget=t.target)}else if(!nu(e.oldShape)&&"bpmn:CompensateEventDefinition"===n.eventDefinitionType&&"bpmn:BoundaryEvent"===n.type){const n=i.outgoing.find((({target:e})=>iu(e)));n&&n.target&&(e._connectionTarget=n.target),function(e){const n=e.outgoing.filter((e=>_r(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;nu(r)&&iu(o)&&(i(o),function(e,n){const i=e.outgoing.filter((e=>_r(e,"bpmn:Association"))),r=i.filter((e=>tu(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;nu(t)&&tu(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;tu(o)&&r(o),nu(e)&&iu(t)&&i(t)}}),!0),this.postExecuted("element.updateProperties",(function(e){const{element:i}=e;tu(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)):iu(i)&&function(e){const n=e.incoming.filter((e=>nu(e.source)));t.removeElements(n)}(i)}),!0)}function tu(e){const t=Or(e);return t&&t.get("isForCompensation")}function nu(e){return e&&_r(e,"bpmn:BoundaryEvent")&&Wr(e,"bpmn:CompensateEventDefinition")}function iu(e){return e&&_r(e,"bpmn:Activity")&&!Ur(e)}function ru(e){e.invoke(Fo,this),this.preExecute("shape.create",1500,(function(e){var t=e.context,n=t.parent,i=t.shape;_r(n,"bpmn:Lane")&&!_r(i,"bpmn:Lane")&&(t.parent=pc(n,"bpmn:Participant"))}))}function ou(e,t){Fo.call(this,e),this.preExecute("shape.create",(function(e){var n=e.context.shape;if(_r(n,"bpmn:DataObjectReference")&&"label"!==n.type){var i=t.create("bpmn:DataObject");n.businessObject.dataObjectRef=i}}))}Yp.$inject=["bpmnReplace","injector"],e(Yp,Fo),Yp.prototype._replaceShape=function(e,t){var n,i=(n=Or(e).eventDefinitions)&&n[0],r={type:"bpmn:BoundaryEvent",host:t};return i&&(r.eventDefinitionType=i.$type),this._bpmnReplace.replaceElement(e,r,{layoutConnection:!1})},Jp.$inject=["eventBus","modeling"],e(Jp,Fo),e(eu,Fo),eu.$inject=["eventBus","modeling","bpmnRules"],ru.$inject=["injector"],e(ru,Fo),ou.$inject=["eventBus","bpmnFactory"],e(ou,Fo);var su=20,au=20,lu=30,cu=2e3;function pu(e,t,n){function i(){var t=e.getRootElement();return _r(t,"bpmn:Collaboration")?t:n.makeCollaboration()}Fo.call(this,t),t.on(["create.start","shape.move.start"],cu,(function(t){var n=t.context,i=n.shape,r=e.getRootElement();if(_r(i,"bpmn:Participant")&&_r(r,"bpmn:Process")&&r.children.length){var o=r.children.filter((function(e){return!_r(e,"bpmn:Group")&&!hn(e)&&!dn(e)}));if(o.length){var s=yt(o),a=function(e,t){t={width:t.width+2*su+lu,height:t.height+2*au};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,s);j(i,a),n.createConstraints=function(e,t){return t=gn(t),{bottom:t.top+e.height/2-au,left:t.right-e.width/2+su,top:t.bottom-e.height/2+au,right:t.left+e.width/2-su-lu}}(i,s)}}})),t.on("create.start",cu,(function(n){var i=n.context.shape,r=e.getRootElement(),o=e.getGraphics(r);function s(e){e.element=r,e.gfx=o}_r(i,"bpmn:Participant")&&_r(r,"bpmn:Process")&&(t.on("element.hover",cu,s),t.once("create.cleanup",(function(){t.off("element.hover",s)})))})),this.preExecute("elements.create",cu,(function(e){var t,n=e.elements,r=e.parent,o=function(e){return f(e,(function(e){return _r(e,"bpmn:Participant")}))}(n);o&&_r(r,"bpmn:Process")&&(e.parent=i(),(t=e.hints=e.hints||{}).participant=o,t.process=r,t.processRef=Or(o).get("processRef"))}),!0),this.preExecute("shape.create",(function(e){var t=e.parent,n=e.shape;_r(n,"bpmn:Participant")&&_r(t,"bpmn:Process")&&(e.parent=i(),e.process=t,e.processRef=Or(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||Or(i).set("processRef",Or(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||Or(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 s=i.children.slice();o?r===o&&n.moveElements(s,{x:0,y:0},o):n.moveElements(s,{x:0,y:0},r)}}),!0)}pu.$inject=["canvas","eventBus","modeling"],e(pu,Fo);var uu="__targetRef_placeholder";function du(e,t){function n(e,n){var i=e.get("properties"),r=f(i,(function(e){return e.name===uu}));return!r&&n&&Ot(i,r=t.create("bpmn:Property",{name:uu})),r}function i(e,t){var i=n(e);i&&(function(e,t,n){return f(e.get("dataInputAssociations"),(function(e){return e!==n&&e.targetRef===t}))}(e,i,t)||Et(e.get("properties"),i))}function r(e){var t,r=e.context,o=r.connection,s=o.businessObject,a=o.target,l=a&&a.businessObject,c=r.newTarget,p=c&&c.businessObject,u=r.oldTarget||r.target,d=u&&u.businessObject,h=o.businessObject;d&&d!==l&&i(d,s),p&&p!==l&&i(p,s),l?(t=n(l,!0),h.targetRef=t):h.targetRef=null}Fo.call(this,e),this.executed(["connection.create","connection.delete","connection.move","connection.reconnect"],hu(r)),this.reverted(["connection.create","connection.delete","connection.move","connection.reconnect"],hu(r))}function hu(e){return function(t){if(_r(t.context.connection,"bpmn:DataInputAssociation"))return e(t)}}function mu(e){this._bpmnUpdater=e}function fu(e,t,n,i){function r(e){return e.children.filter((function(e){return _r(e,"bpmn:DataStoreReference")&&!e.labelTarget}))}function o(e,i){var r=e.businessObject||e;if(i=i||n.filter((function(e){return _r(e,"bpmn:Participant")&&Or(e).processRef}))[0]){var o=i.businessObject||i;t.execute("dataStore.updateContainment",{dataStoreBo:r,dataStoreDi:Pr(e),newSemanticParent:o.processRef||o,newDiParent:Pr(i)})}}Fo.call(this,i),t.registerHandler("dataStore.updateContainment",mu),this.preExecute("shape.create",(function(e){var t=e.context,n=t.shape;_r(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 _r(e,"bpmn:DataStoreReference")})).length&&(t.hints||(t.hints={}),t.hints.autoResize=n.filter((function(e){return!_r(e,"bpmn:DataStoreReference")})))})),this.postExecute("shape.create",(function(e){var t=e.context.shape,n=t.parent;_r(t,"bpmn:DataStoreReference")&&"label"!==t.type&&_r(n,"bpmn:Collaboration")&&o(t)})),this.postExecute("shape.move",(function(e){var t=e.context,n=t.shape,i=t.oldParent,r=n.parent;_r(i,"bpmn:Collaboration")||_r(n,"bpmn:DataStoreReference")&&"label"!==n.type&&_r(r,"bpmn:Collaboration")&&o(n,_r(i,"bpmn:Participant")?i:function(e,t){for(;e.parent;){if(_r(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();Er(n,["bpmn:Participant","bpmn:SubProcess"])&&_r(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){_r(i,"bpmn:Process")&&o(e,i)}))}))}du.$inject=["eventBus","bpmnFactory"],e(du,Fo),mu.$inject=["bpmnUpdater"],mu.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),[]},mu.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),[]},fu.$inject=["canvas","commandStack","elementRegistry","eventBus"],e(fu,Fo);var gu=Math.max,yu=Math.min,vu=20;function bu(e,t){return{top:e.top-t.top,right:e.right-t.right,bottom:e.bottom-t.bottom,left:e.left-t.left}}function xu(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)?yu:gu)(i,r)),u(o)&&(i=(/top|left/.test(e)?gu:yu)(i,o)),i}function wu(e,t){return void 0!==e?e:vu}function _u(e){return!e.waypoints&&"label"!==e.type}function Eu(e,t){var n;if((n=void 0===e.length?y(e.children,_u):e).length)return function(e,t){var n,i,r,o;return"object"==typeof t?(n=wu(t.left),i=wu(t.right),r=wu(t.top),o=wu(t.bottom)):n=i=r=o=wu(t),{x:e.x-n,y:e.y-r,width:e.width+n+i,height:e.height+r+o}}(yt(n),t)}var Ou=Math.abs;var Pu=["bpmn:Participant","bpmn:Process","bpmn:SubProcess"],ku=30;function Su(e,t){return t=t||[],e.children.filter((function(e){_r(e,"bpmn:Lane")&&(Su(e,t),t.push(e))})),t}function Cu(e){return e.children.filter((function(e){return _r(e,"bpmn:Lane")}))}function Au(e){return pc(e,Pu)||e}function Mu(e,t){var n=Au(e),i=Su(n,_r(n,"bpmn:Process")?[]:[n]),r=gn(e),o=gn(t),s=function(e,t){return bu(gn(t),gn(e))}(e,t),a=[],l=Fr(e);return i.forEach((function(t){if(t!==e){var n,i,c=l?0:s.top,p=l?s.right:0,u=l?0:s.bottom,d=l?s.left:0,h=gn(t);s.top&&(Ou(h.bottom-r.top)<10&&(u=o.top-h.bottom),Ou(h.top-r.top)<5&&(c=o.top-h.top)),s.left&&(Ou(h.right-r.left)<10&&(p=o.left-h.right),Ou(h.left-r.left)<5&&(d=o.left-h.left)),s.bottom&&(Ou(h.top-r.bottom)<10&&(c=o.bottom-h.top),Ou(h.bottom-r.bottom)<5&&(u=o.bottom-h.bottom)),s.right&&(Ou(h.left-r.right)<10&&(d=o.right-h.left),Ou(h.right-r.right)<5&&(p=o.right-h.right)),(c||p||u||d)&&a.push({shape:t,newBounds:(n=t,i={top:c,right:p,bottom:u,left:d},{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)})})}})),a}function Tu(e,t){Fo.call(this,e),this.postExecuted("shape.delete",500,(function(e){var n=e.context,i=n.hints,r=n.shape,o=n.oldParent;_r(r,"bpmn:Lane")&&(i&&i.nested||function(e,n){var i,r,o,s,a,l=Fr(e),c=Cu(n),p=[],u=[],d=[],h=[];ft(c,(function(t){return l?t.y>e.y?u.push(t):p.push(t):t.x>e.x?h.push(t):d.push(t),t.children})),c.length&&(i=l?u.length&&p.length?e.height/2:e.height:h.length&&d.length?e.width/2:e.width,p.length&&(r=t.calculateAdjustments(p,"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")),d.length&&(s=t.calculateAdjustments(d,"x",i,e.x-10),t.makeSpace(s.movingShapes,s.resizingShapes,{x:i,y:0},"e")),h.length&&(a=t.calculateAdjustments(h,"x",-i,e.x+e.width+10),t.makeSpace(a.movingShapes,a.resizingShapes,{x:-i,y:0},"w")))}(r,o))}))}Tu.$inject=["eventBus","spaceTool"],e(Tu,Fo);function Ru(e,t){t.invoke(Fo,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",500,(function(e){var t=e.elements;t.filter((function(e){return Du(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,s=e.host;Du(e,(o=s,-1!==t.indexOf(o)?s:i))&&(t[r]=n._replaceShape(e))}))}),!0)}function Du(e,t){return!hn(e)&&_r(e,"bpmn:BoundaryEvent")&&!t}function Nu(e,t,n){function i(e,i,r){var o,s,a,l,c,p,d,h,m=i.waypoints,f=e.outgoing.slice(),g=e.incoming.slice(),v=$c(m,h=u(r.width)?bn(r):r);if(v){if(o=m.slice(0,v.index),s=m.slice(v.index+(v.bendpoint?1:0)),!o.length||!s.length)return;a=v.bendpoint?m[v.index]:h,1!==o.length&&Bu(e,o[o.length-1])||o.push($u(a)),1!==s.length&&Bu(e,s[0])||s.unshift($u(a))}l=i.source,c=i.target,t.canConnect(l,e,i)&&(n.reconnectEnd(i,e,o||h),p=i),t.canConnect(e,c,i)&&(p?d=n.connect(e,c,{type:i.type,waypoints:s}):(n.reconnectStart(i,e,s||h),d=i));var b=[].concat(p&&y(g,(function(e){return e.source===p.source}))||[],d&&y(f,(function(e){return e.target===d.target}))||[]);b.length&&n.removeElements(b)}Fo.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 s=bn(o),a={x:s.x+r.x,y:s.y+r.y},l=f(n.children,(function(e){return t.canInsert(i,e)&&$c(e.waypoints,a)}));l&&(e.targetFlow=l,e.position=a)}}),!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 $u(e){return j({},e)}function ju(e,t){Fo.call(this,e),this.preExecuted("connection.create",(function(e){var n=e.context,i=n.connection,r=n.source,o=n.target,s=n.hints;if((!s||!1!==s.createElementsBehavior)&&Iu(i)){(_r(r,"bpmn:EventBasedGateway")?o.incoming.filter((e=>e!==i&&Iu(e))):o.incoming.filter((e=>e!==i&&Iu(e)&&_r(e.source,"bpmn:EventBasedGateway")))).forEach((function(e){t.removeConnection(e)}))}})),this.preExecuted("shape.replace",(function(e){var n=e.context.newShape;_r(n,"bpmn:EventBasedGateway")&&n.outgoing.filter(Iu).reduce((function(e,t){return e.includes(t.target)?e:e.concat(t.target)}),[]).forEach((function(e){e.incoming.filter(Iu).forEach((function(i){const r=e.incoming.filter(Iu).filter((function(e){return e.source===n}));(i.source!==n||r.length>1)&&t.removeConnection(i)}))}))}))}function Iu(e){return _r(e,"bpmn:SequenceFlow")}Ru.$inject=["bpmnReplace","injector"],e(Ru,Fo),Ru.prototype._replaceShape=function(e){var t,n,i=(n=Or(e).eventDefinitions)&&n[0];return t=i?{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:i.$type}:{type:"bpmn:IntermediateThrowEvent"},this._bpmnReplace.replaceElement(e,t,{layoutConnection:!1})},e(Nu,Fo),Nu.$inject=["eventBus","bpmnRules","modeling"],ju.$inject=["eventBus","modeling"],e(ju,Fo);var Lu=1500;function qu(e,t,n){t.on(["create.hover","create.move","create.out","create.end","shape.move.hover","shape.move.move","shape.move.out","shape.move.end"],Lu,(function(t){var i=t.context.shape||t.shape,r=t.hover;_r(r,"bpmn:Lane")&&!Er(i,["bpmn:Lane","bpmn:Participant"])&&(t.hover=Au(r),t.hoverGfx=e.getGraphics(t.hover));var o=n.getRootElement();r!==o&&(i.labelTarget||Er(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"],Lu,(function(t){var n=t.hover;_r(n,"bpmn:Lane")&&(t.hover=Au(n)||n,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["bendpoint.move.hover"],Lu,(function(t){var n=t.context,i=t.hover,r=n.type;_r(i,"bpmn:Lane")&&/reconnect/.test(r)&&(t.hover=Au(i)||i,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["connect.start"],Lu,(function(e){var t=e.context,n=t.start;_r(n,"bpmn:Lane")&&(t.start=Au(n)||n)})),t.on("shape.move.start",2e3,(function(e){var t=e.shape;_r(t,"bpmn:Lane")&&(e.shape=Au(t)||t)})),t.on("spaceTool.move",2e3,(function(e){var t=e.hover;t&&_r(t,"bpmn:Lane")&&(e.hover=Au(t))}))}qu.$inject=["elementRegistry","eventBus","canvas"];function zu(e,t,n,i,r,o){function s(e,t,i){var r=n.filter((function(e){return _r(e,"bpmn:Group")})).filter((function(e){return e.businessObject!==i}));t&&!function(e,t){return e.some((function(e){var n=Or(e);return(n.categoryValueRef&&n.categoryValueRef.$parent)===t}))}(r,t)&&function(e){var t=e.$parent;t&&(Et(t.get("rootElements"),e),e.$parent=null)}(t),e&&!function(e,t){return e.some((function(e){return Or(e).categoryValueRef===t}))}(r,e)&&function(e){var t=e.$parent;t&&(Et(t.get("categoryValue"),e),e.$parent=null)}(e)}function a(e,n){return function(e,t,n){return Ot(t.get("categoryValue"),e),e.$parent=t,Ot(n.get("rootElements"),t),t.$parent=n,e}(e,n,t.getDefinitions())}function l(n,i){var r=Or(n),o=r.categoryValueRef;o||(o=r.categoryValueRef=i.categoryValue=i.categoryValue||function(e){return e.create("bpmn:CategoryValue")}(e));var s=o.$parent;s||(s=o.$parent=i.category=i.category||function(e){return e.create("bpmn:Category")}(e)),a(o,s,t.getDefinitions())}function c(e,t){var n=t.category,i=t.categoryValue,r=Or(e);i?(r.categoryValueRef=null,s(i,n,r)):s(null,r.categoryValueRef.$parent,r)}function p(t,n){var i=e.create(t.$type);return o.copyElement(t,i,null,n)}r.invoke(Fo,this),this.execute("label.create",(function(e){var t=e.context,n=t.labelTarget;_r(n,"bpmn:Group")&&l(n,t)})),this.revert("label.create",(function(e){var t=e.context,n=t.labelTarget;_r(n,"bpmn:Group")&&c(n,t)})),this.execute("shape.delete",(function(e){var t=e.context,n=t.shape,i=Or(n);if(_r(n,"bpmn:Group")&&!n.labelTarget){var r=t.categoryValue=i.categoryValueRef;r&&(s(r,t.category=r.$parent,i),i.categoryValueRef=null)}})),this.reverted("shape.delete",(function(e){var t=e.context,n=t.shape;if(_r(n,"bpmn:Group")&&!n.labelTarget){var i=t.category,r=t.categoryValue,o=Or(n);r&&(o.categoryValueRef=r,a(r,i))}})),this.execute("shape.create",(function(e){var t=e.context,n=t.shape;_r(n,"bpmn:Group")&&!n.labelTarget&&Or(n).categoryValueRef&&l(n,t)})),this.reverted("shape.create",(function(e){var t=e.context,n=t.shape;_r(n,"bpmn:Group")&&!n.labelTarget&&Or(n).categoryValueRef&&c(n,t)})),i.on("copyPaste.copyElement",770,(function(e){var t=e.descriptor,n=e.element;if(_r(n,"bpmn:Group")&&!n.labelTarget){var i=Or(n);if(i.categoryValueRef){var r=i.categoryValueRef;t.categoryValue=p(r,!0),r.$parent&&(t.category=p(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=p(i)),r&&(i.$parent=p(r)),delete t.category,delete t.categoryValue}))}function Vu(e,t,n,i){var r,o,s,a;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,s=e.x-n.x,a=((i.x-n.x)*o-(i.y-n.y)*s)/r,{x:Math.round(e.x+a*(t.x-e.x)),y:Math.round(e.y+a*(t.y-e.y))})}function Fu(e){function t(e,t,n){var i,r={x:n.x,y:n.y-50},o={x:n.x-50,y:n.y},s=Vu(e,t,n,r),a=Vu(e,t,n,o);i=s&&a?Hu(s,n)>Hu(a,n)?a:s:s||a,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],bn(n.source)),t(i[i.length-1],i[i.length-2],bn(n.target)))}))}function Hu(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Uu(e){Fo.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=Or(n),r=Pr(n);if(Er(i,t)){var o=r.get("isHorizontal");void 0===o&&(o=!0),r.set("isHorizontal",o)}}))}zu.$inject=["bpmnFactory","bpmnjs","elementRegistry","eventBus","injector","moddleCopy"],e(zu,Fo),Fu.$inject=["eventBus"],Uu.$inject=["eventBus"],e(Uu,Fo);var Wu=Math.sqrt,Gu=Math.min,Qu=Math.max,Xu=Math.abs;function Ku(e){return Math.pow(e,2)}function Yu(e,t){return Wu(Ku(e.x-t.x)+Ku(e.y-t.y))}function Zu(e,t,n,i){var r=t.x-e.x,o=t.y-e.y,s=n.x-e.x,a=n.y-e.y,l=r*r+o*o,c=(r*s+o*a)/l,p=c*c-(s*s+a*a-i*i)/l;if(p<0&&p>-1e-6&&(p=0),p<0)return[];var u=Wu(p),d=-c+u,h=-c-u,m={x:e.x-r*d,y:e.y-o*d};return 0===p?[m]:[m,{x:e.x-r*h,y:e.y-o*h}].filter((function(n){return function(e,t,n){return Ju(e.x,t.x,n.x)&&Ju(e.y,t.y,n.y)}(n,e,t)}))}function Ju(e,t,n){return e>=Gu(t,n)-ed&&e<=Qu(t,n)+ed}var ed=.1;function td(e,t){return Xu(e.x-t.x)<=ed&&Xu(e.y-t.y)<=ed}function nd(e,t,n,i){var r=0,o=0,s={point:e,delta:{x:0,y:0}},a=function(e,t){var n,i,r,o,s,a,l,c,p,u,d,h,m=0;for(m=0;m<t.length-1;m++){if(td(n=t[m],i=t[m+1])?a=[n]:(r=Yu(e,n),o=Yu(e,i),a=Zu(n,i,e,Gu(r,o))),a.length<1)throw new Error("expected between [1, 2] circle -> line intersections");1===a.length&&(l={type:"bendpoint",position:a[0],segmentIndex:m,bendpointIndex:td(n,a[0])?m:m+1}),2===a.length&&(d=a[0],h=a[1],l={type:"segment",position:s={x:(d.x+h.x)/2,y:(d.y+h.y)/2},segmentIndex:m,relativeLocation:Yu(n,s)/Yu(n,i)}),c=Yu(l.position,e),(!u||p>c)&&(u=l,p=c)}return u}(e,n),l=a.segmentIndex,c=function(e,t,n,i){var r=n.segmentIndex,o=t.length-e.length;if(i.segmentMove){var s=i.segmentMove.segmentStartIndex,a=i.segmentMove.newSegmentStartIndex;return r===s?a:r>=a?r+o<a?a:r+o:r}if(i.bendpointMove){var l,c=i.bendpointMove.insert,p=i.bendpointMove.bendpointIndex;return 0===o?r:(r>=p&&(l=c?r+1:r-1),r<p&&(l=r,c&&"bendpoint"!==n.type&&p-1===r&&id(t,p)<n.relativeLocation&&l++),l)}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,a,i);if(c<0||c>t.length-2||null===c)return s;var p,u,d=rd(n,l),h=rd(t,c),m=a.position,f=function(e,t){var n=zc(e[0],e[1]),i=zc(e[0],t);return 0===n?0:i/n}(d,m),g=(p=h,u=Ic(d),Ic(p)-u);if("bendpoint"===a.type){var y=t.length-n.length,v=a.bendpointIndex,b=n[v];if(-1!==t.indexOf(b))return s;if(0===y){var x=t[v];return{delta:{x:r=x.x-a.position.x,y:o=x.y-a.position.y},point:{x:e.x+r,y:e.y+o}}}y<0&&0!==v&&v<n.length-1&&(f=id(n,v))}var w,_,E={x:(h[1].x-h[0].x)*f+h[0].x,y:(h[1].y-h[0].y)*f+h[0].y},O=(w={x:e.x-m.x,y:e.y-m.y},(_=g)?{x:Math.cos(_)*w.x-Math.sin(_)*w.y,y:Math.sin(_)*w.x+Math.cos(_)*w.y}:w);return r=E.x+O.x-e.x,o=E.y+O.y-e.y,{point:fn(E),delta:fn({x:r,y:o})}}function id(e,t){var n=zc(e[t-1],e[t]);return n/(n+zc(e[t],e[t+1]))}function rd(e,t){return[e[t],e[t+1]]}function od(e,t,n){var i=na(t),r=na(n),o=ia(e,i),s=o.x*(n.width/t.width),a=o.y*(n.height/t.height);return fn({x:r.x+s,y:r.y+a})}function sd(e,t,n){var i=na(e),r=na(t),o=na(n),s=ia(e,i),a=ia(i,r),l=function(e,t,n){var i=gn(t),r=gn(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,s,a,l=xn(t,e);if("top"===l)o={x:0,y:r.bottom-i.bottom};else if("bottom"===l)o={x:0,y:r.top-i.top};else if("right"===l)o={x:r.left-i.left,y:0};else{if("left"!==l)return null;o={x:r.right-i.right,y:0}}if(s={x:e.x+o.x,y:e.y+o.y},a=xn(n,s),a!==l)return null;return o}(i,t,n);if(l)return l;var c=a.x*(n.width/t.width),p=a.y*(n.height/t.height),u=o.x+c,d=o.y+p;return fn({x:u+s.x-e.x,y:d+s.y-e.y})}var ad="name",ld="text";function cd(e,t,n,i){function r(e){var n=e.context,r=n.element,o=n.properties;if(ad in o&&t.updateLabel(r,o[ad]),ld in o&&_r(r,"bpmn:TextAnnotation")){var s=i.getTextAnnotationBounds({x:r.x,y:r.y,width:r.width,height:r.height},o[ld]||"");t.updateLabel(r,o.text,s)}}function o(e){var t=e.context,n=t.connection,i=n.label,r=j({},t.hints),o=t.newWaypoints||n.waypoints,s=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 nd(bn(e),t,n,i).delta}(i,o,s,r)}Fo.call(this,e),this.postExecute("element.updateProperties",r),this.postExecute("element.updateModdleProperties",(e=>{Or(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;!hn(i)&&Xr(i)&&eo(i)&&t.updateLabel(i,eo(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=Or(n);r&&Xr(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,s=i.oldBounds;if(Kr(r)){var a=r.label,l=function(e,t){if(!t.length)return;var n=function(e,t){var n=t.map((function(t){return{line:t,distance:qc(e,t)}}));return A(n,"distance")[0].line}(e,t);return Lc(e,n)}(bn(a),[[{x:(n=s).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)}]]),c=pd(l,s,o);t.moveShape(a,c)}}))}function pd(e,t,n){return fn(ia(od(e,t,n),e))}function ud(e,t){function n(e,t){var n=e.context,i=n.connection,r=j({},n.hints),o=n.newWaypoints||i.waypoints,s=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 nd(e,t,n,i).point}(t,o,s,r)}Fo.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),s=[].concat(i.waypoints.slice(0,-1),[o]);t.updateWaypoints(i,s)})),r.forEach((function(i){var r=i.waypoints[0],o=n(e,r),s=[].concat([o],i.waypoints.slice(1));t.updateWaypoints(i,s)}))})),this.postExecute(["connection.move"],(function(e){var n=e.context,i=n.connection,r=i.outgoing,o=i.incoming,s=n.delta;o.forEach((function(e){var n=e.waypoints[e.waypoints.length-1],i={x:n.x+s.x,y:n.y+s.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+s.x,y:n.y+s.y},r=[].concat([i],e.waypoints.slice(1));t.updateWaypoints(e,r)}))}))}function dd(e,t,n){var i=yd(e),r=vd(i,t),o=i[0];return r.length?r[r.length-1]:od(o.original||o,n,t)}function hd(e,t,n){var i=yd(e),r=vd(i,t),o=i[i.length-1];return r.length?r[0]:od(o.original||o,n,t)}function md(e,t,n){var i=yd(e),r=gd(t,n),o=i[0];return od(o.original||o,r,t)}function fd(e,t,n){var i=yd(e),r=gd(t,n),o=i[i.length-1];return od(o.original||o,r,t)}function gd(e,t){return{x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}}function yd(e){var t=e.waypoints;if(!t.length)throw new Error("connection#"+e.id+": no waypoints");return t}function vd(e,t){return y(E(e,bd),(function(e){return function(e,t){return"intersect"===xn(t,e,1)}(e,t)}))}function bd(e){return e.original||e}function xd(e,t){Fo.call(this,e),this.postExecute("shape.replace",(function(e){var n=e.oldShape,i=e.newShape;if(function(e,t){return _r(e,"bpmn:Participant")&&Vr(e)&&_r(t,"bpmn:Participant")&&!Vr(t)}(n,i)){var r,o,s,a,l=(o=gt([r=n],!1),s=[],a=[],o.forEach((function(e){e!==r&&(e.incoming.forEach((function(e){_r(e,"bpmn:MessageFlow")&&s.push(e)})),e.outgoing.forEach((function(e){_r(e,"bpmn:MessageFlow")&&a.push(e)})))}),[]),{incoming:s,outgoing:a});l.incoming.forEach((function(e){var r=hd(e,i,n);t.reconnectEnd(e,i,r)})),l.outgoing.forEach((function(e){var r=dd(e,i,n);t.reconnectStart(e,i,r)}))}}),!0)}e(cd,Fo),cd.$inject=["eventBus","modeling","bpmnFactory","textRenderer"],e(ud,Fo),ud.$inject=["eventBus","modeling"],xd.$inject=["eventBus","modeling"],e(xd,Fo);const wd=["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:EscalationEventDefinition","bpmn:ConditionalEventDefinition","bpmn:SignalEventDefinition"];function _d(e){const t=Or(e);if(!(_r(t,"bpmn:BoundaryEvent")||_r(t,"bpmn:StartEvent")&&Ur(t.$parent)))return!1;const n=t.get("eventDefinitions");return!(!n||!n.length)&&wd.some((e=>_r(n[0],e)))}function Ed(e){return _r(e,"bpmn:BoundaryEvent")?"cancelActivity":"isInterrupting"}function Od(e,t){e.invoke(Fo,this),this.postExecuted("shape.replace",(function(e){const n=e.context.oldShape,i=e.context.newShape,r=e.context.hints;if(!_d(i))return;const o=Ed(i);if(r.targetElement&&void 0!==r.targetElement[o])return;const s=Or(n).get(o);s!==Or(i).get(o)&&t.updateProperties(i,{[o]:s})}))}function Pd(e,t){Fo.call(this,e),this.preExecute("shape.resize",(function(e){var n=e.shape,i=Pr(n),r=i&&i.get("label");r&&r.get("bounds")&&t.updateModdleProperties(n,r,{bounds:void 0})}),!0)}function kd(e,t,n){Fo.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(_r(r,"bpmn:SequenceFlow")&&_r(o,"bpmn:SequenceFlow")&&t.canConnect(r.source,o.target,r)){var s=function(e,t){var n=Vu(Sd(e[e.length-2]),Sd(e[e.length-1]),Sd(t[1]),Sd(t[0]));return n?[].concat(e.slice(0,e.length-1),[n],t.slice(1)):[Sd(e[0]),Sd(t[t.length-1])]}(r.waypoints,o.waypoints);n.reconnectEnd(r,o.target,s)}}}))}function Sd(e){return e.original||e}function Cd(e,t){Fo.call(this,e),this.preExecute("shape.delete",(function(e){var t=e.shape,n=t.parent;_r(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 Ad(e,t,n,i){Fo.call(this,e);var r=i.get("dragging",!1);function o(e){var i,r,o=e.source,s=e.target;e.parent&&(_r(e,"bpmn:SequenceFlow")&&(n.canConnectSequenceFlow(o,s)||(r=!0),n.canConnectMessageFlow(o,s)&&(i="bpmn:MessageFlow")),_r(e,"bpmn:MessageFlow")&&(n.canConnectMessageFlow(o,s)||(r=!0),n.canConnectSequenceFlow(o,s)&&(i="bpmn:SequenceFlow")),r&&t.removeConnection(e),i&&t.connect(o,s,{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,s=e.context,a=s.connection,l=s.newSource||a.source,c=s.newTarget||a.target;(i=n.canConnect(l,c))&&i.type!==a.type&&(o=t.connect(l,c,{type:i.type,associationDirection:i.associationDirection,waypoints:a.waypoints.slice()}),a.parent&&t.removeConnection(a),s.connection=o,r&&function(e,t){var n,i=r.context(),o=i&&i.payload.previousSelection;if(!o||!o.length)return;if(n=o.indexOf(e),-1===n)return;o.splice(n,1,t)}(a,o))})),this.postExecuted("element.updateProperties",(function(e){var n,i=e.context,r=i.properties,o=i.element,s=o.businessObject;r.default&&(n=f(o.outgoing,M({id:o.businessObject.default.id})))&&t.updateProperties(n,{conditionExpression:void 0}),r.conditionExpression&&s.sourceRef.default===s&&t.updateProperties(o.source,{default:void 0})}))}function Md(e,t,n,i,r,o){i.invoke(Fo,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=x(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=Ur(e)?o.concat(e.children):o.concat(e)})),1===o.length&&r&&(i=r);var s=t.canReplace(o,i);s&&this._replaceElements(o,s.replacements,r)}),this),this.postExecute(["shape.replace"],1500,(function(e){var n,i=e.context,r=i.oldShape,o=i.newShape,s=r.attachers;s&&s.length&&(n=t.canReplace(s,o),this._replaceElements(s,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})}))}Od.$inject=["injector","modeling"],e(Od,Fo),e(Pd,Fo),Pd.$inject=["eventBus","modeling"],e(kd,Fo),kd.$inject=["eventBus","bpmnRules","modeling"],Cd.$inject=["eventBus","modeling"],e(Cd,Fo),e(Ad,Fo),Ad.$inject=["eventBus","modeling","bpmnRules","injector"],e(Md,Fo),Md.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),s=e.indexOf(o);e[s]=i.replaceElement(o,r,{select:!1})})),t&&r.select(e)},Md.$inject=["bpmnReplace","bpmnRules","elementRegistry","injector","modeling","selection"];var Td={width:140,height:120},Rd={width:300,height:60},Dd={width:60,height:300},Nd={width:300,height:150},Bd={width:150,height:300},$d={width:140,height:120},jd={width:50,height:30};function Id(e){e.on("resize.start",1500,(function(e){var t=e.context,n=t.shape,i=t.direction,r=t.balanced;(_r(n,"bpmn:Lane")||_r(n,"bpmn:Participant"))&&(t.resizeConstraints=function(e,t,n){var i=Au(e),r=!0,o=!0,s=Su(i,[i]),a=gn(e),l={},c={},p=Fr(e),u=p?Rd:Dd;/n/.test(t)?c.top=a.bottom-u.height:/e/.test(t)?c.right=a.left+u.width:/s/.test(t)?c.bottom=a.top+u.height:/w/.test(t)&&(c.left=a.right-u.width);s.forEach((function(e){var i=gn(e);p?(i.top<a.top-10&&(r=!1),i.bottom>a.bottom+10&&(o=!1)):(i.left<a.left-10&&(r=!1),i.right>a.right+10&&(o=!1)),/n/.test(t)&&(n&&Ld(a.top-i.bottom)<10&&Hd(l,"top",i.top+u.height),Ld(a.top-i.top)<5&&Fd(c,"top",i.bottom-u.height)),/e/.test(t)&&(n&&Ld(a.right-i.left)<10&&Fd(l,"right",i.right-u.width),Ld(a.right-i.right)<5&&Hd(c,"right",i.left+u.width)),/s/.test(t)&&(n&&Ld(a.bottom-i.top)<10&&Fd(l,"bottom",i.bottom-u.height),Ld(a.bottom-i.bottom)<5&&Hd(c,"bottom",i.top+u.height)),/w/.test(t)&&(n&&Ld(a.left-i.right)<10&&Hd(l,"left",i.left+u.width),Ld(a.left-i.left)<5&&Fd(c,"left",i.right-u.width))}));var d=i.children.filter((function(e){return!e.hidden&&!e.waypoints&&(_r(e,"bpmn:FlowElement")||_r(e,"bpmn:Artifact"))})),h=p?Ud:Wd;return d.forEach((function(e){var n=gn(e);!/n/.test(t)||p&&!r||Fd(c,"top",n.top-h.top),/e/.test(t)&&(p||o)&&Hd(c,"right",n.right+h.right),!/s/.test(t)||p&&!o||Hd(c,"bottom",n.bottom+h.bottom),/w/.test(t)&&(p||r)&&Fd(c,"left",n.left-h.left)})),{min:c,max:l}}(n,i,r)),_r(n,"bpmn:SubProcess")&&Vr(n)&&(t.minDimensions=$d),_r(n,"bpmn:TextAnnotation")&&(t.minDimensions=jd)}))}Id.$inject=["eventBus"];var Ld=Math.abs,qd=Math.min,zd=Math.max;function Vd(e,t,n,i){var r=e[t];e[t]=void 0===r?n:i(n,r)}function Fd(e,t,n){return Vd(e,t,n,qd)}function Hd(e,t,n){return Vd(e,t,n,zd)}var Ud={top:20,left:50,right:20,bottom:20},Wd={top:50,left:20,right:20,bottom:20};function Gd(e,t){e.on("resize.start",1501,(function(e){var t=e.context,n=t.shape;(_r(n,"bpmn:Lane")||_r(n,"bpmn:Participant"))&&(t.balanced=!bs(e))})),e.on("resize.end",1001,(function(e){var n=e.context,i=n.shape,r=n.canExecute,o=n.newBounds;if(_r(i,"bpmn:Lane")||_r(i,"bpmn:Participant"))return r&&(o=mn(o),t.resizeLane(i,o,n.balanced)),!1}))}Gd.$inject=["eventBus","modeling"];function Qd(e,t,n,i,r){function o(e){return Er(e,["bpmn:ReceiveTask","bpmn:SendTask"])||function(e,t){c(t)||(t=[t]);return _(t,(function(t){return Wr(e,t)}))}(e,["bpmn:ErrorEventDefinition","bpmn:EscalationEventDefinition","bpmn:MessageEventDefinition","bpmn:SignalEventDefinition"])}function s(t){return!!f(e.getDefinitions().get("rootElements"),M({id:t.id}))}function a(e){return _r(e,"bpmn:ErrorEventDefinition")?"errorRef":_r(e,"bpmn:EscalationEventDefinition")?"escalationRef":_r(e,"bpmn:MessageEventDefinition")?"messageRef":_r(e,"bpmn:SignalEventDefinition")?"signalRef":void 0}function l(e){if(Er(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.get("messageRef");var t=e.get("eventDefinitions")[0];return t.get(a(t))}n.invoke(Fo,this),this.executed(["shape.create","element.updateProperties","element.updateModdleProperties"],(function(t){var n=t.shape||t.element;if(o(n)){var i=l(Or(n));i&&!s(i)&&(Ot(e.getDefinitions().get("rootElements"),i),t.addedRootElement=i)}}),!0),this.reverted(["shape.create","element.updateProperties","element.updateModdleProperties"],(function(t){var n=t.addedRootElement;n&&Et(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=l(Or(n));i&&(t.referencedRootElement=i)}})),t.on("copyPaste.pasteElement",500,(function(e){var t=e.descriptor,n=t.businessObject,o=t.referencedRootElement;o&&(s(o)||(o=i.copyElement(o,r.create(o.$type))),function(e,t){if(Er(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.set("messageRef",t);var n=e.get("eventDefinitions")[0];n.set(a(n),t)}(n,o),delete t.referencedRootElement)}))}Qd.$inject=["bpmnjs","eventBus","injector","moddleCopy","bpmnFactory"],e(Qd,Fo);var Xd=Math.max;function Kd(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;_r(e,"bpmn:Participant")&&(r[t]=function(e,t,n){var i=Fr(e);if(r=e,!Cu(r).length)return i?Nd:Bd;var r;var o=function(e){return"x"===e}(t),s={};s=o?i?Nd:{width:Zd(e,n,o),height:Bd.height}:i?{width:Nd.width,height:Yd(e,n,o)}:Bd;return s}(e,n,i)),_r(e,"bpmn:Lane")&&(r[t]=Fr(e)?Rd:Dd),_r(e,"bpmn:SubProcess")&&Vr(e)&&(r[t]=$d),_r(e,"bpmn:TextAnnotation")&&(r[t]=jd),_r(e,"bpmn:Group")&&(r[t]=Td)})),r}))}function Yd(e,t,n){var i;return i=function(e,t,n){var i,r=Cu(e);return i=Jd(r,t,n),e.height-i.height+Rd.height}(e,t,n),Xd(Nd.height,i)}function Zd(e,t,n){var i;return i=function(e,t,n){var i,r=Cu(e);return i=Jd(r,t,n),e.width-i.width+Dd.width}(e,t,n),Xd(Bd.width,i)}function Jd(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=Cu(r)).length?Jd(o,t,n):r}Kd.$inject=["eventBus"];var eh=180,th=160;function nh(e,t,n,i,r,o,s){Fo.call(this,t),this._canvas=e,this._eventBus=t,this._modeling=n,this._elementFactory=i,this._bpmnFactory=r,this._bpmnjs=o,this._elementRegistry=s;var a=this;function l(e){return _r(e,"bpmn:SubProcess")&&!Vr(e)}function c(t){var n=t.shape,i=t.newRootElement,r=Or(n);i=a._addDiagram(i||r),t.newRootElement=e.addRootElement(i)}function p(t){var n=Or(t.shape);a._removeDiagram(n);var i=t.newRootElement=s.get(Zo(n));e.removeRootElement(i)}this.executed("shape.create",(function(e){l(e.shape)&&c(e)}),!0),this.postExecuted("shape.create",(function(e){var t=e.shape,n=e.newRootElement;n&&t.children&&(a._showRecursively(t.children),a._moveChildrenToShape(t,n))}),!0),this.reverted("shape.create",(function(e){l(e.shape)&&p(e)}),!0),this.preExecuted("shape.delete",(function(e){var t=e.shape;if(l(t)){var i=s.get(Zo(t));i&&n.removeElements(i.children.slice())}}),!0),this.executed("shape.delete",(function(e){l(e.shape)&&p(e)}),!0),this.reverted("shape.delete",(function(e){l(e.shape)&&c(e)}),!0),this.preExecuted("shape.replace",(function(t){var n=t.oldShape,i=t.newShape;l(n)&&l(i)&&(t.oldRoot=e.removeRootElement(Zo(n)))}),!0),this.postExecuted("shape.replace",(function(t){var i=t.newShape,r=t.oldRoot,o=e.findRoot(Zo(i));if(r&&o){var s=r.children;n.moveElements(s,{x:0,y:0},o)}}),!0),this.executed("element.updateProperties",(function(e){var t=e.element;if(_r(t,"bpmn:SubProcess")){var n=e.properties,i=e.oldProperties.id,r=n.id;if(i!==r){if(es(t))return s.updateId(t,Jo(r)),void s.updateId(i,r);s.get(Jo(i))&&s.updateId(Jo(i),Jo(r))}}}),!0),this.reverted("element.updateProperties",(function(e){var t=e.element;if(_r(t,"bpmn:SubProcess")){var n=e.properties,i=e.oldProperties.id,r=n.id;if(i!==r){if(es(t))return s.updateId(t,Jo(i)),void s.updateId(r,i);var o=s.get(Jo(r));o&&s.updateId(o,Jo(i))}}}),!0),t.on("element.changed",(function(e){var n=e.element;if(es(n)){var i=n,r=s.get(Yo(i));r&&r!==i&&t.fire("element.changed",{element:r})}})),this.executed("shape.toggleCollapse",400,(function(e){var t=e.shape;_r(t,"bpmn:SubProcess")&&(Vr(t)?p(e):(c(e),a._showRecursively(t.children)))}),!0),this.reverted("shape.toggleCollapse",400,(function(e){var t=e.shape;_r(t,"bpmn:SubProcess")&&(Vr(t)?p(e):(c(e),a._showRecursively(t.children)))}),!0),this.postExecuted("shape.toggleCollapse",600,(function(e){var t=e.shape;if(_r(t,"bpmn:SubProcess")){var n=e.newRootElement;n&&(Vr(t)?a._moveChildrenToShape(n,t):a._moveChildrenToShape(t,n))}}),!0),t.on("copyPaste.createTree",(function(e){var t=e.element,n=e.children;if(l(t)){var i=Zo(t),r=s.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(_r(Pr(r),"bpmndi:BPMNPlane")){var o=Yo(r),s=f(i,(function(e){return e.id===o}));s&&(t.parent=s.id)}})),t.on("copyPaste.pasteElement",(function(e){var t=e.descriptor;t.parent&&(l(t.parent)||t.parent.hidden)&&(t.hidden=!0)}))}function ih(e,t){e.invoke(Fo,this),this.postExecuted("shape.replace",(function(e){var n=e.context.oldShape,i=e.context.newShape;if(_r(i,"bpmn:SubProcess")&&(_r(n,"bpmn:Task")||_r(n,"bpmn:CallActivity"))&&Vr(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 rh(e){Fo.call(this,e),this.preExecute("connection.create",(function(e){const{target:t}=e;_r(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&&_r(t[0],"bpmn:TextAnnotation")&&(e.hints=e.hints||{},e.hints.autoResize=!1)}),!0)}function oh(e,t){Fo.call(this,e),this.postExecuted("shape.toggleCollapse",1500,(function(e){var n=e.shape;if(!Vr(n)){var i=gt(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,bn(n)):t.reconnectStart(e,n,bn(n)))}}),!0)}e(nh,Fo),nh.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 s=yt(o);if(t.x){var a=bn(t),l=bn(s);n={x:a.x-l.x,y:a.y-l.y}}else n={x:eh-s.x,y:th-s.y};i.moveElements(r,n,t,{autoResize:!1})}else i.moveElements(r,{x:0,y:0},t,{autoResize:!1})}},nh.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},nh.prototype._addDiagram=function(e){var t=this._bpmnjs.getDefinitions().diagrams;return e.businessObject||(e=this._createNewDiagram(e)),t.push(e.di.$parent),e},nh.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:Zo(e),type:e.$type,di:i,businessObject:e,collapsed:!0})},nh.prototype._removeDiagram=function(e){var t=this._bpmnjs.getDefinitions().diagrams,n=f(t,(function(t){return t.plane.bpmnElement.id===e.id}));return t.splice(t.indexOf(n),1),n},nh.$inject=["canvas","eventBus","modeling","elementFactory","bpmnFactory","bpmnjs","elementRegistry"],ih.$inject=["injector","modeling"],e(ih,Fo),e(rh,Fo),rh.$inject=["eventBus"],e(oh,Fo),oh.$inject=["eventBus","modeling"];function sh(e,t,n){Fo.call(this,e),this.executed(["shape.toggleCollapse"],500,(function(e){var t,n=e.context.shape;_r(n,"bpmn:SubProcess")&&(n.collapsed?Pr(n).isExpanded=!1:((t=n.children).length&&t.forEach((function(e){"label"!==e.type||e.businessObject.name||(e.hidden=!0)})),Pr(n).isExpanded=!0))})),this.reverted(["shape.toggleCollapse"],500,(function(e){var t=e.context.shape;t.collapsed?Pr(t).isExpanded=!1:Pr(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,s=t;return n=(r=o,r.filter((function(e){return!e.hidden}))).concat([e]),(i=Eu(n))?(s.width=Math.max(i.width,s.width),s.height=Math.max(i.height,s.height),s.x=i.x+(i.width-s.width)/2,s.y=i.y+(i.height-s.height)/2):(s.x=e.x+(e.width-s.width)/2,s.y=e.y+(e.height-s.height)/2),s}(r,o),n.resizeShape(r,i,null,{autoResize:!r.collapsed&&"nwse"})}))}function ah(e,t,n,i){t.invoke(Fo,this),this.preExecute("shape.delete",(function(e){var t=e.context.shape,r=t.businessObject;hn(t)||(_r(t,"bpmn:Participant")&&Vr(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;_r(t,"bpmn:Collaboration")&&n.ids.unclaim(i.id)}))}function lh(e,t){Fo.call(this,e),this.preExecute("connection.delete",(function(e){var n=e.context.connection,i=n.source;(function(e,t){if(!_r(e,"bpmn:SequenceFlow"))return!1;var n=Or(t),i=Or(e);return n.get("default")===i})(n,i)&&t.updateProperties(i,{default:null})}))}e(sh,Fo),sh.$inject=["eventBus","elementFactory","modeling"],e(ah,Fo),ah.$inject=["canvas","injector","moddle","modeling"],e(lh,Fo),lh.$inject=["eventBus","modeling"];function ch(e,t){var n;function i(){if(!n)throw new Error("out of bounds release");return n}Fo.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 ph).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||(_r(t,"bpmn:Lane")&&n.addLane(t),_r(t,"bpmn:FlowNode")&&n.addFlowNode(t))}))}function ph(){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 uh(e,t){Fo.call(this,e),this.postExecuted("elements.create",(function(e){const n=e.context.elements;for(const e of n)dh(e)&&!hh(e)&&t.updateProperties(e,{isForCompensation:void 0})}))}function dh(e){const t=Or(e);return t&&t.isForCompensation}function hh(e){return e.incoming.filter((e=>function(e){return e&&_r(e,"bpmn:BoundaryEvent")&&Wr(e,"bpmn:CompensateEventDefinition")}(e.source))).length>0}ch.$inject=["eventBus","modeling"],e(ch,Fo),e(uh,Fo),uh.$inject=["eventBus","modeling"];var mh={__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",Gp],appendBehavior:["type",Xp],associationBehavior:["type",Kp],attachEventBehavior:["type",Yp],boundaryEventBehavior:["type",Jp],compensateBoundaryEventBehaviour:["type",eu],createBehavior:["type",ru],createDataObjectBehavior:["type",ou],createParticipantBehavior:["type",pu],dataInputAssociationBehavior:["type",du],dataStoreBehavior:["type",fu],deleteLaneBehavior:["type",Tu],detachEventBehavior:["type",Ru],dropOnFlowBehavior:["type",Nu],eventBasedGatewayBehavior:["type",ju],fixHoverBehavior:["type",qu],groupBehavior:["type",zu],importDockingFix:["type",Fu],isHorizontalFix:["type",Uu],labelBehavior:["type",cd],layoutConnectionBehavior:["type",ud],messageFlowBehavior:["type",xd],nonInterruptingBehavior:["type",Od],removeElementBehavior:["type",kd],removeEmbeddedLabelBoundsBehavior:["type",Pd],removeParticipantBehavior:["type",Cd],replaceConnectionBehavior:["type",Ad],replaceElementBehaviour:["type",Md],resizeBehavior:["type",Id],resizeLaneBehavior:["type",Gd],rootElementReferenceBehavior:["type",Qd],spaceToolBehavior:["type",Kd],subProcessPlaneBehavior:["type",nh],subProcessStartEventBehavior:["type",ih],textAnnotationBehavior:["type",rh],toggleCollapseConnectionBehaviour:["type",oh],toggleElementCollapseBehaviour:["type",sh],unclaimIdBehavior:["type",ah],unsetDefaultFlowBehavior:["type",lh],updateFlowNodeRefsBehavior:["type",ch],setCompensationActivityAfterPasteBehavior:["type",uh]};function fh(e,t){var n=xn(e,t,-15);return"intersect"!==n?n:null}function gh(e){Kl.call(this,e)}function yh(e){return!e||hn(e)}function vh(e){do{if(_r(e,"bpmn:Process"))return Or(e);if(_r(e,"bpmn:Participant"))return Or(e).processRef||Or(e)}while(e=e.parent)}function bh(e){return _r(e,"bpmn:TextAnnotation")}function xh(e){return _r(e,"bpmn:Group")&&!e.labelTarget}function wh(e){return _r(e,"bpmn:BoundaryEvent")&&Ph(e,"bpmn:CompensateEventDefinition")}function _h(e){return Or(e).isForCompensation}function Eh(e){for(var t=e;t=t.parent;){if(_r(t,"bpmn:FlowElementsContainer"))return Or(t);if(_r(t,"bpmn:Participant"))return Or(t).processRef}return null}function Oh(e,t){return Eh(e)===Eh(t)}function Ph(e,t){return!!f(Or(e).eventDefinitions||[],(function(e){return _r(e,t)}))}function kh(e,t){return(Or(e).eventDefinitions||[]).every((function(e){return _r(e,t)}))}function Sh(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 Ch(e,t,n){if(yh(e)||yh(t))return null;if(!_r(n,"bpmn:DataAssociation")){if(Vh(e,t))return{type:"bpmn:MessageFlow"};if(Fh(e,t))return{type:"bpmn:SequenceFlow"}}var i=Hh(e,t);return i||(zh(e,t)?{type:"bpmn:Association",associationDirection:"One"}:!!qh(e,t)&&{type:"bpmn:Association",associationDirection:"None"})}function Ah(e,t){return!(!hn(e)&&!xh(e))||!(_r(t,"bpmn:Participant")&&!Vr(t))&&(_r(e,"bpmn:Participant")?_r(t,"bpmn:Process")||_r(t,"bpmn:Collaboration"):Er(e,["bpmn:DataInput","bpmn:DataOutput"])&&e.parent?t===e.parent:_r(e,"bpmn:Lane")?_r(t,"bpmn:Participant")||_r(t,"bpmn:Lane"):!(_r(e,"bpmn:BoundaryEvent")&&!function(e){return Or(e).cancelActivity&&(Rh(e)||Dh(e))}(e))&&(_r(e,"bpmn:FlowElement")&&!_r(e,"bpmn:DataStoreReference")?_r(t,"bpmn:FlowElementsContainer")?Vr(t):Er(t,["bpmn:Participant","bpmn:Lane"]):_r(e,"bpmn:DataStoreReference")&&_r(t,"bpmn:Collaboration")?_(Or(t).get("participants"),(function(e){return!!e.get("processRef")})):Er(e,["bpmn:Artifact","bpmn:DataAssociation","bpmn:DataStoreReference"])?Er(t,["bpmn:Collaboration","bpmn:Lane","bpmn:Participant","bpmn:Process","bpmn:SubProcess"]):!!_r(e,"bpmn:MessageFlow")&&(_r(t,"bpmn:Collaboration")||e.source.parent==t||e.target.parent==t)))}function Mh(e){return _r(e,"bpmn:Lane")}function Th(e){return!!function(e){return!hn(e)&&_r(e,"bpmn:BoundaryEvent")}(e)||(!(!_r(e,"bpmn:IntermediateThrowEvent")||!Rh(e))||_r(e,"bpmn:IntermediateCatchEvent")&&Dh(e))}function Rh(e){var t=Or(e);return t&&!(t.eventDefinitions&&t.eventDefinitions.length)}function Dh(e){return Nh(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])}function Nh(e,t){return t.some((function(t){return Ph(e,t)}))}function Bh(e,t,n,i){if(Array.isArray(e)||(e=[e]),1!==e.length)return!1;var r=e[0];return!hn(r)&&(!!Th(r)&&(!Ur(t)&&(!(!_r(t,"bpmn:Activity")||_h(t))&&(!(i&&!fh(i,t))&&(!function(e){return _r(e,"bpmn:ReceiveTask")&&f(e.incoming,(function(e){return _r(e.source,"bpmn:EventBasedGateway")}))}(t)&&"attach")))))}function $h(e,t,n){if(!t)return!1;var i={replacements:[]};return v(e,(function(e){Ur(t)||_r(e,"bpmn:StartEvent")&&"label"!==e.type&&Ah(e,t)&&(Hr(e)||i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),(function(e){return Wr(e,"bpmn:ErrorEventDefinition")}(e)||function(e){return Wr(e,"bpmn:EscalationEventDefinition")}(e)||function(e){return Wr(e,"bpmn:CompensateEventDefinition")}(e))&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),Nh(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])&&_r(t,"bpmn:SubProcess")&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"})),_r(t,"bpmn:Transaction")||Ph(e,"bpmn:CancelEventDefinition")&&"label"!==e.type&&(_r(e,"bpmn:EndEvent")&&Ah(e,t)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:EndEvent"}),_r(e,"bpmn:BoundaryEvent")&&Bh(e,t,0,n)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:BoundaryEvent"}))})),!!i.replacements.length&&i}function jh(e,t){return!_(e,Mh)&&(!t||e.every((function(e){return Ah(e,t)})))}function Ih(e,t,n,i){return!!t&&(!(!hn(e)&&!xh(e))||!function(e,t){return e===t}(n,t)&&((!n||!Sh(n,t))&&(Ah(e,t)||Uh(e,t))))}function Lh(e,t){return _r(e,"bpmn:SubProcess")?Vr(e)&&(!t||t.width>=100&&t.height>=80):!!_r(e,"bpmn:Lane")||(!!_r(e,"bpmn:Participant")||(!!bh(e)||!!xh(e)))}function qh(e,t){return!Sh(t,e)&&!Sh(e,t)&&(!!function(e,t){var n=bh(e),i=bh(t);return(n||i)&&n!==i}(e,t)||!!Hh(e,t))}function zh(e,t){return Oh(e,t)&&wh(e)&&_r(t,"bpmn:Activity")&&(n=e,!t.attachers.includes(n))&&!Ur(t);var n}function Vh(e,t){return!(Gh(e)&&!Gh(t))&&(_r(n=e,"bpmn:InteractionNode")&&!_r(n,"bpmn:BoundaryEvent")&&(!_r(n,"bpmn:Event")||_r(n,"bpmn:ThrowEvent")&&kh(n,"bpmn:MessageEventDefinition"))&&function(e){return _r(e,"bpmn:InteractionNode")&&!_h(e)&&(!_r(e,"bpmn:Event")||_r(e,"bpmn:CatchEvent")&&kh(e,"bpmn:MessageEventDefinition"))&&!(_r(e,"bpmn:BoundaryEvent")&&!Ph(e,"bpmn:MessageEventDefinition"))}(t)&&!function(e,t){return vh(e)===vh(t)}(e,t));var n}function Fh(e,t){return _r(n=e,"bpmn:FlowNode")&&!_r(n,"bpmn:EndEvent")&&!Ur(n)&&!(_r(n,"bpmn:IntermediateThrowEvent")&&Ph(n,"bpmn:LinkEventDefinition"))&&!wh(n)&&!_h(n)&&function(e){return _r(e,"bpmn:FlowNode")&&!_r(e,"bpmn:StartEvent")&&!_r(e,"bpmn:BoundaryEvent")&&!Ur(e)&&!(_r(e,"bpmn:IntermediateCatchEvent")&&Ph(e,"bpmn:LinkEventDefinition"))&&!_h(e)}(t)&&Oh(e,t)&&!(_r(e,"bpmn:EventBasedGateway")&&!function(e){return _r(e,"bpmn:ReceiveTask")||_r(e,"bpmn:IntermediateCatchEvent")&&(Ph(e,"bpmn:MessageEventDefinition")||Ph(e,"bpmn:TimerEventDefinition")||Ph(e,"bpmn:ConditionalEventDefinition")||Ph(e,"bpmn:SignalEventDefinition"))}(t));var n}function Hh(e,t){return Er(e,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&Er(t,["bpmn:Activity","bpmn:ThrowEvent"])?{type:"bpmn:DataInputAssociation"}:!(!Er(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])||!Er(e,["bpmn:Activity","bpmn:CatchEvent"]))&&{type:"bpmn:DataOutputAssociation"}}function Uh(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&&(Er(t,["bpmn:SequenceFlow","bpmn:MessageFlow"])&&!hn(t)&&_r(e,"bpmn:FlowNode")&&!_r(e,"bpmn:BoundaryEvent")&&Ah(e,t.parent))}function Wh(e,t){return!!hn(t)||!(_r(t,"bpmn:Lane")&&!function(e,t){return e&&t&&-1!==e.indexOf(t)}(e,t.parent))}function Gh(e){return pc(e,"bpmn:Process")||pc(e,"bpmn:Collaboration")}e(gh,Kl),gh.$inject=["eventBus"],gh.prototype.init=function(){this.addRule("connection.start",(function(e){return function(e){if(yh(e))return null;return Er(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 Ch(t,n)}finally{r&&(n.parent=null)}})),this.addRule("connection.reconnect",(function(e){var t=e.connection;return Ch(e.source,e.target,t)})),this.addRule("connection.updateWaypoints",(function(e){return{type:e.connection.type}})),this.addRule("shape.resize",(function(e){return Lh(e.shape,e.newBounds)})),this.addRule("elements.create",(function(e){var t=e.elements,n=e.position,i=e.target;return!(dn(i)&&!Uh(t,i))&&w(t,(function(e){return dn(e)?Ch(e.source,e.target,e):e.host?Bh(e,e.host,null,n):Ih(e,i,null)}))})),this.addRule("elements.move",(function(e){var t=e.target,n=e.shapes,i=e.position;return Bh(n,t,null,i)||$h(n,t,i)||jh(n,t)||Uh(n,t)})),this.addRule("shape.create",(function(e){return Ih(e.shape,e.target,e.source,e.position)})),this.addRule("shape.attach",(function(e){return Bh(e.shape,e.target,null,e.position)})),this.addRule("element.copy",(function(e){var t=e.element;return Wh(e.elements,t)}))},gh.prototype.canConnectMessageFlow=Vh,gh.prototype.canConnectSequenceFlow=Fh,gh.prototype.canConnectDataAssociation=Hh,gh.prototype.canConnectAssociation=qh,gh.prototype.canConnectCompensationAssociation=zh,gh.prototype.canMove=jh,gh.prototype.canAttach=Bh,gh.prototype.canReplace=$h,gh.prototype.canDrop=Ah,gh.prototype.canInsert=Uh,gh.prototype.canCreate=Ih,gh.prototype.canConnect=Ch,gh.prototype.canResize=Lh,gh.prototype.canCopy=Wh;var Qh={__depends__:[Rc],__init__:["bpmnRules"],bpmnRules:["type",gh]};function Xh(e,t){e.on("saveXML.start",2e3,(function(){v(t.getRootElements(),(function(e){var t,n=Pr(e);t=E(y(gt([e],!1),(function(t){return t!==e&&!t.labelTarget})),Pr),n.set("planeElement",t)}))}))}Xh.$inject=["eventBus","canvas"];var Kh={__init__:["bpmnDiOrdering"],bpmnDiOrdering:["type",Xh]};function Yh(e){Fo.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 Zh(e,t){Yh.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=f(n,(function(t){return Er(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||_r(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&&!Er(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),s=g(n.children,(function(t){return!(!e.labelTarget&&t.labelTarget)&&r.level<i(t).level}));return-1!==s&&-1!==o&&o<s&&(s-=1),{index:s,parent:n}}}Yh.prototype.getOrdering=function(e,t){return null},e(Yh,Fo),Zh.$inject=["eventBus","canvas"],e(Zh,Yh);var Jh={__init__:["bpmnOrderingProvider"],bpmnOrderingProvider:["type",Zh]};function em(){}em.prototype.get=function(){return this._data},em.prototype.set=function(e){this._data=e},em.prototype.clear=function(){var e=this._data;return delete this._data,e},em.prototype.isEmpty=function(){return!this._data};var tm={clipboard:["type",em]},nm="drop-ok",im="drop-not-ok",rm="attach-ok",om="new-parent",sm="create";function am(e,t,n,i,r){function o(t,n){[rm,nm,im,om].forEach((function(i){i===n?e.addMarker(t,i):e.removeMarker(t,i)}))}function s(){var e=t.context();e&&e.prefix===sm&&t.cancel()}n.on(["create.move","create.hover"],(function(e){var t=e.context,n=t.elements,i=e.hover,s=t.source,a=t.hints||{};if(!i)return t.canExecute=!1,void(t.target=null);lm(e);var l={x:e.x,y:e.y},c=t.canExecute=i&&function(e,t,n,i,o){if(!t)return!1;var s=f(e=y(e,(function(t){var n=t.labelTarget;return!(t.parent||hn(t)&&-1!==e.indexOf(n))})),(function(e){return!dn(e)})),a=!1,l=!1,c=!1;cm(e)&&(a=r.allowed("shape.attach",{position:n,shape:s,target:t})),a||(c=cm(e)?r.allowed("shape.create",{position:n,shape:s,source:i,target:t}):r.allowed("elements.create",{elements:e,position:n,target:t}));var p=o.connectionTarget;return c||a?(s&&i&&(l=r.allowed("connection.create",{source:p===i?s:i,target:p===i?i:s,hints:{targetParent:t,targetAttach:a}})),{attach:a,connect:l}):(null===c||null===a)&&null}(n,i,l,s,a);i&&null!==c&&(t.target=i,c&&c.attach?o(i,rm):o(i,c?om:im))})),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,s=t.target,a=t.canExecute,l=a&&a.attach,c=a&&a.connect,p=t.hints||{};if(!1===a||!s)return!1;lm(e);var u={x:e.x,y:e.y};r=c?i.appendShape(n,r,u,s,{attach:l,connection:!0===c?{}:c,connectionTarget:p.connectionTarget}):f(o=i.createElements(o,u,s,j({},p,{attach:l})),(function(e){return!dn(e)})),j(t,{elements:o,shape:r}),j(e,{elements:o,shape:r})})),n.on("create.init",(function(){n.on("elements.changed",s),n.once(["create.cancel","create.end"],2e3,(function(){n.off("elements.changed",s)}))})),this.start=function(e,n,i){c(n)||(n=[n]);var r=f(n,(function(e){return!dn(e)}));if(r){i=j({elements:n,hints:{},shape:r},i||{}),v(n,(function(e){u(e.x)||(e.x=0),u(e.y)||(e.y=0)}));var o=yt(y(n,(function(e){return!e.hidden})));v(n,(function(e){dn(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}}))),j(e,{x:e.x-o.x-o.width/2,y:e.y-o.y-o.height/2})})),t.init(e,sm,{cursor:"grabbing",autoActivate:!0,data:{shape:r,elements:n,context:i}})}}}function lm(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 cm(e){return e&&1===e.length&&!dn(e[0])}am.$inject=["canvas","dragging","eventBus","modeling","rules"];function pm(e,t,n,i,r){t.on("create.move",750,(function(t){var o=t.hover,s=t.context,a=s.elements,l=s.dragGroup;l||(l=s.dragGroup=function(e){var t=De("g");Oe(t,r.cls("djs-drag-group",["no-events"]));var o=De("g");return e.forEach((function(e){var r;e.hidden||(e.waypoints?(r=n._createContainer("connection",o),n.drawConnection(Qn(r),e)):(r=n._createContainer("shape",o),n.drawShape(Qn(r),e),Kn(r,e.x,e.y)),i.addDragger(e,t,r))})),t}(a)),o?(l.parentNode||xe(e.getActiveLayer(),l),Kn(l,t.x,t.y)):He(l)})),t.on("create.cleanup",(function(e){var t=e.context.dragGroup;t&&He(t)}))}pm.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];var um={__depends__:[Sc,zp,Rc,Ts],__init__:["create","createPreview"],create:["type",am],createPreview:["type",pm]};function dm(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)}))}dm.$inject=["eventBus"],dm.prototype.getLastMoveEvent=function(){return this._lastMoveEvent||function(e,t){var n=document.createEvent("MouseEvent"),i=e,r=t,o=e,s=t;n.initMouseEvent&&n.initMouseEvent("mousemove",!0,!0,window,0,i,r,o,s,!1,!1,!1,!1,0,null);return n}(0,0)};var hm={__init__:["mouse"],mouse:["type",dm]};function mm(e,t,n,i,r,o,s,a){this._canvas=e,this._create=t,this._clipboard=n,this._elementFactory=i,this._eventBus=r,this._modeling=o,this._mouse=s,this._rules=a,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=f(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),dn(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=fm(e)).original&&(e.original=fm(e.original)),e}))}(n)),hn(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){j(e.hints,{createElementsBehavior:!1})}))}function fm(e){return j({},e)}function gm(e,t){var n=t.indexOf(e);return-1===n?t:t.splice(n,1)}mm.$inject=["canvas","create","clipboard","elementFactory","eventBus","modeling","mouse","rules"],mm.prototype.copy=function(e){var t,n;return c(e)||(e=e?[e]:[]),n=!1===(t=this._eventBus.fire("copyPaste.canCopyElements",{elements:e}))?{}:this.createTree(c(t)?t:e),this._clipboard.set(n),this._eventBus.fire("copyPaste.elementsCopied",{elements:e,tree:n}),n},mm.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||{}})}},mm.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=yt(e);return v(e,(function(e){dn(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}}))),j(e,{x:e.x-r.x-r.width/2,y:e.y-r.y-r.height/2})})),this._modeling.createElements(e,n,t,j({},i))},mm.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,s=j({},q(e,["priority"]));return i[e.parent]?s.parent=i[e.parent]:delete s.parent,n.fire("copyPaste.pasteElement",{cache:i,descriptor:s}),dn(s)?(s.source=i[e.source],s.target=i[e.target],o=i[e.id]=t.createConnection(s),void r.push(o)):hn(s)?(s.labelTarget=i[s.labelTarget],o=i[e.id]=t.createLabel(s),void r.push(o)):(s.host&&(s.host=i[s.host]),o=i[e.id]=t.createShape(s),void r.push(o))}))})),r},mm.prototype.createConnection=function(e){return this._elementFactory.createConnection(q(e,["id"]))},mm.prototype.createLabel=function(e){return this._elementFactory.createLabel(q(e,["id"]))},mm.prototype.createShape=function(e){return this._elementFactory.createShape(q(e,["id"]))},mm.prototype.hasRelations=function(e,t){var n,i;return!(dn(e)&&(n=f(t,M({id:e.source.id})),i=f(t,M({id:e.target.id})),!n||!i))&&!(hn(e)&&!f(t,M({id:e.labelTarget.id})))},mm.prototype.createTree=function(e){var t=this._rules,n=this,i={},r=[];function o(e,t){var n=f(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 ft(dt(e),(function(e,t,i){if(!hn(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)?gm(r.element,e):(i[o]||(i[o]=[]),i[o].push(r.descriptor)):gm(r.element,e)})),i};var ym={__depends__:[tm,um,hm,Rc],__init__:["copyPaste"],copyPaste:["type",mm]};function vm(e,t,n){c(n)||(n=[n]),v(n,(function(n){s(e[n])||(t[n]=e[n])}))}function bm(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=Or(n);if(hn(n))return t;var o=t.businessObject=i(r,!0),s=t.di=i(Pr(n),!0);s.bpmnElement=o,vm(o,t,"name"),vm(s,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(hn(n))return n.businessObject=Or(t[n.labelTarget]),void(n.di=Pr(t[n.labelTarget]));r=n.businessObject=i(r),(o=n.di=i(o)).bpmnElement=r,vm(n,r,["isExpanded","name"]),n.type=r.$type})),t.on("copyPaste.copyElement",750,(function(e){var t=e.descriptor,n=e.element;if(_r(n,"bpmn:Participant")){var r=Or(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=Or(e);return e.default&&(n[e.default]={element:i,property:"default"}),e.host&&(Or(e).attachedToRef=Or(t[e.host])),q(n,x(n,(function(t,n,r){var o=n.element,s=n.property;return r===e.id&&(o.set(s,i),t.push(e.id)),t}),[]))}(e.descriptor,t,function(e){return e[r]=e[r]||{}}(t)))}))}bm.$inject=["bpmnFactory","eventBus","moddleCopy"];var xm=["artifacts","dataInputAssociations","dataOutputAssociations","default","flowElements","lanes","incoming","outgoing","categoryValue"];function wm(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=p(t)&&t.$descriptor,i=e.propertyName;return(!i||-1===xm.indexOf(i))&&(!(i&&n&&!f(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)&&d(t.$instanceOf)&&t.$instanceOf(n)&&(!i.values||!i.values.length))return!1}))}function _m(e,t){return x(e.properties,(function(e,n){return t&&n.default?e:e.concat(n.name)}),[])}wm.$inject=["eventBus","bpmnFactory","moddle"],wm.prototype.copyElement=function(e,t,n,i=!1){var r=this;n&&!c(n)&&(n=[n]),n=n||_m(e.$descriptor);var o=this._eventBus.fire("moddleCopy.canCopyProperties",{propertyNames:n,sourceElement:e,targetElement:t,clone:i});return!1===o||(c(o)&&(n=o),v(n,(function(n){var o;m(e,n)&&(o=e.get(n));var s=r.copyProperty(o,t,n,i);a(s)&&(!1!==r._eventBus.fire("moddleCopy.canSetCopiedProperty",{parent:t,property:s,propertyName:n})&&t.set(n,s))}))),t},wm.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 p(o)&&o.$type&&!o.$parent&&(o.$parent=t),o;var s=this._moddle.getPropertyDescriptor(t,n);if(!s.isReference){if(s.isId)return e&&this._copyId(e,t,i);if(c(e))return x(e,(function(e,s){return(o=r.copyProperty(s,t,n,i))?e.concat(o):e}),[]);if(p(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}}},wm.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 Em={__depends__:[ym],__init__:["bpmnCopyPaste","moddleCopy"],bpmnCopyPaste:["type",bm],moddleCopy:["type",wm]},Om=Math.round;function Pm(e,t){this._modeling=e,this._eventBus=t}function km(e,t){t.on("replace.end",500,(function(t){const{newElement:n,hints:i={}}=t;!1!==i.select&&e.select(n)}))}Pm.$inject=["modeling","eventBus"],Pm.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,s=t.height||e.height,a=t.x||e.x,l=t.y||e.y,c=Om(a+o/2),p=Om(l+s/2),u=i.replaceShape(e,j({},t,{x:c,y:p,width:o,height:s}),n);return r.fire("replace.end",{element:e,newElement:u,hints:n}),u},km.$inject=["selection","eventBus"];var Sm={__init__:["replace","replaceSelectionBehavior"],replaceSelectionBehavior:["type",km],replace:["type",Pm]};var Cm=["cancelActivity","instantiate","eventGatewayType","triggeredByEvent","isInterrupting"];function Am(e,t,n,i,r,o){this.replaceElement=function(a,l,p){p=p||{};var u=l.type,d=a.businessObject;if(Mm(d)&&"bpmn:SubProcess"===u&&function(e,t){var n=e&&m(e,"collapsed")?e.collapsed:!Vr(e);return n!==(t&&(m(t,"collapsed")||m(t,"isExpanded"))?m(t,"collapsed")?t.collapsed:!t.isExpanded:n)}(a,l))return i.toggleCollapse(a),a;var h=e.create(u),f={type:u,businessObject:h,di:{}};"bpmn:ExclusiveGateway"===u&&(f.di.isMarkerVisible=!0),function(e,t,n){c(n)||(n=[n]),v(n,(function(n){s(e[n])||(t[n]=e[n])}))}(a.di,f.di,["fill","stroke","background-color","border-color","color"]);var g=function(e,t){return e.filter((function(e){return t.includes(e)}))}(_m(d.$descriptor),_m(h.$descriptor,!0));j(h,L(l,Cm));var b=y(g,(function(e){return"eventDefinitions"===e?Tm(a,l.eventDefinitionType):"loopCharacteristics"===e?!Ur(h):!m(h,e)&&(("processRef"!==e||!1!==l.isExpanded)&&("triggeredByEvent"!==e&&("isForCompensation"!==e||!Ur(h))))}));if(h=n.copyElement(d,h,b),l.eventDefinitionType&&(Tm(h,l.eventDefinitionType)||(f.eventDefinitionType=l.eventDefinitionType,f.eventDefinitionAttrs=l.eventDefinitionAttrs)),_r(d,"bpmn:Activity")){if(Mm(d))f.isExpanded=Vr(a);else if(l&&m(l,"isExpanded")){f.isExpanded=l.isExpanded;var x=t.getDefaultSize(h,{isExpanded:f.isExpanded});f.width=x.width,f.height=x.height,f.x=a.x-(f.width-a.width)/2,f.y=a.y-(f.height-a.height)/2}Vr(a)&&!_r(d,"bpmn:Task")&&f.isExpanded&&(f.width=a.width,f.height=a.height)}if(Mm(d)&&!Mm(h)&&(p.moveChildren=!1),_r(d,"bpmn:Participant")){!0===l.isExpanded?h.processRef=e.create("bpmn:Process"):p.moveChildren=!1;var w=Fr(a);Pr(a).isHorizontal||(Pr(f).isHorizontal=w),f.width=w?a.width:t.getDefaultSize(f).width,f.height=w?t.getDefaultSize(f).height:a.height}return o.allowed("shape.resize",{shape:h})||(f.height=t.getDefaultSize(f).height,f.width=t.getDefaultSize(f).width),h.name=d.name,Er(d,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&Er(h,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&(h.default=d.default),l.host&&!_r(d,"bpmn:BoundaryEvent")&&_r(h,"bpmn:BoundaryEvent")&&(f.host=l.host),"bpmn:DataStoreReference"!==f.type&&"bpmn:DataObjectReference"!==f.type||(f.x=a.x+(a.width-f.width)/2),r.replaceElement(a,f,{...p,targetElement:l})}}function Mm(e){return _r(e,"bpmn:SubProcess")}function Tm(e,t){var n=Or(e);return t&&n.get("eventDefinitions").some((function(e){return _r(e,t)}))}Am.$inject=["bpmnFactory","elementFactory","moddleCopy","modeling","replace","rules"];var Rm={__depends__:[Em,Sm,Ts],bpmnReplace:["type",Am]};function Dm(e){this._eventBus=e,this._tools=[],this._active=null}Dm.$inject=["eventBus"],Dm.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)},Dm.prototype.isActive=function(e){return e&&this._active===e},Dm.prototype.length=function(e){return this._tools.length},Dm.prototype.setActive=function(e){var t=this._eventBus;this._active!==e&&(this._active=e,t.fire("tool-manager.update",{tool:e}))},Dm.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&&ee(t,'.group[data-group="tools"]')}(e)||this.setActive(null))}),this)};var Nm={__depends__:[Sc],__init__:["toolManager"],toolManager:["type",Dm]};function Bm(e,t){return-1!==e.indexOf(t)}var $m=Math.abs,jm=Math.round,Im={x:"width",y:"height"},Lm="crosshair",qm={n:"top",w:"left",s:"bottom",e:"right"},zm=1500,Vm={n:"s",w:"e",s:"n",e:"w"},Fm=20;function Hm(e,t,n,i,r,o,s){this._canvas=e,this._dragging=t,this._eventBus=n,this._modeling=i,this._rules=r,this._toolManager=o,this._mouse=s;var a=this;o.registerTool("space",{tool:"spaceTool.selection",dragging:"spaceTool"}),n.on("spaceTool.selection.end",(function(e){n.once("spaceTool.selection.ended",(function(){a.activateMakeSpace(e.originalEvent)}))})),n.on("spaceTool.move",zm,(function(e){var t=e.context,n=t.initialized;n||(n=t.initialized=a.init(e,t)),n&&Wm(e)})),n.on("spaceTool.end",(function(e){var t=e.context,i=t.axis,r=t.direction,o=t.movingShapes,s=t.resizingShapes,l=t.start;if(t.initialized){Wm(e);var c={x:0,y:0};c[i]=jm(e["d"+i]),a.makeSpace(o,s,c,r,l),n.once("spaceTool.ended",(function(e){a.activateSelection(e.originalEvent,!0,!0)}))}}))}function Um(e){return{top:e.top-Fm,right:e.right+Fm,bottom:e.bottom+Fm,left:e.left-Fm}}function Wm(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 Gm(e,t){return-1!==e.indexOf(t)}Hm.$inject=["canvas","dragging","eventBus","modeling","rules","toolManager","mouse"],Hm.prototype.activateSelection=function(e,t,n){this._dragging.init(e,"spaceTool.selection",{autoActivate:t,cursor:Lm,data:{context:{reactivate:n}},trapClick:!1})},Hm.prototype.activateMakeSpace=function(e){this._dragging.init(e,"spaceTool",{autoActivate:!0,cursor:Lm,data:{context:{}}})},Hm.prototype.makeSpace=function(e,t,n,i,r){return this._modeling.createSpace(e,t,n,i,r)},Hm.prototype.init=function(e,t){var n=$m(e.dx)>$m(e.dy)?"x":"y",i=e["d"+n],r=e[n]-i;if($m(i)<5)return!1;i<0&&(i*=-1),bs(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),s=this._canvas.getRootElement();!xs(e)&&e.hover&&(s=e.hover);var a=[...gt(s,!0),...s.attachers||[]],l=this.calculateAdjustments(a,n,i,r),c=function(e,t,n,i,r){var o=e.movingShapes,s=e.resizingShapes;if(!s.length)return;var a,l,c={};return v(s,(function(e){var p,d,h,m,f,g,v=e.attachers,b=e.children,x=gn(e),w=y(b,(function(e){return!(dn(e)||hn(e)||Gm(o,e)||Gm(s,e))})),_=y(b,(function(e){return!dn(e)&&!hn(e)&&Gm(o,e)})),E=[],O=[];w.length&&(d=Um(gn(yt(w))),p=i-x[qm[n]]+d[qm[n]],"n"===n?c.bottom=l=u(l)?Math.min(l,p):p:"w"===n?c.right=l=u(l)?Math.min(l,p):p:"s"===n?c.top=a=u(a)?Math.max(a,p):p:"e"===n&&(c.left=a=u(a)?Math.max(a,p):p)),_.length&&(h=Um(gn(yt(_))),p=i-h[qm[Vm[n]]]+x[qm[Vm[n]]],"n"===n?c.bottom=l=u(l)?Math.min(l,p):p:"w"===n?c.right=l=u(l)?Math.min(l,p):p:"s"===n?c.top=a=u(a)?Math.max(a,p):p:"e"===n&&(c.left=a=u(a)?Math.max(a,p):p)),v&&v.length&&(v.forEach((function(e){Gm(o,e)?E.push(e):O.push(e)})),E.length&&(m=gn(yt(E.map(bn))),f=x[qm[Vm[n]]]-(m[qm[Vm[n]]]-i)),O.length&&(g=gn(yt(O.map(bn)))[qm[n]]-(x[qm[n]]-i)),"n"===n?(p=Math.min(f||1/0,g||1/0),c.bottom=l=u(l)?Math.min(l,p):p):"w"===n?(p=Math.min(f||1/0,g||1/0),c.right=l=u(l)?Math.min(l,p):p):"s"===n?(p=Math.max(f||-1/0,g||-1/0),c.top=a=u(a)?Math.max(a,p):p):"e"===n&&(p=Math.max(f||-1/0,g||-1/0),c.left=a=u(a)?Math.max(a,p):p));var P=r&&r[e.id];P&&("n"===n?(p=i+e[Im[t]]-P[Im[t]],c.bottom=l=u(l)?Math.min(l,p):p):"w"===n?(p=i+e[Im[t]]-P[Im[t]],c.right=l=u(l)?Math.min(l,p):p):"s"===n?(p=i-e[Im[t]]+P[Im[t]],c.top=a=u(a)?Math.max(a,p):p):"e"===n&&(p=i-e[Im[t]]+P[Im[t]],c.left=a=u(a)?Math.max(a,p):p))})),c}(l,n,o,r,this._eventBus.fire("spaceTool.getMinDimensions",{axis:n,direction:o,shapes:l.resizingShapes,start:r}));return j(t,l,{axis:n,direction:o,spaceToolConstraints:c,start:r}),Zs("resize-"+("x"===n?"ew":"ns")),!0},Hm.prototype.calculateAdjustments=function(e,t,n,i){var r=this._rules,o=[],s=[],a=[],l=[];function c(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&&!hn(e))if(dn(e))l.push(e);else{var o=e[t],p=o+e[Im[t]];if(function(e){return!!e.host}(e)&&(n>0&&bn(e)[t]>i||n<0&&bn(e)[t]<i))a.push(e);else{var u;if(!(n>0&&o>i||n<0&&p<i))return o<i&&p>i&&r.allowed("shape.resize",{shape:e})?(u=e,void(s.includes(u)||s.push(u))):void 0;c(e)}}})),v(o,(function(e){var t=e.attachers;t&&v(t,(function(e){c(e)}))}));var p=o.concat(s);return v(a,(function(e){var t=e.host;Gm(p,t)&&c(e)})),p=o.concat(s),v(l,(function(e){var t=e.source,n=e.target,i=e.label;Gm(p,t)&&Gm(p,n)&&i&&c(i)})),{movingShapes:o,resizingShapes:s}},Hm.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},Hm.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^spaceTool/.test(e.prefix)};var Qm="djs-dragging",Xm="djs-resizing",Km=Math.max;function Ym(e,t,n,i,r){function o(e,t){v(e,(function(e){r.addDragger(e,t),n.addMarker(e,Qm)}))}e.on("spaceTool.selection.start",(function(e){var t=n.getLayer("space"),r=e.context,o="M 0,-10000 L 0,10000",s="M -10000,0 L 10000,0",a=De("g");Oe(a,i.cls("djs-crosshair-group",["no-events"])),xe(t,a);var l=De("path");Oe(l,"d",o),ke(l).add("djs-crosshair"),xe(a,l);var c=De("path");Oe(c,"d",s),ke(c).add("djs-crosshair"),xe(a,c),r.crosshairGroup=a})),e.on("spaceTool.selection.move",(function(e){Kn(e.context.crosshairGroup,e.x,e.y)})),e.on("spaceTool.selection.cleanup",(function(e){var t=e.context.crosshairGroup;t&&He(t)})),e.on("spaceTool.move",250,(function(e){var s=e.context,a=s.line,l=s.axis,c=s.movingShapes,p=s.resizingShapes;if(s.initialized){if(!s.dragGroup){var u=n.getLayer("space");Oe(a=De("path"),"d","M0,0 L0,0"),ke(a).add("djs-crosshair"),xe(u,a),s.line=a;var d=De("g");Oe(d,i.cls("djs-drag-group",["no-events"])),xe(n.getActiveLayer(),d),o(c,d),o(s.movingConnections=t.filter((function(e){var t=!1;v(c,(function(n){v(n.outgoing,(function(n){e===n&&(t=!0)}))}));var n=!1;v(c,(function(t){v(t.incoming,(function(t){e===t&&(n=!0)}))}));var i=!1;v(p,(function(t){v(t.outgoing,(function(t){e===t&&(i=!0)}))}));var r=!1;return v(p,(function(t){v(t.incoming,(function(t){e===t&&(r=!0)}))})),dn(e)&&(t||i)&&(n||r)})),d),s.dragGroup=d}if(!s.frameGroup){var h=De("g");Oe(h,i.cls("djs-frame-group",["no-events"])),xe(n.getActiveLayer(),h);var m=[];v(p,(function(e){var t=r.addFrame(e,h),i=t.getBBox();m.push({element:t,initialBounds:i}),n.addMarker(e,Xm)})),s.frameGroup=h,s.frames=m}Oe(a,{d:{x:"M"+e.x+", -10000 L"+e.x+", 10000",y:"M -10000, "+e.y+" L 10000, "+e.y}[l]});var f={x:e.dx,y:e.dy};f[{x:"y",y:"x"}[s.axis]]=0,Kn(s.dragGroup,f.x,f.y),v(s.frames,(function(e){var t,n,i=e.element,r=e.initialBounds;"e"===s.direction?Oe(i,{width:Km(r.width+f.x,5)}):Oe(i,{width:t=Km(r.width-f.x,5),x:r.x+r.width-t}),"s"===s.direction?Oe(i,{height:Km(r.height+f.y,5)}):Oe(i,{height:n=Km(r.height-f.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,s=t.line,a=t.dragGroup,l=t.frameGroup;v(i,(function(e){n.removeMarker(e,Qm)})),v(r,(function(e){n.removeMarker(e,Qm)})),a&&(He(s),He(a)),v(o,(function(e){n.removeMarker(e,Xm)})),l&&He(l)}))}Ym.$inject=["eventBus","elementRegistry","canvas","styles","previewSupport"];var Zm={__init__:["spaceToolPreview"],__depends__:[Sc,Rc,Nm,zp,hm],spaceTool:["type",Hm],spaceToolPreview:["type",Ym]};function Jm(e){e.invoke(Hm,this)}Jm.$inject=["injector"],e(Jm,Hm),Jm.prototype.calculateAdjustments=function(e,t,n,i){var r=Hm.prototype.calculateAdjustments.call(this,e,t,n,i);return r.resizingShapes=r.resizingShapes.filter((function(e){return!_r(e,"bpmn:TextAnnotation")&&(!function(e){return _r(e,"bpmn:Participant")&&!Or(e).processRef}(e)||!("y"===t&&Fr(e)||"x"===t&&!Fr(e)))})),r};var ef={__depends__:[Zm],spaceTool:["type",Jm]};function tf(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)}tf.$inject=["eventBus","injector"],tf.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()},tf.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},tf.prototype.clear=function(e){this._stack.length=0,this._stackIdx=-1,!1!==e&&this._fire("changed",{trigger:"clear"})},tf.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()}},tf.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()}},tf.prototype.register=function(e,t){this._setHandler(e,t)},tf.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)},tf.prototype.canUndo=function(){return!!this._getUndoAction()},tf.prototype.canRedo=function(){return!!this._getRedoAction()},tf.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]},tf.prototype._getUndoAction=function(){return this._stack[this._stackIdx]},tf.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)}))},tf.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},tf.prototype._createId=function(){return this._uid++},tf.prototype._atomicDo=function(e){const t=this._currentExecution;t.atomic=!0;try{e()}finally{t.atomic=!1}},tf.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()},tf.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)},tf.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:S("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:t}),e.trigger=null)},tf.prototype._markDirty=function(e){const t=this._currentExecution;e&&(e=c(e)?e:[e],t.dirty=t.dirty.concat(e))},tf.prototype._executedAction=function(e,t){const n=++this._stackIdx;t||this._stack.splice(n,this._stack.length,e)},tf.prototype._revertedAction=function(e){this._stackIdx--},tf.prototype._getHandler=function(e){return this._handlerMap[e]},tf.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 nf={commandStack:["type",tf]};function rf(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 of(e,t,n){Fo.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=sf(n),t.validatedShapes=sf(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;rf((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=Pt(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&&(Ot(i.labels,n,r),n.labelTarget=i)}))}function sf(e){return y(e,(function(t){return-1===e.indexOf(t.labelTarget)}))}e(of,Fo),of.$inject=["injector","eventBus","modeling"];var af={__init__:["labelSupport"],labelSupport:["type",of]},lf="attach-ok";function cf(e,t,n,i,r){Fo.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=pf(t=r),C("id",t,n)),i.validatedShapes=function(e){var t=k(e,"id");return y(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(pf(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,lf),t.once(["shape.move.out","shape.move.cleanup"],(function(){n.removeMarker(r,lf)})))}})),this.preExecuted("elements.move",1401,(function(e){var t=e.context,n=t.closure;v(pf(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:y(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;rf(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=sd(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,s=n.attachers;!1!==(t.hints||{}).attachSupport&&v(s,(function(e){var t=sd(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;rf(t.attachers,(function(e){r.removeShape(e)})),t.host&&r.updateAttachment(t,null)}))}function pf(e){return i(E(e,(function(e){return e.attachers||[]})))}e(cf,Fo),cf.$inject=["injector","eventBus","canvas","rules","modeling"];var uf={__depends__:[Rc],__init__:["attachSupport"],attachSupport:["type",cf]};function df(e){this._model=e}function hf(e,t,n){Fo.call(this,e),this._bpmnFactory=t;var i=this;function r(e){v(e.context.oldRoot.children,(function(e){_r(e,"bpmn:BaseElement")&&i.updateParent(e)}))}function o(e){var t=e.context.shape;_r(t,"bpmn:BaseElement")&&i.updateBounds(t)}function s(e){i.updateConnection(e.context)}function a(e){i.updateConnectionWaypoints(e.context.connection)}function l(e){i.updateAttachment(e.context)}function c(e){const{element:n}=e.context,i=eo(n),r=Pr(n),o=r&&r.get("label");Xr(n)||es(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"],mf((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"],mf((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"],mf((function(e){"label"!==e.context.shape.type&&o(e)}))),this.reverted(["shape.move","shape.create","shape.resize"],mf((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"],mf(s)),this.reverted(["connection.create","connection.move","connection.delete","connection.reconnect"],mf(s)),this.executed(["connection.layout","connection.move","connection.updateWaypoints"],mf(a)),this.reverted(["connection.layout","connection.move","connection.updateWaypoints"],mf(a)),this.executed("connection.reconnect",mf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=Or(n),s=Or(i),a=Or(r);o.conditionExpression&&!Er(a,["bpmn:Activity","bpmn:ExclusiveGateway","bpmn:InclusiveGateway"])&&(t.oldConditionExpression=o.conditionExpression,delete o.conditionExpression),i!==r&&s.default===o&&(t.oldDefault=s.default,delete s.default)}))),this.reverted("connection.reconnect",mf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=Or(n),s=Or(i),a=Or(r);t.oldConditionExpression&&(o.conditionExpression=t.oldConditionExpression),t.oldDefault&&(s.default=t.oldDefault,delete a.default)}))),this.executed(["element.updateAttachment"],mf(l)),this.reverted(["element.updateAttachment"],mf(l)),this.executed("element.updateLabel",mf(c)),this.reverted("element.updateLabel",mf(c))}function mf(e){return function(t){var n=t.context;_r(n.shape||n.connection||n.element,"bpmn:BaseElement")&&e(t)}}function ff(e,t){Fn.call(this),this._bpmnFactory=e,this._moddle=t}function gf(e,t,n){return void 0===t[n]?t:(e[n]=t[n],q(t,[n]))}function yf(e,t){this._modeling=e,this._canvas=t}function vf(e){this._modeling=e}function bf(e,t){this._canvas=e,this._layouter=t}df.$inject=["moddle"],df.prototype._needsId=function(e){return Er(e,["bpmn:RootElement","bpmn:FlowElement","bpmn:MessageFlow","bpmn:DataAssociation","bpmn:Artifact","bpmn:Participant","bpmn:Lane","bpmn:LaneSet","bpmn:Process","bpmn:Collaboration","bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane","bpmn:Property","bpmn:CategoryValue"])},df.prototype._ensureId=function(e){var t;e.id?this._model.ids.claim(e.id,e):(t=_r(e,"bpmn:Activity")?"Activity":_r(e,"bpmn:Event")?"Event":_r(e,"bpmn:Gateway")?"Gateway":Er(e,["bpmn:SequenceFlow","bpmn:MessageFlow"])?"Flow":(e.$type||"").replace(/^[^:]*:/g,""),t+="_",!e.id&&this._needsId(e)&&(e.id=this._model.ids.nextPrefixed(t,e)))},df.prototype.create=function(e,t){var n=this._model.create(e,t||{});return this._ensureId(n),n},df.prototype.createDiLabel=function(){return this.create("bpmndi:BPMNLabel",{bounds:this.createDiBounds()})},df.prototype.createDiShape=function(e,t){return this.create("bpmndi:BPMNShape",j({bpmnElement:e,bounds:this.createDiBounds()},t))},df.prototype.createDiBounds=function(e){return this.create("dc:Bounds",e)},df.prototype.createDiWaypoints=function(e){var t=this;return E(e,(function(e){return t.createDiWaypoint(e)}))},df.prototype.createDiWaypoint=function(e){return this.create("dc:Point",L(e,["x","y"]))},df.prototype.createDiEdge=function(e,t){return this.create("bpmndi:BPMNEdge",j({bpmnElement:e,waypoint:this.createDiWaypoints([])},t))},df.prototype.createDiPlane=function(e,t){return this.create("bpmndi:BPMNPlane",j({bpmnElement:e},t))},e(hf,Fo),hf.$inject=["eventBus","bpmnFactory","connectionDocking"],hf.prototype.updateAttachment=function(e){var t=e.shape,n=t.businessObject,i=t.host;n.attachedToRef=i&&i.businessObject},hf.prototype.updateParent=function(e,t){if(!(hn(e)||_r(e,"bpmn:DataStoreReference")&&e.parent&&_r(e.parent,"bpmn:Collaboration"))){var n=e.parent,i=e.businessObject,r=Pr(e),o=n&&n.businessObject,s=Pr(n);_r(e,"bpmn:FlowNode")&&this.updateFlowNodeRefs(i,o,t&&t.businessObject),_r(e,"bpmn:DataOutputAssociation")&&(o=e.source?e.source.businessObject:null),_r(e,"bpmn:DataInputAssociation")&&(o=e.target?e.target.businessObject:null),this.updateSemanticParent(i,o),_r(e,"bpmn:DataObjectReference")&&i.dataObjectRef&&this.updateSemanticParent(i.dataObjectRef,o),this.updateDiParent(r,s)}},hf.prototype.updateBounds=function(e){var t=Pr(e),n=function(e){if(!_r(e,"bpmn:Activity"))return;var t=Pr(e);if(!t)return;var n=t.get("label");if(!n)return;return n.get("bounds")}(e);if(n){var i=ia(n,t.get("bounds"));j(n,{x:e.x+i.x,y:e.y+i.y})}var r=hn(e)?this._getLabel(t):t,o=r.bounds;o||(o=this._bpmnFactory.createDiBounds(),r.set("bounds",o)),j(o,{x:e.x,y:e.y,width:e.width,height:e.height})},hf.prototype.updateFlowNodeRefs=function(e,t,n){n!==t&&(_r(n,"bpmn:Lane")&&Et(n.get("flowNodeRef"),e),_r(t,"bpmn:Lane")&&Ot(t.get("flowNodeRef"),e))},hf.prototype.updateDiConnection=function(e,t,n){var i=Pr(e),r=Pr(t),o=Pr(n);i.sourceElement&&i.sourceElement.bpmnElement!==Or(t)&&(i.sourceElement=t&&r),i.targetElement&&i.targetElement.bpmnElement!==Or(n)&&(i.targetElement=n&&o)},hf.prototype.updateDiParent=function(e,t){if(t&&!_r(t,"bpmndi:BPMNPlane")&&(t=t.$parent),e.$parent!==t){var n=(t||e.$parent).get("planeElement");t?(n.push(e),e.$parent=t):(Et(n,e),e.$parent=null)}},hf.prototype.getLaneSet=function(e){var t,n;return _r(e,"bpmn:Lane")?((t=e.childLaneSet)||(t=this._bpmnFactory.create("bpmn:LaneSet"),e.childLaneSet=t,t.$parent=e),t):(_r(e,"bpmn:Participant")&&(e=e.processRef),(t=(n=e.get("laneSets"))[0])||((t=this._bpmnFactory.create("bpmn:LaneSet")).$parent=e,n.push(t)),t)},hf.prototype.updateSemanticParent=function(e,t,n){var i;if(e.$parent!==t&&(!_r(e,"bpmn:DataInput")&&!_r(e,"bpmn:DataOutput")||(_r(t,"bpmn:Participant")&&"processRef"in t&&(t=t.processRef),!("ioSpecification"in t)||t.ioSpecification!==e.$parent))){if(_r(e,"bpmn:Lane"))t&&(t=this.getLaneSet(t)),i="lanes";else if(_r(e,"bpmn:FlowElement")){if(t)if(_r(t,"bpmn:Participant"))t=t.processRef;else if(_r(t,"bpmn:Lane"))do{t=t.$parent.$parent}while(_r(t,"bpmn:Lane"));i="flowElements"}else if(_r(e,"bpmn:Artifact")){for(;t&&!_r(t,"bpmn:Process")&&!_r(t,"bpmn:SubProcess")&&!_r(t,"bpmn:Collaboration");){if(_r(t,"bpmn:Participant")){t=t.processRef;break}t=t.$parent}i="artifacts"}else if(_r(e,"bpmn:MessageFlow"))i="messageFlows";else if(_r(e,"bpmn:Participant")){i="participants";var r,o=e.processRef;o&&(r=function(e){for(;e&&!_r(e,"bpmn:Definitions");)e=e.$parent;return e}(e.$parent||t),e.$parent&&(Et(r.get("rootElements"),o),o.$parent=null),t&&(Ot(r.get("rootElements"),o),o.$parent=r))}else _r(e,"bpmn:DataOutputAssociation")?i="dataOutputAssociations":_r(e,"bpmn:DataInputAssociation")&&(i="dataInputAssociations");if(!i)throw new Error(`no parent for <${e.id}> in <${t.id}>`);var s;if(e.$parent&&Et(s=e.$parent.get(i),e),t?((s=t.get(i)).push(e),e.$parent=t):e.$parent=null,n){var a=n.get(i);Et(s,e),t&&(a||(a=[],t.set(i,a)),a.push(e))}}},hf.prototype.updateConnectionWaypoints=function(e){Pr(e).set("waypoint",this._bpmnFactory.createDiWaypoints(e.waypoints))},hf.prototype.updateConnection=function(e){var t,n=e.connection,i=Or(n),r=n.source,o=Or(r),s=n.target,a=Or(n.target);if(_r(i,"bpmn:DataAssociation"))_r(i,"bpmn:DataInputAssociation")?(i.get("sourceRef")[0]=o,t=e.parent||e.newParent||a,this.updateSemanticParent(i,a,t)):_r(i,"bpmn:DataOutputAssociation")&&(t=e.parent||e.newParent||o,this.updateSemanticParent(i,o,t),i.targetRef=a);else{var l=_r(i,"bpmn:SequenceFlow");i.sourceRef!==o&&(l&&(Et(i.sourceRef&&i.sourceRef.get("outgoing"),i),o&&o.get("outgoing")&&o.get("outgoing").push(i)),i.sourceRef=o),i.targetRef!==a&&(l&&(Et(i.targetRef&&i.targetRef.get("incoming"),i),a&&a.get("incoming")&&a.get("incoming").push(i)),i.targetRef=a)}this.updateConnectionWaypoints(n),this.updateDiConnection(n,r,s)},hf.prototype._getLabel=function(e){return e.label||(e.label=this._bpmnFactory.createDiLabel()),e.label},e(ff,Fn),ff.$inject=["bpmnFactory","moddle"],ff.prototype._baseCreate=Fn.prototype.create,ff.prototype.create=function(e,t){if("label"===e){var n=t.di||this._bpmnFactory.createDiLabel();return this._baseCreate(e,j({type:"label",di:n},Gr,t))}return this.createElement(e,t)},ff.prototype.createElement=function(e,t){var n,i,r,o=(t=j({},t||{})).businessObject,s=t.di;if(!o){if(!t.type)throw new Error("no shape type specified");br(o=this._bpmnFactory.create(t.type))}if(!Er(s,["bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane"])){var l=j({},s||{},{id:o.id+"_di"});s="root"===e?this._bpmnFactory.createDiPlane(o,l):"connection"===e?this._bpmnFactory.createDiEdge(o,l):this._bpmnFactory.createDiShape(o,l)}return _r(o,"bpmn:Group")&&(t=j({isFrame:!0},t)),t=function(e,t,n){return v(n,(function(n){t=gf(e,t,n)})),t}(o,t,["processRef","isInterrupting","associationDirection","isForCompensation"]),t.isExpanded&&(t=gf(s,t,"isExpanded")),Er(o,["bpmn:Lane","bpmn:Participant"])&&(t=gf(s,t,"isHorizontal")),_r(o,"bpmn:SubProcess")&&(t.collapsed=!Vr(o,s)),_r(o,"bpmn:ExclusiveGateway")&&(m(s,"isMarkerVisible")?void 0===s.isMarkerVisible&&(s.isMarkerVisible=!1):s.isMarkerVisible=!0),a(t.triggeredByEvent)&&(o.triggeredByEvent=t.triggeredByEvent,delete t.triggeredByEvent),a(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,s),t=j({id:o.id},n,t,{businessObject:o,di:s}),this._baseCreate(e,t)},ff.prototype.getDefaultSize=function(e,t){var n=Or(e);if(t=t||Pr(e),_r(n,"bpmn:SubProcess"))return Vr(n,t)?{width:350,height:200}:{width:100,height:80};if(_r(n,"bpmn:Task"))return{width:100,height:80};if(_r(n,"bpmn:Gateway"))return{width:50,height:50};if(_r(n,"bpmn:Event"))return{width:36,height:36};if(_r(n,"bpmn:Participant")){var i=void 0===t.isHorizontal||!0===t.isHorizontal;return Vr(n,t)?i?{width:600,height:250}:{width:250,height:600}:i?{width:400,height:60}:{width:60,height:400}}return _r(n,"bpmn:Lane")?{width:400,height:100}:_r(n,"bpmn:DataObjectReference")?{width:36,height:50}:_r(n,"bpmn:DataStoreReference")?{width:50,height:50}:_r(n,"bpmn:TextAnnotation")?{width:100,height:30}:_r(n,"bpmn:Group")?{width:300,height:300}:{width:100,height:80}},ff.prototype.createParticipantShape=function(e){return p(e)||(e={isExpanded:e}),!1!==(e=j({type:"bpmn:Participant"},e||{})).isExpanded&&(e.processRef=this._bpmnFactory.create("bpmn:Process")),this.createShape(e)},yf.$inject=["modeling","canvas"],yf.prototype.preExecute=function(e){var t=this._modeling,n=e.elements,i=e.alignment;v(n,(function(e){var n={x:0,y:0};a(i.left)?n.x=i.left-e.x:a(i.right)?n.x=i.right-e.width-e.x:a(i.center)?n.x=i.center-Math.round(e.width/2)-e.x:a(i.top)?n.y=i.top-e.y:a(i.bottom)?n.y=i.bottom-e.height-e.y:a(i.middle)&&(n.y=i.middle-Math.round(e.height/2)-e.y),t.moveElements([e],n,e.parent)}))},yf.prototype.postExecute=function(e){},vf.$inject=["modeling"],vf.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},vf.prototype.postExecute=function(e){var t,n,i=e.hints||{};t=e.source,n=e.shape,_(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))},bf.$inject=["canvas","layouter"],bf.prototype.execute=function(e){var t=e.connection,n=e.source,i=e.target,r=e.parent,o=e.parentIndex,s=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,s)),this._canvas.addConnection(t,r,o),t},bf.prototype.revert=function(e){var t=e.connection;return this._canvas.removeConnection(t),t.source=null,t.target=null,t};var xf=Math.round;function wf(e){this._modeling=e}wf.$inject=["modeling"],wf.prototype.preExecute=function(e){var t=e.elements,n=e.parent,i=e.parentIndex,r=e.position,o=e.hints,s=this._modeling;v(t,(function(e){u(e.x)||(e.x=0),u(e.y)||(e.y=0)}));var a=yt(y(t,(function(e){return!e.hidden})));v(t,(function(e){dn(e)&&(e.waypoints=E(e.waypoints,(function(e){return{x:xf(e.x-a.x-a.width/2+r.x),y:xf(e.y-a.y-a.height/2+r.y)}}))),j(e,{x:xf(e.x-a.x-a.width/2+r.x),y:xf(e.y-a.y-a.height/2+r.y)})}));var l=dt(t),c={};v(t,(function(e){if(dn(e))c[e.id]=u(i)?s.createConnection(c[e.source.id],c[e.target.id],i,e,e.parent||n,o):s.createConnection(c[e.source.id],c[e.target.id],e,e.parent||n,o);else{var t=j({},o);-1===l.indexOf(e)&&(t.autoResize=!1),hn(e)&&(t=q(t,["attach"])),c[e.id]=u(i)?s.createShape(e,L(e,["x","y","width","height"]),e.parent||n,i,t):s.createShape(e,L(e,["x","y","width","height"]),e.parent||n,t)}})),e.elements=P(c)};var _f=Math.round;function Ef(e){this._canvas=e}function Of(e){Ef.call(this,e)}Ef.$inject=["canvas"],Ef.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?j(t,n):j(t,{x:n.x-_f(t.width/2),y:n.y-_f(t.height/2)}),this._canvas.addShape(t,i,r),t},Ef.prototype.revert=function(e){var t=e.shape;return this._canvas.removeShape(t),t},e(Of,Ef),Of.$inject=["canvas"];var Pf=Ef.prototype.execute;Of.prototype.execute=function(e){var t=e.shape;return function(e){["width","height"].forEach((function(t){void 0===e[t]&&(e[t]=0)}))}(t),t.labelTarget=e.labelTarget,Pf.call(this,e)};var kf=Ef.prototype.revert;function Sf(e,t){this._canvas=e,this._modeling=t}function Cf(e,t){this._modeling=e,this._elementRegistry=t}function Af(e,t){this._canvas=e,this._modeling=t}function Mf(e){this._modeling=e}Of.prototype.revert=function(e){return e.shape.labelTarget=null,kf.call(this,e)},Sf.$inject=["canvas","modeling"],Sf.prototype.preExecute=function(e){var t=this._modeling,n=e.connection;rf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),rf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})}))},Sf.prototype.execute=function(e){var t=e.connection,n=t.parent;return e.parent=n,e.parentIndex=Pt(n.children,t),e.source=t.source,e.target=t.target,this._canvas.removeConnection(t),t.source=null,t.target=null,t},Sf.prototype.revert=function(e){var t=e.connection,n=e.parent,i=e.parentIndex;return t.source=e.source,t.target=e.target,Ot(n.children,t,i),this._canvas.addConnection(t,n),t},Cf.$inject=["modeling","elementRegistry"],Cf.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))}))},Af.$inject=["canvas","modeling"],Af.prototype.preExecute=function(e){var t=this._modeling,n=e.shape;rf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),rf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})})),rf(n.children,(function(e){dn(e)?t.removeConnection(e,{nested:!0}):t.removeShape(e,{nested:!0})}))},Af.prototype.execute=function(e){var t=this._canvas,n=e.shape,i=n.parent;return e.oldParent=i,e.oldParentIndex=Pt(i.children,n),t.removeShape(n),n},Af.prototype.revert=function(e){var t=this._canvas,n=e.shape,i=e.oldParent,r=e.oldParentIndex;return Ot(i.children,n,r),t.addShape(n,i),n},Mf.$inject=["modeling"];var Tf={x:"y",y:"x"};function Rf(e,t){this._layouter=e,this._canvas=t}function Df(){}function Nf(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}function Bf(e){this._modeling=e}function $f(e){this._helper=new Bf(e)}function jf(e){this._modeling=e,this._helper=new Bf(e)}function If(e){this._modeling=e}function Lf(e){return e.original||e}function qf(e,t){this._modeling=e,this._rules=t}function zf(e){this._modeling=e}function Vf(e){this._modeling=e}function Ff(e){return j({},e)}function Hf(e){switch(e){case"n":case"s":return"y";case"w":case"e":return"x"}}function Uf(e,t,n){var i=Hf(n);return/e|s/.test(n)?e[i]>t:/n|w/.test(n)?e[i]<t:void 0}function Wf(e,t){return-1!==e.indexOf(t)}function Gf(e){this._modeling=e}function Qf(e){var t={};return v(e,(function(e){t[e.id]=e.hidden,e.children&&(t=j({},t,Qf(e.children)))})),t}function Xf(e,t){var n=[];return v(e,(function(e){e.hidden=t,n=n.concat(e),e.children&&(n=n.concat(Xf(e.children,e.collapsed||t)))})),n}function Kf(e,t){var n=[];return v(e,(function(e){e.hidden=t[e.id],n=n.concat(e),e.children&&(n=n.concat(Kf(e.children,t)))})),n}function Yf(e){this._modeling=e}function Zf(e,t){return Et(e&&e.attachers,t)}function Jf(e,t,n){if(e){var i=e.attachers;i||(e.attachers=i=[]),Ot(i,t,n)}}function eg(){}function tg(e,t,n){this._eventBus=e,this._elementFactory=t,this._commandStack=n;var i=this;e.on("diagram.init",(function(){i.registerHandlers(n)}))}function ng(e){this._elementRegistry=e}function ig(e,t){v(t,(function(t,n){e.set(n,t)}))}Mf.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 s(e){return e[i]+e[r]/2}function a(e){return e.length-1}function l(e){return e.max-e.min}var c,p,u=n[0],d=a(n),h=n[d],m=0;v(n,(function(e,c){var p,u,h;e.elements.length<2?c&&c!==n.length-1&&(o(e,e.elements[0]),m+=l(e.range)):(u=(p=A(e.elements,i))[0],c===d&&(u=p[a(p)]),h=s(u),e.range=null,v(p,(function(n){!function(e,n){var r={y:0};r[i]=e-s(n),r[i]&&(r[Tf[i]]=0,t.moveElements([n],r,n.parent))}(h,n),null!==e.range?o(e,n):e.range={min:n[i],max:n[i]+n[r]}})),c&&c!==n.length-1&&(m+=l(e.range)))})),p=Math.abs(h.range.min-u.range.max),(c=Math.round((p-m)/(n.length-1)))<n.length-1||v(n,(function(e,o){var s,a={};e!==u&&e!==h&&(s=n[o-1],e.range.max=0,v(e.elements,(function(n,o){a[Tf[i]]=0,a[i]=s.range.max-n[i]+c,e.range.min!==n[i]&&(a[i]+=n[i]-e.range.min),a[i]&&t.moveElements([n],a,n.parent),e.range.max=Math.max(n[i]+n[r],o?e.range.max:0)})))}))},Mf.prototype.postExecute=function(e){},Rf.$inject=["layouter","canvas"],Rf.prototype.execute=function(e){var t=e.connection;return j(e,{oldWaypoints:t.waypoints}),t.waypoints=this._layouter.layoutConnection(t,e.hints),t},Rf.prototype.revert=function(e){var t=e.connection;return t.waypoints=e.oldWaypoints,t},Df.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=Et(o.children,t),Ot(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},Df.prototype.revert=function(e){var t=e.connection,n=t.parent,i=e.oldParent,r=e.oldParentIndex,o=e.delta;return Et(n.children,t),Ot(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},Nf.prototype.add=function(e,t){return this.addAll([e],t)},Nf.prototype.addAll=function(e,t){var n=function(e,t,n){s(t)&&(t=!0),p(t)&&(n=t,t=!0);var i=xt((n=n||{}).allShapes),r=xt(n.allConnections),o=xt(n.enclosedElements),a=xt(n.enclosedConnections),l=xt(n.topLevel,t&&k(e,(function(e){return e.id})));function c(e){l[e.source.id]&&l[e.target.id]&&(l[e.id]=[e]),i[e.source.id]&&i[e.target.id]&&(a[e.id]=o[e.id]=e),r[e.id]=e}return ft(e,(function(e){if(o[e.id]=e,!e.waypoints)return i[e.id]=e,v(e.incoming,c),v(e.outgoing,c),e.children;a[e.id]=r[e.id]=e})),{allShapes:i,allConnections:r,topLevel:l,enclosedConnections:a,enclosedElements:o}}(e,!!t,this);return j(this,n),this},Bf.prototype.moveRecursive=function(e,t,n){return e?this.moveClosure(this.getClosure(e),t,n):[]},Bf.prototype.moveClosure=function(e,t,n,i,r){var o=this._modeling,s=e.allShapes,a=e.allConnections,l=e.enclosedConnections,c=e.topLevel,p=!1;r&&r.parent===n&&(p=!0),v(s,(function(e){o.moveShape(e,t,c[e.id]&&!p&&n,{recurse:!1,layout:!1})})),v(a,(function(e){var i=!!s[e.source.id],r=!!s[e.target.id];l[e.id]&&i&&r?o.moveConnection(e,t,c[e.id]&&!p&&n):o.layoutConnection(e,{connectionStart:i&&md(e,e.source,t),connectionEnd:r&&fd(e,e.target,t)})}))},Bf.prototype.getClosure=function(e){return(new Nf).addAll(e,!0)},$f.$inject=["modeling"],$f.prototype.preExecute=function(e){e.closure=this._helper.getClosure(e.shapes)},$f.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)},jf.$inject=["modeling"],jf.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=L(t,["x","y","width","height"]),e.oldParent=o,e.oldParentIndex=Et(o.children,t),Ot(i.children,t,r),j(t,{parent:i,x:t.x+n.x,y:t.y+n.y}),t},jf.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:fd(e,t,n)})})),v(t.outgoing,(function(e){r.layoutConnection(e,{connectionStart:md(e,t,n)})}))),!1!==i.recurse&&this.moveChildren(e)},jf.prototype.revert=function(e){var t=e.shape,n=e.oldParent,i=e.oldParentIndex,r=e.delta;return Ot(n.children,t,i),j(t,{parent:n,x:t.x-r.x,y:t.y-r.y}),t},jf.prototype.moveChildren=function(e){var t=e.delta,n=e.shape;this._helper.moveRecursive(n.children,t,null)},jf.prototype.getNewParent=function(e){return e.newParent||e.shape.parent},If.$inject=["modeling"],If.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 c(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},If.prototype.postExecute=function(e){var t=e.connection,n=e.newSource,i=e.newTarget,r=e.dockingOrPoints,o=e.hints||{},s={};o.connectionStart&&(s.connectionStart=o.connectionStart),o.connectionEnd&&(s.connectionEnd=o.connectionEnd),!1!==o.layoutConnection&&(!n||i&&"source"!==o.docking||(s.connectionStart=s.connectionStart||Lf(c(r)?r[0]:r)),!i||n&&"target"!==o.docking||(s.connectionEnd=s.connectionEnd||Lf(c(r)?r[r.length-1]:r)),o.newWaypoints&&(s.waypoints=o.newWaypoints),this._modeling.layoutConnection(t,s))},If.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},qf.$inject=["modeling","rules"],qf.prototype.preExecute=function(e){var t,n=this,i=this._modeling,r=this._rules,o=e.oldShape,s=e.newData,a=e.hints||{};function l(e,t,n){return r.allowed("connection.reconnect",{connection:n,source:e,target:t})}var c,p={x:s.x,y:s.y},u={x:o.x,y:o.y,width:o.width,height:o.height};t=e.newShape=e.newShape||n.createShape(s,p,o.parent,a),o.host&&i.updateAttachment(t,o.host),!1!==a.moveChildren&&(c=o.children.slice(),i.moveElements(c,{x:0,y:0},t,a));var d=o.incoming.slice(),h=o.outgoing.slice();v(d,(function(e){l(e.source,t,e)&&n.reconnectEnd(e,t,hd(e,t,u),a)})),v(h,(function(e){var i=e.target;l(t,i,e)&&n.reconnectStart(e,t,dd(e,t,u),a)}))},qf.prototype.postExecute=function(e){var t=e.oldShape;this._modeling.removeShape(t)},qf.prototype.execute=function(e){},qf.prototype.revert=function(e){},qf.prototype.createShape=function(e,t,n,i){return this._modeling.createShape(e,t,n,i)},qf.prototype.reconnectStart=function(e,t,n,i){this._modeling.reconnectStart(e,t,n,i)},qf.prototype.reconnectEnd=function(e,t,n,i){this._modeling.reconnectEnd(e,t,n,i)},zf.$inject=["modeling"],zf.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},j(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},zf.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:hd(e,n,i)})})),v(n.outgoing,(function(e){t.layoutConnection(e,{connectionStart:dd(e,n,i)})})))},zf.prototype.revert=function(e){var t=e.shape,n=e.oldBounds;return j(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Vf.$inject=["modeling"],Vf.prototype.preExecute=function(e){var t=e.delta,n=e.direction,i=e.movingShapes,r=e.resizingShapes,o=e.start,s={};this.moveShapes(i,t),v(r,(function(e){s[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;(Bm(e,r)||Bm(e,o)||Bm(t,r)||Bm(t,o))&&(Bm(n,i)||n.push(i))}))})),n}(i,r),t,n,o,i,r,s)},Vf.prototype.execute=function(){},Vf.prototype.revert=function(){},Vf.prototype.moveShapes=function(e,t){var n=this;v(e,(function(e){n._modeling.moveShape(e,t,null,{autoResize:!1,layout:!1,recurse:!1})}))},Vf.prototype.resizeShapes=function(e,t,n){var i=this;v(e,(function(e){var r=function(e,t,n){var i=e.x,r=e.y,o=e.width,s=e.height,a=n.x,l=n.y;switch(t){case"n":return{x:i,y:r+l,width:o,height:s-l};case"s":return{x:i,y:r,width:o,height:s+l};case"w":return{x:i+a,y:r,width:o-a,height:s};case"e":return{x:i,y:r,width:o+a,height:s};default:throw new Error("unknown direction: "+t)}}(e,n,t);i._modeling.resizeShape(e,r,null,{attachSupport:!1,autoResize:!1,layout:!1})}))},Vf.prototype.updateConnectionWaypoints=function(e,t,n,i,r,o,s){var a=this,l=r.concat(o);v(e,(function(e){var c=e.source,p=e.target,u=function(e){return E(e.waypoints,(function(e){return(e=Ff(e)).original&&(e.original=Ff(e.original)),e}))}(e),d=Hf(n),h={};Wf(l,c)&&Wf(l,p)?(u=E(u,(function(e){return Uf(e,i,n)&&(e[d]=e[d]+t[d]),e.original&&Uf(e.original,i,n)&&(e.original[d]=e.original[d]+t[d]),e})),a._modeling.updateWaypoints(e,u,{labelBehavior:!1})):(Wf(l,c)||Wf(l,p))&&(Wf(r,c)?h.connectionStart=md(e,c,t):Wf(r,p)?h.connectionEnd=fd(e,p,t):Wf(o,c)?h.connectionStart=dd(e,c,s[c.id]):Wf(o,p)&&(h.connectionEnd=hd(e,p,s[p.id])),a._modeling.layoutConnection(e,h))}))},Gf.$inject=["modeling"],Gf.prototype.execute=function(e){var t=e.shape,n=t.children;e.oldChildrenVisibility=Qf(n),t.collapsed=!t.collapsed;var i=Xf(n,t.collapsed);return[t].concat(i)},Gf.prototype.revert=function(e){var t=e.shape,n=e.oldChildrenVisibility,i=Kf(t.children,n);return t.collapsed=!t.collapsed,[t].concat(i)},Yf.$inject=["modeling"],Yf.prototype.execute=function(e){var t=e.shape,n=e.newHost,i=t.host;return e.oldHost=i,e.attacherIdx=Zf(i,t),Jf(n,t),t.host=n,t},Yf.prototype.revert=function(e){var t=e.shape,n=e.newHost,i=e.oldHost,r=e.attacherIdx;return t.host=i,Zf(n,t),Jf(i,t,r),t},eg.prototype.execute=function(e){var t=e.connection,n=e.newWaypoints;return e.oldWaypoints=t.waypoints,t.waypoints=n,t},eg.prototype.revert=function(e){var t=e.connection,n=e.oldWaypoints;return t.waypoints=n,t},tg.$inject=["eventBus","elementFactory","commandStack"],tg.prototype.getHandlers=function(){return{"shape.append":vf,"shape.create":Ef,"shape.delete":Af,"shape.move":jf,"shape.resize":zf,"shape.replace":qf,"shape.toggleCollapse":Gf,spaceTool:Vf,"label.create":Of,"connection.create":bf,"connection.delete":Sf,"connection.move":Df,"connection.layout":Rf,"connection.updateWaypoints":eg,"connection.reconnect":If,"elements.create":wf,"elements.move":$f,"elements.delete":Cf,"elements.distribute":Mf,"elements.align":yf,"element.updateAttachment":Yf}},tg.prototype.registerHandlers=function(e){v(this.getHandlers(),(function(t,n){e.registerHandler(n,t)}))},tg.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)},tg.prototype.updateAttachment=function(e,t){var n={shape:e,newHost:t};this._commandStack.execute("element.updateAttachment",n)},tg.prototype.moveElements=function(e,t,n,i){var r,o=(i=i||{}).attach,s=n;!0===o?(r=n,s=n.parent):!1===o&&(r=null);var a={shapes:e,delta:t,newParent:s,newHost:r,hints:i};this._commandStack.execute("elements.move",a)},tg.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)},tg.prototype.layoutConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.layout",n)},tg.prototype.createConnection=function(e,t,n,i,r,o){"object"==typeof n&&(o=r,r=i,i=n,n=void 0);var s={source:e,target:t,parent:r,parentIndex:n,connection:i=this._create("connection",i),hints:o};return this._commandStack.execute("connection.create",s),s.connection},tg.prototype.createShape=function(e,t,n,i,r){"number"!=typeof i&&(r=i,i=void 0);var o,s,a=(r=r||{}).attach;e=this._create("shape",e),a?(o=n.parent,s=n):o=n;var l={position:t,shape:e,parent:o,parentIndex:i,host:s,hints:r};return this._commandStack.execute("shape.create",l),l.shape},tg.prototype.createElements=function(e,t,n,i,r){c(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},tg.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},tg.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},tg.prototype.removeElements=function(e){var t={elements:e};this._commandStack.execute("elements.delete",t)},tg.prototype.distributeElements=function(e,t,n){var i={groups:e,axis:t,dimension:n};this._commandStack.execute("elements.distribute",i)},tg.prototype.removeShape=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.delete",n)},tg.prototype.removeConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.delete",n)},tg.prototype.replaceShape=function(e,t,n){var i={oldShape:e,newData:t,hints:n||{}};return this._commandStack.execute("shape.replace",i),i.newShape},tg.prototype.alignElements=function(e,t){var n={elements:e,alignment:t};this._commandStack.execute("elements.align",n)},tg.prototype.resizeShape=function(e,t,n,i){var r={shape:e,newBounds:t,minBounds:n,hints:i};this._commandStack.execute("shape.resize",r)},tg.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)},tg.prototype.updateWaypoints=function(e,t,n){var i={connection:e,newWaypoints:t,hints:n||{}};this._commandStack.execute("connection.updateWaypoints",i)},tg.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)},tg.prototype.reconnectStart=function(e,t,n,i){i||(i={}),this.reconnect(e,t,e.target,n,j(i,{docking:"source"}))},tg.prototype.reconnectEnd=function(e,t,n,i){i||(i={}),this.reconnect(e,e.source,t,n,j(i,{docking:"target"}))},tg.prototype.connect=function(e,t,n,i){return this.createConnection(e,t,n||{},e.parent,i)},tg.prototype._create=function(e,t){return t instanceof jn?t:this._elementFactory.create(e,t)},tg.prototype.toggleCollapse=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.toggleCollapse",n)},ng.$inject=["elementRegistry"],ng.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 x(t,(function(t,n){return t[n]=e.get(n),t}),{})}(n,O(i));return ig(n,i),e.oldProperties=o,e.changed=r,r},ng.prototype.revert=function(e){var t=e.oldProperties,n=e.moddleElement,i=e.changed;return ig(n,t),i},ng.prototype._getVisualReferences=function(e){var t=this._elementRegistry;return _r(e,"bpmn:DataObject")?function(e,t){return t.filter((function(t){return _r(t,"bpmn:DataObjectReference")&&Or(t).dataObjectRef===e}))}(e,t):[]};var rg="default",og="id",sg="di",ag={width:0,height:0};function lg(e,t,n,i){this._elementRegistry=e,this._moddle=t,this._modeling=n,this._textRenderer=i}function cg(e,t){return og in e&&e[og]!==t[og]}function pg(e,t){var n=e.businessObject,i=Pr(e);v(t,(function(e,t){t!==sg?n.set(t,e):i&&function(e,t){v(t,(function(t,n){e.set(n,t)}))}(i,e)}))}lg.$inject=["elementRegistry","moddle","modeling","textRenderer"],lg.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,s=function(e){var t=j({},e);return ug.forEach((function(n){n in e&&(t[n]=Or(t[n]))})),t}(e.properties),a=e.oldProperties||function(e,t){var n=O(t),i=e.businessObject,r=Pr(e);return x(n,(function(e,n){return e[n]=n!==sg?i.get(n):function(e,t){return x(t,(function(t,n){return t[n]=e&&e.get(n),t}),{})}(r,O(t.di)),e}),{})}(t,s);return cg(s,o)&&(r.unclaim(o[og]),i.updateId(t,s[og]),r.claim(s[og],o)),rg in s&&(s[rg]&&n.push(i.get(s[rg].id)),o[rg]&&n.push(i.get(o[rg].id))),pg(t,s),e.oldProperties=a,e.changed=n,n},lg.prototype.postExecute=function(e){var t=e.element.label,n=t&&Or(t).name;if(n){var i=this._textRenderer.getExternalLabelBounds(t,n);this._modeling.resizeShape(t,i,ag)}},lg.prototype.revert=function(e){var t=e.element,n=e.properties,i=e.oldProperties,r=t.businessObject,o=this._elementRegistry,s=this._moddle.ids;return pg(t,i),cg(n,r)&&(s.unclaim(n[og]),o.updateId(t,i[og]),s.claim(i[og],r)),e.changed};var ug=["default"];function dg(e,t){this._canvas=e,this._modeling=t}function hg(e,t){this._modeling=e,this._spaceTool=t}function mg(e){this._modeling=e}function fg(e,t){this._modeling=e,this._spaceTool=t}dg.$inject=["canvas","modeling"],dg.prototype.execute=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,r=t.getRootElement(),o=r.businessObject,s=o.$parent,a=Pr(r);return t.setRootElement(n),t.removeRootElement(r),Ot(s.rootElements,i),i.$parent=s,Et(s.rootElements,o),o.$parent=null,r.di=null,a.bpmnElement=i,n.di=a,e.oldRoot=r,[]},dg.prototype.revert=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,r=e.oldRoot,o=r.businessObject,s=i.$parent,a=Pr(n);return t.setRootElement(r),t.removeRootElement(n),Et(s.rootElements,i),i.$parent=null,Ot(s.rootElements,o),o.$parent=s,n.di=null,a.bpmnElement=o,r.di=a,[]},hg.$inject=["modeling","spaceTool"],hg.prototype.preExecute=function(e){var t=this._spaceTool,n=this._modeling,i=e.shape,r=e.location,o=Au(i),s=o===i,a=s?i:i.parent,l=Cu(a),c=Fr(i);if(c?"left"===r?r="top":"right"===r&&(r="bottom"):"top"===r?r="left":"bottom"===r&&(r="right"),!l.length){var p=c?{x:i.x+ku,y:i.y,width:i.width-ku,height:i.height}:{x:i.x,y:i.y+ku,width:i.width,height:i.height-ku};n.createShape({type:"bpmn:Lane",isHorizontal:c},p,a)}var u,d,h,m,f,g=[];ft(o,(function(e){return g.push(e),e.label&&g.push(e.label),e===i?[]:y(e.children,(function(e){return e!==i}))})),"top"===r?(u=-120,h=(d=i.y)+10,m="n",f="y"):"left"===r?(u=-120,h=(d=i.x)+10,m="w",f="x"):"bottom"===r?(u=120,h=(d=i.y+i.height)-10,m="s",f="y"):"right"===r&&(u=120,h=(d=i.x+i.width)-10,m="e",f="x");var v=t.calculateAdjustments(g,f,u,h),b=c?{x:0,y:u}:{x:u,y:0};t.makeSpace(v.movingShapes,v.resizingShapes,b,m,h);var x=c?{x:i.x+(s?ku:0),y:d-("top"===r?120:0),width:i.width-(s?ku:0),height:120}:{x:d-("left"===r?120:0),y:i.y+(s?ku:0),width:120,height:i.height-(s?ku:0)};e.newLane=n.createShape({type:"bpmn:Lane",isHorizontal:c},x,a)},mg.$inject=["modeling"],mg.prototype.preExecute=function(e){var t=this._modeling,n=e.shape,i=e.count,r=Cu(n),o=r.length;if(o>i)throw new Error(`more than <${i}> child lanes`);var s,a,l,c,p=Fr(n),u=p?n.height:n.width,d=Math.round(u/i);for(c=0;c<i;c++)s=c===i-1?u-d*c:d,a=p?{x:n.x+ku,y:n.y+c*d,width:n.width-ku,height:s}:{x:n.x+c*d,y:n.y+ku,width:s,height:n.height-ku},c<o?t.resizeShape(r[c],a):(l={type:"bpmn:Lane",isHorizontal:p},t.createShape(l,a,n))},fg.$inject=["modeling","spaceTool"],fg.prototype.preExecute=function(e){var t=e.shape,n=e.newBounds;!1!==e.balanced?this.resizeBalanced(t,n):this.resizeSpace(t,n)},fg.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)}))},fg.prototype.resizeSpace=function(e,t){var n,i,r,o,s,a=this._spaceTool,l=gn(e),c=bu(gn(t),l),p=Au(e),u=[],d=[];ft(p,(function(e){return u.push(e),(_r(e,"bpmn:Lane")||_r(e,"bpmn:Participant"))&&d.push(e),e.children})),(c.bottom||c.top)&&(n=c.bottom||c.top,i=e.y+(c.bottom?e.height:0)+(c.bottom?-10:10),r=c.bottom?"s":"n",o=c.top>0||c.bottom<0?-n:n,s=a.calculateAdjustments(u,"y",o,i),a.makeSpace(s.movingShapes,s.resizingShapes,{x:0,y:n},r)),(c.left||c.right)&&(n=c.right||c.left,i=e.x+(c.right?e.width:0)+(c.right?-10:100),r=c.right?"e":"w",o=c.left>0||c.right<0?-n:n,s=a.calculateAdjustments(d,"x",o,i),a.makeSpace(s.movingShapes,s.resizingShapes,{x:n,y:0},r))};var gg="flowNodeRef",yg="lanes";function vg(e){this._elementRegistry=e}function bg(e){this._moddle=e}vg.$inject=["elementRegistry"],vg.prototype._computeUpdates=function(e,t){var n=[],i=[],r={},o=[];function s(e){-1===n.indexOf(e)&&(o.push(e),n.push(e))}function a(e){if(!e.parent)return[];var t=function(e){var t=Au(e);return r[t.id]||(r[t.id]=Su(t)),r[t.id]}(e);return t.filter((function(t){return n=e,i=gn(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=Au(e);if(t&&-1===n.indexOf(t)){var i=t.children.filter((function(e){return _r(e,"bpmn:FlowNode")}));i.forEach(s),n.push(t)}})),e.forEach(s),o.forEach((function(e){var t=e.businessObject,n=t.get(yg).slice(),r=a(e);i.push({flowNode:t,remove:n,add:r})})),t.forEach((function(e){var t=e.businessObject;e.parent||t.get(gg).forEach((function(e){i.push({flowNode:e,remove:[t],add:[]})}))})),i},vg.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(yg);e.remove.forEach((function(e){Et(n,e),Et(e.get(gg),t)})),e.add.forEach((function(e){Ot(n,e),Ot(e.get(gg),t)}))})),[]},vg.prototype.revert=function(e){return e.updates.forEach((function(e){var t=e.flowNode,n=t.get(yg);e.add.forEach((function(e){Et(n,e),Et(e.get(gg),t)})),e.remove.forEach((function(e){Ot(n,e),Ot(e.get(gg),t)}))})),[]},bg.$inject=["moddle"],bg.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),[]},bg.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 xg={fill:void 0,stroke:void 0};function wg(e){this._commandStack=e,this._normalizeColor=function(e){if(e){if(h(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}`)}}}wg.$inject=["commandStack"],wg.prototype.postExecute=function(e){var t=e.elements,n=e.colors||xg,i=this,r={};"fill"in n&&j(r,{"background-color":this._normalizeColor(n.fill)}),"stroke"in n&&j(r,{"border-color":this._normalizeColor(n.stroke)}),v(t,(function(e){var t=dn(e)?L(r,["border-color"]):r,n=Pr(e);if(function(e){"border-color"in e&&(e.stroke=e["border-color"]);"background-color"in e&&(e.fill=e["background-color"])}(t),hn(e))i._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:n.label,properties:{color:r["border-color"]}});else{if(!Er(n,["bpmndi:BPMNEdge","bpmndi:BPMNShape"]))return;i._commandStack.execute("element.updateProperties",{element:e,properties:{di:t}})}}))};var _g={width:0,height:0};function Eg(e,t,n){function i(e,t){var n=e.label||e,i=e.labelTarget||e;return to(n,t),[n,i]}this.preExecute=function(t){var n=t.element,i=n.businessObject,r=t.newLabel;if(!hn(n)&&Xr(n)&&!Kr(n)&&!Og(r)){var o=Zr(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=eo(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,s=n.newBounds,a=n.hints||{};if(hn(r)||_r(r,"bpmn:TextAnnotation"))if(hn(r)&&Og(o))!1!==a.removeShape&&e.removeShape(r,{unsetLabel:!1});else{var l=eo(i);void 0===s&&(s=t.getExternalLabelBounds(r,l)),s&&e.resizeShape(r,s,_g)}}}function Og(e){return!e||!e.trim()}function Pg(e,t,n,i){tg.call(this,e,t,n),this._bpmnRules=i}function kg(){}Eg.$inject=["modeling","textRenderer","bpmnFactory"],e(Pg,tg),Pg.$inject=["eventBus","elementFactory","commandStack","bpmnRules"],Pg.prototype.getHandlers=function(){var e=tg.prototype.getHandlers.call(this);return e["element.updateModdleProperties"]=ng,e["element.updateProperties"]=lg,e["canvas.updateRoot"]=dg,e["lane.add"]=hg,e["lane.resize"]=fg,e["lane.split"]=mg,e["lane.updateRefs"]=vg,e["id.updateClaim"]=bg,e["element.setColor"]=wg,e["element.updateLabel"]=Eg,e},Pg.prototype.updateLabel=function(e,t,n,i){this._commandStack.execute("element.updateLabel",{element:e,newLabel:t,newBounds:n,hints:i||{}})},Pg.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)},Pg.prototype.updateModdleProperties=function(e,t,n){this._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:t,properties:n})},Pg.prototype.updateProperties=function(e,t){this._commandStack.execute("element.updateProperties",{element:e,properties:t})},Pg.prototype.resizeLane=function(e,t,n){this._commandStack.execute("lane.resize",{shape:e,newBounds:t,balanced:n})},Pg.prototype.addLane=function(e,t){var n={shape:e,location:t};return this._commandStack.execute("lane.add",n),n.newLane},Pg.prototype.splitLane=function(e,t){this._commandStack.execute("lane.split",{shape:e,count:t})},Pg.prototype.makeCollaboration=function(){var e=this._create("root",{type:"bpmn:Collaboration"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},Pg.prototype.makeProcess=function(){var e=this._create("root",{type:"bpmn:Process"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},Pg.prototype.updateLaneRefs=function(e,t){this._commandStack.execute("lane.updateRefs",{flowNodeShapes:e,laneShapes:t})},Pg.prototype.claimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t,claiming:!0})},Pg.prototype.unclaimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t})},Pg.prototype.setColor=function(e,t){e.length||(e=[e]),this._commandStack.execute("element.setColor",{elements:e,colors:t})},kg.prototype.layoutConnection=function(e,t){return[(t=t||{}).connectionStart||bn(t.source||e.source),t.connectionEnd||bn(t.target||e.target)]};var Sg=20,Cg=5,Ag=Math.round,Mg=20,Tg={"h:h":20,"v:v":20,"h:v":-10,"v:h":-10};function Rg(e,t,n){var i,r,o,s=xn(t,e,Cg),a=n.split(":")[0],l=Ag((t.x-e.x)/2+e.x),c=Ag((t.y-e.y)/2+e.y),p=(o=s,{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/left|right/,v:/top|bottom/}[a].test(o)),u=/h|r|l/.test(a),d=!1,h=!1;return p?(i=u?{x:l,y:e.y}:{x:e.x,y:c},r=u?"h:h":"v:v"):(d=function(e,t){return!{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/./,v:/./}[t].test(e)}(s,a),r=u?"h:v":"v:h",d?u?(h=c===e.y,i={x:e.x+Sg*(/l/.test(a)?-1:1),y:h?c+Sg:c}):i={x:(h=l===e.x)?l+Sg:l,y:e.y+Sg*(/t/.test(a)?-1:1)}:i={x:l,y:c}),{waypoints:Ng(e,i,r).concat(i),directions:r,turnNextDirections:h}}function Dg(e){return e.split(":").reverse().join(":")}function Ng(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(Lg(n)){var i=function(e,t,n){return Rg(e,t,n)}(e,t,n),r=function(e,t,n){var i=Rg(t,e,Dg(n));return{waypoints:i.waypoints.slice().reverse(),directions:Dg(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:Ng(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=Ag((t.x-e.x)/2+e.x),r=Ag((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 Bg(e,t,n,i,r){var o=b(r&&r.preferredLayouts||[],"straight")[0]||"h:h",s=xn(e,t,Tg[o]||0),a=function(e,t){if(Lg(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}}(s,o);n=n||bn(e),i=i||bn(t);var l=a.split(":"),c=qg(n,e,l[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]}(s));return function(e,t,n){var i=Ng(e,t,n);return i.unshift(e),i.push(t),zg(i)}(c,qg(i,t,l[1],s),a)}function $g(e,t,n,i,r,o){var s;return c(n)&&(r=n,o=i,n=bn(e),i=bn(t)),r=r||[],s=-1!==(o=j({preferredLayouts:[]},o)).preferredLayouts.indexOf("straight")&&function(e,t,n,i,r){var o,s,a={};if(s=xn(e,t),!/^(top|bottom|left|right)$/.test(s))return null;/top|bottom/.test(s)&&(o="x");/left|right/.test(s)&&(o="y");return"target"===r.preserveDocking?jg(o,i,e)?(a[o]=i[o],[{x:void 0!==a.x?a.x:n.x,y:void 0!==a.y?a.y:n.y,original:{x:void 0!==a.x?a.x:n.x,y:void 0!==a.y?a.y:n.y}},{x:i.x,y:i.y}]):null:jg(o,n,t)?(a[o]=n[o],[{x:n.x,y:n.y},{x:void 0!==a.x?a.x:i.x,y:void 0!==a.y?a.y:i.y,original:{x:void 0!==a.x?a.x:i.x,y:void 0!==a.y?a.y:i.y}}]):null}(e,t,n,i,o),s||(s=o.connectionEnd&&function(e,t,n,i){var r=i.slice().reverse();return r=Ig(e,t,n,r),r?r.reverse():null}(t,e,i,r),s||((s=o.connectionStart&&Ig(e,t,n,r))||(!o.connectionStart&&!o.connectionEnd&&r&&r.length?r:Bg(e,t,n,i,o))))}function jg(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 Ig(e,t,n,i){if(function(e){return e.length<3||!(e.length>4)&&!!f(e,(function(t,n){var i=e[n-1];return i&&kt(t,i)<3}))}(i))return null;var r,o=i[0],s=i.slice();return s[0]=n,s[1]=function(e,t,n){switch(At(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}}(s[1],o,n),r=function(e,t,n){var i;for(i=e.length-2;0!==i;i--)if(Tt(e[i],t,Mg)||Tt(e[i],n,Mg))return e.slice(i);return e}(s,e,t),r!==s&&(s=Ig(e,t,n,r)),s&&At(s)?null:s}function Lg(e){return e&&/t|r|b|l/.test(e)}function qg(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 zg(e){return e.reduce((function(t,n,i){return St(t[t.length-1],e[i+1],n,0)||t.push(n),t}),[])}var Vg=-10,Fg=40,Hg={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},Ug={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},Wg={top:"bottom","top-right":"bottom-left","top-left":"bottom-right",right:"left",bottom:"top","bottom-right":"top-left","bottom-left":"top-right",left:"right"},Gg={top:"t",right:"r",bottom:"b",left:"l"};function Qg(e){this._elementRegistry=e}function Xg(e,t){return _r(t,"bpmn:Participant")?"source":_r(e,"bpmn:Participant")?"target":Jg(t)?"source":Jg(e)||_r(t,"bpmn:Event")?"target":_r(e,"bpmn:Event")?"source":null}function Kg(e){return Jg(e)?"target":"source"}function Yg(e,t){return e?e.original||e:bn(t)}function Zg(e,t){return _r(t,"bpmn:Activity")&&_r(e,"bpmn:BoundaryEvent")&&t.businessObject.isForCompensation}function Jg(e){return _r(e,"bpmn:SubProcess")&&Vr(e)}function ey(e,t){return e===t}function ty(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 iy(e,t){return Wg[e]===t}function ry(e){return"right"===e||"left"===e}function oy(e,t,n){var i=t.waypoints,r=i&&i.length&&xn(i[0],e);return"top"===r?n.loop.fromTop:"right"===r?n.loop.fromRight:"left"===r?n.loop.fromLeft:n.loop.fromBottom}function sy(e,t,n,i){var r,o,s,a,l=bn(e),c=bn(t),p=(a=(s=e).host,xn(bn(s),a,Vg)),u=ey(e.host,t),d=-1!==["top","right","bottom","left"].indexOf(p),h=xn(c,l,{x:e.width/2+t.width/2,y:e.height/2+t.height/2});return u?function(e,t,n,i,r,o){var s,a=t?e:o.isHorizontal?ny(e):ty(e),l=Gg[a];s=t?ry(e)?ay("y",n,i,r)?"h":o.boundaryLoop.alternateHorizontalSide:ay("x",n,i,r)?"v":o.boundaryLoop.alternateVerticalSide:o.boundaryLoop.default;return[l+":"+s]}(p,d,e,t,n,i):(r=function(e,t,n,i){if(n)return Gg[e];var r=ny(e),o=ty(e),s=ny(t),a=ty(t);if(i){if(ey(r,s)||iy(o,a))return Gg[r]}else if(ey(o,a)||iy(r,s))return Gg[o];return Gg[i?o:r]}(p,h,d,i.isHorizontal),o=function(e,t,n,i){if(n)return ry(e)?function(e,t){var n=ty(e),i=Wg[n];return-1!==t.indexOf(i)}(e,t)||ey(e,t)?"h":"v":function(e,t){var n=ny(e),i=Wg[n];return-1!==t.indexOf(i)}(e,t)||ey(e,t)?"v":"h";return i?ey(ny(e),ny(t))?"h":"v":ey(ty(e),ty(t))?"v":"h"}(p,h,d,i.isHorizontal),[r+":"+o])}function ay(e,t,n,i){var r=Fg;return!(ly(e,i,n,r)||ly(e,i,{x:n.x+n.width,y:n.y+n.height},r)||ly(e,i,bn(t),r))}function ly(e,t,n,i){return Math.abs(t[e]-n[e])<i}function cy(e){return j({original:e.point.original||e.point},e.actual)}function py(e,t){this._elementRegistry=e,this._graphicsFactory=t}e(Qg,kg),Qg.prototype.layoutConnection=function(e,t){t||(t={});var n,i,r=t.source||e.source,o=t.target||e.target,s=t.waypoints||e.waypoints,a=t.connectionStart,l=t.connectionEnd,c=this._elementRegistry;if(a||(a=Yg(s&&s[0],r)),l||(l=Yg(s&&s[s.length-1],o)),(_r(e,"bpmn:Association")||_r(e,"bpmn:DataAssociation"))&&s&&!Zg(r,o))return[].concat([a],s.slice(1,-1),[l]);var p=uc(r,c)?Hg:Ug;return _r(e,"bpmn:MessageFlow")?n=function(e,t,n){return{preferredLayouts:n.messageFlow,preserveDocking:Xg(e,t)}}(r,o,p):(_r(e,"bpmn:SequenceFlow")||Zg(r,o))&&(n=r===o?{preferredLayouts:oy(r,e,p)}:_r(r,"bpmn:BoundaryEvent")?{preferredLayouts:sy(r,o,l,p)}:Jg(r)||Jg(o)?{preferredLayouts:p.subProcess,preserveDocking:Kg(r)}:_r(r,"bpmn:Gateway")?{preferredLayouts:p.fromGateway}:_r(o,"bpmn:Gateway")?{preferredLayouts:p.toGateway}:{preferredLayouts:p.default}),n&&(i=zg($g(r,o,a,l,s,n=j(n,t)))),i||[a,l]},Qg.$inject=["elementRegistry"],py.$inject=["elementRegistry","graphicsFactory"],py.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(cy(i)),o.push(cy(r)),o},py.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}},py.prototype._getIntersection=function(e,t,n){return wn(this._getShapePath(e),this._getConnectionPath(t),n)},py.prototype._getConnectionPath=function(e){return this._graphicsFactory.getConnectionPath(e)},py.prototype._getShapePath=function(e){return this._graphicsFactory.getShapePath(e)},py.prototype._getGfx=function(e){return this._elementRegistry.getGraphics(e)};var uy={__init__:["modeling","bpmnUpdater"],__depends__:[mh,Qh,Kh,Jh,Rm,nf,af,uf,Ts,Vo,ef],bpmnFactory:["type",df],bpmnUpdater:["type",hf],elementFactory:["type",ff],modeling:["type",Pg],layouter:["type",Qg],connectionDocking:["type",py]};const dy=Math.round;function hy(e,t,n,i,r,o){this._complexPreview=e,this._connectionDocking=t,this._elementFactory=n,this._eventBus=i,this._layouter=r,this._rules=o}hy.prototype.create=function(e,t,n){const i=this._complexPreview,r=this._connectionDocking,o=this._elementFactory,s=this._eventBus,a=this._layouter,c=this._rules,p=o.createShape(j({type:t},n)),u=s.fire("autoPlace",{source:e,shape:p});if(!u)return;j(p,{x:u.x-dy(p.width/2),y:u.y-dy(p.height/2)});const d=c.allowed("connection.create",{source:e,target:p,hints:{targetParent:e.parent}});let h=null;d&&(h=o.createConnection(d),h.waypoints=a.layoutConnection(h,{source:e,target:p}),h.waypoints=r.getCroppedWaypoints(h,e,p)),i.create({created:[p,h].filter((e=>!l(e)))})},hy.prototype.cleanUp=function(){this._complexPreview.cleanUp()},hy.$inject=["complexPreview","connectionDocking","elementFactory","eventBus","layouter","rules"];var my={__depends__:[fc,Hp,uy],__init__:["appendPreview"],appendPreview:["type",hy]},fy=Math.min,gy=Math.max;function yy(e){e.preventDefault()}function vy(e){e.stopPropagation()}function by(e){this.container=e.container,this.parent=fe('<div class="djs-direct-editing-parent"><div class="djs-direct-editing-content" contenteditable="true"></div></div>'),this.content=ye("[contenteditable]",this.parent),this.keyHandler=e.keyHandler||function(){},this.resizeHandler=e.resizeHandler||function(){},this.autoResize=$(this.autoResize,this),this.handlePaste=$(this.handlePaste,this)}function xy(e,t){this._eventBus=e,this._canvas=t,this._providers=[],this._textbox=new by({container:t.getContainer(),keyHandler:$(this._handleKey,this),resizeHandler:$(this._handleResize,this)})}by.prototype.create=function(e,t,n,i){var r=this.parent,o=this.content,s=this.container;i=this.options=i||{};var a=L(t=this.style=t||{},["width","height","maxWidth","maxHeight","minWidth","minHeight","left","top","backgroundColor","position","overflow","border","wordWrap","textAlign","outline","transform"]);j(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"},a);var l=L(t,["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"]);return j(o.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},l),i.centerVertically&&j(o.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},l),o.innerText=n,le.bind(o,"keydown",this.keyHandler),le.bind(o,"mousedown",vy),le.bind(o,"paste",this.handlePaste),i.autoResize&&le.bind(o,"input",this.autoResize),i.resizable&&this.resizable(t),s.appendChild(r),this.setSelection(o.lastChild,o.lastChild&&o.lastChild.length),r},by.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)}},by.prototype.insertText=function(e){e=function(e){return e.replace(/\r\n|\r|\n/g,"\n")}(e),document.execCommand("insertText",!1,e)||this._insertTextIE(e)},by.prototype._insertTextIE=function(e){var t,n,i,r=this.getSelection(),o=r.startContainer,s=r.endContainer,a=r.startOffset,l=r.endOffset,c=r.commonAncestorContainer,p=(t=c.childNodes,[].slice.call(t));if(function(e){return e.nodeType===Node.TEXT_NODE}(c)){var u=o.textContent;o.textContent=u.substring(0,a)+e+u.substring(l),n=o,i=a+e.length}else if(o===this.content&&s===this.content){var d=document.createTextNode(e);this.content.insertBefore(d,p[a]),n=d,i=d.textContent.length}else{var h=p.indexOf(o),m=p.indexOf(s);p.forEach((function(t,n){n===h?t.textContent=o.textContent.substring(0,a)+e+s.textContent.substring(l):n>h&&n<=m&&be(t)})),n=o,i=a+e.length}n&&void 0!==i&&setTimeout((function(){self.setSelection(n,i)}))},by.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})}},by.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,s=parseInt(this.style.maxHeight)||1/0;if(!n){var a,l,c,p;n=this.resizeHandle=fe('<div class="djs-direct-editing-resize-handle"></div>');var u=function(n){yy(n),vy(n);var u=fy(gy(c+n.clientX-a,i),o),d=fy(gy(p+n.clientY-l,r),s);t.style.width=u+"px",t.style.height=d+"px",e.resizeHandler({width:c,height:p,dx:n.clientX-a,dy:n.clientY-l})},d=function(e){yy(e),vy(e),le.unbind(document,"mousemove",u,!1),le.unbind(document,"mouseup",d,!1)};le.bind(n,"mousedown",(function(e){yy(e),vy(e),a=e.clientX,l=e.clientY;var n=t.getBoundingClientRect();c=n.width,p=n.height,le.bind(document,"mousemove",u),le.bind(document,"mouseup",d)}))}j(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)},by.prototype.destroy=function(){var e=this.parent,t=this.content,n=this.resizeHandle;t.innerText="",e.removeAttribute("style"),t.removeAttribute("style"),le.unbind(t,"keydown",this.keyHandler),le.unbind(t,"mousedown",vy),le.unbind(t,"input",this.autoResize),le.unbind(t,"paste",this.handlePaste),n&&(n.removeAttribute("style"),be(n)),be(e)},by.prototype.getValue=function(){return this.content.innerText.trim()},by.prototype.getSelection=function(){return window.getSelection().getRangeAt(0)},by.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)},xy.$inject=["eventBus","canvas"],xy.prototype.registerProvider=function(e){this._providers.push(e)},xy.prototype.isActive=function(e){return!(!this._active||e&&this._active.element!==e)},xy.prototype.cancel=function(){this._active&&(this._fire("cancel"),this.close())},xy.prototype._fire=function(e,t){this._eventBus.fire("directEditing."+e,t||{active:this._active})},xy.prototype.close=function(){this._textbox.destroy(),this._fire("deactivate"),this._active=null,this.resizable=void 0,this._canvas.restoreFocus&&this._canvas.restoreFocus()},xy.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()}},xy.prototype.getValue=function(){return this._textbox.getValue()},xy.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())},xy.prototype._handleResize=function(e){this._fire("resize",e)},xy.prototype.activate=function(e){var t;this.isActive()&&this.cancel();var n=f(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 wy={__depends__:[Os],__init__:["directEditing"],directEditing:["type",xy]};function _y(e){return function(t){var n=t.target,i=Or(e),r=i.eventDefinitions&&i.eventDefinitions[0],o=i.$type===n.type,s=(r&&r.$type)===n.eventDefinitionType,a=!!n.triggeredByEvent==!!i.triggeredByEvent,l=void 0===n.isExpanded||n.isExpanded===Vr(e);return!(o&&s&&a&&l)}}var Ey=[{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"}}],Oy=[{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"}}],Py=[{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"}}],ky=[{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"}}],Sy=[{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"}}],Cy=[{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}}],Ay=[{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}}],My=Ay,Ty=[{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}}],Ry=[{label:"Data store reference",actionName:"replace-with-data-store-reference",className:"bpmn-icon-data-store",target:{type:"bpmn:DataStoreReference"}}],Dy=[{label:"Data object reference",actionName:"replace-with-data-object-reference",className:"bpmn-icon-data-object",target:{type:"bpmn:DataObjectReference"}}],Ny=[{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}}],By=[{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}}],$y=[{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"}],jy=[{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}}],Iy={"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 Ly(e,t,n,i,r,o,s,a){this._bpmnFactory=e,this._popupMenu=t,this._modeling=n,this._moddle=i,this._bpmnReplace=r,this._rules=o,this._translate=s,this._moddleCopy=a,this._register()}Ly.$inject=["bpmnFactory","popupMenu","modeling","moddle","bpmnReplace","rules","translate","moddleCopy"],Ly.prototype._register=function(){this._popupMenu.registerProvider("bpmn-replace",this)},Ly.prototype.getPopupMenuEntries=function(e){var t=e.businessObject,n=this._rules,i=[];if(c(e)||!n.allowed("shape.replace",{element:e}))return{};var r=_y(e);return _r(t,"bpmn:DataObjectReference")?this._createEntries(e,Ry):_r(t,"bpmn:DataStoreReference")&&!_r(e.parent,"bpmn:Collaboration")?this._createEntries(e,Dy):_r(t,"bpmn:StartEvent")&&!_r(t.$parent,"bpmn:SubProcess")?(i=y(Ey,r),this._createEntries(e,i)):_r(t,"bpmn:Participant")?(i=y(jy,(function(t){return Vr(e)!==t.target.isExpanded})),this._createEntries(e,i)):_r(t,"bpmn:StartEvent")&&Ur(t.$parent)?(i=y(By,(function(e){var n=!1!==e.target.isInterrupting,i=t.isInterrupting===n;return r(e)||!r(e)&&!i})),this._createEntries(e,i)):_r(t,"bpmn:StartEvent")&&!Ur(t.$parent)&&_r(t.$parent,"bpmn:SubProcess")?(i=y(Oy,r),this._createEntries(e,i)):_r(t,"bpmn:EndEvent")?(i=y(ky,(function(e){return!("bpmn:CancelEventDefinition"==e.target.eventDefinitionType&&!_r(t.$parent,"bpmn:Transaction"))&&r(e)})),this._createEntries(e,i)):_r(t,"bpmn:BoundaryEvent")?(i=y(Ny,(function(e){var n=e.target;if("bpmn:CancelEventDefinition"==n.eventDefinitionType&&!_r(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)):_r(t,"bpmn:IntermediateCatchEvent")||_r(t,"bpmn:IntermediateThrowEvent")?(i=y(Py,r),this._createEntries(e,i)):_r(t,"bpmn:Gateway")?(i=y(Sy,r),this._createEntries(e,i)):_r(t,"bpmn:Transaction")?(i=y(Ay,r),this._createEntries(e,i)):Ur(t)&&Vr(e)?(i=y(My,r),this._createEntries(e,i)):_r(t,"bpmn:SubProcess")&&Vr(e)?(i=y(Cy,r),this._createEntries(e,i)):_r(t,"bpmn:AdHocSubProcess")&&!Vr(e)?(i=y(Ty,(function(e){var t=e.target,n="bpmn:SubProcess"===t.type,i=!0===t.isExpanded;return _y(t)&&(!n||i)})),this._createEntries(e,i)):_r(t,"bpmn:SequenceFlow")?this._createSequenceFlowEntries(e,$y):_r(t,"bpmn:FlowNode")?(i=y(Ty,r),_r(t,"bpmn:SubProcess")&&!Vr(e)&&(i=y(i,(function(e){return"Sub-process (collapsed)"!==e.label}))),this._createEntries(e,i)):{}},Ly.prototype.getPopupMenuHeaderEntries=function(e){var t={};return _r(e,"bpmn:Activity")&&!Ur(e)&&(t={...t,...this._getLoopCharacteristicsHeaderEntries(e)}),_r(e,"bpmn:DataObjectReference")&&(t={...t,...this._getCollectionHeaderEntries(e)}),_r(e,"bpmn:Participant")&&(t={...t,...this._getParticipantMultiplicityHeaderEntries(e)}),!_r(e,"bpmn:SubProcess")||_r(e,"bpmn:Transaction")||Ur(e)||(t={...t,...this._getAdHocHeaderEntries(e)}),_d(e)&&(t={...t,...this._getNonInterruptingHeaderEntries(e)}),t},Ly.prototype._createEntries=function(e,t){var n={},i=this;return v(t,(function(t){n[t.actionName]=i._createEntry(t,e)})),n},Ly.prototype._createSequenceFlowEntries=function(e,t){var n=Or(e),i={},r=this._modeling,o=this._moddle,s=this;return v(t,(function(t){switch(t.actionName){case"replace-with-default-flow":n.sourceRef.default!==n&&(_r(n.sourceRef,"bpmn:ExclusiveGateway")||_r(n.sourceRef,"bpmn:InclusiveGateway")||_r(n.sourceRef,"bpmn:ComplexGateway")||_r(n.sourceRef,"bpmn:Activity"))&&(i={...i,[t.actionName]:s._createEntry(t,e,(function(){r.updateProperties(e.source,{default:n})}))});break;case"replace-with-conditional-flow":!n.conditionExpression&&_r(n.sourceRef,"bpmn:Activity")&&(i={...i,[t.actionName]:s._createEntry(t,e,(function(){var t=o.create("bpmn:FormalExpression",{body:""});r.updateProperties(e,{conditionExpression:t})}))});break;default:_r(n.sourceRef,"bpmn:Activity")&&n.conditionExpression&&(i={...i,[t.actionName]:s._createEntry(t,e,(function(){r.updateProperties(e,{conditionExpression:void 0})}))}),(_r(n.sourceRef,"bpmn:ExclusiveGateway")||_r(n.sourceRef,"bpmn:InclusiveGateway")||_r(n.sourceRef,"bpmn:ComplexGateway")||_r(n.sourceRef,"bpmn:Activity"))&&n.sourceRef.default===n&&(i={...i,[t.actionName]:s._createEntry(t,e,(function(){r.updateProperties(e.source,{default:void 0})}))})}})),i},Ly.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}},Ly.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&&_r(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,s,a=Or(e).loopCharacteristics;return a&&(r=a.isSequential,o=void 0===a.isSequential,s=void 0!==a.isSequential&&!a.isSequential),{"toggle-parallel-mi":{className:"bpmn-icon-parallel-mi-marker",title:n("Parallel multi-instance"),active:s,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"}}}},Ly.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})}}}},Ly.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})}}}},Ly.prototype._getAdHocHeaderEntries=function(e){var t=this._translate,n=_r(Or(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})}}}},Ly.prototype._getNonInterruptingHeaderEntries=function(e){const t=this._translate,n=Or(e),i=this,r=Ed(e),o=_r(e,"bpmn:BoundaryEvent")?Iy["intermediate-event-non-interrupting"]:Iy["start-event-non-interrupting"],s=!n[r];return{"toggle-non-interrupting":{imageHtml:o,title:t("Toggle non-interrupting"),active:s,action:function(){i._modeling.updateProperties(e,{[r]:!!s})}}}};var qy={__depends__:[Ul,Rm,fc],__init__:["replaceMenuProvider"],replaceMenuProvider:["type",Ly]};function zy(e,t,n,i,r,o,s,a,l,c,p,u,d){e=e||{},i.registerProvider(this),this._contextPad=i,this._modeling=r,this._elementFactory=o,this._connect=s,this._create=a,this._popupMenu=l,this._canvas=c,this._rules=p,this._translate=u,this._eventBus=n,this._appendPreview=d,!1!==e.autoPlace&&(this._autoPlace=t.get("autoPlace",!1)),n.on("create.end",250,(function(e){var t=e.context.shape;if(bs(e)&&i.isOpen(t)){var n=i.getEntries(t);n.replace&&n.replace.action.click(e,t)}})),n.on("contextPad.close",(function(){d.cleanUp()}))}function Vy(e,t,n){var i=e.$instanceOf(t),r=!1;return v(e.eventDefinitions||[],(function(e){e.$type===n&&(r=!0)})),i&&r}zy.$inject=["config.contextPad","injector","eventBus","contextPad","modeling","elementFactory","connect","create","popupMenu","canvas","rules","translate","appendPreview"],zy.prototype.getMultiElementContextPadEntries=function(e){var t=this._modeling,n={};return this._isDeleteAllowed(e)&&j(n,{delete:{group:"edit",className:"bpmn-icon-trash",title:this._translate("Delete"),action:{click:function(e,n){t.removeElements(n.slice())}}}}),n},zy.prototype._isDeleteAllowed=function(e){var t=this._rules.allowed("elements.delete",{elements:e});return c(t)?w(e,(e=>t.includes(e))):t},zy.prototype.getContextPadEntries=function(e){var t=this._contextPad,n=this._modeling,i=this._elementFactory,r=this._connect,o=this._create,s=this._popupMenu,a=this._autoPlace,l=this._translate,c=this._appendPreview,p={};if("label"===e.type)return this._isDeleteAllowed([e])&&j(p,m()),p;var u=e.businessObject;function d(e,t){r.start(e,t)}function h(e,t){n.removeElements([t])}function m(){return{delete:{group:"edit",className:"bpmn-icon-trash",title:l("Delete"),action:{click:h}}}}function f(e,t,n,r){function s(t,n){var s=i.createShape(j({type:e},r));o.start(t,s,{source:n})}var l=a?function(t,n){var o=i.createShape(j({type:e},r));a.append(n,o)}:s,p=a?function(t,n){return c.create(n,e,r),()=>{c.cleanUp()}}:null;return{group:"model",className:t,title:n,action:{dragstart:s,click:l,hover:p}}}function g(e){return function(i,r){n.splitLane(r,e),t.open(r,!0)}}if(Er(u,["bpmn:Lane","bpmn:Participant"])&&Vr(e)){var y=Cu(e);j(p,{"lane-insert-above":{group:"lane-insert-above",className:"bpmn-icon-lane-insert-above",title:l("Add lane above"),action:{click:function(e,t){n.addLane(t,"top")}}}}),y.length<2&&((Fr(e)?e.height>=120:e.width>=120)&&j(p,{"lane-divide-two":{group:"lane-divide",className:"bpmn-icon-lane-divide-two",title:l("Divide into two lanes"),action:{click:g(2)}}}),(Fr(e)?e.height>=180:e.width>=180)&&j(p,{"lane-divide-three":{group:"lane-divide",className:"bpmn-icon-lane-divide-three",title:l("Divide into three lanes"),action:{click:g(3)}}})),j(p,{"lane-insert-below":{group:"lane-insert-below",className:"bpmn-icon-lane-insert-below",title:l("Add lane below"),action:{click:function(e,t){n.addLane(t,"bottom")}}}})}return _r(u,"bpmn:FlowNode")&&(_r(u,"bpmn:EventBasedGateway")?j(p,{"append.receive-task":f("bpmn:ReceiveTask","bpmn-icon-receive-task",l("Append receive task")),"append.message-intermediate-event":f("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-message",l("Append message intermediate catch event"),{eventDefinitionType:"bpmn:MessageEventDefinition"}),"append.timer-intermediate-event":f("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-timer",l("Append timer intermediate catch event"),{eventDefinitionType:"bpmn:TimerEventDefinition"}),"append.condition-intermediate-event":f("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-condition",l("Append conditional intermediate catch event"),{eventDefinitionType:"bpmn:ConditionalEventDefinition"}),"append.signal-intermediate-event":f("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-signal",l("Append signal intermediate catch event"),{eventDefinitionType:"bpmn:SignalEventDefinition"})}):Vy(u,"bpmn:BoundaryEvent","bpmn:CompensateEventDefinition")?j(p,{"append.compensation-activity":f("bpmn:Task","bpmn-icon-task",l("Append compensation activity"),{isForCompensation:!0})}):_r(u,"bpmn:EndEvent")||u.isForCompensation||Vy(u,"bpmn:IntermediateThrowEvent","bpmn:LinkEventDefinition")||Ur(u)||j(p,{"append.end-event":f("bpmn:EndEvent","bpmn-icon-end-event-none",l("Append end event")),"append.gateway":f("bpmn:ExclusiveGateway","bpmn-icon-gateway-none",l("Append gateway")),"append.append-task":f("bpmn:Task","bpmn-icon-task",l("Append task")),"append.intermediate-event":f("bpmn:IntermediateThrowEvent","bpmn-icon-intermediate-event-none",l("Append intermediate/boundary event"))})),s.isEmpty(e,"bpmn-replace")||j(p,{replace:{group:"edit",className:"bpmn-icon-screw-wrench",title:l("Change element"),action:{click:function(e,n){var i=j(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}});s.open(n,"bpmn-replace",i,{title:l("Change element"),width:300,search:!0})}}}}),_r(u,"bpmn:SequenceFlow")&&j(p,{"append.text-annotation":f("bpmn:TextAnnotation","bpmn-icon-text-annotation",l("Add text annotation"))}),Er(u,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference"])&&j(p,{"append.text-annotation":f("bpmn:TextAnnotation","bpmn-icon-text-annotation",l("Add text annotation")),connect:{group:"connect",className:"bpmn-icon-connection-multi",title:l("Connect to other element"),action:{click:d,dragstart:d}}}),_r(u,"bpmn:TextAnnotation")&&j(p,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:l("Connect using association"),action:{click:d,dragstart:d}}}),Er(u,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&j(p,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:l("Connect using data input association"),action:{click:d,dragstart:d}}}),_r(u,"bpmn:Group")&&j(p,{"append.text-annotation":f("bpmn:TextAnnotation","bpmn-icon-text-annotation",l("Add text annotation"))}),this._isDeleteAllowed([e])&&j(p,m()),p};var Fy={__depends__:[my,wy,Aa,Ts,Np,um,qy],__init__:["contextPadProvider"],contextPadProvider:["type",zy]},Hy={horizontal:["x","width"],vertical:["y","height"]};function Uy(e,t){this._modeling=e,this._filters=[],this.registerFilter((function(e){var n=t.allowed("elements.distribute",{elements:e});return c(n)?n:n?e:[]}))}Uy.$inject=["modeling","rules"],Uy.prototype.registerFilter=function(e){if("function"!=typeof e)throw new Error("the filter has to be a function");this._filters.push(e)},Uy.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},Uy.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},Uy.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 s,a=n._findRange(e,i,r),l=t[t.length-1];l&&n._hasIntersection(l.range,a)?t[t.length-1].elements.push(e):(s={range:a,elements:[e]},t.push(s))})),t},Uy.prototype._setOrientation=function(e){var t=Hy[e];this._axis=t[0],this._dimension=t[1]},Uy.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)},Uy.prototype._findRange=function(e){var t=e[this._axis];return{min:t+5,max:t+e[this._dimension]-5}};var Wy={__init__:["distributeElements"],distributeElements:["type",Uy]};function Gy(e){Kl.call(this,e)}Gy.$inject=["eventBus"],e(Gy,Kl),Gy.prototype.init=function(){this.addRule("elements.distribute",(function(e){var t=e.elements;return!((t=dt(t=y(t,(function(e){var t=Er(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 Qy={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 Xy(e,t,n,i){this._distributeElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",900,this)}Xy.$inject=["popupMenu","distributeElements","translate","rules"],Xy.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&j(t,this._getEntries(e)),t},Xy.prototype._isAllowed=function(e){return this._rules.allowed("elements.distribute",{elements:e})},Xy.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:Qy.horizontal,action:function(n,r){t.trigger(e,"horizontal"),i.close()}},"distribute-elements-vertical":{group:"distribute",title:n("Distribute elements vertically"),imageHtml:Qy.vertical,action:function(n,r){t.trigger(e,"vertical"),i.close()}}}};var Ky={__depends__:[Ul,Wy],__init__:["bpmnDistributeElements","distributeElementsMenuProvider"],bpmnDistributeElements:["type",Gy],distributeElementsMenuProvider:["type",Xy]},Yy="is not a registered action";function Zy(e,t){this._actions={};var n=this;e.on("diagram.init",(function(){n._registerDefaultActions(t),e.fire("editorActions.init",{editorActions:n})}))}function Jy(e,t){return new Error(e+" "+t)}Zy.$inject=["eventBus","injector"],Zy.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),s=e.get("canvas",!1),a=e.get("rules",!1),l=e.get("keyboardMove",!1),p=e.get("keyboardMoveSelection",!1);t&&(this.register("undo",(function(){t.undo()})),this.register("redo",(function(){t.redo()}))),o&&i&&this.register("copy",(function(){var e=i.get();if(e.length)return o.copy(e)})),o&&this.register("paste",(function(){o.paste()})),r&&this.register("stepZoom",(function(e){r.stepZoom(e.value)})),s&&this.register("zoom",(function(e){s.zoom(e.value)})),n&&i&&a&&this.register("removeSelection",(function(){var e=i.get();if(e.length){var t,r=a.allowed("elements.delete",{elements:e});!1!==r&&(t=c(r)?r:e).length&&n.removeElements(t.slice())}})),l&&this.register("moveCanvas",(function(e){l.moveCanvas(e)})),p&&this.register("moveSelection",(function(e){p.moveSelection(e.direction,e.accelerated)}))},Zy.prototype.trigger=function(e,t){if(!this._actions[e])throw Jy(e,Yy);return this._actions[e](t)},Zy.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)}))},Zy.prototype._registerAction=function(e,t){if(this.isRegistered(e))throw Jy(e,"is already registered");this._actions[e]=t},Zy.prototype.unregister=function(e){if(!this.isRegistered(e))throw Jy(e,Yy);this._actions[e]=void 0},Zy.prototype.getActions=function(){return Object.keys(this._actions)},Zy.prototype.isRegistered=function(e){return!!this._actions[e]};var ev={__init__:["editorActions"],editorActions:["type",Zy]};function tv(e){e.invoke(Zy,this)}e(tv,Zy),tv.$inject=["injector"],tv.prototype._registerDefaultActions=function(e){Zy.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),s=e.get("handTool",!1),a=e.get("globalConnect",!1),l=e.get("distributeElements",!1),c=e.get("alignElements",!1),p=e.get("directEditing",!1),u=e.get("searchPad",!1),d=e.get("modeling",!1),h=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()})),s&&this._registerAction("handTool",(function(){s.toggle()})),a&&this._registerAction("globalConnectTool",(function(){a.toggle()})),i&&l&&this._registerAction("distributeElements",(function(e){var t=i.get(),n=e.type;t.length&&l.trigger(t,n)})),i&&c&&this._registerAction("alignElements",(function(e){var t=i.get(),n=[],r=e.type;t.length&&(n=y(t,(function(e){return!_r(e,"bpmn:Lane")})),c.trigger(n,r))})),i&&d&&this._registerAction("setColor",(function(e){var t=i.get();t.length&&d.setColor(t,e)})),i&&p&&this._registerAction("directEditing",(function(){var e=i.get();e.length&&p.activate(e[0])})),u&&this._registerAction("find",(function(){u.toggle()})),t&&d&&this._registerAction("moveToOrigin",(function(){var e,i,r=t.getRootElement();e=yt(i=_r(r,"bpmn:Collaboration")?n.filter((function(e){return _r(e.parent,"bpmn:Collaboration")})):n.filter((function(e){return e!==r&&!_r(e.parent,"bpmn:SubProcess")}))),d.moveElements(i,{x:-e.x,y:-e.y},r)})),i&&h&&this._registerAction("replaceElement",(function(e){h.triggerEntry("replace","click",e)}))};var nv={__depends__:[ev],editorActions:["type",tv]};function iv(e){e.on(["create.init","shape.move.init"],(function(e){var t=e.context;Er(e.shape,["bpmn:Participant","bpmn:SubProcess","bpmn:TextAnnotation"])&&(t.gridSnappingContext||(t.gridSnappingContext={}),t.gridSnappingContext.snapLocation="top-left")}))}iv.$inject=["eventBus"];var rv=10;function ov(e,t,n){return n||(n="round"),Math[n](e/t)*t}function sv(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&&js(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,s=o.snapLocation,a=o.snapOffset;if(a&&u(a[t]))return a[t];a||(a=o.snapOffset={});u(a[t])||(a[t]=0);if(!r)return a[t];n.get(r.id)||(av(t)?a[t]+=r[t]+r.width/2:a[t]+=r[t]+r.height/2);if(!s)return a[t];"x"===t?/left/.test(s)?a[t]-=r.width/2:/right/.test(s)&&(a[t]+=r.width/2):/top/.test(s)?a[t]-=r.height/2:/bottom/.test(s)&&(a[t]+=r.height/2);return a[t]}(t,n,e);o&&(i.offset=o);var s=function(e,t){var n=e.context,i=n.createConstraints,r=n.resizeConstraints||{},o=n.gridSnappingContext,s=o.snapConstraints;if(s&&s[t])return s[t];s||(s=o.snapConstraints={});s[t]||(s[t]={});var a=n.direction;i&&(av(t)?(s.x.min=i.left,s.x.max=i.right):(s.y.min=i.top,s.y.max=i.bottom));var l=r.min,c=r.max;l&&(av(t)?cv(a)?s.x.max=l.left:s.x.min=l.right:lv(a)?s.y.max=l.top:s.y.min=l.bottom);c&&(av(t)?cv(a)?s.x.min=c.left:s.x.max=c.right:lv(a)?s.y.min=c.top:s.y.max=c.bottom);return s[t]}(t,n);s&&j(i,s),_p(t,n)||r.snapEvent(t,n,i)}))}}))}function av(e){return"x"===e}function lv(e){return-1!==e.indexOf("n")}function cv(e){return-1!==e.indexOf("w")}function pv(e,t){Fo.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;h(i)?t.newBounds=n.snapComplex(o,i):t.newBounds=n.snapSimple(r,o)}}))}sv.prototype.snapEvent=function(e,t,n){Ep(e,t,this.snapValue(e[t],n))},sv.prototype.getGridSpacing=function(){return rv},sv.prototype.snapValue=function(e,t){var n,i,r=0;return t&&t.offset&&(r=t.offset),e=ov(e+=r,rv),t&&t.min&&u(n=t.min)&&(n=ov(n+r,rv,"ceil"),e=Math.max(e,n)),t&&t.max&&u(i=t.max)&&(i=ov(i+r,rv,"floor"),e=Math.min(e,i)),e-=r},sv.prototype.isActive=function(){return this.active},sv.prototype.setActive=function(e){this.active=e,this._eventBus.fire("gridSnapping.toggle",{active:e})},sv.prototype.toggleActive=function(){this.setActive(!this.active)},sv.$inject=["elementRegistry","eventBus","config.gridSnapping"],pv.$inject=["eventBus","gridSnapping","modeling"],e(pv,Fo),pv.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},pv.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},pv.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),j(e,o),e},pv.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),j(e,o),e};function uv(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))}))}uv.$inject=["eventBus","gridSnapping"];var dv={__depends__:[{__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",pv],gridSnappingSpaceToolBehavior:["type",uv]}],__init__:["gridSnapping"],gridSnapping:["type",sv]};function hv(e,t,n){e.on("autoPlace",2e3,(function(e){var i=e.source,r=bn(i),o=e.shape,s=dc(i,o,n);return["x","y"].forEach((function(e){var n={};s[e]!==r[e]&&(s[e]>r[e]?n.min=s[e]:n.max=s[e],_r(o,"bpmn:TextAnnotation")&&(!function(e){return"x"===e}(e)?n.offset=-o.height/2:n.offset=-o.width/2),s[e]=t.snapValue(s[e],n))})),s}))}hv.$inject=["eventBus","gridSnapping","elementRegistry"];function mv(e,t,n){t.on(["create.start","shape.move.start"],1750,(function(t){var i=t.context,r=i.shape,o=e.getRootElement();_r(r,"bpmn:Participant")&&_r(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})))}))}mv.$inject=["canvas","eventBus","gridSnapping"];function fv(e,t,n){Fo.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||{},s=r.waypoints;o.connectionStart||o.connectionEnd||!1===o.createElementsBehavior||function(e){return e.length>3}(s)&&n.updateWaypoints(r,i.snapMiddleSegments(s))}))}function gv(e,t,n){var i=At(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=j({},t,r),n=j({},n,r)),[t,n]}fv.$inject=["eventBus","gridSnapping","modeling"],e(fv,Fo),fv.prototype.snapMiddleSegments=function(e){var t,n=this._gridSnapping;e=e.slice();for(var i=1;i<e.length-2;i++)t=gv(n,e[i],e[i+1]),e[i]=t[0],e[i+1]=t[1];return e};var yv={__depends__:[dv,{__init__:["gridSnappingAutoPlaceBehavior","gridSnappingParticipantBehavior","gridSnappingLayoutConnectionBehavior"],gridSnappingAutoPlaceBehavior:["type",hv],gridSnappingParticipantBehavior:["type",mv],gridSnappingLayoutConnectionBehavior:["type",fv]}],__init__:["bpmnGridSnapping"],bpmnGridSnapping:["type",iv]};function vv(e,t){this._interactionEvents=t;var n=this;e.on(["interactionEvents.createHit","interactionEvents.updateHit"],(function(e){var t=e.element,i=e.gfx;return _r(t,"bpmn:Lane")?n._createParticipantHit(t,i):_r(t,"bpmn:Participant")?Vr(t)?n._createParticipantHit(t,i):n._createDefaultHit(t,i):_r(t,"bpmn:SubProcess")?Vr(t)?n._createSubProcessHit(t,i):n._createDefaultHit(t,i):void 0}))}vv.$inject=["eventBus","interactionEvents"],vv.prototype._createDefaultHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createDefaultHit(e,t),!0},vv.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=Fr(e)?{width:30,height:e.height}:{width:e.width,height:30};return this._interactionEvents.createBoxHit(t,"all",n),!0},vv.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 bv={__init__:["bpmnInteractionEvents"],bpmnInteractionEvents:["type",vv]};function xv(e){e.invoke(Ws,this)}e(xv,Ws),xv.$inject=["injector"],xv.prototype.registerBindings=function(e,t){function n(n,i){t.isRegistered(n)&&e.addListener(i)}Ws.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 wv={__depends__:[Gs],__init__:["keyboardBindings"],keyboardBindings:["type",xv]},_v={moveSpeed:1,moveSpeedAccelerated:10},Ev="left",Ov="right",Pv="down",kv={ArrowLeft:Ev,Left:Ev,ArrowUp:"up",Up:"up",ArrowRight:Ov,Right:Ov,ArrowDown:Pv,Down:Pv},Sv={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 Cv(e,t,n,i,r){var o=this;this._config=j({},_v,e||{}),t.addListener(1500,(function(e){var n=e.keyEvent,i=kv[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 s=this._config[t?"moveSpeedAccelerated":"moveSpeed"],a=Sv[e](s);i.allowed("elements.move",{shapes:o})&&n.moveElements(o,a)}}}Cv.$inject=["config.keyboardMoveSelection","keyboard","modeling","rules","selection"];var Av={__depends__:[Gs,Ts],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",Cv]};function Mv(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,s=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=gn(e);return yn({top:xu("top",n,t),right:xu("right",n,t),bottom:xu("bottom",n,t),left:xu("left",n,t)})}(n,s),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:gn(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=mn(r)))return;n.resizeShape(t,r)}}(e.context)}))}function Tv(e,t){var n=bn(e),i=gn(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 Rv(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"}Mv.prototype.canResize=function(e){var t=this._rules,n=L(e,["newBounds","shape","delta","direction"]);return t.allowed("shape.resize",n)},Mv.prototype.activate=function(e,t,n){var i,r,o=this._dragging;if("string"==typeof n&&(n={direction:n}),!(r=(i=j({shape:t},n)).direction))throw new Error("must provide a direction (n|w|s|e|nw|se|ne|sw)");o.init(e,Tv(t,r),"resize",{autoActivate:!0,cursor:Rv(r),data:{shape:t,context:i}})},Mv.prototype.computeMinResizeBox=function(e){var t=e.shape;return function(e,t,n,i){var r=gn(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},s=i?gn(i):o;return yn({top:yu(o.top,s.top),left:yu(o.left,s.left),bottom:gu(o.bottom,s.bottom),right:gu(o.right,s.right)})}(e.direction,t,e.minDimensions||{width:10,height:10},Eu(t,e.childrenBoxPadding))},Mv.$inject=["eventBus","rules","modeling","dragging"];var Dv="djs-resizing",Nv="resize-not-ok";function Bv(e,t,n){e.on("resize.move",500,(function(e){var i,r,o,s;i=e.context,r=i.shape,o=i.newBounds,(s=i.frame)||(s=i.frame=n.addFrame(r,t.getActiveLayer()),t.addMarker(r,Dv)),o.width>5&&Oe(s,{x:o.x,width:o.width}),o.height>5&&Oe(s,{y:o.y,height:o.height}),i.canExecute?ke(s).remove(Nv):ke(s).add(Nv)})),e.on("resize.cleanup",(function(e){var n,i;n=e.context,i=n.shape,n.frame&&He(n.frame),t.removeMarker(i,Dv)}))}Bv.$inject=["eventBus","canvas","previewSupport"];var $v=-6,jv="djs-resizer",Iv=["n","w","s","e","nw","ne","se","sw"];function Lv(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,$(r.addResizer,r))})),e.on("shape.changed",(function(e){var t=e.element;n.isSelected(t)&&(r.removeResizers(),r.addResizer(t))}))}Lv.prototype.makeDraggable=function(e,t,n){var i=this._resize;function r(t){vs(t)&&i.activate(t,e,n)}le.bind(t,"mousedown",r),le.bind(t,"touchstart",r)},Lv.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=$v);-1!==e.indexOf("s")?t.y=6:-1!==e.indexOf("n")&&(t.y=$v);return t}(i),s=De("g");ke(s).add(jv),ke(s).add(jv+"-"+e.id),ke(s).add(jv+"-"+i),xe(r,s);var a=De("rect");Oe(a,{x:-4+o.x,y:-4+o.y,width:8,height:8}),ke(a).add(jv+"-visual"),xe(s,a);var l=De("rect");return Oe(l,{x:-10+o.x,y:-10+o.y,width:20,height:20}),ke(l).add(jv+"-hit"),xe(s,l),Xn(s,t,n),s},Lv.prototype.createResizer=function(e,t){var n=Tv(e,t),i=this._createResizer(e,n.x,n.y,t);this.makeDraggable(e,i,t)},Lv.prototype.addResizer=function(e){var t=this;!dn(e)&&this._resize.canResize({shape:e})&&v(Iv,(function(n){t.createResizer(e,n)}))},Lv.prototype.removeResizers=function(){Ce(this._getResizersParent())},Lv.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")},Lv.$inject=["eventBus","canvas","selection","resize"];var qv={__depends__:[Rc,Sc,zp],__init__:["resize","resizePreview","resizeHandles"],resize:["type",Mv],resizePreview:["type",Bv],resizeHandles:["type",Lv]};function zv(e,t,n,i,r,o,s){function a(e,t){(t||Er(e,["bpmn:Task","bpmn:TextAnnotation","bpmn:Participant"])||Vv(e))&&i.activate(e)}this._bpmnFactory=t,this._canvas=n,this._modeling=r,this._textRenderer=s,i.registerProvider(this),e.on("element.dblclick",(function(e){a(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||a(n))})),e.on("autoPlace.end",500,(function(e){a(e.shape)}))}function Vv(e){return _r(e,"bpmn:SubProcess")&&!Vr(e)}zv.$inject=["eventBus","bpmnFactory","canvas","directEditing","modeling","resizeHandles","textRenderer"],zv.prototype.activate=function(e){var t=eo(e);if(void 0!==t){var n={text:t};j(n,this.getEditingBBox(e));var i={},r=n.style||{};return j(r,{backgroundColor:null,border:null}),(Er(e,["bpmn:Task","bpmn:Participant","bpmn:Lane","bpmn:CallActivity"])||Vv(e))&&j(i,{centerVertically:!0}),Xr(e)&&(j(i,{autoResize:!0}),j(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),_r(e,"bpmn:TextAnnotation")&&(j(i,{resizable:!0,autoResize:!0}),j(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),j(n,{options:i,style:r}),n}},zv.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,s={x:i.x,y:i.y},a=t.zoom(),l=this._textRenderer.getDefaultStyle(),c=this._textRenderer.getExternalStyle(),p=c.fontSize*a,u=c.lineHeight,d=l.fontSize*a,h=l.lineHeight,m={fontFamily:this._textRenderer.getDefaultStyle().fontFamily,fontWeight:this._textRenderer.getDefaultStyle().fontWeight};if(_r(e,"bpmn:Lane")||function(e){return _r(e,"bpmn:Participant")&&Vr(e)}(e)){var f=Fr(e);j(s,f?{width:i.height,height:30*a,x:i.x-i.height/2+15*a,y:o-30*a/2}:{width:i.width,height:30*a}),j(m,{fontSize:d+"px",lineHeight:h,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px",transform:f?"rotate(-90deg)":null})}if(function(e){return _r(e,"bpmn:Participant")&&!Vr(e)}(e)){var g=Fr(e);j(s,g?{width:i.width,height:i.height}:{width:i.height,height:i.width,x:r-i.height/2,y:o-i.width/2}),j(m,{fontSize:d+"px",lineHeight:h,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px",transform:g?null:"rotate(-90deg)"})}(Er(e,["bpmn:Task","bpmn:CallActivity"])||Vv(e))&&(j(s,{width:i.width,height:i.height}),j(m,{fontSize:d+"px",lineHeight:h,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px"})),function(e){return _r(e,"bpmn:SubProcess")&&Vr(e)}(e)&&(j(s,{width:i.width,x:i.x}),j(m,{fontSize:d+"px",lineHeight:h,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px"}));var y=90*a,v=7*a,b=4*a;if(n.labelTarget&&(j(s,{width:y,height:i.height+v+b,x:r-y/2,y:i.y-v}),j(m,{fontSize:p+"px",lineHeight:u,paddingTop:v+"px",paddingBottom:b+"px"})),Xr(n)&&!Kr(n)&&!hn(n)){var x=Zr(e),w=t.getAbsoluteBBox({x:x.x,y:x.y,width:0,height:0}),_=p+v+b;j(s,{width:y,height:_,x:w.x-y/2,y:w.y-_/2}),j(m,{fontSize:p+"px",lineHeight:u,paddingTop:v+"px",paddingBottom:b+"px"})}return _r(e,"bpmn:TextAnnotation")&&(j(s,{width:i.width,height:i.height,minWidth:30*a,minHeight:10*a}),j(m,{textAlign:"left",paddingTop:5*a+"px",paddingBottom:7*a+"px",paddingLeft:7*a+"px",paddingRight:5*a+"px",fontSize:d+"px",lineHeight:h})),{bounds:s,style:m}},zv.prototype.update=function(e,t,n,i){var r,o,s;_r(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}),(s=t)&&s.trim()||(t=null),this._modeling.updateLabel(e,t,r)};var Fv="djs-element-hidden",Hv="djs-label-hidden";function Uv(e,t,n){var i,r,o,s=this,a=t.getDefaultLayer();e.on("directEditing.activate",(function(e){var l=e.active;if(_r(i=l.element.label||l.element,"bpmn:TextAnnotation")){r=t.getAbsoluteBBox(i),o=De("g");var c=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:i.width,containerHeight:i.height,position:{mx:0,my:0}}),p=s.path=De("path");Oe(p,{d:c,strokeWidth:2,stroke:Wv(i)}),xe(o,p),xe(a,o),Kn(o,i.x,i.y)}_r(i,"bpmn:TextAnnotation")||i.labelTarget?t.addMarker(i,Fv):(_r(i,"bpmn:Task")||_r(i,"bpmn:CallActivity")||_r(i,"bpmn:SubProcess")||_r(i,"bpmn:Participant")||_r(i,"bpmn:Lane"))&&t.addMarker(i,Hv)})),e.on("directEditing.resize",(function(e){if(_r(i,"bpmn:TextAnnotation")){var t=e.height,o=e.dy,a=Math.max(i.height/r.height*(t+o),0),l=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:i.width,containerHeight:a,position:{mx:0,my:0}});Oe(s.path,{d:l})}})),e.on(["directEditing.complete","directEditing.cancel"],(function(e){var n=e.active;n&&(t.removeMarker(n.element.label||n.element,Fv),t.removeMarker(i,Hv)),i=void 0,r=void 0,o&&(He(o),o=void 0)}))}function Wv(e,t){return Pr(e).get("stroke")||t||"black"}Uv.$inject=["eventBus","canvas","pathMap"];var Gv={__depends__:[Vo,qv,wy],__init__:["labelEditingProvider","labelEditingPreview"],labelEditingProvider:["type",zv],labelEditingPreview:["type",Uv]},Qv=new No("tt");function Xv(e,t){e.style.display=!1===t?"none":""}var Kv="djs-tooltip",Yv="."+Kv;function Zv(e,t){var n,i;this._eventBus=e,this._canvas=t,this._ids=Qv,this._tooltipDefaults={show:{minZoom:.7,maxZoom:5}},this._tooltips={},this._tooltipRoot=(n=t.getContainer(),Q(i=fe('<div class="djs-tooltip-container" />'),{position:"absolute",width:"0",height:"0"}),n.insertBefore(i,n.firstChild),i);var r=this;ue.bind(this._tooltipRoot,Yv,"mousedown",(function(e){e.stopPropagation()})),ue.bind(this._tooltipRoot,Yv,"mouseover",(function(e){r.trigger("mouseover",e)})),ue.bind(this._tooltipRoot,Yv,"mouseout",(function(e){r.trigger("mouseout",e)})),this._init()}Zv.$inject=["eventBus","canvas"],Zv.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=j({},this._tooltipDefaults,e,{id:t}),this._addTooltip(e),e.timeout&&this.setTimeout(e),t},Zv.prototype.trigger=function(e,t){var n=t.delegateTarget||t.target,i=this.get(X(n,"data-tooltip-id"));i&&("mouseover"===e&&i.timeout&&this.clearTimeout(i),"mouseout"===e&&i.timeout&&(i.timeout=1e3,this.setTimeout(i)))},Zv.prototype.get=function(e){return"string"!=typeof e&&(e=e.id),this._tooltips[e]},Zv.prototype.clearTimeout=function(e){if(e=this.get(e)){var t=e.removeTimer;t&&(clearTimeout(t),e.removeTimer=null)}},Zv.prototype.setTimeout=function(e){if(e=this.get(e)){this.clearTimeout(e);var t=this;e.removeTimer=setTimeout((function(){t.remove(e)}),e.timeout)}},Zv.prototype.remove=function(e){var t=this.get(e);t&&(be(t.html),be(t.htmlContainer),delete t.htmlContainer,delete this._tooltips[t.id])},Zv.prototype.show=function(){Xv(this._tooltipRoot)},Zv.prototype.hide=function(){Xv(this._tooltipRoot,!1)},Zv.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},Zv.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)),h(i)&&(i=fe(i)),Q(t=fe('<div data-tooltip-id="'+n+'" class="'+Kv+'">'),{position:"absolute"}),t.appendChild(i),e.type&&Y(t).add("djs-tooltip-"+e.type),e.className&&Y(t).add(e.className),e.htmlContainer=t,r.appendChild(t),this._tooltips[n]=e,this._updateTooltip(e)},Zv.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)},Zv.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),Xv(i,r))}))},Zv.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 Jv={__init__:["tooltips"],tooltips:["type",Zv]};function eb(e,t,n){e.on(["shape.move.rejected","create.rejected"],(function(e){var i,r,o=e.context,s=o.shape;_r(o.target,"bpmn:Collaboration")&&_r(s,"bpmn:FlowNode")&&(i=e,r=n("flow elements must be children of pools/participants"),t.add({position:{x:i.x+5,y:i.y+5},type:"error",timeout:2e3,html:"<div>"+r+"</div>"}))}))}eb.$inject=["eventBus","tooltips","translate"];var tb={__depends__:[Jv],__init__:["modelingFeedback"],modelingFeedback:["type",eb]};function nb(e,t){this._eventBus=e,this.offset=5;var n=t.cls("djs-outline",["no-fill"]),i=this;function r(e){var t=De("rect");return Oe(t,j({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=ye(".djs-outline",n);o||xe(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=ye(".djs-outline",n);o||xe(n,o=r()),i.updateConnectionOutline(o,t)}))}nb.prototype.updateShapeOutline=function(e,t){var n=!1,i=this._getProviders();i.length&&v(i,(function(i){n=n||i.updateOutline(t,e)})),n||Oe(e,{x:-this.offset,y:-this.offset,width:t.width+2*this.offset,height:t.height+2*this.offset})},nb.prototype.updateConnectionOutline=function(e,t){var n=yt(t);Oe(e,{x:n.x-this.offset,y:n.y-this.offset,width:n.width+2*this.offset,height:n.height+2*this.offset})},nb.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("outline.getProviders",e,(function(e){e.providers.push(t)}))},nb.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"outline.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},nb.prototype.getOutline=function(e){var t;return v(this._getProviders(),(function(n){d(n.getOutline)&&(t=t||n.getOutline(e))})),t},nb.$inject=["eventBus","styles","elementRegistry"];function ib(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)}))}ib.prototype._updateMultiSelectionOutline=function(e){var t=this._canvas.getLayer("selectionOutline");Ce(t);var n=e.length>1;if(ke(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}}(yt(e)),r=De("rect");Oe(r,j({rx:3},i)),ke(r).add("djs-selection-outline"),xe(t,r)}},ib.$inject=["eventBus","canvas","selection"];var rb={__depends__:[Ts],__init__:["outline","multiSelectionOutline"],outline:["type",nb],multiSelectionOutline:["type",ib]},ob=Math.round;function sb(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 s(e,n,i,r){if(p(i)&&(r=i,i=!1),!n.waypoints&&n.parent&&!ke(e.target).has("djs-hit-no-move")){var o=function(e){return{x:e.x+ob(e.width/2),y:e.y+ob(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 y(e,(function(e){for(;e=e.parent;)if(t[e.id])return!1;return!0}))}(r),j(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,s={x:e.dx,y:e.dy};t=o(i,s,{x:e.x,y:e.y},r),n.delta=s,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,s=t.shapes;if(!1===r)return!1;i.x=ob(i.x),i.y=ob(i.y),0===i.x&&0===i.y||n.moveElements(s,i,t.target,{primaryShape:t.shape,attach:o})})),e.on("element.mousedown",(function(e){if(vs(e)){var t=hs(e);if(!t)throw new Error("must supply DOM mousedown event");return s(t,e.element)}})),this.start=s}sb.$inject=["eventBus","dragging","modeling","selection","rules"];var ab="djs-dragging",lb="drop-ok",cb="drop-not-ok",pb="new-parent",ub="attach-ok";function db(e,t,n,r){function o(e){var t=function(e){var t=y(e,(function(t){return!dn(t)||f(e,M({id:t.source.id}))&&f(e,M({id:t.target.id}))}));return t}(s(e));return t}function s(e){var t=gt(e,!0),n=t.flatMap((e=>(e.incoming||[]).concat(e.outgoing||[]))),i=t.concat(n);return[...new Set(i)]}function a(e,n){[ub,lb,cb,pb].forEach((function(i){i===n?t.addMarker(e,i):t.removeMarker(e,i)}))}e.on("shape.move.start",499,(function(e){var a,l=e.context,c=l.shapes,p=l.allDraggedElements,u=o(c);if(!l.dragGroup){var d=De("g");Oe(d,n.cls("djs-drag-group",["no-events"])),xe(t.getActiveLayer(),d),l.dragGroup=d}u.forEach((function(e){r.addDragger(e,l.dragGroup)})),v(p=p?i([p,s(c)]):s(c),(function(e){t.addMarker(e,ab)})),l.allDraggedElements=p,l.differentParents=1!==(a=k(c,(function(e){return e.parent&&e.parent.id})),O(a).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?a(i,ub):t.canExecute&&r&&i.id!==r.id?a(i,pb):a(i,t.canExecute?lb:cb)),Kn(n,e.dx,e.dy)})),e.on(["shape.move.out","shape.move.cleanup"],(function(e){var t=e.context.target;t&&a(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,ab)})),r&&He(r)})),this.makeDraggable=function(e,n,i){r.addDragger(n,e.dragGroup),i&&t.addMarker(n,ab),e.allDraggedElements?e.allDraggedElements.push(n):e.allDraggedElements=[n]}}db.$inject=["eventBus","canvas","styles","previewSupport"];var hb={__depends__:[Os,Ts,rb,Rc,Sc,zp],__init__:["move","movePreview"],move:["type",sb],movePreview:["type",db]},mb=".djs-palette-toggle",fb=".entry",gb=mb+", "+fb,yb="djs-palette-",vb="open",bb="two-column";function xb(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 wb(e,t){var n=t.getPaletteEntries();return d(n)?n(e):(v(n,(function(t,n){e[n]=t})),e)}xb.$inject=["eventBus","canvas"],xb.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("palette.getProviders",e,(function(e){e.providers.push(t)})),this._rebuild()},xb.prototype.getEntries=function(){return this._getProviders().reduce(wb,{})},xb.prototype._rebuild=function(){this._diagramInitialized&&(this._getProviders().length&&(this._container||this._init(),this._update()))},xb.prototype._init=function(){var e=this,t=this._eventBus,n=this._getParentContainer(),i=this._container=fe(xb.HTML_MARKUP);n.appendChild(i),Y(n).add(yb+"shown"),ue.bind(i,gb,"click",(function(t){if(ge(t.delegateTarget,mb))return e.toggle();e.trigger("click",t)})),le.bind(i,"mousedown",(function(e){e.stopPropagation()})),ue.bind(i,fb,"dragstart",(function(t){e.trigger("dragstart",t)})),t.on("canvas.resized",this._layoutChanged,this),t.fire("palette.create",{container:i})},xb.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(t),t.providers},xb.prototype._toggleState=function(e){e=e||{};var t,n=this._getParentContainer(),i=this._container,r=this._eventBus,o=Y(i),s=Y(n);t="twoColumn"in e?e.twoColumn:this._needsCollapse(n.clientHeight,this._entries||{}),o.toggle(bb,t),s.toggle(yb+bb,t),"open"in e&&(o.toggle(vb,e.open),s.toggle(yb+vb,e.open)),r.fire("palette.changed",{twoColumn:t,open:this.isOpen()})},xb.prototype._update=function(){var e=ye(".djs-palette-entries",this._container),t=this._entries=this.getEntries();J(e),v(t,(function(t,n){var i=t.group||"default",r=ye("[data-group="+Go(i)+"]",e);r||(X(r=fe('<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>'),s=fe(o);if(r.appendChild(s),!t.separator&&(X(s,"data-action",n),t.title&&X(s,"title",t.title),t.className&&function(e,t){var n=Y(e);(c(t)?t:t.split(/\s+/g)).forEach((function(e){n.add(e)}))}(s,t.className),t.imageUrl)){var a=fe("<img>");X(a,"src",t.imageUrl),s.appendChild(a)}})),this.open()},xb.prototype.trigger=function(e,t,n){var i,r,o=t.delegateTarget||t.target;return o?(i=X(o,"data-action"),r=t.originalEvent||t,this.triggerEntry(i,e,r,n)):t.preventDefault()},xb.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(d(o)){if("click"===t)return o(n,i)}else if(o[t])return o[t](n,i);n.preventDefault()}},xb.prototype._layoutChanged=function(){this._toggleState({})},xb.prototype._needsCollapse=function(e,t){return e<46*Object.keys(t).length+50},xb.prototype.close=function(){this._toggleState({open:!1,twoColumn:!1})},xb.prototype.open=function(){this._toggleState({open:!0})},xb.prototype.toggle=function(){this.isOpen()?this.close():this.open()},xb.prototype.isActiveTool=function(e){return e&&this._activeTool===e},xb.prototype.updateToolHighlight=function(e){var t;this._toolsContainer||(t=ye(".djs-palette-entries",this._container),this._toolsContainer=ye("[data-group=tools]",t)),v(this._toolsContainer.children,(function(t){var n=t.getAttribute("data-action");if(n){var i=Y(t);n=n.replace("-tool",""),i.contains("entry")&&n===e?i.add("highlighted-entry"):i.remove("highlighted-entry")}}))},xb.prototype.isOpen=function(){return Y(this._container).has(vb)},xb.prototype._getParentContainer=function(){return this._canvas.getContainer()},xb.HTML_MARKUP='<div class="djs-palette"><div class="djs-palette-entries"></div><div class="djs-palette-toggle"></div></div>';var _b={__init__:["palette"],palette:["type",xb]},Eb="crosshair";function Ob(e,t,n,i,r,o,s){this._selection=r,this._dragging=n,this._mouse=s;var a=this,l=function(e){var n,i=t.getActiveLayer();Oe(n=e.frame=De("rect"),{class:"djs-lasso-overlay",width:1,height:1,x:0,y:0}),xe(i,n)},c=function(e){var t=e.frame,n=e.bbox;Oe(t,{x:n.x,y:n.y,width:n.width,height:n.height})},p=function(e){e.frame&&He(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(){a.activateLasso(t.originalEvent,!0)}))})),e.on("lasso.end",0,(function(e){var t=e.context,n=Pb(e),r=i.filter((function(e){return e})),o=xs(e);a.select(r,n,o?t.selection:[])})),e.on("lasso.start",(function(e){var t=e.context;t.bbox=Pb(e),l(t),t.selection=r.get()})),e.on("lasso.move",(function(e){var t=e.context;t.bbox=Pb(e),c(t)})),e.on("lasso.cleanup",(function(e){var t=e.context;p(t)})),e.on("element.mousedown",1500,(function(e){if(xs(e))return a.activateLasso(e.originalEvent),!0}))}function Pb(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}}Ob.$inject=["eventBus","canvas","dragging","elementRegistry","selection","toolManager","mouse"],Ob.prototype.activateLasso=function(e,t){this._dragging.init(e,"lasso",{autoActivate:t,cursor:Eb,data:{context:{}}})},Ob.prototype.activateSelection=function(e,t){this._dragging.init(e,"lasso.selection",{trapClick:!1,autoActivate:t,cursor:Eb,data:{context:{}},keepSelection:!0})},Ob.prototype.select=function(e,t,n=[]){var i=function(e,t){var n={};return v(e,(function(e){var i=e;i.waypoints&&(i=yt(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,...P(i)])},Ob.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},Ob.prototype.isActive=function(){var e=this._dragging.context();return e&&/^lasso/.test(e.prefix)};var kb={__depends__:[Nm,hm],__init__:["lassoTool"],lassoTool:["type",Ob]},Sb=1500,Cb="grab";function Ab(e,t,n,i,r,o){this._dragging=n,this._mouse=o;var s=this,a=i.get("keyboard",!1);r.registerTool("hand",{tool:"hand",dragging:"hand.move"}),e.on("element.mousedown",Sb,(function(e){if(bs(e))return s.activateMove(e.originalEvent,!0),!1})),a&&a.addListener(Sb,(function(e){if(Mb(e.keyEvent)&&!s.isActive()){var t=s._mouse.getLastMoveEvent();s.activateMove(t,!!t)}}),"keyboard.keydown"),a&&a.addListener(Sb,(function(e){Mb(e.keyEvent)&&s.isActive()&&s.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(){s.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!bs(t)&&n&&e.once("hand.move.ended",(function(e){s.activateHand(e.originalEvent,!0,!0)})),!1}))}function Mb(e){return Is("Space",e)}Ab.$inject=["eventBus","canvas","dragging","injector","toolManager","mouse"],Ab.prototype.activateMove=function(e,t,n){"object"==typeof t&&(n=t,t=!1),this._dragging.init(e,"hand.move",{autoActivate:t,cursor:Cb,data:{context:n||{}}})},Ab.prototype.activateHand=function(e,t,n){this._dragging.init(e,"hand",{trapClick:!1,autoActivate:t,cursor:Cb,data:{context:{reactivate:n}}})},Ab.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateHand(e,!!e)},Ab.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^(hand|hand\.move)$/.test(e.prefix)};var Tb={__depends__:[Nm,hm],__init__:["handTool"],handTool:["type",Ab]},Rb="connect-ok",Db="connect-not-ok";function Nb(e,t,n,i,r,o,s){var a=this;this._dragging=t,this._rules=o,this._mouse=s,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=a.canStartConnect(n);null!==r&&(t.startTarget=n,i.addMarker(n,r?Rb:Db))})),e.on(["global-connect.out","global-connect.cleanup"],(function(e){var t=e.context.startTarget,n=e.context.canStartConnect;t&&i.removeMarker(t,n?Rb:Db)})),e.on(["global-connect.ended"],(function(t){var i=t.context.startTarget,r={x:t.x,y:t.y};if(a.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}))}Nb.$inject=["eventBus","dragging","connect","canvas","toolManager","rules","mouse"],Nb.prototype.start=function(e,t){this._dragging.init(e,"global-connect",{autoActivate:t,trapClick:!1,data:{context:{}}})},Nb.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();return this.start(e,!!e)},Nb.prototype.isActive=function(){var e=this._dragging.context();return e&&/^global-connect/.test(e.prefix)},Nb.prototype.canStartConnect=function(e){return this._rules.allowed("connection.start",{source:e})};var Bb={__depends__:[Np,Rc,Sc,Nm,hm],globalConnect:["type",Nb]};function $b(e,t,n,i,r,o,s,a){this._palette=e,this._create=t,this._elementFactory=n,this._spaceTool=i,this._lassoTool=r,this._handTool=o,this._globalConnect=s,this._translate=a,e.registerProvider(this)}$b.$inject=["palette","create","elementFactory","spaceTool","lassoTool","handTool","globalConnect","translate"],$b.prototype.getPaletteEntries=function(){var e={},t=this._create,n=this._elementFactory,i=this._spaceTool,r=this._lassoTool,o=this._handTool,s=this._globalConnect,a=this._translate;function l(e,i,r,o,s){function a(i){var r=n.createShape(j({type:e},s));t.start(i,r)}return{group:i,className:r,title:o,action:{dragstart:a,click:a}}}function c(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 p(e){t.start(e,n.createParticipantShape())}return j(e,{"hand-tool":{group:"tools",className:"bpmn-icon-hand-tool",title:a("Activate hand tool"),action:{click:function(e){o.activateHand(e)}}},"lasso-tool":{group:"tools",className:"bpmn-icon-lasso-tool",title:a("Activate lasso tool"),action:{click:function(e){r.activateSelection(e)}}},"space-tool":{group:"tools",className:"bpmn-icon-space-tool",title:a("Activate create/remove space tool"),action:{click:function(e){i.activateSelection(e)}}},"global-connect-tool":{group:"tools",className:"bpmn-icon-connection-multi",title:a("Activate global connect tool"),action:{click:function(e){s.start(e)}}},"tool-separator":{group:"tools",separator:!0},"create.start-event":l("bpmn:StartEvent","event","bpmn-icon-start-event-none",a("Create start event")),"create.intermediate-event":l("bpmn:IntermediateThrowEvent","event","bpmn-icon-intermediate-event-none",a("Create intermediate/boundary event")),"create.end-event":l("bpmn:EndEvent","event","bpmn-icon-end-event-none",a("Create end event")),"create.exclusive-gateway":l("bpmn:ExclusiveGateway","gateway","bpmn-icon-gateway-none",a("Create gateway")),"create.task":l("bpmn:Task","activity","bpmn-icon-task",a("Create task")),"create.data-object":l("bpmn:DataObjectReference","data-object","bpmn-icon-data-object",a("Create data object reference")),"create.data-store":l("bpmn:DataStoreReference","data-store","bpmn-icon-data-store",a("Create data store reference")),"create.subprocess-expanded":{group:"activity",className:"bpmn-icon-subprocess-expanded",title:a("Create expanded sub-process"),action:{dragstart:c,click:c}},"create.participant-expanded":{group:"collaboration",className:"bpmn-icon-participant",title:a("Create pool/participant"),action:{dragstart:p,click:p}},"create.group":l("bpmn:Group","artifact","bpmn-icon-group",a("Create group"))}),e};var jb={__depends__:[_b,um,ef,kb,Tb,Bb,Co],__init__:["paletteProvider"],paletteProvider:["type",$b]};function Ib(e,t,n,i,r){Fo.call(this,e),e.on("shape.move.move",250,(function(e){var o=e.context,s=o.canExecute;o.visualReplacements||(o.visualReplacements={}),s&&s.replacements?function(e){v(e.canExecute.replacements,(function(o){var s=o.oldElementId,a={type:o.newElementType};if(!e.visualReplacements[s]){var l=t.get(s);j(a,{x:l.x,y:l.y});var c=n.createShape(a);i.addShape(c,l.parent);var p=ye('[data-element-id="'+Go(l.id)+'"]',e.dragGroup);p&&Oe(p,{display:"none"});var u=r.addDragger(c,e.dragGroup);e.visualReplacements[s]=u,i.removeShape(c)}}))}(o):function(e){var t=e.visualReplacements;v(t,(function(n,i){var r=ye('[data-element-id="'+Go(i)+'"]',e.dragGroup);r&&Oe(r,{display:"inline"}),n.remove(),t[i]&&delete t[i]}))}(o)}))}Ib.$inject=["eventBus","elementRegistry","elementFactory","canvas","previewSupport"],e(Ib,Fo);var Lb={__depends__:[zp],__init__:["bpmnReplacePreview"],bpmnReplacePreview:["type",Ib]},qb=40,zb=20,Vb=10,Fb=20,Hb=["x","y"],Ub=Math.abs;function Wb(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,s=t.target;e.originalEvent&&js(e.originalEvent)||(t.initialConnectionStart||(t.initialConnectionStart=t.connectionStart),n&&r&&function(e,t,n){Hb.forEach((function(i){var r=Xb(i,t);e[i]<t[i]+n?Ep(e,i,t[i]+n):e[i]>t[i]+r-n&&Ep(e,i,t[i]+r-n)}))}(e,r,function(e){return _r(e,"bpmn:Task")?Vb:zb}(r)),r&&function(e,t){return _(t,(function(t){return Qb(e,t)}))}(n,["bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:SequenceFlow"])?(t.connectionStart=wp(i),Er(r,["bpmn:Event","bpmn:Gateway"])&&Gb(e,wp(r)),Er(r,["bpmn:Task","bpmn:SubProcess"])&&function(e,t){var n=wp(t);Hb.forEach((function(i){(function(e,t,n){return e[n]>t[n]+Fb&&e[n]<t[n]+Xb(n,t)-Fb})(e,t,i)&&Ep(e,i,n[i])}))}(e,r),_r(o,"bpmn:BoundaryEvent")&&s===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=wp(n),o=xn(r,i,-10),s=[];/top|bottom/.test(o)&&s.push("x");/left|right/.test(o)&&s.push("y");s.forEach((function(t){var n,i=e[t];Ub(i-r[t])<qb&&(n=i>r[t]?r[t]+qb:r[t]-qb,Ep(e,t,n))}))}(e)):Qb(n,"bpmn:MessageFlow")?(_r(i,"bpmn:Event")&&(t.connectionStart=wp(i)),_r(r,"bpmn:Event")&&Gb(e,wp(r))):t.connectionStart=t.initialConnectionStart)}))}function Gb(e,t){Ep(e,"x",t.x),Ep(e,"y",t.y)}function Qb(e,t){return e&&e.type===t}function Xb(e,t){return"x"===e?t.width:t.height}function Kb(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}function Yb(){this._snapValues={}}Wb.$inject=["eventBus"],Kb.prototype.getSnapOrigin=function(e){return this._snapOrigins[e]},Kb.prototype.setSnapOrigin=function(e,t){this._snapOrigins[e]=t,-1===this._snapLocations.indexOf(e)&&this._snapLocations.push(e)},Kb.prototype.addDefaultSnap=function(e,t){var n=this._defaultSnaps[e];n||(n=this._defaultSnaps[e]=[]),n.push(t)},Kb.prototype.getSnapLocations=function(){return this._snapLocations},Kb.prototype.setSnapLocations=function(e){this._snapLocations=e},Kb.prototype.pointsForTarget=function(e){var t=e.id||e,n=this._targets[t];return n||(n=this._targets[t]=new Yb).initDefaults(this._defaultSnaps),n},Yb.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)},Yb.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],yp(r-e)<=n)return r}(e[n],r[n],i)},Yb.prototype.initDefaults=function(e){var t=this;v(e||{},(function(e,n){v(e,(function(e){t.add(n,e)}))}))};var Zb=1250;function Jb(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"],Zb,(function(e){var t=e.context,r=t.shape,o=t.snapContext,s=t.target;if((!e.originalEvent||!js(e.originalEvent))&&!_p(e)&&s){var a=o.pointsForTarget(s);a.initialized||((a=i.addSnapTargetPoints(a,r,s)).initialized=!0),n.snap(e,a)}})),t.on(["create.cleanup","shape.move.cleanup"],(function(){n.hide()}))}Jb.$inject=["elementRegistry","eventBus","snapping"],Jb.prototype.initSnap=function(e){var t,n=this._elementRegistry,i=e.context,r=i.shape,o=i.snapContext;o||(o=i.snapContext=new Kb);var s=(t=n.get(r.id)?wp(r,e):{x:e.x+wp(r).x,y:e.y+wp(r).y}).x-r.width/2,a=t.y-r.height/2,l=t.x+r.width/2,c=t.y+r.height/2;return o.setSnapOrigin("mid",{x:t.x-e.x,y:t.y-e.y}),hn(r)||(o.setSnapOrigin("top-left",{x:s-e.x,y:a-e.y}),o.setSnapOrigin("bottom-right",{x:l-e.x,y:c-e.y})),o},Jb.prototype.addSnapTargetPoints=function(e,t,n){return v(this.getSnapTargets(t,n),(function(n){if(hn(n))hn(t)&&e.add("mid",wp(n));else if(dn(n)){if(n.waypoints.length<3)return;v(n.waypoints.slice(1,-1),(function(t){e.add("mid",t)}))}else e.add("mid",wp(n))})),u(t.x)&&u(t.y)?(this._elementRegistry.get(t.id)&&e.add("mid",wp(t)),e):e},Jb.prototype.getSnapTargets=function(e,t){return Op(t).filter((function(e){return!e.hidden}))};function ex(e,t){t.invoke(Jb,this),e.on(["create.move","create.end"],1500,tx),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)&&!_p(e)&&function(e,t){var n,i=gn(t),r=fh(e,t),o=e.context,s=o.shape;n=s.parent?{x:0,y:0}:bn(s);/top/.test(r)?Ep(e,"y",i.top-n.y):/bottom/.test(r)&&Ep(e,"y",i.bottom-n.y);/left/.test(r)?Ep(e,"x",i.left-n.x):/right/.test(r)&&Ep(e,"x",i.right-n.x)}(e,i)}))}function tx(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)&&Ep(e,"x",e.x),(n&&n>=e.y||r&&r<=e.y)&&Ep(e,"y",e.y)}}function nx(e,t){return-1!==e.indexOf(t)}function ix(e,t,n){return t?{x:e.x-n.x,y:e.y-n.y}:{x:e.x,y:e.y}}e(ex,Jb),ex.$inject=["eventBus","injector"],ex.prototype.initSnap=function(e){var t=Jb.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",ix(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",ix(r,i,e))})),_r(n,"bpmn:Participant")&&t.setSnapLocations(["top-left","bottom-right","mid"]),t},ex.prototype.addSnapTargetPoints=function(e,t,n){Jb.prototype.addSnapTargetPoints.call(this,e,t,n);var i=this.getSnapTargets(t,n);v(i,(function(n){var i;(function(e){if(_r(e,"bpmn:SubProcess")&&Vr(e))return!0;return _r(e,"bpmn:Participant")}(n)||(i="bpmn:TextAnnotation",[t,n].every((function(e){return _r(e,i)}))))&&(e.add("top-left",bp(n)),e.add("bottom-right",xp(n)))}));var r=this._elementRegistry;return v(t.incoming,(function(n){if(r.get(t.id)){nx(i,n.source)||e.add("mid",bn(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)){nx(i,n.target)||e.add("mid",bn(n.target));var o=n.waypoints[n.waypoints.length-1];e.add(n.id+"-docking",o.original||o)}})),_r(n,"bpmn:SequenceFlow")&&(e=this.addSnapTargetPoints(e,t,n.parent)),e},ex.prototype.getSnapTargets=function(e,t){return Jb.prototype.getSnapTargets.call(this,e,t).filter((function(e){return!_r(e,"bpmn:Lane")}))};function rx(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,s=i.direction,a=i.snapContext;if(!(e.originalEvent&&js(e.originalEvent)||_p(e))){var l=a.pointsForTarget(o);l.initialized||((l=n.addSnapTargetPoints(l,r,o,s)).initialized=!0),function(e){return"n"===e||"s"===e}(s)&&Ep(e,"x",e.x),function(e){return"e"===e||"w"===e}(s)&&Ep(e,"y",e.y),t.snap(e,l)}})),e.on(["resize.cleanup"],(function(){t.hide()}))}function ox(e,t){var n=bn(e),i=gn(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}rx.prototype.initSnap=function(e){var t=e.context,n=t.shape,i=t.direction,r=t.snapContext;r||(r=t.snapContext=new Kb);var o=ox(n,i);return r.setSnapOrigin("corner",{x:o.x-e.x,y:o.y-e.y}),r},rx.prototype.addSnapTargetPoints=function(e,t,n,i){return v(this.getSnapTargets(t,n),(function(t){e.add("corner",xp(t)),e.add("corner",bp(t))})),e.add("corner",ox(t,i)),e},rx.$inject=["eventBus","snapping"],rx.prototype.getSnapTargets=function(e,t){return Op(t).filter((function(t){return!(n=t,i=e,n.host===i||dn(t)||function(e){return!!e.hidden}(t)||hn(t));var n,i}))};function sx(e){this._canvas=e,this._asyncHide=B($(this.hide,this),1e3)}sx.$inject=["canvas"],sx.prototype.snap=function(e,t){var n=e.context.snapContext,i=n.getSnapLocations(),r={x:_p(e,"x"),y:_p(e,"y")};v(i,(function(i){var o=n.getSnapOrigin(i),s={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(s,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];p(n)&&Ep(e,t,n.originValue)}))},sx.prototype._createLine=function(e){var t=this._canvas.getLayer("snap"),n=De("path");return Oe(n,{d:"M0,0 L0,0"}),ke(n).add("djs-snap-line"),xe(t,n),{update:function(t){u(t)?Oe(n,"horizontal"===e?{d:"M-100000,"+t+" L+100000,"+t,display:""}:{d:"M "+t+",-100000 L "+t+", +100000",display:""}):Oe(n,{display:"none"})}}},sx.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}},sx.prototype.showSnapLine=function(e,t){var n=this.getSnapLine(e);n&&n.update(t),this._asyncHide()},sx.prototype.getSnapLine=function(e){return this._snapLines||this._createSnapLines(),this._snapLines[e]},sx.prototype.hide=function(){v(this._snapLines,(function(e){e.update()}))};var ax={__depends__:[{__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",Jb],resizeSnapping:["type",rx],snapping:["type",sx]}],__init__:["connectSnapping","createMoveSnapping"],connectSnapping:["type",Wb],createMoveSnapping:["type",ex]};function lx(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=ye(lx.INPUT_SELECTOR,this._container),this._resultsContainer=ye(lx.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 cx(e,t,n){var i=function(e){var t="";return e.forEach((function(e){var n=Xo(e.value||e.matched||e.normal),i=e.match||e.matched;t+=i?'<b class="'+lx.RESULT_HIGHLIGHT_CLASS+'">'+n+"</b>":n})),""!==t?t:null}(t),r=fe(n);r.innerHTML=i,e.appendChild(r)}lx.$inject=["canvas","eventBus","selection","translate"],lx.prototype._bindEvents=function(){var e=this;function t(t,n,i,r){e._eventMaps.push({el:t,type:i,listener:ue.bind(t,n,i,r)})}t(document,"html","click",(function(t){e.close(!1)})),t(this._container,lx.INPUT_SELECTOR,"click",(function(e){e.stopPropagation(),e.delegateTarget.focus()})),t(this._container,lx.RESULT_SELECTOR,"mouseover",(function(t){t.stopPropagation(),e._scrollToNode(t.delegateTarget),e._preselect(t.delegateTarget)})),t(this._container,lx.RESULT_SELECTOR,"click",(function(t){t.stopPropagation(),e._select(t.delegateTarget)})),t(this._container,lx.INPUT_SELECTOR,"keydown",(function(e){Is("ArrowUp",e)&&e.preventDefault(),Is("ArrowDown",e)&&e.preventDefault()})),t(this._container,lx.INPUT_SELECTOR,"keyup",(function(t){if(Is("Escape",t))return e.close();if(Is("Enter",t)){var n=e._getCurrentResult();return n?e._select(n):e.close(!1)}return Is("ArrowUp",t)?e._scrollToDirection(!0):Is("ArrowDown",t)?e._scrollToDirection():void(Is(["ArrowLeft","ArrowRight"],t)||e._search(t.delegateTarget.value))}))},lx.prototype._unbindEvents=function(){this._eventMaps.forEach((function(e){ue.unbind(e.el,e.type,e.listener)}))},lx.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=ye(lx.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}else this._selection.select(null)}},lx.prototype._scrollToDirection=function(e){var t=this._getCurrentResult();if(t){var n=e?t.previousElementSibling:t.nextElementSibling;n&&(this._scrollToNode(n),this._preselect(n))}},lx.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)}},lx.prototype._clearResults=function(){J(this._resultsContainer),this._results={},this._eventBus.fire("searchPad.cleared")},lx.prototype._getCurrentResult=function(){return ye(lx.RESULT_SELECTED_SELECTOR,this._resultsContainer)},lx.prototype._createResultNode=function(e,t){var n=fe(lx.RESULT_HTML);return e.primaryTokens.length>0&&cx(n,e.primaryTokens,lx.RESULT_PRIMARY_HTML),cx(n,e.secondaryTokens,lx.RESULT_SECONDARY_HTML),X(n,lx.RESULT_ID_ATTRIBUTE,t),this._resultsContainer.appendChild(n),n},lx.prototype.registerProvider=function(e){this._searchProvider=e},lx.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,Y(this._canvas.getContainer()).add("djs-search-open"),Y(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))},lx.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,Y(this._canvas.getContainer()).remove("djs-search-open"),Y(this._container).remove("open"),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._eventBus.fire("searchPad.closed"),this._canvas.restoreFocus())},lx.prototype.toggle=function(){this.isOpen()?this.close():this.open()},lx.prototype.isOpen=function(){return this._open},lx.prototype._preselect=function(e){var t=this._getCurrentResult();if(e!==t){t&&Y(t).remove(lx.RESULT_SELECTED_CLASS);var n=X(e,lx.RESULT_ID_ATTRIBUTE),i=this._results[n].element;Y(e).add(lx.RESULT_SELECTED_CLASS),this._canvas.scrollToElement(i,{top:300}),this._selection.select(i),this._eventBus.fire("searchPad.preselected",i)}},lx.prototype._select=function(e){var t=X(e,lx.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)},lx.prototype._getBoxHtml=function(){const e=fe(lx.BOX_HTML),t=ye(lx.INPUT_SELECTOR,e);return t&&t.setAttribute("aria-label",this._translate("Search in diagram")),e},lx.CONTAINER_SELECTOR=".djs-search-container",lx.INPUT_SELECTOR=".djs-search-input input",lx.RESULTS_CONTAINER_SELECTOR=".djs-search-results",lx.RESULT_SELECTOR=".djs-search-result",lx.RESULT_SELECTED_CLASS="djs-search-result-selected",lx.RESULT_SELECTED_SELECTOR="."+lx.RESULT_SELECTED_CLASS,lx.RESULT_ID_ATTRIBUTE="data-result-id",lx.RESULT_HIGHLIGHT_CLASS="djs-search-highlight",lx.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>',lx.RESULT_HTML='<div class="djs-search-result"></div>',lx.RESULT_PRIMARY_HTML='<div class="djs-search-result-primary"></div>',lx.RESULT_SECONDARY_HTML='<p class="djs-search-result-secondary"></p>';var px={__depends__:[Co,qo,Ts],searchPad:["type",lx]};function ux(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._search=i,t.registerProvider(this)}function dx(e){const{item:{element:t},tokens:n}=e;return{element:t,primaryTokens:n.label,secondaryTokens:n.id}}ux.$inject=["elementRegistry","searchPad","canvas","search"],ux.prototype.find=function(e){var t=this._canvas.getRootElements(),n=this._elementRegistry.filter((function(e){return!hn(e)&&!t.includes(e)}));return this._search(n.map((e=>({element:e,label:eo(e),id:e.id}))),e,{keys:["label","id"]}).map(dx)};var hx={__depends__:[px,Hl],__init__:["bpmnSearch"],bpmnSearch:["type",ux]};const mx={width:36,height:50},fx={width:50,height:50};function gx(e,t,n){return De("path",{d:e,strokeWidth:2,transform:`translate(${t.x}, ${t.y})`,...n})}function yx(e,t){this._styles=t,e.registerProvider(this)}function vx(e,t){var n;return"bpmn:DataObjectReference"===t?n=mx:"bpmn:DataStoreReference"===t&&(n=fx),e.width===n.width&&e.height===n.height}yx.$inject=["outline","styles"],yx.prototype.getOutline=function(e){const t=this._styles.cls("djs-outline",["no-fill"]);var n;if(!hn(e))return _r(e,"bpmn:Gateway")?(j((n=De("rect")).style,{"transform-box":"fill-box",transform:"rotate(45deg)","transform-origin":"center"}),Oe(n,j({x:2,y:2,rx:4,width:e.width-4,height:e.height-4},t))):Er(e,["bpmn:Task","bpmn:SubProcess","bpmn:Group","bpmn:CallActivity"])?Oe(n=De("rect"),j({x:-5,y:-5,rx:14,width:e.width+10,height:e.height+10},t)):_r(e,"bpmn:EndEvent")?Oe(n=De("circle"),j({cx:e.width/2,cy:e.height/2,r:e.width/2+5+1},t)):_r(e,"bpmn:Event")?Oe(n=De("circle"),j({cx:e.width/2,cy:e.height/2,r:e.width/2+5},t)):_r(e,"bpmn:DataObjectReference")&&vx(e,"bpmn:DataObjectReference")?n=gx("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):_r(e,"bpmn:DataStoreReference")&&vx(e,"bpmn:DataStoreReference")&&(n=gx("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},yx.prototype.updateOutline=function(e,t){if(!hn(e))return Er(e,["bpmn:SubProcess","bpmn:Group"])?(Oe(t,{width:e.width+10,height:e.height+10}),!0):!!Er(e,["bpmn:Event","bpmn:Gateway","bpmn:DataStoreReference","bpmn:DataObjectReference"])};var bx={__depends__:[rb],__init__:["outlineProvider"],outlineProvider:["type",yx]};function xx(e){zr.call(this,e)}e(xx,zr),xx.Viewer=Rs,xx.NavigatedViewer=da,xx.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>')},xx.prototype._interactionModules=[Ks,oa,ua],xx.prototype._modelingModules=[Zl,fc,Mc,xc,Cp,Np,$p,Fy,Em,um,Ky,nv,yv,bv,wv,Av,Gv,uy,tb,hb,jb,Lb,qv,ax,hx,bx],xx.prototype._modules=[].concat(Rs.prototype._modules,xx.prototype._interactionModules,xx.prototype._modelingModules);var wx=new No,_x={min:.2,max:4};function Ex(e,t,n,i,r){var o=this;function s(e){o._state._svgClientRect&&!Cx(o._state._svgClientRect)||(o._state._svgClientRect=o._svg.getBoundingClientRect()),Px(Ox({x:e.x-o._state._svgClientRect.left,y:e.y-o._state._svgClientRect.top},o._svg,o._lastViewbox),o._canvas),o._update()}function a(e){return function(t){var n=Dx(t);o._state._svgClientRect&&!Cx(o._state._svgClientRect)||(o._state._svgClientRect=o._svg.getBoundingClientRect()),e&&s(n);var r=Ox({x:n.x-o._state._svgClientRect.left,y:n.y-o._state._svgClientRect.top},o._svg,o._lastViewbox),a=i.viewbox(),p=function(e,t){var n={x:t.x+t.width/2,y:t.y+t.height/2};return{x:e.x-n.x,y:e.y-n.y}}(r,a),u=o._viewportDom.getBoundingClientRect(),d={x:n.x-u.left+1,y:n.y-u.top+1};j(o._state,{cachedViewbox:a,initialDragPosition:{x:n.x,y:n.y},isDragging:!0,offsetViewport:p,offsetViewportDom:d,viewportClientRect:o._viewport.getBoundingClientRect(),parentClientRect:o._parent.getBoundingClientRect()}),le.bind(document,"mousemove",l),le.bind(document,"mouseup",c)}}function l(e){var t=Dx(e);if(o._state.isDragging){o._state._svgClientRect&&!Cx(o._state._svgClientRect)||(o._state._svgClientRect=o._svg.getBoundingClientRect());var n=o._state.offsetViewportDom,i=o._state.viewportClientRect,r=o._state.parentClientRect;j(o._viewportDom.style,{top:t.y-n.y-r.top+"px",left:t.x-n.x-r.left+"px"});var s=Mx(r,{top:t.y-n.y-r.top,left:t.x-n.x-r.left,width:i.width,height:i.height});j(o._overlay.style,{clipPath:s});var a=Ox({x:t.x-o._state._svgClientRect.left,y:t.y-o._state._svgClientRect.top},o._svg,o._lastViewbox);Px({x:a.x-o._state.offsetViewport.x,y:a.y-o._state.offsetViewport.y},o._canvas)}}function c(e){var t=Dx(e);o._state.isDragging&&(o._state.initialDragPosition.x===t.x&&o._state.initialDragPosition.y===t.y&&s(e),o._update(),j(o._state,{cachedViewbox:null,initialDragPosition:null,isDragging:!1,offsetViewport:null,offsetViewportDom:null}),le.unbind(document,"mousemove",l),le.unbind(document,"mouseup",c))}this._canvas=i,this._elementRegistry=r,this._eventBus=n,this._injector=t,this._state={isOpen:void 0,isDragging:!1,initialDragPosition:null,offsetViewport:null,cachedViewbox:null,dragger:null,svgClientRect:null,parentClientRect:null,zoomDelta:0},this._minimapId=wx.next(),this._init(),this.toggle(e&&e.open||!1),le.bind(this._viewportDom,"mousedown",a(!1)),le.bind(this._svg,"mousedown",a(!0)),le.bind(this._parent,"wheel",(function(e){if(e.preventDefault(),e.stopPropagation(),e.ctrlKey&&(o._state._svgClientRect&&!Cx(o._state._svgClientRect)||(o._state._svgClientRect=o._svg.getBoundingClientRect()),t=e,n=o._state._svgClientRect,t.x>n.left&&t.x<n.left+n.width&&t.y>n.top&&t.y<n.top+n.height)){var t,n,r,s,a,l,c=0===e.deltaMode?.02:.32,p=Math.sqrt(Math.pow(e.deltaY,2)+Math.pow(e.deltaX,2))*Ax(e.deltaY)*-c;if(o._state.zoomDelta+=p,Math.abs(o._state.zoomDelta)>.1){var u=p>0?1:-1,d=Math.log(i.zoom())/Math.log(10),h=(r=_x,s=20,a=Math.log(r.min)/Math.log(10),l=Math.log(r.max)/Math.log(10),(Math.abs(a)+Math.abs(l))/s),m=Math.round(d/h)*h;m+=h*u;var f=Math.pow(10,m);i.zoom(function(e,t){return Math.max(e.min,Math.min(e.max,t))}(_x,f),g),o._state.zoomDelta=0;var g=Ox({x:e.clientX-o._state._svgClientRect.left,y:e.clientY-o._state._svgClientRect.top},o._svg,o._lastViewbox);Px(g,o._canvas),o._update()}}})),le.bind(this._toggle,"click",(function(e){e.preventDefault(),e.stopPropagation(),o.toggle()})),n.on(["shape.added","connection.added"],(function(e){var t=e.element;o._addElement(t),o._update()})),n.on(["shape.removed","connection.removed"],(function(e){var t=e.element;o._removeElement(t),o._update()})),n.on("elements.changed",250,(function(e){e.elements.forEach((function(e){o._updateElement(e)})),o._update()})),n.on("element.updateId",(function(e){var t=e.element,n=e.newId;o._updateElementId(t,n)})),n.on("canvas.viewbox.changed",(function(){o._state.isDragging||o._update()})),n.on("canvas.resized",(function(){document.body.contains(o._parent)&&(o._state.isDragging||o._update(),o._state._svgClientRect=o._svg.getBoundingClientRect())})),n.on(["root.set","plane.set"],(function(e){o._clear(),(e.element||e.plane.rootElement).children.forEach((function(e){o._addElement(e)})),o._update()}))}function Ox(e,t,n){var i=t.getBoundingClientRect(),r=function(e,t){var n=e.width/e.height,i=j({},{x:e.x,y:e.y,width:e.width,height:e.height});if(n>t){var r=i.width*(1/t);j(i,{y:i.y-(r-i.height)/2,height:r})}else if(n<t){var o=i.height*t;j(i,{x:i.x-(o-i.width)/2,width:o})}return i}(n,i.width/i.height);return{x:kx(e.x,0,i.width,r.x,r.x+r.width),y:kx(e.y,0,i.height,r.y,r.y+r.height)}}function Px(e,t){var n=t.viewbox(),i=n.width,r=n.height;t.viewbox({x:e.x-i/2,y:e.y-r/2,width:i,height:r})}function kx(e,t,n,i,r){return(e-t)*(r-i)/(n-t)+i}function Sx(e,t,n){var i=function(e){var t=ye(".children",e);t||xe(e,t=De("g",{class:"children"}));return t}(t),r=[].slice.call(i.childNodes)[n];r?t.insertBefore(e,r.nextSibling):t.appendChild(e)}function Cx(e){return 0===e.width&&0===e.height}Ex.$inject=["config.minimap","injector","eventBus","canvas","elementRegistry"],Ex.prototype._init=function(){var e=this._canvas.getContainer(),t=this._parent=document.createElement("div");Y(t).add("djs-minimap"),e.appendChild(t);var n=this._toggle=document.createElement("div");Y(n).add("toggle"),t.appendChild(n);var i=this._map=document.createElement("div");Y(i).add("map"),t.appendChild(i);var r=this._svg=De("svg");Oe(r,{width:"100%",height:"100%"}),xe(i,r),xe(r,this._elementsGroup=De("g"));var o=this._viewportGroup=De("g");xe(r,o);var s=this._viewport=De("rect");ke(s).add("viewport"),xe(o,s),le.bind(t,"mousedown",(function(e){e.stopPropagation()}));var a=this._viewportDom=document.createElement("div");Y(a).add("viewport-dom"),this._parent.appendChild(a);var l=this._overlay=document.createElement("div");Y(l).add("overlay"),this._parent.appendChild(l)},Ex.prototype._update=function(){var e=this._canvas.viewbox(),t=e.inner,n=e.outer;if(Rx(e)){var i,r,o,s,a=n.width-t.width,l=n.height-t.height;t.width<n.width?(i=t.x-a/2,o=n.width,t.x+t.width<n.width&&(i=Math.min(0,t.x))):(i=t.x,o=t.width),t.height<n.height?(r=t.y-l/2,s=n.height,t.y+t.height<n.height&&(r=Math.min(0,t.y))):(r=t.y,s=t.height),i-=50,r-=50,o+=100,s+=100,this._lastViewbox={x:i,y:r,width:o,height:s},Oe(this._svg,{viewBox:i+", "+r+", "+o+", "+s}),Oe(this._viewport,{x:e.x,y:e.y,width:e.width,height:e.height});var c=this._state._parentClientRect=this._parent.getBoundingClientRect(),p=this._viewport.getBoundingClientRect(),u={top:p.top-c.top,left:p.left-c.left,width:p.width,height:p.height};j(this._viewportDom.style,{top:u.top+"px",left:u.left+"px",width:u.width+"px",height:u.height+"px"});var d=Mx(c,u);j(this._overlay.style,{clipPath:d})}},Ex.prototype.open=function(){j(this._state,{isOpen:!0}),Y(this._parent).add("open");var e=this._injector.get("translate",!1)||function(e){return e};X(this._toggle,"title",e("Close minimap")),this._update(),this._eventBus.fire("minimap.toggle",{open:!0})},Ex.prototype.close=function(){j(this._state,{isOpen:!1}),Y(this._parent).remove("open");var e=this._injector.get("translate",!1)||function(e){return e};X(this._toggle,"title",e("Open minimap")),this._eventBus.fire("minimap.toggle",{open:!1})},Ex.prototype.toggle=function(e){var t=this.isOpen();void 0===e&&(e=!t),e!=t&&(e?this.open():this.close())},Ex.prototype.isOpen=function(){return this._state.isOpen},Ex.prototype._updateElement=function(e){try{void 0!==e.parent&&null!==e.parent&&(this._removeElement(e),this._addElement(e))}catch(e){console.warn("Minimap#_updateElement errored",e)}},Ex.prototype._updateElementId=function(e,t){try{var n=ye("#"+Go(this._prefixId(e.id)),this._elementsGroup);n&&(n.id=this._prefixId(t))}catch(e){console.warn("Minimap#_updateElementId errored",e)}},Ex.prototype.isOnActivePlane=function(e){var t=this._canvas;return t.findRoot?t.findRoot(e)===t.getRootElement():!t.findPlane||t.findPlane(e)===t.getActivePlane()},Ex.prototype._addElement=function(e){var t=this;if(this._removeElement(e),this.isOnActivePlane(e)){var n,i,r,o=this._createElement(e),s=ye("#"+Go(this._prefixId(e.parent.id)),this._elementsGroup);if(o){var a=function(e,t){var n=ye(".djs-children",t.parentNode);if(!n)return;var i=[].slice.call(n.childNodes),r=-1;return i.forEach((function(t,n){ye(".djs-element",t)===e&&(r=n)})),r}(this._elementRegistry.getGraphics(e),this._elementRegistry.getGraphics(e.parent));return"undefined"!==a&&s?s.childNodes.length>a?Sx(o,s,a):Sx(o,s,s.childNodes.length-1):this._elementsGroup.appendChild(o),!function(e){return e.waypoints}(e)?(i=e.x,r=e.y,s&&(i-=(n=e.parent).x,r-=n.y),Oe(o,{transform:"translate("+i+" "+r+")"})):(i=0,r=0,void 0!==(n=e.parent).x&&void 0!==n.y&&(i=-n.x,r=-n.y),Oe(o,{transform:"translate("+i+" "+r+")"})),e.children&&e.children.length&&e.children.forEach((function(e){t._addElement(e)})),o}}},Ex.prototype._removeElement=function(e){var t=this._svg.getElementById(this._prefixId(e.id));t&&He(t)},Ex.prototype._createElement=function(e){var t,n=this._elementRegistry.getGraphics(e);if(n&&(t=Qn(n))){var i=function(e){return ve("[id]",e).forEach((function(e){e.remove()})),e}(Ae(t));return Oe(i,{id:this._prefixId(e.id)}),i}},Ex.prototype._clear=function(){Ce(this._elementsGroup)},Ex.prototype._prefixId=function(e){return"djs-minimap-"+e+"-"+this._minimapId};var Ax=Math.sign||function(e){return e>=0?1:-1};function Mx(e,t){return"polygon("+[Tx(t.left,t.top),Tx(t.left+t.width,t.top),Tx(t.left+t.width,t.top+t.height),Tx(t.left,t.top+t.height),Tx(t.left,e.height),Tx(e.width,e.height),Tx(e.width,0),Tx(0,0),Tx(0,e.height),Tx(t.left,e.height)].join(", ")+")"}function Tx(e,t){return e+"px "+t+"px"}function Rx(e){return w(e,(function(e){return p(e)?Rx(e):u(e)&&isFinite(e)}))}function Dx(e){return e.center?e.center:{x:e.clientX,y:e.clientY}}var Nx={__init__:["minimap"],minimap:["type",Ex]},Bx=1e5,$x=1e5;function jx(e,t){this._canvas=e;var n=this;t.on("diagram.init",(function(){n._init(),n.toggle(!0)})),t.on("gridSnapping.toggle",(function(e){var t=e.active;n.toggle(t),n._centerGridAroundViewbox()})),t.on("canvas.viewbox.changed",(function(e){var t=e.viewbox;n._centerGridAroundViewbox(t)}))}jx.prototype._init=function(){var e=ye("defs",this._canvas._svg);e||(e=De("defs"),xe(this._canvas._svg,e));var t=this._pattern=De("pattern"),n="djs-grid-pattern-"+Math.trunc(1e6*Math.random());Oe(t,{id:n,width:rv,height:rv,patternUnits:"userSpaceOnUse"});var i=this._circle=De("circle");Oe(i,{cx:.5,cy:.5,r:.5,fill:"#ccc"}),xe(t,i),xe(e,t),Oe(this._gfx=De("rect"),{x:-Bx/2,y:-$x/2,width:Bx,height:$x,fill:`url(#${n})`})},jx.prototype._centerGridAroundViewbox=function(e){e||(e=this._canvas.viewbox());var t=bn(e);Oe(this._gfx,{x:-Bx/2+ov(t.x,rv),y:-$x/2+ov(t.y,rv)})},jx.prototype.isVisible=function(){return this._visible},jx.prototype.toggle=function(e){if(void 0===e&&(e=!this._visible),e!==this._visible){var t=this._getParent();e?xe(t,this._gfx):Ce(t),this._visible=e}},jx.prototype._getParent=function(){return this._canvas.getLayer("djs-grid",-2)},jx.$inject=["canvas","eventBus"];var Ix={__init__:["grid"],grid:["type",jx]};function Lx(e,t){var n,i,r=(e=e||{}).borderColor||"rgba(0,0,0,0.1)",o=e.crossColor||"#CCC",s=-1;xe(t.getLayer("djs-origin",-1),n=Vx("g",{"pointer-events":"none"})),!1!==e.showBorder&&xe(n,Vx("path",{class:zx("border"),d:qx(["M",-22,s,"H",-1e3,"M",22,s,"H",6e3,"M",s,-22,"V",-1e3,"M",s,22,"V",3e3]),fill:"none",stroke:r,"stroke-width":"2px","stroke-dasharray":"6, 6","shape-rendering":"crispedges"})),xe(n,Vx("path",{d:qx(["M",-15,s,"H",15,"M",s,-15,"V",15]),class:zx("cross"),fill:"none",stroke:o,"stroke-width":"2px","stroke-linecap":"round"})),(i=Vx("text",{x:-40,y:-10,fill:o,class:zx("label")})).textContent="(0, 0)",xe(n,i)}function qx(e){return e.join(" ")}function zx(e){return"djs-origin-"+e}function Vx(e,t){var n=De(e);return Oe(n,t),n}Lx.$inject=["config.origin","canvas"];var Fx={__init__:[Lx]},Hx={offset:{x:150,y:75},tolerance:50,alignOnSave:!0};function Ux(e,t,n,i,r,o){function s(e,n){var i=n.offset,r=n.tolerance,o={};return["x","y"].forEach((function(n){var s=-e[n]+i[n],a=t.get("gridSnapping",!1);a&&(s=function(e,t,n){n||(n="round");return Math[n](e/t)*t}(s,a.getGridSpacing())),o[n]=Math.abs(s)<r?0:s})),o}function a(){var t=r.viewbox().inner,n=r.getRootElement().children;if(n.length){var o=s(t,e);0===o.x&&0===o.y||i.execute("elements.alignToOrigin",{elements:n,delta:o})}}function l(e){return function(t){n.once("commandStack.changed",(function(){var n=t.delta,i=r.viewbox().scale;r.scroll({dx:e*n.x*i,dy:e*n.y*i})}))}}var c,p,d;e=function(e){var t=j({},Hx,e||{});return u(t.offset)&&(t.offset={x:t.offset,y:t.offset}),t}(e),i.register("elements.alignToOrigin",{preExecute:function(e){var t=e.delta,n=e.elements;o.moveElements(n,t)},execute:l(-1),revert:l(1)}),e.alignOnSave&&(c=t.get("_parent",!1),p=n,((d=c&&c._eventBus)||p).on("saveXML.start",1250,a),d&&p.on("diagram.destroy",(function(){d.off("saveXML.start",a)}))),this.align=a,this.computeAdjustment=s,this._config=e}Ux.$inject=["config.alignToOrigin","injector","eventBus","commandStack","canvas","modeling"];var Wx={__init__:["alignToOrigin"],alignToOrigin:["type",Ux]};function Gx(e){function t(e){if(!e.labelTarget){var t=Or(e);_r(t,"bpmn:Participant")&&(t=t.processRef),_r(t,"bpmn:Process")&&(t.isExecutable=!!t.isExecutable)}}e.on(["shape.added","root.added"],(function(e){t(e.element)})),e.on("elements.changed",(function(e){e.elements.forEach((function(e){t(e)}))}))}Gx.$inject=["eventBus"];var Qx,Xx,Kx,Yx,Zx,Jx,ew,tw,nw={__init__:[Gx]},iw={},rw=[],ow=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,sw=Array.isArray;function aw(e,t){for(var n in t)e[n]=t[n];return e}function lw(e){var t=e.parentNode;t&&t.removeChild(e)}function cw(e,t,n){var i,r,o,s={};for(o in t)"key"==o?i=t[o]:"ref"==o?r=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?Qx.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===s[o]&&(s[o]=e.defaultProps[o]);return pw(e,s,i,r,null)}function pw(e,t,n,i,r){var o={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++Kx:r,__i:-1,__u:0};return null==r&&null!=Xx.vnode&&Xx.vnode(o),o}function uw(e){return e.children}function dw(e,t){this.props=e,this.context=t}function hw(e,t){if(null==t)return e.__?hw(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?hw(e):null}function mw(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return mw(e)}}function fw(e){(!e.__d&&(e.__d=!0)&&Yx.push(e)&&!gw.__r++||Zx!==Xx.debounceRendering)&&((Zx=Xx.debounceRendering)||Jx)(gw)}function gw(){var e,t,n,i,r,o,s,a,l;for(Yx.sort(ew);e=Yx.shift();)e.__d&&(t=Yx.length,i=void 0,o=(r=(n=e).__v).__e,a=[],l=[],(s=n.__P)&&((i=aw({},r)).__v=r.__v+1,Xx.vnode&&Xx.vnode(i),Pw(s,i,r,n.__n,void 0!==s.ownerSVGElement,32&r.__u?[o]:null,a,null==o?hw(r):o,!!(32&r.__u),l),i.__.__k[i.__i]=i,kw(a,i,l),i.__e!=o&&mw(i)),Yx.length>t&&Yx.sort(ew));gw.__r=0}function yw(e,t,n,i,r,o,s,a,l,c,p){var u,d,h,m,f,g=i&&i.__k||rw,y=t.length;for(n.__d=l,function(e,t,n){var i,r,o,s,a,l=t.length,c=n.length,p=c,u=0;for(e.__k=[],i=0;i<l;i++)null!=(r=e.__k[i]=null==(r=t[i])||"boolean"==typeof r||"function"==typeof r?null:"string"==typeof r||"number"==typeof r||"bigint"==typeof r||r.constructor==String?pw(null,r,null,null,r):sw(r)?pw(uw,{children:r},null,null,null):void 0===r.constructor&&r.__b>0?pw(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)?(r.__=e,r.__b=e.__b+1,a=xw(r,n,s=i+u,p),r.__i=a,o=null,-1!==a&&(p--,(o=n[a])&&(o.__u|=131072)),null==o||null===o.__v?(-1==a&&u--,"function"!=typeof r.type&&(r.__u|=65536)):a!==s&&(a===s+1?u++:a>s?p>l-s?u+=a-s:u--:u=a<s&&a==s-1?a-s:0,a!==i+u&&(r.__u|=65536))):(o=n[i])&&null==o.key&&o.__e&&(o.__e==e.__d&&(e.__d=hw(o)),Cw(o,o,!1),n[i]=null,p--);if(p)for(i=0;i<c;i++)null!=(o=n[i])&&!(131072&o.__u)&&(o.__e==e.__d&&(e.__d=hw(o)),Cw(o,o))}(n,t,g),l=n.__d,u=0;u<y;u++)null!=(h=n.__k[u])&&"boolean"!=typeof h&&"function"!=typeof h&&(d=-1===h.__i?iw:g[h.__i]||iw,h.__i=u,Pw(e,h,d,r,o,s,a,l,c,p),m=h.__e,h.ref&&d.ref!=h.ref&&(d.ref&&Sw(d.ref,null,h),p.push(h.ref,h.__c||m,h)),null==f&&null!=m&&(f=m),65536&h.__u||d.__k===h.__k?l=vw(h,l,e):"function"==typeof h.type&&void 0!==h.__d?l=h.__d:m&&(l=m.nextSibling),h.__d=void 0,h.__u&=-196609);n.__d=l,n.__e=f}function vw(e,t,n){var i,r;if("function"==typeof e.type){for(i=e.__k,r=0;i&&r<i.length;r++)i[r]&&(i[r].__=e,t=vw(i[r],t,n));return t}return e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function bw(e,t){return t=t||[],null==e||"boolean"==typeof e||(sw(e)?e.some((function(e){bw(e,t)})):t.push(e)),t}function xw(e,t,n,i){var r=e.key,o=e.type,s=n-1,a=n+1,l=t[n];if(null===l||l&&r==l.key&&o===l.type)return n;if(i>(null==l||131072&l.__u?0:1))for(;s>=0||a<t.length;){if(s>=0){if((l=t[s])&&!(131072&l.__u)&&r==l.key&&o===l.type)return s;s--}if(a<t.length){if((l=t[a])&&!(131072&l.__u)&&r==l.key&&o===l.type)return a;a++}}return-1}function ww(e,t,n){"-"===t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||ow.test(t)?n:n+"px"}function _w(e,t,n,i,r){var o;e:if("style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof i&&(e.style.cssText=i=""),i)for(t in i)n&&t in n||ww(e.style,t,"");if(n)for(t in n)i&&n[t]===i[t]||ww(e.style,t,n[t])}else if("o"===t[0]&&"n"===t[1])o=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?i?n.u=i.u:(n.u=Date.now(),e.addEventListener(t,o?Ow:Ew,o)):e.removeEventListener(t,o?Ow:Ew,o);else{if(r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&"rowSpan"!==t&&"colSpan"!==t&&"role"!==t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,n))}}function Ew(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(Xx.event?Xx.event(e):e)}function Ow(e){return this.l[e.type+!0](Xx.event?Xx.event(e):e)}function Pw(e,t,n,i,r,o,s,a,l,c){var p,u,d,h,m,f,g,y,v,b,x,w,_,E,O,P=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(l=!!(32&n.__u),o=[a=t.__e=n.__e]),(p=Xx.__b)&&p(t);e:if("function"==typeof P)try{if(y=t.props,v=(p=P.contextType)&&i[p.__c],b=p?v?v.props.value:p.__:i,n.__c?g=(u=t.__c=n.__c).__=u.__E:("prototype"in P&&P.prototype.render?t.__c=u=new P(y,b):(t.__c=u=new dw(y,b),u.constructor=P,u.render=Aw),v&&v.sub(u),u.props=y,u.state||(u.state={}),u.context=b,u.__n=i,d=u.__d=!0,u.__h=[],u._sb=[]),null==u.__s&&(u.__s=u.state),null!=P.getDerivedStateFromProps&&(u.__s==u.state&&(u.__s=aw({},u.__s)),aw(u.__s,P.getDerivedStateFromProps(y,u.__s))),h=u.props,m=u.state,u.__v=t,d)null==P.getDerivedStateFromProps&&null!=u.componentWillMount&&u.componentWillMount(),null!=u.componentDidMount&&u.__h.push(u.componentDidMount);else{if(null==P.getDerivedStateFromProps&&y!==h&&null!=u.componentWillReceiveProps&&u.componentWillReceiveProps(y,b),!u.__e&&(null!=u.shouldComponentUpdate&&!1===u.shouldComponentUpdate(y,u.__s,b)||t.__v===n.__v)){for(t.__v!==n.__v&&(u.props=y,u.state=u.__s,u.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.forEach((function(e){e&&(e.__=t)})),x=0;x<u._sb.length;x++)u.__h.push(u._sb[x]);u._sb=[],u.__h.length&&s.push(u);break e}null!=u.componentWillUpdate&&u.componentWillUpdate(y,u.__s,b),null!=u.componentDidUpdate&&u.__h.push((function(){u.componentDidUpdate(h,m,f)}))}if(u.context=b,u.props=y,u.__P=e,u.__e=!1,w=Xx.__r,_=0,"prototype"in P&&P.prototype.render){for(u.state=u.__s,u.__d=!1,w&&w(t),p=u.render(u.props,u.state,u.context),E=0;E<u._sb.length;E++)u.__h.push(u._sb[E]);u._sb=[]}else do{u.__d=!1,w&&w(t),p=u.render(u.props,u.state,u.context),u.state=u.__s}while(u.__d&&++_<25);u.state=u.__s,null!=u.getChildContext&&(i=aw(aw({},i),u.getChildContext())),d||null==u.getSnapshotBeforeUpdate||(f=u.getSnapshotBeforeUpdate(h,m)),yw(e,sw(O=null!=p&&p.type===uw&&null==p.key?p.props.children:p)?O:[O],t,n,i,r,o,s,a,l,c),u.base=t.__e,t.__u&=-161,u.__h.length&&s.push(u),g&&(u.__E=u.__=null)}catch(e){t.__v=null,l||null!=o?(t.__e=a,t.__u|=l?160:32,o[o.indexOf(a)]=null):(t.__e=n.__e,t.__k=n.__k),Xx.__e(e,t,n)}else null==o&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=function(e,t,n,i,r,o,s,a,l){var c,p,u,d,h,m,f,g=n.props,y=t.props,v=t.type;if("svg"===v&&(r=!0),null!=o)for(c=0;c<o.length;c++)if((h=o[c])&&"setAttribute"in h==!!v&&(v?h.localName===v:3===h.nodeType)){e=h,o[c]=null;break}if(null==e){if(null===v)return document.createTextNode(y);e=r?document.createElementNS("http://www.w3.org/2000/svg",v):document.createElement(v,y.is&&y),o=null,a=!1}if(null===v)g===y||a&&e.data===y||(e.data=y);else{if(o=o&&Qx.call(e.childNodes),g=n.props||iw,!a&&null!=o)for(g={},c=0;c<e.attributes.length;c++)g[(h=e.attributes[c]).name]=h.value;for(c in g)h=g[c],"children"==c||("dangerouslySetInnerHTML"==c?u=h:"key"===c||c in y||_w(e,c,null,h,r));for(c in y)h=y[c],"children"==c?d=h:"dangerouslySetInnerHTML"==c?p=h:"value"==c?m=h:"checked"==c?f=h:"key"===c||a&&"function"!=typeof h||g[c]===h||_w(e,c,h,g[c],r);if(p)a||u&&(p.__html===u.__html||p.__html===e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(u&&(e.innerHTML=""),yw(e,sw(d)?d:[d],t,n,i,r&&"foreignObject"!==v,o,s,o?o[0]:n.__k&&hw(n,0),a,l),null!=o)for(c=o.length;c--;)null!=o[c]&&lw(o[c]);a||(c="value",void 0!==m&&(m!==e[c]||"progress"===v&&!m||"option"===v&&m!==g[c])&&_w(e,c,m,g[c],!1),c="checked",void 0!==f&&f!==e[c]&&_w(e,c,f,g[c],!1))}return e}(n.__e,t,n,i,r,o,s,l,c);(p=Xx.diffed)&&p(t)}function kw(e,t,n){t.__d=void 0;for(var i=0;i<n.length;i++)Sw(n[i],n[++i],n[++i]);Xx.__c&&Xx.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){Xx.__e(e,t.__v)}}))}function Sw(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(e){Xx.__e(e,n)}}function Cw(e,t,n){var i,r;if(Xx.unmount&&Xx.unmount(e),(i=e.ref)&&(i.current&&i.current!==e.__e||Sw(i,null,t)),null!=(i=e.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){Xx.__e(e,t)}i.base=i.__P=null,e.__c=void 0}if(i=e.__k)for(r=0;r<i.length;r++)i[r]&&Cw(i[r],t,n||"function"!=typeof e.type);n||null==e.__e||lw(e.__e),e.__=e.__e=e.__d=void 0}function Aw(e,t,n){return this.constructor(e,n)}function Mw(e,t,n){var i,r,o,s;Xx.__&&Xx.__(e,t),r=(i="function"==typeof n)?null:n&&n.__k||t.__k,o=[],s=[],Pw(t,e=(!i&&n||t).__k=cw(uw,null,[e]),r||iw,iw,void 0!==t.ownerSVGElement,!i&&n?[n]:r?null:t.firstChild?Qx.call(t.childNodes):null,o,!i&&n?n:r?r.__e:t.firstChild,i,s),kw(o,e,s)}function Tw(e,t){var n={__c:t="__cC"+tw++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var n,i;return this.getChildContext||(n=[],(i={})[t]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&n.some((function(e){e.__e=!0,fw(e)}))},this.sub=function(e){n.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n.splice(n.indexOf(e),1),t&&t.call(e)}}),e.children}};return n.Provider.__=n.Consumer.contextType=n}Qx=rw.slice,Xx={__e:function(e,t,n,i){for(var r,o,s;t=t.__;)if((r=t.__c)&&!r.__)try{if((o=r.constructor)&&null!=o.getDerivedStateFromError&&(r.setState(o.getDerivedStateFromError(e)),s=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,i||{}),s=r.__d),s)return r.__E=r}catch(t){e=t}throw e}},Kx=0,dw.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=aw({},this.state),"function"==typeof e&&(e=e(aw({},n),this.props)),e&&aw(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),fw(this))},dw.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),fw(this))},dw.prototype.render=uw,Yx=[],Jx="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ew=function(e,t){return e.__v.__b-t.__v.__b},gw.__r=0,tw=0;var Rw,Dw,Nw,Bw,$w=0,jw=[],Iw=[],Lw=Xx.__b,qw=Xx.__r,zw=Xx.diffed,Vw=Xx.__c,Fw=Xx.unmount;function Hw(e,t){Xx.__h&&Xx.__h(Dw,e,$w||t),$w=0;var n=Dw.__H||(Dw.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({__V:Iw}),n.__[e]}function Uw(e){return $w=1,Ww(o_,e)}function Ww(e,t,n){var i=Hw(Rw++,2);if(i.t=e,!i.__c&&(i.__=[n?n(t):o_(void 0,t),function(e){var t=i.__N?i.__N[0]:i.__[0],n=i.t(t,e);t!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=Dw,!Dw.u)){var r=function(e,t,n){if(!i.__c.__H)return!0;var r=i.__c.__H.__.filter((function(e){return e.__c}));if(r.every((function(e){return!e.__N})))return!o||o.call(this,e,t,n);var s=!1;return r.forEach((function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(s=!0)}})),!(!s&&i.__c.props===e)&&(!o||o.call(this,e,t,n))};Dw.u=!0;var o=Dw.shouldComponentUpdate,s=Dw.componentWillUpdate;Dw.componentWillUpdate=function(e,t,n){if(this.__e){var i=o;o=void 0,r(e,t,n),o=i}s&&s.call(this,e,t,n)},Dw.shouldComponentUpdate=r}return i.__N||i.__}function Gw(e,t){var n=Hw(Rw++,3);!Xx.__s&&r_(n.__H,t)&&(n.__=e,n.i=t,Dw.__H.__h.push(n))}function Qw(e,t){var n=Hw(Rw++,4);!Xx.__s&&r_(n.__H,t)&&(n.__=e,n.i=t,Dw.__h.push(n))}function Xw(e){return $w=5,Kw((function(){return{current:e}}),[])}function Kw(e,t){var n=Hw(Rw++,7);return r_(n.__H,t)?(n.__V=e(),n.i=t,n.__h=e,n.__V):n.__}function Yw(e,t){return $w=8,Kw((function(){return e}),t)}function Zw(e){var t=Dw.context[e.__c],n=Hw(Rw++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(Dw)),t.props.value):e.__}function Jw(){for(var e;e=jw.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(n_),e.__H.__h.forEach(i_),e.__H.__h=[]}catch(t){e.__H.__h=[],Xx.__e(t,e.__v)}}Xx.__b=function(e){Dw=null,Lw&&Lw(e)},Xx.__r=function(e){qw&&qw(e),Rw=0;var t=(Dw=e.__c).__H;t&&(Nw===Dw?(t.__h=[],Dw.__h=[],t.__.forEach((function(e){e.__N&&(e.__=e.__N),e.__V=Iw,e.__N=e.i=void 0}))):(t.__h.forEach(n_),t.__h.forEach(i_),t.__h=[],Rw=0)),Nw=Dw},Xx.diffed=function(e){zw&&zw(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==jw.push(t)&&Bw===Xx.requestAnimationFrame||((Bw=Xx.requestAnimationFrame)||t_)(Jw)),t.__H.__.forEach((function(e){e.i&&(e.__H=e.i),e.__V!==Iw&&(e.__=e.__V),e.i=void 0,e.__V=Iw}))),Nw=Dw=null},Xx.__c=function(e,t){t.some((function(e){try{e.__h.forEach(n_),e.__h=e.__h.filter((function(e){return!e.__||i_(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],Xx.__e(n,e.__v)}})),Vw&&Vw(e,t)},Xx.unmount=function(e){Fw&&Fw(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{n_(e)}catch(e){t=e}})),n.__H=void 0,t&&Xx.__e(t,n.__v))};var e_="function"==typeof requestAnimationFrame;function t_(e){var t,n=function(){clearTimeout(i),e_&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,100);e_&&(t=requestAnimationFrame(n))}function n_(e){var t=Dw,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),Dw=t}function i_(e){var t=Dw;e.__c=e.__(),Dw=t}function r_(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function o_(e,t){return"function"==typeof t?t(e):t}function s_(e,t){for(var n in t)e[n]=t[n];return e}function a_(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var i in t)if("__source"!==i&&e[i]!==t[i])return!0;return!1}function l_(e){this.props=e}(l_.prototype=new dw).isPureReactComponent=!0,l_.prototype.shouldComponentUpdate=function(e,t){return a_(this.props,e)||a_(this.state,t)};var c_=Xx.__b;Xx.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),c_&&c_(e)};var p_="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function u_(e){function t(t){var n=s_({},t);return delete n.ref,e(n,t.ref||null)}return t.$$typeof=p_,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var d_=Xx.__e;Xx.__e=function(e,t,n,i){if(e.then)for(var r,o=t;o=o.__;)if((r=o.__c)&&r.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t);d_(e,t,n,i)};var h_=Xx.unmount;function m_(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach((function(e){"function"==typeof e.__c&&e.__c()})),e.__c.__H=null),null!=(e=s_({},e)).__c&&(e.__c.__P===n&&(e.__c.__P=t),e.__c=null),e.__k=e.__k&&e.__k.map((function(e){return m_(e,t,n)}))),e}function f_(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map((function(e){return f_(e,t,n)})),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function g_(){this.__u=0,this.t=null,this.__b=null}function y_(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function v_(){this.u=null,this.o=null}Xx.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),h_&&h_(e)},(g_.prototype=new dw).__c=function(e,t){var n=t.__c,i=this;null==i.t&&(i.t=[]),i.t.push(n);var r=y_(i.__v),o=!1,s=function(){o||(o=!0,n.__R=null,r?r(a):a())};n.__R=s;var a=function(){if(! --i.__u){if(i.state.__a){var e=i.state.__a;i.__v.__k[0]=f_(e,e.__c.__P,e.__c.__O)}var t;for(i.setState({__a:i.__b=null});t=i.t.pop();)t.forceUpdate()}};i.__u++||32&t.__u||i.setState({__a:i.__b=i.__v.__k[0]}),e.then(s,s)},g_.prototype.componentWillUnmount=function(){this.t=[]},g_.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=m_(this.__b,n,i.__O=i.__P)}this.__b=null}var r=t.__a&&cw(uw,null,e.fallback);return r&&(r.__u&=-33),[cw(uw,null,t.__a?null:e.children),r]};var b_=function(e,t,n){if(++n[1]===n[0]&&e.o.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.o.size))for(n=e.u;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.u=n=n[2]}};function x_(e){return this.getChildContext=function(){return e.context},e.children}function w_(e){var t=this,n=e.i;t.componentWillUnmount=function(){Mw(null,t.l),t.l=null,t.i=null},t.i&&t.i!==n&&t.componentWillUnmount(),t.l||(t.i=n,t.l={nodeType:1,parentNode:n,childNodes:[],appendChild:function(e){this.childNodes.push(e),t.i.appendChild(e)},insertBefore:function(e,n){this.childNodes.push(e),t.i.appendChild(e)},removeChild:function(e){this.childNodes.splice(this.childNodes.indexOf(e)>>>1,1),t.i.removeChild(e)}}),Mw(cw(x_,{context:t.context},e.__v),t.l)}function __(e,t){var n=cw(w_,{__v:e,i:t});return n.containerInfo=t,n}(v_.prototype=new dw).__a=function(e){var t=this,n=y_(t.__v),i=t.o.get(e);return i[0]++,function(r){var o=function(){t.props.revealOrder?(i.push(r),b_(t,e,i)):r()};n?n(o):o()}},v_.prototype.render=function(e){this.u=null,this.o=new Map;var t=bw(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var n=t.length;n--;)this.o.set(t[n],this.u=[1,0,this.u]);return e.children},v_.prototype.componentDidUpdate=v_.prototype.componentDidMount=function(){var e=this;this.o.forEach((function(t,n){b_(e,n,t)}))};var E_="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,O_=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,P_=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,k_=/[A-Z0-9]/g,S_="undefined"!=typeof document,C_=function(e){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(e)};dw.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach((function(e){Object.defineProperty(dw.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})}));var A_=Xx.event;function M_(){}function T_(){return this.cancelBubble}function R_(){return this.defaultPrevented}Xx.event=function(e){return A_&&(e=A_(e)),e.persist=M_,e.isPropagationStopped=T_,e.isDefaultPrevented=R_,e.nativeEvent=e};var D_={enumerable:!1,configurable:!0,get:function(){return this.class}},N_=Xx.vnode;Xx.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,i={};for(var r in t){var o=t[r];if(!("value"===r&&"defaultValue"in t&&null==o||S_&&"children"===r&&"noscript"===n||"class"===r||"className"===r)){var s=r.toLowerCase();"defaultValue"===r&&"value"in t&&null==t.value?r="value":"download"===r&&!0===o?o="":"ondoubleclick"===s?r="ondblclick":"onchange"!==s||"input"!==n&&"textarea"!==n||C_(t.type)?"onfocus"===s?r="onfocusin":"onblur"===s?r="onfocusout":P_.test(r)?r=s:-1===n.indexOf("-")&&O_.test(r)?r=r.replace(k_,"-$&").toLowerCase():null===o&&(o=void 0):s=r="oninput","oninput"===s&&i[r=s]&&(r="oninputCapture"),i[r]=o}}"select"==n&&i.multiple&&Array.isArray(i.value)&&(i.value=bw(t.children).forEach((function(e){e.props.selected=-1!=i.value.indexOf(e.props.value)}))),"select"==n&&null!=i.defaultValue&&(i.value=bw(t.children).forEach((function(e){e.props.selected=i.multiple?-1!=i.defaultValue.indexOf(e.props.value):i.defaultValue==e.props.value}))),t.class&&!t.className?(i.class=t.class,Object.defineProperty(i,"className",D_)):(t.className&&!t.class||t.class&&t.className)&&(i.class=i.className=t.className),e.props=i}(e),e.$$typeof=E_,N_&&N_(e)};var B_=Xx.__r;Xx.__r=function(e){B_&&B_(e),e.__c};var $_=Xx.diffed;Xx.diffed=function(e){$_&&$_(e);var t=e.props,n=e.__e;null!=n&&"textarea"===e.type&&"value"in t&&t.value!==n.value&&(n.value=null==t.value?"":t.value),null};var j_=cw,I_=0;function L_(e,t,n,i,r,o){var s,a,l={};for(a in t)"ref"==a?s=t[a]:l[a]=t[a];var c={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--I_,__i:-1,__u:0,__source:r,__self:o};if("function"==typeof e&&(s=e.defaultProps))for(a in s)void 0===l[a]&&(l[a]=s[a]);return Xx.vnode&&Xx.vnode(c),c}function q_(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var z_,V_={exports:{}};
171
+ `,this._current.container)},Ll.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:s}=this._getContext(e,t);this._current={position:n,providerId:t,target:e,entries:r,headerEntries:o,emptyPlaceholder:s,container:this._createContainer({provider:t}),options:i},this._emit("open"),this._bindAutoClose(),this._render()},Ll.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()},Ll.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)}},Ll.prototype.close=function(){this.isOpen()&&(this._emit("close"),this.reset(),this._canvas.restoreFocus(),this._current=null)},Ll.prototype.reset=function(){const e=this._current.container;tl(null,e),be(e)},Ll.prototype._emit=function(e,t){this._eventBus.fire(`popupMenu.${e}`,t)},Ll.prototype._onOpened=function(){this._emit("opened")},Ll.prototype._onClosed=function(){this._emit("closed")},Ll.prototype._createContainer=function(e){var t=this._canvas.getContainer();const n=fe(`<div class="djs-popup-parent djs-scrollable" data-popup=${e.provider}></div>`);return t.appendChild(n),n},Ll.prototype._bindAutoClose=function(){this._eventBus.once(Il,this.close,this)},Ll.prototype._unbindAutoClose=function(){this._eventBus.off(Il,this.close,this)},Ll.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),a(e)&&n<e&&(r=e),a(t)&&n>t&&(r=t)),r},Ll.prototype._ensureVisible=function(e,t){var n=document.documentElement.getBoundingClientRect(),i=e.getBoundingClientRect(),r={},o=t.x,s=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,s=t.y-i.height):r.x?(o=t.x-i.width,s=t.y):r.y&&t.y<i.height?(o=t.x,s=10):r.y&&(o=t.x,s=t.y-i.height),t.y<n.top&&(s=t.y+i.height),{x:o,y:s}},Ll.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},Ll.prototype.registerProvider=function(e,t,n){n||(n=t,t=1e3),this._eventBus.on("popupMenu.getProviders."+e,t,(function(e){e.providers.push(n)}))},Ll.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"popupMenu.getProviders."+e,providers:[]});return this._eventBus.fire(t),t.providers},Ll.prototype._getEntries=function(e,t){var n={};return v(t,(function(t){if(t.getPopupMenuEntries){var i=t.getPopupMenuEntries(e);d(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]=q(e,["id"])}))})),n},Ll.prototype._getHeaderEntries=function(e,t){var n={};return v(t,(function(t){if(t.getPopupMenuHeaderEntries){var i=t.getPopupMenuHeaderEntries(e);d(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]=q(e,["id"])}))}})),n},Ll.prototype._getEmptyPlaceholder=function(e){const t=e.find((e=>d(e.getEmptyPlaceholder)));return t&&t.getEmptyPlaceholder()},Ll.prototype.isOpen=function(){return!!this._current},Ll.prototype.trigger=function(e,t,n="click"){if(e.preventDefault(),!t){let n=X(ee(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(d(i)){if("click"===n)return i(e,t)}else if(i[n])return i[n](e,t)},Ll.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 Hl={search:["value",function(e,t,n){const{keys:i}=n;if(!(t=t.trim().toLowerCase()))throw new Error("<pattern> must not be empty");const 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:s}=function(e,t){if(!e)return{tokens:[],matchedWords:{}};const n=[],i={},r=t.map(Fl),o=[`(?<all>${r.join("\\s+")})`,...r].join("|"),s=new RegExp(o,"ig");let a,l=0;for(;a=s.exec(e);){const[r]=a,o=a.index,s=a.index+r.length,c=0===o,p=s===e.length,u=!!a.groups.all,d=c||/\s/.test(e.charAt(o-1)),h=p||/\s/.test(e.charAt(s+1));a.index>l&&n.push({value:e.slice(l,a.index),index:l}),n.push({value:r,index:a.index,match:!0,wordStart:d,wordEnd:h,start:c,end:p,all:u});const m=u?t:[r];for(const e of m)i[e.toLowerCase()]=!0;l=a.index+r.length}l<e.length&&n.push({value:e.slice(l),index:l});return{tokens:n,matchedWords:i}}(r,t);return{tokens:{...n.tokens,[i]:o},matchedWords:{...n.matchedWords,...s}}}),{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=ql(t.tokens[i],n.tokens[i]);if(0!==e)return e;const r=Vl(t.item[i],n.item[i]);if(0!==r)return r}return 0}}(i))}]},Ul={__depends__:[Hl],__init__:["popupMenu"],popupMenu:["type",Ll]},Wl={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 Gl(e,t,n,i){e.registerProvider(900,this),this._contextPad=e,this._popupMenu=t,this._translate=n,this._canvas=i}Gl.$inject=["contextPad","popupMenu","translate","canvas"],Gl.prototype.getMultiElementContextPadEntries=function(e){var t={};return this._isAllowed(e)&&j(t,this._getEntries(e)),t},Gl.prototype._isAllowed=function(e){return!this._popupMenu.isEmpty(e,"align-elements")},Gl.prototype._getEntries=function(){var e=this;return{"align-elements":{group:"align-elements",title:e._translate("Align elements"),html:`<div class="entry">${Wl.align}</div>`,action:{click:function(t,n){var i=e._getMenuPosition(n);j(i,{cursor:{x:t.x,y:t.y}}),e._popupMenu.open(n,"align-elements",i)}}}}},Gl.prototype._getMenuPosition=function(e){var t=this._contextPad.getPad(e).html.getBoundingClientRect();return{x:t.left,y:t.bottom+5}};var Ql=["left","center","right","top","middle","bottom"];function Xl(e,t,n,i){this._alignElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",this)}function Kl(e){Fo.call(this,e),this.init()}function Yl(e){Kl.call(this,e)}Xl.$inject=["popupMenu","alignElements","translate","rules"],Xl.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&j(t,this._getEntries(e)),t},Xl.prototype._isAllowed=function(e){return this._rules.allowed("elements.align",{elements:e})},Xl.prototype._getEntries=function(e){var t=this._alignElements,n=this._translate,i=this._popupMenu,r={};return v(Ql,(function(o){r["align-elements-"+o]={group:"align",title:n("Align elements "+o),className:"bjs-align-elements-menu-entry",imageHtml:Wl[o],action:function(){t.trigger(e,o),i.close()}}})),r},Kl.$inject=["eventBus"],e(Kl,Fo),Kl.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)}))},Kl.prototype.init=function(){},Yl.$inject=["eventBus"],e(Yl,Kl),Yl.prototype.init=function(){this.addRule("elements.align",(function(e){var t=y(e.elements,(function(e){return!(e.waypoints||e.host||e.labelTarget)}));return!((t=dt(t)).length<2)&&t}))};var Zl={__depends__:[va,Aa,Ul],__init__:["alignElementsContextPadProvider","alignElementsMenuProvider","bpmnAlignElements"],alignElementsContextPadProvider:["type",Gl],alignElementsMenuProvider:["type",Xl],bpmnAlignElements:["type",Yl]},Jl=10,ec=50,tc=250;function nc(e,t,n,i){for(var r;r=rc(e,n,t);)n=i(t,n,r);return n}function ic(e){return function(t,n,i){var r={x:n.x,y:n.y};return["x","y"].forEach((function(o){var s=e[o];if(s){var a="x"===o?"width":"height",l=s.margin,c=s.minDistance;r[o]=l<0?Math.min(i[o]+l-t[a]/2,n[o]-c+l):Math.max(i[o]+i[a]+l+t[a]/2,n[o]+c+l)}})),r}}function rc(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=oc(e);e.host&&(t=t.concat(oc(e.host)));e.attachers&&(t=t.concat(e.attachers.reduce((function(e,t){return e.concat(oc(t))}),[])));return t}(e);return f(r,(function(e){return e!==n&&"intersect"===xn(e,i,Jl)}))}function oc(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 sc(){return!0}function ac(e,t,n){e.on("autoPlace",100,(function(e){var t=e.shape;return function(e,t,n){n||(n={});var i=n.defaultDistance||ec,r=bn(e),o=gn(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}),s=t.appendShape(n,i,o,n.parent,r);return e.fire("autoPlace.end",{source:n,shape:s}),s}}function lc(e,t){e.on("autoPlace.end",500,(function(e){t.select(e.shape)}))}ac.$inject=["eventBus","modeling","canvas"],lc.$inject=["eventBus","selection"];var cc={__init__:["autoPlaceSelectionBehavior"],autoPlace:["type",ac],autoPlaceSelectionBehavior:["type",lc]};function pc(e,t){for(h(t)&&(t=[t]);e=e.parent;)if(Er(e,t))return e;return null}function uc(e,t){var n=pc(e,"bpmn:Process");if(n)return!0;var i,r=["bpmn:Participant","bpmn:Lane"];if(n=pc(e,r))return Fr(n);if(Er(e,r))return Fr(e);for(i=Or(e);i&&!_r(i,"bpmn:Process");i=i.$parent);if(!t)return!0;var o=t.find((function(e){var t=Or(e);return t&&t.get("processRef")===i}));return!o||Fr(o)}function dc(e,t,n){var i=uc(e,n);return _r(t,"bpmn:TextAnnotation")?function(e,t,n){var i=gn(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};dn(e)&&(r=bn(e),n?(r.x+=100,r.y-=50):(r.x+=100,r.y+=50));var o={margin:n?-30:30,minDistance:20},s=n?{y:o}:{x:o};return nc(e,t,r,ic(s))}(e,t,i):Er(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])?function(e,t,n){var i=gn(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},s=n?{x:o}:{y:o};return nc(e,t,r,ic(s))}(e,t,i):_r(t,"bpmn:FlowNode")?function(e,t,n){var i=gn(e),r=bn(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"},s=function(e,t){t||(t={});var n=t.defaultDistance||ec,i=t.direction||"e",r=t.filter,o=t.getWeight||function(t){return t.source===e?1:-1},s=t.maxDistance||tc,a=t.reference||"start";function l(e,t){return"n"===i?"start"===a?gn(e).top-gn(t).bottom:"center"===a?gn(e).top-bn(t).y:gn(e).top-gn(t).top:"w"===i?"start"===a?gn(e).left-gn(t).right:"center"===a?gn(e).left-bn(t).x:gn(e).left-gn(t).left:"s"===i?"start"===a?gn(t).top-gn(e).bottom:"center"===a?bn(t).y-gn(e).bottom:gn(t).bottom-gn(e).bottom:"start"===a?gn(t).left-gn(e).right:"center"===a?bn(t).x-gn(e).right:gn(t).right-gn(e).right}r||(r=sc);var c=e.incoming.filter(r).map((function(t){var n=o(t),i=n<0?l(t.source,e):l(e,t.source);return{id:t.source.id,distance:i,weight:n}})),p=e.outgoing.filter(r).map((function(t){var n=o(t),i=n>0?l(e,t.target):l(t.target,e);return{id:t.target.id,distance:i,weight:n}})),u=x(c.concat(p).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>s||(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 _r(e,"bpmn:SequenceFlow")},direction:o.directionHint}),a=30,l=o.minDistance,c=o.baseOrientation;_r(e,"bpmn:BoundaryEvent")&&-1!==(c=xn(e,e.host,-25)).indexOf(o.boundaryOrientation)&&(a*=-1);var p=n?{x:i.right+s+t.width/2,y:r.y+hc(c,l,o)}:{x:r.x+hc(c,l,o),y:i.bottom+s+t.height/2},u={margin:a,minDistance:l},d=n?{y:u}:{x:u};return nc(e,t,p,ic(d))}(e,t,i):void 0}function hc(e,t,n){return e.includes(n.start)?-1*t:e.includes(n.end)?t:0}function mc(e,t){e.on("autoPlace",(function(e){var n=e.shape;return dc(e.source,n,t)}))}mc.$inject=["eventBus","elementRegistry"];var fc={__depends__:[cc],__init__:["bpmnAutoPlace"],bpmnAutoPlace:["type",mc]};function gc(e,t,n,r){Fo.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(P(t.closure.topLevel)),r=t.hints,s=!r||r.autoResize;!1!==s&&v(k(n,(function(e){return e.parent.id})),(function(e,t){c(s)&&(e=e.filter((function(e){return f(s,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 yc(e){e.invoke(gc,this)}function vc(e){Kl.call(this,e);var t=this;this.addRule("element.autoResize",(function(e){return t.canResize(e.elements,e.target)}))}function bc(e,t){vc.call(this,e),this._modeling=t}gc.$inject=["eventBus","elementRegistry","modeling","rules"],e(gc,Fo),gc.prototype._getOptimalBounds=function(e,t){var n=this.getOffset(t),i=this.getPadding(t),r=gn(yt(e)),o=gn(t),s={};return r.top-o.top<i.top&&(s.top=r.top-n.top),r.left-o.left<i.left&&(s.left=r.left-n.left),o.right-r.right<i.right&&(s.right=r.right+n.right),o.bottom-r.bottom<i.bottom&&(s.bottom=r.bottom+n.bottom),yn(j({},o,s))},gc.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=gn(e),t=gn(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}(L(t,["x","y","width","height"]),n);this.resize(t,n,{autoResize:i});var r=t.parent;r&&this._expand([t],r)}}},gc.prototype.getOffset=function(e){return{top:60,bottom:60,left:100,right:100}},gc.prototype.getPadding=function(e){return{top:2,bottom:2,left:15,right:15}},gc.prototype.resize=function(e,t,n){this._modeling.resizeShape(e,t,null,n)},yc.$inject=["injector"],e(yc,gc),yc.prototype.resize=function(e,t,n){_r(e,"bpmn:Participant")?this._modeling.resizeLane(e,t,null,n):this._modeling.resizeShape(e,t,null,n)},vc.$inject=["eventBus"],e(vc,Kl),vc.prototype.canResize=function(e,t){return!1},e(bc,vc),bc.$inject=["eventBus","modeling"],bc.prototype.canResize=function(e,t){if(_r(t.di,"bpmndi:BPMNPlane"))return!1;if(!_r(t,"bpmn:Participant")&&!_r(t,"bpmn:Lane")&&!_r(t,"bpmn:SubProcess"))return!1;var n=!0;return v(e,(function(e){(_r(e,"bpmn:Lane")||hn(e))&&(n=!1)})),n};var xc={__init__:["bpmnAutoResize","bpmnAutoResizeProvider"],bpmnAutoResize:["type",yc],bpmnAutoResizeProvider:["type",bc]};function wc(e,t,n){var i,r,o=this,s=n.get("dragging",!1);s&&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(),s.hover({element:r,gfx:i}),s.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=fs(e),function(e){return ee(e,"svg, .djs-element",!0)}(document.elementFromPoint(t.x,t.y))}}wc.$inject=["elementRegistry","eventBus","injector"];var _c={__init__:["hoverFix"],hoverFix:["type",wc]},Ec=Math.round,Oc="djs-drag-active";function Pc(e){e.preventDefault()}function kc(e,t,n,i){var r,o={threshold:5,trapClick:!0};function s(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 a(t,n){n=n||r;var i=e.createEvent(j({},n.payload,n.data,{isTouch:n.isTouch}));return!1!==e.fire("drag."+t,i)&&e.fire(n.prefix+"."+t,i)}function l(e,i){var o,l=r.payload,c=r.displacement,p=r.globalStart,u=fs(e),d=ia(u,p),h=r.localStart,m=s(u),g=ia(m,h);if(!r.active&&(i||(o=d,Math.sqrt(Math.pow(o.x,2)+Math.pow(o.y,2))>r.threshold))){if(j(l,{x:Ec(h.x+c.x),y:Ec(h.y+c.y),dx:0,dy:0},{originalEvent:e}),!1===a("start"))return f();r.active=!0,r.keepSelection||(l.previousSelection=n.get(),n.select(null)),r.cursor&&Zs(r.cursor),t.addMarker(t.getRootElement(),Oc)}ms(e),r.active&&(j(l,{x:Ec(m.x+c.x),y:Ec(m.y+c.y),dx:Ec(g.x),dy:Ec(g.y)},{originalEvent:e}),a("move"))}function c(e){var t=!0;r.active&&(e&&(r.payload.originalEvent=e,ms(e)),t=a("end")),!1===t&&a("rejected"),a("ended",g(!0!==t))}function p(e){Is("Escape",e)&&(Pc(e),f())}function u(t){var n;r.active&&(n=ta(e),setTimeout(n,400),Pc(t)),c(t)}function d(e){l(e)}function h(e){var t=r.payload;t.hoverGfx=e.gfx,t.hover=e.element,a("hover")}function m(e){a("out");var t=r.payload;t.hoverGfx=null,t.hover=null}function f(e){var t;if(r){var n=r.active;n&&a("cancel"),t=g(e),n&&a("canceled",t)}}function g(o){var s,g;a("cleanup"),Js(),g=r.trapClick?u:c,le.unbind(document,"mousemove",l),le.unbind(document,"dragstart",Pc),le.unbind(document,"selectstart",Pc),le.unbind(document,"mousedown",g,!0),le.unbind(document,"mouseup",g,!0),le.unbind(document,"keyup",p),le.unbind(document,"touchstart",d,!0),le.unbind(document,"touchcancel",f,!0),le.unbind(document,"touchmove",l,!0),le.unbind(document,"touchend",c,!0),e.off("element.hover",h),e.off("element.out",m),t.removeMarker(t.getRootElement(),Oc);var y=r.payload.previousSelection;return!1!==o&&y&&!n.get().length&&function(e){var t=e.filter((function(e){return i.get(e.id)}));t.length&&n.select(t)}(y),s=r,r=null,s}e.on("diagram.destroy",f),this.init=function(t,n,i,g){r&&f(!1),"string"==typeof n&&(g=i,i=n,n=null);var y,v,b,x,w,_=(g=j({},o,g||{})).data||{};x=g.trapClick?u:c,t?(y=hs(t)||t,v=fs(t),ms(t),"dragstart"===y.type&&Pc(y)):(y=null,v={x:0,y:0}),b=s(v),n||(n=b),w=function(e){return"undefined"!=typeof TouchEvent&&e instanceof TouchEvent}(y),r=j({prefix:i,data:_,payload:{},globalStart:v,displacement:ia(n,b),localStart:b,isTouch:w},g),g.manual||(w?(le.bind(document,"touchstart",d,!0),le.bind(document,"touchcancel",f,!0),le.bind(document,"touchmove",l,!0),le.bind(document,"touchend",c,!0)):(le.bind(document,"mousemove",l),le.bind(document,"dragstart",Pc),le.bind(document,"selectstart",Pc),le.bind(document,"mousedown",x,!0),le.bind(document,"mouseup",x,!0)),le.bind(document,"keyup",p),e.on("element.hover",h),e.on("element.out",m)),a("init"),g.autoActivate&&l(t,!0)},this.move=l,this.hover=h,this.out=m,this.end=c,this.cancel=f,this.context=function(){return r},this.setOptions=function(e){j(o,e)}}kc.$inject=["eventBus","canvas","selection","elementRegistry"];var Sc={__depends__:[_c,Ts],dragging:["type",kc]};function Cc(e,t,n){this._canvas=n,this._opts=j({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 Ac(e,t,n){return t<e&&e<n}Cc.$inject=["config.autoScroll","eventBus","canvas"],Cc.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 s=0,a=0,l=0;l<4;l++)Ac(o[l],n.scrollThresholdOut[l],n.scrollThresholdIn[l])&&(0===l?s=n.scrollStep:1==l?a=n.scrollStep:2==l?s=-n.scrollStep:3==l&&(a=-n.scrollStep));0===s&&0===a||(t.scroll({dx:s,dy:a}),this._scrolling=setTimeout((function(){i.startScroll(e)}),n.scrollRepeatTimeout))},Cc.prototype.stopScroll=function(){clearTimeout(this._scrolling)},Cc.prototype.setOptions=function(e){this._opts=j({},this._opts,e)},Cc.prototype._toBorderPoint=function(e){var t=this._canvas._container.getBoundingClientRect(),n=fs(e.originalEvent);return{x:n.x-t.left,y:n.y-t.top}};var Mc={__depends__:[Sc],__init__:["autoScroll"],autoScroll:["type",Cc]};function Tc(e){this._commandStack=e.get("commandStack",!1)}Tc.$inject=["injector"],Tc.prototype.allowed=function(e,t){var n=!0,i=this._commandStack;return i&&(n=i.canExecute(e,t)),void 0===n||n};var Rc={__init__:["rules"],rules:["type",Tc]},Dc=Math.round,Nc=Math.max;var Bc=10;function $c(e,t){return function(e,t){var n,i;for(n=0;i=e[n];n++)if(kt(i,t)<=Bc)return{point:e[n],bendpoint:!0,index:n};return null}(e,t)||function(e,t){var n,i,r=on(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,Bc),(n=[],e.forEach((function(e,t){n.push([0===t?"M":"L",e.x,e.y])})),n)),o=r[0],s=r[r.length-1];return o?o!==s?o.segment2!==s.segment2?{point:e[i=Nc(o.segment2,s.segment2)-1],bendpoint:!0,index:i}:{point:{x:Dc(o.x+s.x)/2,y:Dc(o.y+s.y)/2},index:o.segment2}:{point:{x:Dc(o.x),y:Dc(o.y)},index:o.segment2}:null}(e,t)}function jc(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}function Ic(e){return Math.atan((e[1].y-e[0].y)/(e[1].x-e[0].x))}function Lc(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 qc(e,t){var n=Lc(e,t);return jc({x:n.x-e.x,y:n.y-e.y})}function zc(e,t){return jc({x:e.x-t.x,y:e.y-t.y})}var Vc="djs-bendpoint",Fc="djs-segment-dragger";function Hc(e,t,n){var i=function(e,t){var n,i=fs(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 $c(t,i)}function Uc(e,t){var n=De("g");ke(n).add(Vc),xe(e,n);var i=De("circle");Oe(i,{cx:0,cy:0,r:4}),ke(i).add("djs-visual"),xe(n,i);var r=De("circle");return Oe(r,{cx:0,cy:0,r:10}),ke(r).add("djs-hit"),xe(n,r),t&&ke(n).add(t),n}function Wc(e,t,n,i){var r=De("g");xe(e,r);var o=function(e,t,n){var i=t.x-e.x,r=t.y-e.y;return Qc("h"===n?i:r)}(t,n,i),s=De("rect");Oe(s,{x:-9,y:-3,width:18,height:6}),ke(s).add("djs-visual"),xe(r,s);var a=De("rect");return Oe(a,{x:-o/2,y:-8.5,width:o,height:17}),ke(a).add("djs-hit"),xe(r,a),Yn(r,"v"===i?90:0),r}function Gc(e,t,n){var i=De("g"),r=Rt(t,n),o=At(t,n);return xe(e,i),Wc(i,t,n,o),ke(i).add(Fc),ke(i).add("h"===o?"horizontal":"vertical"),Kn(i,r.x,r.y),i}function Qc(e){return Math.abs(Math.round(2*e/3))}function Xc(e,t){var n=function(e,t){for(var n,i=t.waypoints,r=1/0,o=0;o<i.length-1;o++){var s=qc(e,[i[o],i[o+1]]);s<r&&(r=s,n=o)}return[i[n],i[n+1]]}(e,t);return Lc(e,n)}function Kc(e,t,n,i,r){function o(e,n){var o,s=n.waypoints,a=Hc(t,s,e);if(a)return o=function(e,t){var n,i,r=e.waypoints;return t.index<=0||t.bendpoint?null:(i=At((n={start:r[t.index-1],end:r[t.index]}).start,n.end))?Qc("h"===i?n.end.x-n.start.x:n.end.y-n.start.y)/2:null}(n,a),!function(e,t,n){var i,r,o,s,a,l,c=e.index,p=e.point;return!(c<=0||e.bendpoint)&&(o=Rt(i=t[c-1],r=t[c]),s=At(i,r),a=Math.abs(p.x-o.x),l=Math.abs(p.y-o.y),s&&a<=n&&l<=n)}(a,s,o)?i.start(e,n,a.index,!a.bendpoint):r.start(e,n,a.index),!0}function s(e,t,i){le.bind(e,t,(function(e){n.triggerMouseEvent(t,e,i),e.stopPropagation()}))}function a(e,n){var i=t.getLayer("overlays"),r=ye('.djs-bendpoints[data-element-id="'+Go(e.id)+'"]',i);return!r&&n&&(Oe(r=De("g"),{"data-element-id":e.id}),ke(r).add("djs-bendpoints"),xe(i,r),s(r,"mousedown",e),s(r,"click",e),s(r,"dblclick",e)),r}function l(e,t){return ye('.djs-segment-dragger[data-segment-idx="'+e+'"]',t)}function c(e,t){t.waypoints.forEach((function(t,n){var i=Uc(e);xe(e,i),Kn(i,t.x,t.y)})),Uc(e,"floating")}function p(e,t){for(var n,i,r,o=t.waypoints,a=1;a<o.length;a++)At(n=o[a-1],i=o[a])&&(Oe(r=Gc(e,n,i),{"data-segment-idx":a}),s(r,"mousemove",t))}function u(e){var t=a(e);return t||(c(t=a(e,!0),e),p(t,e)),t}function d(e){var t=a(e);t&&(!function(e){v(ve("."+Fc,e),(function(e){He(e)}))}(t),function(e){v(ve("."+Vc,e),(function(e){He(e)}))}(t),p(t,e),c(t,e))}function h(e,t,n){var i,r,o=l(t.index,e),s=n[t.index-1],a=n[t.index],c=t.point,p=Rt(s,a),u=At(s,a);o&&(i=function(e){return ye(".djs-visual",e)}(o),r={x:c.x-p.x,y:c.y-p.y},"v"===u&&(r={x:r.y,y:r.x}),Kn(i,r.x,r.y))}e.on("connection.changed",(function(e){d(e.element)})),e.on("connection.remove",(function(e){var t=a(e.element);t&&He(t)})),e.on("element.marker.update",(function(e){var t,n=e.element;n.waypoints&&(t=u(n),e.add?ke(t).add(e.marker):ke(t).remove(e.marker))})),e.on("element.mousemove",(function(e){var n,i,r=e.element,o=r.waypoints;if(o){if(n=a(r,!0),!(i=Hc(t,o,e.originalEvent)))return;!function(e,t){var n=ye(".floating",e),i=t.point;n&&Kn(n,i.x,i.y)}(n,i),i.bendpoint||h(n,i,o)}})),e.on("element.mousedown",(function(e){if(vs(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=a(t);i&&Oe(i,{"data-element-id":n})}})),this.addHandles=u,this.updateHandles=d,this.getBendpointsContainer=a,this.getSegmentDragger=l}Kc.$inject=["eventBus","canvas","interactionEvents","bendpointMove","connectionSegmentMove"];var Yc=Math.round,Zc="reconnectStart",Jc="reconnectEnd",ep="updateWaypoints";function tp(e,t,n,i,r,o){this._injector=e,this.start=function(e,t,o,s){var a,l=n.getGraphics(t),c=t.source,p=t.target,u=t.waypoints,d=(a=s||0!==o?s||o!==u.length-1?ep:Jc:Zc)===ep?"connection.updateWaypoints":"connection.reconnect",h=r.allowed(d,{connection:t,source:c,target:p});!1===h&&(h=r.allowed(d,{connection:t,source:p,target:c})),!1!==h&&i.init(e,"bendpoint.move",{data:{connection:t,connectionGfx:l,context:{allowed:h,bendpointIndex:o,connection:t,source:c,target:p,insert:s,type:a}}})},t.on("bendpoint.move.hover",(function(e){var t,n=e.context,i=n.connection,o=i.source,s=i.target,a=e.hover,l=n.type;if(n.hover=a,a){var c=l===ep?"connection.updateWaypoints":"connection.reconnect";if(t=n.allowed=r.allowed(c,{connection:i,source:l===Zc?a:o,target:l===Jc?a:s}))return n.source=l===Zc?a:o,void(n.target=l===Jc?a:s);!1===t&&(t=n.allowed=r.allowed(c,{connection:i,source:l===Jc?a:s,target:l===Zc?a:o})),t&&(n.source=l===Jc?a:s,n.target=l===Zc?a: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!==ep&&(t.allowed=!1)})),t.on("bendpoint.move.end",(function(e){var t=e.context,n=t.allowed,i=t.bendpointIndex,r=t.connection,s=t.insert,a=r.waypoints.slice(),l=t.source,c=t.target,p=t.type,u=t.hints||{},d={x:Yc(e.x),y:Yc(e.y)};if(!n)return!1;p===ep?(s?a.splice(i,0,d):a[i]=d,u.bendpointMove={insert:s,bendpointIndex:i},a=this.cropWaypoints(r,a),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===kt(t,i=e[r+1])||St(n,i,t)?e.splice(r,1):r++;return e}(a),u)):(p===Zc?(u.docking="source",np(t)&&(u.docking="target",u.newWaypoints=a.reverse())):p===Jc&&(u.docking="target",np(t)&&(u.docking="source",u.newWaypoints=a.reverse())),o.reconnect(r,l,c,d,u))}),this)}function np(e){var t=e.hover,n=e.source,i=e.target,r=e.type;return r===Zc?t&&i&&t===i&&n!==i:r===Jc?t&&n&&t===n&&n!==i:void 0}tp.$inject=["injector","eventBus","canvas","dragging","rules","modeling"],tp.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 ip="updateWaypoints",rp="connect-ok",op="connect-not-ok",sp="connect-hover",ap="djs-updating",lp="djs-dragging";function cp(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,s=r.waypoints,a=s.slice();t.waypoints=s,o&&a.splice(n,0,{x:e.x,y:e.y}),r.waypoints=a,ke(t.draggerGfx=Uc(i.getLayer("overlays"))).add("djs-dragging"),i.addMarker(r,lp),i.addMarker(r,ap)})),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,sp),o===ip)return;n?(i.removeMarker(r,op),i.addMarker(r,rp)):!1===n&&(i.removeMarker(r,rp),i.addMarker(r,op))}})),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,sp),i.removeMarker(n,r?rp:op))})),n.on("bendpoint.move.move",(function(t){var n=t.context,i=n.allowed,o=n.bendpointIndex,s=n.draggerGfx,a=n.hover,l=n.type,c=n.connection,p=c.source,u=c.target,d=c.waypoints.slice(),h={x:t.x,y:t.y},m=n.hints||{},f={};r&&(m.connectionStart&&(f.connectionStart=m.connectionStart),m.connectionEnd&&(f.connectionEnd=m.connectionEnd),"reconnectStart"===l?np(n)?(f.connectionEnd=f.connectionEnd||h,f.source=u,f.target=a||p,d=d.reverse()):(f.connectionStart=f.connectionStart||h,f.source=a||p,f.target=u):"reconnectEnd"===l?np(n)?(f.connectionStart=f.connectionStart||h,f.source=a||u,f.target=p,d=d.reverse()):(f.connectionEnd=f.connectionEnd||h,f.source=p,f.target=a||u):(f.noCropping=!0,f.noLayout=!0,d[o]=h),l===ip&&(d=e.cropWaypoints(c,d)),f.waypoints=d,r.drawPreview(n,i,f)),Kn(s,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,s=t.hover,a=t.target,l=t.waypoints;n.waypoints=l,He(o),i.removeMarker(n,ap),i.removeMarker(n,lp),s&&(i.removeMarker(s,rp),i.removeMarker(s,a?rp:op)),r&&r.cleanUp(t)}))}cp.$inject=["bendpointMove","injector","eventBus","canvas"];var pp="connect-hover",up="djs-updating";function dp(e,t,n){return hp(e,t,e[t]+n)}function hp(e,t,n){return{x:"x"===t?n:e.x,y:"y"===t?n:e.y}}function mp(e){return"x"===e?"y":"x"}function fp(e,t,n){var i,r;return e.original?e.original:(i=bn(t),hp(e,r=mp(n),i[r]))}function gp(e,t,n,i,r,o){var s=e.get("connectionDocking",!1);function a(e,t){if(!s)return t;var n,i=e.waypoints;return e.waypoints=t,n=s.getCroppedWaypoints(e),e.waypoints=i,n}function l(e){r.update("connection",e.connection,e.connectionGfx)}function c(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 hp(t,i,Math.min(Math.max(o+20,e[i]),r-20))}(n,i[e.segmentStartIndex+t],i[e.segmentEndIndex+t],mp(e.axis));Kn(e.draggerGfx,r.x,r.y)}this.start=function(e,t,r){var o,s,a,l,c=n.getGraphics(t),p=r-1,u=r,d=t.waypoints,h=d[p],m=d[u],f=Hc(n,d,e);(s=At(h,m))&&(a="v"===s?"x":"y",0===p&&(h=fp(h,t.source,a)),u===d.length-1&&(m=fp(m,t.target,a)),o={connection:t,segmentStartIndex:p,segmentEndIndex:u,segmentStart:h,segmentEnd:m,axis:a,dragPosition:l=f?f.point:{x:(h.x+m.x)/2,y:(h.y+m.y)/2}},i.init(e,l,"connectionSegment.move",{cursor:"x"===a?"resize-ew":"resize-ns",data:{connection:t,connectionGfx:c,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=Gc(r,t.segmentStart,t.segmentEnd),ke(t.draggerGfx).add("djs-dragging"),n.addMarker(i,up)})),t.on("connectionSegment.move.move",(function(e){var t,n,i=e.context,r=i.connection,o=i.segmentStartIndex,s=i.segmentEndIndex,p=i.segmentStart,u=i.segmentEnd,d=i.axis,h=i.originalWaypoints.slice(),m=dp(p,d,e["d"+d]),f=dp(u,d,e["d"+d]),g=h.length,y=0;h[o]=m,h[s]=f,o<2&&(t=xn(r.source,m),1===o?"intersect"===t&&(h.shift(),h[0]=m,y--):"intersect"!==t&&(h.unshift(p),y++)),s>g-3&&(n=xn(r.target,f),s===g-2?"intersect"===n&&(h.pop(),h[h.length-1]=f):"intersect"!==n&&h.push(u)),i.newWaypoints=r.waypoints=a(r,h),c(i,y,e),i.newSegmentStartIndex=o+y,l(e)})),t.on("connectionSegment.move.hover",(function(e){e.context.hover=e.hover,n.addMarker(e.hover,pp)})),t.on(["connectionSegment.move.out","connectionSegment.move.cleanup"],(function(e){var t=e.context.hover;t&&n.removeMarker(t,pp)})),t.on("connectionSegment.move.cleanup",(function(e){var t=e.context,i=t.connection;t.draggerGfx&&He(t.draggerGfx),n.removeMarker(i,up)})),t.on(["connectionSegment.move.cancel","connectionSegment.move.end"],(function(e){var t=e.context;t.connection.waypoints=t.originalWaypoints,l(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 s=function(e,t){var n=0,i=e.filter((function(i,r){return!St(e[r-1],e[r+1],i)||(n=r<=t?n-1:n,!1)}));return{waypoints:i,segmentOffset:n}}(i,r),l=a(n,s.waypoints),c=s.segmentOffset,p={segmentMove:{segmentStartIndex:t.segmentStartIndex,newSegmentStartIndex:r+c}};o.updateWaypoints(n,l,p)}))}gp.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];var yp=Math.abs,vp=Math.round;function bp(e){return{x:e.x,y:e.y}}function xp(e){return{x:e.x+e.width,y:e.y+e.height}}function wp(e,t){return!e||isNaN(e.x)||isNaN(e.y)?t:{x:vp(e.x+e.width/2),y:vp(e.y+e.height/2)}}function _p(e,t){var n=e.snapped;return!!n&&("string"==typeof t?n[t]:n.x&&n.y)}function Ep(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 Op(e){return e.children||[]}var Pp=Math.abs,kp=Math.round;function Sp(e){function t(e,t){if(c(e)){for(var n=e.length;n--;)if(Pp(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?Xc(t,e):e.width?{x:kp(e.width/2+e.x),y:kp(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,s=t.segmentStart,a=t.segmentStartIndex,l=t.segmentEnd,c=t.segmentEndIndex,p=t.axis;if(i)return i;var u=[o[a-1],s,l,o[c+1]];return a<2&&u.unshift(n(r.source,e)),c>o.length-3&&u.unshift(n(r.target,e)),t.snapPoints=i={horizontal:[],vertical:[]},v(u,(function(e){e&&(e=e.original||e,"y"===p&&i.horizontal.push(e.y),"x"===p&&i.vertical.push(e.x))})),i}(e),s=e.x,a=e.y;if(o){var l=s-(i=t(o.vertical,s)),c=a-(r=t(o.horizontal,a));j(e,{dx:e.dx-l,dy:e.dy-c,x:i,y:r}),(l||-1!==o.vertical.indexOf(s))&&Ep(e,"x",i),(c||-1!==o.horizontal.indexOf(a))&&Ep(e,"y",r)}})),e.on(["connect.hover","connect.move","connect.end"],1500,(function(e){var t=e.context.hover,i=t&&n(t,e);dn(t)&&i&&i.x&&i.y&&(Ep(e,"x",i.x),Ep(e,"y",i.y))})),e.on(["bendpoint.move.move","bendpoint.move.end"],1500,(function(e){var i,r,o=e.context,s=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),a=o.hover,l=a&&n(a,e),c=e.x,p=e.y;if(s){var u=c-(i=t(l?s.vertical.concat([l.x]):s.vertical,c)),d=p-(r=t(l?s.horizontal.concat([l.y]):s.horizontal,p));j(e,{dx:e.dx-u,dy:e.dy-d,x:e.x-u,y:e.y-d}),(u||-1!==s.vertical.indexOf(c))&&Ep(e,"x",i),(d||-1!==s.horizontal.indexOf(p))&&Ep(e,"y",r)}}))}Sp.$inject=["eventBus"];var Cp={__depends__:[Sc,Rc],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",Kc],bendpointMove:["type",tp],bendpointMovePreview:["type",cp],connectionSegmentMove:["type",gp],bendpointSnapping:["type",Sp]};function Ap(e,t,n,i){function r(e,t){return i.allowed("connection.create",{source:e,target:t})}e.on("connect.hover",(function(e){var t,n=e.context,i=n.start,o=e.hover;if(n.hover=o,!l(t=n.canExecute=r(i,o))){if(!1!==t)return n.source=i,void(n.target=o);l(t=n.canExecute=r(o,i))||!1!==t&&(n.source=o,n.target=i)}})),e.on(["connect.out","connect.cleanup"],(function(e){var t=e.context;t.hover=null,t.source=null,t.target=null,t.canExecute=!1})),e.on("connect.end",(function(e){var t=e.context,i=t.canExecute,r=t.connectionStart,o={x:e.x,y:e.y},s=t.source,a=t.target;if(!i)return!1;var l=null,c={connectionStart:Mp(t)?o:r,connectionEnd:Mp(t)?r:o};p(i)&&(l=i),t.connection=n.connect(s,a,l,c)})),this.start=function(e,n,i,r){p(i)||(r=i,i=bn(n)),t.init(e,"connect",{autoActivate:r,data:{shape:n,context:{start:n,connectionStart:i}}})}}function Mp(e){var t=e.hover,n=e.source,i=e.target;return t&&n&&t===n&&n!==i}Ap.$inject=["eventBus","dragging","modeling","rules"];var Tp="connect-ok",Rp="connect-not-ok";function Dp(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,s=t.start,a=t.startPosition,l=t.target,c=t.connectionStart||a,p=t.connectionEnd||{x:e.x,y:e.y},u=c,d=p;Mp(t)&&(u=p,d=c),i.drawPreview(t,n,{source:o||s,target:l||r,connectionStart:u,connectionEnd:d})})),t.on("connect.hover",900,(function(e){var t=e.context,i=e.hover,r=t.canExecute;null!==r&&n.addMarker(i,r?Tp:Rp)})),t.on(["connect.out","connect.cleanup"],1100,(function(e){var t=e.hover;t&&(n.removeMarker(t,Tp),n.removeMarker(t,Rp))})),i&&t.on("connect.cleanup",(function(e){i.cleanUp(e.context)}))}Dp.$inject=["injector","eventBus","canvas"];var Np={__depends__:[Ts,Rc,Sc],__init__:["connectPreview"],connect:["type",Ap],connectPreview:["type",Dp]};function Bp(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)}Bp.$inject=["injector","canvas","graphicsFactory","elementFactory"],Bp.prototype.drawPreview=function(e,t,n){n=n||{};var i,r=e.connectionPreviewGfx,o=e.getConnection,s=n.source,a=n.target,l=n.waypoints,c=n.connectionStart,p=n.connectionEnd,u=n.noLayout,d=n.noCropping,h=n.noNoop,m=this;r||(r=e.connectionPreviewGfx=this.createConnectionPreviewGfx()),Ce(r),o||(o=e.getConnection=function(e){var t={};return function(n){var i=JSON.stringify(n),r=t[i];return r||(r=t[i]=e.apply(null,arguments)),r}}((function(e,t,n){return m.getConnection(e,t,n)}))),t&&(i=o(t,s,a)),i?(i.waypoints=l||[],this._layouter&&!u&&(i.waypoints=this._layouter.layoutConnection(i,{source:s,target:a,connectionStart:c,connectionEnd:p,waypoints:n.waypoints||i.waypoints})),i.waypoints&&i.waypoints.length||(i.waypoints=[s?bn(s):c,a?bn(a):p]),this._connectionDocking&&(s||a)&&!d&&(i.waypoints=this._connectionDocking.getCroppedWaypoints(i,s,a)),this._graphicsFactory.drawConnection(r,i,{stroke:"var(--element-dragger-color)"})):!h&&this.drawNoopPreview(r,n)},Bp.prototype.drawNoopPreview=function(e,t){var n=t.source,i=t.target,r=t.connectionStart||bn(n),o=t.connectionEnd||bn(i),s=this.cropWaypoints(r,o,n,i);xe(e,this.createNoopConnection(s[0],s[1]))},Bp.prototype.cropWaypoints=function(e,t,n,i){var r=this._graphicsFactory,o=n&&r.getShapePath(n),s=i&&r.getShapePath(i),a=r.getConnectionPath({waypoints:[e,t]});return[e=n&&wn(o,a,!0)||e,t=i&&wn(s,a,!1)||t]},Bp.prototype.cleanUp=function(e){e&&e.connectionPreviewGfx&&He(e.connectionPreviewGfx)},Bp.prototype.getConnection=function(e){var t=function(e){return p(e)?e:{}}(e);return this._elementFactory.createConnection(t)},Bp.prototype.createConnectionPreviewGfx=function(){var e=De("g");return Oe(e,{pointerEvents:"none"}),ke(e).add("djs-dragger"),xe(this._canvas.getActiveLayer(),e),e},Bp.prototype.createNoopConnection=function(e,t){return pt([e,t],{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"})};var $p={__init__:["connectionPreview"],connectionPreview:["type",Bp]};const jp=new No("ps");var Ip=["marker-start","marker-mid","marker-end"],Lp=["circle","ellipse","line","path","polygon","polyline","path","rect"];function qp(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._styles=i}qp.$inject=["elementRegistry","eventBus","canvas","styles"],qp.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")},qp.prototype.getGfx=function(e){return this._elementRegistry.getGraphics(e)},qp.prototype.addDragger=function(e,t,n,i="djs-dragger"){var r=Ae(n=n||this.getGfx(e)),o=n.getBoundingClientRect();return this._cloneMarkers(Qn(r),i),Oe(r,this._styles.cls(i,[],{x:o.top,y:o.left})),xe(t,r),Oe(r,"data-preview-support-element-id",e.id),r},qp.prototype.addFrame=function(e,t){var n=De("rect",{class:"djs-resize-overlay",width:e.width,height:e.height,x:e.x,y:e.y});return xe(t,n),Oe(n,"data-preview-support-element-id",e.id),n},qp.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!==Lp.indexOf(e.nodeName)}(e)&&Ip.forEach((function(r){if(Oe(e,r)){var o=function(e,t,n){var i=(r=Oe(e,t),r.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]);var r;return ye("marker#"+i,n||document)}(e,r,i._canvas.getContainer());o&&i._cloneMarker(n,e,o,r,t)}}))},qp.prototype._cloneMarker=function(e,t,n,i,r="djs-dragger"){var o=[n.id,r,jp.next()].join("-"),s=ye("marker#"+n.id,e);e=e||this._canvas._svg;var a=s||Ae(n);a.id=o,ke(a).add(r);var l=ye(":scope > defs",e);l||xe(e,l=De("defs")),xe(l,a);var c=function(e){return"url(#"+e+")"}(a.id);Oe(t,i,c)};var zp={__init__:["previewSupport"],previewSupport:["type",qp]};const Vp="complex-preview";class Fp{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(Vp);t.filter((e=>!function(e){return e.hidden}(e))).forEach((e=>{let t;dn(e)?(t=this._graphicsFactory._createContainer("connection",De("g")),this._graphicsFactory.drawConnection(Qn(t),e)):(t=this._graphicsFactory._createContainer("shape",De("g")),this._graphicsFactory.drawShape(Qn(t),e),Kn(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);dn(e)?Kn(n,t.x,t.y):Kn(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",De("g"));this._graphicsFactory.drawShape(Qn(n),e,{width:t.width,height:t.height}),Kn(n,t.x,t.y),this._previewSupport.addDragger(e,o,n)}))}cleanUp(){Ce(this._canvas.getLayer(Vp)),this._markers.forEach((([e,t])=>this._canvas.removeMarker(e,t))),this._markers=[]}show(){this._canvas.showLayer(Vp)}hide(){this._canvas.hideLayer(Vp)}}Fp.$inject=["canvas","graphicsFactory","previewSupport"];var Hp={__depends__:[zp],__init__:["complexPreview"],complexPreview:["type",Fp]},Up=["top","bottom","left","right"],Wp=10;function Gp(e,t){function n(e){if(Kr(e)&&!dn(e)){var n=function(e){var t=bn(e.label),n=bn(e),i=Qp(n,t);if(r=i,-1===Up.indexOf(r))return;var r;var o=function(e){var t=bn(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 Qp(t,e)}));return n}(e);if(e.host){var s=function(e){var t,n=e.host,i=bn(e),r=xn(i,n);t=r.indexOf("-")>=0?r.split("-"):[r];var o=Up.filter((function(e){return-1===t.indexOf(e)}));return o}(e);o=o.concat(s)}var a=Up.filter((function(e){return-1===o.indexOf(e)}));if(-1!==a.indexOf(i))return;return a[0]}(e);n&&function(e,n){var i=bn(e),r=e.label,o=bn(r);if(!r.parent)return;var s,a=gn(e);switch(n){case"top":s={x:i.x,y:a.top-Wp-r.height/2};break;case"left":s={x:a.left-Wp-r.width/2,y:i.y};break;case"bottom":s={x:i.x,y:a.bottom+Wp+r.height/2};break;case"right":s={x:a.right+Wp+r.width/2,y:i.y}}var l=ia(s,o);t.moveShape(r,l)}(e,n)}}Fo.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 Qp(e,t){return xn(t,e,5)}function Xp(e){Fo.call(this,e),this.preExecute("shape.append",(function(e){var t=e.source,n=e.shape;e.position||(_r(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 Kp(e,t){e.invoke(Fo,this),this.postExecute("shape.move",(function(e){var n=e.newParent,i=e.shape;v(y(i.incoming.concat(i.outgoing),(function(e){return _r(e,"bpmn:Association")})),(function(e){t.moveConnection(e,{x:0,y:0},n)}))}),!0)}e(Gp,Fo),Gp.$inject=["eventBus","modeling"],e(Xp,Fo),Xp.$inject=["eventBus"],e(Kp,Fo),Kp.$inject=["injector","modeling"];function Yp(e,t){t.invoke(Fo,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 Zp(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];Zp(r,i)&&(e.shapes=[n._replaceShape(r,i)])}}),!0)}function Zp(e,t){return!hn(e)&&Er(e,["bpmn:IntermediateThrowEvent","bpmn:IntermediateCatchEvent"])&&!!t}function Jp(e,t){function n(e){return y(e.attachers,(function(e){return _r(e,"bpmn:BoundaryEvent")}))}Fo.call(this,e),this.postExecute("connection.create",(function(e){var i=e.context.source,r=e.context.target,o=n(r);_r(i,"bpmn:EventBasedGateway")&&_r(r,"bpmn:ReceiveTask")&&o.length>0&&t.removeElements(o)})),this.postExecute("connection.reconnect",(function(e){var i=e.context.oldSource,r=e.context.newSource;_r(i,"bpmn:Gateway")&&_r(r,"bpmn:EventBasedGateway")&&v(r.outgoing,(function(e){var i=e.target,r=n(i);_r(i,"bpmn:ReceiveTask")&&r.length>0&&t.removeElements(r)}))}))}function eu(e,t,n){function i(e){t.updateProperties(e,{isForCompensation:!0})}function r(e){t.updateProperties(e,{isForCompensation:void 0})}Fo.call(this,e),this.preExecute("shape.replace",(function(e){const{newData:n,oldShape:i}=e;if(nu(e.oldShape)&&"bpmn:CompensateEventDefinition"!==n.eventDefinitionType||"bpmn:BoundaryEvent"!==n.type){const t=i.outgoing.find((({target:e})=>tu(e)));t&&t.target&&(e._connectionTarget=t.target)}else if(!nu(e.oldShape)&&"bpmn:CompensateEventDefinition"===n.eventDefinitionType&&"bpmn:BoundaryEvent"===n.type){const n=i.outgoing.find((({target:e})=>iu(e)));n&&n.target&&(e._connectionTarget=n.target),function(e){const n=e.outgoing.filter((e=>_r(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;nu(r)&&iu(o)&&(i(o),function(e,n){const i=e.outgoing.filter((e=>_r(e,"bpmn:Association"))),r=i.filter((e=>tu(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;nu(t)&&tu(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;tu(o)&&r(o),nu(e)&&iu(t)&&i(t)}}),!0),this.postExecuted("element.updateProperties",(function(e){const{element:i}=e;tu(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)):iu(i)&&function(e){const n=e.incoming.filter((e=>nu(e.source)));t.removeElements(n)}(i)}),!0)}function tu(e){const t=Or(e);return t&&t.get("isForCompensation")}function nu(e){return e&&_r(e,"bpmn:BoundaryEvent")&&Wr(e,"bpmn:CompensateEventDefinition")}function iu(e){return e&&_r(e,"bpmn:Activity")&&!Ur(e)}function ru(e){e.invoke(Fo,this),this.preExecute("shape.create",1500,(function(e){var t=e.context,n=t.parent,i=t.shape;_r(n,"bpmn:Lane")&&!_r(i,"bpmn:Lane")&&(t.parent=pc(n,"bpmn:Participant"))}))}function ou(e,t){Fo.call(this,e),this.preExecute("shape.create",(function(e){var n=e.context.shape;if(_r(n,"bpmn:DataObjectReference")&&"label"!==n.type){var i=t.create("bpmn:DataObject");n.businessObject.dataObjectRef=i}}))}Yp.$inject=["bpmnReplace","injector"],e(Yp,Fo),Yp.prototype._replaceShape=function(e,t){var n,i=(n=Or(e).eventDefinitions)&&n[0],r={type:"bpmn:BoundaryEvent",host:t};return i&&(r.eventDefinitionType=i.$type),this._bpmnReplace.replaceElement(e,r,{layoutConnection:!1})},Jp.$inject=["eventBus","modeling"],e(Jp,Fo),e(eu,Fo),eu.$inject=["eventBus","modeling","bpmnRules"],ru.$inject=["injector"],e(ru,Fo),ou.$inject=["eventBus","bpmnFactory"],e(ou,Fo);var su=20,au=20,lu=30,cu=2e3;function pu(e,t,n){function i(){var t=e.getRootElement();return _r(t,"bpmn:Collaboration")?t:n.makeCollaboration()}Fo.call(this,t),t.on(["create.start","shape.move.start"],cu,(function(t){var n=t.context,i=n.shape,r=e.getRootElement();if(_r(i,"bpmn:Participant")&&_r(r,"bpmn:Process")&&r.children.length){var o=r.children.filter((function(e){return!_r(e,"bpmn:Group")&&!hn(e)&&!dn(e)}));if(o.length){var s=yt(o),a=function(e,t){t={width:t.width+2*su+lu,height:t.height+2*au};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,s);j(i,a),n.createConstraints=function(e,t){return t=gn(t),{bottom:t.top+e.height/2-au,left:t.right-e.width/2+su,top:t.bottom-e.height/2+au,right:t.left+e.width/2-su-lu}}(i,s)}}})),t.on("create.start",cu,(function(n){var i=n.context.shape,r=e.getRootElement(),o=e.getGraphics(r);function s(e){e.element=r,e.gfx=o}_r(i,"bpmn:Participant")&&_r(r,"bpmn:Process")&&(t.on("element.hover",cu,s),t.once("create.cleanup",(function(){t.off("element.hover",s)})))})),this.preExecute("elements.create",cu,(function(e){var t,n=e.elements,r=e.parent,o=function(e){return f(e,(function(e){return _r(e,"bpmn:Participant")}))}(n);o&&_r(r,"bpmn:Process")&&(e.parent=i(),(t=e.hints=e.hints||{}).participant=o,t.process=r,t.processRef=Or(o).get("processRef"))}),!0),this.preExecute("shape.create",(function(e){var t=e.parent,n=e.shape;_r(n,"bpmn:Participant")&&_r(t,"bpmn:Process")&&(e.parent=i(),e.process=t,e.processRef=Or(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||Or(i).set("processRef",Or(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||Or(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 s=i.children.slice();o?r===o&&n.moveElements(s,{x:0,y:0},o):n.moveElements(s,{x:0,y:0},r)}}),!0)}pu.$inject=["canvas","eventBus","modeling"],e(pu,Fo);var uu="__targetRef_placeholder";function du(e,t){function n(e,n){var i=e.get("properties"),r=f(i,(function(e){return e.name===uu}));return!r&&n&&Ot(i,r=t.create("bpmn:Property",{name:uu})),r}function i(e,t){var i=n(e);i&&(function(e,t,n){return f(e.get("dataInputAssociations"),(function(e){return e!==n&&e.targetRef===t}))}(e,i,t)||Et(e.get("properties"),i))}function r(e){var t,r=e.context,o=r.connection,s=o.businessObject,a=o.target,l=a&&a.businessObject,c=r.newTarget,p=c&&c.businessObject,u=r.oldTarget||r.target,d=u&&u.businessObject,h=o.businessObject;d&&d!==l&&i(d,s),p&&p!==l&&i(p,s),l?(t=n(l,!0),h.targetRef=t):h.targetRef=null}Fo.call(this,e),this.executed(["connection.create","connection.delete","connection.move","connection.reconnect"],hu(r)),this.reverted(["connection.create","connection.delete","connection.move","connection.reconnect"],hu(r))}function hu(e){return function(t){if(_r(t.context.connection,"bpmn:DataInputAssociation"))return e(t)}}function mu(e){this._bpmnUpdater=e}function fu(e,t,n,i){function r(e){return e.children.filter((function(e){return _r(e,"bpmn:DataStoreReference")&&!e.labelTarget}))}function o(e,i){var r=e.businessObject||e;if(i=i||n.filter((function(e){return _r(e,"bpmn:Participant")&&Or(e).processRef}))[0]){var o=i.businessObject||i;t.execute("dataStore.updateContainment",{dataStoreBo:r,dataStoreDi:Pr(e),newSemanticParent:o.processRef||o,newDiParent:Pr(i)})}}Fo.call(this,i),t.registerHandler("dataStore.updateContainment",mu),this.preExecute("shape.create",(function(e){var t=e.context,n=t.shape;_r(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 _r(e,"bpmn:DataStoreReference")})).length&&(t.hints||(t.hints={}),t.hints.autoResize=n.filter((function(e){return!_r(e,"bpmn:DataStoreReference")})))})),this.postExecute("shape.create",(function(e){var t=e.context.shape,n=t.parent;_r(t,"bpmn:DataStoreReference")&&"label"!==t.type&&_r(n,"bpmn:Collaboration")&&o(t)})),this.postExecute("shape.move",(function(e){var t=e.context,n=t.shape,i=t.oldParent,r=n.parent;_r(i,"bpmn:Collaboration")||_r(n,"bpmn:DataStoreReference")&&"label"!==n.type&&_r(r,"bpmn:Collaboration")&&o(n,_r(i,"bpmn:Participant")?i:function(e,t){for(;e.parent;){if(_r(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();Er(n,["bpmn:Participant","bpmn:SubProcess"])&&_r(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){_r(i,"bpmn:Process")&&o(e,i)}))}))}du.$inject=["eventBus","bpmnFactory"],e(du,Fo),mu.$inject=["bpmnUpdater"],mu.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),[]},mu.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),[]},fu.$inject=["canvas","commandStack","elementRegistry","eventBus"],e(fu,Fo);var gu=Math.max,yu=Math.min,vu=20;function bu(e,t){return{top:e.top-t.top,right:e.right-t.right,bottom:e.bottom-t.bottom,left:e.left-t.left}}function xu(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)?yu:gu)(i,r)),u(o)&&(i=(/top|left/.test(e)?gu:yu)(i,o)),i}function wu(e,t){return void 0!==e?e:vu}function _u(e){return!e.waypoints&&"label"!==e.type}function Eu(e,t){var n;if((n=void 0===e.length?y(e.children,_u):e).length)return function(e,t){var n,i,r,o;return"object"==typeof t?(n=wu(t.left),i=wu(t.right),r=wu(t.top),o=wu(t.bottom)):n=i=r=o=wu(t),{x:e.x-n,y:e.y-r,width:e.width+n+i,height:e.height+r+o}}(yt(n),t)}var Ou=Math.abs;var Pu=["bpmn:Participant","bpmn:Process","bpmn:SubProcess"],ku=30;function Su(e,t){return t=t||[],e.children.filter((function(e){_r(e,"bpmn:Lane")&&(Su(e,t),t.push(e))})),t}function Cu(e){return e.children.filter((function(e){return _r(e,"bpmn:Lane")}))}function Au(e){return pc(e,Pu)||e}function Mu(e,t){var n=Au(e),i=Su(n,_r(n,"bpmn:Process")?[]:[n]),r=gn(e),o=gn(t),s=function(e,t){return bu(gn(t),gn(e))}(e,t),a=[],l=Fr(e);return i.forEach((function(t){if(t!==e){var n,i,c=l?0:s.top,p=l?s.right:0,u=l?0:s.bottom,d=l?s.left:0,h=gn(t);s.top&&(Ou(h.bottom-r.top)<10&&(u=o.top-h.bottom),Ou(h.top-r.top)<5&&(c=o.top-h.top)),s.left&&(Ou(h.right-r.left)<10&&(p=o.left-h.right),Ou(h.left-r.left)<5&&(d=o.left-h.left)),s.bottom&&(Ou(h.top-r.bottom)<10&&(c=o.bottom-h.top),Ou(h.bottom-r.bottom)<5&&(u=o.bottom-h.bottom)),s.right&&(Ou(h.left-r.right)<10&&(d=o.right-h.left),Ou(h.right-r.right)<5&&(p=o.right-h.right)),(c||p||u||d)&&a.push({shape:t,newBounds:(n=t,i={top:c,right:p,bottom:u,left:d},{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)})})}})),a}function Tu(e,t){Fo.call(this,e),this.postExecuted("shape.delete",500,(function(e){var n=e.context,i=n.hints,r=n.shape,o=n.oldParent;_r(r,"bpmn:Lane")&&(i&&i.nested||function(e,n){var i,r,o,s,a,l=Fr(e),c=Cu(n),p=[],u=[],d=[],h=[];ft(c,(function(t){return l?t.y>e.y?u.push(t):p.push(t):t.x>e.x?h.push(t):d.push(t),t.children})),c.length&&(i=l?u.length&&p.length?e.height/2:e.height:h.length&&d.length?e.width/2:e.width,p.length&&(r=t.calculateAdjustments(p,"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")),d.length&&(s=t.calculateAdjustments(d,"x",i,e.x-10),t.makeSpace(s.movingShapes,s.resizingShapes,{x:i,y:0},"e")),h.length&&(a=t.calculateAdjustments(h,"x",-i,e.x+e.width+10),t.makeSpace(a.movingShapes,a.resizingShapes,{x:-i,y:0},"w")))}(r,o))}))}Tu.$inject=["eventBus","spaceTool"],e(Tu,Fo);function Ru(e,t){t.invoke(Fo,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",500,(function(e){var t=e.elements;t.filter((function(e){return Du(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,s=e.host;Du(e,(o=s,-1!==t.indexOf(o)?s:i))&&(t[r]=n._replaceShape(e))}))}),!0)}function Du(e,t){return!hn(e)&&_r(e,"bpmn:BoundaryEvent")&&!t}function Nu(e,t,n){function i(e,i,r){var o,s,a,l,c,p,d,h,m=i.waypoints,f=e.outgoing.slice(),g=e.incoming.slice(),v=$c(m,h=u(r.width)?bn(r):r);if(v){if(o=m.slice(0,v.index),s=m.slice(v.index+(v.bendpoint?1:0)),!o.length||!s.length)return;a=v.bendpoint?m[v.index]:h,1!==o.length&&Bu(e,o[o.length-1])||o.push($u(a)),1!==s.length&&Bu(e,s[0])||s.unshift($u(a))}l=i.source,c=i.target,t.canConnect(l,e,i)&&(n.reconnectEnd(i,e,o||h),p=i),t.canConnect(e,c,i)&&(p?d=n.connect(e,c,{type:i.type,waypoints:s}):(n.reconnectStart(i,e,s||h),d=i));var b=[].concat(p&&y(g,(function(e){return e.source===p.source}))||[],d&&y(f,(function(e){return e.target===d.target}))||[]);b.length&&n.removeElements(b)}Fo.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 s=bn(o),a={x:s.x+r.x,y:s.y+r.y},l=f(n.children,(function(e){return t.canInsert(i,e)&&$c(e.waypoints,a)}));l&&(e.targetFlow=l,e.position=a)}}),!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 $u(e){return j({},e)}function ju(e,t){Fo.call(this,e),this.preExecuted("connection.create",(function(e){var n=e.context,i=n.connection,r=n.source,o=n.target,s=n.hints;if((!s||!1!==s.createElementsBehavior)&&Iu(i)){(_r(r,"bpmn:EventBasedGateway")?o.incoming.filter((e=>e!==i&&Iu(e))):o.incoming.filter((e=>e!==i&&Iu(e)&&_r(e.source,"bpmn:EventBasedGateway")))).forEach((function(e){t.removeConnection(e)}))}})),this.preExecuted("shape.replace",(function(e){var n=e.context.newShape;_r(n,"bpmn:EventBasedGateway")&&n.outgoing.filter(Iu).reduce((function(e,t){return e.includes(t.target)?e:e.concat(t.target)}),[]).forEach((function(e){e.incoming.filter(Iu).forEach((function(i){const r=e.incoming.filter(Iu).filter((function(e){return e.source===n}));(i.source!==n||r.length>1)&&t.removeConnection(i)}))}))}))}function Iu(e){return _r(e,"bpmn:SequenceFlow")}Ru.$inject=["bpmnReplace","injector"],e(Ru,Fo),Ru.prototype._replaceShape=function(e){var t,n,i=(n=Or(e).eventDefinitions)&&n[0];return t=i?{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:i.$type}:{type:"bpmn:IntermediateThrowEvent"},this._bpmnReplace.replaceElement(e,t,{layoutConnection:!1})},e(Nu,Fo),Nu.$inject=["eventBus","bpmnRules","modeling"],ju.$inject=["eventBus","modeling"],e(ju,Fo);var Lu=1500;function qu(e,t,n){t.on(["create.hover","create.move","create.out","create.end","shape.move.hover","shape.move.move","shape.move.out","shape.move.end"],Lu,(function(t){var i=t.context.shape||t.shape,r=t.hover;_r(r,"bpmn:Lane")&&!Er(i,["bpmn:Lane","bpmn:Participant"])&&(t.hover=Au(r),t.hoverGfx=e.getGraphics(t.hover));var o=n.getRootElement();r!==o&&(i.labelTarget||Er(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"],Lu,(function(t){var n=t.hover;_r(n,"bpmn:Lane")&&(t.hover=Au(n)||n,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["bendpoint.move.hover"],Lu,(function(t){var n=t.context,i=t.hover,r=n.type;_r(i,"bpmn:Lane")&&/reconnect/.test(r)&&(t.hover=Au(i)||i,t.hoverGfx=e.getGraphics(t.hover))})),t.on(["connect.start"],Lu,(function(e){var t=e.context,n=t.start;_r(n,"bpmn:Lane")&&(t.start=Au(n)||n)})),t.on("shape.move.start",2e3,(function(e){var t=e.shape;_r(t,"bpmn:Lane")&&(e.shape=Au(t)||t)})),t.on("spaceTool.move",2e3,(function(e){var t=e.hover;t&&_r(t,"bpmn:Lane")&&(e.hover=Au(t))}))}qu.$inject=["elementRegistry","eventBus","canvas"];function zu(e,t,n,i,r,o){function s(e,t,i){var r=n.filter((function(e){return _r(e,"bpmn:Group")})).filter((function(e){return e.businessObject!==i}));t&&!function(e,t){return e.some((function(e){var n=Or(e);return(n.categoryValueRef&&n.categoryValueRef.$parent)===t}))}(r,t)&&function(e){var t=e.$parent;t&&(Et(t.get("rootElements"),e),e.$parent=null)}(t),e&&!function(e,t){return e.some((function(e){return Or(e).categoryValueRef===t}))}(r,e)&&function(e){var t=e.$parent;t&&(Et(t.get("categoryValue"),e),e.$parent=null)}(e)}function a(e,n){return function(e,t,n){return Ot(t.get("categoryValue"),e),e.$parent=t,Ot(n.get("rootElements"),t),t.$parent=n,e}(e,n,t.getDefinitions())}function l(n,i){var r=Or(n),o=r.categoryValueRef;o||(o=r.categoryValueRef=i.categoryValue=i.categoryValue||function(e){return e.create("bpmn:CategoryValue")}(e));var s=o.$parent;s||(s=o.$parent=i.category=i.category||function(e){return e.create("bpmn:Category")}(e)),a(o,s,t.getDefinitions())}function c(e,t){var n=t.category,i=t.categoryValue,r=Or(e);i?(r.categoryValueRef=null,s(i,n,r)):s(null,r.categoryValueRef.$parent,r)}function p(t,n){var i=e.create(t.$type);return o.copyElement(t,i,null,n)}r.invoke(Fo,this),this.execute("label.create",(function(e){var t=e.context,n=t.labelTarget;_r(n,"bpmn:Group")&&l(n,t)})),this.revert("label.create",(function(e){var t=e.context,n=t.labelTarget;_r(n,"bpmn:Group")&&c(n,t)})),this.execute("shape.delete",(function(e){var t=e.context,n=t.shape,i=Or(n);if(_r(n,"bpmn:Group")&&!n.labelTarget){var r=t.categoryValue=i.categoryValueRef;r&&(s(r,t.category=r.$parent,i),i.categoryValueRef=null)}})),this.reverted("shape.delete",(function(e){var t=e.context,n=t.shape;if(_r(n,"bpmn:Group")&&!n.labelTarget){var i=t.category,r=t.categoryValue,o=Or(n);r&&(o.categoryValueRef=r,a(r,i))}})),this.execute("shape.create",(function(e){var t=e.context,n=t.shape;_r(n,"bpmn:Group")&&!n.labelTarget&&Or(n).categoryValueRef&&l(n,t)})),this.reverted("shape.create",(function(e){var t=e.context,n=t.shape;_r(n,"bpmn:Group")&&!n.labelTarget&&Or(n).categoryValueRef&&c(n,t)})),i.on("copyPaste.copyElement",770,(function(e){var t=e.descriptor,n=e.element;if(_r(n,"bpmn:Group")&&!n.labelTarget){var i=Or(n);if(i.categoryValueRef){var r=i.categoryValueRef;t.categoryValue=p(r,!0),r.$parent&&(t.category=p(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=p(i)),r&&(i.$parent=p(r)),delete t.category,delete t.categoryValue}))}function Vu(e,t,n,i){var r,o,s,a;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,s=e.x-n.x,a=((i.x-n.x)*o-(i.y-n.y)*s)/r,{x:Math.round(e.x+a*(t.x-e.x)),y:Math.round(e.y+a*(t.y-e.y))})}function Fu(e){function t(e,t,n){var i,r={x:n.x,y:n.y-50},o={x:n.x-50,y:n.y},s=Vu(e,t,n,r),a=Vu(e,t,n,o);i=s&&a?Hu(s,n)>Hu(a,n)?a:s:s||a,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],bn(n.source)),t(i[i.length-1],i[i.length-2],bn(n.target)))}))}function Hu(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Uu(e){Fo.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=Or(n),r=Pr(n);if(Er(i,t)){var o=r.get("isHorizontal");void 0===o&&(o=!0),r.set("isHorizontal",o)}}))}zu.$inject=["bpmnFactory","bpmnjs","elementRegistry","eventBus","injector","moddleCopy"],e(zu,Fo),Fu.$inject=["eventBus"],Uu.$inject=["eventBus"],e(Uu,Fo);var Wu=Math.sqrt,Gu=Math.min,Qu=Math.max,Xu=Math.abs;function Ku(e){return Math.pow(e,2)}function Yu(e,t){return Wu(Ku(e.x-t.x)+Ku(e.y-t.y))}function Zu(e,t,n,i){var r=t.x-e.x,o=t.y-e.y,s=n.x-e.x,a=n.y-e.y,l=r*r+o*o,c=(r*s+o*a)/l,p=c*c-(s*s+a*a-i*i)/l;if(p<0&&p>-1e-6&&(p=0),p<0)return[];var u=Wu(p),d=-c+u,h=-c-u,m={x:e.x-r*d,y:e.y-o*d};return 0===p?[m]:[m,{x:e.x-r*h,y:e.y-o*h}].filter((function(n){return function(e,t,n){return Ju(e.x,t.x,n.x)&&Ju(e.y,t.y,n.y)}(n,e,t)}))}function Ju(e,t,n){return e>=Gu(t,n)-ed&&e<=Qu(t,n)+ed}var ed=.1;function td(e,t){return Xu(e.x-t.x)<=ed&&Xu(e.y-t.y)<=ed}function nd(e,t,n,i){var r=0,o=0,s={point:e,delta:{x:0,y:0}},a=function(e,t){var n,i,r,o,s,a,l,c,p,u,d,h,m=0;for(m=0;m<t.length-1;m++){if(td(n=t[m],i=t[m+1])?a=[n]:(r=Yu(e,n),o=Yu(e,i),a=Zu(n,i,e,Gu(r,o))),a.length<1)throw new Error("expected between [1, 2] circle -> line intersections");1===a.length&&(l={type:"bendpoint",position:a[0],segmentIndex:m,bendpointIndex:td(n,a[0])?m:m+1}),2===a.length&&(d=a[0],h=a[1],l={type:"segment",position:s={x:(d.x+h.x)/2,y:(d.y+h.y)/2},segmentIndex:m,relativeLocation:Yu(n,s)/Yu(n,i)}),c=Yu(l.position,e),(!u||p>c)&&(u=l,p=c)}return u}(e,n),l=a.segmentIndex,c=function(e,t,n,i){var r=n.segmentIndex,o=t.length-e.length;if(i.segmentMove){var s=i.segmentMove.segmentStartIndex,a=i.segmentMove.newSegmentStartIndex;return r===s?a:r>=a?r+o<a?a:r+o:r}if(i.bendpointMove){var l,c=i.bendpointMove.insert,p=i.bendpointMove.bendpointIndex;return 0===o?r:(r>=p&&(l=c?r+1:r-1),r<p&&(l=r,c&&"bendpoint"!==n.type&&p-1===r&&id(t,p)<n.relativeLocation&&l++),l)}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,a,i);if(c<0||c>t.length-2||null===c)return s;var p,u,d=rd(n,l),h=rd(t,c),m=a.position,f=function(e,t){var n=zc(e[0],e[1]),i=zc(e[0],t);return 0===n?0:i/n}(d,m),g=(p=h,u=Ic(d),Ic(p)-u);if("bendpoint"===a.type){var y=t.length-n.length,v=a.bendpointIndex,b=n[v];if(-1!==t.indexOf(b))return s;if(0===y){var x=t[v];return{delta:{x:r=x.x-a.position.x,y:o=x.y-a.position.y},point:{x:e.x+r,y:e.y+o}}}y<0&&0!==v&&v<n.length-1&&(f=id(n,v))}var w,_,E={x:(h[1].x-h[0].x)*f+h[0].x,y:(h[1].y-h[0].y)*f+h[0].y},O=(w={x:e.x-m.x,y:e.y-m.y},(_=g)?{x:Math.cos(_)*w.x-Math.sin(_)*w.y,y:Math.sin(_)*w.x+Math.cos(_)*w.y}:w);return r=E.x+O.x-e.x,o=E.y+O.y-e.y,{point:fn(E),delta:fn({x:r,y:o})}}function id(e,t){var n=zc(e[t-1],e[t]);return n/(n+zc(e[t],e[t+1]))}function rd(e,t){return[e[t],e[t+1]]}function od(e,t,n){var i=na(t),r=na(n),o=ia(e,i),s=o.x*(n.width/t.width),a=o.y*(n.height/t.height);return fn({x:r.x+s,y:r.y+a})}function sd(e,t,n){var i=na(e),r=na(t),o=na(n),s=ia(e,i),a=ia(i,r),l=function(e,t,n){var i=gn(t),r=gn(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,s,a,l=xn(t,e);if("top"===l)o={x:0,y:r.bottom-i.bottom};else if("bottom"===l)o={x:0,y:r.top-i.top};else if("right"===l)o={x:r.left-i.left,y:0};else{if("left"!==l)return null;o={x:r.right-i.right,y:0}}if(s={x:e.x+o.x,y:e.y+o.y},a=xn(n,s),a!==l)return null;return o}(i,t,n);if(l)return l;var c=a.x*(n.width/t.width),p=a.y*(n.height/t.height),u=o.x+c,d=o.y+p;return fn({x:u+s.x-e.x,y:d+s.y-e.y})}var ad="name",ld="text";function cd(e,t,n,i){function r(e){var n=e.context,r=n.element,o=n.properties;if(ad in o&&t.updateLabel(r,o[ad]),ld in o&&_r(r,"bpmn:TextAnnotation")){var s=i.getTextAnnotationBounds({x:r.x,y:r.y,width:r.width,height:r.height},o[ld]||"");t.updateLabel(r,o.text,s)}}function o(e){var t=e.context,n=t.connection,i=n.label,r=j({},t.hints),o=t.newWaypoints||n.waypoints,s=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 nd(bn(e),t,n,i).delta}(i,o,s,r)}Fo.call(this,e),this.postExecute("element.updateProperties",r),this.postExecute("element.updateModdleProperties",(e=>{Or(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;!hn(i)&&Xr(i)&&eo(i)&&t.updateLabel(i,eo(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=Or(n);r&&Xr(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,s=i.oldBounds;if(Kr(r)){var a=r.label,l=function(e,t){if(!t.length)return;var n=function(e,t){var n=t.map((function(t){return{line:t,distance:qc(e,t)}}));return A(n,"distance")[0].line}(e,t);return Lc(e,n)}(bn(a),[[{x:(n=s).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)}]]),c=pd(l,s,o);t.moveShape(a,c)}}))}function pd(e,t,n){return fn(ia(od(e,t,n),e))}function ud(e,t){function n(e,t){var n=e.context,i=n.connection,r=j({},n.hints),o=n.newWaypoints||i.waypoints,s=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 nd(e,t,n,i).point}(t,o,s,r)}Fo.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),s=[].concat(i.waypoints.slice(0,-1),[o]);t.updateWaypoints(i,s)})),r.forEach((function(i){var r=i.waypoints[0],o=n(e,r),s=[].concat([o],i.waypoints.slice(1));t.updateWaypoints(i,s)}))})),this.postExecute(["connection.move"],(function(e){var n=e.context,i=n.connection,r=i.outgoing,o=i.incoming,s=n.delta;o.forEach((function(e){var n=e.waypoints[e.waypoints.length-1],i={x:n.x+s.x,y:n.y+s.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+s.x,y:n.y+s.y},r=[].concat([i],e.waypoints.slice(1));t.updateWaypoints(e,r)}))}))}function dd(e,t,n){var i=yd(e),r=vd(i,t),o=i[0];return r.length?r[r.length-1]:od(o.original||o,n,t)}function hd(e,t,n){var i=yd(e),r=vd(i,t),o=i[i.length-1];return r.length?r[0]:od(o.original||o,n,t)}function md(e,t,n){var i=yd(e),r=gd(t,n),o=i[0];return od(o.original||o,r,t)}function fd(e,t,n){var i=yd(e),r=gd(t,n),o=i[i.length-1];return od(o.original||o,r,t)}function gd(e,t){return{x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}}function yd(e){var t=e.waypoints;if(!t.length)throw new Error("connection#"+e.id+": no waypoints");return t}function vd(e,t){return y(E(e,bd),(function(e){return function(e,t){return"intersect"===xn(t,e,1)}(e,t)}))}function bd(e){return e.original||e}function xd(e,t){Fo.call(this,e),this.postExecute("shape.replace",(function(e){var n=e.oldShape,i=e.newShape;if(function(e,t){return _r(e,"bpmn:Participant")&&Vr(e)&&_r(t,"bpmn:Participant")&&!Vr(t)}(n,i)){var r,o,s,a,l=(o=gt([r=n],!1),s=[],a=[],o.forEach((function(e){e!==r&&(e.incoming.forEach((function(e){_r(e,"bpmn:MessageFlow")&&s.push(e)})),e.outgoing.forEach((function(e){_r(e,"bpmn:MessageFlow")&&a.push(e)})))}),[]),{incoming:s,outgoing:a});l.incoming.forEach((function(e){var r=hd(e,i,n);t.reconnectEnd(e,i,r)})),l.outgoing.forEach((function(e){var r=dd(e,i,n);t.reconnectStart(e,i,r)}))}}),!0)}e(cd,Fo),cd.$inject=["eventBus","modeling","bpmnFactory","textRenderer"],e(ud,Fo),ud.$inject=["eventBus","modeling"],xd.$inject=["eventBus","modeling"],e(xd,Fo);const wd=["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:EscalationEventDefinition","bpmn:ConditionalEventDefinition","bpmn:SignalEventDefinition"];function _d(e){const t=Or(e);if(!(_r(t,"bpmn:BoundaryEvent")||_r(t,"bpmn:StartEvent")&&Ur(t.$parent)))return!1;const n=t.get("eventDefinitions");return!(!n||!n.length)&&wd.some((e=>_r(n[0],e)))}function Ed(e){return _r(e,"bpmn:BoundaryEvent")?"cancelActivity":"isInterrupting"}function Od(e,t){e.invoke(Fo,this),this.postExecuted("shape.replace",(function(e){const n=e.context.oldShape,i=e.context.newShape,r=e.context.hints;if(!_d(i))return;const o=Ed(i);if(r.targetElement&&void 0!==r.targetElement[o])return;const s=Or(n).get(o);s!==Or(i).get(o)&&t.updateProperties(i,{[o]:s})}))}function Pd(e,t){Fo.call(this,e),this.preExecute("shape.resize",(function(e){var n=e.shape,i=Pr(n),r=i&&i.get("label");r&&r.get("bounds")&&t.updateModdleProperties(n,r,{bounds:void 0})}),!0)}function kd(e,t,n){Fo.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(_r(r,"bpmn:SequenceFlow")&&_r(o,"bpmn:SequenceFlow")&&t.canConnect(r.source,o.target,r)){var s=function(e,t){var n=Vu(Sd(e[e.length-2]),Sd(e[e.length-1]),Sd(t[1]),Sd(t[0]));return n?[].concat(e.slice(0,e.length-1),[n],t.slice(1)):[Sd(e[0]),Sd(t[t.length-1])]}(r.waypoints,o.waypoints);n.reconnectEnd(r,o.target,s)}}}))}function Sd(e){return e.original||e}function Cd(e,t){Fo.call(this,e),this.preExecute("shape.delete",(function(e){var t=e.shape,n=t.parent;_r(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 Ad(e,t,n,i){Fo.call(this,e);var r=i.get("dragging",!1);function o(e){var i,r,o=e.source,s=e.target;e.parent&&(_r(e,"bpmn:SequenceFlow")&&(n.canConnectSequenceFlow(o,s)||(r=!0),n.canConnectMessageFlow(o,s)&&(i="bpmn:MessageFlow")),_r(e,"bpmn:MessageFlow")&&(n.canConnectMessageFlow(o,s)||(r=!0),n.canConnectSequenceFlow(o,s)&&(i="bpmn:SequenceFlow")),r&&t.removeConnection(e),i&&t.connect(o,s,{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,s=e.context,a=s.connection,l=s.newSource||a.source,c=s.newTarget||a.target;(i=n.canConnect(l,c))&&i.type!==a.type&&(o=t.connect(l,c,{type:i.type,associationDirection:i.associationDirection,waypoints:a.waypoints.slice()}),a.parent&&t.removeConnection(a),s.connection=o,r&&function(e,t){var n,i=r.context(),o=i&&i.payload.previousSelection;if(!o||!o.length)return;if(n=o.indexOf(e),-1===n)return;o.splice(n,1,t)}(a,o))})),this.postExecuted("element.updateProperties",(function(e){var n,i=e.context,r=i.properties,o=i.element,s=o.businessObject;r.default&&(n=f(o.outgoing,M({id:o.businessObject.default.id})))&&t.updateProperties(n,{conditionExpression:void 0}),r.conditionExpression&&s.sourceRef.default===s&&t.updateProperties(o.source,{default:void 0})}))}function Md(e,t,n,i,r,o){i.invoke(Fo,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=x(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=Ur(e)?o.concat(e.children):o.concat(e)})),1===o.length&&r&&(i=r);var s=t.canReplace(o,i);s&&this._replaceElements(o,s.replacements,r)}),this),this.postExecute(["shape.replace"],1500,(function(e){var n,i=e.context,r=i.oldShape,o=i.newShape,s=r.attachers;s&&s.length&&(n=t.canReplace(s,o),this._replaceElements(s,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})}))}Od.$inject=["injector","modeling"],e(Od,Fo),e(Pd,Fo),Pd.$inject=["eventBus","modeling"],e(kd,Fo),kd.$inject=["eventBus","bpmnRules","modeling"],Cd.$inject=["eventBus","modeling"],e(Cd,Fo),e(Ad,Fo),Ad.$inject=["eventBus","modeling","bpmnRules","injector"],e(Md,Fo),Md.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),s=e.indexOf(o);e[s]=i.replaceElement(o,r,{select:!1})})),t&&r.select(e)},Md.$inject=["bpmnReplace","bpmnRules","elementRegistry","injector","modeling","selection"];var Td={width:140,height:120},Rd={width:300,height:60},Dd={width:60,height:300},Nd={width:300,height:150},Bd={width:150,height:300},$d={width:140,height:120},jd={width:50,height:30};function Id(e){e.on("resize.start",1500,(function(e){var t=e.context,n=t.shape,i=t.direction,r=t.balanced;(_r(n,"bpmn:Lane")||_r(n,"bpmn:Participant"))&&(t.resizeConstraints=function(e,t,n){var i=Au(e),r=!0,o=!0,s=Su(i,[i]),a=gn(e),l={},c={},p=Fr(e),u=p?Rd:Dd;/n/.test(t)?c.top=a.bottom-u.height:/e/.test(t)?c.right=a.left+u.width:/s/.test(t)?c.bottom=a.top+u.height:/w/.test(t)&&(c.left=a.right-u.width);s.forEach((function(e){var i=gn(e);p?(i.top<a.top-10&&(r=!1),i.bottom>a.bottom+10&&(o=!1)):(i.left<a.left-10&&(r=!1),i.right>a.right+10&&(o=!1)),/n/.test(t)&&(n&&Ld(a.top-i.bottom)<10&&Hd(l,"top",i.top+u.height),Ld(a.top-i.top)<5&&Fd(c,"top",i.bottom-u.height)),/e/.test(t)&&(n&&Ld(a.right-i.left)<10&&Fd(l,"right",i.right-u.width),Ld(a.right-i.right)<5&&Hd(c,"right",i.left+u.width)),/s/.test(t)&&(n&&Ld(a.bottom-i.top)<10&&Fd(l,"bottom",i.bottom-u.height),Ld(a.bottom-i.bottom)<5&&Hd(c,"bottom",i.top+u.height)),/w/.test(t)&&(n&&Ld(a.left-i.right)<10&&Hd(l,"left",i.left+u.width),Ld(a.left-i.left)<5&&Fd(c,"left",i.right-u.width))}));var d=i.children.filter((function(e){return!e.hidden&&!e.waypoints&&(_r(e,"bpmn:FlowElement")||_r(e,"bpmn:Artifact"))})),h=p?Ud:Wd;return d.forEach((function(e){var n=gn(e);!/n/.test(t)||p&&!r||Fd(c,"top",n.top-h.top),/e/.test(t)&&(p||o)&&Hd(c,"right",n.right+h.right),!/s/.test(t)||p&&!o||Hd(c,"bottom",n.bottom+h.bottom),/w/.test(t)&&(p||r)&&Fd(c,"left",n.left-h.left)})),{min:c,max:l}}(n,i,r)),_r(n,"bpmn:SubProcess")&&Vr(n)&&(t.minDimensions=$d),_r(n,"bpmn:TextAnnotation")&&(t.minDimensions=jd)}))}Id.$inject=["eventBus"];var Ld=Math.abs,qd=Math.min,zd=Math.max;function Vd(e,t,n,i){var r=e[t];e[t]=void 0===r?n:i(n,r)}function Fd(e,t,n){return Vd(e,t,n,qd)}function Hd(e,t,n){return Vd(e,t,n,zd)}var Ud={top:20,left:50,right:20,bottom:20},Wd={top:50,left:20,right:20,bottom:20};function Gd(e,t){e.on("resize.start",1501,(function(e){var t=e.context,n=t.shape;(_r(n,"bpmn:Lane")||_r(n,"bpmn:Participant"))&&(t.balanced=!bs(e))})),e.on("resize.end",1001,(function(e){var n=e.context,i=n.shape,r=n.canExecute,o=n.newBounds;if(_r(i,"bpmn:Lane")||_r(i,"bpmn:Participant"))return r&&(o=mn(o),t.resizeLane(i,o,n.balanced)),!1}))}Gd.$inject=["eventBus","modeling"];function Qd(e,t,n,i,r){function o(e){return Er(e,["bpmn:ReceiveTask","bpmn:SendTask"])||function(e,t){c(t)||(t=[t]);return _(t,(function(t){return Wr(e,t)}))}(e,["bpmn:ErrorEventDefinition","bpmn:EscalationEventDefinition","bpmn:MessageEventDefinition","bpmn:SignalEventDefinition"])}function s(t){return!!f(e.getDefinitions().get("rootElements"),M({id:t.id}))}function a(e){return _r(e,"bpmn:ErrorEventDefinition")?"errorRef":_r(e,"bpmn:EscalationEventDefinition")?"escalationRef":_r(e,"bpmn:MessageEventDefinition")?"messageRef":_r(e,"bpmn:SignalEventDefinition")?"signalRef":void 0}function l(e){if(Er(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.get("messageRef");var t=e.get("eventDefinitions")[0];return t.get(a(t))}n.invoke(Fo,this),this.executed(["shape.create","element.updateProperties","element.updateModdleProperties"],(function(t){var n=t.shape||t.element;if(o(n)){var i=l(Or(n));i&&!s(i)&&(Ot(e.getDefinitions().get("rootElements"),i),t.addedRootElement=i)}}),!0),this.reverted(["shape.create","element.updateProperties","element.updateModdleProperties"],(function(t){var n=t.addedRootElement;n&&Et(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=l(Or(n));i&&(t.referencedRootElement=i)}})),t.on("copyPaste.pasteElement",500,(function(e){var t=e.descriptor,n=t.businessObject,o=t.referencedRootElement;o&&(s(o)||(o=i.copyElement(o,r.create(o.$type))),function(e,t){if(Er(e,["bpmn:ReceiveTask","bpmn:SendTask"]))return e.set("messageRef",t);var n=e.get("eventDefinitions")[0];n.set(a(n),t)}(n,o),delete t.referencedRootElement)}))}Qd.$inject=["bpmnjs","eventBus","injector","moddleCopy","bpmnFactory"],e(Qd,Fo);var Xd=Math.max;function Kd(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;_r(e,"bpmn:Participant")&&(r[t]=function(e,t,n){var i=Fr(e);if(r=e,!Cu(r).length)return i?Nd:Bd;var r;var o=function(e){return"x"===e}(t),s={};s=o?i?Nd:{width:Zd(e,n,o),height:Bd.height}:i?{width:Nd.width,height:Yd(e,n,o)}:Bd;return s}(e,n,i)),_r(e,"bpmn:Lane")&&(r[t]=Fr(e)?Rd:Dd),_r(e,"bpmn:SubProcess")&&Vr(e)&&(r[t]=$d),_r(e,"bpmn:TextAnnotation")&&(r[t]=jd),_r(e,"bpmn:Group")&&(r[t]=Td)})),r}))}function Yd(e,t,n){var i;return i=function(e,t,n){var i,r=Cu(e);return i=Jd(r,t,n),e.height-i.height+Rd.height}(e,t,n),Xd(Nd.height,i)}function Zd(e,t,n){var i;return i=function(e,t,n){var i,r=Cu(e);return i=Jd(r,t,n),e.width-i.width+Dd.width}(e,t,n),Xd(Bd.width,i)}function Jd(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=Cu(r)).length?Jd(o,t,n):r}Kd.$inject=["eventBus"];var eh=180,th=160;function nh(e,t,n,i,r,o,s){Fo.call(this,t),this._canvas=e,this._eventBus=t,this._modeling=n,this._elementFactory=i,this._bpmnFactory=r,this._bpmnjs=o,this._elementRegistry=s;var a=this;function l(e){return _r(e,"bpmn:SubProcess")&&!Vr(e)}function c(t){var n=t.shape,i=t.newRootElement,r=Or(n);i=a._addDiagram(i||r),t.newRootElement=e.addRootElement(i)}function p(t){var n=Or(t.shape);a._removeDiagram(n);var i=t.newRootElement=s.get(Zo(n));e.removeRootElement(i)}this.executed("shape.create",(function(e){l(e.shape)&&c(e)}),!0),this.postExecuted("shape.create",(function(e){var t=e.shape,n=e.newRootElement;n&&t.children&&(a._showRecursively(t.children),a._moveChildrenToShape(t,n))}),!0),this.reverted("shape.create",(function(e){l(e.shape)&&p(e)}),!0),this.preExecuted("shape.delete",(function(e){var t=e.shape;if(l(t)){var i=s.get(Zo(t));i&&n.removeElements(i.children.slice())}}),!0),this.executed("shape.delete",(function(e){l(e.shape)&&p(e)}),!0),this.reverted("shape.delete",(function(e){l(e.shape)&&c(e)}),!0),this.preExecuted("shape.replace",(function(t){var n=t.oldShape,i=t.newShape;l(n)&&l(i)&&(t.oldRoot=e.removeRootElement(Zo(n)))}),!0),this.postExecuted("shape.replace",(function(t){var i=t.newShape,r=t.oldRoot,o=e.findRoot(Zo(i));if(r&&o){var s=r.children;n.moveElements(s,{x:0,y:0},o)}}),!0),this.executed("element.updateProperties",(function(e){var t=e.element;if(_r(t,"bpmn:SubProcess")){var n=e.properties,i=e.oldProperties.id,r=n.id;if(i!==r){if(es(t))return s.updateId(t,Jo(r)),void s.updateId(i,r);s.get(Jo(i))&&s.updateId(Jo(i),Jo(r))}}}),!0),this.reverted("element.updateProperties",(function(e){var t=e.element;if(_r(t,"bpmn:SubProcess")){var n=e.properties,i=e.oldProperties.id,r=n.id;if(i!==r){if(es(t))return s.updateId(t,Jo(i)),void s.updateId(r,i);var o=s.get(Jo(r));o&&s.updateId(o,Jo(i))}}}),!0),t.on("element.changed",(function(e){var n=e.element;if(es(n)){var i=n,r=s.get(Yo(i));r&&r!==i&&t.fire("element.changed",{element:r})}})),this.executed("shape.toggleCollapse",400,(function(e){var t=e.shape;_r(t,"bpmn:SubProcess")&&(Vr(t)?p(e):(c(e),a._showRecursively(t.children)))}),!0),this.reverted("shape.toggleCollapse",400,(function(e){var t=e.shape;_r(t,"bpmn:SubProcess")&&(Vr(t)?p(e):(c(e),a._showRecursively(t.children)))}),!0),this.postExecuted("shape.toggleCollapse",600,(function(e){var t=e.shape;if(_r(t,"bpmn:SubProcess")){var n=e.newRootElement;n&&(Vr(t)?a._moveChildrenToShape(n,t):a._moveChildrenToShape(t,n))}}),!0),t.on("copyPaste.createTree",(function(e){var t=e.element,n=e.children;if(l(t)){var i=Zo(t),r=s.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(_r(Pr(r),"bpmndi:BPMNPlane")){var o=Yo(r),s=f(i,(function(e){return e.id===o}));s&&(t.parent=s.id)}})),t.on("copyPaste.pasteElement",(function(e){var t=e.descriptor;t.parent&&(l(t.parent)||t.parent.hidden)&&(t.hidden=!0)}))}function ih(e,t){e.invoke(Fo,this),this.postExecuted("shape.replace",(function(e){var n=e.context.oldShape,i=e.context.newShape;if(_r(i,"bpmn:SubProcess")&&(_r(n,"bpmn:Task")||_r(n,"bpmn:CallActivity"))&&Vr(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 rh(e){Fo.call(this,e),this.preExecute("connection.create",(function(e){const{target:t}=e;_r(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&&_r(t[0],"bpmn:TextAnnotation")&&(e.hints=e.hints||{},e.hints.autoResize=!1)}),!0)}function oh(e,t){Fo.call(this,e),this.postExecuted("shape.toggleCollapse",1500,(function(e){var n=e.shape;if(!Vr(n)){var i=gt(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,bn(n)):t.reconnectStart(e,n,bn(n)))}}),!0)}e(nh,Fo),nh.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 s=yt(o);if(t.x){var a=bn(t),l=bn(s);n={x:a.x-l.x,y:a.y-l.y}}else n={x:eh-s.x,y:th-s.y};i.moveElements(r,n,t,{autoResize:!1})}else i.moveElements(r,{x:0,y:0},t,{autoResize:!1})}},nh.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},nh.prototype._addDiagram=function(e){var t=this._bpmnjs.getDefinitions().diagrams;return e.businessObject||(e=this._createNewDiagram(e)),t.push(e.di.$parent),e},nh.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:Zo(e),type:e.$type,di:i,businessObject:e,collapsed:!0})},nh.prototype._removeDiagram=function(e){var t=this._bpmnjs.getDefinitions().diagrams,n=f(t,(function(t){return t.plane.bpmnElement.id===e.id}));return t.splice(t.indexOf(n),1),n},nh.$inject=["canvas","eventBus","modeling","elementFactory","bpmnFactory","bpmnjs","elementRegistry"],ih.$inject=["injector","modeling"],e(ih,Fo),e(rh,Fo),rh.$inject=["eventBus"],e(oh,Fo),oh.$inject=["eventBus","modeling"];function sh(e,t,n){Fo.call(this,e),this.executed(["shape.toggleCollapse"],500,(function(e){var t,n=e.context.shape;_r(n,"bpmn:SubProcess")&&(n.collapsed?Pr(n).isExpanded=!1:((t=n.children).length&&t.forEach((function(e){"label"!==e.type||e.businessObject.name||(e.hidden=!0)})),Pr(n).isExpanded=!0))})),this.reverted(["shape.toggleCollapse"],500,(function(e){var t=e.context.shape;t.collapsed?Pr(t).isExpanded=!1:Pr(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,s=t;return n=(r=o,r.filter((function(e){return!e.hidden}))).concat([e]),(i=Eu(n))?(s.width=Math.max(i.width,s.width),s.height=Math.max(i.height,s.height),s.x=i.x+(i.width-s.width)/2,s.y=i.y+(i.height-s.height)/2):(s.x=e.x+(e.width-s.width)/2,s.y=e.y+(e.height-s.height)/2),s}(r,o),n.resizeShape(r,i,null,{autoResize:!r.collapsed&&"nwse"})}))}function ah(e,t,n,i){t.invoke(Fo,this),this.preExecute("shape.delete",(function(e){var t=e.context.shape,r=t.businessObject;hn(t)||(_r(t,"bpmn:Participant")&&Vr(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;_r(t,"bpmn:Collaboration")&&n.ids.unclaim(i.id)}))}function lh(e,t){Fo.call(this,e),this.preExecute("connection.delete",(function(e){var n=e.context.connection,i=n.source;(function(e,t){if(!_r(e,"bpmn:SequenceFlow"))return!1;var n=Or(t),i=Or(e);return n.get("default")===i})(n,i)&&t.updateProperties(i,{default:null})}))}e(sh,Fo),sh.$inject=["eventBus","elementFactory","modeling"],e(ah,Fo),ah.$inject=["canvas","injector","moddle","modeling"],e(lh,Fo),lh.$inject=["eventBus","modeling"];function ch(e,t){var n;function i(){if(!n)throw new Error("out of bounds release");return n}Fo.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 ph).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||(_r(t,"bpmn:Lane")&&n.addLane(t),_r(t,"bpmn:FlowNode")&&n.addFlowNode(t))}))}function ph(){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 uh(e,t){Fo.call(this,e),this.postExecuted("elements.create",(function(e){const n=e.context.elements;for(const e of n)dh(e)&&!hh(e)&&t.updateProperties(e,{isForCompensation:void 0})}))}function dh(e){const t=Or(e);return t&&t.isForCompensation}function hh(e){return e.incoming.filter((e=>function(e){return e&&_r(e,"bpmn:BoundaryEvent")&&Wr(e,"bpmn:CompensateEventDefinition")}(e.source))).length>0}ch.$inject=["eventBus","modeling"],e(ch,Fo),e(uh,Fo),uh.$inject=["eventBus","modeling"];var mh={__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",Gp],appendBehavior:["type",Xp],associationBehavior:["type",Kp],attachEventBehavior:["type",Yp],boundaryEventBehavior:["type",Jp],compensateBoundaryEventBehaviour:["type",eu],createBehavior:["type",ru],createDataObjectBehavior:["type",ou],createParticipantBehavior:["type",pu],dataInputAssociationBehavior:["type",du],dataStoreBehavior:["type",fu],deleteLaneBehavior:["type",Tu],detachEventBehavior:["type",Ru],dropOnFlowBehavior:["type",Nu],eventBasedGatewayBehavior:["type",ju],fixHoverBehavior:["type",qu],groupBehavior:["type",zu],importDockingFix:["type",Fu],isHorizontalFix:["type",Uu],labelBehavior:["type",cd],layoutConnectionBehavior:["type",ud],messageFlowBehavior:["type",xd],nonInterruptingBehavior:["type",Od],removeElementBehavior:["type",kd],removeEmbeddedLabelBoundsBehavior:["type",Pd],removeParticipantBehavior:["type",Cd],replaceConnectionBehavior:["type",Ad],replaceElementBehaviour:["type",Md],resizeBehavior:["type",Id],resizeLaneBehavior:["type",Gd],rootElementReferenceBehavior:["type",Qd],spaceToolBehavior:["type",Kd],subProcessPlaneBehavior:["type",nh],subProcessStartEventBehavior:["type",ih],textAnnotationBehavior:["type",rh],toggleCollapseConnectionBehaviour:["type",oh],toggleElementCollapseBehaviour:["type",sh],unclaimIdBehavior:["type",ah],unsetDefaultFlowBehavior:["type",lh],updateFlowNodeRefsBehavior:["type",ch],setCompensationActivityAfterPasteBehavior:["type",uh]};function fh(e,t){var n=xn(e,t,-15);return"intersect"!==n?n:null}function gh(e){Kl.call(this,e)}function yh(e){return!e||hn(e)}function vh(e){do{if(_r(e,"bpmn:Process"))return Or(e);if(_r(e,"bpmn:Participant"))return Or(e).processRef||Or(e)}while(e=e.parent)}function bh(e){return _r(e,"bpmn:TextAnnotation")}function xh(e){return _r(e,"bpmn:Group")&&!e.labelTarget}function wh(e){return _r(e,"bpmn:BoundaryEvent")&&Ph(e,"bpmn:CompensateEventDefinition")}function _h(e){return Or(e).isForCompensation}function Eh(e){for(var t=e;t=t.parent;){if(_r(t,"bpmn:FlowElementsContainer"))return Or(t);if(_r(t,"bpmn:Participant"))return Or(t).processRef}return null}function Oh(e,t){return Eh(e)===Eh(t)}function Ph(e,t){return!!f(Or(e).eventDefinitions||[],(function(e){return _r(e,t)}))}function kh(e,t){return(Or(e).eventDefinitions||[]).every((function(e){return _r(e,t)}))}function Sh(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 Ch(e,t,n){if(yh(e)||yh(t))return null;if(!_r(n,"bpmn:DataAssociation")){if(Vh(e,t))return{type:"bpmn:MessageFlow"};if(Fh(e,t))return{type:"bpmn:SequenceFlow"}}var i=Hh(e,t);return i||(zh(e,t)?{type:"bpmn:Association",associationDirection:"One"}:!!qh(e,t)&&{type:"bpmn:Association",associationDirection:"None"})}function Ah(e,t){return!(!hn(e)&&!xh(e))||!(_r(t,"bpmn:Participant")&&!Vr(t))&&(_r(e,"bpmn:Participant")?_r(t,"bpmn:Process")||_r(t,"bpmn:Collaboration"):Er(e,["bpmn:DataInput","bpmn:DataOutput"])&&e.parent?t===e.parent:_r(e,"bpmn:Lane")?_r(t,"bpmn:Participant")||_r(t,"bpmn:Lane"):!(_r(e,"bpmn:BoundaryEvent")&&!function(e){return Or(e).cancelActivity&&(Rh(e)||Dh(e))}(e))&&(_r(e,"bpmn:FlowElement")&&!_r(e,"bpmn:DataStoreReference")?_r(t,"bpmn:FlowElementsContainer")?Vr(t):Er(t,["bpmn:Participant","bpmn:Lane"]):_r(e,"bpmn:DataStoreReference")&&_r(t,"bpmn:Collaboration")?_(Or(t).get("participants"),(function(e){return!!e.get("processRef")})):Er(e,["bpmn:Artifact","bpmn:DataAssociation","bpmn:DataStoreReference"])?Er(t,["bpmn:Collaboration","bpmn:Lane","bpmn:Participant","bpmn:Process","bpmn:SubProcess"]):!!_r(e,"bpmn:MessageFlow")&&(_r(t,"bpmn:Collaboration")||e.source.parent==t||e.target.parent==t)))}function Mh(e){return _r(e,"bpmn:Lane")}function Th(e){return!!function(e){return!hn(e)&&_r(e,"bpmn:BoundaryEvent")}(e)||(!(!_r(e,"bpmn:IntermediateThrowEvent")||!Rh(e))||_r(e,"bpmn:IntermediateCatchEvent")&&Dh(e))}function Rh(e){var t=Or(e);return t&&!(t.eventDefinitions&&t.eventDefinitions.length)}function Dh(e){return Nh(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])}function Nh(e,t){return t.some((function(t){return Ph(e,t)}))}function Bh(e,t,n,i){if(Array.isArray(e)||(e=[e]),1!==e.length)return!1;var r=e[0];return!hn(r)&&(!!Th(r)&&(!Ur(t)&&(!(!_r(t,"bpmn:Activity")||_h(t))&&(!(i&&!fh(i,t))&&(!function(e){return _r(e,"bpmn:ReceiveTask")&&f(e.incoming,(function(e){return _r(e.source,"bpmn:EventBasedGateway")}))}(t)&&"attach")))))}function $h(e,t,n){if(!t)return!1;var i={replacements:[]};return v(e,(function(e){Ur(t)||_r(e,"bpmn:StartEvent")&&"label"!==e.type&&Ah(e,t)&&(Hr(e)||i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),(function(e){return Wr(e,"bpmn:ErrorEventDefinition")}(e)||function(e){return Wr(e,"bpmn:EscalationEventDefinition")}(e)||function(e){return Wr(e,"bpmn:CompensateEventDefinition")}(e))&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"}),Nh(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])&&_r(t,"bpmn:SubProcess")&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:StartEvent"})),_r(t,"bpmn:Transaction")||Ph(e,"bpmn:CancelEventDefinition")&&"label"!==e.type&&(_r(e,"bpmn:EndEvent")&&Ah(e,t)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:EndEvent"}),_r(e,"bpmn:BoundaryEvent")&&Bh(e,t,0,n)&&i.replacements.push({oldElementId:e.id,newElementType:"bpmn:BoundaryEvent"}))})),!!i.replacements.length&&i}function jh(e,t){return!_(e,Mh)&&(!t||e.every((function(e){return Ah(e,t)})))}function Ih(e,t,n,i){return!!t&&(!(!hn(e)&&!xh(e))||!function(e,t){return e===t}(n,t)&&((!n||!Sh(n,t))&&(Ah(e,t)||Uh(e,t))))}function Lh(e,t){return _r(e,"bpmn:SubProcess")?Vr(e)&&(!t||t.width>=100&&t.height>=80):!!_r(e,"bpmn:Lane")||(!!_r(e,"bpmn:Participant")||(!!bh(e)||!!xh(e)))}function qh(e,t){return!Sh(t,e)&&!Sh(e,t)&&(!!function(e,t){var n=bh(e),i=bh(t);return(n||i)&&n!==i}(e,t)||!!Hh(e,t))}function zh(e,t){return Oh(e,t)&&wh(e)&&_r(t,"bpmn:Activity")&&(n=e,!t.attachers.includes(n))&&!Ur(t);var n}function Vh(e,t){return!(Gh(e)&&!Gh(t))&&(_r(n=e,"bpmn:InteractionNode")&&!_r(n,"bpmn:BoundaryEvent")&&(!_r(n,"bpmn:Event")||_r(n,"bpmn:ThrowEvent")&&kh(n,"bpmn:MessageEventDefinition"))&&function(e){return _r(e,"bpmn:InteractionNode")&&!_h(e)&&(!_r(e,"bpmn:Event")||_r(e,"bpmn:CatchEvent")&&kh(e,"bpmn:MessageEventDefinition"))&&!(_r(e,"bpmn:BoundaryEvent")&&!Ph(e,"bpmn:MessageEventDefinition"))}(t)&&!function(e,t){return vh(e)===vh(t)}(e,t));var n}function Fh(e,t){return _r(n=e,"bpmn:FlowNode")&&!_r(n,"bpmn:EndEvent")&&!Ur(n)&&!(_r(n,"bpmn:IntermediateThrowEvent")&&Ph(n,"bpmn:LinkEventDefinition"))&&!wh(n)&&!_h(n)&&function(e){return _r(e,"bpmn:FlowNode")&&!_r(e,"bpmn:StartEvent")&&!_r(e,"bpmn:BoundaryEvent")&&!Ur(e)&&!(_r(e,"bpmn:IntermediateCatchEvent")&&Ph(e,"bpmn:LinkEventDefinition"))&&!_h(e)}(t)&&Oh(e,t)&&!(_r(e,"bpmn:EventBasedGateway")&&!function(e){return _r(e,"bpmn:ReceiveTask")||_r(e,"bpmn:IntermediateCatchEvent")&&(Ph(e,"bpmn:MessageEventDefinition")||Ph(e,"bpmn:TimerEventDefinition")||Ph(e,"bpmn:ConditionalEventDefinition")||Ph(e,"bpmn:SignalEventDefinition"))}(t));var n}function Hh(e,t){return Er(e,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&Er(t,["bpmn:Activity","bpmn:ThrowEvent"])?{type:"bpmn:DataInputAssociation"}:!(!Er(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])||!Er(e,["bpmn:Activity","bpmn:CatchEvent"]))&&{type:"bpmn:DataOutputAssociation"}}function Uh(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&&(Er(t,["bpmn:SequenceFlow","bpmn:MessageFlow"])&&!hn(t)&&_r(e,"bpmn:FlowNode")&&!_r(e,"bpmn:BoundaryEvent")&&Ah(e,t.parent))}function Wh(e,t){return!!hn(t)||!(_r(t,"bpmn:Lane")&&!function(e,t){return e&&t&&-1!==e.indexOf(t)}(e,t.parent))}function Gh(e){return pc(e,"bpmn:Process")||pc(e,"bpmn:Collaboration")}e(gh,Kl),gh.$inject=["eventBus"],gh.prototype.init=function(){this.addRule("connection.start",(function(e){return function(e){if(yh(e))return null;return Er(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 Ch(t,n)}finally{r&&(n.parent=null)}})),this.addRule("connection.reconnect",(function(e){var t=e.connection;return Ch(e.source,e.target,t)})),this.addRule("connection.updateWaypoints",(function(e){return{type:e.connection.type}})),this.addRule("shape.resize",(function(e){return Lh(e.shape,e.newBounds)})),this.addRule("elements.create",(function(e){var t=e.elements,n=e.position,i=e.target;return!(dn(i)&&!Uh(t,i))&&w(t,(function(e){return dn(e)?Ch(e.source,e.target,e):e.host?Bh(e,e.host,null,n):Ih(e,i,null)}))})),this.addRule("elements.move",(function(e){var t=e.target,n=e.shapes,i=e.position;return Bh(n,t,null,i)||$h(n,t,i)||jh(n,t)||Uh(n,t)})),this.addRule("shape.create",(function(e){return Ih(e.shape,e.target,e.source,e.position)})),this.addRule("shape.attach",(function(e){return Bh(e.shape,e.target,null,e.position)})),this.addRule("element.copy",(function(e){var t=e.element;return Wh(e.elements,t)}))},gh.prototype.canConnectMessageFlow=Vh,gh.prototype.canConnectSequenceFlow=Fh,gh.prototype.canConnectDataAssociation=Hh,gh.prototype.canConnectAssociation=qh,gh.prototype.canConnectCompensationAssociation=zh,gh.prototype.canMove=jh,gh.prototype.canAttach=Bh,gh.prototype.canReplace=$h,gh.prototype.canDrop=Ah,gh.prototype.canInsert=Uh,gh.prototype.canCreate=Ih,gh.prototype.canConnect=Ch,gh.prototype.canResize=Lh,gh.prototype.canCopy=Wh;var Qh={__depends__:[Rc],__init__:["bpmnRules"],bpmnRules:["type",gh]};function Xh(e,t){e.on("saveXML.start",2e3,(function(){v(t.getRootElements(),(function(e){var t,n=Pr(e);t=E(y(gt([e],!1),(function(t){return t!==e&&!t.labelTarget})),Pr),n.set("planeElement",t)}))}))}Xh.$inject=["eventBus","canvas"];var Kh={__init__:["bpmnDiOrdering"],bpmnDiOrdering:["type",Xh]};function Yh(e){Fo.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 Zh(e,t){Yh.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=f(n,(function(t){return Er(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||_r(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&&!Er(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),s=g(n.children,(function(t){return!(!e.labelTarget&&t.labelTarget)&&r.level<i(t).level}));return-1!==s&&-1!==o&&o<s&&(s-=1),{index:s,parent:n}}}Yh.prototype.getOrdering=function(e,t){return null},e(Yh,Fo),Zh.$inject=["eventBus","canvas"],e(Zh,Yh);var Jh={__init__:["bpmnOrderingProvider"],bpmnOrderingProvider:["type",Zh]};function em(){}em.prototype.get=function(){return this._data},em.prototype.set=function(e){this._data=e},em.prototype.clear=function(){var e=this._data;return delete this._data,e},em.prototype.isEmpty=function(){return!this._data};var tm={clipboard:["type",em]},nm="drop-ok",im="drop-not-ok",rm="attach-ok",om="new-parent",sm="create";function am(e,t,n,i,r){function o(t,n){[rm,nm,im,om].forEach((function(i){i===n?e.addMarker(t,i):e.removeMarker(t,i)}))}function s(){var e=t.context();e&&e.prefix===sm&&t.cancel()}n.on(["create.move","create.hover"],(function(e){var t=e.context,n=t.elements,i=e.hover,s=t.source,a=t.hints||{};if(!i)return t.canExecute=!1,void(t.target=null);lm(e);var l={x:e.x,y:e.y},c=t.canExecute=i&&function(e,t,n,i,o){if(!t)return!1;var s=f(e=y(e,(function(t){var n=t.labelTarget;return!(t.parent||hn(t)&&-1!==e.indexOf(n))})),(function(e){return!dn(e)})),a=!1,l=!1,c=!1;cm(e)&&(a=r.allowed("shape.attach",{position:n,shape:s,target:t})),a||(c=cm(e)?r.allowed("shape.create",{position:n,shape:s,source:i,target:t}):r.allowed("elements.create",{elements:e,position:n,target:t}));var p=o.connectionTarget;return c||a?(s&&i&&(l=r.allowed("connection.create",{source:p===i?s:i,target:p===i?i:s,hints:{targetParent:t,targetAttach:a}})),{attach:a,connect:l}):(null===c||null===a)&&null}(n,i,l,s,a);i&&null!==c&&(t.target=i,c&&c.attach?o(i,rm):o(i,c?om:im))})),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,s=t.target,a=t.canExecute,l=a&&a.attach,c=a&&a.connect,p=t.hints||{};if(!1===a||!s)return!1;lm(e);var u={x:e.x,y:e.y};r=c?i.appendShape(n,r,u,s,{attach:l,connection:!0===c?{}:c,connectionTarget:p.connectionTarget}):f(o=i.createElements(o,u,s,j({},p,{attach:l})),(function(e){return!dn(e)})),j(t,{elements:o,shape:r}),j(e,{elements:o,shape:r})})),n.on("create.init",(function(){n.on("elements.changed",s),n.once(["create.cancel","create.end"],2e3,(function(){n.off("elements.changed",s)}))})),this.start=function(e,n,i){c(n)||(n=[n]);var r=f(n,(function(e){return!dn(e)}));if(r){i=j({elements:n,hints:{},shape:r},i||{}),v(n,(function(e){u(e.x)||(e.x=0),u(e.y)||(e.y=0)}));var o=yt(y(n,(function(e){return!e.hidden})));v(n,(function(e){dn(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}}))),j(e,{x:e.x-o.x-o.width/2,y:e.y-o.y-o.height/2})})),t.init(e,sm,{cursor:"grabbing",autoActivate:!0,data:{shape:r,elements:n,context:i}})}}}function lm(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 cm(e){return e&&1===e.length&&!dn(e[0])}am.$inject=["canvas","dragging","eventBus","modeling","rules"];function pm(e,t,n,i,r){t.on("create.move",750,(function(t){var o=t.hover,s=t.context,a=s.elements,l=s.dragGroup;l||(l=s.dragGroup=function(e){var t=De("g");Oe(t,r.cls("djs-drag-group",["no-events"]));var o=De("g");return e.forEach((function(e){var r;e.hidden||(e.waypoints?(r=n._createContainer("connection",o),n.drawConnection(Qn(r),e)):(r=n._createContainer("shape",o),n.drawShape(Qn(r),e),Kn(r,e.x,e.y)),i.addDragger(e,t,r))})),t}(a)),o?(l.parentNode||xe(e.getActiveLayer(),l),Kn(l,t.x,t.y)):He(l)})),t.on("create.cleanup",(function(e){var t=e.context.dragGroup;t&&He(t)}))}pm.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];var um={__depends__:[Sc,zp,Rc,Ts],__init__:["create","createPreview"],create:["type",am],createPreview:["type",pm]};function dm(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)}))}dm.$inject=["eventBus"],dm.prototype.getLastMoveEvent=function(){return this._lastMoveEvent||function(e,t){var n=document.createEvent("MouseEvent"),i=e,r=t,o=e,s=t;n.initMouseEvent&&n.initMouseEvent("mousemove",!0,!0,window,0,i,r,o,s,!1,!1,!1,!1,0,null);return n}(0,0)};var hm={__init__:["mouse"],mouse:["type",dm]};function mm(e,t,n,i,r,o,s,a){this._canvas=e,this._create=t,this._clipboard=n,this._elementFactory=i,this._eventBus=r,this._modeling=o,this._mouse=s,this._rules=a,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=f(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),dn(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=fm(e)).original&&(e.original=fm(e.original)),e}))}(n)),hn(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){j(e.hints,{createElementsBehavior:!1})}))}function fm(e){return j({},e)}function gm(e,t){var n=t.indexOf(e);return-1===n?t:t.splice(n,1)}mm.$inject=["canvas","create","clipboard","elementFactory","eventBus","modeling","mouse","rules"],mm.prototype.copy=function(e){var t,n;return c(e)||(e=e?[e]:[]),n=!1===(t=this._eventBus.fire("copyPaste.canCopyElements",{elements:e}))?{}:this.createTree(c(t)?t:e),this._clipboard.set(n),this._eventBus.fire("copyPaste.elementsCopied",{elements:e,tree:n}),n},mm.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||{}})}},mm.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=yt(e);return v(e,(function(e){dn(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}}))),j(e,{x:e.x-r.x-r.width/2,y:e.y-r.y-r.height/2})})),this._modeling.createElements(e,n,t,j({},i))},mm.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,s=j({},q(e,["priority"]));return i[e.parent]?s.parent=i[e.parent]:delete s.parent,n.fire("copyPaste.pasteElement",{cache:i,descriptor:s}),dn(s)?(s.source=i[e.source],s.target=i[e.target],o=i[e.id]=t.createConnection(s),void r.push(o)):hn(s)?(s.labelTarget=i[s.labelTarget],o=i[e.id]=t.createLabel(s),void r.push(o)):(s.host&&(s.host=i[s.host]),o=i[e.id]=t.createShape(s),void r.push(o))}))})),r},mm.prototype.createConnection=function(e){return this._elementFactory.createConnection(q(e,["id"]))},mm.prototype.createLabel=function(e){return this._elementFactory.createLabel(q(e,["id"]))},mm.prototype.createShape=function(e){return this._elementFactory.createShape(q(e,["id"]))},mm.prototype.hasRelations=function(e,t){var n,i;return!(dn(e)&&(n=f(t,M({id:e.source.id})),i=f(t,M({id:e.target.id})),!n||!i))&&!(hn(e)&&!f(t,M({id:e.labelTarget.id})))},mm.prototype.createTree=function(e){var t=this._rules,n=this,i={},r=[];function o(e,t){var n=f(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 ft(dt(e),(function(e,t,i){if(!hn(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)?gm(r.element,e):(i[o]||(i[o]=[]),i[o].push(r.descriptor)):gm(r.element,e)})),i};var ym={__depends__:[tm,um,hm,Rc],__init__:["copyPaste"],copyPaste:["type",mm]};function vm(e,t,n){c(n)||(n=[n]),v(n,(function(n){s(e[n])||(t[n]=e[n])}))}function bm(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=Or(n);if(hn(n))return t;var o=t.businessObject=i(r,!0),s=t.di=i(Pr(n),!0);s.bpmnElement=o,vm(o,t,"name"),vm(s,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(hn(n))return n.businessObject=Or(t[n.labelTarget]),void(n.di=Pr(t[n.labelTarget]));r=n.businessObject=i(r),(o=n.di=i(o)).bpmnElement=r,vm(n,r,["isExpanded","name"]),n.type=r.$type})),t.on("copyPaste.copyElement",750,(function(e){var t=e.descriptor,n=e.element;if(_r(n,"bpmn:Participant")){var r=Or(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=Or(e);return e.default&&(n[e.default]={element:i,property:"default"}),e.host&&(Or(e).attachedToRef=Or(t[e.host])),q(n,x(n,(function(t,n,r){var o=n.element,s=n.property;return r===e.id&&(o.set(s,i),t.push(e.id)),t}),[]))}(e.descriptor,t,function(e){return e[r]=e[r]||{}}(t)))}))}bm.$inject=["bpmnFactory","eventBus","moddleCopy"];var xm=["artifacts","dataInputAssociations","dataOutputAssociations","default","flowElements","lanes","incoming","outgoing","categoryValue"];function wm(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=p(t)&&t.$descriptor,i=e.propertyName;return(!i||-1===xm.indexOf(i))&&(!(i&&n&&!f(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)&&d(t.$instanceOf)&&t.$instanceOf(n)&&(!i.values||!i.values.length))return!1}))}function _m(e,t){return x(e.properties,(function(e,n){return t&&n.default?e:e.concat(n.name)}),[])}wm.$inject=["eventBus","bpmnFactory","moddle"],wm.prototype.copyElement=function(e,t,n,i=!1){var r=this;n&&!c(n)&&(n=[n]),n=n||_m(e.$descriptor);var o=this._eventBus.fire("moddleCopy.canCopyProperties",{propertyNames:n,sourceElement:e,targetElement:t,clone:i});return!1===o||(c(o)&&(n=o),v(n,(function(n){var o;m(e,n)&&(o=e.get(n));var s=r.copyProperty(o,t,n,i);a(s)&&(!1!==r._eventBus.fire("moddleCopy.canSetCopiedProperty",{parent:t,property:s,propertyName:n})&&t.set(n,s))}))),t},wm.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 p(o)&&o.$type&&!o.$parent&&(o.$parent=t),o;var s=this._moddle.getPropertyDescriptor(t,n);if(!s.isReference){if(s.isId)return e&&this._copyId(e,t,i);if(c(e))return x(e,(function(e,s){return(o=r.copyProperty(s,t,n,i))?e.concat(o):e}),[]);if(p(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}}},wm.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 Em={__depends__:[ym],__init__:["bpmnCopyPaste","moddleCopy"],bpmnCopyPaste:["type",bm],moddleCopy:["type",wm]},Om=Math.round;function Pm(e,t){this._modeling=e,this._eventBus=t}function km(e,t){t.on("replace.end",500,(function(t){const{newElement:n,hints:i={}}=t;!1!==i.select&&e.select(n)}))}Pm.$inject=["modeling","eventBus"],Pm.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,s=t.height||e.height,a=t.x||e.x,l=t.y||e.y,c=Om(a+o/2),p=Om(l+s/2),u=i.replaceShape(e,j({},t,{x:c,y:p,width:o,height:s}),n);return r.fire("replace.end",{element:e,newElement:u,hints:n}),u},km.$inject=["selection","eventBus"];var Sm={__init__:["replace","replaceSelectionBehavior"],replaceSelectionBehavior:["type",km],replace:["type",Pm]};var Cm=["cancelActivity","instantiate","eventGatewayType","triggeredByEvent","isInterrupting"];function Am(e,t,n,i,r,o){this.replaceElement=function(a,l,p){p=p||{};var u=l.type,d=a.businessObject;if(Mm(d)&&"bpmn:SubProcess"===u&&function(e,t){var n=e&&m(e,"collapsed")?e.collapsed:!Vr(e);return n!==(t&&(m(t,"collapsed")||m(t,"isExpanded"))?m(t,"collapsed")?t.collapsed:!t.isExpanded:n)}(a,l))return i.toggleCollapse(a),a;var h=e.create(u),f={type:u,businessObject:h,di:{}};"bpmn:ExclusiveGateway"===u&&(f.di.isMarkerVisible=!0),function(e,t,n){c(n)||(n=[n]),v(n,(function(n){s(e[n])||(t[n]=e[n])}))}(a.di,f.di,["fill","stroke","background-color","border-color","color"]);var g=function(e,t){return e.filter((function(e){return t.includes(e)}))}(_m(d.$descriptor),_m(h.$descriptor,!0));j(h,L(l,Cm));var b=y(g,(function(e){return"eventDefinitions"===e?Tm(a,l.eventDefinitionType):"loopCharacteristics"===e?!Ur(h):!m(h,e)&&(("processRef"!==e||!1!==l.isExpanded)&&("triggeredByEvent"!==e&&("isForCompensation"!==e||!Ur(h))))}));if(h=n.copyElement(d,h,b),l.eventDefinitionType&&(Tm(h,l.eventDefinitionType)||(f.eventDefinitionType=l.eventDefinitionType,f.eventDefinitionAttrs=l.eventDefinitionAttrs)),_r(d,"bpmn:Activity")){if(Mm(d))f.isExpanded=Vr(a);else if(l&&m(l,"isExpanded")){f.isExpanded=l.isExpanded;var x=t.getDefaultSize(h,{isExpanded:f.isExpanded});f.width=x.width,f.height=x.height,f.x=a.x-(f.width-a.width)/2,f.y=a.y-(f.height-a.height)/2}Vr(a)&&!_r(d,"bpmn:Task")&&f.isExpanded&&(f.width=a.width,f.height=a.height)}if(Mm(d)&&!Mm(h)&&(p.moveChildren=!1),_r(d,"bpmn:Participant")){!0===l.isExpanded?h.processRef=e.create("bpmn:Process"):p.moveChildren=!1;var w=Fr(a);Pr(a).isHorizontal||(Pr(f).isHorizontal=w),f.width=w?a.width:t.getDefaultSize(f).width,f.height=w?t.getDefaultSize(f).height:a.height}return o.allowed("shape.resize",{shape:h})||(f.height=t.getDefaultSize(f).height,f.width=t.getDefaultSize(f).width),h.name=d.name,Er(d,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&Er(h,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&(h.default=d.default),l.host&&!_r(d,"bpmn:BoundaryEvent")&&_r(h,"bpmn:BoundaryEvent")&&(f.host=l.host),"bpmn:DataStoreReference"!==f.type&&"bpmn:DataObjectReference"!==f.type||(f.x=a.x+(a.width-f.width)/2),r.replaceElement(a,f,{...p,targetElement:l})}}function Mm(e){return _r(e,"bpmn:SubProcess")}function Tm(e,t){var n=Or(e);return t&&n.get("eventDefinitions").some((function(e){return _r(e,t)}))}Am.$inject=["bpmnFactory","elementFactory","moddleCopy","modeling","replace","rules"];var Rm={__depends__:[Em,Sm,Ts],bpmnReplace:["type",Am]};function Dm(e){this._eventBus=e,this._tools=[],this._active=null}Dm.$inject=["eventBus"],Dm.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)},Dm.prototype.isActive=function(e){return e&&this._active===e},Dm.prototype.length=function(e){return this._tools.length},Dm.prototype.setActive=function(e){var t=this._eventBus;this._active!==e&&(this._active=e,t.fire("tool-manager.update",{tool:e}))},Dm.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&&ee(t,'.group[data-group="tools"]')}(e)||this.setActive(null))}),this)};var Nm={__depends__:[Sc],__init__:["toolManager"],toolManager:["type",Dm]};function Bm(e,t){return-1!==e.indexOf(t)}var $m=Math.abs,jm=Math.round,Im={x:"width",y:"height"},Lm="crosshair",qm={n:"top",w:"left",s:"bottom",e:"right"},zm=1500,Vm={n:"s",w:"e",s:"n",e:"w"},Fm=20;function Hm(e,t,n,i,r,o,s){this._canvas=e,this._dragging=t,this._eventBus=n,this._modeling=i,this._rules=r,this._toolManager=o,this._mouse=s;var a=this;o.registerTool("space",{tool:"spaceTool.selection",dragging:"spaceTool"}),n.on("spaceTool.selection.end",(function(e){n.once("spaceTool.selection.ended",(function(){a.activateMakeSpace(e.originalEvent)}))})),n.on("spaceTool.move",zm,(function(e){var t=e.context,n=t.initialized;n||(n=t.initialized=a.init(e,t)),n&&Wm(e)})),n.on("spaceTool.end",(function(e){var t=e.context,i=t.axis,r=t.direction,o=t.movingShapes,s=t.resizingShapes,l=t.start;if(t.initialized){Wm(e);var c={x:0,y:0};c[i]=jm(e["d"+i]),a.makeSpace(o,s,c,r,l),n.once("spaceTool.ended",(function(e){a.activateSelection(e.originalEvent,!0,!0)}))}}))}function Um(e){return{top:e.top-Fm,right:e.right+Fm,bottom:e.bottom+Fm,left:e.left-Fm}}function Wm(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 Gm(e,t){return-1!==e.indexOf(t)}Hm.$inject=["canvas","dragging","eventBus","modeling","rules","toolManager","mouse"],Hm.prototype.activateSelection=function(e,t,n){this._dragging.init(e,"spaceTool.selection",{autoActivate:t,cursor:Lm,data:{context:{reactivate:n}},trapClick:!1})},Hm.prototype.activateMakeSpace=function(e){this._dragging.init(e,"spaceTool",{autoActivate:!0,cursor:Lm,data:{context:{}}})},Hm.prototype.makeSpace=function(e,t,n,i,r){return this._modeling.createSpace(e,t,n,i,r)},Hm.prototype.init=function(e,t){var n=$m(e.dx)>$m(e.dy)?"x":"y",i=e["d"+n],r=e[n]-i;if($m(i)<5)return!1;i<0&&(i*=-1),bs(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),s=this._canvas.getRootElement();!xs(e)&&e.hover&&(s=e.hover);var a=[...gt(s,!0),...s.attachers||[]],l=this.calculateAdjustments(a,n,i,r),c=function(e,t,n,i,r){var o=e.movingShapes,s=e.resizingShapes;if(!s.length)return;var a,l,c={};return v(s,(function(e){var p,d,h,m,f,g,v=e.attachers,b=e.children,x=gn(e),w=y(b,(function(e){return!(dn(e)||hn(e)||Gm(o,e)||Gm(s,e))})),_=y(b,(function(e){return!dn(e)&&!hn(e)&&Gm(o,e)})),E=[],O=[];w.length&&(d=Um(gn(yt(w))),p=i-x[qm[n]]+d[qm[n]],"n"===n?c.bottom=l=u(l)?Math.min(l,p):p:"w"===n?c.right=l=u(l)?Math.min(l,p):p:"s"===n?c.top=a=u(a)?Math.max(a,p):p:"e"===n&&(c.left=a=u(a)?Math.max(a,p):p)),_.length&&(h=Um(gn(yt(_))),p=i-h[qm[Vm[n]]]+x[qm[Vm[n]]],"n"===n?c.bottom=l=u(l)?Math.min(l,p):p:"w"===n?c.right=l=u(l)?Math.min(l,p):p:"s"===n?c.top=a=u(a)?Math.max(a,p):p:"e"===n&&(c.left=a=u(a)?Math.max(a,p):p)),v&&v.length&&(v.forEach((function(e){Gm(o,e)?E.push(e):O.push(e)})),E.length&&(m=gn(yt(E.map(bn))),f=x[qm[Vm[n]]]-(m[qm[Vm[n]]]-i)),O.length&&(g=gn(yt(O.map(bn)))[qm[n]]-(x[qm[n]]-i)),"n"===n?(p=Math.min(f||1/0,g||1/0),c.bottom=l=u(l)?Math.min(l,p):p):"w"===n?(p=Math.min(f||1/0,g||1/0),c.right=l=u(l)?Math.min(l,p):p):"s"===n?(p=Math.max(f||-1/0,g||-1/0),c.top=a=u(a)?Math.max(a,p):p):"e"===n&&(p=Math.max(f||-1/0,g||-1/0),c.left=a=u(a)?Math.max(a,p):p));var P=r&&r[e.id];P&&("n"===n?(p=i+e[Im[t]]-P[Im[t]],c.bottom=l=u(l)?Math.min(l,p):p):"w"===n?(p=i+e[Im[t]]-P[Im[t]],c.right=l=u(l)?Math.min(l,p):p):"s"===n?(p=i-e[Im[t]]+P[Im[t]],c.top=a=u(a)?Math.max(a,p):p):"e"===n&&(p=i-e[Im[t]]+P[Im[t]],c.left=a=u(a)?Math.max(a,p):p))})),c}(l,n,o,r,this._eventBus.fire("spaceTool.getMinDimensions",{axis:n,direction:o,shapes:l.resizingShapes,start:r}));return j(t,l,{axis:n,direction:o,spaceToolConstraints:c,start:r}),Zs("resize-"+("x"===n?"ew":"ns")),!0},Hm.prototype.calculateAdjustments=function(e,t,n,i){var r=this._rules,o=[],s=[],a=[],l=[];function c(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&&!hn(e))if(dn(e))l.push(e);else{var o=e[t],p=o+e[Im[t]];if(function(e){return!!e.host}(e)&&(n>0&&bn(e)[t]>i||n<0&&bn(e)[t]<i))a.push(e);else{var u;if(!(n>0&&o>i||n<0&&p<i))return o<i&&p>i&&r.allowed("shape.resize",{shape:e})?(u=e,void(s.includes(u)||s.push(u))):void 0;c(e)}}})),v(o,(function(e){var t=e.attachers;t&&v(t,(function(e){c(e)}))}));var p=o.concat(s);return v(a,(function(e){var t=e.host;Gm(p,t)&&c(e)})),p=o.concat(s),v(l,(function(e){var t=e.source,n=e.target,i=e.label;Gm(p,t)&&Gm(p,n)&&i&&c(i)})),{movingShapes:o,resizingShapes:s}},Hm.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},Hm.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^spaceTool/.test(e.prefix)};var Qm="djs-dragging",Xm="djs-resizing",Km=Math.max;function Ym(e,t,n,i,r){function o(e,t){v(e,(function(e){r.addDragger(e,t),n.addMarker(e,Qm)}))}e.on("spaceTool.selection.start",(function(e){var t=n.getLayer("space"),r=e.context,o="M 0,-10000 L 0,10000",s="M -10000,0 L 10000,0",a=De("g");Oe(a,i.cls("djs-crosshair-group",["no-events"])),xe(t,a);var l=De("path");Oe(l,"d",o),ke(l).add("djs-crosshair"),xe(a,l);var c=De("path");Oe(c,"d",s),ke(c).add("djs-crosshair"),xe(a,c),r.crosshairGroup=a})),e.on("spaceTool.selection.move",(function(e){Kn(e.context.crosshairGroup,e.x,e.y)})),e.on("spaceTool.selection.cleanup",(function(e){var t=e.context.crosshairGroup;t&&He(t)})),e.on("spaceTool.move",250,(function(e){var s=e.context,a=s.line,l=s.axis,c=s.movingShapes,p=s.resizingShapes;if(s.initialized){if(!s.dragGroup){var u=n.getLayer("space");Oe(a=De("path"),"d","M0,0 L0,0"),ke(a).add("djs-crosshair"),xe(u,a),s.line=a;var d=De("g");Oe(d,i.cls("djs-drag-group",["no-events"])),xe(n.getActiveLayer(),d),o(c,d),o(s.movingConnections=t.filter((function(e){var t=!1;v(c,(function(n){v(n.outgoing,(function(n){e===n&&(t=!0)}))}));var n=!1;v(c,(function(t){v(t.incoming,(function(t){e===t&&(n=!0)}))}));var i=!1;v(p,(function(t){v(t.outgoing,(function(t){e===t&&(i=!0)}))}));var r=!1;return v(p,(function(t){v(t.incoming,(function(t){e===t&&(r=!0)}))})),dn(e)&&(t||i)&&(n||r)})),d),s.dragGroup=d}if(!s.frameGroup){var h=De("g");Oe(h,i.cls("djs-frame-group",["no-events"])),xe(n.getActiveLayer(),h);var m=[];v(p,(function(e){var t=r.addFrame(e,h),i=t.getBBox();m.push({element:t,initialBounds:i}),n.addMarker(e,Xm)})),s.frameGroup=h,s.frames=m}Oe(a,{d:{x:"M"+e.x+", -10000 L"+e.x+", 10000",y:"M -10000, "+e.y+" L 10000, "+e.y}[l]});var f={x:e.dx,y:e.dy};f[{x:"y",y:"x"}[s.axis]]=0,Kn(s.dragGroup,f.x,f.y),v(s.frames,(function(e){var t,n,i=e.element,r=e.initialBounds;"e"===s.direction?Oe(i,{width:Km(r.width+f.x,5)}):Oe(i,{width:t=Km(r.width-f.x,5),x:r.x+r.width-t}),"s"===s.direction?Oe(i,{height:Km(r.height+f.y,5)}):Oe(i,{height:n=Km(r.height-f.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,s=t.line,a=t.dragGroup,l=t.frameGroup;v(i,(function(e){n.removeMarker(e,Qm)})),v(r,(function(e){n.removeMarker(e,Qm)})),a&&(He(s),He(a)),v(o,(function(e){n.removeMarker(e,Xm)})),l&&He(l)}))}Ym.$inject=["eventBus","elementRegistry","canvas","styles","previewSupport"];var Zm={__init__:["spaceToolPreview"],__depends__:[Sc,Rc,Nm,zp,hm],spaceTool:["type",Hm],spaceToolPreview:["type",Ym]};function Jm(e){e.invoke(Hm,this)}Jm.$inject=["injector"],e(Jm,Hm),Jm.prototype.calculateAdjustments=function(e,t,n,i){var r=Hm.prototype.calculateAdjustments.call(this,e,t,n,i);return r.resizingShapes=r.resizingShapes.filter((function(e){return!_r(e,"bpmn:TextAnnotation")&&(!function(e){return _r(e,"bpmn:Participant")&&!Or(e).processRef}(e)||!("y"===t&&Fr(e)||"x"===t&&!Fr(e)))})),r};var ef={__depends__:[Zm],spaceTool:["type",Jm]};function tf(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)}tf.$inject=["eventBus","injector"],tf.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()},tf.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},tf.prototype.clear=function(e){this._stack.length=0,this._stackIdx=-1,!1!==e&&this._fire("changed",{trigger:"clear"})},tf.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()}},tf.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()}},tf.prototype.register=function(e,t){this._setHandler(e,t)},tf.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)},tf.prototype.canUndo=function(){return!!this._getUndoAction()},tf.prototype.canRedo=function(){return!!this._getRedoAction()},tf.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]},tf.prototype._getUndoAction=function(){return this._stack[this._stackIdx]},tf.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)}))},tf.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},tf.prototype._createId=function(){return this._uid++},tf.prototype._atomicDo=function(e){const t=this._currentExecution;t.atomic=!0;try{e()}finally{t.atomic=!1}},tf.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()},tf.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)},tf.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:S("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:t}),e.trigger=null)},tf.prototype._markDirty=function(e){const t=this._currentExecution;e&&(e=c(e)?e:[e],t.dirty=t.dirty.concat(e))},tf.prototype._executedAction=function(e,t){const n=++this._stackIdx;t||this._stack.splice(n,this._stack.length,e)},tf.prototype._revertedAction=function(e){this._stackIdx--},tf.prototype._getHandler=function(e){return this._handlerMap[e]},tf.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 nf={commandStack:["type",tf]};function rf(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 of(e,t,n){Fo.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=sf(n),t.validatedShapes=sf(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;rf((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=Pt(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&&(Ot(i.labels,n,r),n.labelTarget=i)}))}function sf(e){return y(e,(function(t){return-1===e.indexOf(t.labelTarget)}))}e(of,Fo),of.$inject=["injector","eventBus","modeling"];var af={__init__:["labelSupport"],labelSupport:["type",of]},lf="attach-ok";function cf(e,t,n,i,r){Fo.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=pf(t=r),C("id",t,n)),i.validatedShapes=function(e){var t=k(e,"id");return y(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(pf(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,lf),t.once(["shape.move.out","shape.move.cleanup"],(function(){n.removeMarker(r,lf)})))}})),this.preExecuted("elements.move",1401,(function(e){var t=e.context,n=t.closure;v(pf(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:y(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;rf(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=sd(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,s=n.attachers;!1!==(t.hints||{}).attachSupport&&v(s,(function(e){var t=sd(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;rf(t.attachers,(function(e){r.removeShape(e)})),t.host&&r.updateAttachment(t,null)}))}function pf(e){return i(E(e,(function(e){return e.attachers||[]})))}e(cf,Fo),cf.$inject=["injector","eventBus","canvas","rules","modeling"];var uf={__depends__:[Rc],__init__:["attachSupport"],attachSupport:["type",cf]};function df(e){this._model=e}function hf(e,t,n){Fo.call(this,e),this._bpmnFactory=t;var i=this;function r(e){v(e.context.oldRoot.children,(function(e){_r(e,"bpmn:BaseElement")&&i.updateParent(e)}))}function o(e){var t=e.context.shape;_r(t,"bpmn:BaseElement")&&i.updateBounds(t)}function s(e){i.updateConnection(e.context)}function a(e){i.updateConnectionWaypoints(e.context.connection)}function l(e){i.updateAttachment(e.context)}function c(e){const{element:n}=e.context,i=eo(n),r=Pr(n),o=r&&r.get("label");Xr(n)||es(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"],mf((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"],mf((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"],mf((function(e){"label"!==e.context.shape.type&&o(e)}))),this.reverted(["shape.move","shape.create","shape.resize"],mf((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"],mf(s)),this.reverted(["connection.create","connection.move","connection.delete","connection.reconnect"],mf(s)),this.executed(["connection.layout","connection.move","connection.updateWaypoints"],mf(a)),this.reverted(["connection.layout","connection.move","connection.updateWaypoints"],mf(a)),this.executed("connection.reconnect",mf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=Or(n),s=Or(i),a=Or(r);o.conditionExpression&&!Er(a,["bpmn:Activity","bpmn:ExclusiveGateway","bpmn:InclusiveGateway"])&&(t.oldConditionExpression=o.conditionExpression,delete o.conditionExpression),i!==r&&s.default===o&&(t.oldDefault=s.default,delete s.default)}))),this.reverted("connection.reconnect",mf((function(e){var t=e.context,n=t.connection,i=t.oldSource,r=t.newSource,o=Or(n),s=Or(i),a=Or(r);t.oldConditionExpression&&(o.conditionExpression=t.oldConditionExpression),t.oldDefault&&(s.default=t.oldDefault,delete a.default)}))),this.executed(["element.updateAttachment"],mf(l)),this.reverted(["element.updateAttachment"],mf(l)),this.executed("element.updateLabel",mf(c)),this.reverted("element.updateLabel",mf(c))}function mf(e){return function(t){var n=t.context;_r(n.shape||n.connection||n.element,"bpmn:BaseElement")&&e(t)}}function ff(e,t){Fn.call(this),this._bpmnFactory=e,this._moddle=t}function gf(e,t,n){return void 0===t[n]?t:(e[n]=t[n],q(t,[n]))}function yf(e,t){this._modeling=e,this._canvas=t}function vf(e){this._modeling=e}function bf(e,t){this._canvas=e,this._layouter=t}df.$inject=["moddle"],df.prototype._needsId=function(e){return Er(e,["bpmn:RootElement","bpmn:FlowElement","bpmn:MessageFlow","bpmn:DataAssociation","bpmn:Artifact","bpmn:Participant","bpmn:Lane","bpmn:LaneSet","bpmn:Process","bpmn:Collaboration","bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane","bpmn:Property","bpmn:CategoryValue"])},df.prototype._ensureId=function(e){var t;e.id?this._model.ids.claim(e.id,e):(t=_r(e,"bpmn:Activity")?"Activity":_r(e,"bpmn:Event")?"Event":_r(e,"bpmn:Gateway")?"Gateway":Er(e,["bpmn:SequenceFlow","bpmn:MessageFlow"])?"Flow":(e.$type||"").replace(/^[^:]*:/g,""),t+="_",!e.id&&this._needsId(e)&&(e.id=this._model.ids.nextPrefixed(t,e)))},df.prototype.create=function(e,t){var n=this._model.create(e,t||{});return this._ensureId(n),n},df.prototype.createDiLabel=function(){return this.create("bpmndi:BPMNLabel",{bounds:this.createDiBounds()})},df.prototype.createDiShape=function(e,t){return this.create("bpmndi:BPMNShape",j({bpmnElement:e,bounds:this.createDiBounds()},t))},df.prototype.createDiBounds=function(e){return this.create("dc:Bounds",e)},df.prototype.createDiWaypoints=function(e){var t=this;return E(e,(function(e){return t.createDiWaypoint(e)}))},df.prototype.createDiWaypoint=function(e){return this.create("dc:Point",L(e,["x","y"]))},df.prototype.createDiEdge=function(e,t){return this.create("bpmndi:BPMNEdge",j({bpmnElement:e,waypoint:this.createDiWaypoints([])},t))},df.prototype.createDiPlane=function(e,t){return this.create("bpmndi:BPMNPlane",j({bpmnElement:e},t))},e(hf,Fo),hf.$inject=["eventBus","bpmnFactory","connectionDocking"],hf.prototype.updateAttachment=function(e){var t=e.shape,n=t.businessObject,i=t.host;n.attachedToRef=i&&i.businessObject},hf.prototype.updateParent=function(e,t){if(!(hn(e)||_r(e,"bpmn:DataStoreReference")&&e.parent&&_r(e.parent,"bpmn:Collaboration"))){var n=e.parent,i=e.businessObject,r=Pr(e),o=n&&n.businessObject,s=Pr(n);_r(e,"bpmn:FlowNode")&&this.updateFlowNodeRefs(i,o,t&&t.businessObject),_r(e,"bpmn:DataOutputAssociation")&&(o=e.source?e.source.businessObject:null),_r(e,"bpmn:DataInputAssociation")&&(o=e.target?e.target.businessObject:null),this.updateSemanticParent(i,o),_r(e,"bpmn:DataObjectReference")&&i.dataObjectRef&&this.updateSemanticParent(i.dataObjectRef,o),this.updateDiParent(r,s)}},hf.prototype.updateBounds=function(e){var t=Pr(e),n=function(e){if(!_r(e,"bpmn:Activity"))return;var t=Pr(e);if(!t)return;var n=t.get("label");if(!n)return;return n.get("bounds")}(e);if(n){var i=ia(n,t.get("bounds"));j(n,{x:e.x+i.x,y:e.y+i.y})}var r=hn(e)?this._getLabel(t):t,o=r.bounds;o||(o=this._bpmnFactory.createDiBounds(),r.set("bounds",o)),j(o,{x:e.x,y:e.y,width:e.width,height:e.height})},hf.prototype.updateFlowNodeRefs=function(e,t,n){n!==t&&(_r(n,"bpmn:Lane")&&Et(n.get("flowNodeRef"),e),_r(t,"bpmn:Lane")&&Ot(t.get("flowNodeRef"),e))},hf.prototype.updateDiConnection=function(e,t,n){var i=Pr(e),r=Pr(t),o=Pr(n);i.sourceElement&&i.sourceElement.bpmnElement!==Or(t)&&(i.sourceElement=t&&r),i.targetElement&&i.targetElement.bpmnElement!==Or(n)&&(i.targetElement=n&&o)},hf.prototype.updateDiParent=function(e,t){if(t&&!_r(t,"bpmndi:BPMNPlane")&&(t=t.$parent),e.$parent!==t){var n=(t||e.$parent).get("planeElement");t?(n.push(e),e.$parent=t):(Et(n,e),e.$parent=null)}},hf.prototype.getLaneSet=function(e){var t,n;return _r(e,"bpmn:Lane")?((t=e.childLaneSet)||(t=this._bpmnFactory.create("bpmn:LaneSet"),e.childLaneSet=t,t.$parent=e),t):(_r(e,"bpmn:Participant")&&(e=e.processRef),(t=(n=e.get("laneSets"))[0])||((t=this._bpmnFactory.create("bpmn:LaneSet")).$parent=e,n.push(t)),t)},hf.prototype.updateSemanticParent=function(e,t,n){var i;if(e.$parent!==t&&(!_r(e,"bpmn:DataInput")&&!_r(e,"bpmn:DataOutput")||(_r(t,"bpmn:Participant")&&"processRef"in t&&(t=t.processRef),!("ioSpecification"in t)||t.ioSpecification!==e.$parent))){if(_r(e,"bpmn:Lane"))t&&(t=this.getLaneSet(t)),i="lanes";else if(_r(e,"bpmn:FlowElement")){if(t)if(_r(t,"bpmn:Participant"))t=t.processRef;else if(_r(t,"bpmn:Lane"))do{t=t.$parent.$parent}while(_r(t,"bpmn:Lane"));i="flowElements"}else if(_r(e,"bpmn:Artifact")){for(;t&&!_r(t,"bpmn:Process")&&!_r(t,"bpmn:SubProcess")&&!_r(t,"bpmn:Collaboration");){if(_r(t,"bpmn:Participant")){t=t.processRef;break}t=t.$parent}i="artifacts"}else if(_r(e,"bpmn:MessageFlow"))i="messageFlows";else if(_r(e,"bpmn:Participant")){i="participants";var r,o=e.processRef;o&&(r=function(e){for(;e&&!_r(e,"bpmn:Definitions");)e=e.$parent;return e}(e.$parent||t),e.$parent&&(Et(r.get("rootElements"),o),o.$parent=null),t&&(Ot(r.get("rootElements"),o),o.$parent=r))}else _r(e,"bpmn:DataOutputAssociation")?i="dataOutputAssociations":_r(e,"bpmn:DataInputAssociation")&&(i="dataInputAssociations");if(!i)throw new Error(`no parent for <${e.id}> in <${t.id}>`);var s;if(e.$parent&&Et(s=e.$parent.get(i),e),t?((s=t.get(i)).push(e),e.$parent=t):e.$parent=null,n){var a=n.get(i);Et(s,e),t&&(a||(a=[],t.set(i,a)),a.push(e))}}},hf.prototype.updateConnectionWaypoints=function(e){Pr(e).set("waypoint",this._bpmnFactory.createDiWaypoints(e.waypoints))},hf.prototype.updateConnection=function(e){var t,n=e.connection,i=Or(n),r=n.source,o=Or(r),s=n.target,a=Or(n.target);if(_r(i,"bpmn:DataAssociation"))_r(i,"bpmn:DataInputAssociation")?(i.get("sourceRef")[0]=o,t=e.parent||e.newParent||a,this.updateSemanticParent(i,a,t)):_r(i,"bpmn:DataOutputAssociation")&&(t=e.parent||e.newParent||o,this.updateSemanticParent(i,o,t),i.targetRef=a);else{var l=_r(i,"bpmn:SequenceFlow");i.sourceRef!==o&&(l&&(Et(i.sourceRef&&i.sourceRef.get("outgoing"),i),o&&o.get("outgoing")&&o.get("outgoing").push(i)),i.sourceRef=o),i.targetRef!==a&&(l&&(Et(i.targetRef&&i.targetRef.get("incoming"),i),a&&a.get("incoming")&&a.get("incoming").push(i)),i.targetRef=a)}this.updateConnectionWaypoints(n),this.updateDiConnection(n,r,s)},hf.prototype._getLabel=function(e){return e.label||(e.label=this._bpmnFactory.createDiLabel()),e.label},e(ff,Fn),ff.$inject=["bpmnFactory","moddle"],ff.prototype._baseCreate=Fn.prototype.create,ff.prototype.create=function(e,t){if("label"===e){var n=t.di||this._bpmnFactory.createDiLabel();return this._baseCreate(e,j({type:"label",di:n},Gr,t))}return this.createElement(e,t)},ff.prototype.createElement=function(e,t){var n,i,r,o=(t=j({},t||{})).businessObject,s=t.di;if(!o){if(!t.type)throw new Error("no shape type specified");br(o=this._bpmnFactory.create(t.type))}if(!Er(s,["bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane"])){var l=j({},s||{},{id:o.id+"_di"});s="root"===e?this._bpmnFactory.createDiPlane(o,l):"connection"===e?this._bpmnFactory.createDiEdge(o,l):this._bpmnFactory.createDiShape(o,l)}return _r(o,"bpmn:Group")&&(t=j({isFrame:!0},t)),t=function(e,t,n){return v(n,(function(n){t=gf(e,t,n)})),t}(o,t,["processRef","isInterrupting","associationDirection","isForCompensation"]),t.isExpanded&&(t=gf(s,t,"isExpanded")),Er(o,["bpmn:Lane","bpmn:Participant"])&&(t=gf(s,t,"isHorizontal")),_r(o,"bpmn:SubProcess")&&(t.collapsed=!Vr(o,s)),_r(o,"bpmn:ExclusiveGateway")&&(m(s,"isMarkerVisible")?void 0===s.isMarkerVisible&&(s.isMarkerVisible=!1):s.isMarkerVisible=!0),a(t.triggeredByEvent)&&(o.triggeredByEvent=t.triggeredByEvent,delete t.triggeredByEvent),a(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,s),t=j({id:o.id},n,t,{businessObject:o,di:s}),this._baseCreate(e,t)},ff.prototype.getDefaultSize=function(e,t){var n=Or(e);if(t=t||Pr(e),_r(n,"bpmn:SubProcess"))return Vr(n,t)?{width:350,height:200}:{width:100,height:80};if(_r(n,"bpmn:Task"))return{width:100,height:80};if(_r(n,"bpmn:Gateway"))return{width:50,height:50};if(_r(n,"bpmn:Event"))return{width:36,height:36};if(_r(n,"bpmn:Participant")){var i=void 0===t.isHorizontal||!0===t.isHorizontal;return Vr(n,t)?i?{width:600,height:250}:{width:250,height:600}:i?{width:400,height:60}:{width:60,height:400}}return _r(n,"bpmn:Lane")?{width:400,height:100}:_r(n,"bpmn:DataObjectReference")?{width:36,height:50}:_r(n,"bpmn:DataStoreReference")?{width:50,height:50}:_r(n,"bpmn:TextAnnotation")?{width:100,height:30}:_r(n,"bpmn:Group")?{width:300,height:300}:{width:100,height:80}},ff.prototype.createParticipantShape=function(e){return p(e)||(e={isExpanded:e}),!1!==(e=j({type:"bpmn:Participant"},e||{})).isExpanded&&(e.processRef=this._bpmnFactory.create("bpmn:Process")),this.createShape(e)},yf.$inject=["modeling","canvas"],yf.prototype.preExecute=function(e){var t=this._modeling,n=e.elements,i=e.alignment;v(n,(function(e){var n={x:0,y:0};a(i.left)?n.x=i.left-e.x:a(i.right)?n.x=i.right-e.width-e.x:a(i.center)?n.x=i.center-Math.round(e.width/2)-e.x:a(i.top)?n.y=i.top-e.y:a(i.bottom)?n.y=i.bottom-e.height-e.y:a(i.middle)&&(n.y=i.middle-Math.round(e.height/2)-e.y),t.moveElements([e],n,e.parent)}))},yf.prototype.postExecute=function(e){},vf.$inject=["modeling"],vf.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},vf.prototype.postExecute=function(e){var t,n,i=e.hints||{};t=e.source,n=e.shape,_(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))},bf.$inject=["canvas","layouter"],bf.prototype.execute=function(e){var t=e.connection,n=e.source,i=e.target,r=e.parent,o=e.parentIndex,s=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,s)),this._canvas.addConnection(t,r,o),t},bf.prototype.revert=function(e){var t=e.connection;return this._canvas.removeConnection(t),t.source=null,t.target=null,t};var xf=Math.round;function wf(e){this._modeling=e}wf.$inject=["modeling"],wf.prototype.preExecute=function(e){var t=e.elements,n=e.parent,i=e.parentIndex,r=e.position,o=e.hints,s=this._modeling;v(t,(function(e){u(e.x)||(e.x=0),u(e.y)||(e.y=0)}));var a=yt(y(t,(function(e){return!e.hidden})));v(t,(function(e){dn(e)&&(e.waypoints=E(e.waypoints,(function(e){return{x:xf(e.x-a.x-a.width/2+r.x),y:xf(e.y-a.y-a.height/2+r.y)}}))),j(e,{x:xf(e.x-a.x-a.width/2+r.x),y:xf(e.y-a.y-a.height/2+r.y)})}));var l=dt(t),c={};v(t,(function(e){if(dn(e))c[e.id]=u(i)?s.createConnection(c[e.source.id],c[e.target.id],i,e,e.parent||n,o):s.createConnection(c[e.source.id],c[e.target.id],e,e.parent||n,o);else{var t=j({},o);-1===l.indexOf(e)&&(t.autoResize=!1),hn(e)&&(t=q(t,["attach"])),c[e.id]=u(i)?s.createShape(e,L(e,["x","y","width","height"]),e.parent||n,i,t):s.createShape(e,L(e,["x","y","width","height"]),e.parent||n,t)}})),e.elements=P(c)};var _f=Math.round;function Ef(e){this._canvas=e}function Of(e){Ef.call(this,e)}Ef.$inject=["canvas"],Ef.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?j(t,n):j(t,{x:n.x-_f(t.width/2),y:n.y-_f(t.height/2)}),this._canvas.addShape(t,i,r),t},Ef.prototype.revert=function(e){var t=e.shape;return this._canvas.removeShape(t),t},e(Of,Ef),Of.$inject=["canvas"];var Pf=Ef.prototype.execute;Of.prototype.execute=function(e){var t=e.shape;return function(e){["width","height"].forEach((function(t){void 0===e[t]&&(e[t]=0)}))}(t),t.labelTarget=e.labelTarget,Pf.call(this,e)};var kf=Ef.prototype.revert;function Sf(e,t){this._canvas=e,this._modeling=t}function Cf(e,t){this._modeling=e,this._elementRegistry=t}function Af(e,t){this._canvas=e,this._modeling=t}function Mf(e){this._modeling=e}Of.prototype.revert=function(e){return e.shape.labelTarget=null,kf.call(this,e)},Sf.$inject=["canvas","modeling"],Sf.prototype.preExecute=function(e){var t=this._modeling,n=e.connection;rf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),rf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})}))},Sf.prototype.execute=function(e){var t=e.connection,n=t.parent;return e.parent=n,e.parentIndex=Pt(n.children,t),e.source=t.source,e.target=t.target,this._canvas.removeConnection(t),t.source=null,t.target=null,t},Sf.prototype.revert=function(e){var t=e.connection,n=e.parent,i=e.parentIndex;return t.source=e.source,t.target=e.target,Ot(n.children,t,i),this._canvas.addConnection(t,n),t},Cf.$inject=["modeling","elementRegistry"],Cf.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))}))},Af.$inject=["canvas","modeling"],Af.prototype.preExecute=function(e){var t=this._modeling,n=e.shape;rf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),rf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})})),rf(n.children,(function(e){dn(e)?t.removeConnection(e,{nested:!0}):t.removeShape(e,{nested:!0})}))},Af.prototype.execute=function(e){var t=this._canvas,n=e.shape,i=n.parent;return e.oldParent=i,e.oldParentIndex=Pt(i.children,n),t.removeShape(n),n},Af.prototype.revert=function(e){var t=this._canvas,n=e.shape,i=e.oldParent,r=e.oldParentIndex;return Ot(i.children,n,r),t.addShape(n,i),n},Mf.$inject=["modeling"];var Tf={x:"y",y:"x"};function Rf(e,t){this._layouter=e,this._canvas=t}function Df(){}function Nf(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}function Bf(e){this._modeling=e}function $f(e){this._helper=new Bf(e)}function jf(e){this._modeling=e,this._helper=new Bf(e)}function If(e){this._modeling=e}function Lf(e){return e.original||e}function qf(e,t){this._modeling=e,this._rules=t}function zf(e){this._modeling=e}function Vf(e){this._modeling=e}function Ff(e){return j({},e)}function Hf(e){switch(e){case"n":case"s":return"y";case"w":case"e":return"x"}}function Uf(e,t,n){var i=Hf(n);return/e|s/.test(n)?e[i]>t:/n|w/.test(n)?e[i]<t:void 0}function Wf(e,t){return-1!==e.indexOf(t)}function Gf(e){this._modeling=e}function Qf(e){var t={};return v(e,(function(e){t[e.id]=e.hidden,e.children&&(t=j({},t,Qf(e.children)))})),t}function Xf(e,t){var n=[];return v(e,(function(e){e.hidden=t,n=n.concat(e),e.children&&(n=n.concat(Xf(e.children,e.collapsed||t)))})),n}function Kf(e,t){var n=[];return v(e,(function(e){e.hidden=t[e.id],n=n.concat(e),e.children&&(n=n.concat(Kf(e.children,t)))})),n}function Yf(e){this._modeling=e}function Zf(e,t){return Et(e&&e.attachers,t)}function Jf(e,t,n){if(e){var i=e.attachers;i||(e.attachers=i=[]),Ot(i,t,n)}}function eg(){}function tg(e,t,n){this._eventBus=e,this._elementFactory=t,this._commandStack=n;var i=this;e.on("diagram.init",(function(){i.registerHandlers(n)}))}function ng(e){this._elementRegistry=e}function ig(e,t){v(t,(function(t,n){e.set(n,t)}))}Mf.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 s(e){return e[i]+e[r]/2}function a(e){return e.length-1}function l(e){return e.max-e.min}var c,p,u=n[0],d=a(n),h=n[d],m=0;v(n,(function(e,c){var p,u,h;e.elements.length<2?c&&c!==n.length-1&&(o(e,e.elements[0]),m+=l(e.range)):(u=(p=A(e.elements,i))[0],c===d&&(u=p[a(p)]),h=s(u),e.range=null,v(p,(function(n){!function(e,n){var r={y:0};r[i]=e-s(n),r[i]&&(r[Tf[i]]=0,t.moveElements([n],r,n.parent))}(h,n),null!==e.range?o(e,n):e.range={min:n[i],max:n[i]+n[r]}})),c&&c!==n.length-1&&(m+=l(e.range)))})),p=Math.abs(h.range.min-u.range.max),(c=Math.round((p-m)/(n.length-1)))<n.length-1||v(n,(function(e,o){var s,a={};e!==u&&e!==h&&(s=n[o-1],e.range.max=0,v(e.elements,(function(n,o){a[Tf[i]]=0,a[i]=s.range.max-n[i]+c,e.range.min!==n[i]&&(a[i]+=n[i]-e.range.min),a[i]&&t.moveElements([n],a,n.parent),e.range.max=Math.max(n[i]+n[r],o?e.range.max:0)})))}))},Mf.prototype.postExecute=function(e){},Rf.$inject=["layouter","canvas"],Rf.prototype.execute=function(e){var t=e.connection;return j(e,{oldWaypoints:t.waypoints}),t.waypoints=this._layouter.layoutConnection(t,e.hints),t},Rf.prototype.revert=function(e){var t=e.connection;return t.waypoints=e.oldWaypoints,t},Df.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=Et(o.children,t),Ot(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},Df.prototype.revert=function(e){var t=e.connection,n=t.parent,i=e.oldParent,r=e.oldParentIndex,o=e.delta;return Et(n.children,t),Ot(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},Nf.prototype.add=function(e,t){return this.addAll([e],t)},Nf.prototype.addAll=function(e,t){var n=function(e,t,n){s(t)&&(t=!0),p(t)&&(n=t,t=!0);var i=xt((n=n||{}).allShapes),r=xt(n.allConnections),o=xt(n.enclosedElements),a=xt(n.enclosedConnections),l=xt(n.topLevel,t&&k(e,(function(e){return e.id})));function c(e){l[e.source.id]&&l[e.target.id]&&(l[e.id]=[e]),i[e.source.id]&&i[e.target.id]&&(a[e.id]=o[e.id]=e),r[e.id]=e}return ft(e,(function(e){if(o[e.id]=e,!e.waypoints)return i[e.id]=e,v(e.incoming,c),v(e.outgoing,c),e.children;a[e.id]=r[e.id]=e})),{allShapes:i,allConnections:r,topLevel:l,enclosedConnections:a,enclosedElements:o}}(e,!!t,this);return j(this,n),this},Bf.prototype.moveRecursive=function(e,t,n){return e?this.moveClosure(this.getClosure(e),t,n):[]},Bf.prototype.moveClosure=function(e,t,n,i,r){var o=this._modeling,s=e.allShapes,a=e.allConnections,l=e.enclosedConnections,c=e.topLevel,p=!1;r&&r.parent===n&&(p=!0),v(s,(function(e){o.moveShape(e,t,c[e.id]&&!p&&n,{recurse:!1,layout:!1})})),v(a,(function(e){var i=!!s[e.source.id],r=!!s[e.target.id];l[e.id]&&i&&r?o.moveConnection(e,t,c[e.id]&&!p&&n):o.layoutConnection(e,{connectionStart:i&&md(e,e.source,t),connectionEnd:r&&fd(e,e.target,t)})}))},Bf.prototype.getClosure=function(e){return(new Nf).addAll(e,!0)},$f.$inject=["modeling"],$f.prototype.preExecute=function(e){e.closure=this._helper.getClosure(e.shapes)},$f.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)},jf.$inject=["modeling"],jf.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=L(t,["x","y","width","height"]),e.oldParent=o,e.oldParentIndex=Et(o.children,t),Ot(i.children,t,r),j(t,{parent:i,x:t.x+n.x,y:t.y+n.y}),t},jf.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:fd(e,t,n)})})),v(t.outgoing,(function(e){r.layoutConnection(e,{connectionStart:md(e,t,n)})}))),!1!==i.recurse&&this.moveChildren(e)},jf.prototype.revert=function(e){var t=e.shape,n=e.oldParent,i=e.oldParentIndex,r=e.delta;return Ot(n.children,t,i),j(t,{parent:n,x:t.x-r.x,y:t.y-r.y}),t},jf.prototype.moveChildren=function(e){var t=e.delta,n=e.shape;this._helper.moveRecursive(n.children,t,null)},jf.prototype.getNewParent=function(e){return e.newParent||e.shape.parent},If.$inject=["modeling"],If.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 c(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},If.prototype.postExecute=function(e){var t=e.connection,n=e.newSource,i=e.newTarget,r=e.dockingOrPoints,o=e.hints||{},s={};o.connectionStart&&(s.connectionStart=o.connectionStart),o.connectionEnd&&(s.connectionEnd=o.connectionEnd),!1!==o.layoutConnection&&(!n||i&&"source"!==o.docking||(s.connectionStart=s.connectionStart||Lf(c(r)?r[0]:r)),!i||n&&"target"!==o.docking||(s.connectionEnd=s.connectionEnd||Lf(c(r)?r[r.length-1]:r)),o.newWaypoints&&(s.waypoints=o.newWaypoints),this._modeling.layoutConnection(t,s))},If.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},qf.$inject=["modeling","rules"],qf.prototype.preExecute=function(e){var t,n=this,i=this._modeling,r=this._rules,o=e.oldShape,s=e.newData,a=e.hints||{};function l(e,t,n){return r.allowed("connection.reconnect",{connection:n,source:e,target:t})}var c,p={x:s.x,y:s.y},u={x:o.x,y:o.y,width:o.width,height:o.height};t=e.newShape=e.newShape||n.createShape(s,p,o.parent,a),o.host&&i.updateAttachment(t,o.host),!1!==a.moveChildren&&(c=o.children.slice(),i.moveElements(c,{x:0,y:0},t,a));var d=o.incoming.slice(),h=o.outgoing.slice();v(d,(function(e){l(e.source,t,e)&&n.reconnectEnd(e,t,hd(e,t,u),a)})),v(h,(function(e){var i=e.target;l(t,i,e)&&n.reconnectStart(e,t,dd(e,t,u),a)}))},qf.prototype.postExecute=function(e){var t=e.oldShape;this._modeling.removeShape(t)},qf.prototype.execute=function(e){},qf.prototype.revert=function(e){},qf.prototype.createShape=function(e,t,n,i){return this._modeling.createShape(e,t,n,i)},qf.prototype.reconnectStart=function(e,t,n,i){this._modeling.reconnectStart(e,t,n,i)},qf.prototype.reconnectEnd=function(e,t,n,i){this._modeling.reconnectEnd(e,t,n,i)},zf.$inject=["modeling"],zf.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},j(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},zf.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:hd(e,n,i)})})),v(n.outgoing,(function(e){t.layoutConnection(e,{connectionStart:dd(e,n,i)})})))},zf.prototype.revert=function(e){var t=e.shape,n=e.oldBounds;return j(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Vf.$inject=["modeling"],Vf.prototype.preExecute=function(e){var t=e.delta,n=e.direction,i=e.movingShapes,r=e.resizingShapes,o=e.start,s={};this.moveShapes(i,t),v(r,(function(e){s[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;(Bm(e,r)||Bm(e,o)||Bm(t,r)||Bm(t,o))&&(Bm(n,i)||n.push(i))}))})),n}(i,r),t,n,o,i,r,s)},Vf.prototype.execute=function(){},Vf.prototype.revert=function(){},Vf.prototype.moveShapes=function(e,t){var n=this;v(e,(function(e){n._modeling.moveShape(e,t,null,{autoResize:!1,layout:!1,recurse:!1})}))},Vf.prototype.resizeShapes=function(e,t,n){var i=this;v(e,(function(e){var r=function(e,t,n){var i=e.x,r=e.y,o=e.width,s=e.height,a=n.x,l=n.y;switch(t){case"n":return{x:i,y:r+l,width:o,height:s-l};case"s":return{x:i,y:r,width:o,height:s+l};case"w":return{x:i+a,y:r,width:o-a,height:s};case"e":return{x:i,y:r,width:o+a,height:s};default:throw new Error("unknown direction: "+t)}}(e,n,t);i._modeling.resizeShape(e,r,null,{attachSupport:!1,autoResize:!1,layout:!1})}))},Vf.prototype.updateConnectionWaypoints=function(e,t,n,i,r,o,s){var a=this,l=r.concat(o);v(e,(function(e){var c=e.source,p=e.target,u=function(e){return E(e.waypoints,(function(e){return(e=Ff(e)).original&&(e.original=Ff(e.original)),e}))}(e),d=Hf(n),h={};Wf(l,c)&&Wf(l,p)?(u=E(u,(function(e){return Uf(e,i,n)&&(e[d]=e[d]+t[d]),e.original&&Uf(e.original,i,n)&&(e.original[d]=e.original[d]+t[d]),e})),a._modeling.updateWaypoints(e,u,{labelBehavior:!1})):(Wf(l,c)||Wf(l,p))&&(Wf(r,c)?h.connectionStart=md(e,c,t):Wf(r,p)?h.connectionEnd=fd(e,p,t):Wf(o,c)?h.connectionStart=dd(e,c,s[c.id]):Wf(o,p)&&(h.connectionEnd=hd(e,p,s[p.id])),a._modeling.layoutConnection(e,h))}))},Gf.$inject=["modeling"],Gf.prototype.execute=function(e){var t=e.shape,n=t.children;e.oldChildrenVisibility=Qf(n),t.collapsed=!t.collapsed;var i=Xf(n,t.collapsed);return[t].concat(i)},Gf.prototype.revert=function(e){var t=e.shape,n=e.oldChildrenVisibility,i=Kf(t.children,n);return t.collapsed=!t.collapsed,[t].concat(i)},Yf.$inject=["modeling"],Yf.prototype.execute=function(e){var t=e.shape,n=e.newHost,i=t.host;return e.oldHost=i,e.attacherIdx=Zf(i,t),Jf(n,t),t.host=n,t},Yf.prototype.revert=function(e){var t=e.shape,n=e.newHost,i=e.oldHost,r=e.attacherIdx;return t.host=i,Zf(n,t),Jf(i,t,r),t},eg.prototype.execute=function(e){var t=e.connection,n=e.newWaypoints;return e.oldWaypoints=t.waypoints,t.waypoints=n,t},eg.prototype.revert=function(e){var t=e.connection,n=e.oldWaypoints;return t.waypoints=n,t},tg.$inject=["eventBus","elementFactory","commandStack"],tg.prototype.getHandlers=function(){return{"shape.append":vf,"shape.create":Ef,"shape.delete":Af,"shape.move":jf,"shape.resize":zf,"shape.replace":qf,"shape.toggleCollapse":Gf,spaceTool:Vf,"label.create":Of,"connection.create":bf,"connection.delete":Sf,"connection.move":Df,"connection.layout":Rf,"connection.updateWaypoints":eg,"connection.reconnect":If,"elements.create":wf,"elements.move":$f,"elements.delete":Cf,"elements.distribute":Mf,"elements.align":yf,"element.updateAttachment":Yf}},tg.prototype.registerHandlers=function(e){v(this.getHandlers(),(function(t,n){e.registerHandler(n,t)}))},tg.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)},tg.prototype.updateAttachment=function(e,t){var n={shape:e,newHost:t};this._commandStack.execute("element.updateAttachment",n)},tg.prototype.moveElements=function(e,t,n,i){var r,o=(i=i||{}).attach,s=n;!0===o?(r=n,s=n.parent):!1===o&&(r=null);var a={shapes:e,delta:t,newParent:s,newHost:r,hints:i};this._commandStack.execute("elements.move",a)},tg.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)},tg.prototype.layoutConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.layout",n)},tg.prototype.createConnection=function(e,t,n,i,r,o){"object"==typeof n&&(o=r,r=i,i=n,n=void 0);var s={source:e,target:t,parent:r,parentIndex:n,connection:i=this._create("connection",i),hints:o};return this._commandStack.execute("connection.create",s),s.connection},tg.prototype.createShape=function(e,t,n,i,r){"number"!=typeof i&&(r=i,i=void 0);var o,s,a=(r=r||{}).attach;e=this._create("shape",e),a?(o=n.parent,s=n):o=n;var l={position:t,shape:e,parent:o,parentIndex:i,host:s,hints:r};return this._commandStack.execute("shape.create",l),l.shape},tg.prototype.createElements=function(e,t,n,i,r){c(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},tg.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},tg.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},tg.prototype.removeElements=function(e){var t={elements:e};this._commandStack.execute("elements.delete",t)},tg.prototype.distributeElements=function(e,t,n){var i={groups:e,axis:t,dimension:n};this._commandStack.execute("elements.distribute",i)},tg.prototype.removeShape=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.delete",n)},tg.prototype.removeConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.delete",n)},tg.prototype.replaceShape=function(e,t,n){var i={oldShape:e,newData:t,hints:n||{}};return this._commandStack.execute("shape.replace",i),i.newShape},tg.prototype.alignElements=function(e,t){var n={elements:e,alignment:t};this._commandStack.execute("elements.align",n)},tg.prototype.resizeShape=function(e,t,n,i){var r={shape:e,newBounds:t,minBounds:n,hints:i};this._commandStack.execute("shape.resize",r)},tg.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)},tg.prototype.updateWaypoints=function(e,t,n){var i={connection:e,newWaypoints:t,hints:n||{}};this._commandStack.execute("connection.updateWaypoints",i)},tg.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)},tg.prototype.reconnectStart=function(e,t,n,i){i||(i={}),this.reconnect(e,t,e.target,n,j(i,{docking:"source"}))},tg.prototype.reconnectEnd=function(e,t,n,i){i||(i={}),this.reconnect(e,e.source,t,n,j(i,{docking:"target"}))},tg.prototype.connect=function(e,t,n,i){return this.createConnection(e,t,n||{},e.parent,i)},tg.prototype._create=function(e,t){return t instanceof jn?t:this._elementFactory.create(e,t)},tg.prototype.toggleCollapse=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.toggleCollapse",n)},ng.$inject=["elementRegistry"],ng.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 x(t,(function(t,n){return t[n]=e.get(n),t}),{})}(n,O(i));return ig(n,i),e.oldProperties=o,e.changed=r,r},ng.prototype.revert=function(e){var t=e.oldProperties,n=e.moddleElement,i=e.changed;return ig(n,t),i},ng.prototype._getVisualReferences=function(e){var t=this._elementRegistry;return _r(e,"bpmn:DataObject")?function(e,t){return t.filter((function(t){return _r(t,"bpmn:DataObjectReference")&&Or(t).dataObjectRef===e}))}(e,t):[]};var rg="default",og="id",sg="di",ag={width:0,height:0};function lg(e,t,n,i){this._elementRegistry=e,this._moddle=t,this._modeling=n,this._textRenderer=i}function cg(e,t){return og in e&&e[og]!==t[og]}function pg(e,t){var n=e.businessObject,i=Pr(e);v(t,(function(e,t){t!==sg?n.set(t,e):i&&function(e,t){v(t,(function(t,n){e.set(n,t)}))}(i,e)}))}lg.$inject=["elementRegistry","moddle","modeling","textRenderer"],lg.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,s=function(e){var t=j({},e);return ug.forEach((function(n){n in e&&(t[n]=Or(t[n]))})),t}(e.properties),a=e.oldProperties||function(e,t){var n=O(t),i=e.businessObject,r=Pr(e);return x(n,(function(e,n){return e[n]=n!==sg?i.get(n):function(e,t){return x(t,(function(t,n){return t[n]=e&&e.get(n),t}),{})}(r,O(t.di)),e}),{})}(t,s);return cg(s,o)&&(r.unclaim(o[og]),i.updateId(t,s[og]),r.claim(s[og],o)),rg in s&&(s[rg]&&n.push(i.get(s[rg].id)),o[rg]&&n.push(i.get(o[rg].id))),pg(t,s),e.oldProperties=a,e.changed=n,n},lg.prototype.postExecute=function(e){var t=e.element.label,n=t&&Or(t).name;if(n){var i=this._textRenderer.getExternalLabelBounds(t,n);this._modeling.resizeShape(t,i,ag)}},lg.prototype.revert=function(e){var t=e.element,n=e.properties,i=e.oldProperties,r=t.businessObject,o=this._elementRegistry,s=this._moddle.ids;return pg(t,i),cg(n,r)&&(s.unclaim(n[og]),o.updateId(t,i[og]),s.claim(i[og],r)),e.changed};var ug=["default"];function dg(e,t){this._canvas=e,this._modeling=t}function hg(e,t){this._modeling=e,this._spaceTool=t}function mg(e){this._modeling=e}function fg(e,t){this._modeling=e,this._spaceTool=t}dg.$inject=["canvas","modeling"],dg.prototype.execute=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,r=t.getRootElement(),o=r.businessObject,s=o.$parent,a=Pr(r);return t.setRootElement(n),t.removeRootElement(r),Ot(s.rootElements,i),i.$parent=s,Et(s.rootElements,o),o.$parent=null,r.di=null,a.bpmnElement=i,n.di=a,e.oldRoot=r,[]},dg.prototype.revert=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,r=e.oldRoot,o=r.businessObject,s=i.$parent,a=Pr(n);return t.setRootElement(r),t.removeRootElement(n),Et(s.rootElements,i),i.$parent=null,Ot(s.rootElements,o),o.$parent=s,n.di=null,a.bpmnElement=o,r.di=a,[]},hg.$inject=["modeling","spaceTool"],hg.prototype.preExecute=function(e){var t=this._spaceTool,n=this._modeling,i=e.shape,r=e.location,o=Au(i),s=o===i,a=s?i:i.parent,l=Cu(a),c=Fr(i);if(c?"left"===r?r="top":"right"===r&&(r="bottom"):"top"===r?r="left":"bottom"===r&&(r="right"),!l.length){var p=c?{x:i.x+ku,y:i.y,width:i.width-ku,height:i.height}:{x:i.x,y:i.y+ku,width:i.width,height:i.height-ku};n.createShape({type:"bpmn:Lane",isHorizontal:c},p,a)}var u,d,h,m,f,g=[];ft(o,(function(e){return g.push(e),e.label&&g.push(e.label),e===i?[]:y(e.children,(function(e){return e!==i}))})),"top"===r?(u=-120,h=(d=i.y)+10,m="n",f="y"):"left"===r?(u=-120,h=(d=i.x)+10,m="w",f="x"):"bottom"===r?(u=120,h=(d=i.y+i.height)-10,m="s",f="y"):"right"===r&&(u=120,h=(d=i.x+i.width)-10,m="e",f="x");var v=t.calculateAdjustments(g,f,u,h),b=c?{x:0,y:u}:{x:u,y:0};t.makeSpace(v.movingShapes,v.resizingShapes,b,m,h);var x=c?{x:i.x+(s?ku:0),y:d-("top"===r?120:0),width:i.width-(s?ku:0),height:120}:{x:d-("left"===r?120:0),y:i.y+(s?ku:0),width:120,height:i.height-(s?ku:0)};e.newLane=n.createShape({type:"bpmn:Lane",isHorizontal:c},x,a)},mg.$inject=["modeling"],mg.prototype.preExecute=function(e){var t=this._modeling,n=e.shape,i=e.count,r=Cu(n),o=r.length;if(o>i)throw new Error(`more than <${i}> child lanes`);var s,a,l,c,p=Fr(n),u=p?n.height:n.width,d=Math.round(u/i);for(c=0;c<i;c++)s=c===i-1?u-d*c:d,a=p?{x:n.x+ku,y:n.y+c*d,width:n.width-ku,height:s}:{x:n.x+c*d,y:n.y+ku,width:s,height:n.height-ku},c<o?t.resizeShape(r[c],a):(l={type:"bpmn:Lane",isHorizontal:p},t.createShape(l,a,n))},fg.$inject=["modeling","spaceTool"],fg.prototype.preExecute=function(e){var t=e.shape,n=e.newBounds;!1!==e.balanced?this.resizeBalanced(t,n):this.resizeSpace(t,n)},fg.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)}))},fg.prototype.resizeSpace=function(e,t){var n,i,r,o,s,a=this._spaceTool,l=gn(e),c=bu(gn(t),l),p=Au(e),u=[],d=[];ft(p,(function(e){return u.push(e),(_r(e,"bpmn:Lane")||_r(e,"bpmn:Participant"))&&d.push(e),e.children})),(c.bottom||c.top)&&(n=c.bottom||c.top,i=e.y+(c.bottom?e.height:0)+(c.bottom?-10:10),r=c.bottom?"s":"n",o=c.top>0||c.bottom<0?-n:n,s=a.calculateAdjustments(u,"y",o,i),a.makeSpace(s.movingShapes,s.resizingShapes,{x:0,y:n},r)),(c.left||c.right)&&(n=c.right||c.left,i=e.x+(c.right?e.width:0)+(c.right?-10:100),r=c.right?"e":"w",o=c.left>0||c.right<0?-n:n,s=a.calculateAdjustments(d,"x",o,i),a.makeSpace(s.movingShapes,s.resizingShapes,{x:n,y:0},r))};var gg="flowNodeRef",yg="lanes";function vg(e){this._elementRegistry=e}function bg(e){this._moddle=e}vg.$inject=["elementRegistry"],vg.prototype._computeUpdates=function(e,t){var n=[],i=[],r={},o=[];function s(e){-1===n.indexOf(e)&&(o.push(e),n.push(e))}function a(e){if(!e.parent)return[];var t=function(e){var t=Au(e);return r[t.id]||(r[t.id]=Su(t)),r[t.id]}(e);return t.filter((function(t){return n=e,i=gn(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=Au(e);if(t&&-1===n.indexOf(t)){var i=t.children.filter((function(e){return _r(e,"bpmn:FlowNode")}));i.forEach(s),n.push(t)}})),e.forEach(s),o.forEach((function(e){var t=e.businessObject,n=t.get(yg).slice(),r=a(e);i.push({flowNode:t,remove:n,add:r})})),t.forEach((function(e){var t=e.businessObject;e.parent||t.get(gg).forEach((function(e){i.push({flowNode:e,remove:[t],add:[]})}))})),i},vg.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(yg);e.remove.forEach((function(e){Et(n,e),Et(e.get(gg),t)})),e.add.forEach((function(e){Ot(n,e),Ot(e.get(gg),t)}))})),[]},vg.prototype.revert=function(e){return e.updates.forEach((function(e){var t=e.flowNode,n=t.get(yg);e.add.forEach((function(e){Et(n,e),Et(e.get(gg),t)})),e.remove.forEach((function(e){Ot(n,e),Ot(e.get(gg),t)}))})),[]},bg.$inject=["moddle"],bg.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),[]},bg.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 xg={fill:void 0,stroke:void 0};function wg(e){this._commandStack=e,this._normalizeColor=function(e){if(e){if(h(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}`)}}}wg.$inject=["commandStack"],wg.prototype.postExecute=function(e){var t=e.elements,n=e.colors||xg,i=this,r={};"fill"in n&&j(r,{"background-color":this._normalizeColor(n.fill)}),"stroke"in n&&j(r,{"border-color":this._normalizeColor(n.stroke)}),v(t,(function(e){var t=dn(e)?L(r,["border-color"]):r,n=Pr(e);if(function(e){"border-color"in e&&(e.stroke=e["border-color"]);"background-color"in e&&(e.fill=e["background-color"])}(t),hn(e))i._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:n.label,properties:{color:r["border-color"]}});else{if(!Er(n,["bpmndi:BPMNEdge","bpmndi:BPMNShape"]))return;i._commandStack.execute("element.updateProperties",{element:e,properties:{di:t}})}}))};var _g={width:0,height:0};function Eg(e,t,n){function i(e,t){var n=e.label||e,i=e.labelTarget||e;return to(n,t),[n,i]}this.preExecute=function(t){var n=t.element,i=n.businessObject,r=t.newLabel;if(!hn(n)&&Xr(n)&&!Kr(n)&&!Og(r)){var o=Zr(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=eo(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,s=n.newBounds,a=n.hints||{};if(hn(r)||_r(r,"bpmn:TextAnnotation"))if(hn(r)&&Og(o))!1!==a.removeShape&&e.removeShape(r,{unsetLabel:!1});else{var l=eo(i);void 0===s&&(s=t.getExternalLabelBounds(r,l)),s&&e.resizeShape(r,s,_g)}}}function Og(e){return!e||!e.trim()}function Pg(e,t,n,i){tg.call(this,e,t,n),this._bpmnRules=i}function kg(){}Eg.$inject=["modeling","textRenderer","bpmnFactory"],e(Pg,tg),Pg.$inject=["eventBus","elementFactory","commandStack","bpmnRules"],Pg.prototype.getHandlers=function(){var e=tg.prototype.getHandlers.call(this);return e["element.updateModdleProperties"]=ng,e["element.updateProperties"]=lg,e["canvas.updateRoot"]=dg,e["lane.add"]=hg,e["lane.resize"]=fg,e["lane.split"]=mg,e["lane.updateRefs"]=vg,e["id.updateClaim"]=bg,e["element.setColor"]=wg,e["element.updateLabel"]=Eg,e},Pg.prototype.updateLabel=function(e,t,n,i){this._commandStack.execute("element.updateLabel",{element:e,newLabel:t,newBounds:n,hints:i||{}})},Pg.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)},Pg.prototype.updateModdleProperties=function(e,t,n){this._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:t,properties:n})},Pg.prototype.updateProperties=function(e,t){this._commandStack.execute("element.updateProperties",{element:e,properties:t})},Pg.prototype.resizeLane=function(e,t,n){this._commandStack.execute("lane.resize",{shape:e,newBounds:t,balanced:n})},Pg.prototype.addLane=function(e,t){var n={shape:e,location:t};return this._commandStack.execute("lane.add",n),n.newLane},Pg.prototype.splitLane=function(e,t){this._commandStack.execute("lane.split",{shape:e,count:t})},Pg.prototype.makeCollaboration=function(){var e=this._create("root",{type:"bpmn:Collaboration"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},Pg.prototype.makeProcess=function(){var e=this._create("root",{type:"bpmn:Process"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},Pg.prototype.updateLaneRefs=function(e,t){this._commandStack.execute("lane.updateRefs",{flowNodeShapes:e,laneShapes:t})},Pg.prototype.claimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t,claiming:!0})},Pg.prototype.unclaimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t})},Pg.prototype.setColor=function(e,t){e.length||(e=[e]),this._commandStack.execute("element.setColor",{elements:e,colors:t})},kg.prototype.layoutConnection=function(e,t){return[(t=t||{}).connectionStart||bn(t.source||e.source),t.connectionEnd||bn(t.target||e.target)]};var Sg=20,Cg=5,Ag=Math.round,Mg=20,Tg={"h:h":20,"v:v":20,"h:v":-10,"v:h":-10};function Rg(e,t,n){var i,r,o,s=xn(t,e,Cg),a=n.split(":")[0],l=Ag((t.x-e.x)/2+e.x),c=Ag((t.y-e.y)/2+e.y),p=(o=s,{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/left|right/,v:/top|bottom/}[a].test(o)),u=/h|r|l/.test(a),d=!1,h=!1;return p?(i=u?{x:l,y:e.y}:{x:e.x,y:c},r=u?"h:h":"v:v"):(d=function(e,t){return!{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/./,v:/./}[t].test(e)}(s,a),r=u?"h:v":"v:h",d?u?(h=c===e.y,i={x:e.x+Sg*(/l/.test(a)?-1:1),y:h?c+Sg:c}):i={x:(h=l===e.x)?l+Sg:l,y:e.y+Sg*(/t/.test(a)?-1:1)}:i={x:l,y:c}),{waypoints:Ng(e,i,r).concat(i),directions:r,turnNextDirections:h}}function Dg(e){return e.split(":").reverse().join(":")}function Ng(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(Lg(n)){var i=function(e,t,n){return Rg(e,t,n)}(e,t,n),r=function(e,t,n){var i=Rg(t,e,Dg(n));return{waypoints:i.waypoints.slice().reverse(),directions:Dg(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:Ng(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=Ag((t.x-e.x)/2+e.x),r=Ag((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 Bg(e,t,n,i,r){var o=b(r&&r.preferredLayouts||[],"straight")[0]||"h:h",s=xn(e,t,Tg[o]||0),a=function(e,t){if(Lg(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}}(s,o);n=n||bn(e),i=i||bn(t);var l=a.split(":"),c=qg(n,e,l[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]}(s));return function(e,t,n){var i=Ng(e,t,n);return i.unshift(e),i.push(t),zg(i)}(c,qg(i,t,l[1],s),a)}function $g(e,t,n,i,r,o){var s;return c(n)&&(r=n,o=i,n=bn(e),i=bn(t)),r=r||[],s=-1!==(o=j({preferredLayouts:[]},o)).preferredLayouts.indexOf("straight")&&function(e,t,n,i,r){var o,s,a={};if(s=xn(e,t),!/^(top|bottom|left|right)$/.test(s))return null;/top|bottom/.test(s)&&(o="x");/left|right/.test(s)&&(o="y");return"target"===r.preserveDocking?jg(o,i,e)?(a[o]=i[o],[{x:void 0!==a.x?a.x:n.x,y:void 0!==a.y?a.y:n.y,original:{x:void 0!==a.x?a.x:n.x,y:void 0!==a.y?a.y:n.y}},{x:i.x,y:i.y}]):null:jg(o,n,t)?(a[o]=n[o],[{x:n.x,y:n.y},{x:void 0!==a.x?a.x:i.x,y:void 0!==a.y?a.y:i.y,original:{x:void 0!==a.x?a.x:i.x,y:void 0!==a.y?a.y:i.y}}]):null}(e,t,n,i,o),s||(s=o.connectionEnd&&function(e,t,n,i){var r=i.slice().reverse();return r=Ig(e,t,n,r),r?r.reverse():null}(t,e,i,r),s||((s=o.connectionStart&&Ig(e,t,n,r))||(!o.connectionStart&&!o.connectionEnd&&r&&r.length?r:Bg(e,t,n,i,o))))}function jg(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 Ig(e,t,n,i){if(function(e){return e.length<3||!(e.length>4)&&!!f(e,(function(t,n){var i=e[n-1];return i&&kt(t,i)<3}))}(i))return null;var r,o=i[0],s=i.slice();return s[0]=n,s[1]=function(e,t,n){switch(At(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}}(s[1],o,n),r=function(e,t,n){var i;for(i=e.length-2;0!==i;i--)if(Tt(e[i],t,Mg)||Tt(e[i],n,Mg))return e.slice(i);return e}(s,e,t),r!==s&&(s=Ig(e,t,n,r)),s&&At(s)?null:s}function Lg(e){return e&&/t|r|b|l/.test(e)}function qg(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 zg(e){return e.reduce((function(t,n,i){return St(t[t.length-1],e[i+1],n,0)||t.push(n),t}),[])}var Vg=-10,Fg=40,Hg={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},Ug={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},Wg={top:"bottom","top-right":"bottom-left","top-left":"bottom-right",right:"left",bottom:"top","bottom-right":"top-left","bottom-left":"top-right",left:"right"},Gg={top:"t",right:"r",bottom:"b",left:"l"};function Qg(e){this._elementRegistry=e}function Xg(e,t){return _r(t,"bpmn:Participant")?"source":_r(e,"bpmn:Participant")?"target":Jg(t)?"source":Jg(e)||_r(t,"bpmn:Event")?"target":_r(e,"bpmn:Event")?"source":null}function Kg(e){return Jg(e)?"target":"source"}function Yg(e,t){return e?e.original||e:bn(t)}function Zg(e,t){return _r(t,"bpmn:Activity")&&_r(e,"bpmn:BoundaryEvent")&&t.businessObject.isForCompensation}function Jg(e){return _r(e,"bpmn:SubProcess")&&Vr(e)}function ey(e,t){return e===t}function ty(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 iy(e,t){return Wg[e]===t}function ry(e){return"right"===e||"left"===e}function oy(e,t,n){var i=t.waypoints,r=i&&i.length&&xn(i[0],e);return"top"===r?n.loop.fromTop:"right"===r?n.loop.fromRight:"left"===r?n.loop.fromLeft:n.loop.fromBottom}function sy(e,t,n,i){var r,o,s,a,l=bn(e),c=bn(t),p=(a=(s=e).host,xn(bn(s),a,Vg)),u=ey(e.host,t),d=-1!==["top","right","bottom","left"].indexOf(p),h=xn(c,l,{x:e.width/2+t.width/2,y:e.height/2+t.height/2});return u?function(e,t,n,i,r,o){var s,a=t?e:o.isHorizontal?ny(e):ty(e),l=Gg[a];s=t?ry(e)?ay("y",n,i,r)?"h":o.boundaryLoop.alternateHorizontalSide:ay("x",n,i,r)?"v":o.boundaryLoop.alternateVerticalSide:o.boundaryLoop.default;return[l+":"+s]}(p,d,e,t,n,i):(r=function(e,t,n,i){if(n)return Gg[e];var r=ny(e),o=ty(e),s=ny(t),a=ty(t);if(i){if(ey(r,s)||iy(o,a))return Gg[r]}else if(ey(o,a)||iy(r,s))return Gg[o];return Gg[i?o:r]}(p,h,d,i.isHorizontal),o=function(e,t,n,i){if(n)return ry(e)?function(e,t){var n=ty(e),i=Wg[n];return-1!==t.indexOf(i)}(e,t)||ey(e,t)?"h":"v":function(e,t){var n=ny(e),i=Wg[n];return-1!==t.indexOf(i)}(e,t)||ey(e,t)?"v":"h";return i?ey(ny(e),ny(t))?"h":"v":ey(ty(e),ty(t))?"v":"h"}(p,h,d,i.isHorizontal),[r+":"+o])}function ay(e,t,n,i){var r=Fg;return!(ly(e,i,n,r)||ly(e,i,{x:n.x+n.width,y:n.y+n.height},r)||ly(e,i,bn(t),r))}function ly(e,t,n,i){return Math.abs(t[e]-n[e])<i}function cy(e){return j({original:e.point.original||e.point},e.actual)}function py(e,t){this._elementRegistry=e,this._graphicsFactory=t}e(Qg,kg),Qg.prototype.layoutConnection=function(e,t){t||(t={});var n,i,r=t.source||e.source,o=t.target||e.target,s=t.waypoints||e.waypoints,a=t.connectionStart,l=t.connectionEnd,c=this._elementRegistry;if(a||(a=Yg(s&&s[0],r)),l||(l=Yg(s&&s[s.length-1],o)),(_r(e,"bpmn:Association")||_r(e,"bpmn:DataAssociation"))&&s&&!Zg(r,o))return[].concat([a],s.slice(1,-1),[l]);var p=uc(r,c)?Hg:Ug;return _r(e,"bpmn:MessageFlow")?n=function(e,t,n){return{preferredLayouts:n.messageFlow,preserveDocking:Xg(e,t)}}(r,o,p):(_r(e,"bpmn:SequenceFlow")||Zg(r,o))&&(n=r===o?{preferredLayouts:oy(r,e,p)}:_r(r,"bpmn:BoundaryEvent")?{preferredLayouts:sy(r,o,l,p)}:Jg(r)||Jg(o)?{preferredLayouts:p.subProcess,preserveDocking:Kg(r)}:_r(r,"bpmn:Gateway")?{preferredLayouts:p.fromGateway}:_r(o,"bpmn:Gateway")?{preferredLayouts:p.toGateway}:{preferredLayouts:p.default}),n&&(i=zg($g(r,o,a,l,s,n=j(n,t)))),i||[a,l]},Qg.$inject=["elementRegistry"],py.$inject=["elementRegistry","graphicsFactory"],py.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(cy(i)),o.push(cy(r)),o},py.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}},py.prototype._getIntersection=function(e,t,n){return wn(this._getShapePath(e),this._getConnectionPath(t),n)},py.prototype._getConnectionPath=function(e){return this._graphicsFactory.getConnectionPath(e)},py.prototype._getShapePath=function(e){return this._graphicsFactory.getShapePath(e)},py.prototype._getGfx=function(e){return this._elementRegistry.getGraphics(e)};var uy={__init__:["modeling","bpmnUpdater"],__depends__:[mh,Qh,Kh,Jh,Rm,nf,af,uf,Ts,Vo,ef],bpmnFactory:["type",df],bpmnUpdater:["type",hf],elementFactory:["type",ff],modeling:["type",Pg],layouter:["type",Qg],connectionDocking:["type",py]};const dy=Math.round;function hy(e,t,n,i,r,o){this._complexPreview=e,this._connectionDocking=t,this._elementFactory=n,this._eventBus=i,this._layouter=r,this._rules=o}hy.prototype.create=function(e,t,n){const i=this._complexPreview,r=this._connectionDocking,o=this._elementFactory,s=this._eventBus,a=this._layouter,c=this._rules,p=o.createShape(j({type:t},n)),u=s.fire("autoPlace",{source:e,shape:p});if(!u)return;j(p,{x:u.x-dy(p.width/2),y:u.y-dy(p.height/2)});const d=c.allowed("connection.create",{source:e,target:p,hints:{targetParent:e.parent}});let h=null;d&&(h=o.createConnection(d),h.waypoints=a.layoutConnection(h,{source:e,target:p}),h.waypoints=r.getCroppedWaypoints(h,e,p)),i.create({created:[p,h].filter((e=>!l(e)))})},hy.prototype.cleanUp=function(){this._complexPreview.cleanUp()},hy.$inject=["complexPreview","connectionDocking","elementFactory","eventBus","layouter","rules"];var my={__depends__:[fc,Hp,uy],__init__:["appendPreview"],appendPreview:["type",hy]},fy=Math.min,gy=Math.max;function yy(e){e.preventDefault()}function vy(e){e.stopPropagation()}function by(e){this.container=e.container,this.parent=fe('<div class="djs-direct-editing-parent"><div class="djs-direct-editing-content" contenteditable="true"></div></div>'),this.content=ye("[contenteditable]",this.parent),this.keyHandler=e.keyHandler||function(){},this.resizeHandler=e.resizeHandler||function(){},this.autoResize=$(this.autoResize,this),this.handlePaste=$(this.handlePaste,this)}function xy(e,t){this._eventBus=e,this._canvas=t,this._providers=[],this._textbox=new by({container:t.getContainer(),keyHandler:$(this._handleKey,this),resizeHandler:$(this._handleResize,this)})}by.prototype.create=function(e,t,n,i){var r=this.parent,o=this.content,s=this.container;i=this.options=i||{};var a=L(t=this.style=t||{},["width","height","maxWidth","maxHeight","minWidth","minHeight","left","top","backgroundColor","position","overflow","border","wordWrap","textAlign","outline","transform"]);j(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"},a);var l=L(t,["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"]);return j(o.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},l),i.centerVertically&&j(o.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},l),o.innerText=n,le.bind(o,"keydown",this.keyHandler),le.bind(o,"mousedown",vy),le.bind(o,"paste",this.handlePaste),i.autoResize&&le.bind(o,"input",this.autoResize),i.resizable&&this.resizable(t),s.appendChild(r),this.setSelection(o.lastChild,o.lastChild&&o.lastChild.length),r},by.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)}},by.prototype.insertText=function(e){e=function(e){return e.replace(/\r\n|\r|\n/g,"\n")}(e),document.execCommand("insertText",!1,e)||this._insertTextIE(e)},by.prototype._insertTextIE=function(e){var t,n,i,r=this.getSelection(),o=r.startContainer,s=r.endContainer,a=r.startOffset,l=r.endOffset,c=r.commonAncestorContainer,p=(t=c.childNodes,[].slice.call(t));if(function(e){return e.nodeType===Node.TEXT_NODE}(c)){var u=o.textContent;o.textContent=u.substring(0,a)+e+u.substring(l),n=o,i=a+e.length}else if(o===this.content&&s===this.content){var d=document.createTextNode(e);this.content.insertBefore(d,p[a]),n=d,i=d.textContent.length}else{var h=p.indexOf(o),m=p.indexOf(s);p.forEach((function(t,n){n===h?t.textContent=o.textContent.substring(0,a)+e+s.textContent.substring(l):n>h&&n<=m&&be(t)})),n=o,i=a+e.length}n&&void 0!==i&&setTimeout((function(){self.setSelection(n,i)}))},by.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})}},by.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,s=parseInt(this.style.maxHeight)||1/0;if(!n){var a,l,c,p;n=this.resizeHandle=fe('<div class="djs-direct-editing-resize-handle"></div>');var u=function(n){yy(n),vy(n);var u=fy(gy(c+n.clientX-a,i),o),d=fy(gy(p+n.clientY-l,r),s);t.style.width=u+"px",t.style.height=d+"px",e.resizeHandler({width:c,height:p,dx:n.clientX-a,dy:n.clientY-l})},d=function(e){yy(e),vy(e),le.unbind(document,"mousemove",u,!1),le.unbind(document,"mouseup",d,!1)};le.bind(n,"mousedown",(function(e){yy(e),vy(e),a=e.clientX,l=e.clientY;var n=t.getBoundingClientRect();c=n.width,p=n.height,le.bind(document,"mousemove",u),le.bind(document,"mouseup",d)}))}j(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)},by.prototype.destroy=function(){var e=this.parent,t=this.content,n=this.resizeHandle;t.innerText="",e.removeAttribute("style"),t.removeAttribute("style"),le.unbind(t,"keydown",this.keyHandler),le.unbind(t,"mousedown",vy),le.unbind(t,"input",this.autoResize),le.unbind(t,"paste",this.handlePaste),n&&(n.removeAttribute("style"),be(n)),be(e)},by.prototype.getValue=function(){return this.content.innerText.trim()},by.prototype.getSelection=function(){return window.getSelection().getRangeAt(0)},by.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)},xy.$inject=["eventBus","canvas"],xy.prototype.registerProvider=function(e){this._providers.push(e)},xy.prototype.isActive=function(e){return!(!this._active||e&&this._active.element!==e)},xy.prototype.cancel=function(){this._active&&(this._fire("cancel"),this.close())},xy.prototype._fire=function(e,t){this._eventBus.fire("directEditing."+e,t||{active:this._active})},xy.prototype.close=function(){this._textbox.destroy(),this._fire("deactivate"),this._active=null,this.resizable=void 0,this._canvas.restoreFocus&&this._canvas.restoreFocus()},xy.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()}},xy.prototype.getValue=function(){return this._textbox.getValue()},xy.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())},xy.prototype._handleResize=function(e){this._fire("resize",e)},xy.prototype.activate=function(e){var t;this.isActive()&&this.cancel();var n=f(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 wy={__depends__:[Os],__init__:["directEditing"],directEditing:["type",xy]};function _y(e){return function(t){var n=t.target,i=Or(e),r=i.eventDefinitions&&i.eventDefinitions[0],o=i.$type===n.type,s=(r&&r.$type)===n.eventDefinitionType,a=!!n.triggeredByEvent==!!i.triggeredByEvent,l=void 0===n.isExpanded||n.isExpanded===Vr(e);return!(o&&s&&a&&l)}}var Ey=[{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"}}],Oy=[{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"}}],Py=[{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"}}],ky=[{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"}}],Sy=[{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"}}],Cy=[{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}}],Ay=[{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}}],My=Ay,Ty=[{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}}],Ry=[{label:"Data store reference",actionName:"replace-with-data-store-reference",className:"bpmn-icon-data-store",target:{type:"bpmn:DataStoreReference"}}],Dy=[{label:"Data object reference",actionName:"replace-with-data-object-reference",className:"bpmn-icon-data-object",target:{type:"bpmn:DataObjectReference"}}],Ny=[{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}}],By=[{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}}],$y=[{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"}],jy=[{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}}],Iy={"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 Ly(e,t,n,i,r,o,s,a){this._bpmnFactory=e,this._popupMenu=t,this._modeling=n,this._moddle=i,this._bpmnReplace=r,this._rules=o,this._translate=s,this._moddleCopy=a,this._register()}Ly.$inject=["bpmnFactory","popupMenu","modeling","moddle","bpmnReplace","rules","translate","moddleCopy"],Ly.prototype._register=function(){this._popupMenu.registerProvider("bpmn-replace",this)},Ly.prototype.getPopupMenuEntries=function(e){var t=e.businessObject,n=this._rules,i=[];if(c(e)||!n.allowed("shape.replace",{element:e}))return{};var r=_y(e);return _r(t,"bpmn:DataObjectReference")?this._createEntries(e,Ry):_r(t,"bpmn:DataStoreReference")&&!_r(e.parent,"bpmn:Collaboration")?this._createEntries(e,Dy):_r(t,"bpmn:StartEvent")&&!_r(t.$parent,"bpmn:SubProcess")?(i=y(Ey,r),this._createEntries(e,i)):_r(t,"bpmn:Participant")?(i=y(jy,(function(t){return Vr(e)!==t.target.isExpanded})),this._createEntries(e,i)):_r(t,"bpmn:StartEvent")&&Ur(t.$parent)?(i=y(By,(function(e){var n=!1!==e.target.isInterrupting,i=t.isInterrupting===n;return r(e)||!r(e)&&!i})),this._createEntries(e,i)):_r(t,"bpmn:StartEvent")&&!Ur(t.$parent)&&_r(t.$parent,"bpmn:SubProcess")?(i=y(Oy,r),this._createEntries(e,i)):_r(t,"bpmn:EndEvent")?(i=y(ky,(function(e){return!("bpmn:CancelEventDefinition"==e.target.eventDefinitionType&&!_r(t.$parent,"bpmn:Transaction"))&&r(e)})),this._createEntries(e,i)):_r(t,"bpmn:BoundaryEvent")?(i=y(Ny,(function(e){var n=e.target;if("bpmn:CancelEventDefinition"==n.eventDefinitionType&&!_r(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)):_r(t,"bpmn:IntermediateCatchEvent")||_r(t,"bpmn:IntermediateThrowEvent")?(i=y(Py,r),this._createEntries(e,i)):_r(t,"bpmn:Gateway")?(i=y(Sy,r),this._createEntries(e,i)):_r(t,"bpmn:Transaction")?(i=y(Ay,r),this._createEntries(e,i)):Ur(t)&&Vr(e)?(i=y(My,r),this._createEntries(e,i)):_r(t,"bpmn:SubProcess")&&Vr(e)?(i=y(Cy,r),this._createEntries(e,i)):_r(t,"bpmn:AdHocSubProcess")&&!Vr(e)?(i=y(Ty,(function(e){var t=e.target,n="bpmn:SubProcess"===t.type,i=!0===t.isExpanded;return _y(t)&&(!n||i)})),this._createEntries(e,i)):_r(t,"bpmn:SequenceFlow")?this._createSequenceFlowEntries(e,$y):_r(t,"bpmn:FlowNode")?(i=y(Ty,r),_r(t,"bpmn:SubProcess")&&!Vr(e)&&(i=y(i,(function(e){return"Sub-process (collapsed)"!==e.label}))),this._createEntries(e,i)):{}},Ly.prototype.getPopupMenuHeaderEntries=function(e){var t={};return _r(e,"bpmn:Activity")&&!Ur(e)&&(t={...t,...this._getLoopCharacteristicsHeaderEntries(e)}),_r(e,"bpmn:DataObjectReference")&&(t={...t,...this._getCollectionHeaderEntries(e)}),_r(e,"bpmn:Participant")&&(t={...t,...this._getParticipantMultiplicityHeaderEntries(e)}),!_r(e,"bpmn:SubProcess")||_r(e,"bpmn:Transaction")||Ur(e)||(t={...t,...this._getAdHocHeaderEntries(e)}),_d(e)&&(t={...t,...this._getNonInterruptingHeaderEntries(e)}),t},Ly.prototype._createEntries=function(e,t){var n={},i=this;return v(t,(function(t){n[t.actionName]=i._createEntry(t,e)})),n},Ly.prototype._createSequenceFlowEntries=function(e,t){var n=Or(e),i={},r=this._modeling,o=this._moddle,s=this;return v(t,(function(t){switch(t.actionName){case"replace-with-default-flow":n.sourceRef.default!==n&&(_r(n.sourceRef,"bpmn:ExclusiveGateway")||_r(n.sourceRef,"bpmn:InclusiveGateway")||_r(n.sourceRef,"bpmn:ComplexGateway")||_r(n.sourceRef,"bpmn:Activity"))&&(i={...i,[t.actionName]:s._createEntry(t,e,(function(){r.updateProperties(e.source,{default:n})}))});break;case"replace-with-conditional-flow":!n.conditionExpression&&_r(n.sourceRef,"bpmn:Activity")&&(i={...i,[t.actionName]:s._createEntry(t,e,(function(){var t=o.create("bpmn:FormalExpression",{body:""});r.updateProperties(e,{conditionExpression:t})}))});break;default:_r(n.sourceRef,"bpmn:Activity")&&n.conditionExpression&&(i={...i,[t.actionName]:s._createEntry(t,e,(function(){r.updateProperties(e,{conditionExpression:void 0})}))}),(_r(n.sourceRef,"bpmn:ExclusiveGateway")||_r(n.sourceRef,"bpmn:InclusiveGateway")||_r(n.sourceRef,"bpmn:ComplexGateway")||_r(n.sourceRef,"bpmn:Activity"))&&n.sourceRef.default===n&&(i={...i,[t.actionName]:s._createEntry(t,e,(function(){r.updateProperties(e.source,{default:void 0})}))})}})),i},Ly.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}},Ly.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&&_r(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,s,a=Or(e).loopCharacteristics;return a&&(r=a.isSequential,o=void 0===a.isSequential,s=void 0!==a.isSequential&&!a.isSequential),{"toggle-parallel-mi":{className:"bpmn-icon-parallel-mi-marker",title:n("Parallel multi-instance"),active:s,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"}}}},Ly.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})}}}},Ly.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})}}}},Ly.prototype._getAdHocHeaderEntries=function(e){var t=this._translate,n=_r(Or(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})}}}},Ly.prototype._getNonInterruptingHeaderEntries=function(e){const t=this._translate,n=Or(e),i=this,r=Ed(e),o=_r(e,"bpmn:BoundaryEvent")?Iy["intermediate-event-non-interrupting"]:Iy["start-event-non-interrupting"],s=!n[r];return{"toggle-non-interrupting":{imageHtml:o,title:t("Toggle non-interrupting"),active:s,action:function(){i._modeling.updateProperties(e,{[r]:!!s})}}}};var qy={__depends__:[Ul,Rm,fc],__init__:["replaceMenuProvider"],replaceMenuProvider:["type",Ly]};function zy(e,t,n,i,r,o,s,a,l,c,p,u,d){e=e||{},i.registerProvider(this),this._contextPad=i,this._modeling=r,this._elementFactory=o,this._connect=s,this._create=a,this._popupMenu=l,this._canvas=c,this._rules=p,this._translate=u,this._eventBus=n,this._appendPreview=d,!1!==e.autoPlace&&(this._autoPlace=t.get("autoPlace",!1)),n.on("create.end",250,(function(e){var t=e.context.shape;if(bs(e)&&i.isOpen(t)){var n=i.getEntries(t);n.replace&&n.replace.action.click(e,t)}})),n.on("contextPad.close",(function(){d.cleanUp()}))}function Vy(e,t,n){var i=e.$instanceOf(t),r=!1;return v(e.eventDefinitions||[],(function(e){e.$type===n&&(r=!0)})),i&&r}zy.$inject=["config.contextPad","injector","eventBus","contextPad","modeling","elementFactory","connect","create","popupMenu","canvas","rules","translate","appendPreview"],zy.prototype.getMultiElementContextPadEntries=function(e){var t=this._modeling,n={};return this._isDeleteAllowed(e)&&j(n,{delete:{group:"edit",className:"bpmn-icon-trash",title:this._translate("Delete"),action:{click:function(e,n){t.removeElements(n.slice())}}}}),n},zy.prototype._isDeleteAllowed=function(e){var t=this._rules.allowed("elements.delete",{elements:e});return c(t)?w(e,(e=>t.includes(e))):t},zy.prototype.getContextPadEntries=function(e){var t=this._contextPad,n=this._modeling,i=this._elementFactory,r=this._connect,o=this._create,s=this._popupMenu,a=this._autoPlace,l=this._translate,c=this._appendPreview,p={};if("label"===e.type)return this._isDeleteAllowed([e])&&j(p,m()),p;var u=e.businessObject;function d(e,t){r.start(e,t)}function h(e,t){n.removeElements([t])}function m(){return{delete:{group:"edit",className:"bpmn-icon-trash",title:l("Delete"),action:{click:h}}}}function f(e,t,n,r){function s(t,n){var s=i.createShape(j({type:e},r));o.start(t,s,{source:n})}var l=a?function(t,n){var o=i.createShape(j({type:e},r));a.append(n,o)}:s,p=a?function(t,n){return c.create(n,e,r),()=>{c.cleanUp()}}:null;return{group:"model",className:t,title:n,action:{dragstart:s,click:l,hover:p}}}function g(e){return function(i,r){n.splitLane(r,e),t.open(r,!0)}}if(Er(u,["bpmn:Lane","bpmn:Participant"])&&Vr(e)){var y=Cu(e);j(p,{"lane-insert-above":{group:"lane-insert-above",className:"bpmn-icon-lane-insert-above",title:l("Add lane above"),action:{click:function(e,t){n.addLane(t,"top")}}}}),y.length<2&&((Fr(e)?e.height>=120:e.width>=120)&&j(p,{"lane-divide-two":{group:"lane-divide",className:"bpmn-icon-lane-divide-two",title:l("Divide into two lanes"),action:{click:g(2)}}}),(Fr(e)?e.height>=180:e.width>=180)&&j(p,{"lane-divide-three":{group:"lane-divide",className:"bpmn-icon-lane-divide-three",title:l("Divide into three lanes"),action:{click:g(3)}}})),j(p,{"lane-insert-below":{group:"lane-insert-below",className:"bpmn-icon-lane-insert-below",title:l("Add lane below"),action:{click:function(e,t){n.addLane(t,"bottom")}}}})}return _r(u,"bpmn:FlowNode")&&(_r(u,"bpmn:EventBasedGateway")?j(p,{"append.receive-task":f("bpmn:ReceiveTask","bpmn-icon-receive-task",l("Append receive task")),"append.message-intermediate-event":f("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-message",l("Append message intermediate catch event"),{eventDefinitionType:"bpmn:MessageEventDefinition"}),"append.timer-intermediate-event":f("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-timer",l("Append timer intermediate catch event"),{eventDefinitionType:"bpmn:TimerEventDefinition"}),"append.condition-intermediate-event":f("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-condition",l("Append conditional intermediate catch event"),{eventDefinitionType:"bpmn:ConditionalEventDefinition"}),"append.signal-intermediate-event":f("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-signal",l("Append signal intermediate catch event"),{eventDefinitionType:"bpmn:SignalEventDefinition"})}):Vy(u,"bpmn:BoundaryEvent","bpmn:CompensateEventDefinition")?j(p,{"append.compensation-activity":f("bpmn:Task","bpmn-icon-task",l("Append compensation activity"),{isForCompensation:!0})}):_r(u,"bpmn:EndEvent")||u.isForCompensation||Vy(u,"bpmn:IntermediateThrowEvent","bpmn:LinkEventDefinition")||Ur(u)||j(p,{"append.end-event":f("bpmn:EndEvent","bpmn-icon-end-event-none",l("Append end event")),"append.gateway":f("bpmn:ExclusiveGateway","bpmn-icon-gateway-none",l("Append gateway")),"append.append-task":f("bpmn:Task","bpmn-icon-task",l("Append task")),"append.intermediate-event":f("bpmn:IntermediateThrowEvent","bpmn-icon-intermediate-event-none",l("Append intermediate/boundary event"))})),s.isEmpty(e,"bpmn-replace")||j(p,{replace:{group:"edit",className:"bpmn-icon-screw-wrench",title:l("Change element"),action:{click:function(e,n){var i=j(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}});s.open(n,"bpmn-replace",i,{title:l("Change element"),width:300,search:!0})}}}}),_r(u,"bpmn:SequenceFlow")&&j(p,{"append.text-annotation":f("bpmn:TextAnnotation","bpmn-icon-text-annotation",l("Add text annotation"))}),Er(u,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference"])&&j(p,{"append.text-annotation":f("bpmn:TextAnnotation","bpmn-icon-text-annotation",l("Add text annotation")),connect:{group:"connect",className:"bpmn-icon-connection-multi",title:l("Connect to other element"),action:{click:d,dragstart:d}}}),_r(u,"bpmn:TextAnnotation")&&j(p,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:l("Connect using association"),action:{click:d,dragstart:d}}}),Er(u,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&j(p,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:l("Connect using data input association"),action:{click:d,dragstart:d}}}),_r(u,"bpmn:Group")&&j(p,{"append.text-annotation":f("bpmn:TextAnnotation","bpmn-icon-text-annotation",l("Add text annotation"))}),this._isDeleteAllowed([e])&&j(p,m()),p};var Fy={__depends__:[my,wy,Aa,Ts,Np,um,qy],__init__:["contextPadProvider"],contextPadProvider:["type",zy]},Hy={horizontal:["x","width"],vertical:["y","height"]};function Uy(e,t){this._modeling=e,this._filters=[],this.registerFilter((function(e){var n=t.allowed("elements.distribute",{elements:e});return c(n)?n:n?e:[]}))}Uy.$inject=["modeling","rules"],Uy.prototype.registerFilter=function(e){if("function"!=typeof e)throw new Error("the filter has to be a function");this._filters.push(e)},Uy.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},Uy.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},Uy.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 s,a=n._findRange(e,i,r),l=t[t.length-1];l&&n._hasIntersection(l.range,a)?t[t.length-1].elements.push(e):(s={range:a,elements:[e]},t.push(s))})),t},Uy.prototype._setOrientation=function(e){var t=Hy[e];this._axis=t[0],this._dimension=t[1]},Uy.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)},Uy.prototype._findRange=function(e){var t=e[this._axis];return{min:t+5,max:t+e[this._dimension]-5}};var Wy={__init__:["distributeElements"],distributeElements:["type",Uy]};function Gy(e){Kl.call(this,e)}Gy.$inject=["eventBus"],e(Gy,Kl),Gy.prototype.init=function(){this.addRule("elements.distribute",(function(e){var t=e.elements;return!((t=dt(t=y(t,(function(e){var t=Er(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 Qy={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 Xy(e,t,n,i){this._distributeElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",900,this)}Xy.$inject=["popupMenu","distributeElements","translate","rules"],Xy.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&j(t,this._getEntries(e)),t},Xy.prototype._isAllowed=function(e){return this._rules.allowed("elements.distribute",{elements:e})},Xy.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:Qy.horizontal,action:function(n,r){t.trigger(e,"horizontal"),i.close()}},"distribute-elements-vertical":{group:"distribute",title:n("Distribute elements vertically"),imageHtml:Qy.vertical,action:function(n,r){t.trigger(e,"vertical"),i.close()}}}};var Ky={__depends__:[Ul,Wy],__init__:["bpmnDistributeElements","distributeElementsMenuProvider"],bpmnDistributeElements:["type",Gy],distributeElementsMenuProvider:["type",Xy]},Yy="is not a registered action";function Zy(e,t){this._actions={};var n=this;e.on("diagram.init",(function(){n._registerDefaultActions(t),e.fire("editorActions.init",{editorActions:n})}))}function Jy(e,t){return new Error(e+" "+t)}Zy.$inject=["eventBus","injector"],Zy.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),s=e.get("canvas",!1),a=e.get("rules",!1),l=e.get("keyboardMove",!1),p=e.get("keyboardMoveSelection",!1);t&&(this.register("undo",(function(){t.undo()})),this.register("redo",(function(){t.redo()}))),o&&i&&this.register("copy",(function(){var e=i.get();if(e.length)return o.copy(e)})),o&&this.register("paste",(function(){o.paste()})),r&&this.register("stepZoom",(function(e){r.stepZoom(e.value)})),s&&this.register("zoom",(function(e){s.zoom(e.value)})),n&&i&&a&&this.register("removeSelection",(function(){var e=i.get();if(e.length){var t,r=a.allowed("elements.delete",{elements:e});!1!==r&&(t=c(r)?r:e).length&&n.removeElements(t.slice())}})),l&&this.register("moveCanvas",(function(e){l.moveCanvas(e)})),p&&this.register("moveSelection",(function(e){p.moveSelection(e.direction,e.accelerated)}))},Zy.prototype.trigger=function(e,t){if(!this._actions[e])throw Jy(e,Yy);return this._actions[e](t)},Zy.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)}))},Zy.prototype._registerAction=function(e,t){if(this.isRegistered(e))throw Jy(e,"is already registered");this._actions[e]=t},Zy.prototype.unregister=function(e){if(!this.isRegistered(e))throw Jy(e,Yy);this._actions[e]=void 0},Zy.prototype.getActions=function(){return Object.keys(this._actions)},Zy.prototype.isRegistered=function(e){return!!this._actions[e]};var ev={__init__:["editorActions"],editorActions:["type",Zy]};function tv(e){e.invoke(Zy,this)}e(tv,Zy),tv.$inject=["injector"],tv.prototype._registerDefaultActions=function(e){Zy.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),s=e.get("handTool",!1),a=e.get("globalConnect",!1),l=e.get("distributeElements",!1),c=e.get("alignElements",!1),p=e.get("directEditing",!1),u=e.get("searchPad",!1),d=e.get("modeling",!1),h=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()})),s&&this._registerAction("handTool",(function(){s.toggle()})),a&&this._registerAction("globalConnectTool",(function(){a.toggle()})),i&&l&&this._registerAction("distributeElements",(function(e){var t=i.get(),n=e.type;t.length&&l.trigger(t,n)})),i&&c&&this._registerAction("alignElements",(function(e){var t=i.get(),n=[],r=e.type;t.length&&(n=y(t,(function(e){return!_r(e,"bpmn:Lane")})),c.trigger(n,r))})),i&&d&&this._registerAction("setColor",(function(e){var t=i.get();t.length&&d.setColor(t,e)})),i&&p&&this._registerAction("directEditing",(function(){var e=i.get();e.length&&p.activate(e[0])})),u&&this._registerAction("find",(function(){u.toggle()})),t&&d&&this._registerAction("moveToOrigin",(function(){var e,i,r=t.getRootElement();e=yt(i=_r(r,"bpmn:Collaboration")?n.filter((function(e){return _r(e.parent,"bpmn:Collaboration")})):n.filter((function(e){return e!==r&&!_r(e.parent,"bpmn:SubProcess")}))),d.moveElements(i,{x:-e.x,y:-e.y},r)})),i&&h&&this._registerAction("replaceElement",(function(e){h.triggerEntry("replace","click",e)}))};var nv={__depends__:[ev],editorActions:["type",tv]};function iv(e){e.on(["create.init","shape.move.init"],(function(e){var t=e.context;Er(e.shape,["bpmn:Participant","bpmn:SubProcess","bpmn:TextAnnotation"])&&(t.gridSnappingContext||(t.gridSnappingContext={}),t.gridSnappingContext.snapLocation="top-left")}))}iv.$inject=["eventBus"];var rv=10;function ov(e,t,n){return n||(n="round"),Math[n](e/t)*t}function sv(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&&js(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,s=o.snapLocation,a=o.snapOffset;if(a&&u(a[t]))return a[t];a||(a=o.snapOffset={});u(a[t])||(a[t]=0);if(!r)return a[t];n.get(r.id)||(av(t)?a[t]+=r[t]+r.width/2:a[t]+=r[t]+r.height/2);if(!s)return a[t];"x"===t?/left/.test(s)?a[t]-=r.width/2:/right/.test(s)&&(a[t]+=r.width/2):/top/.test(s)?a[t]-=r.height/2:/bottom/.test(s)&&(a[t]+=r.height/2);return a[t]}(t,n,e);o&&(i.offset=o);var s=function(e,t){var n=e.context,i=n.createConstraints,r=n.resizeConstraints||{},o=n.gridSnappingContext,s=o.snapConstraints;if(s&&s[t])return s[t];s||(s=o.snapConstraints={});s[t]||(s[t]={});var a=n.direction;i&&(av(t)?(s.x.min=i.left,s.x.max=i.right):(s.y.min=i.top,s.y.max=i.bottom));var l=r.min,c=r.max;l&&(av(t)?cv(a)?s.x.max=l.left:s.x.min=l.right:lv(a)?s.y.max=l.top:s.y.min=l.bottom);c&&(av(t)?cv(a)?s.x.min=c.left:s.x.max=c.right:lv(a)?s.y.min=c.top:s.y.max=c.bottom);return s[t]}(t,n);s&&j(i,s),_p(t,n)||r.snapEvent(t,n,i)}))}}))}function av(e){return"x"===e}function lv(e){return-1!==e.indexOf("n")}function cv(e){return-1!==e.indexOf("w")}function pv(e,t){Fo.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;h(i)?t.newBounds=n.snapComplex(o,i):t.newBounds=n.snapSimple(r,o)}}))}sv.prototype.snapEvent=function(e,t,n){Ep(e,t,this.snapValue(e[t],n))},sv.prototype.getGridSpacing=function(){return rv},sv.prototype.snapValue=function(e,t){var n,i,r=0;return t&&t.offset&&(r=t.offset),e=ov(e+=r,rv),t&&t.min&&u(n=t.min)&&(n=ov(n+r,rv,"ceil"),e=Math.max(e,n)),t&&t.max&&u(i=t.max)&&(i=ov(i+r,rv,"floor"),e=Math.min(e,i)),e-=r},sv.prototype.isActive=function(){return this.active},sv.prototype.setActive=function(e){this.active=e,this._eventBus.fire("gridSnapping.toggle",{active:e})},sv.prototype.toggleActive=function(){this.setActive(!this.active)},sv.$inject=["elementRegistry","eventBus","config.gridSnapping"],pv.$inject=["eventBus","gridSnapping","modeling"],e(pv,Fo),pv.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},pv.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},pv.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),j(e,o),e},pv.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),j(e,o),e};function uv(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))}))}uv.$inject=["eventBus","gridSnapping"];var dv={__depends__:[{__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",pv],gridSnappingSpaceToolBehavior:["type",uv]}],__init__:["gridSnapping"],gridSnapping:["type",sv]};function hv(e,t,n){e.on("autoPlace",2e3,(function(e){var i=e.source,r=bn(i),o=e.shape,s=dc(i,o,n);return["x","y"].forEach((function(e){var n={};s[e]!==r[e]&&(s[e]>r[e]?n.min=s[e]:n.max=s[e],_r(o,"bpmn:TextAnnotation")&&(!function(e){return"x"===e}(e)?n.offset=-o.height/2:n.offset=-o.width/2),s[e]=t.snapValue(s[e],n))})),s}))}hv.$inject=["eventBus","gridSnapping","elementRegistry"];function mv(e,t,n){t.on(["create.start","shape.move.start"],1750,(function(t){var i=t.context,r=i.shape,o=e.getRootElement();_r(r,"bpmn:Participant")&&_r(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})))}))}mv.$inject=["canvas","eventBus","gridSnapping"];function fv(e,t,n){Fo.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||{},s=r.waypoints;o.connectionStart||o.connectionEnd||!1===o.createElementsBehavior||function(e){return e.length>3}(s)&&n.updateWaypoints(r,i.snapMiddleSegments(s))}))}function gv(e,t,n){var i=At(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=j({},t,r),n=j({},n,r)),[t,n]}fv.$inject=["eventBus","gridSnapping","modeling"],e(fv,Fo),fv.prototype.snapMiddleSegments=function(e){var t,n=this._gridSnapping;e=e.slice();for(var i=1;i<e.length-2;i++)t=gv(n,e[i],e[i+1]),e[i]=t[0],e[i+1]=t[1];return e};var yv={__depends__:[dv,{__init__:["gridSnappingAutoPlaceBehavior","gridSnappingParticipantBehavior","gridSnappingLayoutConnectionBehavior"],gridSnappingAutoPlaceBehavior:["type",hv],gridSnappingParticipantBehavior:["type",mv],gridSnappingLayoutConnectionBehavior:["type",fv]}],__init__:["bpmnGridSnapping"],bpmnGridSnapping:["type",iv]};function vv(e,t){this._interactionEvents=t;var n=this;e.on(["interactionEvents.createHit","interactionEvents.updateHit"],(function(e){var t=e.element,i=e.gfx;return _r(t,"bpmn:Lane")?n._createParticipantHit(t,i):_r(t,"bpmn:Participant")?Vr(t)?n._createParticipantHit(t,i):n._createDefaultHit(t,i):_r(t,"bpmn:SubProcess")?Vr(t)?n._createSubProcessHit(t,i):n._createDefaultHit(t,i):void 0}))}vv.$inject=["eventBus","interactionEvents"],vv.prototype._createDefaultHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createDefaultHit(e,t),!0},vv.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=Fr(e)?{width:30,height:e.height}:{width:e.width,height:30};return this._interactionEvents.createBoxHit(t,"all",n),!0},vv.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 bv={__init__:["bpmnInteractionEvents"],bpmnInteractionEvents:["type",vv]};function xv(e){e.invoke(Ws,this)}e(xv,Ws),xv.$inject=["injector"],xv.prototype.registerBindings=function(e,t){function n(n,i){t.isRegistered(n)&&e.addListener(i)}Ws.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 wv={__depends__:[Gs],__init__:["keyboardBindings"],keyboardBindings:["type",xv]},_v={moveSpeed:1,moveSpeedAccelerated:10},Ev="left",Ov="right",Pv="down",kv={ArrowLeft:Ev,Left:Ev,ArrowUp:"up",Up:"up",ArrowRight:Ov,Right:Ov,ArrowDown:Pv,Down:Pv},Sv={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 Cv(e,t,n,i,r){var o=this;this._config=j({},_v,e||{}),t.addListener(1500,(function(e){var n=e.keyEvent,i=kv[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 s=this._config[t?"moveSpeedAccelerated":"moveSpeed"],a=Sv[e](s);i.allowed("elements.move",{shapes:o})&&n.moveElements(o,a)}}}Cv.$inject=["config.keyboardMoveSelection","keyboard","modeling","rules","selection"];var Av={__depends__:[Gs,Ts],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",Cv]};function Mv(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,s=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=gn(e);return yn({top:xu("top",n,t),right:xu("right",n,t),bottom:xu("bottom",n,t),left:xu("left",n,t)})}(n,s),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:gn(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=mn(r)))return;n.resizeShape(t,r)}}(e.context)}))}function Tv(e,t){var n=bn(e),i=gn(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 Rv(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"}Mv.prototype.canResize=function(e){var t=this._rules,n=L(e,["newBounds","shape","delta","direction"]);return t.allowed("shape.resize",n)},Mv.prototype.activate=function(e,t,n){var i,r,o=this._dragging;if("string"==typeof n&&(n={direction:n}),!(r=(i=j({shape:t},n)).direction))throw new Error("must provide a direction (n|w|s|e|nw|se|ne|sw)");o.init(e,Tv(t,r),"resize",{autoActivate:!0,cursor:Rv(r),data:{shape:t,context:i}})},Mv.prototype.computeMinResizeBox=function(e){var t=e.shape;return function(e,t,n,i){var r=gn(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},s=i?gn(i):o;return yn({top:yu(o.top,s.top),left:yu(o.left,s.left),bottom:gu(o.bottom,s.bottom),right:gu(o.right,s.right)})}(e.direction,t,e.minDimensions||{width:10,height:10},Eu(t,e.childrenBoxPadding))},Mv.$inject=["eventBus","rules","modeling","dragging"];var Dv="djs-resizing",Nv="resize-not-ok";function Bv(e,t,n){e.on("resize.move",500,(function(e){var i,r,o,s;i=e.context,r=i.shape,o=i.newBounds,(s=i.frame)||(s=i.frame=n.addFrame(r,t.getActiveLayer()),t.addMarker(r,Dv)),o.width>5&&Oe(s,{x:o.x,width:o.width}),o.height>5&&Oe(s,{y:o.y,height:o.height}),i.canExecute?ke(s).remove(Nv):ke(s).add(Nv)})),e.on("resize.cleanup",(function(e){var n,i;n=e.context,i=n.shape,n.frame&&He(n.frame),t.removeMarker(i,Dv)}))}Bv.$inject=["eventBus","canvas","previewSupport"];var $v=-6,jv="djs-resizer",Iv=["n","w","s","e","nw","ne","se","sw"];function Lv(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,$(r.addResizer,r))})),e.on("shape.changed",(function(e){var t=e.element;n.isSelected(t)&&(r.removeResizers(),r.addResizer(t))}))}Lv.prototype.makeDraggable=function(e,t,n){var i=this._resize;function r(t){vs(t)&&i.activate(t,e,n)}le.bind(t,"mousedown",r),le.bind(t,"touchstart",r)},Lv.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=$v);-1!==e.indexOf("s")?t.y=6:-1!==e.indexOf("n")&&(t.y=$v);return t}(i),s=De("g");ke(s).add(jv),ke(s).add(jv+"-"+e.id),ke(s).add(jv+"-"+i),xe(r,s);var a=De("rect");Oe(a,{x:-4+o.x,y:-4+o.y,width:8,height:8}),ke(a).add(jv+"-visual"),xe(s,a);var l=De("rect");return Oe(l,{x:-10+o.x,y:-10+o.y,width:20,height:20}),ke(l).add(jv+"-hit"),xe(s,l),Xn(s,t,n),s},Lv.prototype.createResizer=function(e,t){var n=Tv(e,t),i=this._createResizer(e,n.x,n.y,t);this.makeDraggable(e,i,t)},Lv.prototype.addResizer=function(e){var t=this;!dn(e)&&this._resize.canResize({shape:e})&&v(Iv,(function(n){t.createResizer(e,n)}))},Lv.prototype.removeResizers=function(){Ce(this._getResizersParent())},Lv.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")},Lv.$inject=["eventBus","canvas","selection","resize"];var qv={__depends__:[Rc,Sc,zp],__init__:["resize","resizePreview","resizeHandles"],resize:["type",Mv],resizePreview:["type",Bv],resizeHandles:["type",Lv]};function zv(e,t,n,i,r,o,s){function a(e,t){(t||Er(e,["bpmn:Task","bpmn:TextAnnotation","bpmn:Participant"])||Vv(e))&&i.activate(e)}this._bpmnFactory=t,this._canvas=n,this._modeling=r,this._textRenderer=s,i.registerProvider(this),e.on("element.dblclick",(function(e){a(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||a(n))})),e.on("autoPlace.end",500,(function(e){a(e.shape)}))}function Vv(e){return _r(e,"bpmn:SubProcess")&&!Vr(e)}zv.$inject=["eventBus","bpmnFactory","canvas","directEditing","modeling","resizeHandles","textRenderer"],zv.prototype.activate=function(e){var t=eo(e);if(void 0!==t){var n={text:t};j(n,this.getEditingBBox(e));var i={},r=n.style||{};return j(r,{backgroundColor:null,border:null}),(Er(e,["bpmn:Task","bpmn:Participant","bpmn:Lane","bpmn:CallActivity"])||Vv(e))&&j(i,{centerVertically:!0}),Xr(e)&&(j(i,{autoResize:!0}),j(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),_r(e,"bpmn:TextAnnotation")&&(j(i,{resizable:!0,autoResize:!0}),j(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),j(n,{options:i,style:r}),n}},zv.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,s={x:i.x,y:i.y},a=t.zoom(),l=this._textRenderer.getDefaultStyle(),c=this._textRenderer.getExternalStyle(),p=c.fontSize*a,u=c.lineHeight,d=l.fontSize*a,h=l.lineHeight,m={fontFamily:this._textRenderer.getDefaultStyle().fontFamily,fontWeight:this._textRenderer.getDefaultStyle().fontWeight};if(_r(e,"bpmn:Lane")||function(e){return _r(e,"bpmn:Participant")&&Vr(e)}(e)){var f=Fr(e);j(s,f?{width:i.height,height:30*a,x:i.x-i.height/2+15*a,y:o-30*a/2}:{width:i.width,height:30*a}),j(m,{fontSize:d+"px",lineHeight:h,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px",transform:f?"rotate(-90deg)":null})}if(function(e){return _r(e,"bpmn:Participant")&&!Vr(e)}(e)){var g=Fr(e);j(s,g?{width:i.width,height:i.height}:{width:i.height,height:i.width,x:r-i.height/2,y:o-i.width/2}),j(m,{fontSize:d+"px",lineHeight:h,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px",transform:g?null:"rotate(-90deg)"})}(Er(e,["bpmn:Task","bpmn:CallActivity"])||Vv(e))&&(j(s,{width:i.width,height:i.height}),j(m,{fontSize:d+"px",lineHeight:h,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px"})),function(e){return _r(e,"bpmn:SubProcess")&&Vr(e)}(e)&&(j(s,{width:i.width,x:i.x}),j(m,{fontSize:d+"px",lineHeight:h,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px"}));var y=90*a,v=7*a,b=4*a;if(n.labelTarget&&(j(s,{width:y,height:i.height+v+b,x:r-y/2,y:i.y-v}),j(m,{fontSize:p+"px",lineHeight:u,paddingTop:v+"px",paddingBottom:b+"px"})),Xr(n)&&!Kr(n)&&!hn(n)){var x=Zr(e),w=t.getAbsoluteBBox({x:x.x,y:x.y,width:0,height:0}),_=p+v+b;j(s,{width:y,height:_,x:w.x-y/2,y:w.y-_/2}),j(m,{fontSize:p+"px",lineHeight:u,paddingTop:v+"px",paddingBottom:b+"px"})}return _r(e,"bpmn:TextAnnotation")&&(j(s,{width:i.width,height:i.height,minWidth:30*a,minHeight:10*a}),j(m,{textAlign:"left",paddingTop:5*a+"px",paddingBottom:7*a+"px",paddingLeft:7*a+"px",paddingRight:5*a+"px",fontSize:d+"px",lineHeight:h})),{bounds:s,style:m}},zv.prototype.update=function(e,t,n,i){var r,o,s;_r(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}),(s=t)&&s.trim()||(t=null),this._modeling.updateLabel(e,t,r)};var Fv="djs-element-hidden",Hv="djs-label-hidden";function Uv(e,t,n){var i,r,o,s=this,a=t.getDefaultLayer();e.on("directEditing.activate",(function(e){var l=e.active;if(_r(i=l.element.label||l.element,"bpmn:TextAnnotation")){r=t.getAbsoluteBBox(i),o=De("g");var c=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:i.width,containerHeight:i.height,position:{mx:0,my:0}}),p=s.path=De("path");Oe(p,{d:c,strokeWidth:2,stroke:Wv(i)}),xe(o,p),xe(a,o),Kn(o,i.x,i.y)}_r(i,"bpmn:TextAnnotation")||i.labelTarget?t.addMarker(i,Fv):(_r(i,"bpmn:Task")||_r(i,"bpmn:CallActivity")||_r(i,"bpmn:SubProcess")||_r(i,"bpmn:Participant")||_r(i,"bpmn:Lane"))&&t.addMarker(i,Hv)})),e.on("directEditing.resize",(function(e){if(_r(i,"bpmn:TextAnnotation")){var t=e.height,o=e.dy,a=Math.max(i.height/r.height*(t+o),0),l=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:i.width,containerHeight:a,position:{mx:0,my:0}});Oe(s.path,{d:l})}})),e.on(["directEditing.complete","directEditing.cancel"],(function(e){var n=e.active;n&&(t.removeMarker(n.element.label||n.element,Fv),t.removeMarker(i,Hv)),i=void 0,r=void 0,o&&(He(o),o=void 0)}))}function Wv(e,t){return Pr(e).get("stroke")||t||"black"}Uv.$inject=["eventBus","canvas","pathMap"];var Gv={__depends__:[Vo,qv,wy],__init__:["labelEditingProvider","labelEditingPreview"],labelEditingProvider:["type",zv],labelEditingPreview:["type",Uv]},Qv=new No("tt");function Xv(e,t){e.style.display=!1===t?"none":""}var Kv="djs-tooltip",Yv="."+Kv;function Zv(e,t){var n,i;this._eventBus=e,this._canvas=t,this._ids=Qv,this._tooltipDefaults={show:{minZoom:.7,maxZoom:5}},this._tooltips={},this._tooltipRoot=(n=t.getContainer(),Q(i=fe('<div class="djs-tooltip-container" />'),{position:"absolute",width:"0",height:"0"}),n.insertBefore(i,n.firstChild),i);var r=this;ue.bind(this._tooltipRoot,Yv,"mousedown",(function(e){e.stopPropagation()})),ue.bind(this._tooltipRoot,Yv,"mouseover",(function(e){r.trigger("mouseover",e)})),ue.bind(this._tooltipRoot,Yv,"mouseout",(function(e){r.trigger("mouseout",e)})),this._init()}Zv.$inject=["eventBus","canvas"],Zv.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=j({},this._tooltipDefaults,e,{id:t}),this._addTooltip(e),e.timeout&&this.setTimeout(e),t},Zv.prototype.trigger=function(e,t){var n=t.delegateTarget||t.target,i=this.get(X(n,"data-tooltip-id"));i&&("mouseover"===e&&i.timeout&&this.clearTimeout(i),"mouseout"===e&&i.timeout&&(i.timeout=1e3,this.setTimeout(i)))},Zv.prototype.get=function(e){return"string"!=typeof e&&(e=e.id),this._tooltips[e]},Zv.prototype.clearTimeout=function(e){if(e=this.get(e)){var t=e.removeTimer;t&&(clearTimeout(t),e.removeTimer=null)}},Zv.prototype.setTimeout=function(e){if(e=this.get(e)){this.clearTimeout(e);var t=this;e.removeTimer=setTimeout((function(){t.remove(e)}),e.timeout)}},Zv.prototype.remove=function(e){var t=this.get(e);t&&(be(t.html),be(t.htmlContainer),delete t.htmlContainer,delete this._tooltips[t.id])},Zv.prototype.show=function(){Xv(this._tooltipRoot)},Zv.prototype.hide=function(){Xv(this._tooltipRoot,!1)},Zv.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},Zv.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)),h(i)&&(i=fe(i)),Q(t=fe('<div data-tooltip-id="'+n+'" class="'+Kv+'">'),{position:"absolute"}),t.appendChild(i),e.type&&Y(t).add("djs-tooltip-"+e.type),e.className&&Y(t).add(e.className),e.htmlContainer=t,r.appendChild(t),this._tooltips[n]=e,this._updateTooltip(e)},Zv.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)},Zv.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),Xv(i,r))}))},Zv.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 Jv={__init__:["tooltips"],tooltips:["type",Zv]};function eb(e,t,n){e.on(["shape.move.rejected","create.rejected"],(function(e){var i,r,o=e.context,s=o.shape;_r(o.target,"bpmn:Collaboration")&&_r(s,"bpmn:FlowNode")&&(i=e,r=n("flow elements must be children of pools/participants"),t.add({position:{x:i.x+5,y:i.y+5},type:"error",timeout:2e3,html:"<div>"+r+"</div>"}))}))}eb.$inject=["eventBus","tooltips","translate"];var tb={__depends__:[Jv],__init__:["modelingFeedback"],modelingFeedback:["type",eb]};function nb(e,t){this._eventBus=e,this.offset=5;var n=t.cls("djs-outline",["no-fill"]),i=this;function r(e){var t=De("rect");return Oe(t,j({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=ye(".djs-outline",n);o||xe(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=ye(".djs-outline",n);o||xe(n,o=r()),i.updateConnectionOutline(o,t)}))}nb.prototype.updateShapeOutline=function(e,t){var n=!1,i=this._getProviders();i.length&&v(i,(function(i){n=n||i.updateOutline(t,e)})),n||Oe(e,{x:-this.offset,y:-this.offset,width:t.width+2*this.offset,height:t.height+2*this.offset})},nb.prototype.updateConnectionOutline=function(e,t){var n=yt(t);Oe(e,{x:n.x-this.offset,y:n.y-this.offset,width:n.width+2*this.offset,height:n.height+2*this.offset})},nb.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("outline.getProviders",e,(function(e){e.providers.push(t)}))},nb.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"outline.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},nb.prototype.getOutline=function(e){var t;return v(this._getProviders(),(function(n){d(n.getOutline)&&(t=t||n.getOutline(e))})),t},nb.$inject=["eventBus","styles","elementRegistry"];function ib(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)}))}ib.prototype._updateMultiSelectionOutline=function(e){var t=this._canvas.getLayer("selectionOutline");Ce(t);var n=e.length>1;if(ke(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}}(yt(e)),r=De("rect");Oe(r,j({rx:3},i)),ke(r).add("djs-selection-outline"),xe(t,r)}},ib.$inject=["eventBus","canvas","selection"];var rb={__depends__:[Ts],__init__:["outline","multiSelectionOutline"],outline:["type",nb],multiSelectionOutline:["type",ib]},ob=Math.round;function sb(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 s(e,n,i,r){if(p(i)&&(r=i,i=!1),!n.waypoints&&n.parent&&!ke(e.target).has("djs-hit-no-move")){var o=function(e){return{x:e.x+ob(e.width/2),y:e.y+ob(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 y(e,(function(e){for(;e=e.parent;)if(t[e.id])return!1;return!0}))}(r),j(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,s={x:e.dx,y:e.dy};t=o(i,s,{x:e.x,y:e.y},r),n.delta=s,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,s=t.shapes;if(!1===r)return!1;i.x=ob(i.x),i.y=ob(i.y),0===i.x&&0===i.y||n.moveElements(s,i,t.target,{primaryShape:t.shape,attach:o})})),e.on("element.mousedown",(function(e){if(vs(e)){var t=hs(e);if(!t)throw new Error("must supply DOM mousedown event");return s(t,e.element)}})),this.start=s}sb.$inject=["eventBus","dragging","modeling","selection","rules"];var ab="djs-dragging",lb="drop-ok",cb="drop-not-ok",pb="new-parent",ub="attach-ok";function db(e,t,n,r){function o(e){var t=function(e){var t=y(e,(function(t){return!dn(t)||f(e,M({id:t.source.id}))&&f(e,M({id:t.target.id}))}));return t}(s(e));return t}function s(e){var t=gt(e,!0),n=t.flatMap((e=>(e.incoming||[]).concat(e.outgoing||[]))),i=t.concat(n);return[...new Set(i)]}function a(e,n){[ub,lb,cb,pb].forEach((function(i){i===n?t.addMarker(e,i):t.removeMarker(e,i)}))}e.on("shape.move.start",499,(function(e){var a,l=e.context,c=l.shapes,p=l.allDraggedElements,u=o(c);if(!l.dragGroup){var d=De("g");Oe(d,n.cls("djs-drag-group",["no-events"])),xe(t.getActiveLayer(),d),l.dragGroup=d}u.forEach((function(e){r.addDragger(e,l.dragGroup)})),v(p=p?i([p,s(c)]):s(c),(function(e){t.addMarker(e,ab)})),l.allDraggedElements=p,l.differentParents=1!==(a=k(c,(function(e){return e.parent&&e.parent.id})),O(a).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?a(i,ub):t.canExecute&&r&&i.id!==r.id?a(i,pb):a(i,t.canExecute?lb:cb)),Kn(n,e.dx,e.dy)})),e.on(["shape.move.out","shape.move.cleanup"],(function(e){var t=e.context.target;t&&a(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,ab)})),r&&He(r)})),this.makeDraggable=function(e,n,i){r.addDragger(n,e.dragGroup),i&&t.addMarker(n,ab),e.allDraggedElements?e.allDraggedElements.push(n):e.allDraggedElements=[n]}}db.$inject=["eventBus","canvas","styles","previewSupport"];var hb={__depends__:[Os,Ts,rb,Rc,Sc,zp],__init__:["move","movePreview"],move:["type",sb],movePreview:["type",db]},mb=".djs-palette-toggle",fb=".entry",gb=mb+", "+fb,yb="djs-palette-",vb="open",bb="two-column";function xb(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 wb(e,t){var n=t.getPaletteEntries();return d(n)?n(e):(v(n,(function(t,n){e[n]=t})),e)}xb.$inject=["eventBus","canvas"],xb.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("palette.getProviders",e,(function(e){e.providers.push(t)})),this._rebuild()},xb.prototype.getEntries=function(){return this._getProviders().reduce(wb,{})},xb.prototype._rebuild=function(){this._diagramInitialized&&(this._getProviders().length&&(this._container||this._init(),this._update()))},xb.prototype._init=function(){var e=this,t=this._eventBus,n=this._getParentContainer(),i=this._container=fe(xb.HTML_MARKUP);n.appendChild(i),Y(n).add(yb+"shown"),ue.bind(i,gb,"click",(function(t){if(ge(t.delegateTarget,mb))return e.toggle();e.trigger("click",t)})),le.bind(i,"mousedown",(function(e){e.stopPropagation()})),ue.bind(i,fb,"dragstart",(function(t){e.trigger("dragstart",t)})),t.on("canvas.resized",this._layoutChanged,this),t.fire("palette.create",{container:i})},xb.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(t),t.providers},xb.prototype._toggleState=function(e){e=e||{};var t,n=this._getParentContainer(),i=this._container,r=this._eventBus,o=Y(i),s=Y(n);t="twoColumn"in e?e.twoColumn:this._needsCollapse(n.clientHeight,this._entries||{}),o.toggle(bb,t),s.toggle(yb+bb,t),"open"in e&&(o.toggle(vb,e.open),s.toggle(yb+vb,e.open)),r.fire("palette.changed",{twoColumn:t,open:this.isOpen()})},xb.prototype._update=function(){var e=ye(".djs-palette-entries",this._container),t=this._entries=this.getEntries();J(e),v(t,(function(t,n){var i=t.group||"default",r=ye("[data-group="+Go(i)+"]",e);r||(X(r=fe('<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>'),s=fe(o);if(r.appendChild(s),!t.separator&&(X(s,"data-action",n),t.title&&X(s,"title",t.title),t.className&&function(e,t){var n=Y(e);(c(t)?t:t.split(/\s+/g)).forEach((function(e){n.add(e)}))}(s,t.className),t.imageUrl)){var a=fe("<img>");X(a,"src",t.imageUrl),s.appendChild(a)}})),this.open()},xb.prototype.trigger=function(e,t,n){var i,r,o=t.delegateTarget||t.target;return o?(i=X(o,"data-action"),r=t.originalEvent||t,this.triggerEntry(i,e,r,n)):t.preventDefault()},xb.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(d(o)){if("click"===t)return o(n,i)}else if(o[t])return o[t](n,i);n.preventDefault()}},xb.prototype._layoutChanged=function(){this._toggleState({})},xb.prototype._needsCollapse=function(e,t){return e<46*Object.keys(t).length+50},xb.prototype.close=function(){this._toggleState({open:!1,twoColumn:!1})},xb.prototype.open=function(){this._toggleState({open:!0})},xb.prototype.toggle=function(){this.isOpen()?this.close():this.open()},xb.prototype.isActiveTool=function(e){return e&&this._activeTool===e},xb.prototype.updateToolHighlight=function(e){var t;this._toolsContainer||(t=ye(".djs-palette-entries",this._container),this._toolsContainer=ye("[data-group=tools]",t)),v(this._toolsContainer.children,(function(t){var n=t.getAttribute("data-action");if(n){var i=Y(t);n=n.replace("-tool",""),i.contains("entry")&&n===e?i.add("highlighted-entry"):i.remove("highlighted-entry")}}))},xb.prototype.isOpen=function(){return Y(this._container).has(vb)},xb.prototype._getParentContainer=function(){return this._canvas.getContainer()},xb.HTML_MARKUP='<div class="djs-palette"><div class="djs-palette-entries"></div><div class="djs-palette-toggle"></div></div>';var _b={__init__:["palette"],palette:["type",xb]},Eb="crosshair";function Ob(e,t,n,i,r,o,s){this._selection=r,this._dragging=n,this._mouse=s;var a=this,l=function(e){var n,i=t.getActiveLayer();Oe(n=e.frame=De("rect"),{class:"djs-lasso-overlay",width:1,height:1,x:0,y:0}),xe(i,n)},c=function(e){var t=e.frame,n=e.bbox;Oe(t,{x:n.x,y:n.y,width:n.width,height:n.height})},p=function(e){e.frame&&He(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(){a.activateLasso(t.originalEvent,!0)}))})),e.on("lasso.end",0,(function(e){var t=e.context,n=Pb(e),r=i.filter((function(e){return e})),o=xs(e);a.select(r,n,o?t.selection:[])})),e.on("lasso.start",(function(e){var t=e.context;t.bbox=Pb(e),l(t),t.selection=r.get()})),e.on("lasso.move",(function(e){var t=e.context;t.bbox=Pb(e),c(t)})),e.on("lasso.cleanup",(function(e){var t=e.context;p(t)})),e.on("element.mousedown",1500,(function(e){if(xs(e))return a.activateLasso(e.originalEvent),!0}))}function Pb(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}}Ob.$inject=["eventBus","canvas","dragging","elementRegistry","selection","toolManager","mouse"],Ob.prototype.activateLasso=function(e,t){this._dragging.init(e,"lasso",{autoActivate:t,cursor:Eb,data:{context:{}}})},Ob.prototype.activateSelection=function(e,t){this._dragging.init(e,"lasso.selection",{trapClick:!1,autoActivate:t,cursor:Eb,data:{context:{}},keepSelection:!0})},Ob.prototype.select=function(e,t,n=[]){var i=function(e,t){var n={};return v(e,(function(e){var i=e;i.waypoints&&(i=yt(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,...P(i)])},Ob.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},Ob.prototype.isActive=function(){var e=this._dragging.context();return e&&/^lasso/.test(e.prefix)};var kb={__depends__:[Nm,hm],__init__:["lassoTool"],lassoTool:["type",Ob]},Sb=1500,Cb="grab";function Ab(e,t,n,i,r,o){this._dragging=n,this._mouse=o;var s=this,a=i.get("keyboard",!1);r.registerTool("hand",{tool:"hand",dragging:"hand.move"}),e.on("element.mousedown",Sb,(function(e){if(bs(e))return s.activateMove(e.originalEvent,!0),!1})),a&&a.addListener(Sb,(function(e){if(Mb(e.keyEvent)&&!s.isActive()){var t=s._mouse.getLastMoveEvent();s.activateMove(t,!!t)}}),"keyboard.keydown"),a&&a.addListener(Sb,(function(e){Mb(e.keyEvent)&&s.isActive()&&s.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(){s.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!bs(t)&&n&&e.once("hand.move.ended",(function(e){s.activateHand(e.originalEvent,!0,!0)})),!1}))}function Mb(e){return Is("Space",e)}Ab.$inject=["eventBus","canvas","dragging","injector","toolManager","mouse"],Ab.prototype.activateMove=function(e,t,n){"object"==typeof t&&(n=t,t=!1),this._dragging.init(e,"hand.move",{autoActivate:t,cursor:Cb,data:{context:n||{}}})},Ab.prototype.activateHand=function(e,t,n){this._dragging.init(e,"hand",{trapClick:!1,autoActivate:t,cursor:Cb,data:{context:{reactivate:n}}})},Ab.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateHand(e,!!e)},Ab.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^(hand|hand\.move)$/.test(e.prefix)};var Tb={__depends__:[Nm,hm],__init__:["handTool"],handTool:["type",Ab]},Rb="connect-ok",Db="connect-not-ok";function Nb(e,t,n,i,r,o,s){var a=this;this._dragging=t,this._rules=o,this._mouse=s,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=a.canStartConnect(n);null!==r&&(t.startTarget=n,i.addMarker(n,r?Rb:Db))})),e.on(["global-connect.out","global-connect.cleanup"],(function(e){var t=e.context.startTarget,n=e.context.canStartConnect;t&&i.removeMarker(t,n?Rb:Db)})),e.on(["global-connect.ended"],(function(t){var i=t.context.startTarget,r={x:t.x,y:t.y};if(a.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}))}Nb.$inject=["eventBus","dragging","connect","canvas","toolManager","rules","mouse"],Nb.prototype.start=function(e,t){this._dragging.init(e,"global-connect",{autoActivate:t,trapClick:!1,data:{context:{}}})},Nb.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();return this.start(e,!!e)},Nb.prototype.isActive=function(){var e=this._dragging.context();return e&&/^global-connect/.test(e.prefix)},Nb.prototype.canStartConnect=function(e){return this._rules.allowed("connection.start",{source:e})};var Bb={__depends__:[Np,Rc,Sc,Nm,hm],globalConnect:["type",Nb]};function $b(e,t,n,i,r,o,s,a){this._palette=e,this._create=t,this._elementFactory=n,this._spaceTool=i,this._lassoTool=r,this._handTool=o,this._globalConnect=s,this._translate=a,e.registerProvider(this)}$b.$inject=["palette","create","elementFactory","spaceTool","lassoTool","handTool","globalConnect","translate"],$b.prototype.getPaletteEntries=function(){var e={},t=this._create,n=this._elementFactory,i=this._spaceTool,r=this._lassoTool,o=this._handTool,s=this._globalConnect,a=this._translate;function l(e,i,r,o,s){function a(i){var r=n.createShape(j({type:e},s));t.start(i,r)}return{group:i,className:r,title:o,action:{dragstart:a,click:a}}}function c(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 p(e){t.start(e,n.createParticipantShape())}return j(e,{"hand-tool":{group:"tools",className:"bpmn-icon-hand-tool",title:a("Activate hand tool"),action:{click:function(e){o.activateHand(e)}}},"lasso-tool":{group:"tools",className:"bpmn-icon-lasso-tool",title:a("Activate lasso tool"),action:{click:function(e){r.activateSelection(e)}}},"space-tool":{group:"tools",className:"bpmn-icon-space-tool",title:a("Activate create/remove space tool"),action:{click:function(e){i.activateSelection(e)}}},"global-connect-tool":{group:"tools",className:"bpmn-icon-connection-multi",title:a("Activate global connect tool"),action:{click:function(e){s.start(e)}}},"tool-separator":{group:"tools",separator:!0},"create.start-event":l("bpmn:StartEvent","event","bpmn-icon-start-event-none",a("Create start event")),"create.intermediate-event":l("bpmn:IntermediateThrowEvent","event","bpmn-icon-intermediate-event-none",a("Create intermediate/boundary event")),"create.end-event":l("bpmn:EndEvent","event","bpmn-icon-end-event-none",a("Create end event")),"create.exclusive-gateway":l("bpmn:ExclusiveGateway","gateway","bpmn-icon-gateway-none",a("Create gateway")),"create.task":l("bpmn:Task","activity","bpmn-icon-task",a("Create task")),"create.data-object":l("bpmn:DataObjectReference","data-object","bpmn-icon-data-object",a("Create data object reference")),"create.data-store":l("bpmn:DataStoreReference","data-store","bpmn-icon-data-store",a("Create data store reference")),"create.subprocess-expanded":{group:"activity",className:"bpmn-icon-subprocess-expanded",title:a("Create expanded sub-process"),action:{dragstart:c,click:c}},"create.participant-expanded":{group:"collaboration",className:"bpmn-icon-participant",title:a("Create pool/participant"),action:{dragstart:p,click:p}},"create.group":l("bpmn:Group","artifact","bpmn-icon-group",a("Create group"))}),e};var jb={__depends__:[_b,um,ef,kb,Tb,Bb,Co],__init__:["paletteProvider"],paletteProvider:["type",$b]};function Ib(e,t,n,i,r){Fo.call(this,e),e.on("shape.move.move",250,(function(e){var o=e.context,s=o.canExecute;o.visualReplacements||(o.visualReplacements={}),s&&s.replacements?function(e){v(e.canExecute.replacements,(function(o){var s=o.oldElementId,a={type:o.newElementType};if(!e.visualReplacements[s]){var l=t.get(s);j(a,{x:l.x,y:l.y});var c=n.createShape(a);i.addShape(c,l.parent);var p=ye('[data-element-id="'+Go(l.id)+'"]',e.dragGroup);p&&Oe(p,{display:"none"});var u=r.addDragger(c,e.dragGroup);e.visualReplacements[s]=u,i.removeShape(c)}}))}(o):function(e){var t=e.visualReplacements;v(t,(function(n,i){var r=ye('[data-element-id="'+Go(i)+'"]',e.dragGroup);r&&Oe(r,{display:"inline"}),n.remove(),t[i]&&delete t[i]}))}(o)}))}Ib.$inject=["eventBus","elementRegistry","elementFactory","canvas","previewSupport"],e(Ib,Fo);var Lb={__depends__:[zp],__init__:["bpmnReplacePreview"],bpmnReplacePreview:["type",Ib]},qb=40,zb=20,Vb=10,Fb=20,Hb=["x","y"],Ub=Math.abs;function Wb(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,s=t.target;e.originalEvent&&js(e.originalEvent)||(t.initialConnectionStart||(t.initialConnectionStart=t.connectionStart),n&&r&&function(e,t,n){Hb.forEach((function(i){var r=Xb(i,t);e[i]<t[i]+n?Ep(e,i,t[i]+n):e[i]>t[i]+r-n&&Ep(e,i,t[i]+r-n)}))}(e,r,function(e){return _r(e,"bpmn:Task")?Vb:zb}(r)),r&&function(e,t){return _(t,(function(t){return Qb(e,t)}))}(n,["bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:SequenceFlow"])?(t.connectionStart=wp(i),Er(r,["bpmn:Event","bpmn:Gateway"])&&Gb(e,wp(r)),Er(r,["bpmn:Task","bpmn:SubProcess"])&&function(e,t){var n=wp(t);Hb.forEach((function(i){(function(e,t,n){return e[n]>t[n]+Fb&&e[n]<t[n]+Xb(n,t)-Fb})(e,t,i)&&Ep(e,i,n[i])}))}(e,r),_r(o,"bpmn:BoundaryEvent")&&s===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=wp(n),o=xn(r,i,-10),s=[];/top|bottom/.test(o)&&s.push("x");/left|right/.test(o)&&s.push("y");s.forEach((function(t){var n,i=e[t];Ub(i-r[t])<qb&&(n=i>r[t]?r[t]+qb:r[t]-qb,Ep(e,t,n))}))}(e)):Qb(n,"bpmn:MessageFlow")?(_r(i,"bpmn:Event")&&(t.connectionStart=wp(i)),_r(r,"bpmn:Event")&&Gb(e,wp(r))):t.connectionStart=t.initialConnectionStart)}))}function Gb(e,t){Ep(e,"x",t.x),Ep(e,"y",t.y)}function Qb(e,t){return e&&e.type===t}function Xb(e,t){return"x"===e?t.width:t.height}function Kb(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}function Yb(){this._snapValues={}}Wb.$inject=["eventBus"],Kb.prototype.getSnapOrigin=function(e){return this._snapOrigins[e]},Kb.prototype.setSnapOrigin=function(e,t){this._snapOrigins[e]=t,-1===this._snapLocations.indexOf(e)&&this._snapLocations.push(e)},Kb.prototype.addDefaultSnap=function(e,t){var n=this._defaultSnaps[e];n||(n=this._defaultSnaps[e]=[]),n.push(t)},Kb.prototype.getSnapLocations=function(){return this._snapLocations},Kb.prototype.setSnapLocations=function(e){this._snapLocations=e},Kb.prototype.pointsForTarget=function(e){var t=e.id||e,n=this._targets[t];return n||(n=this._targets[t]=new Yb).initDefaults(this._defaultSnaps),n},Yb.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)},Yb.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],yp(r-e)<=n)return r}(e[n],r[n],i)},Yb.prototype.initDefaults=function(e){var t=this;v(e||{},(function(e,n){v(e,(function(e){t.add(n,e)}))}))};var Zb=1250;function Jb(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"],Zb,(function(e){var t=e.context,r=t.shape,o=t.snapContext,s=t.target;if((!e.originalEvent||!js(e.originalEvent))&&!_p(e)&&s){var a=o.pointsForTarget(s);a.initialized||((a=i.addSnapTargetPoints(a,r,s)).initialized=!0),n.snap(e,a)}})),t.on(["create.cleanup","shape.move.cleanup"],(function(){n.hide()}))}Jb.$inject=["elementRegistry","eventBus","snapping"],Jb.prototype.initSnap=function(e){var t,n=this._elementRegistry,i=e.context,r=i.shape,o=i.snapContext;o||(o=i.snapContext=new Kb);var s=(t=n.get(r.id)?wp(r,e):{x:e.x+wp(r).x,y:e.y+wp(r).y}).x-r.width/2,a=t.y-r.height/2,l=t.x+r.width/2,c=t.y+r.height/2;return o.setSnapOrigin("mid",{x:t.x-e.x,y:t.y-e.y}),hn(r)||(o.setSnapOrigin("top-left",{x:s-e.x,y:a-e.y}),o.setSnapOrigin("bottom-right",{x:l-e.x,y:c-e.y})),o},Jb.prototype.addSnapTargetPoints=function(e,t,n){return v(this.getSnapTargets(t,n),(function(n){if(hn(n))hn(t)&&e.add("mid",wp(n));else if(dn(n)){if(n.waypoints.length<3)return;v(n.waypoints.slice(1,-1),(function(t){e.add("mid",t)}))}else e.add("mid",wp(n))})),u(t.x)&&u(t.y)?(this._elementRegistry.get(t.id)&&e.add("mid",wp(t)),e):e},Jb.prototype.getSnapTargets=function(e,t){return Op(t).filter((function(e){return!e.hidden}))};function ex(e,t){t.invoke(Jb,this),e.on(["create.move","create.end"],1500,tx),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)&&!_p(e)&&function(e,t){var n,i=gn(t),r=fh(e,t),o=e.context,s=o.shape;n=s.parent?{x:0,y:0}:bn(s);/top/.test(r)?Ep(e,"y",i.top-n.y):/bottom/.test(r)&&Ep(e,"y",i.bottom-n.y);/left/.test(r)?Ep(e,"x",i.left-n.x):/right/.test(r)&&Ep(e,"x",i.right-n.x)}(e,i)}))}function tx(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)&&Ep(e,"x",e.x),(n&&n>=e.y||r&&r<=e.y)&&Ep(e,"y",e.y)}}function nx(e,t){return-1!==e.indexOf(t)}function ix(e,t,n){return t?{x:e.x-n.x,y:e.y-n.y}:{x:e.x,y:e.y}}e(ex,Jb),ex.$inject=["eventBus","injector"],ex.prototype.initSnap=function(e){var t=Jb.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",ix(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",ix(r,i,e))})),_r(n,"bpmn:Participant")&&t.setSnapLocations(["top-left","bottom-right","mid"]),t},ex.prototype.addSnapTargetPoints=function(e,t,n){Jb.prototype.addSnapTargetPoints.call(this,e,t,n);var i=this.getSnapTargets(t,n);v(i,(function(n){var i;(function(e){if(_r(e,"bpmn:SubProcess")&&Vr(e))return!0;return _r(e,"bpmn:Participant")}(n)||(i="bpmn:TextAnnotation",[t,n].every((function(e){return _r(e,i)}))))&&(e.add("top-left",bp(n)),e.add("bottom-right",xp(n)))}));var r=this._elementRegistry;return v(t.incoming,(function(n){if(r.get(t.id)){nx(i,n.source)||e.add("mid",bn(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)){nx(i,n.target)||e.add("mid",bn(n.target));var o=n.waypoints[n.waypoints.length-1];e.add(n.id+"-docking",o.original||o)}})),_r(n,"bpmn:SequenceFlow")&&(e=this.addSnapTargetPoints(e,t,n.parent)),e},ex.prototype.getSnapTargets=function(e,t){return Jb.prototype.getSnapTargets.call(this,e,t).filter((function(e){return!_r(e,"bpmn:Lane")}))};function rx(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,s=i.direction,a=i.snapContext;if(!(e.originalEvent&&js(e.originalEvent)||_p(e))){var l=a.pointsForTarget(o);l.initialized||((l=n.addSnapTargetPoints(l,r,o,s)).initialized=!0),function(e){return"n"===e||"s"===e}(s)&&Ep(e,"x",e.x),function(e){return"e"===e||"w"===e}(s)&&Ep(e,"y",e.y),t.snap(e,l)}})),e.on(["resize.cleanup"],(function(){t.hide()}))}function ox(e,t){var n=bn(e),i=gn(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}rx.prototype.initSnap=function(e){var t=e.context,n=t.shape,i=t.direction,r=t.snapContext;r||(r=t.snapContext=new Kb);var o=ox(n,i);return r.setSnapOrigin("corner",{x:o.x-e.x,y:o.y-e.y}),r},rx.prototype.addSnapTargetPoints=function(e,t,n,i){return v(this.getSnapTargets(t,n),(function(t){e.add("corner",xp(t)),e.add("corner",bp(t))})),e.add("corner",ox(t,i)),e},rx.$inject=["eventBus","snapping"],rx.prototype.getSnapTargets=function(e,t){return Op(t).filter((function(t){return!(n=t,i=e,n.host===i||dn(t)||function(e){return!!e.hidden}(t)||hn(t));var n,i}))};function sx(e){this._canvas=e,this._asyncHide=B($(this.hide,this),1e3)}sx.$inject=["canvas"],sx.prototype.snap=function(e,t){var n=e.context.snapContext,i=n.getSnapLocations(),r={x:_p(e,"x"),y:_p(e,"y")};v(i,(function(i){var o=n.getSnapOrigin(i),s={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(s,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];p(n)&&Ep(e,t,n.originValue)}))},sx.prototype._createLine=function(e){var t=this._canvas.getLayer("snap"),n=De("path");return Oe(n,{d:"M0,0 L0,0"}),ke(n).add("djs-snap-line"),xe(t,n),{update:function(t){u(t)?Oe(n,"horizontal"===e?{d:"M-100000,"+t+" L+100000,"+t,display:""}:{d:"M "+t+",-100000 L "+t+", +100000",display:""}):Oe(n,{display:"none"})}}},sx.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}},sx.prototype.showSnapLine=function(e,t){var n=this.getSnapLine(e);n&&n.update(t),this._asyncHide()},sx.prototype.getSnapLine=function(e){return this._snapLines||this._createSnapLines(),this._snapLines[e]},sx.prototype.hide=function(){v(this._snapLines,(function(e){e.update()}))};var ax={__depends__:[{__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",Jb],resizeSnapping:["type",rx],snapping:["type",sx]}],__init__:["connectSnapping","createMoveSnapping"],connectSnapping:["type",Wb],createMoveSnapping:["type",ex]};function lx(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=ye(lx.INPUT_SELECTOR,this._container),this._resultsContainer=ye(lx.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 cx(e,t,n){var i=function(e){var t="";return e.forEach((function(e){var n=Xo(e.value||e.matched||e.normal),i=e.match||e.matched;t+=i?'<b class="'+lx.RESULT_HIGHLIGHT_CLASS+'">'+n+"</b>":n})),""!==t?t:null}(t),r=fe(n);r.innerHTML=i,e.appendChild(r)}lx.$inject=["canvas","eventBus","selection","translate"],lx.prototype._bindEvents=function(){var e=this;function t(t,n,i,r){e._eventMaps.push({el:t,type:i,listener:ue.bind(t,n,i,r)})}t(document,"html","click",(function(t){e.close(!1)})),t(this._container,lx.INPUT_SELECTOR,"click",(function(e){e.stopPropagation(),e.delegateTarget.focus()})),t(this._container,lx.RESULT_SELECTOR,"mouseover",(function(t){t.stopPropagation(),e._scrollToNode(t.delegateTarget),e._preselect(t.delegateTarget)})),t(this._container,lx.RESULT_SELECTOR,"click",(function(t){t.stopPropagation(),e._select(t.delegateTarget)})),t(this._container,lx.INPUT_SELECTOR,"keydown",(function(e){Is("ArrowUp",e)&&e.preventDefault(),Is("ArrowDown",e)&&e.preventDefault()})),t(this._container,lx.INPUT_SELECTOR,"keyup",(function(t){if(Is("Escape",t))return e.close();if(Is("Enter",t)){var n=e._getCurrentResult();return n?e._select(n):e.close(!1)}return Is("ArrowUp",t)?e._scrollToDirection(!0):Is("ArrowDown",t)?e._scrollToDirection():void(Is(["ArrowLeft","ArrowRight"],t)||e._search(t.delegateTarget.value))}))},lx.prototype._unbindEvents=function(){this._eventMaps.forEach((function(e){ue.unbind(e.el,e.type,e.listener)}))},lx.prototype._search=function(e){var t=this;if(this._clearResults(),e.trim()){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=ye(lx.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}else this._selection.select(null)}},lx.prototype._scrollToDirection=function(e){var t=this._getCurrentResult();if(t){var n=e?t.previousElementSibling:t.nextElementSibling;n&&(this._scrollToNode(n),this._preselect(n))}},lx.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)}},lx.prototype._clearResults=function(){J(this._resultsContainer),this._results={},this._eventBus.fire("searchPad.cleared")},lx.prototype._getCurrentResult=function(){return ye(lx.RESULT_SELECTED_SELECTOR,this._resultsContainer)},lx.prototype._createResultNode=function(e,t){var n=fe(lx.RESULT_HTML);return e.primaryTokens.length>0&&cx(n,e.primaryTokens,lx.RESULT_PRIMARY_HTML),cx(n,e.secondaryTokens,lx.RESULT_SECONDARY_HTML),X(n,lx.RESULT_ID_ATTRIBUTE,t),this._resultsContainer.appendChild(n),n},lx.prototype.registerProvider=function(e){this._searchProvider=e},lx.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,Y(this._canvas.getContainer()).add("djs-search-open"),Y(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))},lx.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,Y(this._canvas.getContainer()).remove("djs-search-open"),Y(this._container).remove("open"),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._eventBus.fire("searchPad.closed"),this._canvas.restoreFocus())},lx.prototype.toggle=function(){this.isOpen()?this.close():this.open()},lx.prototype.isOpen=function(){return this._open},lx.prototype._preselect=function(e){var t=this._getCurrentResult();if(e!==t){t&&Y(t).remove(lx.RESULT_SELECTED_CLASS);var n=X(e,lx.RESULT_ID_ATTRIBUTE),i=this._results[n].element;Y(e).add(lx.RESULT_SELECTED_CLASS),this._canvas.scrollToElement(i,{top:300}),this._selection.select(i),this._eventBus.fire("searchPad.preselected",i)}},lx.prototype._select=function(e){var t=X(e,lx.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)},lx.prototype._getBoxHtml=function(){const e=fe(lx.BOX_HTML),t=ye(lx.INPUT_SELECTOR,e);return t&&t.setAttribute("aria-label",this._translate("Search in diagram")),e},lx.CONTAINER_SELECTOR=".djs-search-container",lx.INPUT_SELECTOR=".djs-search-input input",lx.RESULTS_CONTAINER_SELECTOR=".djs-search-results",lx.RESULT_SELECTOR=".djs-search-result",lx.RESULT_SELECTED_CLASS="djs-search-result-selected",lx.RESULT_SELECTED_SELECTOR="."+lx.RESULT_SELECTED_CLASS,lx.RESULT_ID_ATTRIBUTE="data-result-id",lx.RESULT_HIGHLIGHT_CLASS="djs-search-highlight",lx.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>',lx.RESULT_HTML='<div class="djs-search-result"></div>',lx.RESULT_PRIMARY_HTML='<div class="djs-search-result-primary"></div>',lx.RESULT_SECONDARY_HTML='<p class="djs-search-result-secondary"></p>';var px={__depends__:[Co,qo,Ts],searchPad:["type",lx]};function ux(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._search=i,t.registerProvider(this)}function dx(e){const{item:{element:t},tokens:n}=e;return{element:t,primaryTokens:n.label,secondaryTokens:n.id}}ux.$inject=["elementRegistry","searchPad","canvas","search"],ux.prototype.find=function(e){var t=this._canvas.getRootElements(),n=this._elementRegistry.filter((function(e){return!hn(e)&&!t.includes(e)}));return this._search(n.map((e=>({element:e,label:eo(e),id:e.id}))),e,{keys:["label","id"]}).map(dx)};var hx={__depends__:[px,Hl],__init__:["bpmnSearch"],bpmnSearch:["type",ux]};const mx={width:36,height:50},fx={width:50,height:50};function gx(e,t,n){return De("path",{d:e,strokeWidth:2,transform:`translate(${t.x}, ${t.y})`,...n})}function yx(e,t){this._styles=t,e.registerProvider(this)}function vx(e,t){var n;return"bpmn:DataObjectReference"===t?n=mx:"bpmn:DataStoreReference"===t&&(n=fx),e.width===n.width&&e.height===n.height}yx.$inject=["outline","styles"],yx.prototype.getOutline=function(e){const t=this._styles.cls("djs-outline",["no-fill"]);var n;if(!hn(e))return _r(e,"bpmn:Gateway")?(j((n=De("rect")).style,{"transform-box":"fill-box",transform:"rotate(45deg)","transform-origin":"center"}),Oe(n,j({x:2,y:2,rx:4,width:e.width-4,height:e.height-4},t))):Er(e,["bpmn:Task","bpmn:SubProcess","bpmn:Group","bpmn:CallActivity"])?Oe(n=De("rect"),j({x:-5,y:-5,rx:14,width:e.width+10,height:e.height+10},t)):_r(e,"bpmn:EndEvent")?Oe(n=De("circle"),j({cx:e.width/2,cy:e.height/2,r:e.width/2+5+1},t)):_r(e,"bpmn:Event")?Oe(n=De("circle"),j({cx:e.width/2,cy:e.height/2,r:e.width/2+5},t)):_r(e,"bpmn:DataObjectReference")&&vx(e,"bpmn:DataObjectReference")?n=gx("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):_r(e,"bpmn:DataStoreReference")&&vx(e,"bpmn:DataStoreReference")&&(n=gx("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},yx.prototype.updateOutline=function(e,t){if(!hn(e))return Er(e,["bpmn:SubProcess","bpmn:Group"])?(Oe(t,{width:e.width+10,height:e.height+10}),!0):!!Er(e,["bpmn:Event","bpmn:Gateway","bpmn:DataStoreReference","bpmn:DataObjectReference"])};var bx={__depends__:[rb],__init__:["outlineProvider"],outlineProvider:["type",yx]};function xx(e){zr.call(this,e)}e(xx,zr),xx.Viewer=Rs,xx.NavigatedViewer=da,xx.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>')},xx.prototype._interactionModules=[Ks,oa,ua],xx.prototype._modelingModules=[Zl,fc,Mc,xc,Cp,Np,$p,Fy,Em,um,Ky,nv,yv,bv,wv,Av,Gv,uy,tb,hb,jb,Lb,qv,ax,hx,bx],xx.prototype._modules=[].concat(Rs.prototype._modules,xx.prototype._interactionModules,xx.prototype._modelingModules);var wx=new No,_x={min:.2,max:4};function Ex(e,t,n,i,r){var o=this;function s(e){o._state._svgClientRect&&!Cx(o._state._svgClientRect)||(o._state._svgClientRect=o._svg.getBoundingClientRect()),Px(Ox({x:e.x-o._state._svgClientRect.left,y:e.y-o._state._svgClientRect.top},o._svg,o._lastViewbox),o._canvas),o._update()}function a(e){return function(t){var n=Dx(t);o._state._svgClientRect&&!Cx(o._state._svgClientRect)||(o._state._svgClientRect=o._svg.getBoundingClientRect()),e&&s(n);var r=Ox({x:n.x-o._state._svgClientRect.left,y:n.y-o._state._svgClientRect.top},o._svg,o._lastViewbox),a=i.viewbox(),p=function(e,t){var n={x:t.x+t.width/2,y:t.y+t.height/2};return{x:e.x-n.x,y:e.y-n.y}}(r,a),u=o._viewportDom.getBoundingClientRect(),d={x:n.x-u.left+1,y:n.y-u.top+1};j(o._state,{cachedViewbox:a,initialDragPosition:{x:n.x,y:n.y},isDragging:!0,offsetViewport:p,offsetViewportDom:d,viewportClientRect:o._viewport.getBoundingClientRect(),parentClientRect:o._parent.getBoundingClientRect()}),le.bind(document,"mousemove",l),le.bind(document,"mouseup",c)}}function l(e){var t=Dx(e);if(o._state.isDragging){o._state._svgClientRect&&!Cx(o._state._svgClientRect)||(o._state._svgClientRect=o._svg.getBoundingClientRect());var n=o._state.offsetViewportDom,i=o._state.viewportClientRect,r=o._state.parentClientRect;j(o._viewportDom.style,{top:t.y-n.y-r.top+"px",left:t.x-n.x-r.left+"px"});var s=Mx(r,{top:t.y-n.y-r.top,left:t.x-n.x-r.left,width:i.width,height:i.height});j(o._overlay.style,{clipPath:s});var a=Ox({x:t.x-o._state._svgClientRect.left,y:t.y-o._state._svgClientRect.top},o._svg,o._lastViewbox);Px({x:a.x-o._state.offsetViewport.x,y:a.y-o._state.offsetViewport.y},o._canvas)}}function c(e){var t=Dx(e);o._state.isDragging&&(o._state.initialDragPosition.x===t.x&&o._state.initialDragPosition.y===t.y&&s(e),o._update(),j(o._state,{cachedViewbox:null,initialDragPosition:null,isDragging:!1,offsetViewport:null,offsetViewportDom:null}),le.unbind(document,"mousemove",l),le.unbind(document,"mouseup",c))}this._canvas=i,this._elementRegistry=r,this._eventBus=n,this._injector=t,this._state={isOpen:void 0,isDragging:!1,initialDragPosition:null,offsetViewport:null,cachedViewbox:null,dragger:null,svgClientRect:null,parentClientRect:null,zoomDelta:0},this._minimapId=wx.next(),this._init(),this.toggle(e&&e.open||!1),le.bind(this._viewportDom,"mousedown",a(!1)),le.bind(this._svg,"mousedown",a(!0)),le.bind(this._parent,"wheel",(function(e){if(e.preventDefault(),e.stopPropagation(),e.ctrlKey&&(o._state._svgClientRect&&!Cx(o._state._svgClientRect)||(o._state._svgClientRect=o._svg.getBoundingClientRect()),t=e,n=o._state._svgClientRect,t.x>n.left&&t.x<n.left+n.width&&t.y>n.top&&t.y<n.top+n.height)){var t,n,r,s,a,l,c=0===e.deltaMode?.02:.32,p=Math.sqrt(Math.pow(e.deltaY,2)+Math.pow(e.deltaX,2))*Ax(e.deltaY)*-c;if(o._state.zoomDelta+=p,Math.abs(o._state.zoomDelta)>.1){var u=p>0?1:-1,d=Math.log(i.zoom())/Math.log(10),h=(r=_x,s=20,a=Math.log(r.min)/Math.log(10),l=Math.log(r.max)/Math.log(10),(Math.abs(a)+Math.abs(l))/s),m=Math.round(d/h)*h;m+=h*u;var f=Math.pow(10,m);i.zoom(function(e,t){return Math.max(e.min,Math.min(e.max,t))}(_x,f),g),o._state.zoomDelta=0;var g=Ox({x:e.clientX-o._state._svgClientRect.left,y:e.clientY-o._state._svgClientRect.top},o._svg,o._lastViewbox);Px(g,o._canvas),o._update()}}})),le.bind(this._toggle,"click",(function(e){e.preventDefault(),e.stopPropagation(),o.toggle()})),n.on(["shape.added","connection.added"],(function(e){var t=e.element;o._addElement(t),o._update()})),n.on(["shape.removed","connection.removed"],(function(e){var t=e.element;o._removeElement(t),o._update()})),n.on("elements.changed",250,(function(e){e.elements.forEach((function(e){o._updateElement(e)})),o._update()})),n.on("element.updateId",(function(e){var t=e.element,n=e.newId;o._updateElementId(t,n)})),n.on("canvas.viewbox.changed",(function(){o._state.isDragging||o._update()})),n.on("canvas.resized",(function(){document.body.contains(o._parent)&&(o._state.isDragging||o._update(),o._state._svgClientRect=o._svg.getBoundingClientRect())})),n.on(["root.set","plane.set"],(function(e){o._clear(),(e.element||e.plane.rootElement).children.forEach((function(e){o._addElement(e)})),o._update()}))}function Ox(e,t,n){var i=t.getBoundingClientRect(),r=function(e,t){var n=e.width/e.height,i=j({},{x:e.x,y:e.y,width:e.width,height:e.height});if(n>t){var r=i.width*(1/t);j(i,{y:i.y-(r-i.height)/2,height:r})}else if(n<t){var o=i.height*t;j(i,{x:i.x-(o-i.width)/2,width:o})}return i}(n,i.width/i.height);return{x:kx(e.x,0,i.width,r.x,r.x+r.width),y:kx(e.y,0,i.height,r.y,r.y+r.height)}}function Px(e,t){var n=t.viewbox(),i=n.width,r=n.height;t.viewbox({x:e.x-i/2,y:e.y-r/2,width:i,height:r})}function kx(e,t,n,i,r){return(e-t)*(r-i)/(n-t)+i}function Sx(e,t,n){var i=function(e){var t=ye(".children",e);t||xe(e,t=De("g",{class:"children"}));return t}(t),r=[].slice.call(i.childNodes)[n];r?t.insertBefore(e,r.nextSibling):t.appendChild(e)}function Cx(e){return 0===e.width&&0===e.height}Ex.$inject=["config.minimap","injector","eventBus","canvas","elementRegistry"],Ex.prototype._init=function(){var e=this._canvas.getContainer(),t=this._parent=document.createElement("div");Y(t).add("djs-minimap"),e.appendChild(t);var n=this._toggle=document.createElement("div");Y(n).add("toggle"),t.appendChild(n);var i=this._map=document.createElement("div");Y(i).add("map"),t.appendChild(i);var r=this._svg=De("svg");Oe(r,{width:"100%",height:"100%"}),xe(i,r),xe(r,this._elementsGroup=De("g"));var o=this._viewportGroup=De("g");xe(r,o);var s=this._viewport=De("rect");ke(s).add("viewport"),xe(o,s),le.bind(t,"mousedown",(function(e){e.stopPropagation()}));var a=this._viewportDom=document.createElement("div");Y(a).add("viewport-dom"),this._parent.appendChild(a);var l=this._overlay=document.createElement("div");Y(l).add("overlay"),this._parent.appendChild(l)},Ex.prototype._update=function(){var e=this._canvas.viewbox(),t=e.inner,n=e.outer;if(Rx(e)){var i,r,o,s,a=n.width-t.width,l=n.height-t.height;t.width<n.width?(i=t.x-a/2,o=n.width,t.x+t.width<n.width&&(i=Math.min(0,t.x))):(i=t.x,o=t.width),t.height<n.height?(r=t.y-l/2,s=n.height,t.y+t.height<n.height&&(r=Math.min(0,t.y))):(r=t.y,s=t.height),i-=50,r-=50,o+=100,s+=100,this._lastViewbox={x:i,y:r,width:o,height:s},Oe(this._svg,{viewBox:i+", "+r+", "+o+", "+s}),Oe(this._viewport,{x:e.x,y:e.y,width:e.width,height:e.height});var c=this._state._parentClientRect=this._parent.getBoundingClientRect(),p=this._viewport.getBoundingClientRect(),u={top:p.top-c.top,left:p.left-c.left,width:p.width,height:p.height};j(this._viewportDom.style,{top:u.top+"px",left:u.left+"px",width:u.width+"px",height:u.height+"px"});var d=Mx(c,u);j(this._overlay.style,{clipPath:d})}},Ex.prototype.open=function(){j(this._state,{isOpen:!0}),Y(this._parent).add("open");var e=this._injector.get("translate",!1)||function(e){return e};X(this._toggle,"title",e("Close minimap")),this._update(),this._eventBus.fire("minimap.toggle",{open:!0})},Ex.prototype.close=function(){j(this._state,{isOpen:!1}),Y(this._parent).remove("open");var e=this._injector.get("translate",!1)||function(e){return e};X(this._toggle,"title",e("Open minimap")),this._eventBus.fire("minimap.toggle",{open:!1})},Ex.prototype.toggle=function(e){var t=this.isOpen();void 0===e&&(e=!t),e!=t&&(e?this.open():this.close())},Ex.prototype.isOpen=function(){return this._state.isOpen},Ex.prototype._updateElement=function(e){try{void 0!==e.parent&&null!==e.parent&&(this._removeElement(e),this._addElement(e))}catch(e){console.warn("Minimap#_updateElement errored",e)}},Ex.prototype._updateElementId=function(e,t){try{var n=ye("#"+Go(this._prefixId(e.id)),this._elementsGroup);n&&(n.id=this._prefixId(t))}catch(e){console.warn("Minimap#_updateElementId errored",e)}},Ex.prototype.isOnActivePlane=function(e){var t=this._canvas;return t.findRoot?t.findRoot(e)===t.getRootElement():!t.findPlane||t.findPlane(e)===t.getActivePlane()},Ex.prototype._addElement=function(e){var t=this;if(this._removeElement(e),this.isOnActivePlane(e)){var n,i,r,o=this._createElement(e),s=ye("#"+Go(this._prefixId(e.parent.id)),this._elementsGroup);if(o){var a=function(e,t){var n=ye(".djs-children",t.parentNode);if(!n)return;var i=[].slice.call(n.childNodes),r=-1;return i.forEach((function(t,n){ye(".djs-element",t)===e&&(r=n)})),r}(this._elementRegistry.getGraphics(e),this._elementRegistry.getGraphics(e.parent));return"undefined"!==a&&s?s.childNodes.length>a?Sx(o,s,a):Sx(o,s,s.childNodes.length-1):this._elementsGroup.appendChild(o),!function(e){return e.waypoints}(e)?(i=e.x,r=e.y,s&&(i-=(n=e.parent).x,r-=n.y),Oe(o,{transform:"translate("+i+" "+r+")"})):(i=0,r=0,void 0!==(n=e.parent).x&&void 0!==n.y&&(i=-n.x,r=-n.y),Oe(o,{transform:"translate("+i+" "+r+")"})),e.children&&e.children.length&&e.children.forEach((function(e){t._addElement(e)})),o}}},Ex.prototype._removeElement=function(e){var t=this._svg.getElementById(this._prefixId(e.id));t&&He(t)},Ex.prototype._createElement=function(e){var t,n=this._elementRegistry.getGraphics(e);if(n&&(t=Qn(n))){var i=function(e){return ve("[id]",e).forEach((function(e){e.remove()})),e}(Ae(t));return Oe(i,{id:this._prefixId(e.id)}),i}},Ex.prototype._clear=function(){Ce(this._elementsGroup)},Ex.prototype._prefixId=function(e){return"djs-minimap-"+e+"-"+this._minimapId};var Ax=Math.sign||function(e){return e>=0?1:-1};function Mx(e,t){return"polygon("+[Tx(t.left,t.top),Tx(t.left+t.width,t.top),Tx(t.left+t.width,t.top+t.height),Tx(t.left,t.top+t.height),Tx(t.left,e.height),Tx(e.width,e.height),Tx(e.width,0),Tx(0,0),Tx(0,e.height),Tx(t.left,e.height)].join(", ")+")"}function Tx(e,t){return e+"px "+t+"px"}function Rx(e){return w(e,(function(e){return p(e)?Rx(e):u(e)&&isFinite(e)}))}function Dx(e){return e.center?e.center:{x:e.clientX,y:e.clientY}}var Nx={__init__:["minimap"],minimap:["type",Ex]},Bx=1e5,$x=1e5;function jx(e,t){this._canvas=e;var n=this;t.on("diagram.init",(function(){n._init(),n.toggle(!0)})),t.on("gridSnapping.toggle",(function(e){var t=e.active;n.toggle(t),n._centerGridAroundViewbox()})),t.on("canvas.viewbox.changed",(function(e){var t=e.viewbox;n._centerGridAroundViewbox(t)}))}jx.prototype._init=function(){var e=ye("defs",this._canvas._svg);e||(e=De("defs"),xe(this._canvas._svg,e));var t=this._pattern=De("pattern"),n="djs-grid-pattern-"+Math.trunc(1e6*Math.random());Oe(t,{id:n,width:rv,height:rv,patternUnits:"userSpaceOnUse"});var i=this._circle=De("circle");Oe(i,{cx:.5,cy:.5,r:.5,fill:"#ccc"}),xe(t,i),xe(e,t),Oe(this._gfx=De("rect"),{x:-Bx/2,y:-$x/2,width:Bx,height:$x,fill:`url(#${n})`})},jx.prototype._centerGridAroundViewbox=function(e){e||(e=this._canvas.viewbox());var t=bn(e);Oe(this._gfx,{x:-Bx/2+ov(t.x,rv),y:-$x/2+ov(t.y,rv)})},jx.prototype.isVisible=function(){return this._visible},jx.prototype.toggle=function(e){if(void 0===e&&(e=!this._visible),e!==this._visible){var t=this._getParent();e?xe(t,this._gfx):Ce(t),this._visible=e}},jx.prototype._getParent=function(){return this._canvas.getLayer("djs-grid",-2)},jx.$inject=["canvas","eventBus"];var Ix={__init__:["grid"],grid:["type",jx]};function Lx(e,t){var n,i,r=(e=e||{}).borderColor||"rgba(0,0,0,0.1)",o=e.crossColor||"#CCC",s=-1;xe(t.getLayer("djs-origin",-1),n=Vx("g",{"pointer-events":"none"})),!1!==e.showBorder&&xe(n,Vx("path",{class:zx("border"),d:qx(["M",-22,s,"H",-1e3,"M",22,s,"H",6e3,"M",s,-22,"V",-1e3,"M",s,22,"V",3e3]),fill:"none",stroke:r,"stroke-width":"2px","stroke-dasharray":"6, 6","shape-rendering":"crispedges"})),xe(n,Vx("path",{d:qx(["M",-15,s,"H",15,"M",s,-15,"V",15]),class:zx("cross"),fill:"none",stroke:o,"stroke-width":"2px","stroke-linecap":"round"})),(i=Vx("text",{x:-40,y:-10,fill:o,class:zx("label")})).textContent="(0, 0)",xe(n,i)}function qx(e){return e.join(" ")}function zx(e){return"djs-origin-"+e}function Vx(e,t){var n=De(e);return Oe(n,t),n}Lx.$inject=["config.origin","canvas"];var Fx={__init__:[Lx]},Hx={offset:{x:150,y:75},tolerance:50,alignOnSave:!0};function Ux(e,t,n,i,r,o){function s(e,n){var i=n.offset,r=n.tolerance,o={};return["x","y"].forEach((function(n){var s=-e[n]+i[n],a=t.get("gridSnapping",!1);a&&(s=function(e,t,n){n||(n="round");return Math[n](e/t)*t}(s,a.getGridSpacing())),o[n]=Math.abs(s)<r?0:s})),o}function a(){var t=r.viewbox().inner,n=r.getRootElement().children;if(n.length){var o=s(t,e);0===o.x&&0===o.y||i.execute("elements.alignToOrigin",{elements:n,delta:o})}}function l(e){return function(t){n.once("commandStack.changed",(function(){var n=t.delta,i=r.viewbox().scale;r.scroll({dx:e*n.x*i,dy:e*n.y*i})}))}}var c,p,d;e=function(e){var t=j({},Hx,e||{});return u(t.offset)&&(t.offset={x:t.offset,y:t.offset}),t}(e),i.register("elements.alignToOrigin",{preExecute:function(e){var t=e.delta,n=e.elements;o.moveElements(n,t)},execute:l(-1),revert:l(1)}),e.alignOnSave&&(c=t.get("_parent",!1),p=n,((d=c&&c._eventBus)||p).on("saveXML.start",1250,a),d&&p.on("diagram.destroy",(function(){d.off("saveXML.start",a)}))),this.align=a,this.computeAdjustment=s,this._config=e}Ux.$inject=["config.alignToOrigin","injector","eventBus","commandStack","canvas","modeling"];var Wx={__init__:["alignToOrigin"],alignToOrigin:["type",Ux]};function Gx(e){function t(e){if(!e.labelTarget){var t=Or(e);_r(t,"bpmn:Participant")&&(t=t.processRef),_r(t,"bpmn:Process")&&(t.isExecutable=!!t.isExecutable)}}e.on(["shape.added","root.added"],(function(e){t(e.element)})),e.on("elements.changed",(function(e){e.elements.forEach((function(e){t(e)}))}))}Gx.$inject=["eventBus"];var Qx,Xx,Kx,Yx,Zx,Jx,ew,tw,nw={__init__:[Gx]},iw={},rw=[],ow=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,sw=Array.isArray;function aw(e,t){for(var n in t)e[n]=t[n];return e}function lw(e){var t=e.parentNode;t&&t.removeChild(e)}function cw(e,t,n){var i,r,o,s={};for(o in t)"key"==o?i=t[o]:"ref"==o?r=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?Qx.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===s[o]&&(s[o]=e.defaultProps[o]);return pw(e,s,i,r,null)}function pw(e,t,n,i,r){var o={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++Kx:r,__i:-1,__u:0};return null==r&&null!=Xx.vnode&&Xx.vnode(o),o}function uw(e){return e.children}function dw(e,t){this.props=e,this.context=t}function hw(e,t){if(null==t)return e.__?hw(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?hw(e):null}function mw(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return mw(e)}}function fw(e){(!e.__d&&(e.__d=!0)&&Yx.push(e)&&!gw.__r++||Zx!==Xx.debounceRendering)&&((Zx=Xx.debounceRendering)||Jx)(gw)}function gw(){var e,t,n,i,r,o,s,a,l;for(Yx.sort(ew);e=Yx.shift();)e.__d&&(t=Yx.length,i=void 0,o=(r=(n=e).__v).__e,a=[],l=[],(s=n.__P)&&((i=aw({},r)).__v=r.__v+1,Xx.vnode&&Xx.vnode(i),Pw(s,i,r,n.__n,void 0!==s.ownerSVGElement,32&r.__u?[o]:null,a,null==o?hw(r):o,!!(32&r.__u),l),i.__.__k[i.__i]=i,kw(a,i,l),i.__e!=o&&mw(i)),Yx.length>t&&Yx.sort(ew));gw.__r=0}function yw(e,t,n,i,r,o,s,a,l,c,p){var u,d,h,m,f,g=i&&i.__k||rw,y=t.length;for(n.__d=l,function(e,t,n){var i,r,o,s,a,l=t.length,c=n.length,p=c,u=0;for(e.__k=[],i=0;i<l;i++)null!=(r=e.__k[i]=null==(r=t[i])||"boolean"==typeof r||"function"==typeof r?null:"string"==typeof r||"number"==typeof r||"bigint"==typeof r||r.constructor==String?pw(null,r,null,null,r):sw(r)?pw(uw,{children:r},null,null,null):void 0===r.constructor&&r.__b>0?pw(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)?(r.__=e,r.__b=e.__b+1,a=xw(r,n,s=i+u,p),r.__i=a,o=null,-1!==a&&(p--,(o=n[a])&&(o.__u|=131072)),null==o||null===o.__v?(-1==a&&u--,"function"!=typeof r.type&&(r.__u|=65536)):a!==s&&(a===s+1?u++:a>s?p>l-s?u+=a-s:u--:u=a<s&&a==s-1?a-s:0,a!==i+u&&(r.__u|=65536))):(o=n[i])&&null==o.key&&o.__e&&(o.__e==e.__d&&(e.__d=hw(o)),Cw(o,o,!1),n[i]=null,p--);if(p)for(i=0;i<c;i++)null!=(o=n[i])&&!(131072&o.__u)&&(o.__e==e.__d&&(e.__d=hw(o)),Cw(o,o))}(n,t,g),l=n.__d,u=0;u<y;u++)null!=(h=n.__k[u])&&"boolean"!=typeof h&&"function"!=typeof h&&(d=-1===h.__i?iw:g[h.__i]||iw,h.__i=u,Pw(e,h,d,r,o,s,a,l,c,p),m=h.__e,h.ref&&d.ref!=h.ref&&(d.ref&&Sw(d.ref,null,h),p.push(h.ref,h.__c||m,h)),null==f&&null!=m&&(f=m),65536&h.__u||d.__k===h.__k?l=vw(h,l,e):"function"==typeof h.type&&void 0!==h.__d?l=h.__d:m&&(l=m.nextSibling),h.__d=void 0,h.__u&=-196609);n.__d=l,n.__e=f}function vw(e,t,n){var i,r;if("function"==typeof e.type){for(i=e.__k,r=0;i&&r<i.length;r++)i[r]&&(i[r].__=e,t=vw(i[r],t,n));return t}return e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function bw(e,t){return t=t||[],null==e||"boolean"==typeof e||(sw(e)?e.some((function(e){bw(e,t)})):t.push(e)),t}function xw(e,t,n,i){var r=e.key,o=e.type,s=n-1,a=n+1,l=t[n];if(null===l||l&&r==l.key&&o===l.type)return n;if(i>(null==l||131072&l.__u?0:1))for(;s>=0||a<t.length;){if(s>=0){if((l=t[s])&&!(131072&l.__u)&&r==l.key&&o===l.type)return s;s--}if(a<t.length){if((l=t[a])&&!(131072&l.__u)&&r==l.key&&o===l.type)return a;a++}}return-1}function ww(e,t,n){"-"===t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||ow.test(t)?n:n+"px"}function _w(e,t,n,i,r){var o;e:if("style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof i&&(e.style.cssText=i=""),i)for(t in i)n&&t in n||ww(e.style,t,"");if(n)for(t in n)i&&n[t]===i[t]||ww(e.style,t,n[t])}else if("o"===t[0]&&"n"===t[1])o=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?i?n.u=i.u:(n.u=Date.now(),e.addEventListener(t,o?Ow:Ew,o)):e.removeEventListener(t,o?Ow:Ew,o);else{if(r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&"rowSpan"!==t&&"colSpan"!==t&&"role"!==t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,n))}}function Ew(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(Xx.event?Xx.event(e):e)}function Ow(e){return this.l[e.type+!0](Xx.event?Xx.event(e):e)}function Pw(e,t,n,i,r,o,s,a,l,c){var p,u,d,h,m,f,g,y,v,b,x,w,_,E,O,P=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(l=!!(32&n.__u),o=[a=t.__e=n.__e]),(p=Xx.__b)&&p(t);e:if("function"==typeof P)try{if(y=t.props,v=(p=P.contextType)&&i[p.__c],b=p?v?v.props.value:p.__:i,n.__c?g=(u=t.__c=n.__c).__=u.__E:("prototype"in P&&P.prototype.render?t.__c=u=new P(y,b):(t.__c=u=new dw(y,b),u.constructor=P,u.render=Aw),v&&v.sub(u),u.props=y,u.state||(u.state={}),u.context=b,u.__n=i,d=u.__d=!0,u.__h=[],u._sb=[]),null==u.__s&&(u.__s=u.state),null!=P.getDerivedStateFromProps&&(u.__s==u.state&&(u.__s=aw({},u.__s)),aw(u.__s,P.getDerivedStateFromProps(y,u.__s))),h=u.props,m=u.state,u.__v=t,d)null==P.getDerivedStateFromProps&&null!=u.componentWillMount&&u.componentWillMount(),null!=u.componentDidMount&&u.__h.push(u.componentDidMount);else{if(null==P.getDerivedStateFromProps&&y!==h&&null!=u.componentWillReceiveProps&&u.componentWillReceiveProps(y,b),!u.__e&&(null!=u.shouldComponentUpdate&&!1===u.shouldComponentUpdate(y,u.__s,b)||t.__v===n.__v)){for(t.__v!==n.__v&&(u.props=y,u.state=u.__s,u.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.forEach((function(e){e&&(e.__=t)})),x=0;x<u._sb.length;x++)u.__h.push(u._sb[x]);u._sb=[],u.__h.length&&s.push(u);break e}null!=u.componentWillUpdate&&u.componentWillUpdate(y,u.__s,b),null!=u.componentDidUpdate&&u.__h.push((function(){u.componentDidUpdate(h,m,f)}))}if(u.context=b,u.props=y,u.__P=e,u.__e=!1,w=Xx.__r,_=0,"prototype"in P&&P.prototype.render){for(u.state=u.__s,u.__d=!1,w&&w(t),p=u.render(u.props,u.state,u.context),E=0;E<u._sb.length;E++)u.__h.push(u._sb[E]);u._sb=[]}else do{u.__d=!1,w&&w(t),p=u.render(u.props,u.state,u.context),u.state=u.__s}while(u.__d&&++_<25);u.state=u.__s,null!=u.getChildContext&&(i=aw(aw({},i),u.getChildContext())),d||null==u.getSnapshotBeforeUpdate||(f=u.getSnapshotBeforeUpdate(h,m)),yw(e,sw(O=null!=p&&p.type===uw&&null==p.key?p.props.children:p)?O:[O],t,n,i,r,o,s,a,l,c),u.base=t.__e,t.__u&=-161,u.__h.length&&s.push(u),g&&(u.__E=u.__=null)}catch(e){t.__v=null,l||null!=o?(t.__e=a,t.__u|=l?160:32,o[o.indexOf(a)]=null):(t.__e=n.__e,t.__k=n.__k),Xx.__e(e,t,n)}else null==o&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=function(e,t,n,i,r,o,s,a,l){var c,p,u,d,h,m,f,g=n.props,y=t.props,v=t.type;if("svg"===v&&(r=!0),null!=o)for(c=0;c<o.length;c++)if((h=o[c])&&"setAttribute"in h==!!v&&(v?h.localName===v:3===h.nodeType)){e=h,o[c]=null;break}if(null==e){if(null===v)return document.createTextNode(y);e=r?document.createElementNS("http://www.w3.org/2000/svg",v):document.createElement(v,y.is&&y),o=null,a=!1}if(null===v)g===y||a&&e.data===y||(e.data=y);else{if(o=o&&Qx.call(e.childNodes),g=n.props||iw,!a&&null!=o)for(g={},c=0;c<e.attributes.length;c++)g[(h=e.attributes[c]).name]=h.value;for(c in g)h=g[c],"children"==c||("dangerouslySetInnerHTML"==c?u=h:"key"===c||c in y||_w(e,c,null,h,r));for(c in y)h=y[c],"children"==c?d=h:"dangerouslySetInnerHTML"==c?p=h:"value"==c?m=h:"checked"==c?f=h:"key"===c||a&&"function"!=typeof h||g[c]===h||_w(e,c,h,g[c],r);if(p)a||u&&(p.__html===u.__html||p.__html===e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(u&&(e.innerHTML=""),yw(e,sw(d)?d:[d],t,n,i,r&&"foreignObject"!==v,o,s,o?o[0]:n.__k&&hw(n,0),a,l),null!=o)for(c=o.length;c--;)null!=o[c]&&lw(o[c]);a||(c="value",void 0!==m&&(m!==e[c]||"progress"===v&&!m||"option"===v&&m!==g[c])&&_w(e,c,m,g[c],!1),c="checked",void 0!==f&&f!==e[c]&&_w(e,c,f,g[c],!1))}return e}(n.__e,t,n,i,r,o,s,l,c);(p=Xx.diffed)&&p(t)}function kw(e,t,n){t.__d=void 0;for(var i=0;i<n.length;i++)Sw(n[i],n[++i],n[++i]);Xx.__c&&Xx.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){Xx.__e(e,t.__v)}}))}function Sw(e,t,n){try{"function"==typeof e?e(t):e.current=t}catch(e){Xx.__e(e,n)}}function Cw(e,t,n){var i,r;if(Xx.unmount&&Xx.unmount(e),(i=e.ref)&&(i.current&&i.current!==e.__e||Sw(i,null,t)),null!=(i=e.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){Xx.__e(e,t)}i.base=i.__P=null,e.__c=void 0}if(i=e.__k)for(r=0;r<i.length;r++)i[r]&&Cw(i[r],t,n||"function"!=typeof e.type);n||null==e.__e||lw(e.__e),e.__=e.__e=e.__d=void 0}function Aw(e,t,n){return this.constructor(e,n)}function Mw(e,t,n){var i,r,o,s;Xx.__&&Xx.__(e,t),r=(i="function"==typeof n)?null:n&&n.__k||t.__k,o=[],s=[],Pw(t,e=(!i&&n||t).__k=cw(uw,null,[e]),r||iw,iw,void 0!==t.ownerSVGElement,!i&&n?[n]:r?null:t.firstChild?Qx.call(t.childNodes):null,o,!i&&n?n:r?r.__e:t.firstChild,i,s),kw(o,e,s)}function Tw(e,t){var n={__c:t="__cC"+tw++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var n,i;return this.getChildContext||(n=[],(i={})[t]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&n.some((function(e){e.__e=!0,fw(e)}))},this.sub=function(e){n.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n.splice(n.indexOf(e),1),t&&t.call(e)}}),e.children}};return n.Provider.__=n.Consumer.contextType=n}Qx=rw.slice,Xx={__e:function(e,t,n,i){for(var r,o,s;t=t.__;)if((r=t.__c)&&!r.__)try{if((o=r.constructor)&&null!=o.getDerivedStateFromError&&(r.setState(o.getDerivedStateFromError(e)),s=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,i||{}),s=r.__d),s)return r.__E=r}catch(t){e=t}throw e}},Kx=0,dw.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=aw({},this.state),"function"==typeof e&&(e=e(aw({},n),this.props)),e&&aw(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),fw(this))},dw.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),fw(this))},dw.prototype.render=uw,Yx=[],Jx="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ew=function(e,t){return e.__v.__b-t.__v.__b},gw.__r=0,tw=0;var Rw,Dw,Nw,Bw,$w=0,jw=[],Iw=[],Lw=Xx.__b,qw=Xx.__r,zw=Xx.diffed,Vw=Xx.__c,Fw=Xx.unmount;function Hw(e,t){Xx.__h&&Xx.__h(Dw,e,$w||t),$w=0;var n=Dw.__H||(Dw.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({__V:Iw}),n.__[e]}function Uw(e){return $w=1,Ww(o_,e)}function Ww(e,t,n){var i=Hw(Rw++,2);if(i.t=e,!i.__c&&(i.__=[n?n(t):o_(void 0,t),function(e){var t=i.__N?i.__N[0]:i.__[0],n=i.t(t,e);t!==n&&(i.__N=[n,i.__[1]],i.__c.setState({}))}],i.__c=Dw,!Dw.u)){var r=function(e,t,n){if(!i.__c.__H)return!0;var r=i.__c.__H.__.filter((function(e){return e.__c}));if(r.every((function(e){return!e.__N})))return!o||o.call(this,e,t,n);var s=!1;return r.forEach((function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(s=!0)}})),!(!s&&i.__c.props===e)&&(!o||o.call(this,e,t,n))};Dw.u=!0;var o=Dw.shouldComponentUpdate,s=Dw.componentWillUpdate;Dw.componentWillUpdate=function(e,t,n){if(this.__e){var i=o;o=void 0,r(e,t,n),o=i}s&&s.call(this,e,t,n)},Dw.shouldComponentUpdate=r}return i.__N||i.__}function Gw(e,t){var n=Hw(Rw++,3);!Xx.__s&&r_(n.__H,t)&&(n.__=e,n.i=t,Dw.__H.__h.push(n))}function Qw(e,t){var n=Hw(Rw++,4);!Xx.__s&&r_(n.__H,t)&&(n.__=e,n.i=t,Dw.__h.push(n))}function Xw(e){return $w=5,Kw((function(){return{current:e}}),[])}function Kw(e,t){var n=Hw(Rw++,7);return r_(n.__H,t)?(n.__V=e(),n.i=t,n.__h=e,n.__V):n.__}function Yw(e,t){return $w=8,Kw((function(){return e}),t)}function Zw(e){var t=Dw.context[e.__c],n=Hw(Rw++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(Dw)),t.props.value):e.__}function Jw(){for(var e;e=jw.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(n_),e.__H.__h.forEach(i_),e.__H.__h=[]}catch(t){e.__H.__h=[],Xx.__e(t,e.__v)}}Xx.__b=function(e){Dw=null,Lw&&Lw(e)},Xx.__r=function(e){qw&&qw(e),Rw=0;var t=(Dw=e.__c).__H;t&&(Nw===Dw?(t.__h=[],Dw.__h=[],t.__.forEach((function(e){e.__N&&(e.__=e.__N),e.__V=Iw,e.__N=e.i=void 0}))):(t.__h.forEach(n_),t.__h.forEach(i_),t.__h=[],Rw=0)),Nw=Dw},Xx.diffed=function(e){zw&&zw(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==jw.push(t)&&Bw===Xx.requestAnimationFrame||((Bw=Xx.requestAnimationFrame)||t_)(Jw)),t.__H.__.forEach((function(e){e.i&&(e.__H=e.i),e.__V!==Iw&&(e.__=e.__V),e.i=void 0,e.__V=Iw}))),Nw=Dw=null},Xx.__c=function(e,t){t.some((function(e){try{e.__h.forEach(n_),e.__h=e.__h.filter((function(e){return!e.__||i_(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],Xx.__e(n,e.__v)}})),Vw&&Vw(e,t)},Xx.unmount=function(e){Fw&&Fw(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{n_(e)}catch(e){t=e}})),n.__H=void 0,t&&Xx.__e(t,n.__v))};var e_="function"==typeof requestAnimationFrame;function t_(e){var t,n=function(){clearTimeout(i),e_&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,100);e_&&(t=requestAnimationFrame(n))}function n_(e){var t=Dw,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),Dw=t}function i_(e){var t=Dw;e.__c=e.__(),Dw=t}function r_(e,t){return!e||e.length!==t.length||t.some((function(t,n){return t!==e[n]}))}function o_(e,t){return"function"==typeof t?t(e):t}function s_(e,t){for(var n in t)e[n]=t[n];return e}function a_(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var i in t)if("__source"!==i&&e[i]!==t[i])return!0;return!1}function l_(e){this.props=e}(l_.prototype=new dw).isPureReactComponent=!0,l_.prototype.shouldComponentUpdate=function(e,t){return a_(this.props,e)||a_(this.state,t)};var c_=Xx.__b;Xx.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),c_&&c_(e)};var p_="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function u_(e){function t(t){var n=s_({},t);return delete n.ref,e(n,t.ref||null)}return t.$$typeof=p_,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var d_=Xx.__e;Xx.__e=function(e,t,n,i){if(e.then)for(var r,o=t;o=o.__;)if((r=o.__c)&&r.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t);d_(e,t,n,i)};var h_=Xx.unmount;function m_(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach((function(e){"function"==typeof e.__c&&e.__c()})),e.__c.__H=null),null!=(e=s_({},e)).__c&&(e.__c.__P===n&&(e.__c.__P=t),e.__c=null),e.__k=e.__k&&e.__k.map((function(e){return m_(e,t,n)}))),e}function f_(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map((function(e){return f_(e,t,n)})),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function g_(){this.__u=0,this.t=null,this.__b=null}function y_(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function v_(){this.u=null,this.o=null}Xx.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),h_&&h_(e)},(g_.prototype=new dw).__c=function(e,t){var n=t.__c,i=this;null==i.t&&(i.t=[]),i.t.push(n);var r=y_(i.__v),o=!1,s=function(){o||(o=!0,n.__R=null,r?r(a):a())};n.__R=s;var a=function(){if(! --i.__u){if(i.state.__a){var e=i.state.__a;i.__v.__k[0]=f_(e,e.__c.__P,e.__c.__O)}var t;for(i.setState({__a:i.__b=null});t=i.t.pop();)t.forceUpdate()}};i.__u++||32&t.__u||i.setState({__a:i.__b=i.__v.__k[0]}),e.then(s,s)},g_.prototype.componentWillUnmount=function(){this.t=[]},g_.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=m_(this.__b,n,i.__O=i.__P)}this.__b=null}var r=t.__a&&cw(uw,null,e.fallback);return r&&(r.__u&=-33),[cw(uw,null,t.__a?null:e.children),r]};var b_=function(e,t,n){if(++n[1]===n[0]&&e.o.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.o.size))for(n=e.u;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.u=n=n[2]}};function x_(e){return this.getChildContext=function(){return e.context},e.children}function w_(e){var t=this,n=e.i;t.componentWillUnmount=function(){Mw(null,t.l),t.l=null,t.i=null},t.i&&t.i!==n&&t.componentWillUnmount(),t.l||(t.i=n,t.l={nodeType:1,parentNode:n,childNodes:[],appendChild:function(e){this.childNodes.push(e),t.i.appendChild(e)},insertBefore:function(e,n){this.childNodes.push(e),t.i.appendChild(e)},removeChild:function(e){this.childNodes.splice(this.childNodes.indexOf(e)>>>1,1),t.i.removeChild(e)}}),Mw(cw(x_,{context:t.context},e.__v),t.l)}function __(e,t){var n=cw(w_,{__v:e,i:t});return n.containerInfo=t,n}(v_.prototype=new dw).__a=function(e){var t=this,n=y_(t.__v),i=t.o.get(e);return i[0]++,function(r){var o=function(){t.props.revealOrder?(i.push(r),b_(t,e,i)):r()};n?n(o):o()}},v_.prototype.render=function(e){this.u=null,this.o=new Map;var t=bw(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var n=t.length;n--;)this.o.set(t[n],this.u=[1,0,this.u]);return e.children},v_.prototype.componentDidUpdate=v_.prototype.componentDidMount=function(){var e=this;this.o.forEach((function(t,n){b_(e,n,t)}))};var E_="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,O_=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,P_=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,k_=/[A-Z0-9]/g,S_="undefined"!=typeof document,C_=function(e){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(e)};dw.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach((function(e){Object.defineProperty(dw.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})}));var A_=Xx.event;function M_(){}function T_(){return this.cancelBubble}function R_(){return this.defaultPrevented}Xx.event=function(e){return A_&&(e=A_(e)),e.persist=M_,e.isPropagationStopped=T_,e.isDefaultPrevented=R_,e.nativeEvent=e};var D_={enumerable:!1,configurable:!0,get:function(){return this.class}},N_=Xx.vnode;Xx.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,i={};for(var r in t){var o=t[r];if(!("value"===r&&"defaultValue"in t&&null==o||S_&&"children"===r&&"noscript"===n||"class"===r||"className"===r)){var s=r.toLowerCase();"defaultValue"===r&&"value"in t&&null==t.value?r="value":"download"===r&&!0===o?o="":"ondoubleclick"===s?r="ondblclick":"onchange"!==s||"input"!==n&&"textarea"!==n||C_(t.type)?"onfocus"===s?r="onfocusin":"onblur"===s?r="onfocusout":P_.test(r)?r=s:-1===n.indexOf("-")&&O_.test(r)?r=r.replace(k_,"-$&").toLowerCase():null===o&&(o=void 0):s=r="oninput","oninput"===s&&i[r=s]&&(r="oninputCapture"),i[r]=o}}"select"==n&&i.multiple&&Array.isArray(i.value)&&(i.value=bw(t.children).forEach((function(e){e.props.selected=-1!=i.value.indexOf(e.props.value)}))),"select"==n&&null!=i.defaultValue&&(i.value=bw(t.children).forEach((function(e){e.props.selected=i.multiple?-1!=i.defaultValue.indexOf(e.props.value):i.defaultValue==e.props.value}))),t.class&&!t.className?(i.class=t.class,Object.defineProperty(i,"className",D_)):(t.className&&!t.class||t.class&&t.className)&&(i.class=i.className=t.className),e.props=i}(e),e.$$typeof=E_,N_&&N_(e)};var B_=Xx.__r;Xx.__r=function(e){B_&&B_(e),e.__c};var $_=Xx.diffed;Xx.diffed=function(e){$_&&$_(e);var t=e.props,n=e.__e;null!=n&&"textarea"===e.type&&"value"in t&&t.value!==n.value&&(n.value=null==t.value?"":t.value),null};var j_=cw,I_=0;function L_(e,t,n,i,r,o){var s,a,l={};for(a in t)"ref"==a?s=t[a]:l[a]=t[a];var c={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--I_,__i:-1,__u:0,__source:r,__self:o};if("function"==typeof e&&(s=e.defaultProps))for(a in s)void 0===l[a]&&(l[a]=s[a]);return Xx.vnode&&Xx.vnode(c),c}function q_(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var z_,V_={exports:{}};
172
172
  /*!
173
173
  Copyright (c) 2018 Jed Watson.
174
174
  Licensed under the MIT License (MIT), see