bpmn-js
Version:
A bpmn 2.0 toolkit and web modeler
21 lines • 164 kB
JavaScript
/*! bpmn-js - bpmn-navigated-viewer v2.5.1 | Copyright (c) 2014-present, camunda Services GmbH | bpmn.io/license */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.BpmnJS=t()}(this,function(){"use strict";"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function e(e,t){return e(t={exports:{}},t.exports),t.exports}var t=e(function(e){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}),n=Object.prototype.toString,i=Object.prototype.hasOwnProperty;function r(e){return"[object Array]"===n.call(e)}function a(e){return"[object Object]"===n.call(e)}function o(e){return"[object Number]"===n.call(e)}function s(e){return"[object Function]"===n.call(e)}function l(e){return"[object String]"===n.call(e)}function p(e,t){return i.call(e,t)}function c(e,t){var n;return t=function(e){return s(e)?e:function(t){return t===e}}(t),h(e,function(e,i){if(t(e,i))return n=e,!1}),n}function u(e,t){var n=[];return h(e,function(e,i){t(e,i)&&n.push(e)}),n}function h(e,t){if(null!==(n=e)&&void 0!==n){var n,i=r(e)?v:g;for(var a in e){if(p(e,a))if(!1===t(e[a],i(a)))return}}}function m(e,t,n){return h(e,function(e,i){n=t(n,e,i)}),n}function f(e,t){return m(e,function(e,n,i){return e&&t(n,i)},!0)}function d(e,t){var n=[];return h(e,function(e,i){n.push(t(e,i))}),n}function y(e){return function(t){return f(e,function(e,n){return t[n]===e})}}function g(e){return e}function v(e){return Number(e)}var x=Array.prototype.slice;function b(e,t){var n;return function(){var i=x.call(arguments);n&&clearTimeout(n),n=setTimeout(function(){e.apply(void 0,function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(i))},t)}}function E(e,t){return e.bind(t)}var w=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e};function _(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return w.apply(void 0,[e].concat(n))}var A=[].indexOf,S=function(e,t){if(A)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},R=/\s+/,C=Object.prototype.toString;function M(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 P(e){for(var t;e.childNodes.length;)t=e.childNodes[0],e.removeChild(t);return e}k.prototype.add=function(e){if(this.list)return this.list.add(e),this;var t=this.array();return~S(t,e)||t.push(e),this.el.className=t.join(" "),this},k.prototype.remove=function(e){if("[object RegExp]"==C.call(e))return this.removeMatching(e);if(this.list)return this.list.remove(e),this;var t=this.array(),n=S(t,e);return~n&&t.splice(n,1),this.el.className=t.join(" "),this},k.prototype.removeMatching=function(e){for(var t=this.array(),n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},k.prototype.toggle=function(e,t){return this.list?(void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this):(void 0!==t?t?this.add(e):this.remove(e):this.has(e)?this.remove(e):this.add(e),this)},k.prototype.array=function(){var e=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(R);return""===e[0]&&e.shift(),e},k.prototype.has=k.prototype.contains=function(e){return this.list?this.list.contains(e):!!~S(this.array(),e)};var T=Element.prototype,N=T.matchesSelector||T.webkitMatchesSelector||T.mozMatchesSelector||T.msMatchesSelector||T.oMatchesSelector,D=function(e,t){if(N)return N.call(e,t);for(var n=e.parentNode.querySelectorAll(t),i=0;i<n.length;++i)if(n[i]==e)return!0;return!1};var O,B=function(e,t,n){for(var i=n?e:e.parentNode;i&&i!==document;){if(D(i,t))return i;i=i.parentNode}},L=window.addEventListener?"addEventListener":"attachEvent",I=window.removeEventListener?"removeEventListener":"detachEvent",F="addEventListener"!==L?"on":"",j={bind:function(e,t,n,i){return e[L](F+t,n,i||!1),n},unbind:function(e,t,n,i){return e[I](F+t,n,i||!1),n}},V=["focus","blur"],W={bind:function(e,t,n,i,r){return-1!==V.indexOf(n)&&(r=!0),j.bind(e,n,function(n){var r=n.target||n.srcElement;n.delegateTarget=B(r,t,!0,e),n.delegateTarget&&i.call(e,n)},r)},unbind:function(e,t,n,i){-1!==V.indexOf(t)&&(i=!0),j.unbind(e,t,n,i)}},z=function(e,t){if("string"!=typeof e)throw new TypeError("String expected");t||(t=document);var n=/<([\w:]+)/.exec(e);if(!n)return t.createTextNode(e);e=e.replace(/^\s+|\s+$/g,"");var i=n[1];if("body"==i){var r=t.createElement("html");return r.innerHTML=e,r.removeChild(r.lastChild)}var a=$[i]||$._default,o=a[0],s=a[1],l=a[2];(r=t.createElement("div")).innerHTML=s+e+l;for(;o--;)r=r.lastChild;if(r.firstChild==r.lastChild)return r.removeChild(r.firstChild);var p=t.createDocumentFragment();for(;r.firstChild;)p.appendChild(r.removeChild(r.firstChild));return p},G=!1;"undefined"!=typeof document&&((O=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',G=!O.getElementsByTagName("link").length,O=void 0);var $={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:G?[1,"X<div>","</div>"]:[0,"",""]};$.td=$.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],$.option=$.optgroup=[1,'<select multiple="multiple">',"</select>"],$.thead=$.tbody=$.colgroup=$.caption=$.tfoot=[1,"<table>","</table>"],$.polyline=$.ellipse=$.polygon=$.circle=$.text=$.line=$.path=$.rect=$.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var H="undefined"!=typeof Element?Element.prototype:{};H.matches||H.matchesSelector||H.webkitMatchesSelector||H.mozMatchesSelector||H.msMatchesSelector||H.oMatchesSelector;function K(e,t){return(t=t||document).querySelector(e)}function U(e){e.parentNode&&e.parentNode.removeChild(e)}function q(e,t){return t.appendChild(function(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch(e){}return e}(e,t)),e}function Y(e,t){return q(t,e),e}var X=2,Z={"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":X,"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":X,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function J(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=Z[i];r?(r===X&&"number"==typeof n&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function Q(e,t,n){if("string"==typeof t){if(void 0===n)return function(e,t){return Z[t]?e.style[t]:e.getAttributeNS(null,t)}(e,t);J(e,t,n)}else!function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)J(e,i,t[i])}(e,t);return e}function ee(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1}var te=/\s+/,ne=Object.prototype.toString;function ie(e){return void 0!==e}function re(e){return new ae(e)}function ae(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function oe(e){var t=e.parentNode;return t&&t.removeChild(e),e}ae.prototype.add=function(e){if(this.list)return this.list.add(e),this;var t=this.array();return~ee(t,e)||t.push(e),ie(this.el.className.baseVal)?this.el.className.baseVal=t.join(" "):this.el.className=t.join(" "),this},ae.prototype.remove=function(e){if("[object RegExp]"===ne.call(e))return this.removeMatching(e);if(this.list)return this.list.remove(e),this;var t=this.array(),n=ee(t,e);return~n&&t.splice(n,1),this.el.className.baseVal=t.join(" "),this},ae.prototype.removeMatching=function(e){for(var t=this.array(),n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},ae.prototype.toggle=function(e,t){return this.list?(ie(t)?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this):(ie(t)?t?this.add(e):this.remove(e):this.has(e)?this.remove(e):this.add(e),this)},ae.prototype.array=function(){var e=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(te);return""===e[0]&&e.shift(),e},ae.prototype.has=ae.prototype.contains=function(e){return this.list?this.list.contains(e):!!~ee(this.array(),e)};var se={svg:"http://www.w3.org/2000/svg"},le='<svg xmlns="'+se.svg+'"';function pe(e){return"<svg"===e.substring(0,4)?-1===e.indexOf(se.svg)&&(e=le+e.substring(4)):e=le+">"+e+"</svg>",function(e){var t;return(t=new DOMParser).async=!1,t.parseFromString(e,"text/xml")}(e)}function ce(e,t){var n;return"<"===e.charAt(0)?(n=pe(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(se.svg,e),t&&Q(n,t),n}var ue=ce("svg");function he(e,t,n,i,r,a){var o=ue.createSVGMatrix();switch(arguments.length){case 0:return o;case 6:e={a:e,b:t,c:n,d:i,e:r,f:a}}return function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)e[i]=t[i];return e}(o,e)}function me(e){return e?ue.createSVGTransformFromMatrix(e):ue.createSVGTransform()}var fe=/([&<>]{1})/g,de=/([\n\r"]{1})/g,ye={"&":"&","<":"<",">":">",'"':"'"};function ge(e,t){return e.replace(t,function(e,t){return ye[t]||t})}function ve(e,t){var n,i,r,a,o;switch(e.nodeType){case 3:t.push(ge(e.textContent,fe));break;case 1:if(t.push("<",e.tagName),e.hasAttributes())for(n=0,i=(r=e.attributes).length;n<i;++n)a=r.item(n),t.push(" ",a.name,'="',ge(a.value,de),'"');if(e.hasChildNodes()){for(t.push(">"),n=0,i=(o=e.childNodes).length;n<i;++n)ve(o.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("\x3c!--",ge(e.nodeValue,fe),"--\x3e");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function xe(e,t){var n,i=pe(t).documentElement;if(function(e){for(var t;t=e.firstChild;)oe(t)}(e),t)for(n=i.firstChild;n;)q(n,e),n=n.nextSibling}function be(e,t){if(void 0!==t){try{xe(e,t)}catch(e){throw new Error("error parsing SVG: "+e.message)}return e}return function(e){for(var t=e.firstChild,n=[];t;)ve(t,n),t=t.nextSibling;return n.join("")}(e)}function Ee(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function we(e,t){var n=e.transform.baseVal;if(1===arguments.length)return n.consolidate();t.length?function(e,t){var n,i;for(e.clear(),n=0;i=t[n];n++)e.appendItem(Ee(e,i));e.consolidate()}(n,t):n.initialize(Ee(n,t))}var _e=/^class /;function Ae(e){return"[object Array]"===Object.prototype.toString.call(e)}function Se(){var e=Array.prototype.slice.call(arguments);1===e.length&&Ae(e[0])&&(e=e[0]);var t=e.pop();return t.$inject=e,t}var Re=/constructor\s*[^(]*\(\s*([^)]*)\)/m,Ce=/^function\s*[^(]*\(\s*([^)]*)\)/m,Me=/\/\*([^*]*)\*\//m;function ke(e){if("function"!=typeof e)throw new Error('Cannot annotate "'+e+'". Expected a function!');var t=e.toString().match(function(e){return _e.test(e.toString())}(e)?Re:Ce);return t&&t[1]&&t[1].split(",").map(function(e){return(t=e.match(Me))?t[1].trim():e.trim()})||[]}var Pe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function Te(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function Ne(e,t){return Object.hasOwnProperty.call(e,t)}var De=1e3;function Oe(e,t){var n=this;t=t||De,e.on(["render.shape","render.connection"],t,function(e,t){var i=e.type,r=t.element,a=t.gfx;if(n.canRender(r))return"render.shape"===i?n.drawShape(a,r):n.drawConnection(a,r)}),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 Be(e){return e.join(",").replace(/,?([A-z]),?/g,"$1")}function Le(e){for(var t,n="",i=0;t=e[i];i++)n+=t.x+","+t.y+" ";return n}function Ie(e,t){var n=ce("polyline");return Q(n,{points:Le(e)}),t&&Q(n,t),n}Oe.prototype.canRender=function(){},Oe.prototype.drawShape=function(){},Oe.prototype.drawConnection=function(){},Oe.prototype.getShapePath=function(){},Oe.prototype.getConnectionPath=function(){};var Fe=1;function je(e,t){Oe.call(this,e,Fe),this.CONNECTION_STYLE=t.style(["no-fill"],{strokeWidth:5,stroke:"fuchsia"}),this.SHAPE_STYLE=t.style({fill:"white",stroke:"fuchsia",strokeWidth:2})}t(je,Oe),je.prototype.canRender=function(){return!0},je.prototype.drawShape=function(e,t){var n=ce("rect");return Q(n,{x:0,y:0,width:t.width||0,height:t.height||0}),Q(n,this.SHAPE_STYLE),Y(e,n),n},je.prototype.drawConnection=function(e,t){var n=Ie(t.waypoints,this.CONNECTION_STYLE);return Y(e,n),n},je.prototype.getShapePath=function(e){var t=e.x,n=e.y,i=e.width;return Be([["M",t,n],["l",i,0],["l",0,e.height],["l",-i,0],["z"]])},je.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 Be(r)},je.$inject=["eventBus","styles"];var Ve={__init__:["defaultRenderer"],defaultRenderer:["type",je],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 _(this.style(t,n),{class:e})},this.style=function(t,n){r(t)||n||(n=t,t=[]);var i=m(t,function(t,n){return _(t,e[n]||{})},{});return n?_(i,n):i},this.computeStyle=function(e,n,i){return r(n)||(i=n,n=[]),t.style(n||[],_({},i,e||{}))}}]};function We(e,t){var n,i,a,o;return t=!!t,r(e)||(e=[e]),h(e,function(e){var r=e;e.waypoints&&!t&&(r=We(e.waypoints,!0));var s=r.x,l=r.y,p=r.height||0,c=r.width||0;(s<n||void 0===n)&&(n=s),(l<i||void 0===i)&&(i=l),(s+c>a||void 0===a)&&(a=s+c),(l+p>o||void 0===o)&&(o=l+p)}),{x:n,y:i,height:o-i,width:a-n}}function ze(e,t){return Math.round(e*t)/t}function Ge(e){return o(e)?e+"px":e}function $e(e,t,n){var i=ce("g");re(i).add(t);var r=void 0!==n?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[r]||null),i}var He={shape:["x","y","width","height"],connection:["waypoints"]};function Ke(e,t,n,i){this._eventBus=t,this._elementRegistry=i,this._graphicsFactory=n,this._init(e||{})}function Ue(e,t){var n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}Ke.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],Ke.prototype._init=function(e){var t=this._eventBus,n=this._container=function(e){var t=(e=_({},{width:"100%",height:"100%"},e)).container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container"),_(n.style,{position:"relative",overflow:"hidden",width:Ge(e.width),height:Ge(e.height)}),t.appendChild(n),n}(e),i=this._svg=ce("svg");Q(i,{width:"100%",height:"100%"}),Y(n,i);var r=this._viewport=$e(i,"viewport");this._layers={},!1!==e.deferUpdate&&(this._viewboxChanged=b(E(this._viewboxChanged,this),300)),t.on("diagram.init",function(){t.fire("canvas.init",{svg:i,viewport:r})},this),t.on(["shape.added","connection.added","shape.removed","connection.removed","elements.changed"],function(){delete this._cachedViewbox},this),t.on("diagram.destroy",500,this._destroy,this),t.on("diagram.clear",500,this._clear,this)},Ke.prototype._destroy=function(e){this._eventBus.fire("canvas.destroy",{svg:this._svg,viewport:this._viewport});var t=this._container.parentNode;t&&t.removeChild(this._container),delete this._svg,delete this._container,delete this._layers,delete this._rootElement,delete this._viewport},Ke.prototype._clear=function(){var e=this;this._elementRegistry.getAll().forEach(function(t){var n=function(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}(t);"root"===n?e.setRootElement(null,!0):e._removeElement(t,n)}),delete this._cachedViewbox},Ke.prototype.getDefaultLayer=function(){return this.getLayer("base",0)},Ke.prototype.getLayer=function(e,t){if(!e)throw new Error("must specify a name");var 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},Ke.prototype._createLayer=function(e,t){t||(t=0);var n=m(this._layers,function(e,n){return t>=n.index&&e++,e},0);return{group:$e(this._viewport,"layer-"+e,n),index:t}},Ke.prototype.getContainer=function(){return this._container},Ke.prototype._updateMarker=function(e,t,n){var i;e.id||(e=this._elementRegistry.get(e)),(i=this._elementRegistry._elements[e.id])&&(h([i.gfx,i.secondaryGfx],function(e){e&&(n?re(e).add(t):re(e).remove(t))}),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},Ke.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},Ke.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},Ke.prototype.hasMarker=function(e,t){return e.id||(e=this._elementRegistry.get(e)),re(this.getGraphics(e)).has(t)},Ke.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},Ke.prototype.getRootElement=function(){return this._rootElement||this.setRootElement({id:"__implicitroot",children:[]}),this._rootElement},Ke.prototype.setRootElement=function(e,t){e&&this._ensureValid("root",e);var n=this._rootElement,i=this._elementRegistry,r=this._eventBus;if(n){if(!t)throw new Error("rootElement already set, need to specify override");r.fire("root.remove",{element:n}),r.fire("root.removed",{element:n}),i.remove(n)}if(e){var a=this.getDefaultLayer();r.fire("root.add",{element:e}),i.add(e,a,this._svg),r.fire("root.added",{element:e,gfx:a})}return this._rootElement=e,e},Ke.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 with id "+t.id+" already exists");var n=He[e];if(!f(n,function(e){return void 0!==t[e]}))throw new Error("must supply { "+n.join(", ")+" } with "+e)},Ke.prototype._setParent=function(e,t,n){!function(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)}}(t.children,e,n),e.parent=t},Ke.prototype._addElement=function(e,t,n,i){n=n||this.getRootElement();var r=this._eventBus,a=this._graphicsFactory;this._ensureValid(e,t),r.fire(e+".add",{element:t,parent:n}),this._setParent(t,n,i);var o=a.create(e,t,i);return this._elementRegistry.add(t,o),a.update(e,t,o),r.fire(e+".added",{element:t,gfx:o}),t},Ke.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},Ke.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},Ke.prototype._removeElement=function(e,t){var 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),function(e,t){if(!e||!t)return-1;var n=e.indexOf(t);-1!==n&&e.splice(n,1)}(e.parent&&e.parent.children,e),e.parent=null,r.fire(t+".removed",{element:e}),n.remove(e),e},Ke.prototype.removeShape=function(e){return this._removeElement(e,"shape")},Ke.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},Ke.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},Ke.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},Ke.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},Ke.prototype.viewbox=function(e){if(void 0===e&&this._cachedViewbox)return this._cachedViewbox;var t,n,i,r,a,o,s=this._viewport,l=this.getSize();return e?(this._changeViewbox(function(){r=Math.min(l.width/e.width,l.height/e.height);var t=this._svg.createSVGMatrix().scale(r).translate(-e.x,-e.y);we(s,t)}),e):(t=this.getDefaultLayer().getBBox(),n=(i=we(s))?i.matrix:he(),r=ze(n.a,1e3),a=ze(-n.e||0,1e3),o=ze(-n.f||0,1e3),e=this._cachedViewbox={x:a?a/r:0,y:o?o/r:0,width:l.width/r,height:l.height/r,scale:r,inner:{width:t.width,height:t.height,x:t.x,y:t.y},outer:l})},Ke.prototype.scroll=function(e){var t=this._viewport,n=t.getCTM();return e&&this._changeViewbox(function(){e=_({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),Ue(t,n)}),{x:n.e,y:n.f}},Ke.prototype.zoom=function(e,t){return e?"fit-viewport"===e?this._fitViewport(t):(this._changeViewbox(function(){"object"!=typeof t&&(n=this.viewbox().outer,t={x:n.width/2,y:n.height/2}),i=this._setZoom(e,t)}),ze(i.a,1e3)):this.viewbox(e).scale;var n,i},Ke.prototype._fitViewport=function(e){var t,n,i=this.viewbox(),r=i.outer,a=i.inner;return a.x>=0&&a.y>=0&&a.x+a.width<=r.width&&a.y+a.height<=r.height&&!e?n={x:0,y:0,width:Math.max(a.width+a.x,r.width),height:Math.max(a.height+a.y,r.height)}:(t=Math.min(1,r.width/a.width,r.height/a.height),n={x:a.x+(e?a.width/2-r.width/t/2:0),y:a.y+(e?a.height/2-r.height/t/2:0),width:r.width/t,height:r.height/t}),this.viewbox(n),this.viewbox(!1).scale},Ke.prototype._setZoom=function(e,t){var n,i,r,a,o=this._svg,s=this._viewport,l=o.createSVGMatrix(),p=o.createSVGPoint(),c=(i=s.getCTM()).a;return t?(n=_(p,t).matrixTransform(i.inverse()),r=l.translate(n.x,n.y).scale(1/c*e).translate(-n.x,-n.y),a=i.multiply(r)):a=l.scale(e),Ue(this._viewport,a),a},Ke.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},Ke.prototype.getAbsoluteBBox=function(e){var t,n=this.viewbox();e.waypoints?t=this.getGraphics(e).getBBox():t=e;return{x:t.x*n.scale-n.x*n.scale,y:t.y*n.scale-n.y*n.scale,width:t.width*n.scale,height:t.height*n.scale}},Ke.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var qe="data-element-id";function Ye(e){this._elements={},this._eventBus=e}Ye.$inject=["eventBus"],Ye.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),Q(t,qe,i),n&&Q(n,qe,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},Ye.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(Q(i.gfx,qe,""),i.secondaryGfx&&Q(i.secondaryGfx,qe,""),delete t[n])},Ye.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)},Ye.prototype.get=function(e){var t;t="string"==typeof e?e:e&&Q(e,qe);var n=this._elements[t];return n&&n.element},Ye.prototype.filter=function(e){var t=[];return this.forEach(function(n,i){e(n,i)&&t.push(n)}),t},Ye.prototype.getAll=function(){return this.filter(function(e){return e})},Ye.prototype.forEach=function(e){var t=this._elements;Object.keys(t).forEach(function(n){var i=t[n],r=i.element,a=i.gfx;return e(r,a)})},Ye.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},Ye.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")};var Xe={extend: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 a=this.indexOf(e);if(void 0===n){if(-1!==a)return;n=this.length}-1!==a&&this.splice(a,1),this.splice(n,0,e),-1===a&&t.set(e,r,i)}}),Object.defineProperty(e,"__refs_collection",{value:!0}),e},isExtended:function(e){return!0===e.__refs_collection}};function Ze(e,t,n){var i=Xe.extend(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 Je(e,t){if(!(this instanceof Je))return new Je(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}Je.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?Ze(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 a=r;r=null,a&&e.unset(a,i,n),r=t,e.set(r,i,n)}}})}(this,t,e)},Je.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return Xe.isExtended(n)||Ze(this,t,e),n},Je.prototype.ensureBound=function(e,t){(function(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)})(e,t)||this.bind(e,t)},Je.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},Je.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var Qe=Je,et=Xe;Qe.Collection=et;var tt=new Qe({name:"children",enumerable:!0,collection:!0},{name:"parent"}),nt=new Qe({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),it=new Qe({name:"attachers",collection:!0},{name:"host"}),rt=new Qe({name:"outgoing",collection:!0},{name:"source"}),at=new Qe({name:"incoming",collection:!0},{name:"target"});function ot(){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)}}),tt.bind(this,"parent"),nt.bind(this,"labels"),rt.bind(this,"outgoing"),at.bind(this,"incoming")}function st(){ot.call(this),tt.bind(this,"children"),it.bind(this,"host"),it.bind(this,"attachers")}function lt(){st.call(this)}function pt(){st.call(this),nt.bind(this,"labelTarget")}function ct(){ot.call(this),rt.bind(this,"source"),at.bind(this,"target")}t(st,ot),t(lt,st),t(pt,st),t(ct,ot);var ut={connection:ct,shape:st,label:pt,root:lt};function ht(){this._uid=12}ht.prototype.createRoot=function(e){return this.create("root",e)},ht.prototype.createLabel=function(e){return this.create("label",e)},ht.prototype.createShape=function(e){return this.create("shape",e)},ht.prototype.createConnection=function(e){return this.create("connection",e)},ht.prototype.create=function(e,t){return(t=_({},t||{})).id||(t.id=e+"_"+this._uid++),function(e,t){var n=ut[e];if(!n)throw new Error("unknown type: <"+e+">");return _(new n,t)}(e,t)};var mt=Array.prototype.slice;function ft(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}function dt(){}function yt(e,t,n){var i=me();i.setTranslate(t,n),we(e,i)}function gt(e,t){this._eventBus=e,this._elementRegistry=t}function vt(e,t,n){t.insertBefore(e,n||t.firstChild)}ft.prototype.on=function(e,t,n,i){if(e=r(e)?e:[e],s(t)&&(i=n,n=t,t=1e3),!o(t))throw new Error("priority must be a number");var a=n;i&&((a=E(n,i)).__fn=n.__fn||n);var l=this,p={priority:t,callback:a};e.forEach(function(e){l._addListener(e,p)})},ft.prototype.once=function(e,t,n,i){var r=this;if(s(t)&&(i=n,n=t,t=1e3),!o(t))throw new Error("priority must be a number");function a(){return r.off(e,a),n.apply(i,arguments)}a.__fn=n,this.on(e,t,a)},ft.prototype.off=function(e,t){var n=this;(e=r(e)?e:[e]).forEach(function(e){n._removeListener(e,t)})},ft.prototype.createEvent=function(e){var t=new dt;return t.init(e),t},ft.prototype.fire=function(e,t){var n,i,r,a;if(a=mt.call(arguments),"object"==typeof e&&(e=(n=e).type),!e)throw new Error("no event type specified");if(i=this._listeners[e]){n=t instanceof dt?t:this.createEvent(t),a[0]=n;var o=n.type;e!==o&&(n.type=e);try{r=this._invokeListeners(n,a,i)}finally{e!==o&&(n.type=o)}return void 0===r&&n.defaultPrevented&&(r=!1),r}},ft.prototype.handleError=function(e){return!1===this.fire("error",{error:e})},ft.prototype._destroy=function(){this._listeners={}},ft.prototype._invokeListeners=function(e,t,n){var i,r,a;for(i=0;(r=n[i])&&!e.cancelBubble;i++)a=this._invokeListener(e,t,r);return a},ft.prototype._invokeListener=function(e,t,n){var i;try{void 0!==(i=function(e,t){return e.apply(null,t)}(n.callback,t))&&(e.returnValue=i,e.stopPropagation()),!1===i&&e.preventDefault()}catch(e){if(!this.handleError(e))throw console.error("unhandled error in event listener"),console.error(e.stack),e}return i},ft.prototype._addListener=function(e,t){var n,i,r=this._getListeners(e);for(i=0;n=r[i];i++)if(n.priority<t.priority)return void r.splice(i,0,t);r.push(t)},ft.prototype._getListeners=function(e){var t=this._listeners[e];return t||(this._listeners[e]=t=[]),t},ft.prototype._removeListener=function(e,t){var n,i,r,a=this._getListeners(e);if(t)for(r=a.length-1;n=a[r];r--)(i=n.callback)!==t&&i.__fn!==t||a.splice(r,1);else a.length=0},dt.prototype.stopPropagation=function(){this.cancelBubble=!0},dt.prototype.preventDefault=function(){this.defaultPrevented=!0},dt.prototype.init=function(e){_(this,e||{})},gt.$inject=["eventBus","elementRegistry"],gt.prototype._getChildren=function(e){var t,n=this._elementRegistry.getGraphics(e);return e.parent?(t=function(e){return e.parentNode.childNodes[1]}(n))||(re(t=ce("g")).add("djs-children"),Y(n.parentNode,t)):t=n,t},gt.prototype._clear=function(e){var t=function(e){return K(".djs-visual",e)}(e);return P(t),t},gt.prototype._createContainer=function(e,t,n){var i=ce("g");re(i).add("djs-group"),void 0!==n?vt(i,t,t.childNodes[n]):Y(t,i);var r=ce("g");re(r).add("djs-element"),re(r).add("djs-"+e),Y(i,r);var a=ce("g");return re(a).add("djs-visual"),Y(r,a),r},gt.prototype.create=function(e,t,n){var i=this._getChildren(t.parent);return this._createContainer(e,i,n)},gt.prototype.updateContainments=function(e){var t=this,n=this._elementRegistry;h(m(e,function(e,t){return t.parent&&(e[t.parent.id]=t.parent),e},{}),function(e){var i=e.children;if(i){var r=t._getChildren(e);h(i.slice().reverse(),function(e){vt(n.getGraphics(e).parentNode,r)})}})},gt.prototype.drawShape=function(e,t){return this._eventBus.fire("render.shape",{gfx:e,element:t})},gt.prototype.getShapePath=function(e){return this._eventBus.fire("render.getShapePath",e)},gt.prototype.drawConnection=function(e,t){return this._eventBus.fire("render.connection",{gfx:e,element:t})},gt.prototype.getConnectionPath=function(e){return this._eventBus.fire("render.getConnectionPath",e)},gt.prototype.update=function(e,t,n){if(t.parent){var i=this._clear(n);if("shape"===e)this.drawShape(i,t),yt(n,t.x,t.y);else{if("connection"!==e)throw new Error("unknown type: "+e);this.drawConnection(i,t)}t.hidden?Q(n,"display","none"):Q(n,"display","block")}},gt.prototype.remove=function(e){oe(this._elementRegistry.getGraphics(e).parentNode)};var xt={__depends__:[Ve],__init__:["canvas"],canvas:["type",Ke],elementRegistry:["type",Ye],elementFactory:["type",ht],eventBus:["type",ft],graphicsFactory:["type",gt]};function bt(e){var t=[],n=[];function i(e){return t.indexOf(e)>=0}e.forEach(function e(r){i(r)||((r.__depends__||[]).forEach(e),i(r)||(function(e){t.push(e)}(r),(r.__init__||[]).forEach(function(e){n.push(e)})))});var r=new function e(t,n){n=n||{get:function(e,t){if(i.push(e),!1===t)return null;throw s('No provider for "'+e+'"!')}};var i=[],r=this._providers=Object.create(n._providers||null),a=this._instances=Object.create(null),o=a.injector=this,s=function(e){var t=i.join(" -> ");return i.length=0,new Error(t?e+" (Resolving: "+t+")":e)},l=function e(t,o){if(!r[t]&&-1!==t.indexOf(".")){for(var l=t.split("."),p=e(l.shift());l.length;)p=p[l.shift()];return p}if(Ne(a,t))return a[t];if(Ne(r,t)){if(-1!==i.indexOf(t))throw i.push(t),s("Cannot resolve circular dependency!");return i.push(t),a[t]=r[t][0](r[t][1]),i.pop(),a[t]}return n.get(t,o)},p=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("function"!=typeof e){if(!Ae(e))throw new Error('Cannot invoke "'+e+'". Expected a function!');e=Se(e.slice())}return{fn:e,dependencies:(e.$inject||ke(e)).map(function(e){return Ne(t,e)?t[e]:l(e)})}},c=function(e){var t=p(e),n=t.dependencies,i=t.fn;return new(Function.prototype.bind.apply(i,[null].concat(Te(n))))},u=function(e,t,n){var i=p(e,n),r=i.dependencies,a=i.fn;return a.call.apply(a,[t].concat(Te(r)))},h=function(e){return Se(function(t){return e.get(t)})},m={factory:u,type:c,value:function(e){return e}};t.forEach(function(t){function n(e,t){return"value"!==e&&Ae(t)&&(t=Se(t.slice())),t}if(t instanceof function(){var e=[];this.factory=function(t,n){return e.push([t,"factory",n]),this},this.value=function(t,n){return e.push([t,"value",n]),this},this.type=function(t,n){return e.push([t,"type",n]),this},this.forEach=function(t){e.forEach(t)}})t.forEach(function(e){var t=e[0],i=e[1],a=e[2];r[t]=[m[i],n(i,a),i]});else if("object"===(void 0===t?"undefined":Pe(t)))if(t.__exports__){var i=Object.keys(t).reduce(function(e,n){return"__"!==n.substring(0,2)&&(e[n]=t[n]),e},Object.create(null)),a=new e((t.__modules__||[]).concat([i]),o),s=Se(function(e){return a.get(e)});t.__exports__.forEach(function(e){r[e]=[s,e,"private",a]})}else Object.keys(t).forEach(function(e){if("private"!==t[e][2]){var i=t[e][0],a=t[e][1];r[e]=[m[i],n(i,a),i]}else r[e]=t[e]})}),this.get=l,this.invoke=u,this.instantiate=c,this.createChild=function(t,n){if(n&&n.length){var i,a,s,l,p=Object.create(null),c=Object.create(null),u=[],m=[],f=[];for(var d in r)i=r[d],-1!==n.indexOf(d)&&("private"===i[2]?-1===(a=u.indexOf(i[3]))?(s=i[3].createChild([],n),l=h(s),u.push(i[3]),m.push(s),f.push(l),p[d]=[l,d,"private",s]):p[d]=[f[a],d,"private",m[a]]:p[d]=[i[2],i[1]],c[d]=!0),"factory"!==i[2]&&"type"!==i[2]||!i[1].$scope||n.forEach(function(e){-1!==i[1].$scope.indexOf(e)&&(p[d]=[i[2],i[1]],c[e]=!0)});n.forEach(function(e){if(!c[e])throw new Error('No provider for "'+e+'". Cannot use provider from the parent!')}),t.unshift(p)}return new e(t,o)}}(t);return n.forEach(function(e){try{r["string"==typeof e?"get":"invoke"](e)}catch(e){throw console.error("Failed to instantiate component"),console.error(e.stack),e}}),r}function Et(e,t){this.injector=t=t||function(e){return bt([{config:["value",e=e||{}]},xt].concat(e.modules||[]))}(e),this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("diagram.init")}Et.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")},Et.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};var wt=Object.freeze({default:Et}),_t=wt&&Et||wt;function At(){}function St(e,t){this.model=e,this.properties=t}At.prototype.get=function(e){return this.$model.properties.get(this,e)},At.prototype.set=function(e,t){this.$model.properties.set(this,e,t)},St.prototype.createType=function(e){var t=this.model,n=this.properties,i=Object.create(At.prototype);h(e.properties,function(e){e.isMany||void 0===e.default||(i[e.name]=e.default)}),n.defineModel(i,t),n.defineDescriptor(i,e);var r=e.ns.name;function a(e){n.define(this,"$type",{value:r,enumerable:!0}),n.define(this,"$attrs",{value:{}}),n.define(this,"$parent",{writable:!0}),h(e,E(function(e,t){this.set(t,e)},this))}return a.prototype=i,a.hasType=i.$instanceOf=this.model.hasType,n.defineModel(a,t),n.defineDescriptor(a,e),a};var Rt={String:!0,Boolean:!0,Integer:!0,Real:!0,Element:!0},Ct={String:function(e){return e},Boolean:function(e){return"true"===e},Integer:function(e){return parseInt(e,10)},Real:function(e){return parseFloat(e,10)}};function Mt(e,t){var n=Ct[e];return n?n(t):t}function kt(e){return!!Rt[e]}function Pt(e){return!!Ct[e]}function Tt(e,t){var n,i,r=e.split(/:/);if(1===r.length)n=e,i=t;else{if(2!==r.length)throw new Error("expected <prefix:localName> or <localName>, got "+e);n=r[1],i=r[0]}return{name:e=(i?i+":":"")+n,prefix:i,localName:n}}function Nt(e){this.ns=e,this.name=e.name,this.allTypes=[],this.allTypesByName={},this.properties=[],this.propertiesByName={}}function Dt(e,t){this.packageMap={},this.typeMap={},this.packages=[],this.properties=t,h(e,E(this.registerPackage,this))}function Ot(e,t,n){var i=t[n];if(i in e)throw new Error("package with "+n+" <"+i+"> already defined")}function Bt(e){this.model=e}function Lt(e,t,n){Object.defineProperty(e,t.name,{enumerable:!t.isReference,writable:!0,value:n,configurable:!0})}function It(e){this.properties=new Bt(this),this.factory=new St(this,this.properties),this.registry=new Dt(e,this.properties),this.typeCache={}}Nt.prototype.build=function(){return e=this,t=["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"],n={},i=Object(e),h(t,function(t){t in i&&(n[t]=e[t])}),n;var e,t,n,i},Nt.prototype.addProperty=function(e,t,n){"boolean"==typeof t&&(n=t,t=void 0),this.addNamedProperty(e,!1!==n);var i=this.properties;void 0!==t?i.splice(t,0,e):i.push(e)},Nt.prototype.replaceProperty=function(e,t,n){var i=e.ns,r=this.properties,a=this.propertiesByName,o=e.name!==t.name;if(e.isId){if(!t.isId)throw new Error("property <"+t.ns.name+"> must be id property to refine <"+e.ns.name+">");this.setIdProperty(t,!1)}if(e.isBody){if(!t.isBody)throw new Error("property <"+t.ns.name+"> must be body property to refine <"+e.ns.name+">");this.setBodyProperty(t,!1)}var s=r.indexOf(e);if(-1===s)throw new Error("property <"+i.name+"> not found in property list");r.splice(s,1),this.addProperty(t,n?void 0:s,o),a[i.name]=a[i.localName]=t},Nt.prototype.redefineProperty=function(e,t,n){var i=e.ns.prefix,r=t.split("#"),a=Tt(r[0],i),o=Tt(r[1],a.prefix).name,s=this.propertiesByName[o];if(!s)throw new Error("refined property <"+o+"> not found");this.replaceProperty(s,e,n),delete e.redefines},Nt.prototype.addNamedProperty=function(e,t){var n=e.ns,i=this.propertiesByName;t&&(this.assertNotDefined(e,n.name),this.assertNotDefined(e,n.localName)),i[n.name]=i[n.localName]=e},Nt.prototype.removeNamedProperty=function(e){var t=e.ns,n=this.propertiesByName;delete n[t.name],delete n[t.localName]},Nt.prototype.setBodyProperty=function(e,t){if(t&&this.bodyProperty)throw new Error("body property defined multiple times (<"+this.bodyProperty.ns.name+">, <"+e.ns.name+">)");this.bodyProperty=e},Nt.prototype.setIdProperty=function(e,t){if(t&&this.idProperty)throw new Error("id property defined multiple times (<"+this.idProperty.ns.name+">, <"+e.ns.name+">)");this.idProperty=e},Nt.prototype.assertNotDefined=function(e,t){var n=e.name,i=this.propertiesByName[n];if(i)throw new Error("property <"+n+"> already defined; override of <"+i.definedBy.ns.name+"#"+i.ns.name+"> by <"+e.definedBy.ns.name+"#"+e.ns.name+"> not allowed without redefines")},Nt.prototype.hasProperty=function(e){return this.propertiesByName[e]},Nt.prototype.addTrait=function(e,t){var n=this.allTypesByName,i=this.allTypes,r=e.name;r in n||(h(e.properties,E(function(n){n=_({},n,{name:n.ns.localName,inherited:t}),Object.defineProperty(n,"definedBy",{value:e});var i=n.replaces,r=n.redefines;i||r?this.redefineProperty(n,i||r,i):(n.isBody&&this.setBodyProperty(n),n.isId&&this.setIdProperty(n),this.addProperty(n))},this)),i.push(e),n[r]=e)},Dt.prototype.getPackage=function(e){return this.packageMap[e]},Dt.prototype.getPackages=function(){return this.packages},Dt.prototype.registerPackage=function(e){e=_({},e);var t=this.packageMap;Ot(t,e,"prefix"),Ot(t,e,"uri"),h(e.types,E(function(t){this.registerType(t,e)},this)),t[e.uri]=t[e.prefix]=e,this.packages.push(e)},Dt.prototype.registerType=function(e,t){var n=Tt((e=_({},e,{superClass:(e.superClass||[]).slice(),extends:(e.extends||[]).slice(),properties:(e.properties||[]).slice(),meta:_(e.meta||{})})).name,t.prefix),i=n.name,r={};h(e.properties,E(function(e){var t=Tt(e.name,n.prefix),i=t.name;kt(e.type)||(e.type=Tt(e.type,t.prefix).name),_(e,{ns:t,name:i}),r[i]=e},this)),_(e,{ns:n,name:i,propertiesByName:r}),h(e.extends,E(function(e){var t=this.typeMap[e];t.traits=t.traits||[],t.traits.push(i)},this)),this.definePackage(e,t),this.typeMap[i]=e},Dt.prototype.mapTypes=function(e,t,n){var i=kt(e.name)?{name:e.name}:this.typeMap[e.name],r=this;function a(e){return o(e,!0)}function o(n,i){var a=Tt(n,kt(n)?"":e.prefix);r.mapTypes(a,t,i)}if(!i)throw new Error("unknown type <"+e.name+">");h(i.superClass,n?a:o),t(i,!n),h(i.traits,a)},Dt.prototype.getEffectiveDescriptor=function(e){var t=Tt(e),n=new Nt(t);this.mapTypes(t,function(e,t){n.addTrait(e,t)});var i=n.build();return this.definePackage(i,i.allTypes[i.allTypes.length-1].$pkg),i},Dt.prototype.definePackage=function(e,t){this.properties.define(e,"$pkg",{value:t})},Bt.prototype.set=function(e,t,n){var i=this.model.getPropertyDescriptor(e,t),r=i&&i.name;void 0===n?i?delete e[r]:delete e.$attrs[t]:i?r in e?e[r]=n:Lt(e,i,n):e.$attrs[t]=n},Bt.prototype.get=function(e,t){var n=this.model.getPropertyDescriptor(e,t);if(!n)return e.$attrs[t];var i=n.name;return!e[i]&&n.isMany&&Lt(e,n,[]),e[i]},Bt.prototype.define=function(e,t,n){Object.defineProperty(e,t,n)},Bt.prototype.defineDescriptor=function(e,t){this.define(e,"$descriptor",{value:t})},Bt.prototype.defineModel=function(e,t){this.define(e,"$model",{value:t})},It.prototype.create=function(e,t){var n=this.getType(e);if(!n)throw new Error("unknown type <"+e+">");return new n(t)},It.prototype.getType=function(e){var t=this.typeCache,n=l(e)?e:e.ns.name,i=t[n];return i||(e=this.registry.getEffectiveDescriptor(n),i=t[n]=this.factory.createType(e)),i},It.prototype.createAny=function(e,t,n){var i=Tt(e),r={$type:e,$instanceOf:function(e){return e===this.$type}},o={name:e,isGeneric:!0,ns:{prefix:i.prefix,localName:i.localName,uri:t}};return this.properties.defineDescriptor(r,o),this.properties.defineModel(r,this),this.properties.define(r,"$parent",{enumerable:!1,writable:!0}),h(n,function(e,t){a(e)&&void 0!==e.value?r[e.name]=e.value:r[t]=e}),r},It.prototype.getPackage=function(e){return this.registry.getPackage(e)},It.prototype.getPackages=function(){return this.registry.getPackages()},It.prototype.getElementDescriptor=function(e){return e.$descriptor},It.prototype.hasType=function(e,t){return void 0===t&&(t=e,e=this),t in e.$model.getElementDescriptor(e).allTypesByName},It.prototype.getPropertyDescriptor=function(e,t){return this.getElementDescriptor(e).propertiesByName[t]},It.prototype.getTypeDescriptor=function(e){return this.registry.typeMap[e]};var Ft=e(function(e,t){var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();
/**
* Tiny stack for browser or server
*
* @author Jason Mulligan <jason.mulligan@avoidwork.com>
* @copyright 2018
* @license BSD-3-Clause
* @link http://avoidwork.github.io/tiny-stack
* @version 1.1.0
*/
!function(t){var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}
/**
* Tiny stack for browser or server
*
* @author Jason Mulligan <jason.mulligan@avoidwork.com>
* @copyright 2018
* @license BSD-3-Clause
* @link http://avoidwork.github.io/tiny-stack
* @version 1.1.0
*/(this,e);for(var t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];this.data=[null].concat(n),this.top=this.data.length-1}return n(e,[{key:"clear",value:function(){return this.data.length=1,this.top=0,this}},{key:"empty",value:function(){return 0===this.top}},{key:"length",value:function(){return this.top}},{key:"peek",value:function(){return this.data[this.top]}},{key:"pop",value:function(){var e=void 0;return this.top>0&&(e=this.data.pop(),this.top--),e}},{key:"push",value:function(e){return this.data[++this.top]=e,this}},{key:"search",value:function(e){var t=this.data.indexOf(e);return-1===t?-1:this.data.length-t}}]),e}();e.exports=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return new(Function.prototype.bind.apply(i,[null].concat(t)))}}("undefined"!=typeof window&&window)}),jt=String.fromCharCode,Vt=Object.prototype.hasOwnProperty,Wt=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/gi,zt={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};function Gt(e,t,n,i){return i?Vt.call(zt,i)?zt[i]:"&"+i+";":jt(t||parseInt(n,16))}function $t(e){return e.length>3&&-1!==e.indexOf("&")?e.replace(Wt,Gt):e}Object.keys(zt).forEach(function(e){zt[e.toUpperCase()]=zt[e]});var Ht="http://www.w3.org/2001/XMLSchema-instance",Kt="xsi",Ut="xsi:type";function qt(e){return new Error(e)}function Yt(e){return"missing namespace for prefix <"+e+">"}function Xt(e){return{get:e,enumerable:!0}}function Zt(e){var t,n={};for(t in e)n[t]=e[t];return n}function Jt(e){return e+"$uri"}function Qt(){return{line:0,column:0}}function en(e){throw e}function tn(e){if(!this)return new tn(e);var t,n,i,r,a,o,s,l,p,c=e&&e.proxy,u=en,h=Qt,m=!1,f=!1,d=null,y=!1;function g(e){e instanceof Error||(e=qt(e)),d=e,u(e,h)}function v(e){a&&(e instanceof Error||(e=qt(e)),a(e,h))}this.on=function(e,p){if("function"!=typeof p)throw qt("required args <name, cb>");switch(e){case"openTag":n=p;break;case"text":t=p;break;case"closeTag":i=p;break;case"error":u=p;break;case"warn":a=p;break;case"cdata":r=p;break;case"attention":l=p;break;case"question":s=p;break;case"comment":o=p;break;default:throw qt("unsupported event: "+e)}return this},this.ns=function(e){if(void 0===e&&(e={}),"object"!=typeof e)throw qt("required args <nsMap={}>");var t,n={};for(t in e)n[t]=e[t];return n[Ht]=Kt,f=!0,p=n,this},this.parse=function(e){if("string"!=typeof e)throw qt("required args <xml=string>");return d=null,function(e){var a,u,d,x,b,E,w,_,A,S,R=f?[]:null,C=f?function(e){var t,n,i={};for(t in e)i[n=e[t]]=n,i[Jt(n)]=t;return i}(p):null,M=[],k=0,P=!1,T=!1,N=0,D=0,O="",B=0;function L(){if(null!==S)return S;var e,t,n,i,r,a,o,s,l,c,u,h=f&&C.xmlns,d=f&&m?[]:null,y=B,g=O,x=g.length,b={},E={};e:for(;y<x;y++)if(l=!1,!(32===(c=g.charCodeAt(y))||c<14&&c>8)){for((c<65||c>122||c>90&&c<97)&&95!==c&&58!==c&&(v("illegal first char attribute name"),l=!0),u=y+1;u<x;u++)if(!((c=g.charCodeAt(u))>96&&c<123||c>64&&c<91||c>47&&c<59||46===c||45===c||95===c)){if(32===c||c<14&&c>8){v("missing attribute value"),y=u;continue e}if(61===c)break;v("illegal attribute name char"),l=!0}if("xmlns:xmlns"===(s=g.substring(y,u))&&(v("illegal declaration of xmlns"),l=!0),34===(c=g.charCodeAt(u+1)))-1===(u=g.indexOf('"',y=u+2))&&-1!==(u=g.indexOf("'",y))&&(v("attribute value quote missmatch"),l=!0);else if(39===c)-1===(u=g.indexOf("'",y=u+2))&&-1!==(u=g.indexOf('"',y))&&(v("attribute value quote missmatch"),l=!0);else for(v("missing attribute value quotes"),l=!0,u+=1;u<x&&!(32===(c=g.charCodeAt(u+1))||c<14&&c>8);u++);for(-1===u&&(v("missing closing quotes"),u=x,l=!0),l||(a=g.substring(y,u)),y=u;u+1<x&&!(32===(c=g.charCodeAt(u+1))||c<14&&c>8);u++)y===u&&(v("illegal character after attribute end"),l=!0);if(y=u+1,!l)if(s in E)v("attribute <"+s+"> already defined");else if(E[s]=!0,f)if(m){if(null!==(r="xmlns"===s?"xmlns":120===s.charCodeAt(0)&&"xmlns:"===s.substr(0,6)?s.substr(6):null)){if(e=$t(a),t=Jt(r),!(o=p[e])){if("xmlns"===r||t in C&&C[t]!==e)do{o="ns"+k++}while(void 0!==C[o]);else o=r;p[e]=o}C[r]!==o&&(i||(C=Zt(C),i=!0),C[r]=o,"xmlns"===r&&(C[Jt(o)]=e,h=o),C[t]=e),b[s]=a;continue}d.push(s,a)}else-1!==(c=s.indexOf(":"))?(n=C[s.substring(0,c)])?((s=h===n?s.substr(c+1):n+s.substr(c))===Ut&&(-1!==(c=a.indexOf(":"))?(n=a.substring(0,c),n=C[n]||n,a=n+a.substring(c)):a=h+":"+a),b[s]=a):v(Yt(s.substring(0,c))):b[s]=a;else b[s]=a}if(m)for(y=0,x=d.length;y<x;y++){if(s=d[y++],a=d[y],-1!==(c=s.indexOf(":"))){if(!(n=C[s.substring(0,c)])){v(Yt(s.substring(0,c)));continue}(s=h===n?s.substr(c+1):n+s.substr(c))===Ut&&(-1!==(c=a.indexOf(":"))?(n=a.substring(0,c),n=C[n]||n,a=n+a.substring(c)):a=h+":"+a)}b[s]=a}return S=b}h=function(){for(var t,n,i=/(\r\n|\r|\n)/g,r=0,a=0,o=0,s=D;N>=o&&(t=i.exec(e))&&!((s=t[0].length+t.index)>N);)r+=1,o=s;return-1==N?(a=s,n=""):(a=N-o,n=-1==D?e.substring(N):e.substring(N,D+1)),{data:n,line:r,column:a}},c&&(A=Object.create({},{name:Xt(function(){return w}),originalName:Xt(function(){return _}),attrs:Xt(L),ns:Xt(function(){return C})}));for(;-1!==D;){if(-1===(N=60===e.charCodeAt(D)?D:e.indexOf("<",D)))return M.length?g("unexpected end of file"):0===D?g("missing start tag"):void 0;if(D!==N&&t&&(t(e.substring(D,N),$t,h),y))return;if(33!==(b=e.charCodeAt(N+1)))if(63!==b){if(-1==(D=e.indexOf(">",N+1)))return g("unclosed tag");if(S={},47===b){if(P=!1,T=!0,!M.length)return g("missing open tag");if(u=w=M.pop(),x=N+2+u.length,e.substring(N+2,x)!==u)return g("closing tag mismatch");for(;x<D;x++)if(!(32===(b=e.charCodeAt(x))||b>8&&b<14))return g("close tag")}else{if(47===e.charCodeAt(D-1)?(u=w=e.substring(N+1,D-1),P=!0,T=!0):(u=w=e.substring(N+1,D),P=!0,T=!1),!(b>96&&b<123||b>64&&b<91||95===b||58===b))return g("illegal first char nodeName");for(x=1,d=u.length;x<d;x++)if(!((b=u.charCodeAt(x))>96&&b<123||b>64&&b<91||b>47&&b<59||45===b||95===b)){if(32===b||b<14&&b>8){w=u.substring(0,x),S=null;break}return g("invalid nodeName")}T||M.push(w)}if(f){if(a=C,P&&(T||R.push(a),null===S&&(m=-1!==u.indexOf("xmlns",x))&&(B=x,O=u,L(),m=!1)),_=w,-1!==(b=w.indexOf(":"))){if(!(E=C[w.substring(0,b)]))return g("missing namespace on <"+_+">");w=w.substr(b+1)}else E=C.xmlns;E&&(w=E+":"+w)}if(P&&(B=x,O=u,n&&(c?n(A,$t,T,h):n(w,L,$t,T,h),y)))return;if(T){if(i&&(i(c?A:w,$t,P,h),y))return;f&&(C=P?a:R.pop())}D+=1}else{if(-1===(D=e.indexOf("?>",N)))return g("unclosed question");if(s&&(s(e.substring(N,D+2),h),y