camunda-bpmn-js
Version:
Embeddable Camunda modeling distributions based on bpmn-js
1 lines • 1.55 MB
JavaScript
!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 h(e){return void 0===e}function u(e){return void 0!==e}function p(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 v(e){return"[object String]"===l.call(e)}function y(e,t){return!p(e)&&c.call(e,t)}function b(e,t){const n=L(t);let i;return _(e,(function(e,t){if(n(e,t))return i=e,!1})),i}function x(e,t){const n=L(t);let i=d(e)?-1:void 0;return _(e,(function(e,t){if(n(e,t))return i=t,!1})),i}function w(e,t){const n=L(t);let i=[];return _(e,(function(e,t){n(e,t)&&i.push(e)})),i}function _(e,t){let n,i;if(h(e))return;const r=d(e)?z:I;for(let o in e)if(y(e,o)&&(n=e[o],i=t(n,r(o)),!1===i))return n}function E(e,t){if(h(e))return[];!function(e){if(!d(e))throw new Error("must supply array")}(e);const n=L(t);return e.filter((function(e,t){return!n(e,t)}))}function k(e,t,n){return _(e,(function(e,i){n=t(n,e,i)})),n}function S(e,t){return!!k(e,(function(e,n,i){return e&&t(n,i)}),!0)}function O(e,t){return!!b(e,t)}function C(e,t){let n=[];return _(e,(function(e,i){n.push(t(e,i))})),n}function A(e){return e&&Object.keys(e)||[]}function P(e){return C(e,(e=>e))}function T(e,t,n={}){return t=N(t),_(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 _(t,(t=>T(t,e,n))),C(n,(function(e,t){return e[0]}))}const R=M;function D(e,t){t=N(t);let n=[];return _(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)})),C(n,(e=>e.v))}function B(e){return function(t){return S(e,(function(e,n){return t[n]===e}))}}function N(e){return g(e)?e:t=>t[e]}function L(e){return g(e)?e:t=>t===e}function I(e){return e}function z(e){return Number(e)}function $(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 j(e,t){return e.bind(t)}function F(e,...t){return Object.assign(e,...t)}function V(e,t,n){let i=e;return _(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)&&p(s)&&(s=i[e]=isNaN(+o)?{}:[]),h(o)?h(n)?delete i[e]:i[e]=n:i=s})),e}function q(e,t){let n={},i=Object(e);return _(t,(function(t){t in i&&(n[t]=e[t])})),n}function H(e,t){let n={};return _(Object(e),(function(e,i){-1===t.indexOf(i)&&(n[i]=e)})),n}const W={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]};function Q(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(W,i)?W[i]:W._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 X(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 G(e,...t){const n=e.style;return _(t,(function(e){e&&_(e,(function(e,t){n[t]=e}))})),e}function U(e,t,n){return 2==arguments.length?e.getAttribute(t):null===n?e.removeAttribute(t):(e.setAttribute(t,n),e)}W.td=W.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],W.option=W.optgroup=[1,'<select multiple="multiple">',"</select>"],W.thead=W.tbody=W.colgroup=W.caption=W.tfoot=[1,"<table>","</table>"],W.polyline=W.ellipse=W.polygon=W.circle=W.text=W.line=W.path=W.rect=W.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];const Y=Object.prototype.toString;function K(e){return new Z(e)}function Z(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function 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}Z.prototype.add=function(e){return this.list.add(e),this},Z.prototype.remove=function(e){return"[object RegExp]"==Y.call(e)?this.removeMatching(e):(this.list.remove(e),this)},Z.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Z.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Z.prototype.array=function(){return Array.from(this.list)},Z.prototype.has=Z.prototype.contains=function(e){return this.list.contains(e)};var 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=X({__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 he(e,t){return(t=t||document).querySelectorAll(e)}function ue(e){e.parentNode&&e.parentNode.removeChild(e)}function pe(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 ve=Object.prototype.toString;function ye(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}ye.prototype.add=function(e){return this.list.add(e),this},ye.prototype.remove=function(e){return"[object RegExp]"==ve.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 be={svg:"http://www.w3.org/2000/svg"},xe='<svg xmlns="'+be.svg+'"';function we(e){var t=!1;"<svg"===e.substring(0,4)?-1===e.indexOf(be.svg)&&(e=xe+e.substring(4)):(e=xe+">"+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 _e(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 Ee=/([&<>]{1})/g,ke=/([&<>\n\r"]{1})/g,Se={"&":"&","<":"<",">":">",'"':"'"};function Oe(e,t){return e.replace(t,(function(e,t){return Se[t]||t}))}function Ce(e,t){var n,i,r,o,s;switch(e.nodeType){case 3:t.push(Oe(e.textContent,Ee));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,'="',Oe(o.value,ke),'"');if(e.hasChildNodes()){for(t.push(">"),n=0,i=(s=e.childNodes).length;n<i;++n)Ce(s.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("\x3c!--",Oe(e.nodeValue,Ee),"--\x3e");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function Ae(e,t){return function(e){for(var t=e.firstChild,n=[];t;)Ce(t,n),t=t.nextSibling;return n.join("")}(e)}function Pe(e){var t=e.parentNode;return t&&t.removeChild(e),e}const Te=/^class[ {]/;function Me(e){return Array.isArray(e)}function Re(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function De(...e){1===e.length&&Me(e[0])&&(e=e[0]);const t=(e=[...e]).pop();return t.$inject=e,t}const Be=/constructor\s*[^(]*\(\s*([^)]*)\)/m,Ne=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,Le=/\/\*([^*]*)\*\//m;function Ie(e){if("function"!=typeof e)throw new Error(`Cannot annotate "${e}". Expected a function!`);const t=e.toString().match(function(e){return Te.test(e.toString())}(e)?Be:Ne);if(!t)return[];const n=t[1]||t[2];return n&&n.split(",").map((e=>{const t=e.match(Le);return(t&&t[1]||e).trim()}))||[]}function ze(e,t){const n=t||{get:function(e,t){if(i.push(e),!1===t)return null;throw 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(Re(o,e))return o[e];if(Re(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=De(e.slice())}return{fn:e,dependencies:(e.$inject||Ie(e)).map((e=>Re(t,e)?t[e]:l(e)))}}function h(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 p(e){return De((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,h,u;for(let e in r)l=r[e],-1!==t.indexOf(e)&&("private"===l[2]?(c=o.indexOf(l[3]),-1===c?(h=l[3].createChild([],t),u=p(h),o.push(l[3]),s.push(h),a.push(u),n[e]=[u,e,"private",h]):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 ze(e,s)}const f={factory:u,type:h,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=De((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],$e(i,o),i]})),m(e,s)}function v(e,t){return-1!==e.indexOf(t)||-1!==(e=(t.__depends__||[]).reduce(v,e)).indexOf(t)?e:e.concat(t)}this.get=l,this.invoke=u,this.instantiate=h,this.createChild=d,this.init=function(e){const t=e.reduce(v,[]).map(g);let n=!1;return function(){n||(n=!0,t.forEach((e=>e())))}}(e)}function $e(e,t){return"value"!==e&&Me(t)&&(t=De(t.slice())),t}var je=1e3;function Fe(e,t){var n=this;t=t||je,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}Fe.prototype.canRender=function(e){},Fe.prototype.drawShape=function(e,t){},Fe.prototype.drawConnection=function(e,t){},Fe.prototype.getShapePath=function(e){},Fe.prototype.getConnectionPath=function(e){};var qe=2,He={"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":qe,"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":qe,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function We(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=He[i];r?(r===qe&&"number"==typeof n&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function Qe(e,t,n){if("string"==typeof t){if(void 0===n)return function(e,t){return He[t]?e.style[t]:e.getAttributeNS(null,t)}(e,t);We(e,t,n)}else!function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)We(e,i,t[i])}(e,t);return e}const Xe=Object.prototype.toString;function Ge(e){return new Ue(e)}function Ue(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function Ye(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Ke(e){return e.cloneNode(!0)}Ue.prototype.add=function(e){return this.list.add(e),this},Ue.prototype.remove=function(e){return"[object RegExp]"==Xe.call(e)?this.removeMatching(e):(this.list.remove(e),this)},Ue.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},Ue.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Ue.prototype.array=function(){return Array.from(this.list)},Ue.prototype.has=Ue.prototype.contains=function(e){return this.list.contains(e)};var Ze={svg:"http://www.w3.org/2000/svg"},Je='<svg xmlns="'+Ze.svg+'"';function et(e){var t=!1;"<svg"===e.substring(0,4)?-1===e.indexOf(Ze.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(Ze.svg,e),t&&Qe(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 ht(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(ht(l));continue}const h=Math.min(t,dt(l.x-n.x,l.y-n.y),dt(c.x-l.x,c.y-l.y));if(!h){i.push(ht(l));continue}const u=pt(l,n,h),p=pt(l,n,.5*h),d=pt(l,c,h),f=pt(l,c,.5*h);i.push(ht(u)),i.push((s=f,a=d,["C",(o=p).x,o.y,s.x,s.y,a.x,a.y]))}return i}function pt(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 Qe(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&&vt(t,e)}))}))}function vt(e,t){if(t){if(e===t)return t;if(e.parent)return vt(e.parent,t)}}function yt(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]),_(e,(function(e,i){var r=t(e,i,n);d(r)&&r.length&&bt(r,t,n+1)}))}function xt(e,t,n){var i=[],r=[];return bt(e,(function(e,n,o){yt(i,e,t);var s=e.children;if(s&&yt(r,s,t))return s})),i}function wt(e,t){return xt(e,!t)}function _t(e,t){var n,i,r,o;return t=!!t,d(e)||(e=[e]),_(e,(function(e){var s=e;e.waypoints&&!t&&(s=_t(e.waypoints,!0));var a=s.x,l=s.y,c=s.height||0,h=s.width||0;(a<n||void 0===n)&&(n=a),(l<i||void 0===i)&&(i=l),(a+h>r||void 0===r)&&(r=a+h),(l+c>o||void 0===o)&&(o=l+c)})),{x:n,y:i,height:o-i,width:r-n}}function Et(e,t){var n={};return _(e,(function(e){var i=e;i.waypoints&&(i=_t(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 kt(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}function St(e){return!(!e||!e.isFrame)}function Ot(e,t){return F({},e||{},t||{})}function Ct(e,t){Fe.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(Ct,Fe),Ct.prototype.canRender=function(){return!0},Ct.prototype.drawShape=function(e,t,n){var i=tt("rect");return Qe(i,{x:0,y:0,width:t.width||0,height:t.height||0}),St(t)?Qe(i,F({},this.FRAME_STYLE,n||{})):Qe(i,F({},this.SHAPE_STYLE,n||{})),Ve(e,i),i},Ct.prototype.drawConnection=function(e,t,n){var i=ft(t.waypoints,F({},this.CONNECTION_STYLE,n||{}));return Ve(e,i),i},Ct.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"]])},Ct.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)},Ct.$inject=["eventBus","styles"];var At={__init__:["defaultRenderer"],defaultRenderer:["type",Ct],styles:["type",function(){var e={"no-fill":{fill:"none"},"no-border":{strokeOpacity:0},"no-events":{pointerEvents:"none"}},t=this;this.cls=function(e,t,n){return F(this.style(t,n),{class:e})},this.style=function(t,n){d(t)||n||(n=t,t=[]);var i=k(t,(function(t,n){return F(t,e[n]||{})}),{});return n?F(i,n):i},this.computeStyle=function(e,n,i){return d(n)||(i=n,n=[]),t.style(n||[],F({},i,e||{}))}}]};function Pt(e,t){if(!e||!t)return-1;var n=e.indexOf(t);return-1!==n&&e.splice(n,1),n}function Tt(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 Rt(e,t){return e&&t?Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)):-1}function Dt(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=Rt(e,t);return Math.abs(r/o)<=i}var Bt=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(Lt(e,n))return t;return!1}function Lt(e,t){const n=t[0];return S(t,(function(t){return Math.abs(n[e]-t[e])<=Bt}))}function It(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 zt(e,t){return{x:Math.round(e.x+(t.x-e.x)/2),y:Math.round(e.y+(t.y-e.y)/2)}}var $t=/,?([a-z]),?/gi,jt=parseFloat,Ft=Math,Vt=Ft.PI,qt=Ft.min,Ht=Ft.max,Wt=Ft.pow,Qt=Ft.abs,Xt=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?[\s]*,?[\s]*)+)/gi,Gt=/(-?\d*\.?\d*(?:e[-+]?\d+)?)[\s]*,?[\s]*/gi,Ut=Array.isArray||function(e){return e instanceof Array};function Yt(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 Kt(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(Xt,(function(e,i,r){var o=[],s=i.toLowerCase();for(r.replace(Gt,(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 Zt(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($t,"$1")}function en(e,t,n,i,r,o,s,a,l){var c=1-l,h=Wt(c,3),u=Wt(c,2),p=l*l*l,d=h*t+3*u*l*i+3*c*l*l*o+p*a;return{x:an(h*e+3*u*l*n+3*c*l*l*r+p*s),y:an(d)}}function tn(e){var t=function(e,t,n,i,r,o,s,a){for(var l,c,h,u,p,d,f,m,g=[],v=[[],[]],y=0;y<2;++y)if(0==y?(c=6*e-12*n+6*r,l=-3*e+9*n-9*r+3*s,h=3*n-3*e):(c=6*t-12*i+6*o,l=-3*t+9*i-9*o+3*a,h=3*i-3*t),Qt(l)<1e-12){if(Qt(c)<1e-12)continue;0<(u=-h/c)&&u<1&&g.push(u)}else f=c*c-4*h*l,m=Ft.sqrt(f),f<0||(0<(p=(-c+m)/(2*l))&&p<1&&g.push(p),0<(d=(-c-m)/(2*l))&&d<1&&g.push(d));var b,x=g.length,w=x;for(;x--;)b=1-(u=g[x]),v[0][x]=b*b*b*e+3*b*b*u*n+3*b*u*u*r+u*u*u*s,v[1][x]=b*b*b*t+3*b*b*u*i+3*b*u*u*o+u*u*u*a;return v[0][w]=e,v[1][w]=t,v[0][w+1]=s,v[1][w+1]=a,v[0].length=v[1].length=w+2,{x0:qt(...v[0]),y0:qt(...v[1]),x1:Ht(...v[0]),y1:Ht(...v[1])}}(...e);return Zt(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,h=[-.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],p=0,d=0;d<12;d++){var f=c*h[d]+c,m=rn(f,e,n,r,s),g=rn(f,t,i,o,a),v=m*m+g*g;p+=u[d]*Ft.sqrt(v)}return c*p}function sn(e,t,n,i,r,o,s,a){if(!(Ht(e,n)<qt(r,s)||qt(e,n)>Ht(r,s)||Ht(t,i)<qt(o,a)||qt(t,i)>Ht(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 h=an(((e*i-t*n)*(r-s)-(e-n)*(r*a-o*s))/c),u=an(l/c),p=+h.toFixed(2),d=+u.toFixed(2);if(!(p<+qt(e,n).toFixed(2)||p>+Ht(e,n).toFixed(2)||p<+qt(r,s).toFixed(2)||p>+Ht(r,s).toFixed(2)||d<+qt(t,i).toFixed(2)||d>+Ht(t,i).toFixed(2)||d<+qt(o,a).toFixed(2)||d>+Ht(o,a).toFixed(2)))return{x:h,y:u}}}}function an(e){return Math.round(1e11*e)/1e11}function ln(e,t,n){if(!function(e,t){return e=Zt(e),nn(t=Zt(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=hn(e)?1:~~(o/5)||1,l=hn(t)?1:~~(s/5)||1,c=new Array(a+1),h=new Array(l+1),u={},p=[];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),h[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],v=h[r],y=h[r+1],b=Qt(g.x-m.x)<.01?"y":"x",x=Qt(y.x-v.x)<.01?"y":"x",w=sn(m.x,m.y,g.x,g.y,v.x,v.y,y.x,y.y);if(w){if(u[f=w.x.toFixed(9)+"#"+w.y.toFixed(9)])continue;u[f]=!0;var _=m.t+Qt((w[b]-m[b])/(g[b]-m[b]))*(g.t-m.t),E=v.t+Qt((w[x]-v[x])/(y[x]-v[x]))*(y.t-v.t);_>=0&&_<=1&&E>=0&&E<=1&&p.push({x:w.x,y:w.y,t1:_,t2:E})}}return p}function cn(e,t,n){e=fn(e),t=fn(t);for(var i,r,o,s,a,l,c,h,u,p,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 v=0,y=t.length;v<y;v++){var b=t[v];if("M"==b[0])o=c=b[1],s=h=b[2];else{"C"==b[0]?(o=(p=[o,s,...b.slice(1)])[6],s=p[7]):(p=[o,s,o,s,c,h,c,h],o=c,s=h);for(var x=ln(u,p),w=0,_=x.length;w<_;w++)x[w].segment1=f,x[w].segment2=v,x[w].bez1=u,x[w].bez2=p;d=d.concat(x)}}}}return d}function hn(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 pn(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 h,u=120*Vt/180,p=Vt/180*(+r||0),d=[],f=Yt((function(e,t,n){return{x:e*Ft.cos(n)-t*Ft.sin(n),y:e*Ft.sin(n)+t*Ft.cos(n)}}));if(c)E=c[0],k=c[1],w=c[2],_=c[3];else{e=(h=f(e,t,-p)).x,t=h.y;var m=(e-(a=(h=f(a,l,-p)).x))/2,g=(t-(l=h.y))/2,v=m*m/(n*n)+g*g/(i*i);v>1&&(n*=v=Ft.sqrt(v),i*=v);var y=n*n,b=i*i,x=(o==s?-1:1)*Ft.sqrt(Qt((y*b-y*g*g-b*m*m)/(y*g*g+b*m*m))),w=x*n*g/i+(e+a)/2,_=x*-i*m/n+(t+l)/2,E=Ft.asin(((t-_)/i).toFixed(9)),k=Ft.asin(((l-_)/i).toFixed(9));(E=e<w?Vt-E:E)<0&&(E=2*Vt+E),(k=a<w?Vt-k:k)<0&&(k=2*Vt+k),s&&E>k&&(E-=2*Vt),!s&&k>E&&(k-=2*Vt)}var S=k-E;if(Qt(S)>u){var O=k,C=a,A=l;k=E+u*(s&&k>E?1:-1),d=dn(a=w+n*Ft.cos(k),l=_+i*Ft.sin(k),n,i,r,0,s,C,A,[k,O,w,_])}S=k-E;var P=Ft.cos(E),T=Ft.sin(E),M=Ft.cos(k),R=Ft.sin(k),D=Ft.tan(S/4),B=4/3*n*D,N=4/3*i*D,L=[e,t],I=[e+B*T,t-N*P],z=[a+B*R,l-N*M],$=[a,l];if(I[0]=2*L[0]-I[0],I[1]=2*L[1]-I[1],c)return[I,z,$].concat(d);for(var j=[],F=0,V=(d=[I,z,$].concat(d).join().split(",")).length;F<V;F++)j[F]=F%2?f(d[F-1],d[F],p).y:f(d[F],d[F+1],p).x;return j}function fn(e){if(function(e){return Ut(e)&&Ut(e[0])}(e)||(e=Kt(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,h=a,u=e.length;h<u;h++){if(t=(c=e[h])[0],n[h]=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 p=1,d=c.length;p<d;p++)l[p]=+c[p]+(p%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",...pn(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",...pn(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 h=t[l],u=h.length;n.x=h[u-2],n.y=h[u-1],n.bx=jt(h[u-4])||n.x,n.by=jt(h[u-3])||n.y}return t}function mn(e){return f(e)&&y(e,"waypoints")}function gn(e){return f(e)&&y(e,"labelTarget")}function vn(e){return{x:Math.round(e.x),y:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height)}}function yn(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 xn(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 _n(e){return mn(e)?wn(e):yn({x:(t=e).x+(t.width||0)/2,y:t.y+(t.height||0)/2});var t}function En(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 kn(e,t,n){var i=function(e,t){return cn(e,t)}(e,t);return 1===i.length||2===i.length&&Rt(i[0],i[1])<1?yn(i[0]):i.length>1?(i=D(i,(function(e){var t=Math.floor(100*e.t2)||1;return t=((t=100-t)<10?"0":"")+t,e.segment2+"#"+t})),yn(i[n?0:i.length-1])):null}function Sn(e,t){return Math.round(e*t)/t}function On(e){return m(e)?e+"px":e}function Cn(e,t,n){const i=tt("g");Ge(i).add(t);const r=void 0!==n?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[r]||null),i}const An={shape:["x","y","width","height"],connection:["waypoints"]};function Pn(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 Tn(e,t){const n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}Pn.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],Pn.prototype._init=function(e){const t=this._eventBus,n=this._container=function(e){const t=(e=F({},{width:"100%",height:"100%"},e)).container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container djs-parent"),G(n,{position:"relative",overflow:"hidden",width:On(e.width),height:On(e.height)}),t.appendChild(n),n}(e),i=this._svg=tt("svg");Qe(i,{width:"100%",height:"100%"}),U(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=Cn(i,"viewport");e.deferUpdate&&(this._viewboxChanged=$(j(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)},Pn.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},Pn.prototype._setFocused=function(e){e!=this._focused&&(this._focused=e,this._eventBus.fire("canvas.focus.changed",{focused:e}))},Pn.prototype._clear=function(){this._elementRegistry.getAll().forEach((e=>{const t=kt(e);"root"===t?this.removeRootElement(e):this._removeElement(e,t)})),this._planes=[],this._rootElement=null,delete this._cachedViewbox},Pn.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)},Pn.prototype.restoreFocus=function(){document.activeElement===document.body&&this.focus()},Pn.prototype.isFocused=function(){return this._focused},Pn.prototype.getDefaultLayer=function(){return this.getLayer("base",0)},Pn.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},Pn.prototype._getChildIndex=function(e){return k(this._layers,(function(t,n){return n.visible&&e>=n.index&&t++,t}),0)},Pn.prototype._createLayer=function(e,t){void 0===t&&(t=1);const n=this._getChildIndex(t);return{group:Cn(this._viewport,"layer-"+e,n),index:t,visible:!0}},Pn.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},Pn.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},Pn.prototype._removeLayer=function(e){const t=this._layers[e];t&&(delete this._layers[e],st(t.group))},Pn.prototype.getActiveLayer=function(){const e=this._findPlaneForRoot(this.getRootElement());return e?e.layer:null},Pn.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},Pn.prototype.getRootElements=function(){return this._planes.map((function(e){return e.rootElement}))},Pn.prototype._findPlaneForRoot=function(e){return b(this._planes,(function(t){return t.rootElement===e}))},Pn.prototype.getContainer=function(){return this._container},Pn.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&&(_([i.gfx,i.secondaryGfx],(function(i){i&&(n?(e.markers.add(t),Ge(i).add(t)):(e.markers.delete(t),Ge(i).remove(t)))})),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},Pn.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},Pn.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},Pn.prototype.hasMarker=function(e,t){return e.id||(e=this._elementRegistry.get(e)),!!e.markers&&e.markers.has(t)},Pn.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},Pn.prototype.getRootElement=function(){const e=this._rootElement;return e||this._planes.length?e:this.setRootElement(this.addRootElement(null))},Pn.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},Pn.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},Pn.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},Pn.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)},Pn.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})},Pn.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})},Pn.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=An[e],i=S(n,(function(e){return void 0!==t[e]}));if(!i)throw new Error("must supply { "+n.join(", ")+" } with "+e)},Pn.prototype._setParent=function(e,t,n){Tt(t.children,e,n),e.parent=t},Pn.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},Pn.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},Pn.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},Pn.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),Pt(e.parent&&e.parent.children,e),e.parent=null,r.fire(t+".removed",{element:e}),n.remove(e),e},Pn.prototype.removeShape=function(e){return this._removeElement(e,"shape")},Pn.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},Pn.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},Pn.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},Pn.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},Pn.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=Sn(r.a,1e3),l=Sn(-r.e||0,1e3),c=Sn(-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})},Pn.prototype.scroll=function(e){const t=this._viewport;let n=t.getCTM();return e&&this._changeViewbox((function(){e=F({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),Tn(t,n)})),{x:n.e,y:n.f}},Pn.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=_t(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 h=bn(s);if(r.width<s.width&&r.height<s.height){const e=Math.max(0,o.right-h.right),t=Math.min(0,o.left-h.left),n=Math.max(0,o.bottom-h.bottom),i=Math.min(0,o.top-h.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})},Pn.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)})),Sn(i.a,1e3)},Pn.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},Pn.prototype._setZoom=function(e,t){const n=this._svg,i=this._viewport,r=n.createSVGMatrix(),o=n.createSVGPoint();let s,a,l,c,h;l=i.getCTM();const u=l.a;return t?(s=F(o,t),a=s.matrixTransform(l.inverse()),c=r.translate(a.x,a.y).scale(1/u*e).translate(-a.x,-a.y),h=l.multiply(c)):h=r.scale(e),Tn(this._viewport,h),h},Pn.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},Pn.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}},Pn.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var Mn="data-element-id";function Rn(e){this._elements={},this._eventBus=e}function Dn(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 Bn(e,t){if(!(this instanceof Bn))return new Bn(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}Rn.$inject=["eventBus"],Rn.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),Qe(t,Mn,i),n&&Qe(n,Mn,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},Rn.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(Qe(i.gfx,Mn,""),i.secondaryGfx&&Qe(i.secondaryGfx,Mn,""),delete t[n])},Rn.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)},Rn.prototype.updateGraphics=function(e,t,n){var i=e.id||e,r=this._elements[i];return n?r.secondaryGfx=t:r.gfx=t,t&&Qe(t,Mn,i),t},Rn.prototype.get=function(e){var t;t="string"==typeof e?e:e&&Qe(e,Mn);var n=this._elements[t];return n&&n.element},Rn.prototype.filter=function(e){var t=[];return this.forEach((function(n,i){e(n,i)&&t.push(n)})),t},Rn.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}},Rn.prototype.getAll=function(){return this.filter((function(e){return e}))},Rn.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)}))},Rn.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},Rn.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")},Bn.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?Dn(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)},Bn.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return function(e){return!0===e.__refs_collection}(n)||Dn(this,t,e),n},Bn.prototype.ensureBound=function(e,t){(function(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)})(e,t)||this.bind(e,t)},Bn.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},Bn.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 Bn({name:"children",enumerable:!0,collection:!0},{name:"parent"}),Ln=new Bn({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),In=new Bn({name:"attachers",collection:!0},{name:"host"}),zn=new Bn({name:"outgoing",collection:!0},{name:"source"}),$n=new Bn({name:"incoming",collection:!0},{name:"target"});function jn(){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"),Ln.bind(this,"labels"),zn.bind(this,"outgoing"),$n.bind(this,"incoming")}function Fn(){jn.call(this),Nn.bind(this,"children"),In.bind(this,"host"),In.bind(this,"attachers")}function Vn(){jn.call(this),Nn.bind(this,"children")}function qn(){Fn.call(this),Ln.bind(this,"labelTarget")}function Hn(){jn.call(this),zn.bind(this,"source"),$n.bind(this,"target")}e(Fn,jn),e(Vn,Fn),e