UNPKG

camunda-bpmn-js

Version:

Embeddable Camunda modeling distributions based on bpmn-js

1 lines 2.51 MB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).BpmnModeler=t()}(this,(function(){"use strict";function e(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,i={exports:{}};var r=function(){if(n)return i.exports;n=1;var e=i.exports=function(t,n){if(n||(n=16),void 0===t&&(t=128),t<=0)return"0";for(var i=Math.log(Math.pow(2,t))/Math.log(n),r=2;i===1/0;r*=2)i=Math.log(Math.pow(2,t/r))/Math.log(n)*r;var o=i-Math.floor(i),s="";for(r=0;r<Math.floor(i);r++){s=Math.floor(Math.random()*n).toString(n)+s}if(o){var a=Math.pow(n,o);s=Math.floor(Math.random()*a).toString(n)+s}var l=parseInt(s,n);return l!==1/0&&l>=Math.pow(2,t)?e(t,n):s};return e.rack=function(t,n,i){var r=function(r){var s=0;do{if(s++>10){if(!i)throw new Error("too many ID collisions, use more bits");t+=i}var a=e(t,n)}while(Object.hasOwnProperty.call(o,a));return o[a]=r,a},o=r.hats={};return r.get=function(e){return r.hats[e]},r.set=function(e,t){return r.hats[e]=t,r},r.bits=t||128,r.base=n||16,r},i.exports}(),o=t(r);function s(e){if(!(this instanceof s))return new s(e);e=e||[128,36,1],this._seed=e.length?o.rack(e[0],e[1],e[2]):e}function a(e){return Array.prototype.concat.apply([],e)}s.prototype.next=function(e){return this._seed(e||!0)},s.prototype.nextPrefixed=function(e,t){var n;do{n=e+this.next(!0)}while(this.assigned(n));return this.claim(n,t),n},s.prototype.claim=function(e,t){this._seed.set(e,t||!0)},s.prototype.assigned=function(e){return this._seed.get(e)||!1},s.prototype.unclaim=function(e){delete this._seed.hats[e]},s.prototype.clear=function(){var e,t=this._seed.hats;for(e in t)this.unclaim(e)};const l=Object.prototype.toString,c=Object.prototype.hasOwnProperty;function p(e){return void 0===e}function u(e){return void 0!==e}function h(e){return null==e}function d(e){return"[object Array]"===l.call(e)}function f(e){return"[object Object]"===l.call(e)}function m(e){return"[object Number]"===l.call(e)}function g(e){const t=l.call(e);return"[object Function]"===t||"[object AsyncFunction]"===t||"[object GeneratorFunction]"===t||"[object AsyncGeneratorFunction]"===t||"[object Proxy]"===t}function y(e){return"[object String]"===l.call(e)}function v(e,t){return!h(e)&&c.call(e,t)}function b(e,t){const n=q(t);let i;return x(e,(function(e,t){if(n(e,t))return i=e,!1})),i}function O(e,t){const n=q(t);let i=d(e)?-1:void 0;return x(e,(function(e,t){if(n(e,t))return i=t,!1})),i}function w(e,t){const n=q(t);let i=[];return x(e,(function(e,t){n(e,t)&&i.push(e)})),i}function x(e,t){let n,i;if(p(e))return;const r=d(e)?j:z;for(let o in e)if(v(e,o)&&(n=e[o],i=t(n,r(o)),!1===i))return n}function P(e,t){if(p(e))return[];!function(e){if(!d(e))throw new Error("must supply array")}(e);const n=q(t);return e.filter((function(e,t){return!n(e,t)}))}function E(e,t,n){return x(e,(function(e,i){n=t(n,e,i)})),n}function _(e,t){return!!E(e,(function(e,n,i){return e&&t(n,i)}),!0)}function k(e,t){return!!b(e,t)}function S(e,t){let n=[];return x(e,(function(e,i){n.push(t(e,i))})),n}function T(e){return e&&Object.keys(e)||[]}function A(e){return S(e,(e=>e))}function C(e,t,n={}){return t=N(t),x(e,(function(e){let i=t(e)||"_",r=n[i];r||(r=n[i]=[]),r.push(e)})),n}function M(e,...t){e=N(e);let n={};return x(t,(t=>C(t,e,n))),S(n,(function(e,t){return e[0]}))}const D=M;function $(e,t){t=N(t);let n=[];return x(e,(function(e,i){let r=t(e,i),o={d:r,v:e};for(var s=0;s<n.length;s++){let{d:e}=n[s];if(r<e)return void n.splice(s,0,o)}n.push(o)})),S(n,(e=>e.v))}function R(e){return function(t){return _(e,(function(e,n){return t[n]===e}))}}function N(e){return g(e)?e:t=>t[e]}function q(e){return g(e)?e:t=>t===e}function z(e){return e}function j(e){return Number(e)}function I(e,t){let n,i,r,o;function s(n){let s=Date.now(),c=n?0:o+t-s;if(c>0)return a(c);e.apply(r,i),l()}function a(e){n=setTimeout(s,e)}function l(){n&&clearTimeout(n),n=o=i=r=void 0}function c(...e){o=Date.now(),i=e,r=this,n||a(t)}return c.flush=function(){n&&s(!0),l()},c.cancel=l,c}function L(e,t){return e.bind(t)}function B(e,...t){return Object.assign(e,...t)}function V(e,t,n){let i=e;return x(t,(function(e,r){if("number"!=typeof e&&"string"!=typeof e)throw new Error("illegal key type: "+typeof e+". Key should be of type number or string.");if("constructor"===e)throw new Error("illegal key: constructor");if("__proto__"===e)throw new Error("illegal key: __proto__");let o=t[r+1],s=i[e];u(o)&&h(s)&&(s=i[e]=isNaN(+o)?{}:[]),p(o)?p(n)?delete i[e]:i[e]=n:i=s})),e}function F(e,t){let n={},i=Object(e);return x(t,(function(t){t in i&&(n[t]=e[t])})),n}function Q(e,t){let n={};return x(Object(e),(function(e,i){-1===t.indexOf(i)&&(n[i]=e)})),n}const X={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]};function H(e,t=globalThis.document){if("string"!=typeof e)throw new TypeError("String expected");const n=/^<!--(.*?)-->$/s.exec(e);if(n)return t.createComment(n[1]);const i=/<([\w:]+)/.exec(e)?.[1];if(!i)return t.createTextNode(e);if(e=e.trim(),"body"===i){const n=t.createElement("html");n.innerHTML=e;const{lastChild:i}=n;return i.remove(),i}let[r,o,s]=Object.hasOwn(X,i)?X[i]:X._default,a=t.createElement("div");for(a.innerHTML=o+e+s;r--;)a=a.lastChild;if(a.firstChild===a.lastChild){const{firstChild:e}=a;return e.remove(),e}const l=t.createDocumentFragment();return l.append(...a.childNodes),l}function U(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}function W(e,...t){const n=e.style;return x(t,(function(e){e&&x(e,(function(e,t){n[t]=e}))})),e}function Y(e,t,n){return 2==arguments.length?e.getAttribute(t):null===n?e.removeAttribute(t):(e.setAttribute(t,n),e)}X.td=X.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],X.option=X.optgroup=[1,'<select multiple="multiple">',"</select>"],X.thead=X.tbody=X.colgroup=X.caption=X.tfoot=[1,"<table>","</table>"],X.polyline=X.ellipse=X.polygon=X.circle=X.text=X.line=X.path=X.rect=X.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];const G=Object.prototype.toString;function Z(e){return new K(e)}function K(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function J(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function ee(e,t,n){var i=n?e:e.parentNode;return i&&"function"==typeof i.closest&&i.closest(t)||null}function te(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}K.prototype.add=function(e){return this.list.add(e),this},K.prototype.remove=function(e){return"[object RegExp]"==G.call(e)?this.removeMatching(e):(this.list.remove(e),this)},K.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},K.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},K.prototype.array=function(){return Array.from(this.list)},K.prototype.has=K.prototype.contains=function(e){return this.list.contains(e)};var ne,ie={};var re=function(){if(ne)return ie;var e,t,n;function i(){e=window.addEventListener?"addEventListener":"attachEvent",t=window.removeEventListener?"removeEventListener":"detachEvent",n="addEventListener"!==e?"on":""}return ne=1,ie.bind=function(t,r,o,s){return e||i(),t[e](n+r,o,s||!1),o},ie.unbind=function(e,r,o,s){return t||i(),e[t](n+r,o,s||!1),o},ie}(),oe=U({__proto__:null,default:te(re)},[re]),se=["focus","blur"];var ae={bind:function(e,t,n,i,r){return-1!==se.indexOf(n)&&(r=!0),oe.bind(e,n,(function(n){var r=n.target||n.srcElement;n.delegateTarget=ee(r,t,!0),n.delegateTarget&&i.call(e,n)}),r)},unbind:function(e,t,n,i){return-1!==se.indexOf(t)&&(i=!0),oe.unbind(e,t,n,i)}};function le(e,t){return e&&"function"==typeof e.matches&&e.matches(t)||!1}function ce(e,t){return(t=t||document).querySelector(e)}function pe(e,t){return(t=t||document).querySelectorAll(e)}function ue(e){e.parentNode&&e.parentNode.removeChild(e)}function he(e,t){return function(e,t){t.appendChild(function(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch(e){}return e}(e,t))}(t,e),e}var de=2,fe={"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":de,"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":de,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function me(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=fe[i];r?(r===de&&"number"==typeof n&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function ge(e,t,n){return"string"==typeof t?function(e,t){return fe[t]?e.style[t]:e.getAttributeNS(null,t)}(e,t):(function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)me(e,i,t[i])}(e,t),e)}const ye=Object.prototype.toString;function ve(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}ve.prototype.add=function(e){return this.list.add(e),this},ve.prototype.remove=function(e){return"[object RegExp]"==ye.call(e)?this.removeMatching(e):(this.list.remove(e),this)},ve.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},ve.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},ve.prototype.array=function(){return Array.from(this.list)},ve.prototype.has=ve.prototype.contains=function(e){return this.list.contains(e)};var be={svg:"http://www.w3.org/2000/svg"},Oe='<svg xmlns="'+be.svg+'"';function we(e){var t=!1;"<svg"===e.substring(0,4)?-1===e.indexOf(be.svg)&&(e=Oe+e.substring(4)):(e=Oe+">"+e+"</svg>",t=!0);var n=function(e){var t;return t=new DOMParser,t.async=!1,t.parseFromString(e,"text/xml")}(e);if(!t)return n;for(var i=document.createDocumentFragment(),r=n.firstChild;r.firstChild;)i.appendChild(r.firstChild);return i}function xe(e,t){var n;return"<"===(e=e.trim()).charAt(0)?(n=we(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(be.svg,e),t&&ge(n,t),n}var Pe=/([&<>]{1})/g,Ee=/([&<>\n\r"]{1})/g,_e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"'"};function ke(e,t){return e.replace(t,(function(e,t){return _e[t]||t}))}function Se(e,t){var n,i,r,o,s;switch(e.nodeType){case 3:t.push(ke(e.textContent,Pe));break;case 1:if(t.push("<",e.tagName),e.hasAttributes())for(n=0,i=(r=e.attributes).length;n<i;++n)o=r.item(n),t.push(" ",o.name,'="',ke(o.value,Ee),'"');if(e.hasChildNodes()){for(t.push(">"),n=0,i=(s=e.childNodes).length;n<i;++n)Se(s.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("\x3c!--",ke(e.nodeValue,Pe),"--\x3e");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function Te(e,t){return function(e){for(var t=e.firstChild,n=[];t;)Se(t,n),t=t.nextSibling;return n.join("")}(e)}function Ae(e){var t=e.parentNode;return t&&t.removeChild(e),e}const Ce=/^class[ {]/;function Me(e){return Array.isArray(e)}function De(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function $e(...e){1===e.length&&Me(e[0])&&(e=e[0]);const t=(e=[...e]).pop();return t.$inject=e,t}const Re=/constructor\s*[^(]*\(\s*([^)]*)\)/m,Ne=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,qe=/\/\*([^*]*)\*\//m;function ze(e){if("function"!=typeof e)throw new Error(`Cannot annotate "${e}". Expected a function!`);const t=e.toString().match(function(e){return Ce.test(e.toString())}(e)?Re:Ne);if(!t)return[];const n=t[1]||t[2];return n&&n.split(",").map((e=>{const t=e.match(qe);return(t&&t[1]||e).trim()}))||[]}function je(e,t){const n=t||{get:function(e,t){if(i.push(e),!1===t)return null;throw a(`No provider for "${e}"!`)}},i=[],r=this._providers=Object.create(n._providers||null),o=this._instances=Object.create(null),s=o.injector=this,a=function(e){const t=i.join(" -> ");return i.length=0,new Error(t?`${e} (Resolving: ${t})`:e)};function l(e,t){if(!r[e]&&e.includes(".")){const t=e.split(".");let n=l(t.shift());for(;t.length;)n=n[t.shift()];return n}if(De(o,e))return o[e];if(De(r,e)){if(-1!==i.indexOf(e))throw i.push(e),a("Cannot resolve circular dependency!");return i.push(e),o[e]=r[e][0](r[e][1]),i.pop(),o[e]}return n.get(e,t)}function c(e,t){if(void 0===t&&(t={}),"function"!=typeof e){if(!Me(e))throw a(`Cannot invoke "${e}". Expected a function!`);e=$e(e.slice())}return{fn:e,dependencies:(e.$inject||ze(e)).map((e=>De(t,e)?t[e]:l(e)))}}function p(e){const{fn:t,dependencies:n}=c(e);return new(Function.prototype.bind.call(t,null,...n))}function u(e,t,n){const{fn:i,dependencies:r}=c(e,n);return i.apply(t,r)}function h(e){return $e((t=>e.get(t)))}function d(e,t){if(t&&t.length){const n=Object.create(null),i=Object.create(null),o=[],s=[],a=[];let l,c,p,u;for(let e in r)l=r[e],-1!==t.indexOf(e)&&("private"===l[2]?(c=o.indexOf(l[3]),-1===c?(p=l[3].createChild([],t),u=h(p),o.push(l[3]),s.push(p),a.push(u),n[e]=[u,e,"private",p]):n[e]=[a[c],e,"private",s[c]]):n[e]=[l[2],l[1]],i[e]=!0),"factory"!==l[2]&&"type"!==l[2]||!l[1].$scope||t.forEach((t=>{-1!==l[1].$scope.indexOf(t)&&(n[e]=[l[2],l[1]],i[t]=!0)}));t.forEach((e=>{if(!i[e])throw new Error('No provider for "'+e+'". Cannot use provider from the parent!')})),e.unshift(n)}return new je(e,s)}const f={factory:u,type:p,value:function(e){return e}};function m(e,t){const n=e.__init__||[];return function(){n.forEach((e=>{"string"==typeof e?t.get(e):t.invoke(e)}))}}function g(e){const t=e.__exports__;if(t){const n=e.__modules__,i=Object.keys(e).reduce(((t,n)=>("__exports__"!==n&&"__modules__"!==n&&"__init__"!==n&&"__depends__"!==n&&(t[n]=e[n]),t)),Object.create(null)),o=d((n||[]).concat(i)),s=$e((function(e){return o.get(e)}));t.forEach((function(e){r[e]=[s,e,"private",o]}));const a=(e.__init__||[]).slice();return a.unshift((function(){o.init()})),m(e=Object.assign({},e,{__init__:a}),o)}return Object.keys(e).forEach((function(t){if("__init__"===t||"__depends__"===t)return;const n=e[t];if("private"===n[2])return void(r[t]=n);const i=n[0],o=n[1];r[t]=[f[i],Ie(i,o),i]})),m(e,s)}function y(e,t){return-1!==e.indexOf(t)||-1!==(e=(t.__depends__||[]).reduce(y,e)).indexOf(t)?e:e.concat(t)}this.get=l,this.invoke=u,this.instantiate=p,this.createChild=d,this.init=function(e){const t=e.reduce(y,[]).map(g);let n=!1;return function(){n||(n=!0,t.forEach((e=>e())))}}(e)}function Ie(e,t){return"value"!==e&&Me(t)&&(t=$e(t.slice())),t}var Le=1e3;function Be(e,t){var n=this;t=t||Le,e.on(["render.shape","render.connection"],t,(function(e,t){var i=e.type,r=t.element,o=t.gfx,s=t.attrs;if(n.canRender(r))return"render.shape"===i?n.drawShape(o,r,s):n.drawConnection(o,r,s)})),e.on(["render.getShapePath","render.getConnectionPath"],t,(function(e,t){if(n.canRender(t))return"render.getShapePath"===e.type?n.getShapePath(t):n.getConnectionPath(t)}))}function Ve(e,t){return function(e,t){t.appendChild(function(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch(e){}return e}(e,t))}(t,e),e}Be.prototype.canRender=function(e){},Be.prototype.drawShape=function(e,t){},Be.prototype.drawConnection=function(e,t){},Be.prototype.getShapePath=function(e){},Be.prototype.getConnectionPath=function(e){};var Fe=2,Qe={"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":Fe,"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":Fe,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function Xe(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=Qe[i];r?(r===Fe&&"number"==typeof n&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function He(e,t,n){if("string"==typeof t){if(void 0===n)return function(e,t){return Qe[t]?e.style[t]:e.getAttributeNS(null,t)}(e,t);Xe(e,t,n)}else!function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)Xe(e,i,t[i])}(e,t);return e}const Ue=Object.prototype.toString;function We(e){return new Ye(e)}function Ye(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function Ge(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Ze(e){return e.cloneNode(!0)}Ye.prototype.add=function(e){return this.list.add(e),this},Ye.prototype.remove=function(e){return"[object RegExp]"==Ue.call(e)?this.removeMatching(e):(this.list.remove(e),this)},Ye.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Ye.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Ye.prototype.array=function(){return Array.from(this.list)},Ye.prototype.has=Ye.prototype.contains=function(e){return this.list.contains(e)};var Ke={svg:"http://www.w3.org/2000/svg"},Je='<svg xmlns="'+Ke.svg+'"';function et(e){var t=!1;"<svg"===e.substring(0,4)?-1===e.indexOf(Ke.svg)&&(e=Je+e.substring(4)):(e=Je+">"+e+"</svg>",t=!0);var n=function(e){var t;return t=new DOMParser,t.async=!1,t.parseFromString(e,"text/xml")}(e);if(!t)return n;for(var i=document.createDocumentFragment(),r=n.firstChild;r.firstChild;)i.appendChild(r.firstChild);return i}function tt(e,t){var n;return"<"===(e=e.trim()).charAt(0)?(n=et(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(Ke.svg,e),t&&He(n,t),n}var nt=null;function it(){return null===nt&&(nt=tt("svg")),nt}function rt(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)e[i]=t[i];return e}function ot(e){return it().createSVGTransform()}function st(e){var t=e.parentNode;return t&&t.removeChild(e),e}function at(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function lt(e,t){var n=e.transform.baseVal;return t&&(Array.isArray(t)||(t=[t]),function(e,t){var n,i;for(e.clear(),n=0;i=t[n];n++)e.appendItem(at(e,i))}(n,t)),n.consolidate()}function ct(e){return e.flat().join(",").replace(/,?([A-Za-z]),?/g,"$1")}function pt(e){return["L",e.x,e.y]}function ut(e,t){const n=e.length,i=[(r=e[0],["M",r.x,r.y])];var r,o,s,a;for(let r=1;r<n;r++){const n=e[r-1],l=e[r],c=e[r+1];if(!c||!t){i.push(pt(l));continue}const p=Math.min(t,dt(l.x-n.x,l.y-n.y),dt(c.x-l.x,c.y-l.y));if(!p){i.push(pt(l));continue}const u=ht(l,n,p),h=ht(l,n,.5*p),d=ht(l,c,p),f=ht(l,c,.5*p);i.push(pt(u)),i.push((s=f,a=d,["C",(o=h).x,o.y,s.x,s.y,a.x,a.y]))}return i}function ht(e,t,n){const i=t.x-e.x,r=t.y-e.y,o=n/dt(i,r);return{x:e.x+i*o,y:e.y+r*o}}function dt(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))}function ft(e,t,n){m(t)&&(n=t,t=null),t||(t={});const i=tt("path",t);return m(n)&&(i.dataset.cornerRadius=String(n)),mt(i,e)}function mt(e,t){return He(e,{d:ct(ut(t,parseInt(e.dataset.cornerRadius,10)||0))}),e}function gt(e){return w(e,(function(t){return!b(e,(function(e){return e!==t&&yt(t,e)}))}))}function yt(e,t){if(t){if(e===t)return t;if(e.parent)return yt(e.parent,t)}}function vt(e,t,n){var i=!n||-1===e.indexOf(t);return i&&e.push(t),i}function bt(e,t,n){n=n||0,d(e)||(e=[e]),x(e,(function(e,i){var r=t(e,i,n);d(r)&&r.length&&bt(r,t,n+1)}))}function Ot(e,t,n){var i=[],r=[];return bt(e,(function(e,n,o){vt(i,e,t);var s=e.children;if(s&&vt(r,s,t))return s})),i}function wt(e,t){return Ot(e,!t)}function xt(e,t){var n,i,r,o;return t=!!t,d(e)||(e=[e]),x(e,(function(e){var s=e;e.waypoints&&!t&&(s=xt(e.waypoints,!0));var a=s.x,l=s.y,c=s.height||0,p=s.width||0;(a<n||void 0===n)&&(n=a),(l<i||void 0===i)&&(i=l),(a+p>r||void 0===r)&&(r=a+p),(l+c>o||void 0===o)&&(o=l+c)})),{x:n,y:i,height:o-i,width:r-n}}function Pt(e,t){var n={};return x(e,(function(e){var i=e;i.waypoints&&(i=xt(i)),!m(t.y)&&i.x>t.x&&(n[e.id]=e),!m(t.x)&&i.y>t.y&&(n[e.id]=e),i.x>t.x&&i.y>t.y&&(m(t.width)&&m(t.height)&&i.width+i.x<t.width+t.x&&i.height+i.y<t.height+t.y?n[e.id]=e:m(t.width)&&m(t.height)||(n[e.id]=e))})),n}function Et(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}function _t(e){return!(!e||!e.isFrame)}function kt(e,t){return B({},e||{},t||{})}function St(e,t){Be.call(this,e,1),this.CONNECTION_STYLE=t.style(["no-fill"],{strokeWidth:5,stroke:"fuchsia"}),this.SHAPE_STYLE=t.style({fill:"white",stroke:"fuchsia",strokeWidth:2}),this.FRAME_STYLE=t.style(["no-fill"],{stroke:"fuchsia",strokeDasharray:4,strokeWidth:2})}e(St,Be),St.prototype.canRender=function(){return!0},St.prototype.drawShape=function(e,t,n){var i=tt("rect");return He(i,{x:0,y:0,width:t.width||0,height:t.height||0}),_t(t)?He(i,B({},this.FRAME_STYLE,n||{})):He(i,B({},this.SHAPE_STYLE,n||{})),Ve(e,i),i},St.prototype.drawConnection=function(e,t,n){var i=ft(t.waypoints,B({},this.CONNECTION_STYLE,n||{}));return Ve(e,i),i},St.prototype.getShapePath=function(e){var t=e.x,n=e.y,i=e.width;return ct([["M",t,n],["l",i,0],["l",0,e.height],["l",-i,0],["z"]])},St.prototype.getConnectionPath=function(e){var t,n,i=e.waypoints,r=[];for(t=0;n=i[t];t++)n=n.original||n,r.push([0===t?"M":"L",n.x,n.y]);return ct(r)},St.$inject=["eventBus","styles"];var Tt={__init__:["defaultRenderer"],defaultRenderer:["type",St],styles:["type",function(){var e={"no-fill":{fill:"none"},"no-border":{strokeOpacity:0},"no-events":{pointerEvents:"none"}},t=this;this.cls=function(e,t,n){return B(this.style(t,n),{class:e})},this.style=function(t,n){d(t)||n||(n=t,t=[]);var i=E(t,(function(t,n){return B(t,e[n]||{})}),{});return n?B(i,n):i},this.computeStyle=function(e,n,i){return d(n)||(i=n,n=[]),t.style(n||[],B({},i,e||{}))}}]};function At(e,t){if(!e||!t)return-1;var n=e.indexOf(t);return-1!==n&&e.splice(n,1),n}function Ct(e,t,n){if(e&&t){"number"!=typeof n&&(n=-1);var i=e.indexOf(t);if(-1!==i){if(i===n)return;if(-1===n)return;e.splice(i,1)}-1!==n?e.splice(n,0,t):e.push(t)}}function Mt(e,t){return e&&t?e.indexOf(t):-1}function Dt(e,t){return e&&t?Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)):-1}function $t(e,t,n,i){if(void 0===i&&(i=5),!e||!t||!n)return!1;var r=(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),o=Dt(e,t);return Math.abs(r/o)<=i}var Rt=2;function Nt(e,t){var n=Array.from(arguments).flat();const i={x:"v",y:"h"};for(const[e,t]of Object.entries(i))if(qt(e,n))return t;return!1}function qt(e,t){const n=t[0];return _(t,(function(t){return Math.abs(n[e]-t[e])<=Rt}))}function zt(e,t,n){return n=n||0,e.x>t.x-n&&e.y>t.y-n&&e.x<t.x+t.width+n&&e.y<t.y+t.height+n}function jt(e,t){return{x:Math.round(e.x+(t.x-e.x)/2),y:Math.round(e.y+(t.y-e.y)/2)}}var It=/,?([a-z]),?/gi,Lt=parseFloat,Bt=Math,Vt=Bt.PI,Ft=Bt.min,Qt=Bt.max,Xt=Bt.pow,Ht=Bt.abs,Ut=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?[\s]*,?[\s]*)+)/gi,Wt=/(-?\d*\.?\d*(?:e[-+]?\d+)?)[\s]*,?[\s]*/gi,Yt=Array.isArray||function(e){return e instanceof Array};function Gt(e){return function t(){var n,i,r=Array.prototype.slice.call(arguments,0).join("␀"),o=t.cache=t.cache||{},s=t.count=t.count||[];return n=o,i=r,Object.prototype.hasOwnProperty.call(n,i)?(function(e,t){for(var n=0,i=e.length;n<i;n++)if(e[n]===t)return e.push(e.splice(n,1)[0])}(s,r),o[r]):(s.length>=1e3&&delete o[s.shift()],s.push(r),o[r]=e(...arguments),o[r])}}function Zt(e){if(!e)return null;var t={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},n=[];return String(e).replace(Ut,(function(e,i,r){var o=[],s=i.toLowerCase();for(r.replace(Wt,(function(e,t){t&&o.push(+t)})),"m"==s&&o.length>2&&(n.push([i,...o.splice(0,2)]),s="l",i="m"==i?"l":"L");o.length>=t[s]&&(n.push([i,...o.splice(0,t[s])]),t[s]););})),n.toString=Jt,n}function Kt(e,t,n,i){return 1===arguments.length&&(t=e.y,n=e.width,i=e.height,e=e.x),{x:e,y:t,width:n,height:i,x2:e+n,y2:t+i}}function Jt(){return this.join(",").replace(It,"$1")}function en(e,t,n,i,r,o,s,a,l){var c=1-l,p=Xt(c,3),u=Xt(c,2),h=l*l*l,d=p*t+3*u*l*i+3*c*l*l*o+h*a;return{x:an(p*e+3*u*l*n+3*c*l*l*r+h*s),y:an(d)}}function tn(e){var t=function(e,t,n,i,r,o,s,a){for(var l,c,p,u,h,d,f,m,g=[],y=[[],[]],v=0;v<2;++v)if(0==v?(c=6*e-12*n+6*r,l=-3*e+9*n-9*r+3*s,p=3*n-3*e):(c=6*t-12*i+6*o,l=-3*t+9*i-9*o+3*a,p=3*i-3*t),Ht(l)<1e-12){if(Ht(c)<1e-12)continue;0<(u=-p/c)&&u<1&&g.push(u)}else f=c*c-4*p*l,m=Bt.sqrt(f),f<0||(0<(h=(-c+m)/(2*l))&&h<1&&g.push(h),0<(d=(-c-m)/(2*l))&&d<1&&g.push(d));var b,O=g.length,w=O;for(;O--;)b=1-(u=g[O]),y[0][O]=b*b*b*e+3*b*b*u*n+3*b*u*u*r+u*u*u*s,y[1][O]=b*b*b*t+3*b*b*u*i+3*b*u*u*o+u*u*u*a;return y[0][w]=e,y[1][w]=t,y[0][w+1]=s,y[1][w+1]=a,y[0].length=y[1].length=w+2,{x0:Ft(...y[0]),y0:Ft(...y[1]),x1:Qt(...y[0]),y1:Qt(...y[1])}}(...e);return Kt(t.x0,t.y0,t.x1-t.x0,t.y1-t.y0)}function nn(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function rn(e,t,n,i,r){return e*(e*(-3*t+9*n-9*i+3*r)+6*t-12*n+6*i)-3*t+3*n}function on(e,t,n,i,r,o,s,a,l){null==l&&(l=1);for(var c=(l=l>1?1:l<0?0:l)/2,p=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],u=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],h=0,d=0;d<12;d++){var f=c*p[d]+c,m=rn(f,e,n,r,s),g=rn(f,t,i,o,a),y=m*m+g*g;h+=u[d]*Bt.sqrt(y)}return c*h}function sn(e,t,n,i,r,o,s,a){if(!(Qt(e,n)<Ft(r,s)||Ft(e,n)>Qt(r,s)||Qt(t,i)<Ft(o,a)||Ft(t,i)>Qt(o,a))){var l=(e*i-t*n)*(o-a)-(t-i)*(r*a-o*s),c=(e-n)*(o-a)-(t-i)*(r-s);if(c){var p=an(((e*i-t*n)*(r-s)-(e-n)*(r*a-o*s))/c),u=an(l/c),h=+p.toFixed(2),d=+u.toFixed(2);if(!(h<+Ft(e,n).toFixed(2)||h>+Qt(e,n).toFixed(2)||h<+Ft(r,s).toFixed(2)||h>+Qt(r,s).toFixed(2)||d<+Ft(t,i).toFixed(2)||d>+Qt(t,i).toFixed(2)||d<+Ft(o,a).toFixed(2)||d>+Qt(o,a).toFixed(2)))return{x:p,y:u}}}}function an(e){return Math.round(1e11*e)/1e11}function ln(e,t,n){if(!function(e,t){return e=Kt(e),nn(t=Kt(t),e.x,e.y)||nn(t,e.x2,e.y)||nn(t,e.x,e.y2)||nn(t,e.x2,e.y2)||nn(e,t.x,t.y)||nn(e,t.x2,t.y)||nn(e,t.x,t.y2)||nn(e,t.x2,t.y2)||(e.x<t.x2&&e.x>t.x||t.x<e.x2&&t.x>e.x)&&(e.y<t.y2&&e.y>t.y||t.y<e.y2&&t.y>e.y)}(tn(e),tn(t)))return[];var i,r,o=on(...e),s=on(...t),a=pn(e)?1:~~(o/5)||1,l=pn(t)?1:~~(s/5)||1,c=new Array(a+1),p=new Array(l+1),u={},h=[];for(i=0;i<a+1;i++){var d=en(...e,i/a);c[i]={x:d.x,y:d.y,t:i/a}}for(i=0;i<l+1;i++)d=en(...t,i/l),p[i]={x:d.x,y:d.y,t:i/l};for(i=0;i<a;i++)for(r=0;r<l;r++){var f,m=c[i],g=c[i+1],y=p[r],v=p[r+1],b=Ht(g.x-m.x)<.01?"y":"x",O=Ht(v.x-y.x)<.01?"y":"x",w=sn(m.x,m.y,g.x,g.y,y.x,y.y,v.x,v.y);if(w){if(u[f=w.x.toFixed(9)+"#"+w.y.toFixed(9)])continue;u[f]=!0;var x=m.t+Ht((w[b]-m[b])/(g[b]-m[b]))*(g.t-m.t),P=y.t+Ht((w[O]-y[O])/(v[O]-y[O]))*(v.t-y.t);x>=0&&x<=1&&P>=0&&P<=1&&h.push({x:w.x,y:w.y,t1:x,t2:P})}}return h}function cn(e,t,n){e=fn(e),t=fn(t);for(var i,r,o,s,a,l,c,p,u,h,d=n?0:[],f=0,m=e.length;f<m;f++){var g=e[f];if("M"==g[0])i=a=g[1],r=l=g[2];else{"C"==g[0]?(i=(u=[i,r,...g.slice(1)])[6],r=u[7]):(u=[i,r,i,r,a,l,a,l],i=a,r=l);for(var y=0,v=t.length;y<v;y++){var b=t[y];if("M"==b[0])o=c=b[1],s=p=b[2];else{"C"==b[0]?(o=(h=[o,s,...b.slice(1)])[6],s=h[7]):(h=[o,s,o,s,c,p,c,p],o=c,s=p);for(var O=ln(u,h),w=0,x=O.length;w<x;w++)O[w].segment1=f,O[w].segment2=y,O[w].bez1=u,O[w].bez2=h;d=d.concat(O)}}}}return d}function pn(e){return e[0]===e[2]&&e[1]===e[3]&&e[4]===e[6]&&e[5]===e[7]}function un(e,t,n,i){return[e,t,n,i,n,i]}function hn(e,t,n,i,r,o){var s=1/3,a=2/3;return[s*e+a*n,s*t+a*i,s*r+a*n,s*o+a*i,r,o]}function dn(e,t,n,i,r,o,s,a,l,c){var p,u=120*Vt/180,h=Vt/180*(+r||0),d=[],f=Gt((function(e,t,n){return{x:e*Bt.cos(n)-t*Bt.sin(n),y:e*Bt.sin(n)+t*Bt.cos(n)}}));if(c)P=c[0],E=c[1],w=c[2],x=c[3];else{e=(p=f(e,t,-h)).x,t=p.y;var m=(e-(a=(p=f(a,l,-h)).x))/2,g=(t-(l=p.y))/2,y=m*m/(n*n)+g*g/(i*i);y>1&&(n*=y=Bt.sqrt(y),i*=y);var v=n*n,b=i*i,O=(o==s?-1:1)*Bt.sqrt(Ht((v*b-v*g*g-b*m*m)/(v*g*g+b*m*m))),w=O*n*g/i+(e+a)/2,x=O*-i*m/n+(t+l)/2,P=Bt.asin(((t-x)/i).toFixed(9)),E=Bt.asin(((l-x)/i).toFixed(9));(P=e<w?Vt-P:P)<0&&(P=2*Vt+P),(E=a<w?Vt-E:E)<0&&(E=2*Vt+E),s&&P>E&&(P-=2*Vt),!s&&E>P&&(E-=2*Vt)}var _=E-P;if(Ht(_)>u){var k=E,S=a,T=l;E=P+u*(s&&E>P?1:-1),d=dn(a=w+n*Bt.cos(E),l=x+i*Bt.sin(E),n,i,r,0,s,S,T,[E,k,w,x])}_=E-P;var A=Bt.cos(P),C=Bt.sin(P),M=Bt.cos(E),D=Bt.sin(E),$=Bt.tan(_/4),R=4/3*n*$,N=4/3*i*$,q=[e,t],z=[e+R*C,t-N*A],j=[a+R*D,l-N*M],I=[a,l];if(z[0]=2*q[0]-z[0],z[1]=2*q[1]-z[1],c)return[z,j,I].concat(d);for(var L=[],B=0,V=(d=[z,j,I].concat(d).join().split(",")).length;B<V;B++)L[B]=B%2?f(d[B-1],d[B],h).y:f(d[B],d[B+1],h).x;return L}function fn(e){if(function(e){return Yt(e)&&Yt(e[0])}(e)||(e=Zt(e)),function(e){for(var t=0,n=e.length;t<n;t++){var i=e[t][0];if("M"!==i&&"C"!==i)return!1}return!0}(e))return e;for(var t=function(e){for(var t=new Array(e.length),n=0,i=e.length;n<i;n++)for(var r=e[n],o=t[n]=new Array(r.length),s=0,a=r.length;s<a;s++)o[s]=r[s];return t.toString=Jt,t}(function(e){if(function(e){for(var t=0,n=e.length;t<n;t++){var i=e[t][0];if("string"==typeof i&&i!==i.toUpperCase())return!1}return!0}(e))return e;var t,n=new Array(e.length),i=0,r=0,o=0,s=0,a=0;"M"==e[0][0]&&(o=i=+e[0][1],s=r=+e[0][2],a++,n[0]=["M",i,r]);for(var l,c,p=a,u=e.length;p<u;p++){if(t=(c=e[p])[0],n[p]=l=new Array(c.length),t!=t.toUpperCase())switch(l[0]=t.toUpperCase(),l[0]){case"A":l[1]=c[1],l[2]=c[2],l[3]=c[3],l[4]=c[4],l[5]=c[5],l[6]=+c[6]+i,l[7]=+c[7]+r;break;case"V":l[1]=+c[1]+r;break;case"H":l[1]=+c[1]+i;break;case"M":o=+c[1]+i,s=+c[2]+r;default:for(var h=1,d=c.length;h<d;h++)l[h]=+c[h]+(h%2?i:r)}else for(var f=0,m=c.length;f<m;f++)l[f]=c[f];switch(t=t.toUpperCase(),l[0]){case"Z":i=+o,r=+s;break;case"H":i=l[1];break;case"V":r=l[1];break;case"M":o=l[l.length-2],s=l[l.length-1];default:i=l[l.length-2],r=l[l.length-1]}}return n.toString=Jt,n}(e)),n={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i=function(e,t,n){var i,r;if(!e)return["C",t.x,t.y,t.x,t.y,t.x,t.y];switch(!(e[0]in{T:1,Q:1})&&(t.qx=t.qy=null),e[0]){case"M":t.X=e[1],t.Y=e[2];break;case"A":e=["C",...dn(t.x,t.y,...e.slice(1))];break;case"S":"C"==n||"S"==n?(i=2*t.x-t.bx,r=2*t.y-t.by):(i=t.x,r=t.y),e=["C",i,r,...e.slice(1)];break;case"T":"Q"==n||"T"==n?(t.qx=2*t.x-t.qx,t.qy=2*t.y-t.qy):(t.qx=t.x,t.qy=t.y),e=["C",...hn(t.x,t.y,t.qx,t.qy,e[1],e[2])];break;case"Q":t.qx=e[1],t.qy=e[2],e=["C",...hn(t.x,t.y,e[1],e[2],e[3],e[4])];break;case"L":e=["C",...un(t.x,t.y,e[1],e[2])];break;case"H":e=["C",...un(t.x,t.y,e[1],t.y)];break;case"V":e=["C",...un(t.x,t.y,t.x,e[1])];break;case"Z":e=["C",...un(t.x,t.y,t.X,t.Y)]}return e},r=function(e,n){if(e[n].length>7){e[n].shift();for(var i=e[n];i.length;)o[n]="A",e.splice(n++,0,["C",...i.splice(0,6)]);e.splice(n,1),c=t.length}},o=[],s="",a="",l=0,c=t.length;l<c;l++){t[l]&&(s=t[l][0]),"C"!=s&&(o[l]=s,l&&(a=o[l-1])),t[l]=i(t[l],n,a),"A"!=o[l]&&"C"==s&&(o[l]="C"),r(t,l);var p=t[l],u=p.length;n.x=p[u-2],n.y=p[u-1],n.bx=Lt(p[u-4])||n.x,n.by=Lt(p[u-3])||n.y}return t}function mn(e){return f(e)&&v(e,"waypoints")}function gn(e){return f(e)&&v(e,"labelTarget")}function yn(e){return{x:Math.round(e.x),y:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height)}}function vn(e){return{x:Math.round(e.x),y:Math.round(e.y)}}function bn(e){return{top:e.y,right:e.x+(e.width||0),bottom:e.y+(e.height||0),left:e.x}}function On(e){return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}function wn(e){for(var t=e.waypoints,n=t.reduce((function(e,n,i){var r=t[i-1];if(r){var o=e[e.length-1],s=o&&o.endLength||0,a=function(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}(r,n);e.push({start:r,end:n,startLength:s,endLength:s+a,length:a})}return e}),[]),i=n.reduce((function(e,t){return e+t.length}),0),r=i/2,o=0,s=n[o];s.endLength<r;)s=n[++o];var a=(r-s.startLength)/s.length;return{x:s.start.x+(s.end.x-s.start.x)*a,y:s.start.y+(s.end.y-s.start.y)*a}}function xn(e){return mn(e)?wn(e):vn({x:(t=e).x+(t.width||0)/2,y:t.y+(t.height||0)/2});var t}function Pn(e,t,n){f(n=n||0)||(n={x:n,y:n});var i=bn(e),r=bn(t),o=i.bottom+n.y<=r.top,s=i.left-n.x>=r.right,a=i.top-n.y>=r.bottom,l=o?"top":a?"bottom":null,c=i.right+n.x<=r.left?"left":s?"right":null;return c&&l?l+"-"+c:c||l||"intersect"}function En(e,t,n){var i=function(e,t){return cn(e,t)}(e,t);return 1===i.length||2===i.length&&Dt(i[0],i[1])<1?vn(i[0]):i.length>1?(i=$(i,(function(e){var t=Math.floor(100*e.t2)||1;return t=((t=100-t)<10?"0":"")+t,e.segment2+"#"+t})),vn(i[n?0:i.length-1])):null}function _n(e,t){return Math.round(e*t)/t}function kn(e){return m(e)?e+"px":e}function Sn(e,t,n){const i=tt("g");We(i).add(t);const r=void 0!==n?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[r]||null),i}const Tn={shape:["x","y","width","height"],connection:["waypoints"]};function An(e,t,n,i){this._eventBus=t,this._elementRegistry=i,this._graphicsFactory=n,this._rootsIdx=0,this._layers={},this._planes=[],this._rootElement=null,this._focused=!1,this._init(e||{})}function Cn(e,t){const n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}An.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],An.prototype._init=function(e){const t=this._eventBus,n=this._container=function(e){const t=(e=B({},{width:"100%",height:"100%"},e)).container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container djs-parent"),W(n,{position:"relative",overflow:"hidden",width:kn(e.width),height:kn(e.height)}),t.appendChild(n),n}(e),i=this._svg=tt("svg");He(i,{width:"100%",height:"100%"}),Y(i,"tabindex",0),e.autoFocus&&t.on("element.hover",(()=>{this.restoreFocus()})),t.on("element.mousedown",500,(e=>{this.focus()})),i.addEventListener("focusin",(()=>{this._setFocused(!0)})),i.addEventListener("focusout",(()=>{this._setFocused(!1)})),i.addEventListener("mouseover",(()=>{this._eventBus.fire("canvas.mouseover")})),i.addEventListener("mouseout",(()=>{this._eventBus.fire("canvas.mouseout")})),Ve(n,i);const r=this._viewport=Sn(i,"viewport");e.deferUpdate&&(this._viewboxChanged=I(L(this._viewboxChanged,this),300)),t.on("diagram.init",(()=>{t.fire("canvas.init",{svg:i,viewport:r})})),t.on(["shape.added","connection.added","shape.removed","connection.removed","elements.changed","root.set"],(()=>{delete this._cachedViewbox})),t.on("diagram.destroy",500,this._destroy,this),t.on("diagram.clear",500,this._clear,this)},An.prototype._destroy=function(){this._eventBus.fire("canvas.destroy",{svg:this._svg,viewport:this._viewport});const e=this._container.parentNode;e&&e.removeChild(this._container),delete this._svg,delete this._container,delete this._layers,delete this._planes,delete this._rootElement,delete this._viewport},An.prototype._setFocused=function(e){e!=this._focused&&(this._focused=e,this._eventBus.fire("canvas.focus.changed",{focused:e}))},An.prototype._clear=function(){this._elementRegistry.getAll().forEach((e=>{const t=Et(e);"root"===t?this.removeRootElement(e):this._removeElement(e,t)})),this._planes=[],this._rootElement=null,delete this._cachedViewbox},An.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)},An.prototype.restoreFocus=function(){document.activeElement===document.body&&this.focus()},An.prototype.isFocused=function(){return this._focused},An.prototype.getDefaultLayer=function(){return this.getLayer("base",0)},An.prototype.getLayer=function(e,t){if(!e)throw new Error("must specify a name");let n=this._layers[e];if(n||(n=this._layers[e]=this._createLayer(e,t)),void 0!==t&&n.index!==t)throw new Error("layer <"+e+"> already created at index <"+t+">");return n.group},An.prototype._getChildIndex=function(e){return E(this._layers,(function(t,n){return n.visible&&e>=n.index&&t++,t}),0)},An.prototype._createLayer=function(e,t){void 0===t&&(t=1);const n=this._getChildIndex(t);return{group:Sn(this._viewport,"layer-"+e,n),index:t,visible:!0}},An.prototype.showLayer=function(e){if(!e)throw new Error("must specify a name");const t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");const n=this._viewport,i=t.group,r=t.index;if(t.visible)return i;const o=this._getChildIndex(r);return n.insertBefore(i,n.childNodes[o]||null),t.visible=!0,i},An.prototype.hideLayer=function(e){if(!e)throw new Error("must specify a name");const t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");const n=t.group;return t.visible?(st(n),t.visible=!1,n):n},An.prototype._removeLayer=function(e){const t=this._layers[e];t&&(delete this._layers[e],st(t.group))},An.prototype.getActiveLayer=function(){const e=this._findPlaneForRoot(this.getRootElement());return e?e.layer:null},An.prototype.findRoot=function(e){if("string"==typeof e&&(e=this._elementRegistry.get(e)),!e)return;const t=this._findPlaneForRoot(function(e){for(;e.parent;)e=e.parent;return e}(e))||{};return t.rootElement},An.prototype.getRootElements=function(){return this._planes.map((function(e){return e.rootElement}))},An.prototype._findPlaneForRoot=function(e){return b(this._planes,(function(t){return t.rootElement===e}))},An.prototype.getContainer=function(){return this._container},An.prototype._updateMarker=function(e,t,n){let i;e.id||(e=this._elementRegistry.get(e)),e.markers=e.markers||new Set,i=this._elementRegistry._elements[e.id],i&&(x([i.gfx,i.secondaryGfx],(function(i){i&&(n?(e.markers.add(t),We(i).add(t)):(e.markers.delete(t),We(i).remove(t)))})),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},An.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},An.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},An.prototype.hasMarker=function(e,t){return e.id||(e=this._elementRegistry.get(e)),!!e.markers&&e.markers.has(t)},An.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},An.prototype.getRootElement=function(){const e=this._rootElement;return e||this._planes.length?e:this.setRootElement(this.addRootElement(null))},An.prototype.addRootElement=function(e){const t=this._rootsIdx++;e||(e={id:"__implicitroot_"+t,children:[],isImplicit:!0});const n=e.layer="root-"+t;this._ensureValid("root",e);const i=this.getLayer(n,0);return this.hideLayer(n),this._addRoot(e,i),this._planes.push({rootElement:e,layer:i}),e},An.prototype.removeRootElement=function(e){"string"==typeof e&&(e=this._elementRegistry.get(e));if(this._findPlaneForRoot(e))return this._removeRoot(e),this._removeLayer(e.layer),this._planes=this._planes.filter((function(t){return t.rootElement!==e})),this._rootElement===e&&(this._rootElement=null),e},An.prototype.setRootElement=function(e){if(e===this._rootElement)return e;let t;if(!e)throw new Error("rootElement required");return t=this._findPlaneForRoot(e),t||(e=this.addRootElement(e)),this._setRoot(e),e},An.prototype._removeRoot=function(e){const t=this._elementRegistry,n=this._eventBus;n.fire("root.remove",{element:e}),n.fire("root.removed",{element:e}),t.remove(e)},An.prototype._addRoot=function(e,t){const n=this._elementRegistry,i=this._eventBus;i.fire("root.add",{element:e}),n.add(e,t),i.fire("root.added",{element:e,gfx:t})},An.prototype._setRoot=function(e,t){const n=this._rootElement;n&&(this._elementRegistry.updateGraphics(n,null,!0),this.hideLayer(n.layer)),e&&(t||(t=this._findPlaneForRoot(e).layer),this._elementRegistry.updateGraphics(e,this._svg,!0),this.showLayer(e.layer)),this._rootElement=e,this._eventBus.fire("root.set",{element:e})},An.prototype._ensureValid=function(e,t){if(!t.id)throw new Error("element must have an id");if(this._elementRegistry.get(t.id))throw new Error("element <"+t.id+"> already exists");const n=Tn[e],i=_(n,(function(e){return void 0!==t[e]}));if(!i)throw new Error("must supply { "+n.join(", ")+" } with "+e)},An.prototype._setParent=function(e,t,n){Ct(t.children,e,n),e.parent=t},An.prototype._addElement=function(e,t,n,i){n=n||this.getRootElement();const r=this._eventBus,o=this._graphicsFactory;this._ensureValid(e,t),r.fire(e+".add",{element:t,parent:n}),this._setParent(t,n,i);const s=o.create(e,t,i);return this._elementRegistry.add(t,s),o.update(e,t,s),r.fire(e+".added",{element:t,gfx:s}),t},An.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},An.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},An.prototype._removeElement=function(e,t){const n=this._elementRegistry,i=this._graphicsFactory,r=this._eventBus;if(e=n.get(e.id||e))return r.fire(t+".remove",{element:e}),i.remove(e),At(e.parent&&e.parent.children,e),e.parent=null,r.fire(t+".removed",{element:e}),n.remove(e),e},An.prototype.removeShape=function(e){return this._removeElement(e,"shape")},An.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},An.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},An.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},An.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},An.prototype.viewbox=function(e){if(void 0===e&&this._cachedViewbox)return structuredClone(this._cachedViewbox);const t=this._viewport,n=this.getSize();let i,r,o,s,a,l,c;return e?(this._changeViewbox((function(){a=Math.min(n.width/e.width,n.height/e.height);const i=this._svg.createSVGMatrix().scale(a).translate(-e.x,-e.y);lt(t,i)})),e):(o=this._rootElement?this.getActiveLayer():null,i=o&&o.getBBox()||{},s=lt(t),r=s?s.matrix:function(e,t,n,i,r,o){var s=it().createSVGMatrix();switch(arguments.length){case 0:return s;case 1:return rt(s,e);case 6:return rt(s,{a:e,b:t,c:n,d:i,e:r,f:o})}}(),a=_n(r.a,1e3),l=_n(-r.e||0,1e3),c=_n(-r.f||0,1e3),e=this._cachedViewbox={x:l?l/a:0,y:c?c/a:0,width:n.width/a,height:n.height/a,scale:a,inner:{width:i.width||0,height:i.height||0,x:i.x||0,y:i.y||0},outer:n})},An.prototype.scroll=function(e){const t=this._viewport;let n=t.getCTM();return e&&this._changeViewbox((function(){e=B({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),Cn(t,n)})),{x:n.e,y:n.f}},An.prototype.scrollToElement=function(e,t){let n=100;"string"==typeof e&&(e=this._elementRegistry.get(e));const i=this.findRoot(e);if(i!==this.getRootElement()&&this.setRootElement(i),i===e)return;t||(t={}),"number"==typeof t&&(n=t),t={top:t.top||n,right:t.right||n,bottom:t.bottom||n,left:t.left||n};const r=xt(e),o=bn(r),s=this.viewbox(),a=this.zoom();let l,c;s.y+=t.top/a,s.x+=t.left/a,s.width-=(t.right+t.left)/a,s.height-=(t.bottom+t.top)/a;const p=bn(s);if(r.width<s.width&&r.height<s.height){const e=Math.max(0,o.right-p.right),t=Math.min(0,o.left-p.left),n=Math.max(0,o.bottom-p.bottom),i=Math.min(0,o.top-p.top);l=e||t,c=n||i}else l=r.x-s.x,c=r.y-s.y;this.scroll({dx:-l*a,dy:-c*a})},An.prototype.zoom=function(e,t){if(!e)return this.viewbox(e).scale;if("fit-viewport"===e)return this._fitViewport(t);let n,i;return this._changeViewbox((function(){"object"!=typeof t&&(n=this.viewbox().outer,t={x:n.width/2,y:n.height/2}),i=this._setZoom(e,t)})),_n(i.a,1e3)},An.prototype._fitViewport=function(e){const t=this.viewbox(),n=t.outer,i=t.inner;let r,o;return i.x>=0&&i.y>=0&&i.x+i.width<=n.width&&i.y+i.height<=n.height&&!e?o={x:0,y:0,width:Math.max(i.width+i.x,n.width),height:Math.max(i.height+i.y,n.height)}:(r=Math.min(1,n.width/i.width,n.height/i.height),o={x:i.x+(e?i.width/2-n.width/r/2:0),y:i.y+(e?i.height/2-n.height/r/2:0),width:n.width/r,height:n.height/r}),this.viewbox(o),this.viewbox(!1).scale},An.prototype._setZoom=function(e,t){const n=this._svg,i=this._viewport,r=n.createSVGMatrix(),o=n.createSVGPoint();let s,a,l,c,p;l=i.getCTM();const u=l.a;return t?(s=B(o,t),a=s.matrixTransform(l.inverse()),c=r.translate(a.x,a.y).scale(1/u*e).translate(-a.x,-a.y),p=l.multiply(c)):p=r.scale(e),Cn(this._viewport,p),p},An.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},An.prototype.getAbsoluteBBox=function(e){const t=this.viewbox();let n;if(e.waypoints){n=this.getGraphics(e).getBBox()}else n=e;return{x:n.x*t.scale-t.x*t.scale,y:n.y*t.scale-t.y*t.scale,width:n.width*t.scale,height:n.height*t.scale}},An.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var Mn="data-element-id";function Dn(e){this._elements={},this._eventBus=e}function $n(e,t,n){var i=function(e,t,n,i){var r=n.inverse;return Object.defineProperty(e,"remove",{value:function(e){var n=this.indexOf(e);return-1!==n&&(this.splice(n,1),t.unset(e,r,i)),e}}),Object.defineProperty(e,"contains",{value:function(e){return-1!==this.indexOf(e)}}),Object.defineProperty(e,"add",{value:function(e,n){var o=this.indexOf(e);if(void 0===n){if(-1!==o)return;n=this.length}-1!==o&&this.splice(o,1),this.splice(n,0,e),-1===o&&t.set(e,r,i)}}),Object.defineProperty(e,"__refs_collection",{value:!0}),e}(n[t.name]||[],e,t,n);Object.defineProperty(n,t.name,{enumerable:t.enumerable,value:i}),i.length&&i.forEach((function(i){e.set(i,t.inverse,n)}))}function Rn(e,t){if(!(this instanceof Rn))return new Rn(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}Dn.$inject=["eventBus"],Dn.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),He(t,Mn,i),n&&He(n,Mn,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},Dn.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(He(i.gfx,Mn,""),i.secondaryGfx&&He(i.secondaryGfx,Mn,""),delete t[n])},Dn.prototype.updateId=function(e,t){this._validateId(t),"string"==typeof e&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t});var n=this.getGraphics(e),i=this.getGraphics(e,!0);this.remove(e),e.id=t,this.add(e,n,i)},Dn.prototype.updateGraphics=function(e,t,n){var i=e.id||e,r=this._elements[i];return n?r.secondaryGfx=t:r.gfx=t,t&&He(t,Mn,i),t},Dn.prototype.get=function(e){var t;t="string"==typeof e?e:e&&He(e,Mn);var n=this._elements[t];return n&&n.element},Dn.prototype.filter=function(e){var t=[];return this.forEach((function(n,i){e(n,i)&&t.push(n)})),t},Dn.prototype.find=function(e){for(var t=this._elements,n=Object.keys(t),i=0;i<n.length;i++){var r=t[n[i]],o=r.element;if(e(o,r.gfx))return o}},Dn.prototype.getAll=function(){return this.filter((function(e){return e}))},Dn.prototype.forEach=function(e){var t=this._elements;Object.keys(t).forEach((function(n){var i=t[n],r=i.element,o=i.gfx;return e(r,o)}))},Dn.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},Dn.prototype._validateId=function(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")},Rn.prototype.bind=function(e,t){if("string"==typeof t){if(!this.props[t])throw new Error("no property <"+t+"> in ref");t=this.props[t]}t.collection?$n(this,t,e):function(e,t,n){var i=t.inverse,r=n[t.name];Object.defineProperty(n,t.name,{configurable:t.configurable,enumerable:t.enumerable,get:function(){return r},set:function(t){if(t!==r){var o=r;r=null,o&&e.unset(o,i,n),r=t,e.set(r,i,n)}}})}(this,t,e)},Rn.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return function(e){return!0===e.__refs_collection}(n)||$n(this,t,e),n},Rn.prototype.ensureBound=function(e,t){(function(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)})(e,t)||this.bind(e,t)},Rn.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},Rn.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var Nn=new Rn({name:"children",enumerable:!0,collection:!0},{name:"parent"}),qn=new Rn({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),zn=new Rn({name:"attachers",collection:!0},{name:"host"}),jn=new Rn({name:"outgoing",collection:!0},{name:"source"}),In=new Rn({name:"incoming",collection:!0},{name:"target"});function Ln(){Object.defineProperty(this,"businessObject",{writable:!0}),Object.defineProperty(this,"label",{get:function(){return this.labels[0]},set:function(e){var t=this.label,n=this.labels;!e&&t?n.remove(t):n.add(e,0)}}),Nn.bind(this,"parent"),qn.bind(this,"labels"),jn.bind(this,"outgoing"),In.bind(this,"incoming")}function Bn(){Ln.call(this),Nn.bind(this,"children"),zn.bind(this,"host"),zn.bind(this,"attachers")}function Vn(){Ln.call(this),Nn.bind(this,"children")}function Fn(){Bn.call(this),qn.bind(this,"labelTarget")}function Qn(){Ln.call(this),jn.bind(this,"source"),In.bind(this,"target")}e(Bn,Ln),e(Vn,Bn),e