maestro-3.0.1-rc2/modules/maestro_template_builder/js/MaestroTemplateBuilder.js
modules/maestro_template_builder/js/MaestroTemplateBuilder.js
(function(J){typeof define=="function"&&define.amd?define(J):J()})((function(){"use strict";var pc=Object.defineProperty;var gc=(J,at,ft)=>at in J?pc(J,at,{enumerable:!0,configurable:!0,writable:!0,value:ft}):J[at]=ft;var Yi=(J,at,ft)=>gc(J,typeof at!="symbol"?at+"":at,ft);(function(t,e){t.Maestro=t.Maestro||{},Maestro.maestroDiagram={},Maestro.maestroDisplayedTasks={},Maestro.maestroLineFrom=null,Maestro.maestroFalseLineFrom=null,Maestro.canvas={},Maestro.canvasRoot={},Maestro.panZoomTimeout=null,Maestro.canvasZoom=1,Maestro.panLeft=0,Maestro.panTop=0,Maestro.panZoomDelay=1500,Maestro.taskTypes={},Maestro.maestroTaskColours=[],Maestro.taskWidth=100,Maestro.taskHeight=50,Maestro.taskRadius=50,Maestro.maestroDrawOneTask=function(n){const r=Maestro.maestroDiagram.get("elementFactory");var i=n.taskname;i=i.slice(0,13),i!=n.taskname&&(i=i+"...");let o=r.createShape({id:n.id,taskType:n.type,parent:Maestro.canvasRoot,x:parseInt(n.left),y:parseInt(n.top),width:Maestro.taskWidth,height:Maestro.taskHeight,type:"maestro:Task",draggable:!0,taskid:n.id,colour:Maestro.maestroTaskColours[n.type],uiLabel:n.uilabel,taskName:i,longTaskName:n.taskname,capabilities:n.capabilities,to:n.to||[],falsebranch:n.falsebranch||[],workflowStatusMessage:n.workflow_status_stage_message,workflowStatusNumber:n.workflow_status_stage_number});Maestro.canvas.addShape(o,Maestro.canvasRoot),Maestro.maestroDisplayedTasks[n.id]=o},Maestro.maestroDrawConnectors=function(n){const r=Maestro.maestroDiagram.get("elementFactory");var i=[],o,a=Maestro.maestroDisplayedTasks[n],s=a.to;s.forEach(u=>{if(u!=""){o=Maestro.maestroDisplayedTasks[u],i=Maestro.maestroCalculateClosestEdgePointsFromShapes(a,o);let l=r.createConnection({type:"connection",waypoints:i,source:a,target:o,businessObject:{connectionType:"MaestroNormal"}});Maestro.canvas.addConnection(l,Maestro.canvasRoot)}});var c=a.falsebranch;c.forEach(u=>{if(u!=""){o=Maestro.maestroDisplayedTasks[u],i=Maestro.maestroCalculateClosestEdgePointsFromShapes(a,o);let l=r.createConnection({type:"connection",waypoints:i,source:a,target:o,businessObject:{connectionType:"MaestroFalse"}});Maestro.canvas.addConnection(l,Maestro.canvasRoot)}})},Maestro.maestroHandleEditClick=function(n,r,i,o){e("#edit-menu > div").children().each(function(){let a=this.getAttribute("maestro_capabilities_id");a!=null&&a.startsWith("maestro_template_")&&e("#"+this.id).hide()}),e("#edit-menu > div").children().each(function(){let a=this.getAttribute("maestro_capabilities_id");if(a!=null&&a.startsWith("maestro_template_"))for(let s=0;s<r.length;s++)a==r[s]&&e("#"+this.id).show()}),e("#maestro-task-menu").css("top",o+"px"),e("#maestro-task-menu").css("left",i+"px"),e("#maestro-task-menu").css("display","block"),e('[name="task_clicked"]').val(n)},Maestro.maestroCalculateClosestEdgePointsFromShapes=function(n,r){let i=n.x,o=n.y,a=n.width,s=n.height,c=r.x,u=r.y,l=r.width,f=r.height,h=i+a/2,p=o+s/2,v=c+l/2,b=u+f/2,_=l/2,A=f/2;var R,d=[],g=[],y=[],E=[],L=[];n.taskType=="MaestroStart"||n.taskType=="MaestroEnd"?(y.push([h,o]),y.push([h,o+s]),y.push([h+A,o+s/2]),y.push([i+s/2,o+s/2])):n.taskType=="MaestroIf"?(y.push([h,p-_]),y.push([h,p+_]),y.push([i+a,o+s/2]),y.push([i,o+s/2])):(y.push([h,o]),y.push([h,o+s]),y.push([i+a,o+s/2]),y.push([i,o+s/2])),r.taskType=="MaestroStart"||r.taskType=="MaestroEnd"?(E.push([v,u]),E.push([v,u+f]),E.push([v+f/2,u+f/2]),E.push([c+f/2,u+f/2])):r.taskType=="MaestroIf"?(E.push([v,b-_]),E.push([v,b+_]),E.push([c+l,u+f/2]),E.push([c,u+f/2])):(E.push([v,u]),E.push([v,u+f]),E.push([c+l,u+f/2]),E.push([c,u+f/2]));for(let m=0;m<y.length;m++)for(let M=0;M<E.length;M++){let O=Math.abs(E[M][0]-y[m][0]),ot=Math.abs(y[m][1]-E[M][1]);R=Math.pow(O,2)+Math.pow(ot,2),d.push(R),g.push([m,M])}R=0;for(let m=0;m<d.length;m++)(d[m]<R||R==0)&&(R=d[m],L=g[m]);var x={x:y[L[0]][0],y:y[L[0]][1]},S={x:E[L[1]][0],y:E[L[1]][1]};return[x,S]},Maestro.maestroCalculateClosestEdgePointsFromConnection=function(n){const r=n.source,i=n.target;return Maestro.maestroCalculateClosestEdgePointsFromShapes(r,i)},Maestro.maestroClearCanvasSeletedElement=function(){const n=Maestro.maestroDiagram.get("selection");n.select(null),n.deselect()},Maestro.maestroGetTaskReference=function(n){return Maestro.maestroDisplayedTasks[n]},Maestro.maestroRemoveTaskLines=function(n){var r=Maestro.maestroGetTaskReference(n)||null;if(r){const i=[...r.outgoing],o=[...r.incoming];i.forEach(function(a){let s=a.id,c=a.target;Maestro.canvas.removeConnection(a),c&&c.incoming&&[...c.incoming].forEach(function(l){l.id==s&&c.incoming.remove(l)}),r.outgoing.remove(a)}),o.forEach(function(a){let s=a.id,c=a.source;Maestro.canvas.removeConnection(a),c&&c.outgoing&&[...c.outgoing].forEach(function(l){l.id==s&&c.outgoing.remove(l)}),r.incoming.remove(a)})}Maestro.maestroClearCanvasSeletedElement()}})(window,jQuery);const J=/^class[ {]/;function at(t){return J.test(t.toString())}function ft(t){return Array.isArray(t)}function Qe(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function ve(...t){t.length===1&&ft(t[0])&&(t=t[0]),t=[...t];const e=t.pop();return e.$inject=t,e}const Ui=/constructor\s*[^(]*\(\s*([^)]*)\)/m,Ki=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,qi=/\/\*([^*]*)\*\//m;function Zi(t){if(typeof t!="function")throw new Error(`Cannot annotate "${t}". Expected a function!`);const e=t.toString().match(at(t)?Ui:Ki);if(!e)return[];const n=e[1]||e[2];return n&&n.split(",").map(r=>{const i=r.match(qi);return(i&&i[1]||r).trim()})||[]}function Bn(t,e){const n=e||{get:function(d,g){if(r.push(d),g===!1)return null;throw s(`No provider for "${d}"!`)}},r=[],i=this._providers=Object.create(n._providers||null),o=this._instances=Object.create(null),a=o.injector=this,s=function(d){const g=r.join(" -> ");return r.length=0,new Error(g?`${d} (Resolving: ${g})`:d)};function c(d,g){if(!i[d]&&d.includes(".")){const y=d.split(".");let E=c(y.shift());for(;y.length;)E=E[y.shift()];return E}if(Qe(o,d))return o[d];if(Qe(i,d)){if(r.indexOf(d)!==-1)throw r.push(d),s("Cannot resolve circular dependency!");return r.push(d),o[d]=i[d][0](i[d][1]),r.pop(),o[d]}return n.get(d,g)}function u(d,g){if(typeof g>"u"&&(g={}),typeof d!="function")if(ft(d))d=ve(d.slice());else throw s(`Cannot invoke "${d}". Expected a function!`);const E=(d.$inject||Zi(d)).map(L=>Qe(g,L)?g[L]:c(L));return{fn:d,dependencies:E}}function l(d){const{fn:g,dependencies:y}=u(d),E=Function.prototype.bind.call(g,null,...y);return new E}function f(d,g,y){const{fn:E,dependencies:L}=u(d,y);return E.apply(g,L)}function h(d){return ve(g=>d.get(g))}function p(d,g){if(g&&g.length){const y=Object.create(null),E=Object.create(null),L=[],x=[],S=[];let m,M,O,ot;for(let Z in i)m=i[Z],g.indexOf(Z)!==-1&&(m[2]==="private"?(M=L.indexOf(m[3]),M===-1?(O=m[3].createChild([],g),ot=h(O),L.push(m[3]),x.push(O),S.push(ot),y[Z]=[ot,Z,"private",O]):y[Z]=[S[M],Z,"private",x[M]]):y[Z]=[m[2],m[1]],E[Z]=!0),(m[2]==="factory"||m[2]==="type")&&m[1].$scope&&g.forEach(Wi=>{m[1].$scope.indexOf(Wi)!==-1&&(y[Z]=[m[2],m[1]],E[Wi]=!0)});g.forEach(Z=>{if(!E[Z])throw new Error('No provider for "'+Z+'". Cannot use provider from the parent!')}),d.unshift(y)}return new Bn(d,a)}const v={factory:f,type:l,value:function(d){return d}};function b(d,g){const y=d.__init__||[];return function(){y.forEach(E=>{typeof E=="string"?g.get(E):g.invoke(E)})}}function _(d){const g=d.__exports__;if(g){const y=d.__modules__,E=Object.keys(d).reduce((M,O)=>(O!=="__exports__"&&O!=="__modules__"&&O!=="__init__"&&O!=="__depends__"&&(M[O]=d[O]),M),Object.create(null)),L=(y||[]).concat(E),x=p(L),S=ve(function(M){return x.get(M)});g.forEach(function(M){i[M]=[S,M,"private",x]});const m=(d.__init__||[]).slice();return m.unshift(function(){x.init()}),d=Object.assign({},d,{__init__:m}),b(d,x)}return Object.keys(d).forEach(function(y){if(y==="__init__"||y==="__depends__")return;const E=d[y];if(E[2]==="private"){i[y]=E;return}const L=E[0],x=E[1];i[y]=[v[L],Xi(L,x),L]}),b(d,a)}function A(d,g){return d.indexOf(g)!==-1||(d=(g.__depends__||[]).reduce(A,d),d.indexOf(g)!==-1)?d:d.concat(g)}function R(d){const g=d.reduce(A,[]).map(_);let y=!1;return function(){y||(y=!0,g.forEach(E=>E()))}}this.get=c,this.invoke=f,this.instantiate=l,this.createChild=p,this.init=R(t)}function Xi(t,e){return t!=="value"&&ft(e)&&(e=ve(e.slice())),e}function Tt(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}var Qi=1e3;function ht(t,e){var n=this;e=e||Qi,t.on(["render.shape","render.connection"],e,function(r,i){var o=r.type,a=i.element,s=i.gfx,c=i.attrs;if(n.canRender(a))return o==="render.shape"?n.drawShape(s,a,c):n.drawConnection(s,a,c)}),t.on(["render.getShapePath","render.getConnectionPath"],e,function(r,i){if(n.canRender(i))return r.type==="render.getShapePath"?n.getShapePath(i):n.getConnectionPath(i)})}ht.prototype.canRender=function(t){},ht.prototype.drawShape=function(t,e){},ht.prototype.drawConnection=function(t,e){},ht.prototype.getShapePath=function(t){},ht.prototype.getConnectionPath=function(t){};function Ji(t){return Array.prototype.concat.apply([],t)}const Yt=Object.prototype.toString,to=Object.prototype.hasOwnProperty;function Wn(t){return t===void 0}function X(t){return t!==void 0}function Je(t){return t==null}function D(t){return Yt.call(t)==="[object Array]"}function tt(t){return Yt.call(t)==="[object Object]"}function N(t){return Yt.call(t)==="[object Number]"}function Q(t){const e=Yt.call(t);return e==="[object Function]"||e==="[object AsyncFunction]"||e==="[object GeneratorFunction]"||e==="[object AsyncGeneratorFunction]"||e==="[object Proxy]"}function ye(t){return Yt.call(t)==="[object String]"}function tn(t,e){return!Je(t)&&to.call(t,e)}function et(t,e){const n=Un(e);let r;return w(t,function(i,o){if(n(i,o))return r=i,!1}),r}function nt(t,e){const n=Un(e);let r=[];return w(t,function(i,o){n(i,o)&&r.push(i)}),r}function w(t,e){let n,r;if(Wn(t))return;const i=D(t)?so:ao;for(let o in t)if(tn(t,o)&&(n=t[o],r=e(n,i(o)),r===!1))return n}function me(t,e,n){return w(t,function(r,i){n=e(n,r,i)}),n}function Yn(t,e){return!!me(t,function(n,r,i){return n&&e(r,i)},!0)}function eo(t,e){return!!et(t,e)}function dt(t,e){let n=[];return w(t,function(r,i){n.push(e(r,i))}),n}function no(t){return t&&Object.keys(t)||[]}function ro(t){return no(t).length}function io(t){return dt(t,e=>e)}function _e(t,e,n={}){return e=en(e),w(t,function(r){let i=e(r)||"_",o=n[i];o||(o=n[i]=[]),o.push(r)}),n}function oo(t,...e){t=en(t);let n={};return w(e,i=>_e(i,t,n)),dt(n,function(i,o){return i[0]})}function xe(t,e){e=en(e);let n=[];return w(t,function(r,i){let o=e(r,i),a={d:o,v:r};for(var s=0;s<n.length;s++){let{d:c}=n[s];if(o<c){n.splice(s,0,a);return}}n.push(a)}),dt(n,r=>r.v)}function we(t){return function(e){return Yn(t,function(n,r){return e[r]===n})}}function en(t){return Q(t)?t:e=>e[t]}function Un(t){return Q(t)?t:e=>e===t}function ao(t){return t}function so(t){return Number(t)}function Kn(t,e){let n,r,i,o;function a(f){let h=Date.now(),p=f?0:o+e-h;if(p>0)return s(p);t.apply(i,r),c()}function s(f){n=setTimeout(a,f)}function c(){n&&clearTimeout(n),n=o=r=i=void 0}function u(){n&&a(!0),c()}function l(...f){o=Date.now(),r=f,i=this,n||s(e)}return l.flush=u,l.cancel=c,l}function be(t,e){return t.bind(e)}function k(t,...e){return Object.assign(t,...e)}function nn(t,e){let n={},r=Object(t);return w(e,function(i){i in r&&(n[i]=t[i])}),n}function co(t,e){let n={},r=Object(t);return w(r,function(i,o){e.indexOf(o)===-1&&(n[o]=i)}),n}function uo(t,e){if(t.ownerDocument!==e.ownerDocument)try{return e.ownerDocument.importNode(t,!0)}catch{}return t}function lo(t,e){return e.appendChild(uo(t,e))}function z(t,e){return lo(e,t),t}var rn=2,qn={"alignment-baseline":1,"baseline-shift":1,clip:1,"clip-path":1,"clip-rule":1,color:1,"color-interpolation":1,"color-interpolation-filters":1,"color-profile":1,"color-rendering":1,cursor:1,direction:1,display:1,"dominant-baseline":1,"enable-background":1,fill:1,"fill-opacity":1,"fill-rule":1,filter:1,"flood-color":1,"flood-opacity":1,font:1,"font-family":1,"font-size":rn,"font-size-adjust":1,"font-stretch":1,"font-style":1,"font-variant":1,"font-weight":1,"glyph-orientation-horizontal":1,"glyph-orientation-vertical":1,"image-rendering":1,kerning:1,"letter-spacing":1,"lighting-color":1,marker:1,"marker-end":1,"marker-mid":1,"marker-start":1,mask:1,opacity:1,overflow:1,"pointer-events":1,"shape-rendering":1,"stop-color":1,"stop-opacity":1,stroke:1,"stroke-dasharray":1,"stroke-dashoffset":1,"stroke-linecap":1,"stroke-linejoin":1,"stroke-miterlimit":1,"stroke-opacity":1,"stroke-width":rn,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function fo(t,e){return qn[e]?t.style[e]:t.getAttributeNS(null,e)}function Zn(t,e,n){var r=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=qn[r];i?(i===rn&&typeof n=="number"&&(n=String(n)+"px"),t.style[r]=n):t.setAttributeNS(null,e,n)}function ho(t,e){var n=Object.keys(e),r,i;for(r=0,i;i=n[r];r++)Zn(t,i,e[i])}function T(t,e,n){if(typeof e=="string")if(n!==void 0)Zn(t,e,n);else return fo(t,e);else ho(t,e);return t}const po=Object.prototype.toString;function B(t){return new pt(t)}function pt(t){if(!t||!t.nodeType)throw new Error("A DOM element reference is required");this.el=t,this.list=t.classList}pt.prototype.add=function(t){return this.list.add(t),this},pt.prototype.remove=function(t){return po.call(t)=="[object RegExp]"?this.removeMatching(t):(this.list.remove(t),this)},pt.prototype.removeMatching=function(t){const e=this.array();for(let n=0;n<e.length;n++)t.test(e[n])&&this.remove(e[n]);return this},pt.prototype.toggle=function(t,e){return typeof e<"u"?e!==this.list.toggle(t,e)&&this.list.toggle(t):this.list.toggle(t),this},pt.prototype.array=function(){return Array.from(this.list)},pt.prototype.has=pt.prototype.contains=function(t){return this.list.contains(t)};function go(t){for(var e;e=t.firstChild;)t.removeChild(e);return t}function Xn(t){return t.cloneNode(!0)}var on={svg:"http://www.w3.org/2000/svg"},Qn='<svg xmlns="'+on.svg+'"';function vo(t){var e=!1;t.substring(0,4)==="<svg"?t.indexOf(on.svg)===-1&&(t=Qn+t.substring(4)):(t=Qn+">"+t+"</svg>",e=!0);var n=yo(t);if(!e)return n;for(var r=document.createDocumentFragment(),i=n.firstChild;i.firstChild;)r.appendChild(i.firstChild);return r}function yo(t){var e;return e=new DOMParser,e.async=!1,e.parseFromString(t,"text/xml")}function G(t,e){var n;return t=t.trim(),t.charAt(0)==="<"?(n=vo(t).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(on.svg,t),e&&T(n,e),n}var an=null;function Jn(){return an===null&&(an=G("svg")),an}function tr(t,e){var n,r,i=Object.keys(e);for(n=0;r=i[n];n++)t[r]=e[r];return t}function mo(t,e,n,r,i,o){var a=Jn().createSVGMatrix();switch(arguments.length){case 0:return a;case 1:return tr(a,t);case 6:return tr(a,{a:t,b:e,c:n,d:r,e:i,f:o})}}function _o(t){return Jn().createSVGTransform()}function Ot(t){var e=t.parentNode;return e&&e.removeChild(t),t}function xo(t,e){return e instanceof SVGMatrix?t.createSVGTransformFromMatrix(e):e}function wo(t,e){var n,r;for(t.clear(),n=0;r=e[n];n++)t.appendItem(xo(t,r))}function sn(t,e){var n=t.transform.baseVal;return e&&(Array.isArray(e)||(e=[e]),wo(n,e)),n.consolidate()}function cn(t){return t.flat().join(",").replace(/,?([A-Za-z]),?/g,"$1")}function bo(t){return["M",t.x,t.y]}function un(t){return["L",t.x,t.y]}function Eo(t,e,n){return["C",t.x,t.y,e.x,e.y,n.x,n.y]}function So(t,e){const n=t.length,r=[bo(t[0])];for(let i=1;i<n;i++){const o=t[i-1],a=t[i],s=t[i+1];if(!s||!e){r.push(un(a));continue}const c=Math.min(e,ln(a.x-o.x,a.y-o.y),ln(s.x-a.x,s.y-a.y));if(!c){r.push(un(a));continue}const u=Ee(a,o,c),l=Ee(a,o,c*.5),f=Ee(a,s,c),h=Ee(a,s,c*.5);r.push(un(u)),r.push(Eo(l,h,f))}return r}function Ee(t,e,n){const r=e.x-t.x,i=e.y-t.y,o=ln(r,i),a=n/o;return{x:t.x+r*a,y:t.y+i*a}}function ln(t,e){return Math.sqrt(Math.pow(t,2)+Math.pow(e,2))}function er(t,e,n){N(e)&&(n=e,e=null),e||(e={});const r=G("path",e);return N(n)&&(r.dataset.cornerRadius=String(n)),nr(r,t)}function nr(t,e){const n=parseInt(t.dataset.cornerRadius,10)||0;return T(t,{d:cn(So(e,n))}),t}function Co(t){return nt(t,function(e){return!et(t,function(n){return n!==e&&rr(e,n)})})}function rr(t,e){if(e){if(t===e)return e;if(t.parent)return rr(t.parent,e)}}function ir(t,e,n){var r=!0;return t.push(e),r}function fn(t,e,n){n=n||0,D(t)||(t=[t]),w(t,function(r,i){var o=e(r,i,n);D(o)&&o.length&&fn(o,e,n+1)})}function ko(t,e,n){var r=[],i=[];return fn(t,function(o,a,s){ir(r,o);var c=o.children;if(c&&ir(i,c))return c}),r}function Mo(t,e){return ko(t)}function Ro(t,e,n){Wn(e)&&(e=!0),tt(e)&&(n=e,e=!0),n=n||{};var r=Ut(n.allShapes),i=Ut(n.allConnections),o=Ut(n.enclosedElements),a=Ut(n.enclosedConnections),s=Ut(n.topLevel,e&&_e(t,function(l){return l.id}));function c(l){s[l.source.id]&&s[l.target.id]&&(s[l.id]=[l]),r[l.source.id]&&r[l.target.id]&&(a[l.id]=o[l.id]=l),i[l.id]=l}function u(l){if(o[l.id]=l,l.waypoints)a[l.id]=i[l.id]=l;else return r[l.id]=l,w(l.incoming,c),w(l.outgoing,c),l.children}return fn(t,u),{allShapes:r,allConnections:i,topLevel:s,enclosedConnections:a,enclosedElements:o}}function st(t,e){e=!!e,D(t)||(t=[t]);var n,r,i,o;return w(t,function(a){var s=a;a.waypoints&&!e&&(s=st(a.waypoints,!0));var c=s.x,u=s.y,l=s.height||0,f=s.width||0;(c<n||n===void 0)&&(n=c),(u<r||r===void 0)&&(r=u),(c+f>i||i===void 0)&&(i=c+f),(u+l>o||o===void 0)&&(o=u+l)}),{x:n,y:r,height:o-r,width:i-n}}function or(t){return"waypoints"in t?"connection":"x"in t?"shape":"root"}function ar(t){return!!(t&&t.isFrame)}function Ut(t,e){return k({},t||{},e||{})}var To=1;function gt(t,e){ht.call(this,t,To),this.CONNECTION_STYLE=e.style(["no-fill"],{strokeWidth:5,stroke:"fuchsia"}),this.SHAPE_STYLE=e.style({fill:"white",stroke:"fuchsia",strokeWidth:2}),this.FRAME_STYLE=e.style(["no-fill"],{stroke:"fuchsia",strokeDasharray:4,strokeWidth:2})}Tt(gt,ht),gt.prototype.canRender=function(){return!0},gt.prototype.drawShape=function(e,n,r){var i=G("rect");return T(i,{x:0,y:0,width:n.width||0,height:n.height||0}),ar(n)?T(i,k({},this.FRAME_STYLE,r||{})):T(i,k({},this.SHAPE_STYLE,r||{})),z(e,i),i},gt.prototype.drawConnection=function(e,n,r){var i=er(n.waypoints,k({},this.CONNECTION_STYLE,r||{}));return z(e,i),i},gt.prototype.getShapePath=function(e){var n=e.x,r=e.y,i=e.width,o=e.height,a=[["M",n,r],["l",i,0],["l",0,o],["l",-i,0],["z"]];return cn(a)},gt.prototype.getConnectionPath=function(e){var n=e.waypoints,r,i,o=[];for(r=0;i=n[r];r++)i=i.original||i,o.push([r===0?"M":"L",i.x,i.y]);return cn(o)},gt.$inject=["eventBus","styles"];function Oo(){var t={"no-fill":{fill:"none"},"no-border":{strokeOpacity:0},"no-events":{pointerEvents:"none"}},e=this;this.cls=function(n,r,i){var o=this.style(r,i);return k(o,{class:n})},this.style=function(n,r){!D(n)&&!r&&(r=n,n=[]);var i=me(n,function(o,a){return k(o,t[a]||{})},{});return r?k(i,r):i},this.computeStyle=function(n,r,i){return D(r)||(i=r,r=[]),e.style(r||[],k({},i,n||{}))}}const Ao={__init__:["defaultRenderer"],defaultRenderer:["type",gt],styles:["type",Oo]};function Po(t,e){return e.forEach(function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach(function(r){if(r!=="default"&&!(r in t)){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}})}),Object.freeze(t)}const jo=Object.prototype.toString,Lo=Object.prototype.hasOwnProperty;function $o(t){return t===void 0}function Io(t){return jo.call(t)==="[object Array]"}function Do(t,e){return Lo.call(t,e)}function sr(t,e){let n,r;if($o(t))return;const i=Io(t)?No:Ho;for(let o in t)if(Do(t,o)&&(n=t[o],r=e(n,i(o)),r===!1))return n}function Ho(t){return t}function No(t){return Number(t)}function Kt(t,...e){const n=t.style;return sr(e,function(r){r&&sr(r,function(i,o){n[o]=i})}),t}function At(t,e,n){return arguments.length==2?t.getAttribute(e):n===null?t.removeAttribute(e):(t.setAttribute(e,n),t)}const Fo=Object.prototype.toString;function ct(t){return new vt(t)}function vt(t){if(!t||!t.nodeType)throw new Error("A DOM element reference is required");this.el=t,this.list=t.classList}vt.prototype.add=function(t){return this.list.add(t),this},vt.prototype.remove=function(t){return Fo.call(t)=="[object RegExp]"?this.removeMatching(t):(this.list.remove(t),this)},vt.prototype.removeMatching=function(t){const e=this.array();for(let n=0;n<e.length;n++)t.test(e[n])&&this.remove(e[n]);return this},vt.prototype.toggle=function(t,e){return typeof e<"u"?e!==this.list.toggle(t,e)&&this.list.toggle(t):this.list.toggle(t),this},vt.prototype.array=function(){return Array.from(this.list)},vt.prototype.has=vt.prototype.contains=function(t){return this.list.contains(t)};function hn(t){for(var e;e=t.firstChild;)t.removeChild(e);return t}function dn(t,e,n){var r=n?t:t.parentNode;return r&&typeof r.closest=="function"&&r.closest(e)||null}var Se={},Ce,pn,gn;function cr(){Ce=window.addEventListener?"addEventListener":"attachEvent",pn=window.removeEventListener?"removeEventListener":"detachEvent",gn=Ce!=="addEventListener"?"on":""}var zo=Se.bind=function(t,e,n,r){return Ce||cr(),t[Ce](gn+e,n,r||!1),n},Go=Se.unbind=function(t,e,n,r){return pn||cr(),t[pn](gn+e,n,r||!1),n},j=Po({__proto__:null,bind:zo,unbind:Go,default:Se},[Se]),ur=["focus","blur"];function Vo(t,e,n,r,i){return ur.indexOf(n)!==-1&&(i=!0),j.bind(t,n,function(o){var a=o.target||o.srcElement;o.delegateTarget=dn(a,e,!0),o.delegateTarget&&r.call(t,o)},i)}function Bo(t,e,n,r){return ur.indexOf(e)!==-1&&(r=!0),j.unbind(t,e,n,r)}var ke={bind:Vo,unbind:Bo},Wo=Yo,lr=!1,Me;typeof document<"u"&&(Me=document.createElement("div"),Me.innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',lr=!Me.getElementsByTagName("link").length,Me=void 0);var H={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:lr?[1,"X<div>","</div>"]:[0,"",""]};H.td=H.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],H.option=H.optgroup=[1,'<select multiple="multiple">',"</select>"],H.thead=H.tbody=H.colgroup=H.caption=H.tfoot=[1,"<table>","</table>"],H.polyline=H.ellipse=H.polygon=H.circle=H.text=H.line=H.path=H.rect=H.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];function Yo(t,e){if(typeof t!="string")throw new TypeError("String expected");e||(e=document);var n=/<([\w:]+)/.exec(t);if(!n)return e.createTextNode(t);t=t.replace(/^\s+|\s+$/g,"");var r=n[1];if(r=="body"){var c=e.createElement("html");return c.innerHTML=t,c.removeChild(c.lastChild)}var i=Object.prototype.hasOwnProperty.call(H,r)?H[r]:H._default,o=i[0],a=i[1],s=i[2],c=e.createElement("div");for(c.innerHTML=a+t+s;o--;)c=c.lastChild;if(c.firstChild==c.lastChild)return c.removeChild(c.firstChild);for(var u=e.createDocumentFragment();c.firstChild;)u.appendChild(c.removeChild(c.firstChild));return u}var yt=Wo;function Uo(t,e){return t&&typeof t.matches=="function"&&t.matches(e)||!1}function rt(t,e){return e=e||document,e.querySelector(t)}function Ko(t,e){return e=e||document,e.querySelectorAll(t)}function vn(t){t.parentNode&&t.parentNode.removeChild(t)}function qt(t,e){if(!t||!e)return-1;var n=t.indexOf(e);return n!==-1&&t.splice(n,1),n}function mt(t,e,n){if(!(!t||!e)){typeof n!="number"&&(n=-1);var r=t.indexOf(e);if(r!==-1){if(r===n)return;if(n!==-1)t.splice(r,1);else return}n!==-1?t.splice(n,0,e):t.push(e)}}function fr(t,e){return!t||!e?-1:t.indexOf(e)}function K(t){return tt(t)&&tn(t,"waypoints")}function Dt(t){return tt(t)&&tn(t,"labelTarget")}function hr(t){return{x:Math.round(t.x),y:Math.round(t.y)}}function Zt(t){return{top:t.y,right:t.x+(t.width||0),bottom:t.y+(t.height||0),left:t.x}}function qo(t){return hr({x:t.x+(t.width||0)/2,y:t.y+(t.height||0)/2})}function Zo(t){for(var e=t.waypoints,n=e.reduce(function(u,l,f){var h=e[f-1];if(h){var p=u[u.length-1],v=p&&p.endLength||0,b=Qo(h,l);u.push({start:h,end:l,startLength:v,endLength:v+b,length:b})}return u},[]),r=n.reduce(function(u,l){return u+l.length},0),i=r/2,o=0,a=n[o];a.endLength<i;)a=n[++o];var s=(i-a.startLength)/a.length,c={x:a.start.x+(a.end.x-a.start.x)*s,y:a.start.y+(a.end.y-a.start.y)*s};return c}function Re(t){return K(t)?Zo(t):qo(t)}function Xo(t,e,n){n=n||0,tt(n)||(n={x:n,y:n});var r=Zt(t),i=Zt(e),o=r.bottom+n.y<=i.top,a=r.left-n.x>=i.right,s=r.top-n.y>=i.bottom,c=r.right+n.x<=i.left,u=o?"top":s?"bottom":null,l=c?"left":a?"right":null;return l&&u?u+"-"+l:l||u||"intersect"}function Qo(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Te(t,e){return Math.round(t*e)/e}function dr(t){return N(t)?t+"px":t}function Jo(t){for(;t.parent;)t=t.parent;return t}function ta(t){t=k({},{width:"100%",height:"100%"},t);const e=t.container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container djs-parent"),Kt(n,{position:"relative",overflow:"hidden",width:dr(t.width),height:dr(t.height)}),e.appendChild(n),n}function pr(t,e,n){const r=G("g");B(r).add(e);const i=n!==void 0?n:t.childNodes.length-1;return t.insertBefore(r,t.childNodes[i]||null),r}const ea="base",gr=0,na=1,ra={shape:["x","y","width","height"],connection:["waypoints"]};function C(t,e,n,r){this._eventBus=e,this._elementRegistry=r,this._graphicsFactory=n,this._rootsIdx=0,this._layers={},this._planes=[],this._rootElement=null,this._focused=!1,this._init(t||{})}C.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],C.prototype._init=function(t){const e=this._eventBus,n=this._container=ta(t),r=this._svg=G("svg");T(r,{width:"100%",height:"100%"}),At(r,"tabindex",0),t.autoFocus&&e.on("element.hover",()=>{this.restoreFocus()}),e.on("element.mousedown",500,o=>{this.focus()}),r.addEventListener("focusin",()=>{this._setFocused(!0)}),r.addEventListener("focusout",()=>{this._setFocused(!1)}),z(n,r);const i=this._viewport=pr(r,"viewport");t.deferUpdate&&(this._viewboxChanged=Kn(be(this._viewboxChanged,this),300)),e.on("diagram.init",()=>{e.fire("canvas.init",{svg:r,viewport:i})}),e.on(["shape.added","connection.added","shape.removed","connection.removed","elements.changed","root.set"],()=>{delete this._cachedViewbox}),e.on("diagram.destroy",500,this._destroy,this),e.on("diagram.clear",500,this._clear,this)},C.prototype._destroy=function(){this._eventBus.fire("canvas.destroy",{svg:this._svg,viewport:this._viewport});const t=this._container.parentNode;t&&t.removeChild(this._container),delete this._svg,delete this._container,delete this._layers,delete this._planes,delete this._rootElement,delete this._viewport},C.prototype._setFocused=function(t){t!=this._focused&&(this._focused=t,this._eventBus.fire("canvas.focus.changed",{focused:t}))},C.prototype._clear=function(){this._elementRegistry.getAll().forEach(e=>{const n=or(e);n==="root"?this.removeRootElement(e):this._removeElement(e,n)}),this._planes=[],this._rootElement=null,delete this._cachedViewbox},C.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)},C.prototype.restoreFocus=function(){document.activeElement===document.body&&this.focus()},C.prototype.isFocused=function(){return this._focused},C.prototype.getDefaultLayer=function(){return this.getLayer(ea,gr)},C.prototype.getLayer=function(t,e){if(!t)throw new Error("must specify a name");let n=this._layers[t];if(n||(n=this._layers[t]=this._createLayer(t,e)),typeof e<"u"&&n.index!==e)throw new Error("layer <"+t+"> already created at index <"+e+">");return n.group},C.prototype._getChildIndex=function(t){return me(this._layers,function(e,n){return n.visible&&t>=n.index&&e++,e},0)},C.prototype._createLayer=function(t,e){typeof e>"u"&&(e=na);const n=this._getChildIndex(e);return{group:pr(this._viewport,"layer-"+t,n),index:e,visible:!0}},C.prototype.showLayer=function(t){if(!t)throw new Error("must specify a name");const e=this._layers[t];if(!e)throw new Error("layer <"+t+"> does not exist");const n=this._viewport,r=e.group,i=e.index;if(e.visible)return r;const o=this._getChildIndex(i);return n.insertBefore(r,n.childNodes[o]||null),e.visible=!0,r},C.prototype.hideLayer=function(t){if(!t)throw new Error("must specify a name");const e=this._layers[t];if(!e)throw new Error("layer <"+t+"> does not exist");const n=e.group;return e.visible&&(Ot(n),e.visible=!1),n},C.prototype._removeLayer=function(t){const e=this._layers[t];e&&(delete this._layers[t],Ot(e.group))},C.prototype.getActiveLayer=function(){const t=this._findPlaneForRoot(this.getRootElement());return t?t.layer:null},C.prototype.findRoot=function(t){return typeof t=="string"&&(t=this._elementRegistry.get(t)),t?(this._findPlaneForRoot(Jo(t))||{}).rootElement:void 0},C.prototype.getRootElements=function(){return this._planes.map(function(t){return t.rootElement})},C.prototype._findPlaneForRoot=function(t){return et(this._planes,function(e){return e.rootElement===t})},C.prototype.getContainer=function(){return this._container},C.prototype._updateMarker=function(t,e,n){let r;t.id||(t=this._elementRegistry.get(t)),t.markers=t.markers||new Set,r=this._elementRegistry._elements[t.id],r&&(w([r.gfx,r.secondaryGfx],function(i){i&&(n?(t.markers.add(e),B(i).add(e)):(t.markers.delete(e),B(i).remove(e)))}),this._eventBus.fire("element.marker.update",{element:t,gfx:r.gfx,marker:e,add:!!n}))},C.prototype.addMarker=function(t,e){this._updateMarker(t,e,!0)},C.prototype.removeMarker=function(t,e){this._updateMarker(t,e,!1)},C.prototype.hasMarker=function(t,e){return t.id||(t=this._elementRegistry.get(t)),t.markers?t.markers.has(e):!1},C.prototype.toggleMarker=function(t,e){this.hasMarker(t,e)?this.removeMarker(t,e):this.addMarker(t,e)},C.prototype.getRootElement=function(){const t=this._rootElement;return t||this._planes.length?t:this.setRootElement(this.addRootElement(null))},C.prototype.addRootElement=function(t){const e=this._rootsIdx++;t||(t={id:"__implicitroot_"+e,children:[],isImplicit:!0});const n=t.layer="root-"+e;this._ensureValid("root",t);const r=this.getLayer(n,gr);return this.hideLayer(n),this._addRoot(t,r),this._planes.push({rootElement:t,layer:r}),t},C.prototype.removeRootElement=function(t){if(typeof t=="string"&&(t=this._elementRegistry.get(t)),!!this._findPlaneForRoot(t))return this._removeRoot(t),this._removeLayer(t.layer),this._planes=this._planes.filter(function(n){return n.rootElement!==t}),this._rootElement===t&&(this._rootElement=null),t},C.prototype.setRootElement=function(t){if(t===this._rootElement)return t;let e;if(!t)throw new Error("rootElement required");return e=this._findPlaneForRoot(t),e||(t=this.addRootElement(t)),this._setRoot(t),t},C.prototype._removeRoot=function(t){const e=this._elementRegistry,n=this._eventBus;n.fire("root.remove",{element:t}),n.fire("root.removed",{element:t}),e.remove(t)},C.prototype._addRoot=function(t,e){const n=this._elementRegistry,r=this._eventBus;r.fire("root.add",{element:t}),n.add(t,e),r.fire("root.added",{element:t,gfx:e})},C.prototype._setRoot=function(t,e){const n=this._rootElement;n&&(this._elementRegistry.updateGraphics(n,null,!0),this.hideLayer(n.layer)),t&&(e||(e=this._findPlaneForRoot(t).layer),this._elementRegistry.updateGraphics(t,this._svg,!0),this.showLayer(t.layer)),this._rootElement=t,this._eventBus.fire("root.set",{element:t})},C.prototype._ensureValid=function(t,e){if(!e.id)throw new Error("element must have an id");if(this._elementRegistry.get(e.id))throw new Error("element <"+e.id+"> already exists");const n=ra[t];if(!Yn(n,function(i){return typeof e[i]<"u"}))throw new Error("must supply { "+n.join(", ")+" } with "+t)},C.prototype._setParent=function(t,e,n){mt(e.children,t,n),t.parent=e},C.prototype._addElement=function(t,e,n,r){n=n||this.getRootElement();const i=this._eventBus,o=this._graphicsFactory;this._ensureValid(t,e),i.fire(t+".add",{element:e,parent:n}),this._setParent(e,n,r);const a=o.create(t,e,r);return this._elementRegistry.add(e,a),o.update(t,e,a),i.fire(t+".added",{element:e,gfx:a}),e},C.prototype.addShape=function(t,e,n){return this._addElement("shape",t,e,n)},C.prototype.addConnection=function(t,e,n){return this._addElement("connection",t,e,n)},C.prototype._removeElement=function(t,e){const n=this._elementRegistry,r=this._graphicsFactory,i=this._eventBus;if(t=n.get(t.id||t),!!t)return i.fire(e+".remove",{element:t}),r.remove(t),qt(t.parent&&t.parent.children,t),t.parent=null,i.fire(e+".removed",{element:t}),n.remove(t),t},C.prototype.removeShape=function(t){return this._removeElement(t,"shape")},C.prototype.removeConnection=function(t){return this._removeElement(t,"connection")},C.prototype.getGraphics=function(t,e){return this._elementRegistry.getGraphics(t,e)},C.prototype._changeViewbox=function(t){this._eventBus.fire("canvas.viewbox.changing"),t.apply(this),this._cachedViewbox=null,this._viewboxChanged()},C.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},C.prototype.viewbox=function(t){if(t===void 0&&this._cachedViewbox)return structuredClone(this._cachedViewbox);const e=this._viewport,n=this.getSize();let r,i,o,a,s,c,u;if(t)this._changeViewbox(function(){s=Math.min(n.width/t.width,n.height/t.height);const l=this._svg.createSVGMatrix().scale(s).translate(-t.x,-t.y);sn(e,l)});else return o=this._rootElement?this.getActiveLayer():null,r=o&&o.getBBox()||{},a=sn(e),i=a?a.matrix:mo(),s=Te(i.a,1e3),c=Te(-i.e||0,1e3),u=Te(-i.f||0,1e3),t=this._cachedViewbox={x:c?c/s:0,y:u?u/s:0,width:n.width/s,height:n.height/s,scale:s,inner:{width:r.width||0,height:r.height||0,x:r.x||0,y:r.y||0},outer:n},t;return t},C.prototype.scroll=function(t){const e=this._viewport;let n=e.getCTM();return t&&this._changeViewbox(function(){t=k({dx:0,dy:0},t||{}),n=this._svg.createSVGMatrix().translate(t.dx,t.dy).multiply(n),vr(e,n)}),{x:n.e,y:n.f}},C.prototype.scrollToElement=function(t,e){let n=100;typeof t=="string"&&(t=this._elementRegistry.get(t));const r=this.findRoot(t);if(r!==this.getRootElement()&&this.setRootElement(r),r===t)return;e||(e={}),typeof e=="number"&&(n=e),e={top:e.top||n,right:e.right||n,bottom:e.bottom||n,left:e.left||n};const i=st(t),o=Zt(i),a=this.viewbox(),s=this.zoom();let c,u;a.y+=e.top/s,a.x+=e.left/s,a.width-=(e.right+e.left)/s,a.height-=(e.bottom+e.top)/s;const l=Zt(a);if(!(i.width<a.width&&i.height<a.height))c=i.x-a.x,u=i.y-a.y;else{const h=Math.max(0,o.right-l.right),p=Math.min(0,o.left-l.left),v=Math.max(0,o.bottom-l.bottom),b=Math.min(0,o.top-l.top);c=h||p,u=v||b}this.scroll({dx:-c*s,dy:-u*s})},C.prototype.zoom=function(t,e){if(!t)return this.viewbox(t).scale;if(t==="fit-viewport")return this._fitViewport(e);let n,r;return this._changeViewbox(function(){typeof e!="object"&&(n=this.viewbox().outer,e={x:n.width/2,y:n.height/2}),r=this._setZoom(t,e)}),Te(r.a,1e3)};function vr(t,e){const n="matrix("+e.a+","+e.b+","+e.c+","+e.d+","+e.e+","+e.f+")";t.setAttribute("transform",n)}C.prototype._fitViewport=function(t){const e=this.viewbox(),n=e.outer,r=e.inner;let i,o;return r.x>=0&&r.y>=0&&r.x+r.width<=n.width&&r.y+r.height<=n.height&&!t?o={x:0,y:0,width:Math.max(r.width+r.x,n.width),height:Math.max(r.height+r.y,n.height)}:(i=Math.min(1,n.width/r.width,n.height/r.height),o={x:r.x+(t?r.width/2-n.width/i/2:0),y:r.y+(t?r.height/2-n.height/i/2:0),width:n.width/i,height:n.height/i}),this.viewbox(o),this.viewbox(!1).scale},C.prototype._setZoom=function(t,e){const n=this._svg,r=this._viewport,i=n.createSVGMatrix(),o=n.createSVGPoint();let a,s,c,u,l;c=r.getCTM();const f=c.a;return e?(a=k(o,e),s=a.matrixTransform(c.inverse()),u=i.translate(s.x,s.y).scale(1/f*t).translate(-s.x,-s.y),l=c.multiply(u)):l=i.scale(t),vr(this._viewport,l),l},C.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},C.prototype.getAbsoluteBBox=function(t){const e=this.viewbox();let n;t.waypoints?n=this.getGraphics(t).getBBox():n=t;const r=n.x*e.scale-e.x*e.scale,i=n.y*e.scale-e.y*e.scale,o=n.width*e.scale,a=n.height*e.scale;return{x:r,y:i,width:o,height:a}},C.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var Ht="data-element-id";function Y(t){this._elements={},this._eventBus=t}Y.$inject=["eventBus"],Y.prototype.add=function(t,e,n){var r=t.id;this._validateId(r),T(e,Ht,r),n&&T(n,Ht,r),this._elements[r]={element:t,gfx:e,secondaryGfx:n}},Y.prototype.remove=function(t){var e=this._elements,n=t.id||t,r=n&&e[n];r&&(T(r.gfx,Ht,""),r.secondaryGfx&&T(r.secondaryGfx,Ht,""),delete e[n])},Y.prototype.updateId=function(t,e){this._validateId(e),typeof t=="string"&&(t=this.get(t)),this._eventBus.fire("element.updateId",{element:t,newId:e});var n=this.getGraphics(t),r=this.getGraphics(t,!0);this.remove(t),t.id=e,this.add(t,n,r)},Y.prototype.updateGraphics=function(t,e,n){var r=t.id||t,i=this._elements[r];return n?i.secondaryGfx=e:i.gfx=e,e&&T(e,Ht,r),e},Y.prototype.get=function(t){var e;typeof t=="string"?e=t:e=t&&T(t,Ht);var n=this._elements[e];return n&&n.element},Y.prototype.filter=function(t){var e=[];return this.forEach(function(n,r){t(n,r)&&e.push(n)}),e},Y.prototype.find=function(t){for(var e=this._elements,n=Object.keys(e),r=0;r<n.length;r++){var i=n[r],o=e[i],a=o.element,s=o.gfx;if(t(a,s))return a}},Y.prototype.getAll=function(){return this.filter(function(t){return t})},Y.prototype.forEach=function(t){var e=this._elements;Object.keys(e).forEach(function(n){var r=e[n],i=r.element,o=r.gfx;return t(i,o)})},Y.prototype.getGraphics=function(t,e){var n=t.id||t,r=this._elements[n];return r&&(e?r.secondaryGfx:r.gfx)},Y.prototype._validateId=function(t){if(!t)throw new Error("element must have an id");if(this._elements[t])throw new Error("element with id "+t+" already added")};function ia(t,e,n,r){var i=n.inverse;return Object.defineProperty(t,"remove",{value:function(o){var a=this.indexOf(o);return a!==-1&&(this.splice(a,1),e.unset(o,i,r)),o}}),Object.defineProperty(t,"contains",{value:function(o){return this.indexOf(o)!==-1}}),Object.defineProperty(t,"add",{value:function(o,a){var s=this.indexOf(o);if(typeof a>"u"){if(s!==-1)return;a=this.length}s!==-1&&this.splice(s,1),this.splice(a,0,o),s===-1&&e.set(o,i,r)}}),Object.defineProperty(t,"__refs_collection",{value:!0}),t}function oa(t){return t.__refs_collection===!0}function aa(t,e){return Object.prototype.hasOwnProperty.call(t,e.name||e)}function yr(t,e,n){var r=ia(n[e.name]||[],t,e,n);Object.defineProperty(n,e.name,{enumerable:e.enumerable,value:r}),r.length&&r.forEach(function(i){t.set(i,e.inverse,n)})}function sa(t,e,n){var r=e.inverse,i=n[e.name];Object.defineProperty(n,e.name,{configurable:e.configurable,enumerable:e.enumerable,get:function(){return i},set:function(o){if(o!==i){var a=i;i=null,a&&t.unset(a,r,n),i=o,t.set(i,r,n)}}})}function q(t,e){if(!(this instanceof q))return new q(t,e);t.inverse=e,e.inverse=t,this.props={},this.props[t.name]=t,this.props[e.name]=e}q.prototype.bind=function(t,e){if(typeof e=="string"){if(!this.props[e])throw new Error("no property <"+e+"> in ref");e=this.props[e]}e.collection?yr(this,e,t):sa(this,e,t)},q.prototype.ensureRefsCollection=function(t,e){var n=t[e.name];return oa(n)||yr(this,e,t),n},q.prototype.ensureBound=function(t,e){aa(t,e)||this.bind(t,e)},q.prototype.unset=function(t,e,n){t&&(this.ensureBound(t,e),e.collection?this.ensureRefsCollection(t,e).remove(n):t[e.name]=void 0)},q.prototype.set=function(t,e,n){t&&(this.ensureBound(t,e),e.collection?this.ensureRefsCollection(t,e).add(n):t[e.name]=n)};var yn=new q({name:"children",enumerable:!0,collection:!0},{name:"parent"}),mr=new q({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),_r=new q({name:"attachers",collection:!0},{name:"host"}),xr=new q({name:"outgoing",collection:!0},{name:"source"}),wr=new q({name:"incoming",collection:!0},{name:"target"});function Nt(){Object.defineProperty(this,"businessObject",{writable:!0}),Object.defineProperty(this,"label",{get:function(){return this.labels[0]},set:function(t){var e=this.label,n=this.labels;!t&&e?n.remove(e):n.add(t,0)}}),yn.bind(this,"parent"),mr.bind(this,"labels"),xr.bind(this,"outgoing"),wr.bind(this,"incoming")}function Xt(){Nt.call(this),yn.bind(this,"children"),_r.bind(this,"host"),_r.bind(this,"attachers")}Tt(Xt,Nt);function br(){Nt.call(this),yn.bind(this,"children")}Tt(br,Xt);function Er(){Xt.call(this),mr.bind(this,"labelTarget")}Tt(Er,Xt);function Sr(){Nt.call(this),xr.bind(this,"source"),wr.bind(this,"target")}Tt(Sr,Nt);var ca={connection:Sr,shape:Xt,label:Er,root:br};function ua(t,e){var n=ca[t];if(!n)throw new Error("unknown type: <"+t+">");return k(new n,e)}function la(t){return t instanceof Nt}function Pt(){this._uid=12}Pt.prototype.createRoot=function(t){return this.create("root",t)},Pt.prototype.createLabel=function(t){return this.create("label",t)},Pt.prototype.createShape=function(t){return this.create("shape",t)},Pt.prototype.createConnection=function(t){return this.create("connection",t)},Pt.prototype.create=function(t,e){return e=k({},e||{}),e.id||(e.id=t+"_"+this._uid++),ua(t,e)};var Oe="__fn",Cr=1e3,fa=Array.prototype.slice;function V(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}V.prototype.on=function(t,e,n,r){if(t=D(t)?t:[t],Q(e)&&(r=n,n=e,e=Cr),!N(e))throw new Error("priority must be a number");var i=n;r&&(i=be(n,r),i[Oe]=n[Oe]||n);var o=this;t.forEach(function(a){o._addListener(a,{priority:e,callback:i,next:null})})},V.prototype.once=function(t,e,n,r){var i=this;if(Q(e)&&(r=n,n=e,e=Cr),!N(e))throw new Error("priority must be a number");function o(){o.__isTomb=!0;var a=n.apply(r,arguments);return i.off(t,o),a}o[Oe]=n,this.on(t,e,o)},V.prototype.off=function(t,e){t=D(t)?t:[t];var n=this;t.forEach(function(r){n._removeListener(r,e)})},V.prototype.createEvent=function(t){var e=new Qt;return e.init(t),e},V.prototype.fire=function(t,e){var n,r,i,o;if(o=fa.call(arguments),typeof t=="object"&&(e=t,t=e.type),!t)throw new Error("no event type specified");if(r=this._listeners[t],!!r){e instanceof Qt?n=e:n=this.createEvent(e),o[0]=n;var a=n.type;t!==a&&(n.type=t);try{i=this._invokeListeners(n,o,r)}finally{t!==a&&(n.type=a)}return i===void 0&&n.defaultPrevented&&(i=!1),i}},V.prototype.handleError=function(t){return this.fire("error",{error:t})===!1},V.prototype._destroy=function(){this._listeners={}},V.prototype._invokeListeners=function(t,e,n){for(var r;n&&!t.cancelBubble;)r=this._invokeListener(t,e,n),n=n.next;return r},V.prototype._invokeListener=function(t,e,n){var r;if(n.callback.__isTomb)return r;try{r=ha(n.callback,e),r!==void 0&&(t.returnValue=r,t.stopPropagation()),r===!1&&t.preventDefault()}catch(i){if(!this.handleError(i))throw console.error("unhandled error in event listener",i),i}return r},V.prototype._addListener=function(t,e){var n=this._getListeners(t),r;if(!n){this._setListeners(t,e);return}for(;n;){if(n.priority<e.priority){e.next=n,r?r.next=e:this._setListeners(t,e);return}r=n,n=n.next}r.next=e},V.prototype._getListeners=function(t){return this._listeners[t]},V.prototype._setListeners=function(t,e){this._listeners[t]=e},V.prototype._removeListener=function(t,e){var n=this._getListeners(t),r,i,o;if(!e){this._setListeners(t,null);return}for(;n;)r=n.next,o=n.callback,(o===e||o[Oe]===e)&&(i?i.next=r:this._setListeners(t,r)),i=n,n=r};function Qt(){}Qt.prototype.stopPropagation=function(){this.cancelBubble=!0},Qt.prototype.preventDefault=function(){this.defaultPrevented=!0},Qt.prototype.init=function(t){k(this,t||{})};function ha(t,e){return t.apply(null,e)}function Ae(t){return t.childNodes[0]}function da(t){return t.parentNode.childNodes[1]}function Pe(t,e,n){var r=_o();r.setTranslate(e,n),sn(t,r)}function W(t,e){this._eventBus=t,this._elementRegistry=e}W.$inject=["eventBus","elementRegistry"],W.prototype._getChildrenContainer=function(t){var e=this._elementRegistry.getGraphics(t),n;return t.parent?(n=da(e),n||(n=G("g"),B(n).add("djs-children"),z(e.parentNode,n))):n=e,n},W.prototype._clear=function(t){var e=Ae(t);return hn(e),e},W.prototype._createContainer=function(t,e,n,r){var i=G("g");B(i).add("djs-group"),typeof n<"u"?kr(i,e,e.childNodes[n]):z(e,i);var o=G("g");B(o).add("djs-element"),B(o).add("djs-"+t),r&&B(o).add("djs-frame"),z(i,o);var a=G("g");return B(a).add("djs-visual"),z(o,a),o},W.prototype.create=function(t,e,n){var r=this._getChildrenContainer(e.parent);return this._createContainer(t,r,n,ar(e))},W.prototype.updateContainments=function(t){var e=this,n=this._elementRegistry,r;r=me(t,function(i,o){return o.parent&&(i[o.parent.id]=o.parent),i},{}),w(r,function(i){var o=i.children;if(o){var a=e._getChildrenContainer(i);w(o.slice().reverse(),function(s){var c=n.getGraphics(s);kr(c.parentNode,a)})}})},W.prototype.drawShape=function(t,e,n={}){var r=this._eventBus;return r.fire("render.shape",{gfx:t,element:e,attrs:n})},W.prototype.getShapePath=function(t){var e=this._eventBus;return e.fire("render.getShapePath",t)},W.prototype.drawConnection=function(t,e,n={}){var r=this._eventBus;return r.fire("render.connection",{gfx:t,element:e,attrs:n})},W.prototype.getConnectionPath=function(t){var e=this._eventBus;return e.fire("render.getConnectionPath",t)},W.prototype.update=function(t,e,n){if(e.parent){var r=this._clear(n);if(t==="shape")this.drawShape(r,e),Pe(n,e.x,e.y);else if(t==="connection")this.drawConnection(r,e);else throw new Error("unknown type: "+t);e.hidden?T(n,"display","none"):T(n,"display","block")}},W.prototype.remove=function(t){var e=this._elementRegistry.getGraphics(t);Ot(e.parentNode)};function kr(t,e,n){var r=n||e.firstChild;t!==r&&e.insertBefore(t,r)}const pa={__depends__:[Ao],__init__:["canvas"],canvas:["type",C],elementRegistry:["type",Y],elementFactory:["type",Pt],eventBus:["type",V],graphicsFactory:["type",W]};function ga(t){var e=new Bn(t);return e.init(),e}function va(t){t=t||{};var e={config:["value",t]},n=[e,pa].concat(t.modules||[]);return ga(n)}function Jt(t,e){this._injector=e||va(t),this.get("eventBus").fire("diagram.init")}Jt.prototype.get=function(t,e){return this._injector.get(t,e)},Jt.prototype.invoke=function(t,e,n){return this._injector.invoke(t,e,n)},Jt.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")},Jt.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};function mn(t){return t&&t[t.length-1]}function Mr(t){return t.y}function Rr(t){return t.x}var ya={left:Rr,center:Rr,right:function(t){return t.x+t.width},top:Mr,middle:Mr,bottom:function(t){return t.y+t.height}};function Ft(t,e){this._modeling=t,this._rules=e}Ft.$inject=["modeling","rules"],Ft.prototype._getOrientationDetails=function(t){var e=["top","bottom","middle"],n="x",r="width";return e.indexOf(t)!==-1&&(n="y",r="height"),{axis:n,dimension:r}},Ft.prototype._isType=function(t,e){return e.indexOf(t)!==-1},Ft.prototype._alignmentPosition=function(t,e){var n=this._getOrientationDetails(t),r=n.axis,i=n.dimension,o={},a={},s=!1,c,u,l;function f(h,p){return Math.round((h[r]+p[r]+p[i])/2)}if(this._isType(t,["left","top"]))o[t]=e[0][r];else if(this._isType(t,["right","bottom"]))l=mn(e),o[t]=l[r]+l[i];else if(this._isType(t,["center","middle"])){if(w(e,function(h){var p=h[r]+Math.round(h[i]/2);a[p]?a[p].elements.push(h):a[p]={elements:[h],center:p}}),c=xe(a,function(h){return h.elements.length>1&&(s=!0),h.elements.length}),s)return o[t]=mn(c).center,o;u=e[0],e=xe(e,function(h){return h[r]+h[i]}),l=mn(e),o[t]=f(u,l)}return o},Ft.prototype.trigger=function(t,e){var n=this._modeling,r,i=nt(t,function(c){return!(c.waypoints||c.host||c.labelTarget)});if(r=this._rules.allowed("elements.align",{elements:i}),D(r)&&(i=r),!(i.length<2||!r)){var o=ya[e],a=xe(i,o),s=this._alignmentPosition(e,a);n.alignElements(a,s)}};const ma={__init__:["alignElements"],alignElements:["type",Ft]};function Tr(t){!t||typeof t.stopPropagation!="function"||t.stopPropagation()}function te(t){return t.originalEvent||t.srcEvent}function _n(t){Tr(t),Tr(te(t))}function ee(t){return t.pointers&&t.pointers.length&&(t=t.pointers[0]),t.touches&&t.touches.length&&(t=t.touches[0]),t?{x:t.clientX,y:t.clientY}:null}var Or=1500;function Ar(t,e,n){var r=this,i=n.get("dragging",!1);function o(a){if(!a.hover){var s=a.originalEvent,c=r._findTargetGfx(s),u=c&&t.get(c);c&&u&&(a.stopPropagation(),i.hover({element:u,gfx:c}),i.move(s))}}i&&e.on("drag.start",function(a){e.once("drag.move",Or,function(s){o(s)})}),(function(){var a,s;e.on("element.hover",function(c){a=c.gfx,s=c.element}),e.on("element.hover",Or,function(c){s&&e.fire("element.out",{element:s,gfx:a})}),e.on("element.out",function(){a=null,s=null})})(),this._findTargetGfx=function(a){var s,c;if(a instanceof MouseEvent)return s=ee(a),c=document.elementFromPoint(s.x,s.y),_a(c)}}Ar.$inject=["elementRegistry","eventBus","injector"];function _a(t){return dn(t,"svg, .djs-element",!0)}const xa={__init__:["hoverFix"],hoverFix:["type",Ar]};function wa(){return/mac/i.test(navigator.platform)}function Pr(t,e){return(te(t)||t).button===e}function ne(t){return Pr(t,0)}function ba(t){return Pr(t,1)}function Ea(t){var e=te(t)||t;return ne(t)&&e.shiftKey}function Sa(t){return!0}function je(t){return ne(t)||ba(t)}var jr=500;function Lr(t,e,n){var r=this;function i(x,S,m){if(!s(x,S)){var M,O,ot;m?O=e.getGraphics(m):(M=S.delegateTarget||S.target,M&&(O=M,m=e.get(O))),!(!O||!m)&&(ot=t.fire(x,{element:m,gfx:O,originalEvent:S}),ot===!1&&(S.stopPropagation(),S.preventDefault()))}}var o={};function a(x){return o[x]}function s(x,S){var m=u[x]||ne;return!m(S)}var c={click:"element.click",contextmenu:"element.contextmenu",dblclick:"element.dblclick",mousedown:"element.mousedown",mousemove:"element.mousemove",mouseover:"element.hover",mouseout:"element.out",mouseup:"element.mouseup"},u={"element.contextmenu":Sa,"element.mousedown":je,"element.mouseup":je,"element.click":je,"element.dblclick":je};function l(x,S,m){var M=c[x];if(!M)throw new Error("unmapped DOM event name <"+x+">");return i(M,S,m)}var f="svg, .djs-element";function h(x,S,m,M){var O=o[m]=function(ot){i(m,ot)};M&&(u[m]=M),O.$delegate=ke.bind(x,f,S,O)}function p(x,S,m){var M=a(m);M&&ke.unbind(x,S,M.$delegate)}function v(x){w(c,function(S,m){h(x,m,S)})}function b(x){w(c,function(S,m){p(x,m,S)})}t.on("canvas.destroy",function(x){b(x.svg)}),t.on("canvas.init",function(x){v(x.svg)}),t.on(["shape.added","connection.added"],function(x){var S=x.element,m=x.gfx;t.fire("interactionEvents.createHit",{element:S,gfx:m})}),t.on(["shape.changed","connection.changed"],jr,function(x){var S=x.element,m=x.gfx;t.fire("interactionEvents.updateHit",{element:S,gfx:m})}),t.on("interactionEvents.createHit",jr,function(x){var S=x.element,m=x.gfx;r.createDefaultHit(S,m)}),t.on("interactionEvents.updateHit",function(x){var S=x.element,m=x.gfx;r.updateDefaultHit(S,m)});var _=y("djs-hit djs-hit-stroke"),A=y("djs-hit djs-hit-click-stroke"),R=y("djs-hit djs-hit-all"),d=y("djs-hit djs-hit-no-move"),g={all:R,"click-stroke":A,stroke:_,"no-move":d};function y(x,S){return S=k({stroke:"white",strokeWidth:15},S||{}),n.cls(x,["no-fill","no-border"],S)}function E(x,S){var m=g[S];if(!m)throw new Error("invalid hit type <"+S+">");return T(x,m),x}function L(x,S){z(x,S)}this.removeHits=function(x){var S=Ko(".djs-hit",x);w(S,Ot)},this.createDefaultHit=function(x,S){var m=x.waypoints,M=x.isFrame,O;return m?this.createWaypointsHit(S,m):(O=M?"stroke":"all",this.createBoxHit(S,O,{width:x.width,height:x.height}))},this.createWaypointsHit=function(x,S){var m=er(S);return E(m,"stroke"),L(x,m),m},this.createBoxHit=function(x,S,m){m=k({x:0,y:0},m);var M=G("rect");return E(M,S),T(M,m),L(x,M),M},this.updateDefaultHit=function(x,S){var m=rt(".djs-hit",S);if(m)return x.waypoints?nr(m,x.waypoints):T(m,{width:x.width,height:x.height}),m},this.fire=i,this.triggerMouseEvent=l,this.mouseHandler=a,this.registerEvent=h,this.unregisterEvent=p}Lr.$inject=["eventBus","elementRegistry","styles"];const $r={__init__:["interactionEvents"],interactionEvents:["type",Lr]};function zt(t,e){this._eventBus=t,this._canvas=e,this._selectedElements=[];var n=this;t.on(["shape.remove","connection.remove"],function(r){var i=r.element;n.deselect(i)}),t.on(["diagram.clear","root.set"],function(r){n.select(null)})}zt.$inject=["eventBus","canvas"],zt.prototype.deselect=function(t){var e=this._selectedElements,n=e.indexOf(t);if(n!==-1){var r=e.slice();e.splice(n,1),this._eventBus.fire("selection.changed",{oldSelection:r,newSelection:e})}},zt.prototype.get=function(){return this._selectedElements},zt.prototype.isSelected=function(t){return this._selectedElements.indexOf(t)!==-1},zt.prototype.select=function(t,e){var n=this._selectedElements,r=n.slice();D(t)||(t=t?[t]:[]);var i=this._canvas,o=i.getRootElement();t=t.filter(function(a){var s=i.findRoot(a);return o===s}),e?w(t,function(a){n.indexOf(a)===-1&&n.push(a)}):this._selectedElements=n=t.slice(),this._eventBus.fire("selection.changed",{oldSelection:r,newSelection:n})};var Ir="hover",Dr="selected";function Hr(t,e){this._canvas=t;function n(i,o){t.addMarker(i,o)}function r(i,o){t.removeMarker(i,o)}e.on("element.hover",function(i){n(i.element,Ir)}),e.on("element.out",function(i){r(i.element,Ir)}),e.on("selection.changed",function(i){function o(u){r(u,Dr)}function a(u){n(u,Dr)}var s=i.oldSelection,c=i.newSelection;w(s,function(u){c.indexOf(u)===-1&&o(u)}),w(c,function(u){s.indexOf(u)===-1&&a(u)})})}Hr.$inject=["canvas","eventBus"];function Nr(t,e,n,r){t.on("create.end",500,function(i){var o=i.context,a=o.canExecute,s=o.elements,c=o.hints||{},u=c.autoSelect;if(a){if(u===!1)return;D(u)?e.select(u):e.select(s.filter(Ca))}}),t.on("connect.end",500,function(i){var o=i.context,a=o.connection;a&&e.select(a)}),t.on("shape.move.end",500,function(i){var o=i.previousSelection||[],a=r.get(i.context.shape.id),s=et(o,function(c){return a.id===c.id});s||e.select(a)}),t.on("element.click",function(i){if(ne(i)){var o=i.element;o===n.getRootElement()&&(o=null);var a=e.isSelected(o),s=e.get().length>1,c=Ea(i);if(a&&s)return c?e.deselect(o):e.select(o);a?e.deselect(o):e.select(o,c)}})}Nr.$inject=["eventBus","selection","canvas","elementRegistry"];function Ca(t){return!t.hidden}const Gt={__init__:["selectionVisuals","selectionBehavior"],__depends__:[$r],selection:["type",zt],selectionVisuals:["type",Hr],selectionBehavior:["type",Nr]};var ka=/^djs-cursor-.*$/;function xn(t){var e=ct(document.body);e.removeMatching(ka),t&&e.add("djs-cursor-"+t)}function Fr(){xn(null)}var Ma=5e3;function zr(t,e){e=e||"element.click";function n(){return!1}return t.once(e,Ma,n),function(){t.off(e,n)}}function Gr(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}function Vt(t,e){return{x:t.x-e.x,y:t.y-e.y}}function wn(t){return t.altKey?!1:t.ctrlKey||t.metaKey}function Ra(t,e){return t=D(t)?t:[t],t.indexOf(e.key)!==-1||t.indexOf(e.code)!==-1}var Bt=Math.round,Vr="djs-drag-active";function jt(t){t.preventDefault()}function Ta(t){return typeof TouchEvent<"u"&&t instanceof TouchEvent}function Oa(t){return Math.sqrt(Math.pow(t.x,2)+Math.pow(t.y,2))}function Br(t,e,n,r){var i={threshold:5,trapClick:!0},o;function a(d){var g=e.viewbox(),y=e._container.getBoundingClientRect();return{x:g.x+(d.x-y.left)/g.scale,y:g.y+(d.y-y.top)/g.scale}}function s(d,g){g=g||o;var y=t.createEvent(k({},g.payload,g.data,{isTouch:g.isTouch}));return t.fire("drag."+d,y)===!1?!1:t.fire(g.prefix+"."+d,y)}function c(d){var g=d.filter(function(y){return r.get(y.id)});g.length&&n.select(g)}function u(d,g){var y=o.payload,E=o.displacement,L=o.globalStart,x=ee(d),S=Vt(x,L),m=o.localStart,M=a(x),O=Vt(M,m);if(!o.active&&(g||Oa(S)>o.threshold)){if(k(y,{x:Bt(m.x+E.x),y:Bt(m.y+E.y),dx:0,dy:0},{originalEvent:d}),s("start")===!1)return _();o.active=!0,o.keepSelection||(y.previousSelection=n.get(),n.select(null)),o.cursor&&xn(o.cursor),e.addMarker(e.getRootElement(),Vr)}_n(d),o.active&&(k(y,{x:Bt(M.x+E.x),y:Bt(M.y+E.y),dx:Bt(O.x),dy:Bt(O.y)},{originalEvent:d}),s("move"))}function l(d){var g,y=!0;o.active&&(d&&(o.payload.originalEvent=d,_n(d)),y=s("end")),y===!1&&s("rejected"),g=A(y!==!0),s("ended",g)}function f(d){Ra("Escape",d)&&(jt(d),_())}function h(d){var g;o.active&&(g=zr(t),setTimeout(g,400),jt(d)),l(d)}function p(d){u(d)}function v(d){var g=o.payload;g.hoverGfx=d.gfx,g.hover=d.element,s("hover")}function b(d){s("out");var g=o.payload;g.hoverGfx=null,g.hover=null}function _(d){var g;if(o){var y=o.active;y&&s("cancel"),g=A(d),y&&s("canceled",g)}}function A(d){var g,y;s("cleanup"),Fr(),o.trapClick?y=h:y=l,j.unbind(document,"mousemove",u),j.unbind(document,"dragstart",jt),j.unbind(document,"selectstart",jt),j.unbind(document,"mousedown",y,!0),j.unbind(document,"mouseup",y,!0),j.unbind(document,"keyup",f),j.unbind(document,"touchstart",p,!0),j.unbind(document,"touchcancel",_,!0),j.unbind(document,"touchmove",u,!0),j.unbind(document,"touchend",l,!0),t.off("element.hover",v),t.off("element.out",b),e.removeMarker(e.getRootElement(),Vr);var E=o.payload.previousSelection;return d!==!1&&E&&!n.get().length&&c(E),g=o,o=null,g}function R(d,g,y,E){o&&_(!1),typeof g=="string"&&(E=y,y=g,g=null),E=k({},i,E||{});var L=E.data||{},x,S,m,M,O;E.trapClick?M=h:M=l,d?(x=te(d)||d,S=ee(d),_n(d),x.type==="dragstart"&&jt(x)):(x=null,S={x:0,y:0}),m=a(S),g||(g=m),O=Ta(x),o=k({prefix:y,data:L,payload:{},globalStart:S,displacement:Vt(g,m),localStart:m,isTouch:O},E),E.manual||(O?(j.bind(document,"touchstart",p,!0),j.bind(document,"touchcancel",_,!0),j.bind(document,"touchmove",u,!0),j.bind(document,"touchend",l,!0)):(j.bind(document,"mousemove",u),j.bind(document,"dragstart",jt),j.bind(document,"selectstart",jt),j.bind(document,"mousedown",M,!0),j.bind(document,"mouseup",M,!0)),j.bind(document,"keyup",f),t.on("element.hover",v),t.on("element.out",b)),s("init"),E.autoActivate&&u(d,!0)}t.on("diagram.destroy",_),this.init=R,this.move=u,this.hover=v,this.out=b,this.end=l,this.cancel=_,this.context=function(){return o},this.setOptions=function(d){k(i,d)}}Br.$inject=["eventBus","canvas","selection","elementRegistry"];const bn={__depends__:[xa,Gt],dragging:["type",Br]};function En(t){this._counter=0,this._prefix=(t?t+"-":"")+Math.floor(Math.random()*1e9)+"-"}En.prototype.next=function(){return this._prefix+ ++this._counter};const Aa=new En("ps");var Pa=["marker-start","marker-mid","marker-end"],ja=["circle","ellipse","line","path","polygon","polyline","path","rect"];function _t(t,e,n,r){this._elementRegistry=t,this._canvas=n,this._styles=r}_t.$inject=["elementRegistry","eventBus","canvas","styles"],_t.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")},_t.prototype.getGfx=function(t){return this._elementRegistry.getGraphics(t)},_t.prototype.addDragger=function(t,e,n,r="djs-dragger"){n=n||this.getGfx(t);var i=Xn(n),o=n.getBoundingClientRect();return this._cloneMarkers(Ae(i),r),T(i,this._styles.cls(r,[],{x:o.top,y:o.left})),z(e,i),T(i,"data-preview-support-element-id",t.id),i},_t.prototype.addFrame=function(t,e){var n=G("rect",{class:"djs-resize-overlay",width:t.width,height:t.height,x:t.x,y:t.y});return z(e,n),T(n,"data-preview-support-element-id",t.id),n},_t.prototype._cloneMarkers=function(t,e="djs-dragger",n=t){var r=this;t.childNodes&&t.childNodes.forEach(i=>{r._cloneMarkers(i,e,n)}),Da(t)&&Pa.forEach(function(i){if(T(t,i)){var o=La(t,i,r._canvas.getContainer());o&&r._cloneMarker(n,t,o,i,e)}})},_t.prototype._cloneMarker=function(t,e,n,r,i="djs-dragger"){var o=[n.id,i,Aa.next()].join("-"),a=rt("marker#"+n.id,t);t=t||this._canvas._svg;var s=a||Xn(n);s.id=o,B(s).add(i);var c=rt(":scope > defs",t);c||(c=G("defs"),z(t,c)),z(c,s);var u=Ia(s.id);T(e,r,u)};function La(t,e,n){var r=$a(T(t,e));return rt("marker#"+r,n||document)}function $a(t){return t.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]}function Ia(t){return"url(#"+t+")"}function Da(t){return ja.indexOf(t.nodeName)!==-1}const Wr={__init__:["previewSupport"],previewSupport:["type",_t]};function Sn(t){this._commandStack=t.get("commandStack",!1)}Sn.$inject=["injector"],Sn.prototype.allowed=function(t,e){var n=!0,r=this._commandStack;return r&&(n=r.canExecute(t,e)),n===void 0?!0:n};const re={__init__:["rules"],rules:["type",Sn]};var Ha="drop-ok",Yr="drop-not-ok",Ur="attach-ok",Kr="new-parent",qr="create",Na=2e3;function Zr(t,e,n,r,i){function o(c,u,l,f,h){if(!u)return!1;c=nt(c,function(R){var d=R.labelTarget;return!R.parent&&!(Dt(R)&&c.indexOf(d)!==-1)});var p=et(c,function(R){return!K(R)}),v=!1,b=!1,_=!1;Qr(c)&&(v=i.allowed("shape.attach",{position:l,shape:p,target:u})),v||(Qr(c)?_=i.allowed("shape.create",{position:l,shape:p,source:f,target:u}):_=i.allowed("elements.create",{elements:c,position:l,target:u}));var A=h.connectionTarget;return _||v?(p&&f&&(b=i.allowed("connection.create",{source:A===f?p:f,target:A===f?f:p,hints:{targetParent:u,targetAttach:v}})),{attach:v,connect:b}):_===null||v===null?null:!1}function a(c,u){[Ur,Ha,Yr,Kr].forEach(function(l){l===u?t.addMarker(c,l):t.removeMarker(c,l)})}n.on(["create.move","create.hover"],function(c){var u=c.context,l=u.elements,f=c.hover,h=u.source,p=u.hints||{};if(!f){u.canExecute=!1,u.target=null;return}Xr(c);var v={x:c.x,y:c.y},b=u.canExecute=f&&o(l,f,v,h,p);f&&b!==null&&(u.target=f,b&&b.attach?a(f,Ur):a(f,b?Kr:Yr))}),n.on(["create.end","create.out","create.cleanup"],function(c){var u=c.hover;u&&a(u,null)}),n.on("create.end",function(c){var u=c.context,l=u.source,f=u.shape,h=u.elements,p=u.target,v=u.canExecute,b=v&&v.attach,_=v&&v.connect,A=u.hints||{};if(v===!1||!p)return!1;Xr(c);var R={x:c.x,y:c.y};_?f=r.appendShape(l,f,R,p,{attach:b,connection:_===!0?{}:_,connectionTarget:A.connectionTarget}):(h=r.createElements(h,R,p,k({},A,{attach:b})),f=et(h,function(d){return!K(d)})),k(u,{elements:h,shape:f}),k(c,{elements:h,shape:f})});function s(){var c=e.context();c&&c.prefix===qr&&e.cancel()}n.on("create.init",function(){n.on("elements.changed",s),n.once(["create.cancel","create.end"],Na,function(){n.off("elements.changed",s)})}),this.start=function(c,u,l){D(u)||(u=[u]);var f=et(u,function(v){return!K(v)});if(f){l=k({elements:u,hints:{},shape:f},l||{}),w(u,function(v){N(v.x)||(v.x=0),N(v.y)||(v.y=0)});var h=nt(u,function(v){return!v.hidden}),p=st(h);w(u,function(v){K(v)&&(v.waypoints=dt(v.waypoints,function(b){return{x:b.x-p.x-p.width/2,y:b.y-p.y-p.height/2}})),k(v,{x:v.x-p.x-p.width/2,y:v.y-p.y-p.height/2})}),e.init(c,qr,{cursor:"grabbing",autoActivate:!0,data:{shape:f,elements:u,context:l}})}}}Zr.$inject=["canvas","dragging","eventBus","modeling","rules"];function Xr(t){var e=t.context,n=e.createConstraints;n&&(n.left&&(t.x=Math.max(t.x,n.left)),n.right&&(t.x=Math.min(t.x,n.right)),n.top&&(t.y=Math.max(t.y,n.top)),n.bottom&&(t.y=Math.min(t.y,n.bottom)))}function Qr(t){return t&&t.length===1&&!K(t[0])}var Fa=750;function Jr(t,e,n,r,i){function o(a){var s=G("g");T(s,i.cls("djs-drag-group",["no-events"]));var c=G("g");return a.forEach(function(u){var l;u.hidden||(u.waypoints?(l=n._createContainer("connection",c),n.drawConnection(Ae(l),u)):(l=n._createContainer("shape",c),n.drawShape(Ae(l),u),Pe(l,u.x,u.y)),r.addDragger(u,s,l))}),s}e.on("create.move",Fa,function(a){var s=a.hover,c=a.context,u=c.elements,l=c.dragGroup;l||(l=c.dragGroup=o(u));var f;s?(l.parentNode||(f=t.getActiveLayer(),z(f,l)),Pe(l,a.x,a.y)):Ot(l)}),e.on("create.cleanup",function(a){var s=a.context,c=s.dragGroup;c&&Ot(c)})}Jr.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];const za={__depends__:[bn,Wr,re,Gt],__init__:["create","createPreview"],create:["type",Zr],createPreview:["type",Jr]};var Ga=Math.abs,ti=Math.round;function Va(t,e,n){n=n===void 0?10:n;var r,i;for(r=0;r<e.length;r++)if(i=e[r],Ga(i-t)<=n)return i}function Ba(t){return{x:t.x,y:t.y}}function Wa(t){return{x:t.x+t.width,y:t.y+t.height}}function Wt(t,e){return!t||isNaN(t.x)||isNaN(t.y)?e:{x:ti(t.x+t.width/2),y:ti(t.y+t.height/2)}}function ie(t,e){var n=t.snapped;return n?typeof e=="string"?n[e]:n.x&&n.y:!1}function Le(t,e,n){if(typeof e!="string")throw new Error("axis must be in [x, y]");if(typeof n!="number"&&n!==!1)throw new Error("value must be Number or false");var r,i=t[e],o=t.snapped=t.snapped||{};return n===!1?o[e]=!1:(o[e]=!0,r=n-i,t[e]+=r,t["d"+e]+=r),i}function ei(t){return t.children||[]}var $e=10;function Cn(t,e,n){return n||(n="round"),Math[n](t/e)*e}var Ya=1200,Ua=800;function xt(t,e,n){var r=!n||n.active!==!1;this._eventBus=e;var i=this;e.on("diagram.init",Ua,function(){i.setActive(r)}),e.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"],Ya,function(o){var a=o.originalEvent;if(!(!i.active||a&&wn(a))){var s=o.context,c=s.gridSnappingContext;c||(c=s.gridSnappingContext={}),["x","y"].forEach(function(u){var l={},f=qa(o,u,t);f&&(l.offset=f);var h=Ka(o,u);h&&k(l,h),ie(o,u)||i.snapEvent(o,u,l)})}})}xt.prototype.snapEvent=function(t,e,n){var r=this.snapValue(t[e],n);Le(t,e,r)},xt.prototype.getGridSpacing=function(){return $e},xt.prototype.snapValue=function(t,e){var n=0;e&&e.offset&&(n=e.offset),t+=n,t=Cn(t,$e);var r,i;return e&&e.min&&(r=e.min,N(r)&&(r=Cn(r+n,$e,"ceil"),t=Math.max(t,r))),e&&e.max&&(i=e.max,N(i)&&(i=Cn(i+n,$e,"floor"),t=Math.min(t,i))),t-=n,t},xt.prototype.isActive=function(){return this.active},xt.prototype.setActive=function(t){this.active=t,this._eventBus.fire("gridSnapping.toggle",{active:t})},xt.prototype.toggleActive=function(){this.setActive(!this.active)},xt.$inject=["elementRegistry","eventBus","config.gridSnapping"];function Ka(t,e){var n=t.context,r=n.createConstraints,i=n.resizeConstraints||{},o=n.gridSnappingContext,a=o.snapConstraints;if(a&&a[e])return a[e];a||(a=o.snapConstraints={}),a[e]||(a[e]={});var s=n.direction;r&&(Ie(e)?(a.x.min=r.left,a.x.max=r.right):(a.y.min=r.top,a.y.max=r.bottom));var c=i.min,u=i.max;return c&&(Ie(e)?ri(s)?a.x.max=c.left:a.x.min=c.right:ni(s)?a.y.max=c.top:a.y.min=c.bottom),u&&(Ie(e)?ri(s)?a.x.min=u.left:a.x.max=u.right:ni(s)?a.y.min=u.top:a.y.max=u.bottom),a[e]}function qa(t,e,n){var r=t.context,i=t.shape,o=r.gridSnappingContext,a=o.snapLocation,s=o.snapOffset;return s&&N(s[e])||(s||(s=o.snapOffset={}),N(s[e])||(s[e]=0),!i)||(n.get(i.id)||(Ie(e)?s[e]+=i[e]+i.width/2:s[e]+=i[e]+i.height/2),!a)||(e==="x"?/left/.test(a)?s[e]-=i.width/2:/right/.test(a)&&(s[e]+=i.width/2):/top/.test(a)?s[e]-=i.height/2:/bottom/.test(a)&&(s[e]+=i.height/2)),s[e]}function Ie(t){return t==="x"}function ni(t){return t.indexOf("n")!==-1}function ri(t){return t.indexOf("w")!==-1}var Za=1e3;function U(t){this._eventBus=t}U.$inject=["eventBus"];function Xa(t,e){return function(n){return t.call(e||null,n.context,n.command,n)}}U.prototype.on=function(t,e,n,r,i,o){if((Q(e)||N(e))&&(o=i,i=r,r=n,n=e,e=null),Q(n)&&(o=i,i=r,r=n,n=Za),tt(i)&&(o=i,i=!1),!Q(r))throw new Error("handlerFn must be a function");D(t)||(t=[t]);var a=this._eventBus;w(t,function(s){var c=["commandStack",s,e].filter(function(u){return u}).join(".");a.on(c,n,i?Xa(r,o):r,o)})},U.prototype.canExecute=ut("canExecute"),U.prototype.preExecute=ut("preExecute"),U.prototype.preExecuted=ut("preExecuted"),U.prototype.execute=ut("execute"),U.prototype.executed=ut("executed"),U.prototype.postExecute=ut("postExecute"),U.prototype.postExecuted=ut("postExecuted"),U.prototype.revert=ut("revert"),U.prototype.reverted=ut("reverted");function ut(t){return function(n,r,i,o,a){(Q(n)||N(n))&&(a=o,o=i,i=r,r=n,n=null),this.on(n,t,r,i,o,a)}}function Lt(t,e){U.call(this,t),this._gridSnapping=e;var n=this;this.preExecute("shape.resize",function(r){var i=r.context,o=i.hints||{},a=o.autoResize;if(a){var s=i.shape,c=i.newBounds;ye(a)?i.newBounds=n.snapComplex(c,a):i.newBounds=n.snapSimple(s,c)}})}Lt.$inject=["eventBus","gridSnapping","modeling"],Tt(Lt,U),Lt.prototype.snapSimple=function(t,e){var n=this._gridSnapping;return e.width=n.snapValue(e.width,{min:e.width}),e.height=n.snapValue(e.height,{min:e.height}),e.x=t.x+t.width/2-e.width/2,e.y=t.y+t.height/2-e.height/2,e},Lt.prototype.snapComplex=function(t,e){return/w|e/.test(e)&&(t=this.snapHorizontally(t,e)),/n|s/.test(e)&&(t=this.snapVertically(t,e)),t},Lt.prototype.snapHorizontally=function(t,e){var n=this._gridSnapping,r=/w/.test(e),i=/e/.test(e),o={};return o.width=n.snapValue(t.width,{min:t.width}),i&&(r?(o.x=n.snapValue(t.x,{max:t.x}),o.width+=n.snapValue(t.x-o.x,{min:t.x-o.x})):t.x=t.x+t.width-o.width),k(t,o),t},Lt.prototype.snapVertically=function(t,e){var n=this._gridSnapping,r=/n/.test(e),i=/s/.test(e),o={};return o.height=n.snapValue(t.height,{min:t.height}),r&&(i?(o.y=n.snapValue(t.y,{max:t.y}),o.height+=n.snapValue(t.y-o.y,{min:t.y-o.y})):t.y=t.y+t.height-o.height),k(t,o),t};var Qa=2e3;function ii(t,e){t.on(["spaceTool.move","spaceTool.end"],Qa,function(n){var r=n.context;if(r.initialized){var i=r.axis,o;i==="x"?(o=e.snapValue(n.dx),n.x=n.x+o-n.dx,n.dx=o):(o=e.snapValue(n.dy),n.y=n.y+o-n.dy,n.dy=o)}})}ii.$inject=["eventBus","gridSnapping"];const Ja={__depends__:[{__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",Lt],gridSnappingSpaceToolBehavior:["type",ii]}],__init__:["gridSnapping"],gridSnapping:["type",xt]};var ts=new En("ov"),es=500;function F(t,e,n,r){this._eventBus=e,this._canvas=n,this._elementRegistry=r,this._ids=ts,this._overlayDefaults=k({show:null,scale:!0},t&&t.defaults),this._overlays={},this._overlayContainers=[],this._overlayRoot=ns(n.getContainer()),this._init()}F.$inject=["config.overlays","eventBus","canvas","elementRegistry"],F.prototype.get=function(t){if(ye(t)&&(t={id:t}),ye(t.element)&&(t.element=this._elementRegistry.get(t.element)),t.element){var e=this._getOverlayContainer(t.element,!0);return e?t.type?nt(e.overlays,we({type:t.type})):e.overlays.slice():[]}else return t.type?nt(this._overlays,we({type:t.type})):t.id?this._overlays[t.id]:null},F.prototype.add=function(t,e,n){if(tt(e)&&(n=e,e=null),t.id||(t=this._elementRegistry.get(t)),!n.position)throw new Error("must specifiy overlay position");if(!n.html)throw new Error("must specifiy overlay html");if(!t)throw new Error("invalid element specified");var r=this._ids.next();return n=k({},this._overlayDefaults,n,{id:r,type:e,element:t,html:n.html}),this._addOverlay(n),r},F.prototype.remove=function(t){var e=this.get(t)||[];D(e)||(e=[e]);var n=this;w(e,function(r){var i=n._getOverlayContainer(r.element,!0);if(r&&(vn(r.html),vn(r.htmlContainer),delete r.htmlContainer,delete r.element,delete n._overlays[r.id]),i){var o=i.overlays.indexOf(r);o!==-1&&i.overlays.splice(o,1)}})},F.prototype.isShown=function(){return this._overlayRoot.style.display!=="none"},F.prototype.show=function(){De(this._overlayRoot)},F.prototype.hide=function(){De(this._overlayRoot,!1)},F.prototype.clear=function(){this._overlays={},this._overlayContainers=[],hn(this._overlayRoot)},F.prototype._updateOverlayContainer=function(t){var e=t.element,n=t.html,r=e.x,i=e.y;if(e.waypoints){var o=st(e);r=o.x,i=o.y}oi(n,r,i),At(t.html,"data-container-id",e.id)},F.prototype._updateOverlay=function(t){var e=t.position,n=t.htmlContainer,r=t.element,i=e.left,o=e.top;if(e.right!==void 0){var a;r.waypoints?a=st(r).width:a=r.width,i=e.right*-1+a}if(e.bottom!==void 0){var s;r.waypoints?s=st(r).height:s=r.height,o=e.bottom*-1+s}oi(n,i||0,o||0),this._updateOverlayVisibilty(t,this._canvas.viewbox())},F.prototype._createOverlayContainer=function(t){var e=yt('<div class="djs-overlays" />');Kt(e,{position:"absolute"}),this._overlayRoot.appendChild(e);var n={html:e,element:t,overlays:[]};return this._updateOverlayContainer(n),this._overlayContainers.push(n),n},F.prototype._updateRoot=function(t){var e=t.scale||1,n="matrix("+[e,0,0,e,-1*t.x*e,-1*t.y*e].join(",")+")";ai(this._overlayRoot,n)},F.prototype._getOverlayContainer=function(t,e){var n=et(this._overlayContainers,function(r){return r.element===t});return!n&&!e?this._createOverlayContainer(t):n},F.prototype._addOverlay=function(t){var e=t.id,n=t.element,r=t.html,i,o;r.get&&r.constructor.prototype.jquery&&(r=r.get(0)),ye(r)&&(r=yt(r)),o=this._getOverlayContainer(n),i=yt('<div class="djs-overlay" data-overlay-id="'+e+'">'),Kt(i,{position:"absolute"}),i.appendChild(r),t.type&&ct(i).add("djs-overlay-"+t.type);var a=this._canvas.findRoot(n),s=this._canvas.getRootElement();De(i,a===s),t.htmlContainer=i,o.overlays.push(t),o.html.appendChild(i),this._overlays[e]=t,this._updateOverlay(t),this._updateOverlayVisibilty(t,this._canvas.viewbox())},F.prototype._updateOverlayVisibilty=function(t,e){var n=t.show,r=this._canvas.findRoot(t.element),i=n&&n.minZoom,o=n&&n.maxZoom,a=t.htmlContainer,s=this._canvas.getRootElement(),c=!0;(r!==s||n&&(X(i)&&i>e.scale||X(o)&&o<e.scale))&&(c=!1),De(a,c),this._updateOverlayScale(t,e)},F.prototype._updateOverlayScale=function(t,e){var n=t.scale,r,i,o=t.htmlContainer,a,s="";n!==!0&&(n===!1?(r=1,i=1):(r=n.min,i=n.max),X(r)&&e.scale<r&&(a=(1/e.scale||1)*r),X(i)&&e.scale>i&&(a=(1/e.scale||1)*i)),X(a)&&(s="scale("+a+","+a+")"),ai(o,s)},F.prototype._updateOverlaysVisibilty=function(t){var e=this;w(this._overlays,function(n){e._updateOverlayVisibilty(n,t)})},F.prototype._init=function(){var t=this._eventBus,e=this;function n(r){e._updateRoot(r),e._updateOverlaysVisibilty(r),e.show()}t.on("canvas.viewbox.changing",function(r){e.hide()}),t.on("canvas.viewbox.changed",function(r){n(r.viewbox)}),t.on(["shape.remove","connection.remove"],function(r){var i=r.element,o=e.get({element:i});w(o,function(c){e.remove(c.id)});var a=e._getOverlayContainer(i);if(a){vn(a.html);var s=e._overlayContainers.indexOf(a);s!==-1&&e._overlayContainers.splice(s,1)}}),t.on("element.changed",es,function(r){var i=r.element,o=e._getOverlayContainer(i,!0);o&&(w(o.overlays,function(a){e._updateOverlay(a)}),e._updateOverlayContainer(o))}),t.on("element.marker.update",function(r){var i=e._getOverlayContainer(r.element,!0);i&&ct(i.html)[r.add?"add":"remove"](r.marker)}),t.on("root.set",function(){e._updateOverlaysVisibilty(e._canvas.viewbox())}),t.on("diagram.clear",this.clear,this)};function ns(t){var e=yt('<div class="djs-overlay-container" />');return Kt(e,{position:"absolute",width:0,height:0}),t.insertBefore(e,t.firstChild),e}function oi(t,e,n){Kt(t,{left:e+"px",top:n+"px"})}function De(t,e){t.style.display=e===!1?"none":""}function ai(t,e){t.style["transform-origin"]="top left",["","-ms-","-webkit-"].forEach(function(n){t.style[n+"transform"]=e})}const rs={__init__:["overlays"],overlays:["type",F]};function si(t,e,n,r){function i(a,s){return r.allowed("connection.create",{source:a,target:s})}function o(a,s){return i(s,a)}t.on("connect.hover",function(a){var s=a.context,c=s.start,u=a.hover,l;if(s.hover=u,l=s.canExecute=i(c,u),!Je(l)){if(l!==!1){s.source=c,s.target=u;return}l=s.canExecute=o(c,u),!Je(l)&&l!==!1&&(s.source=u,s.target=c)}}),t.on(["connect.out","connect.cleanup"],function(a){var s=a.context;s.hover=null,s.source=null,s.target=null,s.canExecute=!1}),t.on("connect.end",function(a){var s=a.context,c=s.canExecute,u=s.connectionStart,l={x:a.x,y:a.y},f=s.source,h=s.target;if(!c)return!1;var p=null,v={connectionStart:kn(s)?l:u,connectionEnd:kn(s)?u:l};tt(c)&&(p=c),s.connection=n.connect(f,h,p,v)}),this.start=function(a,s,c,u){tt(c)||(u=c,c=Re(s)),e.init(a,"connect",{autoActivate:u,data:{shape:s,context:{start:s,connectionStart:c}}})}}si.$inject=["eventBus","dragging","modeling","rules"];function kn(t){var e=t.hover,n=t.source,r=t.target;return e&&n&&e===n&&n!==r}var is=1100,os=900,ci="connect-ok",ui="connect-not-ok";function li(t,e,n){var r=t.get("connectionPreview",!1);r&&e.on("connect.move",function(i){var o=i.context,a=o.canExecute,s=o.hover,c=o.source,u=o.start,l=o.startPosition,f=o.target,h=o.connectionStart||l,p=o.connectionEnd||{x:i.x,y:i.y},v=h,b=p;kn(o)&&(v=p,b=h),r.drawPreview(o,a,{source:c||u,target:f||s,connectionStart:v,connectionEnd:b})}),e.on("connect.hover",os,function(i){var o=i.context,a=i.hover,s=o.canExecute;s!==null&&n.addMarker(a,s?ci:ui)}),e.on(["connect.out","connect.cleanup"],is,function(i){var o=i.hover;o&&(n.removeMarker(o,ci),n.removeMarker(o,ui))}),r&&e.on("connect.cleanup",function(i){r.cleanUp(i.context)})}li.$inject=["injector","eventBus","canvas"];const as={__depends__:[Gt,re,bn],__init__:["connectPreview"],connect:["type",si],connectPreview:["type",li]};function $(t,e){this._handlerMap={},this._stack=[],this._stackIdx=-1,this._currentExecution={actions:[],dirty:[],trigger:null},this._injector=e,this._eventBus=t,this._uid=1,t.on(["diagram.destroy","diagram.clear"],function(){this.clear(!1)},this)}$.$inject=["eventBus","injector"],$.prototype.execute=function(t,e){if(!t)throw new Error("command required");this._currentExecution.trigger="execute";const n={command:t,context:e};this._pushAction(n),this._internalExecute(n),this._popAction()},$.prototype.canExecute=function(t,e){const n={command:t,context:e},r=this._getHandler(t);let i=this._fire(t,"canExecute",n);if(i===void 0){if(!r)return!1;r.canExecute&&(i=r.canExecute(e))}return i},$.prototype.clear=function(t){this._stack.length=0,this._stackIdx=-1,t!==!1&&this._fire("changed",{trigger:"clear"})},$.prototype.undo=function(){let t=this._getUndoAction(),e;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()}},$.prototype.redo=function(){let t=this._getRedoAction(),e;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()}},$.prototype.register=function(t,e){this._setHandler(t,e)},$.prototype.registerHandler=function(t,e){if(!t||!e)throw new Error("command and handlerCls must be defined");const n=this._injector.instantiate(e);this.register(t,n)},$.prototype.canUndo=function(){return!!this._getUndoAction()},$.prototype.canRedo=function(){return!!this._getRedoAction()},$.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]},$.prototype._getUndoAction=function(){return this._stack[this._stackIdx]},$.prototype._internalUndo=function(t){const e=t.command,n=t.context,r=this._getHandler(e);this._atomicDo(()=>{this._fire(e,"revert",t),r.revert&&this._markDirty(r.revert(n)),this._revertedAction(t),this._fire(e,"reverted",t)})},$.prototype._fire=function(t,e,n){arguments.length<3&&(n=e,e=null);const r=e?[t+"."+e,e]:[t];let i;n=this._eventBus.createEvent(n);for(const o of r)if(i=this._eventBus.fire("commandStack."+o,n),n.cancelBubble)break;return i},$.prototype._createId=function(){return this._uid++},$.prototype._atomicDo=function(t){const e=this._currentExecution;e.atomic=!0;try{t()}finally{e.atomic=!1}},$.prototype._internalExecute=function(t,e){const n=t.command,r=t.context,i=this._getHandler(n);if(!i)throw new Error("no command handler registered for <"+n+">");this._pushAction(t),e||(this._fire(n,"preExecute",t),i.preExecute&&i.preExecute(r),this._fire(n,"preExecuted",t)),this._atomicDo(()=>{this._fire(n,"execute",t),i.execute&&this._markDirty(i.execute(r)),this._executedAction(t,e),this._fire(n,"executed",t)}),e||(this._fire(n,"postExecute",t),i.postExecute&&i.postExecute(r),this._fire(n,"postExecuted",t)),this._popAction()},$.prototype._pushAction=function(t){const e=this._currentExecution,n=e.actions,r=n[0];if(e.atomic)throw new Error("illegal invocation in <execute> or <revert> phase (action: "+t.command+")");t.id||(t.id=r&&r.id||this._createId()),n.push(t)},$.prototype._popAction=function(){const t=this._currentExecution,e=t.trigger,n=t.actions,r=t.dirty;n.pop(),n.length||(this._eventBus.fire("elements.changed",{elements:oo("id",r.reverse())}),r.length=0,this._fire("changed",{trigger:e}),t.trigger=null)},$.prototype._markDirty=function(t){const e=this._currentExecution;t&&(t=D(t)?t:[t],e.dirty=e.dirty.concat(t))},$.prototype._executedAction=function(t,e){const n=++this._stackIdx;e||this._stack.splice(n,this._stack.length,t)},$.prototype._revertedAction=function(t){this._stackIdx--},$.prototype._getHandler=function(t){return this._handlerMap[t]},$.prototype._setHandler=function(t,e){if(!t||!e)throw new Error("command and handler required");if(this._handlerMap[t])throw new Error("overriding handler for command <"+t+">");this._handlerMap[t]=e};const ss={commandStack:["type",$]};function fi(t,e,n,r){t.on("element.changed",function(i){var o=i.element;(o.parent||o===e.getRootElement())&&(i.gfx=n.getGraphics(o)),i.gfx&&t.fire(or(o)+".changed",i)}),t.on("elements.changed",function(i){var o=i.elements;o.forEach(function(a){t.fire("element.changed",{element:a})}),r.updateContainments(o)}),t.on("shape.changed",function(i){r.update("shape",i.element,i.gfx)}),t.on("connection.changed",function(i){r.update("connection",i.element,i.gfx)})}fi.$inject=["eventBus","canvas","elementRegistry","graphicsFactory"];const cs={__init__:["changeSupport"],changeSupport:["type",fi]};function He(t,e){this._modeling=t,this._canvas=e}He.$inject=["modeling","canvas"],He.prototype.preExecute=function(t){var e=this._modeling,n=t.elements,r=t.alignment;w(n,function(i){var o={x:0,y:0};X(r.left)?o.x=r.left-i.x:X(r.right)?o.x=r.right-i.width-i.x:X(r.center)?o.x=r.center-Math.round(i.width/2)-i.x:X(r.top)?o.y=r.top-i.y:X(r.bottom)?o.y=r.bottom-i.height-i.y:X(r.middle)&&(o.y=r.middle-Math.round(i.height/2)-i.y),e.moveElements([i],o,i.parent)})},He.prototype.postExecute=function(t){};function Ne(t){this._modeling=t}Ne.$inject=["modeling"],Ne.prototype.preExecute=function(t){var e=t.source;if(!e)throw new Error("source required");var n=t.target||e.parent,r=t.shape,i=t.hints||{};r=t.shape=this._modeling.createShape(r,t.position,n,{attach:i.attach}),t.shape=r},Ne.prototype.postExecute=function(t){var e=t.hints||{};us(t.source,t.shape)||(e.connectionTarget===t.source?this._modeling.connect(t.shape,t.source,t.connection):this._modeling.connect(t.source,t.shape,t.connection))};function us(t,e){return eo(t.outgoing,function(n){return n.target===e})}function Fe(t,e){this._canvas=t,this._layouter=e}Fe.$inject=["canvas","layouter"],Fe.prototype.execute=function(t){var e=t.connection,n=t.source,r=t.target,i=t.parent,o=t.parentIndex,a=t.hints;if(!n||!r)throw new Error("source and target required");if(!i)throw new Error("parent required");return e.source=n,e.target=r,e.waypoints||(e.waypoints=this._layouter.layoutConnection(e,a)),this._canvas.addConnection(e,i,o),e},Fe.prototype.revert=function(t){var e=t.connection;return this._canvas.removeConnection(e),e.source=null,e.target=null,e};var ze=Math.round;function Mn(t){this._modeling=t}Mn.$inject=["modeling"],Mn.prototype.preExecute=function(t){var e=t.elements,n=t.parent,r=t.parentIndex,i=t.position,o=t.hints,a=this._modeling;w(e,function(f){N(f.x)||(f.x=0),N(f.y)||(f.y=0)});var s=nt(e,function(f){return!f.hidden}),c=st(s);w(e,function(f){K(f)&&(f.waypoints=dt(f.waypoints,function(h){return{x:ze(h.x-c.x-c.width/2+i.x),y:ze(h.y-c.y-c.height/2+i.y)}})),k(f,{x:ze(f.x-c.x-c.width/2+i.x),y:ze(f.y-c.y-c.height/2+i.y)})});var u=Co(e),l={};w(e,function(f){if(K(f)){l[f.id]=N(r)?a.createConnection(l[f.source.id],l[f.target.id],r,f,f.parent||n,o):a.createConnection(l[f.source.id],l[f.target.id],f,f.parent||n,o);return}var h=k({},o);u.indexOf(f)===-1&&(h.autoResize=!1),Dt(f)&&(h=co(h,["attach"])),l[f.id]=N(r)?a.createShape(f,nn(f,["x","y","width","height"]),f.parent||n,r,h):a.createShape(f,nn(f,["x","y","width","height"]),f.parent||n,h)}),t.elements=io(l)};var hi=Math.round;function wt(t){this._canvas=t}wt.$inject=["canvas"],wt.prototype.execute=function(t){var e=t.shape,n=t.position,r=t.parent,i=t.parentIndex;if(!r)throw new Error("parent required");if(!n)throw new Error("position required");return n.width!==void 0?k(e,n):k(e,{x:n.x-hi(e.width/2),y:n.y-hi(e.height/2)}),this._canvas.addShape(e,r,i),e},wt.prototype.revert=function(t){var e=t.shape;return this._canvas.removeShape(e),e};function oe(t){wt.call(this,t)}Tt(oe,wt),oe.$inject=["canvas"];var ls=wt.prototype.execute;oe.prototype.execute=function(t){var e=t.shape;return hs(e),e.labelTarget=t.labelTarget,ls.call(this,t)};var fs=wt.prototype.revert;oe.prototype.revert=function(t){return t.shape.labelTarget=null,fs.call(this,t)};function hs(t){["width","height"].forEach(function(e){typeof t[e]>"u"&&(t[e]=0)})}function ae(t,e){if(typeof e!="function")throw new Error("removeFn iterator must be a function");if(t){for(var n;n=t[0];)e(n);return t}}function se(t,e){this._canvas=t,this._modeling=e}se.$inject=["canvas","modeling"],se.prototype.preExecute=function(t){var e=this._modeling,n=t.connection;ae(n.incoming,function(r){e.removeConnection(r,{nested:!0})}),ae(n.outgoing,function(r){e.removeConnection(r,{nested:!0})})},se.prototype.execute=function(t){var e=t.connection,n=e.parent;return t.parent=n,t.parentIndex=fr(n.children,e),t.source=e.source,t.target=e.target,this._canvas.removeConnection(e),e.source=null,e.target=null,e},se.prototype.revert=function(t){var e=t.connection,n=t.parent,r=t.parentIndex;return e.source=t.source,e.target=t.target,mt(n.children,e,r),this._canvas.addConnection(e,n),e};function Rn(t,e){this._modeling=t,this._elementRegistry=e}Rn.$inject=["modeling","elementRegistry"],Rn.prototype.postExecute=function(t){var e=this._modeling,n=this._elementRegistry,r=t.elements;w(r,function(i){n.get(i.id)&&(i.waypoints?e.removeConnection(i):e.removeShape(i))})};function ce(t,e){this._canvas=t,this._modeling=e}ce.$inject=["canvas","modeling"],ce.prototype.preExecute=function(t){var e=this._modeling,n=t.shape;ae(n.incoming,function(r){e.removeConnection(r,{nested:!0})}),ae(n.outgoing,function(r){e.removeConnection(r,{nested:!0})}),ae(n.children,function(r){K(r)?e.removeConnection(r,{nested:!0}):e.removeShape(r,{nested:!0})})},ce.prototype.execute=function(t){var e=this._canvas,n=t.shape,r=n.parent;return t.oldParent=r,t.oldParentIndex=fr(r.children,n),e.removeShape(n),n},ce.prototype.revert=function(t){var e=this._canvas,n=t.shape,r=t.oldParent,i=t.oldParentIndex;return mt(r.children,n,i),e.addShape(n,r),n};function Ge(t){this._modeling=t}Ge.$inject=["modeling"];var di={x:"y",y:"x"};Ge.prototype.preExecute=function(t){var e=this._modeling,n=t.groups,r=t.axis,i=t.dimension;function o(_,A){_.range.min=Math.min(A[r],_.range.min),_.range.max=Math.max(A[r]+A[i],_.range.max)}function a(_){return _[r]+_[i]/2}function s(_){return _.length-1}function c(_){return _.max-_.min}function u(_,A){var R={y:0};R[r]=_-a(A),R[r]&&(R[di[r]]=0,e.moveElements([A],R,A.parent))}var l=n[0],f=s(n),h=n[f],p,v,b=0;w(n,function(_,A){var R,d,g;if(_.elements.length<2){A&&A!==n.length-1&&(o(_,_.elements[0]),b+=c(_.range));return}R=xe(_.elements,r),d=R[0],A===f&&(d=R[s(R)]),g=a(d),_.range=null,w(R,function(y){if(u(g,y),_.range===null){_.range={min:y[r],max:y[r]+y[i]};return}o(_,y)}),A&&A!==n.length-1&&(b+=c(_.range))}),v=Math.abs(h.range.min-l.range.max),p=Math.round((v-b)/(n.length-1)),!(p<n.length-1)&&w(n,function(_,A){var R={},d;_===l||_===h||(d=n[A-1],_.range.max=0,w(_.elements,function(g,y){R[di[r]]=0,R[r]=d.range.max-g[r]+p,_.range.min!==g[r]&&(R[r]+=g[r]-_.range.min),R[r]&&e.moveElements([g],R,g.parent),_.range.max=Math.max(g[r]+g[i],y?_.range.max:0)}))})},Ge.prototype.postExecute=function(t){};function Ve(t,e){this._layouter=t,this._canvas=e}Ve.$inject=["layouter","canvas"],Ve.prototype.execute=function(t){var e=t.connection,n=e.waypoints;return k(t,{oldWaypoints:n}),e.waypoints=this._layouter.layoutConnection(e,t.hints),e},Ve.prototype.revert=function(t){var e=t.connection;return e.waypoints=t.oldWaypoints,e};function Tn(){}Tn.prototype.execute=function(t){var e=t.connection,n=t.delta,r=t.newParent||e.parent,i=t.newParentIndex,o=e.parent;return t.oldParent=o,t.oldParentIndex=qt(o.children,e),mt(r.children,e,i),e.parent=r,w(e.waypoints,function(a){a.x+=n.x,a.y+=n.y,a.original&&(a.original.x+=n.x,a.original.y+=n.y)}),e},Tn.prototype.revert=function(t){var e=t.connection,n=e.parent,r=t.oldParent,i=t.oldParentIndex,o=t.delta;return qt(n.children,e),mt(r.children,e,i),e.parent=r,w(e.waypoints,function(a){a.x-=o.x,a.y-=o.y,a.original&&(a.original.x-=o.x,a.original.y-=o.y)}),e};function Be(t,e,n){var r=Gr(e),i=Gr(n),o=Vt(t,r),a={x:o.x*(n.width/e.width),y:o.y*(n.height/e.height)};return hr({x:i.x+a.x,y:i.y+a.y})}function On(t,e,n){var r=We(t),i=gi(r,e),o=r[0];return i.length?i[i.length-1]:Be(o.original||o,n,e)}function An(t,e,n){var r=We(t),i=gi(r,e),o=r[r.length-1];return i.length?i[0]:Be(o.original||o,n,e)}function Pn(t,e,n){var r=We(t),i=pi(e,n),o=r[0];return Be(o.original||o,i,e)}function jn(t,e,n){var r=We(t),i=pi(e,n),o=r[r.length-1];return Be(o.original||o,i,e)}function pi(t,e){return{x:t.x-e.x,y:t.y-e.y,width:t.width,height:t.height}}function We(t){var e=t.waypoints;if(!e.length)throw new Error("connection#"+t.id+": no waypoints");return e}function gi(t,e){var n=dt(t,ps);return nt(n,function(r){return ds(r,e)})}function ds(t,e){return Xo(e,t,1)==="intersect"}function ps(t){return t.original||t}function Ln(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}Ln.prototype.add=function(t,e){return this.addAll([t],e)},Ln.prototype.addAll=function(t,e){var n=Ro(t,!!e,this);return k(this,n),this};function ue(t){this._modeling=t}ue.prototype.moveRecursive=function(t,e,n){return t?this.moveClosure(this.getClosure(t),e,n):[]},ue.prototype.moveClosure=function(t,e,n,r,i){var o=this._modeling,a=t.allShapes,s=t.allConnections,c=t.enclosedConnections,u=t.topLevel,l=!1;i&&i.parent===n&&(l=!0),w(a,function(f){o.moveShape(f,e,u[f.id]&&!l&&n,{recurse:!1,layout:!1})}),w(s,function(f){var h=!!a[f.source.id],p=!!a[f.target.id];c[f.id]&&h&&p?o.moveConnection(f,e,u[f.id]&&!l&&n):o.layoutConnection(f,{connectionStart:h&&Pn(f,f.source,e),connectionEnd:p&&jn(f,f.target,e)})})},ue.prototype.getClosure=function(t){return new Ln().addAll(t,!0)};function Ye(t){this._helper=new ue(t)}Ye.$inject=["modeling"],Ye.prototype.preExecute=function(t){t.closure=this._helper.getClosure(t.shapes)},Ye.prototype.postExecute=function(t){var e=t.hints,n;e&&e.primaryShape&&(n=e.primaryShape,e.oldParent=n.parent),this._helper.moveClosure(t.closure,t.delta,t.newParent,t.newHost,n)};function $t(t){this._modeling=t,this._helper=new ue(t)}$t.$inject=["modeling"],$t.prototype.execute=function(t){var e=t.shape,n=t.delta,r=t.newParent||e.parent,i=t.newParentIndex,o=e.parent;return t.oldBounds=nn(e,["x","y","width","height"]),t.oldParent=o,t.oldParentIndex=qt(o.children,e),mt(r.children,e,i),k(e,{parent:r,x:e.x+n.x,y:e.y+n.y}),e},$t.prototype.postExecute=function(t){var e=t.shape,n=t.delta,r=t.hints,i=this._modeling;r.layout!==!1&&(w(e.incoming,function(o){i.layoutConnection(o,{connectionEnd:jn(o,e,n)})}),w(e.outgoing,function(o){i.layoutConnection(o,{connectionStart:Pn(o,e,n)})})),r.recurse!==!1&&this.moveChildren(t)},$t.prototype.revert=function(t){var e=t.shape,n=t.oldParent,r=t.oldParentIndex,i=t.delta;return mt(n.children,e,r),k(e,{parent:n,x:e.x-i.x,y:e.y-i.y}),e},$t.prototype.moveChildren=function(t){var e=t.delta,n=t.shape;this._helper.moveRecursive(n.children,e,null)},$t.prototype.getNewParent=function(t){return t.newParent||t.shape.parent};function le(t){this._modeling=t}le.$inject=["modeling"],le.prototype.execute=function(t){var e=t.newSource,n=t.newTarget,r=t.connection,i=t.dockingOrPoints;if(!e&&!n)throw new Error("newSource or newTarget required");return D(i)&&(t.oldWaypoints=r.waypoints,r.waypoints=i),e&&(t.oldSource=r.source,r.source=e),n&&(t.oldTarget=r.target,r.target=n),r},le.prototype.postExecute=function(t){var e=t.connection,n=t.newSource,r=t.newTarget,i=t.dockingOrPoints,o=t.hints||{},a={};o.connectionStart&&(a.connectionStart=o.connectionStart),o.connectionEnd&&(a.connectionEnd=o.connectionEnd),o.layoutConnection!==!1&&(n&&(!r||o.docking==="source")&&(a.connectionStart=a.connectionStart||vi(D(i)?i[0]:i)),r&&(!n||o.docking==="target")&&(a.connectionEnd=a.connectionEnd||vi(D(i)?i[i.length-1]:i)),o.newWaypoints&&(a.waypoints=o.newWaypoints),this._modeling.layoutConnection(e,a))},le.prototype.revert=function(t){var e=t.oldSource,n=t.oldTarget,r=t.oldWaypoints,i=t.connection;return e&&(i.source=e),n&&(i.target=n),r&&(i.waypoints=r),i};function vi(t){return t.original||t}function lt(t,e){this._modeling=t,this._rules=e}lt.$inject=["modeling","rules"],lt.prototype.preExecute=function(t){var e=this,n=this._modeling,r=this._rules,i=t.oldShape,o=t.newData,a=t.hints||{},s;function c(v,b,_){return r.allowed("connection.reconnect",{connection:_,source:v,target:b})}var u={x:o.x,y:o.y},l={x:i.x,y:i.y,width:i.width,height:i.height};s=t.newShape=t.newShape||e.createShape(o,u,i.parent,a),i.host&&n.updateAttachment(s,i.host);var f;a.moveChildren!==!1&&(f=i.children.slice(),n.moveElements(f,{x:0,y:0},s,a));var h=i.incoming.slice(),p=i.outgoing.slice();w(h,function(v){var b=v.source,_=c(b,s,v);_&&e.reconnectEnd(v,s,An(v,s,l),a)}),w(p,function(v){var b=v.target,_=c(s,b,v);_&&e.reconnectStart(v,s,On(v,s,l),a)})},lt.prototype.postExecute=function(t){var e=t.oldShape;this._modeling.removeShape(e)},lt.prototype.execute=function(t){},lt.prototype.revert=function(t){},lt.prototype.createShape=function(t,e,n,r){return this._modeling.createShape(t,e,n,r)},lt.prototype.reconnectStart=function(t,e,n,r){this._modeling.reconnectStart(t,e,n,r)},lt.prototype.reconnectEnd=function(t,e,n,r){this._modeling.reconnectEnd(t,e,n,r)};function fe(t){this._modeling=t}fe.$inject=["modeling"],fe.prototype.execute=function(t){var e=t.shape,n=t.newBounds,r=t.minBounds;if(n.x===void 0||n.y===void 0||n.width===void 0||n.height===void 0)throw new Error("newBounds must have {x, y, width, height} properties");if(r&&(n.width<r.width||n.height<r.height))throw new Error("width and height cannot be less than minimum height and width");if(!r&&n.width<10||n.height<10)throw new Error("width and height cannot be less than 10px");return t.oldBounds={width:e.width,height:e.height,x:e.x,y:e.y},k(e,{width:n.width,height:n.height,x:n.x,y:n.y}),e},fe.prototype.postExecute=function(t){var e=this._modeling,n=t.shape,r=t.oldBounds,i=t.hints||{};i.layout!==!1&&(w(n.incoming,function(o){e.layoutConnection(o,{connectionEnd:An(o,n,r)})}),w(n.outgoing,function(o){e.layoutConnection(o,{connectionStart:On(o,n,r)})}))},fe.prototype.revert=function(t){var e=t.shape,n=t.oldBounds;return k(e,{width:n.width,height:n.height,x:n.x,y:n.y}),e};function gs(t,e){var n=[];return w(t.concat(e),function(r){var i=r.incoming,o=r.outgoing;w(i.concat(o),function(a){var s=a.source,c=a.target;(he(t,s)||he(t,c)||he(e,s)||he(e,c))&&(he(n,a)||n.push(a))})}),n}function he(t,e){return t.indexOf(e)!==-1}function vs(t,e,n){var r=t.x,i=t.y,o=t.width,a=t.height,s=n.x,c=n.y;switch(e){case"n":return{x:r,y:i+c,width:o,height:a-c};case"s":return{x:r,y:i,width:o,height:a+c};case"w":return{x:r+s,y:i,width:o-s,height:a};case"e":return{x:r,y:i,width:o+s,height:a};default:throw new Error("unknown direction: "+e)}}function bt(t){this._modeling=t}bt.$inject=["modeling"],bt.prototype.preExecute=function(t){var e=t.delta,n=t.direction,r=t.movingShapes,i=t.resizingShapes,o=t.start,a={};this.moveShapes(r,e),w(i,function(s){a[s.id]=ms(s)}),this.resizeShapes(i,e,n),this.updateConnectionWaypoints(gs(r,i),e,n,o,r,i,a)},bt.prototype.execute=function(){},bt.prototype.revert=function(){},bt.prototype.moveShapes=function(t,e){var n=this;w(t,function(r){n._modeling.moveShape(r,e,null,{autoResize:!1,layout:!1,recurse:!1})})},bt.prototype.resizeShapes=function(t,e,n){var r=this;w(t,function(i){var o=vs(i,n,e);r._modeling.resizeShape(i,o,null,{attachSupport:!1,autoResize:!1,layout:!1})})},bt.prototype.updateConnectionWaypoints=function(t,e,n,r,i,o,a){var s=this,c=i.concat(o);w(t,function(u){var l=u.source,f=u.target,h=ys(u),p=mi(n),v={};Et(c,l)&&Et(c,f)?(h=dt(h,function(b){return _i(b,r,n)&&(b[p]=b[p]+e[p]),b.original&&_i(b.original,r,n)&&(b.original[p]=b.original[p]+e[p]),b}),s._modeling.updateWaypoints(u,h,{labelBehavior:!1})):(Et(c,l)||Et(c,f))&&(Et(i,l)?v.connectionStart=Pn(u,l,e):Et(i,f)?v.connectionEnd=jn(u,f,e):Et(o,l)?v.connectionStart=On(u,l,a[l.id]):Et(o,f)&&(v.connectionEnd=An(u,f,a[f.id])),s._modeling.layoutConnection(u,v))})};function yi(t){return k({},t)}function ys(t){return dt(t.waypoints,function(e){return e=yi(e),e.original&&(e.original=yi(e.original)),e})}function mi(t){switch(t){case"n":return"y";case"w":return"x";case"s":return"y";case"e":return"x"}}function _i(t,e,n){var r=mi(n);if(/e|s/.test(n))return t[r]>e;if(/n|w/.test(n))return t[r]<e}function Et(t,e){return t.indexOf(e)!==-1}function ms(t){return{x:t.x,y:t.y,height:t.height,width:t.width}}function Ue(t){this._modeling=t}Ue.$inject=["modeling"],Ue.prototype.execute=function(t){var e=t.shape,n=e.children;t.oldChildrenVisibility=xi(n),e.collapsed=!e.collapsed;var r=wi(n,e.collapsed);return[e].concat(r)},Ue.prototype.revert=function(t){var e=t.shape,n=t.oldChildrenVisibility,r=e.children,i=bi(r,n);return e.collapsed=!e.collapsed,[e].concat(i)};function xi(t){var e={};return w(t,function(n){e[n.id]=n.hidden,n.children&&(e=k({},e,xi(n.children)))}),e}function wi(t,e){var n=[];return w(t,function(r){r.hidden=e,n=n.concat(r),r.children&&(n=n.concat(wi(r.children,r.collapsed||e)))}),n}function bi(t,e){var n=[];return w(t,function(r){r.hidden=e[r.id],n=n.concat(r),r.children&&(n=n.concat(bi(r.children,e)))}),n}function Ke(t){this._modeling=t}Ke.$inject=["modeling"],Ke.prototype.execute=function(t){var e=t.shape,n=t.newHost,r=e.host;return t.oldHost=r,t.attacherIdx=Ei(r,e),Si(n,e),e.host=n,e},Ke.prototype.revert=function(t){var e=t.shape,n=t.newHost,r=t.oldHost,i=t.attacherIdx;return e.host=r,Ei(n,e),Si(r,e,i),e};function Ei(t,e){return qt(t&&t.attachers,e)}function Si(t,e,n){if(t){var r=t.attachers;r||(t.attachers=r=[]),mt(r,e,n)}}function $n(){}$n.prototype.execute=function(t){var e=t.connection,n=t.newWaypoints;return t.oldWaypoints=e.waypoints,e.waypoints=n,e},$n.prototype.revert=function(t){var e=t.connection,n=t.oldWaypoints;return e.waypoints=n,e};function P(t,e,n){this._eventBus=t,this._elementFactory=e,this._commandStack=n;var r=this;t.on("diagram.init",function(){r.registerHandlers(n)})}P.$inject=["eventBus","elementFactory","commandStack"],P.prototype.getHandlers=function(){return{"shape.append":Ne,"shape.create":wt,"shape.delete":ce,"shape.move":$t,"shape.resize":fe,"shape.replace":lt,"shape.toggleCollapse":Ue,spaceTool:bt,"label.create":oe,"connection.create":Fe,"connection.delete":se,"connection.move":Tn,"connection.layout":Ve,"connection.updateWaypoints":$n,"connection.reconnect":le,"elements.create":Mn,"elements.move":Ye,"elements.delete":Rn,"elements.distribute":Ge,"elements.align":He,"element.updateAttachment":Ke}},P.prototype.registerHandlers=function(t){w(this.getHandlers(),function(e,n){t.registerHandler(n,e)})},P.prototype.moveShape=function(t,e,n,r,i){typeof r=="object"&&(i=r,r=null);var o={shape:t,delta:e,newParent:n,newParentIndex:r,hints:i||{}};this._commandStack.execute("shape.move",o)},P.prototype.updateAttachment=function(t,e){var n={shape:t,newHost:e};this._commandStack.execute("element.updateAttachment",n)},P.prototype.moveElements=function(t,e,n,r){r=r||{};var i=r.attach,o=n,a;i===!0?(a=n,o=n.parent):i===!1&&(a=null);var s={shapes:t,delta:e,newParent:o,newHost:a,hints:r};this._commandStack.execute("elements.move",s)},P.prototype.moveConnection=function(t,e,n,r,i){typeof r=="object"&&(i=r,r=void 0);var o={connection:t,delta:e,newParent:n,newParentIndex:r,hints:i||{}};this._commandStack.execute("connection.move",o)},P.prototype.layoutConnection=function(t,e){var n={connection:t,hints:e||{}};this._commandStack.execute("connection.layout",n)},P.prototype.createConnection=function(t,e,n,r,i,o){typeof n=="object"&&(o=i,i=r,r=n,n=void 0),r=this._create("connection",r);var a={source:t,target:e,parent:i,parentIndex:n,connection:r,hints:o};return this._commandStack.execute("connection.create",a),a.connection},P.prototype.createShape=function(t,e,n,r,i){typeof r!="number"&&(i=r,r=void 0),i=i||{};var o=i.attach,a,s;t=this._create("shape",t),o?(a=n.parent,s=n):a=n;var c={position:e,shape:t,parent:a,parentIndex:r,host:s,hints:i};return this._commandStack.execute("shape.create",c),c.shape},P.prototype.createElements=function(t,e,n,r,i){D(t)||(t=[t]),typeof r!="number"&&(i=r,r=void 0),i=i||{};var o={position:e,elements:t,parent:n,parentIndex:r,hints:i};return this._commandStack.execute("elements.create",o),o.elements},P.prototype.createLabel=function(t,e,n,r){n=this._create("label",n);var i={labelTarget:t,position:e,parent:r||t.parent,shape:n};return this._commandStack.execute("label.create",i),i.shape},P.prototype.appendShape=function(t,e,n,r,i){i=i||{},e=this._create("shape",e);var o={source:t,position:n,target:r,shape:e,connection:i.connection,connectionParent:i.connectionParent,hints:i};return this._commandStack.execute("shape.append",o),o.shape},P.prototype.removeElements=function(t){var e={elements:t};this._commandStack.execute("elements.delete",e)},P.prototype.distributeElements=function(t,e,n){var r={groups:t,axis:e,dimension:n};this._commandStack.execute("elements.distribute",r)},P.prototype.removeShape=function(t,e){var n={shape:t,hints:e||{}};this._commandStack.execute("shape.delete",n)},P.prototype.removeConnection=function(t,e){var n={connection:t,hints:e||{}};this._commandStack.execute("connection.delete",n)},P.prototype.replaceShape=function(t,e,n){var r={oldShape:t,newData:e,hints:n||{}};return this._commandStack.execute("shape.replace",r),r.newShape},P.prototype.alignElements=function(t,e){var n={elements:t,alignment:e};this._commandStack.execute("elements.align",n)},P.prototype.resizeShape=function(t,e,n,r){var i={shape:t,newBounds:e,minBounds:n,hints:r};this._commandStack.execute("shape.resize",i)},P.prototype.createSpace=function(t,e,n,r,i){var o={delta:n,direction:r,movingShapes:t,resizingShapes:e,start:i};this._commandStack.execute("spaceTool",o)},P.prototype.updateWaypoints=function(t,e,n){var r={connection:t,newWaypoints:e,hints:n||{}};this._commandStack.execute("connection.updateWaypoints",r)},P.prototype.reconnect=function(t,e,n,r,i){var o={connection:t,newSource:e,newTarget:n,dockingOrPoints:r,hints:i||{}};this._commandStack.execute("connection.reconnect",o)},P.prototype.reconnectStart=function(t,e,n,r){r||(r={}),this.reconnect(t,e,t.target,n,k(r,{docking:"source"}))},P.prototype.reconnectEnd=function(t,e,n,r){r||(r={}),this.reconnect(t,t.source,e,n,k(r,{docking:"target"}))},P.prototype.connect=function(t,e,n,r){return this.createConnection(t,e,n||{},t.parent,r)},P.prototype._create=function(t,e){return la(e)?e:this._elementFactory.create(t,e)},P.prototype.toggleCollapse=function(t,e){var n={shape:t,hints:e||{}};this._commandStack.execute("shape.toggleCollapse",n)};function Ci(){}Ci.prototype.layoutConnection=function(t,e){return e=e||{},[e.connectionStart||Re(e.source||t.source),e.connectionEnd||Re(e.target||t.target)]};const _s={__depends__:[ss,cs,Gt,re],__init__:["modeling"],modeling:["type",P],layouter:["type",Ci]};var xs=15;function ki(t,e){var n;function r(s){return a(s.originalEvent)}t.on("canvas.focus.changed",function(s){s.focused?t.on("element.mousedown",500,r):t.off("element.mousedown",r)});function i(s){var c=n.start,u=n.button,l=ee(s),f=Vt(l,c);if(!n.dragging&&ws(f)>xs&&(n.dragging=!0,u===0&&zr(t),xn("grab")),n.dragging){var h=n.last||n.start;f=Vt(l,h),e.scroll({dx:f.x,dy:f.y}),n.last=l}s.preventDefault()}function o(s){j.unbind(document,"mousemove",i),j.unbind(document,"mouseup",o),n=null,Fr()}function a(s){if(!dn(s.target,".djs-draggable")){var c=s.button;if(!(c>=2||s.ctrlKey||s.shiftKey||s.altKey))return n={button:c,start:ee(s)},j.bind(document,"mousemove",i),j.bind(document,"mouseup",o),!0}}this.isActive=function(){return!!n}}ki.$inject=["eventBus","canvas"];function ws(t){return Math.sqrt(Math.pow(t.x,2)+Math.pow(t.y,2))}const bs={__init__:["moveCanvas"],moveCanvas:["type",ki]};var Es=500,Ss=1e3;function It(t,e){this._eventBus=t,this.offset=5;var n=e.cls("djs-outline",["no-fill"]),r=this;function i(o){var a=G("rect");return T(a,k({x:0,y:0,rx:4,width:100,height:100},n)),a}t.on(["shape.added","shape.changed"],Es,function(o){var a=o.element,s=o.gfx,c=rt(".djs-outline",s);c||(c=r.getOutline(a)||i(),z(s,c)),r.updateShapeOutline(c,a)}),t.on(["connection.added","connection.changed"],function(o){var a=o.element,s=o.gfx,c=rt(".djs-outline",s);c||(c=i(),z(s,c)),r.updateConnectionOutline(c,a)})}It.prototype.updateShapeOutline=function(t,e){var n=!1,r=this._getProviders();r.length&&w(r,function(i){n=n||i.updateOutline(e,t)}),n||T(t,{x:-this.offset,y:-this.offset,width:e.width+this.offset*2,height:e.height+this.offset*2})},It.prototype.updateConnectionOutline=function(t,e){var n=st(e);T(t,{x:n.x-this.offset,y:n.y-this.offset,width:n.width+this.offset*2,height:n.height+this.offset*2})},It.prototype.registerProvider=function(t,e){e||(e=t,t=Ss),this._eventBus.on("outline.getProviders",t,function(n){n.providers.push(e)})},It.prototype._getProviders=function(){var t=this._eventBus.createEvent({type:"outline.getProviders",providers:[]});return this._eventBus.fire(t),t.providers},It.prototype.getOutline=function(t){var e,n=this._getProviders();return w(n,function(r){Q(r.getOutline)&&(e=e||r.getOutline(t))}),e},It.$inject=["eventBus","styles","elementRegistry"];var qe=6;function In(t,e,n){this._canvas=e;var r=this;t.on("element.changed",function(i){n.isSelected(i.element)&&r._updateMultiSelectionOutline(n.get())}),t.on("selection.changed",function(i){var o=i.newSelection;r._updateMultiSelectionOutline(o)})}In.prototype._updateMultiSelectionOutline=function(t){var e=this._canvas.getLayer("selectionOutline");go(e);var n=t.length>1,r=this._canvas.getContainer();if(B(r)[n?"add":"remove"]("djs-multi-select"),!!n){var i=Cs(st(t)),o=G("rect");T(o,k({rx:3},i)),B(o).add("djs-selection-outline"),z(e,o)}},In.$inject=["eventBus","canvas","selection"];function Cs(t){return{x:t.x-qe,y:t.y-qe,width:t.width+qe*2,height:t.height+qe*2}}const ks={__depends__:[Gt],__init__:["outline","multiSelectionOutline"],outline:["type",It],multiSelectionOutline:["type",In]};var Ms=500,Rs=1250,Ts=1500,Ze=Math.round;function Os(t){return{x:t.x+Ze(t.width/2),y:t.y+Ze(t.height/2)}}function Mi(t,e,n,r,i){function o(s,c,u,l){return i.allowed("elements.move",{shapes:s,delta:c,position:u,target:l})}t.on("shape.move.start",Ts,function(s){var c=s.context,u=s.shape,l=r.get().slice();l.indexOf(u)===-1&&(l=[u]),l=As(l),k(c,{shapes:l,validatedShapes:l,shape:u})}),t.on("shape.move.start",Rs,function(s){var c=s.context,u=c.validatedShapes,l;if(l=c.canExecute=o(u),!l)return!1}),t.on("shape.move.move",Ms,function(s){var c=s.context,u=c.validatedShapes,l=s.hover,f={x:s.dx,y:s.dy},h={x:s.x,y:s.y},p;if(p=o(u,f,h,l),c.delta=f,c.canExecute=p,p===null){c.target=null;return}c.target=l}),t.on("shape.move.end",function(s){var c=s.context,u=c.delta,l=c.canExecute,f=l==="attach",h=c.shapes;if(l===!1)return!1;u.x=Ze(u.x),u.y=Ze(u.y),!(u.x===0&&u.y===0)&&n.moveElements(h,u,c.target,{primaryShape:c.shape,attach:f})}),t.on("element.mousedown",function(s){if(ne(s)){var c=te(s);if(!c)throw new Error("must supply DOM mousedown event");return a(c,s.element)}});function a(s,c,u,l){if(tt(u)&&(l=u,u=!1),!(c.waypoints||!c.parent)&&!B(s.target).has("djs-hit-no-move")){var f=Os(c);return e.init(s,f,"shape.move",{cursor:"grabbing",autoActivate:u,data:{shape:c,context:l||{}}}),!0}}this.start=a}Mi.$inject=["eventBus","dragging","modeling","selection","rules"];function As(t){var e=_e(t,"id");return nt(t,function(n){for(;n=n.parent;)if(e[n.id])return!1;return!0})}var Ri=499,Dn="djs-dragging",Ti="drop-ok",Oi="drop-not-ok",Ai="new-parent",Pi="attach-ok";function ji(t,e,n,r){function i(c){var u=o(c),l=Ps(u);return l}function o(c){var u=Mo(c),l=u.flatMap(p=>(p.incoming||[]).concat(p.outgoing||[])),f=u.concat(l),h=[...new Set(f)];return h}function a(c,u){[Pi,Ti,Oi,Ai].forEach(function(l){l===u?e.addMarker(c,l):e.removeMarker(c,l)})}function s(c,u,l){r.addDragger(u,c.dragGroup),l&&e.addMarker(u,Dn),c.allDraggedElements?c.allDraggedElements.push(u):c.allDraggedElements=[u]}t.on("shape.move.start",Ri,function(c){var u=c.context,l=u.shapes,f=u.allDraggedElements,h=i(l);if(!u.dragGroup){var p=G("g");T(p,n.cls("djs-drag-group",["no-events"]));var v=e.getActiveLayer();z(v,p),u.dragGroup=p}h.forEach(function(b){r.addDragger(b,u.dragGroup)}),f?f=Ji([f,o(l)]):f=o(l),w(f,function(b){e.addMarker(b,Dn)}),u.allDraggedElements=f,u.differentParents=js(l)}),t.on("shape.move.move",Ri,function(c){var u=c.context,l=u.dragGroup,f=u.target,h=u.shape.parent,p=u.canExecute;f&&(p==="attach"?a(f,Pi):u.canExecute&&h&&f.id!==h.id?a(f,Ai):a(f,u.canExecute?Ti:Oi)),Pe(l,c.dx,c.dy)}),t.on(["shape.move.out","shape.move.cleanup"],function(c){var u=c.context,l=u.target;l&&a(l,null)}),t.on("shape.move.cleanup",function(c){var u=c.context,l=u.allDraggedElements,f=u.dragGroup;w(l,function(h){e.removeMarker(h,Dn)}),f&&Ot(f)}),this.makeDraggable=s}ji.$inject=["eventBus","canvas","styles","previewSupport"];function Ps(t){var e=nt(t,function(n){return K(n)?et(t,we({id:n.source.id}))&&et(t,we({id:n.target.id})):!0});return e}function js(t){return ro(_e(t,function(e){return e.parent&&e.parent.id}))!==1}const Ls={__depends__:[$r,Gt,ks,re,bn,Wr],__init__:["move","movePreview"],move:["type",Mi],movePreview:["type",ji]};function $s(t){return CSS.escape(t)}var Li=".djs-palette-toggle",$i=".entry",Is=Li+", "+$i,Hn="djs-palette-",Ds="shown",Nn="open",Ii="two-column",Hs=1e3;function I(t,e){this._eventBus=t,this._canvas=e;var n=this;t.on("tool-manager.update",function(r){var i=r.tool;n.updateToolHighlight(i)}),t.on("i18n.changed",function(){n._update()}),t.on("diagram.init",function(){n._diagramInitialized=!0,n._rebuild()})}I.$inject=["eventBus","canvas"],I.prototype.registerProvider=function(t,e){e||(e=t,t=Hs),this._eventBus.on("palette.getProviders",t,function(n){n.providers.push(e)}),this._rebuild()},I.prototype.getEntries=function(){var t=this._getProviders();return t.reduce(Fs,{})},I.prototype._rebuild=function(){if(this._diagramInitialized){var t=this._getProviders();t.length&&(this._container||this._init(),this._update())}},I.prototype._init=function(){var t=this,e=this._eventBus,n=this._getParentContainer(),r=this._container=yt(I.HTML_MARKUP);n.appendChild(r),ct(n).add(Hn+Ds),ke.bind(r,Is,"click",function(i){var o=i.delegateTarget;if(Uo(o,Li))return t.toggle();t.trigger("click",i)}),j.bind(r,"mousedown",function(i){i.stopPropagation()}),ke.bind(r,$i,"dragstart",function(i){t.trigger("dragstart",i)}),e.on("canvas.resized",this._layoutChanged,this),e.fire("palette.create",{container:r})},I.prototype._getProviders=function(t){var e=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},I.prototype._toggleState=function(t){t=t||{};var e=this._getParentContainer(),n=this._container,r=this._eventBus,i,o=ct(n),a=ct(e);"twoColumn"in t?i=t.twoColumn:i=this._needsCollapse(e.clientHeight,this._entries||{}),o.toggle(Ii,i),a.toggle(Hn+Ii,i),"open"in t&&(o.toggle(Nn,t.open),a.toggle(Hn+Nn,t.open)),r.fire("palette.changed",{twoColumn:i,open:this.isOpen()})},I.prototype._update=function(){var t=rt(".djs-palette-entries",this._container),e=this._entries=this.getEntries();hn(t),w(e,function(n,r){var i=n.group||"default",o=rt("[data-group="+$s(i)+"]",t);o||(o=yt('<div class="group"></div>'),At(o,"data-group",i),t.appendChild(o));var a=n.html||(n.separator?'<hr class="separator" />':'<div class="entry" draggable="true"></div>'),s=yt(a);if(o.appendChild(s),!n.separator&&(At(s,"data-action",r),n.title&&At(s,"title",n.title),n.className&&Ns(s,n.className),n.imageUrl)){var c=yt("<img>");At(c,"src",n.imageUrl),s.appendChild(c)}}),this.open()},I.prototype.trigger=function(t,e,n){var r,i,o=e.delegateTarget||e.target;return o?(r=At(o,"data-action"),i=e.originalEvent||e,this.triggerEntry(r,t,i,n)):e.preventDefault()},I.prototype.triggerEntry=function(t,e,n,r){var i=this._entries,o,a;if(o=i[t],!!o&&(a=o.action,this._eventBus.fire("palette.trigger",{entry:o,event:n})!==!1)){if(Q(a)){if(e==="click")return a(n,r)}else if(a[e])return a[e](n,r);n.preventDefault()}},I.prototype._layoutChanged=function(){this._toggleState({})},I.prototype._needsCollapse=function(t,e){var n=50,r=Object.keys(e).length*46;return t<r+n},I.prototype.close=function(){this._toggleState({open:!1,twoColumn:!1})},I.prototype.open=function(){this._toggleState({open:!0})},I.prototype.toggle=function(){this.isOpen()?this.close():this.open()},I.prototype.isActiveTool=function(t){return t&&this._activeTool===t},I.prototype.updateToolHighlight=function(t){var e,n;this._toolsContainer||(e=rt(".djs-palette-entries",this._container),this._toolsContainer=rt("[data-group=tools]",e)),n=this._toolsContainer,w(n.children,function(r){var i=r.getAttribute("data-action");if(i){var o=ct(r);i=i.replace("-tool",""),o.contains("entry")&&i===t?o.add("highlighted-entry"):o.remove("highlighted-entry")}})},I.prototype.isOpen=function(){return ct(this._container).has(Nn)},I.prototype._getParentContainer=function(){return this._canvas.getContainer()},I.HTML_MARKUP='<div class="djs-palette"><div class="djs-palette-entries"></div><div class="djs-palette-toggle"></div></div>';function Ns(t,e){var n=ct(t),r=D(e)?e:e.split(/\s+/g);r.forEach(function(i){n.add(i)})}function Fs(t,e){var n=e.getPaletteEntries();return Q(n)?n(t):(w(n,function(r,i){t[i]=r}),t)}const zs={__init__:["palette"],palette:["type",I]};function St(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}St.prototype.getSnapOrigin=function(t){return this._snapOrigins[t]},St.prototype.setSnapOrigin=function(t,e){this._snapOrigins[t]=e,this._snapLocations.indexOf(t)===-1&&this._snapLocations.push(t)},St.prototype.addDefaultSnap=function(t,e){var n=this._defaultSnaps[t];n||(n=this._defaultSnaps[t]=[]),n.push(e)},St.prototype.getSnapLocations=function(){return this._snapLocations},St.prototype.setSnapLocations=function(t){this._snapLocations=t},St.prototype.pointsForTarget=function(t){var e=t.id||t,n=this._targets[e];return n||(n=this._targets[e]=new Xe,n.initDefaults(this._defaultSnaps)),n};function Xe(){this._snapValues={}}Xe.prototype.add=function(t,e){var n=this._snapValues[t];n||(n=this._snapValues[t]={x:[],y:[]}),n.x.indexOf(e.x)===-1&&n.x.push(e.x),n.y.indexOf(e.y)===-1&&n.y.push(e.y)},Xe.prototype.snap=function(t,e,n,r){var i=this._snapValues[e];return i&&Va(t[n],i[n],r)},Xe.prototype.initDefaults=function(t){var e=this;w(t||{},function(n,r){w(n,function(i){e.add(r,i)})})};var Gs=1250;function de(t,e,n){var r=this;this._elementRegistry=t,e.on(["create.start","shape.move.start"],function(i){r.initSnap(i)}),e.on(["create.move","create.end","shape.move.move","shape.move.end"],Gs,function(i){var o=i.context,a=o.shape,s=o.snapContext,c=o.target;if(!(i.originalEvent&&wn(i.originalEvent))&&!(ie(i)||!c)){var u=s.pointsForTarget(c);u.initialized||(u=r.addSnapTargetPoints(u,a,c),u.initialized=!0),n.snap(i,u)}}),e.on(["create.cleanup","shape.move.cleanup"],function(){n.hide()})}de.$inject=["elementRegistry","eventBus","snapping"],de.prototype.initSnap=function(t){var e=this._elementRegistry,n=t.context,r=n.shape,i=n.snapContext;i||(i=n.snapContext=new St);var o;e.get(r.id)?o=Wt(r,t):o={x:t.x+Wt(r).x,y:t.y+Wt(r).y};var a={x:o.x-r.width/2,y:o.y-r.height/2},s={x:o.x+r.width/2,y:o.y+r.height/2};return i.setSnapOrigin("mid",{x:o.x-t.x,y:o.y-t.y}),Dt(r)||(i.setSnapOrigin("top-left",{x:a.x-t.x,y:a.y-t.y}),i.setSnapOrigin("bottom-right",{x:s.x-t.x,y:s.y-t.y})),i},de.prototype.addSnapTargetPoints=function(t,e,n){var r=this.getSnapTargets(e,n);return w(r,function(i){if(Dt(i)){Dt(e)&&t.add("mid",Wt(i));return}if(K(i)){if(i.waypoints.length<3)return;var o=i.waypoints.slice(1,-1);w(o,function(a){t.add("mid",a)});return}t.add("mid",Wt(i))}),!N(e.x)||!N(e.y)||this._elementRegistry.get(e.id)&&t.add("mid",Wt(e)),t},de.prototype.getSnapTargets=function(t,e){return ei(e).filter(function(n){return!Vs(n)})};function Vs(t){return!!t.hidden}var Bs=1250;function pe(t,e){var n=this;t.on(["resize.start"],function(r){n.initSnap(r)}),t.on(["resize.move","resize.end"],Bs,function(r){var i=r.context,o=i.shape,a=o.parent,s=i.direction,c=i.snapContext;if(!(r.originalEvent&&wn(r.originalEvent))&&!ie(r)){var u=c.pointsForTarget(a);u.initialized||(u=n.addSnapTargetPoints(u,o,a,s),u.initialized=!0),Us(s)&&Le(r,"x",r.x),Ks(s)&&Le(r,"y",r.y),e.snap(r,u)}}),t.on(["resize.cleanup"],function(){e.hide()})}pe.prototype.initSnap=function(t){var e=t.context,n=e.shape,r=e.direction,i=e.snapContext;i||(i=e.snapContext=new St);var o=Di(n,r);return i.setSnapOrigin("corner",{x:o.x-t.x,y:o.y-t.y}),i},pe.prototype.addSnapTargetPoints=function(t,e,n,r){var i=this.getSnapTargets(e,n);return w(i,function(o){t.add("corner",Wa(o)),t.add("corner",Ba(o))}),t.add("corner",Di(e,r)),t},pe.$inject=["eventBus","snapping"],pe.prototype.getSnapTargets=function(t,e){return ei(e).filter(function(n){return!Ws(n,t)&&!K(n)&&!Ys(n)&&!Dt(n)})};function Di(t,e){var n=Re(t),r=Zt(t),i={x:n.x,y:n.y};return e.indexOf("n")!==-1?i.y=r.top:e.indexOf("s")!==-1&&(i.y=r.bottom),e.indexOf("e")!==-1?i.x=r.right:e.indexOf("w")!==-1&&(i.x=r.left),i}function Ws(t,e){return t.host===e}function Ys(t){return!!t.hidden}function Us(t){return t==="n"||t==="s"}function Ks(t){return t==="e"||t==="w"}var qs=7,Zs=1e3;function Ct(t){this._canvas=t,this._asyncHide=Kn(be(this.hide,this),Zs)}Ct.$inject=["canvas"],Ct.prototype.snap=function(t,e){var n=t.context,r=n.snapContext,i=r.getSnapLocations(),o={x:ie(t,"x"),y:ie(t,"y")};w(i,function(a){var s=r.getSnapOrigin(a),c={x:t.x+s.x,y:t.y+s.y};if(w(["x","y"],function(u){var l;o[u]||(l=e.snap(c,a,u,qs),l!==void 0&&(o[u]={value:l,originValue:l-s[u]}))}),o.x&&o.y)return!1}),this.showSnapLine("vertical",o.x&&o.x.value),this.showSnapLine("horizontal",o.y&&o.y.value),w(["x","y"],function(a){var s=o[a];tt(s)&&Le(t,a,s.originValue)})},Ct.prototype._createLine=function(t){var e=this._canvas.getLayer("snap"),n=G("path");return T(n,{d:"M0,0 L0,0"}),B(n).add("djs-snap-line"),z(e,n),{update:function(r){N(r)?t==="horizontal"?T(n,{d:"M-100000,"+r+" L+100000,"+r,display:""}):T(n,{d:"M "+r+",-100000 L "+r+", +100000",display:""}):T(n,{display:"none"})}}},Ct.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}},Ct.prototype.showSnapLine=function(t,e){var n=this.getSnapLine(t);n&&n.update(e),this._asyncHide()},Ct.prototype.getSnapLine=function(t){return this._snapLines||this._createSnapLines(),this._snapLines[t]},Ct.prototype.hide=function(){w(this._snapLines,function(t){t.update()})};const Xs={__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",de],resizeSnapping:["type",pe],snapping:["type",Ct]};function Fn(t){return Math.log(t)/Math.log(10)}function Hi(t,e){var n=Fn(t.min),r=Fn(t.max),i=Math.abs(n)+Math.abs(r);return i/e}function Qs(t,e){return Math.max(t.min,Math.min(t.max,e))}var Js=Math.sign||function(t){return t>=0?1:-1},zn={min:.2,max:4},Ni=10,tc=.1,ec=.75;function it(t,e,n){t=t||{},this._enabled=!1,this._canvas=n,this._container=n._container,this._handleWheel=be(this._handleWheel,this),this._totalDelta=0,this._scale=t.scale||ec;var r=this;e.on("canvas.focus.changed",function(i){r._init(i.focused&&t.enabled!==!1)})}it.$inject=["config.zoomScroll","eventBus","canvas"],it.prototype.scroll=function(e){this._canvas.scroll(e)},it.prototype.reset=function(){this._canvas.zoom("fit-viewport")},it.prototype.zoom=function(e,n){var r=Hi(zn,Ni*2);this._totalDelta+=e,Math.abs(this._totalDelta)>tc&&(this._zoom(e,n,r),this._totalDelta=0)},it.prototype._handleWheel=function(e){if(this._canvas.isFocused()){var n=this._container;e.preventDefault();var r=e.ctrlKey||wa()&&e.metaKey,i=e.shiftKey,o=-1*this._scale,a;if(r?o*=e.deltaMode===0?.02:.32:o*=e.deltaMode===0?1:16,r){var s=n.getBoundingClientRect(),c={x:e.clientX-s.left,y:e.clientY-s.top};a=Math.sqrt(Math.pow(e.deltaY,2)+Math.pow(e.deltaX,2))*Js(e.deltaY)*o,this.zoom(a,c)}else i?a={dx:o*e.deltaY,dy:0}:a={dx:o*e.deltaX,dy:o*e.deltaY},this.scroll(a)}},it.prototype.stepZoom=function(e,n){var r=Hi(zn,Ni);this._zoom(e,n,r)},it.prototype._zoom=function(t,e,n){var r=this._canvas,i=t>0?1:-1,o=Fn(r.zoom()),a=Math.round(o/n)*n;a+=n*i;var s=Math.pow(10,a);r.zoom(Qs(zn,s),e)},it.prototype.toggle=function(e){var n=this._container,r=this._handleWheel,i=this._enabled;return typeof e>"u"&&(e=!i),i!==e&&j[e?"bind":"unbind"](n,"wheel",r,!1),this._enabled=e,e},it.prototype._init=function(t){this.toggle(t)};const nc={__init__:["zoomScroll"],zoomScroll:["type",it]};function rc(t,e){if(t.ownerDocument!==e.ownerDocument)try{return e.ownerDocument.importNode(t,!0)}catch{}return t}function ic(t,e){return e.appendChild(rc(t,e))}function kt(t,e){return ic(e,t),t}var Gn=2,Fi={"alignment-baseline":1,"baseline-shift":1,clip:1,"clip-path":1,"clip-rule":1,color:1,"color-interpolation":1,"color-interpolation-filters":1,"color-profile":1,"color-rendering":1,cursor:1,direction:1,display:1,"dominant-baseline":1,"enable-background":1,fill:1,"fill-opacity":1,"fill-rule":1,filter:1,"flood-color":1,"flood-opacity":1,font:1,"font-family":1,"font-size":Gn,"font-size-adjust":1,"font-stretch":1,"font-style":1,"font-variant":1,"font-weight":1,"glyph-orientation-horizontal":1,"glyph-orientation-vertical":1,"image-rendering":1,kerning:1,"letter-spacing":1,"lighting-color":1,marker:1,"marker-end":1,"marker-mid":1,"marker-start":1,mask:1,opacity:1,overflow:1,"pointer-events":1,"shape-rendering":1,"stop-color":1,"stop-opacity":1,stroke:1,"stroke-dasharray":1,"stroke-dashoffset":1,"stroke-linecap":1,"stroke-linejoin":1,"stroke-miterlimit":1,"stroke-opacity":1,"stroke-width":Gn,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function oc(t,e){return Fi[e]?t.style[e]:t.getAttributeNS(null,e)}function zi(t,e,n){var r=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=Fi[r];i?(i===Gn&&typeof n=="number"&&(n=String(n)+"px"),t.style[r]=n):t.setAttributeNS(null,e,n)}function ac(t,e){var n=Object.keys(e),r,i;for(r=0,i;i=n[r];r++)zi(t,i,e[i])}function Mt(t,e,n){if(typeof e=="string")if(n!==void 0)zi(t,e,n);else return oc(t,e);else ac(t,e);return t}var Vn={svg:"http://www.w3.org/2000/svg"},Gi='<svg xmlns="'+Vn.svg+'"';function sc(t){var e=!1;t.substring(0,4)==="<svg"?t.indexOf(Vn.svg)===-1&&(t=Gi+t.substring(4)):(t=Gi+">"+t+"</svg>",e=!0);var n=cc(t);if(!e)return n;for(var r=document.createDocumentFragment(),i=n.firstChild;i.firstChild;)r.appendChild(i.firstChild);return r}function cc(t){var e;return e=new DOMParser,e.async=!1,e.parseFromString(t,"text/xml")}function Rt(t,e){var n;return t=t.trim(),t.charAt(0)==="<"?(n=sc(t).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(Vn.svg,t),n}const uc=window.Drupal||Drupal,lc=window.Maestro||Maestro;class Vi extends ht{constructor(e,n){super(e,2e3),this._overlays=n,this._drupal=uc,this._maestro=lc}canRender(e){return e.type.startsWith("maestro:Task")}drawShape(e,n){const r=n.taskid,i=n.taskName||"---",o=n.taskType||null,a=n.workflowStatusMessage||"",s=n.workflowStatusNumber||"",c=n.colour||"#333",{width:u,height:l}=n,f=Rt("g");if(o=="MaestroStart"||o=="MaestroEnd"){const h=Rt("circle");h.setAttribute("cx",u/2),h.setAttribute("cy",l/2),h.setAttribute("r",l/2),h.setAttribute("fill","#eee"),h.setAttribute("stroke",c),h.setAttribute("taskid",r),kt(f,h)}else if(o=="MaestroIf"){const h=Rt("polygon"),p=u/2,v=l/2,b=u/2,_=[`${p},${v-b}`,`${p+b},${v}`,`${p},${v+b}`,`${p-b},${v}`].join(" ");h.setAttribute("points",_),h.setAttribute("fill","#eee"),h.setAttribute("stroke",c),h.setAttribute("taskid",r),kt(f,h)}else{const h=Rt("rect");h.setAttribute("width",u),h.setAttribute("height",l),h.setAttribute("fill","#eee"),h.setAttribute("stroke",c),h.setAttribute("rx",10),h.setAttribute("ry",10),h.setAttribute("taskid",r),kt(f,h)}{const h=Rt("text");h.setAttribute("x",u/2),h.setAttribute("y",l/2),h.setAttribute("text-anchor","middle"),h.setAttribute("dominant-baseline","middle"),h.setAttribute("font-family","Arial, sans-serif"),h.setAttribute("font-size","12"),h.setAttribute("fill","#333"),h.setAttribute("pointer-events","none"),h.setAttribute("data-task-label",r),h.textContent=i,kt(f,h)}if(s){const h=Rt("rect");s.toString();const p=24,v=12,b=2;h.setAttribute("x",u-15-(p/2+b)),h.setAttribute("y",l-10-(v/2+b)),h.setAttribute("width",p+b),h.setAttribute("height",v+b),h.setAttribute("fill","#909090"),h.setAttribute("stroke","#cccccc"),h.setAttribute("stroke-width","1"),h.setAttribute("rx","6"),h.setAttribute("ry","6"),h.setAttribute("pointer-events","all"),h.setAttribute("title",a),kt(f,h);const _=Rt("text");_.setAttribute("x",u-(15+b)),_.setAttribute("y",l-10),_.setAttribute("text-anchor","middle"),_.setAttribute("dominant-baseline","middle"),_.setAttribute("font-family","Arial, sans-serif"),_.setAttribute("font-size","10"),_.setAttribute("fill","#333"),_.setAttribute("data-task-status-number",r),_.textContent=s,_.setAttribute("title",a),kt(f,_)}return kt(e,f),this._overlays.add(n,"maestro-hamburger",{position:{top:-10,left:5},html:this._createHamburgerSVGOverlay(n)}),f}_createHamburgerSVGOverlay(e){const n=document.createElement("div");n.style.width="20px",n.style.height="20px",n.style.cursor="pointer",n.setAttribute("data-taskid",e.taskid);const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("width","20"),r.setAttribute("height","20"),r.setAttribute("viewBox","0 0 20 20");const i=document.createElementNS("http://www.w3.org/2000/svg","rect");i.setAttribute("width","20"),i.setAttribute("height","20"),i.setAttribute("fill","#fff"),i.setAttribute("stroke","#333"),i.setAttribute("rx","4"),i.setAttribute("ry","4"),r.appendChild(i);for(let o=0;o<3;o++){const a=document.createElementNS("http://www.w3.org/2000/svg","rect");a.setAttribute("x","4"),a.setAttribute("y",4+o*5),a.setAttribute("width","12"),a.setAttribute("height","2"),a.setAttribute("fill","#555"),r.appendChild(a)}return n.appendChild(r),n.addEventListener("click",o=>{o.stopPropagation(),this._maestro.maestroHandleEditClick(e.taskid,e.capabilities,o.pageX,o.pageY)}),n}}Yi(Vi,"$inject",["eventBus","overlays"]);const fc={__init__:["maestroTaskRenderer"],maestroTaskRenderer:["type",Vi]};function Bi(t,e,n){e.on("diagram.init",()=>{t.zoom(parseFloat(Maestro.canvasZoom)||1);const i=t.viewbox();t.viewbox({x:parseFloat(Maestro.panLeft)||0,y:parseFloat(Maestro.panTop)||0,width:i.width,height:i.height,scale:parseFloat(Maestro.canvasZoom)||1}),r(t)}),e.on("drag.start",1500,function(i){const o=i.shape;o&&o.draggable===!1&&i.preventDefault()}),e.on("shape.added",function(i){const o=i.element;(o.createdWithPalette||!1)&&(document.querySelector('[name="palette_task_type"]').value=o.taskType,document.querySelector('[name="palette_task_id"]').value=o.id,document.querySelector('[name="palette_task_label"]').value=o.taskName,document.querySelector('[name="task_clicked"]').value=o.id,document.querySelector('[name="task_top"]').value=o.y,document.querySelector('[name="task_left"]').value=o.x,jQuery("#edit-create-new-task-from-palette-complete").trigger("mousedown"),document.querySelector('[name="palette_task_type"]').value="",document.querySelector('[name="palette_task_id"]').value="",document.querySelector('[name="palette_task_label"]').value="",document.querySelector('[name="task_clicked"]').value="",document.querySelector('[name="task_top"]').value="",document.querySelector('[name="task_left"]').value="",Maestro.maestroDisplayedTasks[o.id]=o,Maestro.maestroClearCanvasSeletedElement());const s=i.gfx;if(o.type.startsWith("maestro:Task")){let c=Rt("title"),u=o.longTaskName||"";u+=`
${o.taskType}`,u+=`
ID: ${o.taskid}`,parseInt(o.workflowStatusNumber)>0&&(u+=`
${o.workflowStatusMessage}`),c.textContent=u,kt(s,c)}}),e.on("commandStack.shape.move.postExecuted",function(i){const a=i.context.shape;setTimeout(()=>{a.incoming.concat(a.outgoing).forEach(c=>{let u=Maestro.maestroCalculateClosestEdgePointsFromConnection(c);n.updateWaypoints(c,u)}),jQuery('[name="task_clicked"]').val(a.id),jQuery('[name="task_top"]').val(a.y),jQuery('[name="task_left"]').val(a.x),jQuery("#edit-move-task-complete").trigger("mousedown"),Maestro.maestroClearCanvasSeletedElement()},0)}),e.on("connection.added",function(i){const o=i.element,a=i.gfx.querySelector("path"),s=window.location.href.split("#")[0];if(a){let c="#000",u="black";(o.businessObject.connectionType||!1)=="MaestroFalse"&&(c="#f00",u="red"),a.style.color=c,a.setAttribute("stroke",c),a.setAttribute("stroke-width",3),Mt(a,"color",c),Mt(a,"stroke",c),Mt(a,"stroke-width",3),Mt(a,"marker-end",`url(${s}#arrowhead-${u})`)}}),e.on("element.changed",function(i){const o=i.element,a=window.location.href.split("#")[0];if(o.waypoints){const c=t.getGraphics(o).querySelector("path");if(c){let u="#000",l="black";(o.businessObject.connectionType||!1)=="MaestroFalse"&&(u="#f00",l="red"),c.style.color=u,c.setAttribute("stroke",u),c.setAttribute("stroke-width",3),c.style.color=u,Mt(c,"color",u),Mt(c,"stroke",u),Mt(c,"stroke-width",3),Mt(c,"marker-end",`url(${a}#arrowhead-${l})`)}}}),e.on("selection.changed",function(i){const o=Maestro.maestroDiagram.get("canvas"),a=Maestro.maestroDiagram.get("elementFactory"),s=o.getRootElement();var c,u,l,f,h="maestroNormal",p="#edit-draw-line-complete";(Maestro.maestroLineFrom!=null||Maestro.maestroFalseLineFrom!=null)&&i.newSelection.length&&(h="MaestroNormal",f=i.newSelection[0]||null,Maestro.maestroLineFrom?l=Maestro.maestroGetTaskReference(Maestro.maestroLineFrom):(h="MaestroFalse",l=Maestro.maestroGetTaskReference(Maestro.maestroFalseLineFrom),p="#edit-draw-false-line-complete"),u=Maestro.maestroCalculateClosestEdgePointsFromShapes(l,f),c=a.createConnection({type:"connection",waypoints:u,source:l,target:f,businessObject:{connectionType:h}}),o.addConnection(c,s),i.stopPropagation(),i.preventDefault(),Maestro.maestroClearCanvasSeletedElement(),jQuery(".maestro-template-message-area").css("display","none"),jQuery('[name="task_line_from"]').val(l.id),jQuery('[name="task_line_to"]').val(f.id),jQuery(p).trigger("mousedown"),Maestro.maestroLineFrom=null,Maestro.maestroFalseLineFrom=null)}),e.on("canvas.viewbox.changed",function(i){const o=i.viewbox;jQuery('[name="pan_top"]').val(o.y),jQuery('[name="pan_left"]').val(o.x),jQuery('[name="zoom"]').val(o.scale),clearTimeout(Maestro.panZoomTimeout),Maestro.panZoomTimeout=setTimeout(function(){jQuery("#edit-pan-zoom-complete").trigger("mousedown")},Maestro.panZoomDelay)});function r(i){const o=i.getContainer().querySelector("svg");let a=o.querySelector("defs");a||(a=document.createElementNS("http://www.w3.org/2000/svg","defs"),o.insertBefore(a,o.firstChild));var s=document.createElementNS("http://www.w3.org/2000/svg","marker");s.setAttribute("id","arrowhead-black"),s.setAttribute("viewBox","0 0 10 10"),s.setAttribute("markerWidth","12"),s.setAttribute("markerHeight","12"),s.setAttribute("refX","10"),s.setAttribute("refY","5"),s.setAttribute("orient","auto"),s.setAttribute("markerUnits","userSpaceOnUse"),s.setAttribute("strokeWidth",1);var c=document.createElementNS("http://www.w3.org/2000/svg","polygon");c.setAttribute("points","0 0, 10 5, 0 10"),c.setAttribute("fill","currentColor"),c.setAttribute("stroke","none"),s.appendChild(c),a.appendChild(s),s=document.createElementNS("http://www.w3.org/2000/svg","marker"),s.setAttribute("id","arrowhead-red"),s.setAttribute("viewBox","0 0 10 10"),s.setAttribute("markerWidth","12"),s.setAttribute("markerHeight","12"),s.setAttribute("refX","10"),s.setAttribute("refY","5"),s.setAttribute("orient","auto"),s.setAttribute("markerUnits","userSpaceOnUse"),s.setAttribute("strokeWidth",1),c=document.createElementNS("http://www.w3.org/2000/svg","polygon"),c.setAttribute("points","0 0, 10 5, 0 10"),c.setAttribute("fill","#f00"),c.setAttribute("stroke","none"),s.appendChild(c),a.appendChild(s)}}Bi.$inject=["canvas","eventBus","modeling"];const hc={__init__:["maestroTaskEvents"],maestroTaskEvents:["type",Bi]};function ge(t,e,n){this._palette=t,this._create=e,this._elementFactory=n,t.registerProvider(this),this.injectTaskColors()}ge.$inject=["palette","create","elementFactory"],ge.prototype.createTaskTypeEntries=function(t){const e={};return!Maestro.taskTypes||!Maestro.maestroTaskColours?(console.warn("Maestro task types or colors not found"),e):(Object.keys(Maestro.taskTypes).forEach(n=>{const r=Maestro.taskTypes[n],i=Maestro.maestroTaskColours[n]||"#cccccc",o=Maestro.taskWidth||100,a=Maestro.taskHeight||50,s=`create-${n.toLowerCase()}`;new Date().getTime();const u=Maestro.taskCapabilities[n]||{},l=Object.values(u);e[s]=t("maestro:Task","maestro-tasks",`palette-icon-${n.toLowerCase()}`,`Create ${r}`,{businessObject:{$type:"maestro:Task",taskType:n},createdWithPalette:!0,width:100,height:80,taskType:n,taskColor:i,id:`${n.toLowerCase()}`,x:10,y:10,width:o,height:a,type:"maestro:Task",draggable:!0,taskid:`${n.toLowerCase()}`,colour:i,uiLabel:`${r}`,taskName:`${r}`,capabilities:[...l],to:[],falsebranch:[],workflowStatusMessage:"",workflowStatusNumber:""})}),e["zoom-separator"]={group:"zoom",separator:!0,class:"maestro-zoom-separator"},e["zoom-in"]={group:"zoom",className:"maestro-palette-zoom",title:"Zoom In",action:{click:function(){const n=Maestro.canvas.zoom(),r=Math.min(n+.1,4);Maestro.canvas.zoom(r)}},html:`
<div class="entry" title="Zoom In">
<svg width="20" height="20" viewBox="0 0 20 20">
<path d="M10 4v12M4 10h12" stroke="currentColor" stroke-width="2" fill="none"/>
</svg>
</div>
`},e["zoom-out"]={group:"zoom",className:"maestro-palette-zoom",title:"Zoom Out",action:{click:function(){const n=Maestro.canvas.zoom(),r=Math.max(n-.1,.2);Maestro.canvas.zoom(r)}},html:`
<div class="entry" title="Zoom Out">
<svg width="20" height="20" viewBox="0 0 20 20">
<path d="M4 10h12" stroke="currentColor" stroke-width="2" fill="none"/>
</svg>
</div>
`},e)},ge.prototype.injectTaskColors=function(){if(!Maestro.maestroTaskColours)return;const t=document.createElement("style");let e="",n="",r="";Object.keys(Maestro.taskTypes).forEach(i=>{n="",r="";const o=Maestro.maestroTaskColours[i],a=Maestro.taskTypes[i];if(i=="MaestroEnd"){var s=a.slice(0,8);s!=a&&(s=s+"..."),e+=`.palette-icon-${i.toLowerCase()}:after {
content: "";
display: block;
background: none;
position: relative;
width: 50px;
height: 50px;
border: solid ${o} 2px;
border-radius: 30px;
top: -45px;
left: 10px;
}`,n=`
width: 79px !important;
height: 54px !important;
margin: 2px;
border: none;
padding: 3px;
line-height: 38px !important;
`}else if(i=="MaestroIf"){var s=a.slice(0,12);s!=a&&(s=s+"..."),e+=`.palette-icon-${i.toLowerCase()}:after {
content: "";
display: block;
background: none;
position: relative;
width: 40px;
height: 40px;
border: solid ${o} 2px;
border-radius: 0px;
transform: rotate(45deg);
top: -41px;
left: 10px;
}`,n=`
width: 79px !important;
height: 54px !important;
margin: 2px;
border: none;
padding: 3px;
line-height: 38px !important;
`,r=`
position: relative;
left: -5px;
`}else{var s=a;n=`
border: solid ${o} 2px;
width: 75px !important;
height: 50px !important;
margin: 2px;
border-radius: 12px;
padding: 3px;
line-height: 38px !important;
`,r=`
width: 80px;
position: relative;
display: block;
height: 55px;
white-space: wrap;
line-height: 10px;
margin-top: 16px;
text-align: center;
left: -2px;
`}e+=`.palette-icon-${i.toLowerCase()} {
${n}
}
.palette-icon-${i.toLowerCase()}:before {
content: "${s}";
font-size: 7pt;
${r}
}
`}),t.textContent=e,document.head.appendChild(t)},ge.prototype.getPaletteEntries=function(t){const{_create:e,_elementFactory:n}=this;function r(i,o,a,s,c={}){function u(l){const f=n.createShape(Object.assign({type:i},c)),h=Date.now(),p={...c};p.id=`${c.id}${h}`,p.taskid=`${c.taskid}${h}`,p&&Object.assign(f,p),e.start(l,f)}return{group:o,className:a,title:s,action:{dragstart:u,click:u}}}return{...this.createTaskTypeEntries(r)}};const dc={__depends__:[ma,C,as,za,V,Pt,W,Ja,_s,bs,Ls,rs,{__init__:[["defaultRenderer",function(t){t.CONNECTION_STYLE={fill:"none",strokeWidth:3,stroke:"#000"}}]]},zs,re,Xs,nc,hc,fc,{__init__:["maestroPaletteProvider"],maestroPaletteProvider:["type",ge]}]};window.TemplateBuilder=window.TemplateBuilder||{},(function(t,e,n,r){TemplateBuilder.setup=function(){r.tasks=n.maestro||{},r.maestroTaskColours=n.maestroTaskColours||[],r.taskTypes=n.task_types,r.taskCapabilities=n.taskCapabilities||{},r.taskWidth=n.taskWidth||100,r.taskHeight=n.taskHeight||50,r.taskRadius=n.taskRadius||50,r.canvasZoom=n.zoom||1,r.panLeft=n.pan_left||0,r.panTop=n.pan_top||0,r.panZoomDelay=n.panZoomDelay||1500},TemplateBuilder.createTemplateCanvas=function(i){r.maestroDiagram=new Jt({canvas:{container:i},modules:[dc]}),r.canvas=r.maestroDiagram.get("canvas");const o=r.maestroDiagram.get("elementFactory");r.canvasRoot=o.createRoot(),r.canvas.setRootElement(r.canvasRoot)},TemplateBuilder.drawOneTask=function(i){r.maestroDrawOneTask(i)},TemplateBuilder.drawConnectors=function(i){r.maestroDrawConnectors(i)}})(window,jQuery,drupalSettings,Maestro)}));
