bpmn-js
Version:
A bpmn 2.0 toolkit and web modeler
10 lines • 158 kB
JavaScript
/*! bpmn-js - bpmn-viewer v1.1.0 | 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";var e=Object.prototype.toString,t=Object.prototype.hasOwnProperty;function n(t){return"[object Array]"===e.call(t)}function i(t){return"[object Object]"===e.call(t)}function r(t){return"[object Number]"===e.call(t)}function a(t){return"[object Function]"===e.call(t)}function o(t){return"[object String]"===e.call(t)}function s(e,n){return t.call(e,n)}function p(e,t){var n;return t=function(e){return a(e)?e:function(t){return t===e}}(t),c(e,function(e,i){if(t(e,i))return n=e,!1}),n}function l(e,t){var n=[];return c(e,function(e,i){t(e,i)&&n.push(e)}),n}function c(e,t){if(null!==(i=e)&&void 0!==i){var i,r=n(e)?y:d;for(var a in e){if(s(e,a))if(!1===t(e[a],r(a)))return}}}function u(e,t,n){return c(e,function(e,i){n=t(n,e,i)}),n}function h(e,t){return u(e,function(e,n,i){return e&&t(n,i)},!0)}function m(e,t){var n=[];return c(e,function(e,i){n.push(t(e,i))}),n}function f(e){return function(t){return h(e,function(e,n){return t[n]===e})}}function d(e){return e}function y(e){return Number(e)}var g=Array.prototype.slice;function v(e,t){var n;return function(){var i=g.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 x(e,t){return e.bind(t)}var E=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 b(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return E.apply(void 0,[e].concat(n))}function w(e,t){var n={},i=Object(e);return c(t,function(t){t in i&&(n[t]=e[t])}),n}var A=[].indexOf,_=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},S=/\s+/,R=Object.prototype.toString;function C(e){return new M(e)}function M(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function k(e){for(var t;e.childNodes.length;)t=e.childNodes[0],e.removeChild(t);return e}M.prototype.add=function(e){if(this.list)return this.list.add(e),this;var t=this.array();return~_(t,e)||t.push(e),this.el.className=t.join(" "),this},M.prototype.remove=function(e){if("[object RegExp]"==R.call(e))return this.removeMatching(e);if(this.list)return this.list.remove(e),this;var t=this.array(),n=_(t,e);return~n&&t.splice(n,1),this.el.className=t.join(" "),this},M.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},M.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)},M.prototype.array=function(){var e=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(S);return""===e[0]&&e.shift(),e},M.prototype.has=M.prototype.contains=function(e){return this.list?this.list.contains(e):!!~_(this.array(),e)};var P=Element.prototype,T=P.matchesSelector||P.webkitMatchesSelector||P.mozMatchesSelector||P.msMatchesSelector||P.oMatchesSelector,N=function(e,t){if(T)return T.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 D,O=window.addEventListener?"addEventListener":"attachEvent",B=window.removeEventListener?"removeEventListener":"detachEvent",L="addEventListener"!==O?"on":"",I={bind:function(e,t,n,i){return e[O](L+t,n,i||!1),n},unbind:function(e,t,n,i){return e[B](L+t,n,i||!1),n}},F=["focus","blur"],j={bind:function(e,t,n,i,r){return-1!==F.indexOf(n)&&(r=!0),I.bind(e,n,function(n){var r=n.target||n.srcElement;n.delegateTarget=function(e,t,n){for(var i=n?e:e.parentNode;i&&i!==document;){if(N(i,t))return i;i=i.parentNode}}(r,t,!0),n.delegateTarget&&i.call(e,n)},r)},unbind:function(e,t,n,i){-1!==F.indexOf(t)&&(i=!0),I.unbind(e,t,n,i)}},V=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=z[i]||z._default,o=a[0],s=a[1],p=a[2];(r=t.createElement("div")).innerHTML=s+e+p;for(;o--;)r=r.lastChild;if(r.firstChild==r.lastChild)return r.removeChild(r.firstChild);var l=t.createDocumentFragment();for(;r.firstChild;)l.appendChild(r.removeChild(r.firstChild));return l},W=!1;"undefined"!=typeof document&&((D=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',W=!D.getElementsByTagName("link").length,D=void 0);var z={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:W?[1,"X<div>","</div>"]:[0,"",""]};z.td=z.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],z.option=z.optgroup=[1,'<select multiple="multiple">',"</select>"],z.thead=z.tbody=z.colgroup=z.caption=z.tfoot=[1,"<table>","</table>"],z.polyline=z.ellipse=z.polygon=z.circle=z.text=z.line=z.path=z.rect=z.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var G="undefined"!=typeof Element?Element.prototype:{};G.matches||G.matchesSelector||G.webkitMatchesSelector||G.mozMatchesSelector||G.msMatchesSelector||G.oMatchesSelector;function $(e,t){return(t=t||document).querySelector(e)}function H(e){e.parentNode&&e.parentNode.removeChild(e)}function K(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 U(e,t){return K(t,e),e}var q=2,Y={"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":q,"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":q,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function X(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=Y[i];r?(r===q&&"number"==typeof n&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function Z(e,t,n){if("string"==typeof t){if(void 0===n)return function(e,t){return Y[t]?e.style[t]:e.getAttributeNS(null,t)}(e,t);X(e,t,n)}else!function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)X(e,i,t[i])}(e,t);return e}function J(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 Q=/\s+/,ee=Object.prototype.toString;function te(e){return void 0!==e}function ne(e){return new ie(e)}function ie(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function re(e){var t=e.parentNode;return t&&t.removeChild(e),e}ie.prototype.add=function(e){if(this.list)return this.list.add(e),this;var t=this.array();return~J(t,e)||t.push(e),te(this.el.className.baseVal)?this.el.className.baseVal=t.join(" "):this.el.className=t.join(" "),this},ie.prototype.remove=function(e){if("[object RegExp]"===ee.call(e))return this.removeMatching(e);if(this.list)return this.list.remove(e),this;var t=this.array(),n=J(t,e);return~n&&t.splice(n,1),this.el.className.baseVal=t.join(" "),this},ie.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},ie.prototype.toggle=function(e,t){return this.list?(te(t)?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this):(te(t)?t?this.add(e):this.remove(e):this.has(e)?this.remove(e):this.add(e),this)},ie.prototype.array=function(){var e=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(Q);return""===e[0]&&e.shift(),e},ie.prototype.has=ie.prototype.contains=function(e){return this.list?this.list.contains(e):!!~J(this.array(),e)};var ae={svg:"http://www.w3.org/2000/svg"},oe='<svg xmlns="'+ae.svg+'"';function se(e){return"<svg"===e.substring(0,4)?-1===e.indexOf(ae.svg)&&(e=oe+e.substring(4)):e=oe+">"+e+"</svg>",function(e){var t;return(t=new DOMParser).async=!1,t.parseFromString(e,"text/xml")}(e)}function pe(e,t){var n;return"<"===e.charAt(0)?(n=se(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(ae.svg,e),t&&Z(n,t),n}var le=pe("svg");function ce(e,t,n,i,r,a){var o=le.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 ue(e){return e?le.createSVGTransformFromMatrix(e):le.createSVGTransform()}var he=/([&<>]{1})/g,me=/([\n\r"]{1})/g,fe={"&":"&","<":"<",">":">",'"':"'"};function de(e,t){return e.replace(t,function(e,t){return fe[t]||t})}function ye(e,t){var n,i,r,a,o;switch(e.nodeType){case 3:t.push(de(e.textContent,he));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,'="',de(a.value,me),'"');if(e.hasChildNodes()){for(t.push(">"),n=0,i=(o=e.childNodes).length;n<i;++n)ye(o.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("\x3c!--",de(e.nodeValue,he),"--\x3e");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function ge(e,t){var n,i=se(t).documentElement;if(function(e){for(var t;t=e.firstChild;)re(t)}(e),t)for(n=i.firstChild;n;)K(n,e),n=n.nextSibling}function ve(e,t){if(void 0!==t){try{ge(e,t)}catch(e){throw new Error("error parsing SVG: "+e.message)}return e}return function(e){for(var t=e.firstChild,n=[];t;)ye(t,n),t=t.nextSibling;return n.join("")}(e)}function xe(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function Ee(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(xe(e,i));e.consolidate()}(n,t):n.initialize(xe(n,t))}var be=/^class /;function we(e){return"[object Array]"===Object.prototype.toString.call(e)}function Ae(){var e=Array.prototype.slice.call(arguments);1===e.length&&we(e[0])&&(e=e[0]);var t=e.pop();return t.$inject=e,t}var _e=/constructor\s*[^(]*\(\s*([^)]*)\)/m,Se=/^function\s*[^(]*\(\s*([^)]*)\)/m,Re=/\/\*([^*]*)\*\//m;function Ce(e){if("function"!=typeof e)throw new Error('Cannot annotate "'+e+'". Expected a function!');var t=e.toString().match(function(e){return be.test(e.toString())}(e)?_e:Se);return t&&t[1]&&t[1].split(",").map(function(e){return(t=e.match(Re))?t[1].trim():e.trim()})||[]}var Me="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 ke(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 Pe(e,t){return Object.hasOwnProperty.call(e,t)}"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function Te(e,t){return e(t={exports:{}},t.exports),t.exports}var Ne=Te(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}}),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=pe("polyline");return Z(n,{points:Le(e)}),t&&Z(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})}Ne(je,Oe),je.prototype.canRender=function(){return!0},je.prototype.drawShape=function(e,t){var n=pe("rect");return Z(n,{x:0,y:0,width:t.width||0,height:t.height||0}),Z(n,this.SHAPE_STYLE),U(e,n),n},je.prototype.drawConnection=function(e,t){var n=Ie(t.waypoints,this.CONNECTION_STYLE);return U(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 b(this.style(t,n),{class:e})},this.style=function(t,i){n(t)||i||(i=t,t=[]);var r=u(t,function(t,n){return b(t,e[n]||{})},{});return i?b(r,i):r},this.computeStyle=function(e,i,r){return n(i)||(r=i,i=[]),t.style(i||[],b({},r,e||{}))}}]};function We(e,t){var i,r,a,o;return t=!!t,n(e)||(e=[e]),c(e,function(e){var n=e;e.waypoints&&!t&&(n=We(e.waypoints,!0));var s=n.x,p=n.y,l=n.height||0,c=n.width||0;(s<i||void 0===i)&&(i=s),(p<r||void 0===r)&&(r=p),(s+c>a||void 0===a)&&(a=s+c),(p+l>o||void 0===o)&&(o=p+l)}),{x:i,y:r,height:o-r,width:a-i}}function ze(e,t){return Math.round(e*t)/t}function Ge(e){return r(e)?e+"px":e}function $e(e,t,n){var i=pe("g");ne(i).add(t);var r=void 0!==n?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[r]),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=b({},{width:"100%",height:"100%"},e)).container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container"),b(n.style,{position:"relative",overflow:"hidden",width:Ge(e.width),height:Ge(e.height)}),t.appendChild(n),n}(e),i=this._svg=pe("svg");Z(i,{width:"100%",height:"100%"}),U(n,i);var r=this._viewport=$e(i,"viewport");this._layers={},!1!==e.deferUpdate&&(this._viewboxChanged=v(x(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=u(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])&&(c([i.gfx,i.secondaryGfx],function(e){e&&(n?ne(e).add(t):ne(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)),ne(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(!h(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,p=this.getSize();return e?(this._changeViewbox(function(){r=Math.min(p.width/e.width,p.height/e.height);var t=this._svg.createSVGMatrix().scale(r).translate(-e.x,-e.y);Ee(s,t)}),e):(t=this.getDefaultLayer().getBBox(),n=(i=Ee(s))?i.matrix:ce(),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:p.width/r,height:p.height/r,scale:r,inner:{width:t.width,height:t.height,x:t.x,y:t.y},outer:p})},Ke.prototype.scroll=function(e){var t=this._viewport,n=t.getCTM();return e&&this._changeViewbox(function(){e=b({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),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,p=o.createSVGMatrix(),l=o.createSVGPoint(),c=(i=s.getCTM()).a;return t?(n=b(l,t).matrixTransform(i.inverse()),r=p.translate(n.x,n.y).scale(1/c*e).translate(-n.x,-n.y),a=i.multiply(r)):a=p.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),Z(t,qe,i),n&&Z(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&&(Z(i.gfx,qe,""),i.secondaryGfx&&Z(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&&Z(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){this.contains(e)||(this.push(e),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){Object.defineProperty(n,t.name,{enumerable:t.enumerable,value:Xe.extend(n[t.name]||[],e,t,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,{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:"label",enumerable:!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}),tt.bind(this,"parent"),nt.bind(this,"label"),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 pt(){st.call(this)}function lt(){st.call(this),nt.bind(this,"labelTarget")}function ct(){ot.call(this),rt.bind(this,"source"),at.bind(this,"target")}Ne(st,ot),Ne(pt,st),Ne(lt,st),Ne(ct,ot);var ut={connection:ct,shape:st,label:lt,root:pt};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=b({},t||{})).id||(t.id=e+"_"+this._uid++),function(e,t){var n=ut[e];if(!n)throw new Error("unknown type: <"+e+">");return b(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=ue();i.setTranslate(t,n),Ee(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,i,o){if(e=n(e)?e:[e],a(t)&&(o=i,i=t,t=1e3),!r(t))throw new Error("priority must be a number");var s=i;o&&((s=x(i,o)).__fn=i.__fn||i);var p=this,l={priority:t,callback:s};e.forEach(function(e){p._addListener(e,l)})},ft.prototype.once=function(e,t,n,i){var o=this;if(a(t)&&(i=n,n=t,t=1e3),!r(t))throw new Error("priority must be a number");function s(){return o.off(e,s),n.apply(i,arguments)}s.__fn=n,this.on(e,t,s)},ft.prototype.off=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},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},dt.prototype.stopPropagation=function(){this.cancelBubble=!0},dt.prototype.preventDefault=function(){this.defaultPrevented=!0},dt.prototype.init=function(e){b(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))||(ne(t=pe("g")).add("djs-children"),U(n.parentNode,t)):t=n,t},gt.prototype._clear=function(e){var t=function(e){return $(".djs-visual",e)}(e);return k(t),t},gt.prototype._createContainer=function(e,t,n){var i=pe("g");ne(i).add("djs-group"),void 0!==n?vt(i,t,t.childNodes[n]):U(t,i);var r=pe("g");ne(r).add("djs-element"),ne(r).add("djs-"+e),U(i,r);var a=pe("g");return ne(a).add("djs-visual"),U(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;c(u(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);c(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?Z(n,"display","none"):Z(n,"display","block")}},gt.prototype.remove=function(e){re(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 Et(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)},p=function e(t,o){if(!r[t]&&-1!==t.indexOf(".")){for(var p=t.split("."),l=e(p.shift());p.length;)l=l[p.shift()];return l}if(Pe(a,t))return a[t];if(Pe(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)},l=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("function"!=typeof e){if(!we(e))throw new Error('Cannot invoke "'+e+'". Expected a function!');e=Ae(e.slice())}return{fn:e,dependencies:(e.$inject||Ce(e)).map(function(e){return Pe(t,e)?t[e]:p(e)})}},c=function(e){var t=l(e),n=t.dependencies,i=t.fn;return new(Function.prototype.bind.apply(i,[null].concat(ke(n))))},u=function(e,t,n){var i=l(e,n),r=i.dependencies,a=i.fn;return a.call.apply(a,[t].concat(ke(r)))},h=function(e){return Ae(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&&we(t)&&(t=Ae(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":Me(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=Ae(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=p,this.invoke=u,this.instantiate=c,this.createChild=function(t,n){if(n&&n.length){var i,a,s,p,l=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),p=h(s),u.push(i[3]),m.push(s),f.push(p),l[d]=[p,d,"private",s]):l[d]=[f[a],d,"private",m[a]]:l[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)&&(l[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(l)}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 bt(e,t){this.injector=t=t||function(e){return Et([{config:["value",e=e||{}]},xt].concat(e.modules||[]))}(e),this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("diagram.init")}bt.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")},bt.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};var wt=Object.freeze({default:bt}),At=wt&&bt||wt;function _t(){}function St(e,t){this.model=e,this.properties=t}_t.prototype.get=function(e){return this.$model.properties.get(this,e)},_t.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(_t.prototype);c(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}),c(e,x(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,c(e,x(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 w(this,["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"])},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||(c(e.properties,x(function(n){n=b({},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=b({},e);var t=this.packageMap;Ot(t,e,"prefix"),Ot(t,e,"uri"),c(e.types,x(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=b({},e,{superClass:(e.superClass||[]).slice(),extends:(e.extends||[]).slice(),properties:(e.properties||[]).slice(),meta:b(e.meta||{})})).name,t.prefix),i=n.name,r={};c(e.properties,x(function(e){var t=Tt(e.name,n.prefix),i=t.name;kt(e.type)||(e.type=Tt(e.type,t.prefix).name),b(e,{ns:t,name:i}),r[i]=e},this)),b(e,{ns:n,name:i,propertiesByName:r}),c(e.extends,x(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+">");c(i.superClass,n?a:o),t(i,!n),c(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=o(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 r=Tt(e),a={$type:e,$instanceOf:function(e){return e===this.$type}},o={name:e,isGeneric:!0,ns:{prefix:r.prefix,localName:r.localName,uri:t}};return this.properties.defineDescriptor(a,o),this.properties.defineModel(a,this),this.properties.define(a,"$parent",{enumerable:!1,writable:!0}),c(n,function(e,t){i(e)&&void 0!==e.value?a[e.name]=e.value:a[t]=e}),a},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=Te(function(e,t){
/**
* Tiny stack for browser or server
*
* @copyright 2015 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 1.0.0
*/
!function(t){function n(){this.data=[null],this.top=0}n.prototype.clear=function(){return this.data=[null],this.top=0,this},n.prototype.length=function(){return this.top},n.prototype.empty=function(){return 0===this.top},n.prototype.peek=function(){return this.data[this.top]},n.prototype.pop=function(){return this.top>0?(this.top--,this.data.pop()):void 0},n.prototype.push=function(e){return this.data[++this.top]=e,this},n.prototype.search=function(e){var t=this.data.indexOf(e);return-1===t?-1:this.data.length-t},e.exports=function(){return new n}}()}),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,p,l,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,l){if("function"!=typeof l)throw qt("required args <name, cb>");switch(e){case"openTag":n=l;break;case"text":t=l;break;case"closeTag":i=l;break;case"error":u=l;break;case"warn":a=l;break;case"cdata":r=l;break;case"attention":p=l;break;case"question":s=l;break;case"comment":o=l;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,l=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,E,b,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}(l):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,p,c,u,h=f&&C.xmlns,d=f&&m?[]:null,y=B,g=O,x=g.length,E={},b={};e:for(;y<x;y++)if(p=!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"),p=!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"),p=!0}if("xmlns:xmlns"===(s=g.substring(y,u))&&(v("illegal declaration of xmlns"),p=!0),34===(c=g.charCodeAt(u+1)))-1===(u=g.indexOf('"',y=u+2))&&-1!==(u=g.indexOf("'",y))&&(v("attribute value quote missmatch"),p=!0);else if(39===c)-1===(u=g.indexOf("'",y=u+2))&&-1!==(u=g.indexOf('"',y))&&(v("attribute value quote missmatch"),p=!0);else for(v("missing attribute value quotes"),p=!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,p=!0),p||(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"),p=!0);if(y=u+1,!p)if(s in b)v("attribute <"+s+"> already defined");else if(b[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=l[e])){if("xmlns"===r||t in C&&C[t]!==e)do{o="ns"+k++}while(void 0!==C[o]);else o=r;l[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),E[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),E[s]=a):v(Yt(s.substring(0,c))):E[s]=a;else E[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)}E[s]=a}return S=E}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&&(_=Object.create({},{name:Xt(function(){return w}),originalName:Xt(function(){return A}),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!==(E=e.charCodeAt(N+1)))if(63!==E){if(-1==(D=e.indexOf(">",N+1)))return g("unclosed tag");if(S={},47===E){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===(E=e.charCodeAt(x))||E>8&&E<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),!(E>96&&E<123||E>64&&E<91||95===E||58===E))return g("illegal first char nodeName");for(x=1,d=u.length;x<d;x++)if(!((E=u.charCodeAt(x))>96&&E<123||E>64&&E<91||E>47&&E<59||45===E||95===E)){if(32===E||E<14&&E>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)),A=w,-1!==(E=w.indexOf(":"))){if(!(b=C[w.substring(0,E)]))return g("missing namespace on <"+A+">");w=w.substr(E+1)}else b=C.xmlns;b&&(w=b+":"+w)}if(P&&(B=x,O=u,n&&(c?n(_,$t,T,h):n(w,L,$t,T,h),y)))return;if(T){if(i&&(i(c?_: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))return;D+=2}else{if(91===(E=e.charCodeAt(N+2))&&"CDATA["===e.substr(N+3,6)){if(-1===(D=e.indexOf("]]>",N)))return g("unclosed cdata");if(r&&(r(e.substring(N+9,D),h),y))return;D+=3;continue}if(45===E&&45===e.charCodeAt(N+3)){if(-1===(D=e.indexOf("--\x3e",N)))return g("unclosed comment");if(o&&(o(e.substring(N+4,D),$t,h),y))return;D+=3;continue}if(-1===(D=e.indexOf(">",N+1)))return g("unclosed tag");if(p&&(p(e.substring(N,D+1),$t,h),y))return;D+=1}}}(e),h=Qt,y=!1,d},this.stop=function(){y=!0}}function nn(e){return e.xml&&"lowerCase"===e.xml.tagAlias}var rn={xsi:"http://www.w3.org/2001/XMLSchema-instance"},an="xsi:type";function on(e){return e.xml&&e.xml.serialize}function sn(e){return on(e)===an}function pn(e,t){return nn(t)?e.prefix+":"+((n=e.localName).charAt(0).toUpperCase()+n.slice(1)):e.name;var n}function ln(e){return new Error(e)}function cn(e){return e.$descriptor}function un(){}function hn(){}function mn(){}function fn(e,t){this.property=e,this.context=t}function dn(e,t){this.element=t,this.propertyDesc=e}function yn(){}function gn(e,t,n){this.model=e,this.type=e.getType(t),this.context=n}function vn(e,t,n){gn.call(this,e,t,n)}function xn(e,t,n){this.model=e,this.context=n}function En(e){e instanceof It&&(e={model:e}),b(this,{lax:!1},e)}un.prototype.handleEnd=function(){},un.prototype.handleText=function(){},un.prototype.handleNode=function(){},hn.prototype=Object.create(u