H A D | dmn-modeler.production.min.js | 191 `,this._current.container)},nd.prototype.open=function(e,t,n,i){if(!e)throw new Error("target is missing");if(!t)throw new Error("providers for <"+t+"> not found");if(!n)throw new Error("position is missing");this.isOpen()&&this.close();const{entries:o,headerEntries:r,emptyPlaceholder:s}=this._getContext(e,t);this._current={position:n,providerId:t,target:e,entries:o,headerEntries:r,emptyPlaceholder:s,container:this._createContainer({provider:t}),options:i},this._emit("open"),this._bindAutoClose(),this._render()},nd.prototype.refresh=function(){if(!this.isOpen())return;const{target:e,providerId:t}=this._current,{entries:n,headerEntries:i,emptyPlaceholder:o}=this._getContext(e,t);this._current={...this._current,entries:n,headerEntries:i,emptyPlaceholder:o},this._emit("refresh"),this._render()},nd.prototype._getContext=function(e,t){const n=this._getProviders(t);if(!n||!n.length)throw new Error("provider for <"+t+"> not found");const i=this._getEntries(e,n),o=this._getHeaderEntries(e,n);return{entries:i,headerEntries:o,emptyPlaceholder:this._getEmptyPlaceholder(n),empty:!(Object.keys(i).length||Object.keys(o).length)}},nd.prototype.close=function(){this.isOpen()&&(this._emit("close"),this.reset(),this._canvas.restoreFocus(),this._current=null)},nd.prototype.reset=function(){const e=this._current.container;mh(null,e),en(e)},nd.prototype._emit=function(e,t){this._eventBus.fire(`popupMenu.${e}`,t)},nd.prototype._onOpened=function(){this._emit("opened")},nd.prototype._onClosed=function(){this._emit("closed")},nd.prototype._createContainer=function(e){var t=this._canvas.getContainer();const n=Gt(`<div class="djs-popup-parent djs-scrollable" data-popup=${e.provider}></div>`);return t.appendChild(n),n},nd.prototype._bindAutoClose=function(){this._eventBus.once(td,this.close,this)},nd.prototype._unbindAutoClose=function(){this._eventBus.off(td,this.close,this)},nd.prototype._updateScale=function(){var e,t,n=this._canvas.zoom(),o=this._config.scale,r=n;return!0!==o&&(!1===o?(e=1,t=1):(e=o.min,t=o.max),i(e)&&n<e&&(r=e),i(t)&&n>t&&(r=t)),r},nd.prototype._ensureVisible=function(e,t){var n=document.documentElement.getBoundingClientRect(),i=e.getBoundingClientRect(),o={},r=t.x,s=t.y;return t.x+i.width>n.width&&(o.x=!0),t.y+i.height>n.height&&(o.y=!0),o.x&&o.y?(r=t.x-i.width,s=t.y-i.height):o.x?(r=t.x-i.width,s=t.y):o.y&&t.y<i.height?(r=t.x,s=10):o.y&&(r=t.x,s=t.y-i.height),t.y<n.top&&(s=t.y+i.height),{x:r,y:s}},nd.prototype.isEmpty=function(e,t){if(!e)throw new Error("target is missing");if(!t)throw new Error("provider ID is missing");const n=this._getProviders(t);return!n||!n.length||this._getContext(e,t).empty},nd.prototype.registerProvider=function(e,t,n){n||(n=t,t=1e3),this._eventBus.on("popupMenu.getProviders."+e,t,(function(e){e.providers.push(n)}))},nd.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"popupMenu.getProviders."+e,providers:[]});return this._eventBus.fire(t),t.providers},nd.prototype._getEntries=function(e,t){var n={};return p(t,(function(t){if(t.getPopupMenuEntries){var i=t.getPopupMenuEntries(e);l(i)?n=i(n):p(i,(function(e,t){n[t]=e}))}else p(t.getEntries(e),(function(e){var t=e.id;if(!t)throw new Error("entry ID is missing");n[t]=P(e,["id"])}))})),n},nd.prototype._getHeaderEntries=function(e,t){var n={};return p(t,(function(t){if(t.getPopupMenuHeaderEntries){var i=t.getPopupMenuHeaderEntries(e);l(i)?n=i(n):p(i,(function(e,t){n[t]=e}))}else{if(!t.getHeaderEntries)return;p(t.getHeaderEntries(e),(function(e){var t=e.id;if(!t)throw new Error("entry ID is missing");n[t]=P(e,["id"])}))}})),n},nd.prototype._getEmptyPlaceholder=function(e){const t=e.find((e=>l(e.getEmptyPlaceholder)));return t&&t.getEmptyPlaceholder()},nd.prototype.isOpen=function(){return!!this._current},nd.prototype.trigger=function(e,t,n="click"){if(e.preventDefault(),!t){let n=Pt(Bt(e.delegateTarget||e.target,".entry",!0),"data-id");t={id:n,...this._getEntry(n)}}const i=t.action;if(!1!==this._emit("trigger",{entry:t,event:e}))if(l(i)){if("click"===n)return i(e,t)}else if(i[n])return i[n](e,t)},nd.prototype._getEntry=function(e){var t=this._current.entries[e]||this._current.headerEntries[e];if(!t)throw new Error("entry not found");return t};var ad={search:["value",function(e,t,n){const{keys:i}=n,o=t.trim().toLowerCase().split(/\s+/);return e.flatMap((e=>{const t=function(e,t,n){const{matchedWords:i,tokens:o}=n.reduce(((n,i)=>{const o=e[i],{tokens:r,matchedWords:s}=function(e,t){if(!e)return{tokens:[],matchedWords:{}};const n=[],i={},o=t.map(sd).flatMap((e=>["(?<wordStart>\\b"+e+")",e])).join("|"),r=new RegExp(o,"ig");let s,a=0;for(;s=r.exec(e);){const[t]=s;s.index>a&&n.push({value:e.slice(a,s.index),index:a}),n.push({value:t,index:s.index,match:!0,wordStart:!!s.groups.wordStart,start:0===s.index}),i[t.toLowerCase()]=!0,a=s.index+t.length}a<e.length&&n.push({value:e.slice(a),index:a});return{tokens:n,matchedWords:i}}(o,t);return{tokens:{...n.tokens,[i]:r},matchedWords:{...n.matchedWords,...s}}}),{matchedWords:{},tokens:{}});if(Object.keys(i).length!==t.length)return null;return o}(e,o,i);return t?{item:e,tokens:t}:[]})).sort(function(e){return(t,n)=>{for(const i of e){const e=id(t.tokens[i],n.tokens[i]);if(0!==e)return e;const o=rd(t.item[i],n.item[i]);if(0!==o)return o}return 0}}(i))}]},ld={__depends__:[ad],__init__:["popupMenu"],popupMenu:["type",nd]},cd=Math.round;function ud(e,t){this._modeling=e,this._eventBus=t}function hd(e,t){t.on("replace.end",500,(function(t){const{newElement:n,hints:i={}}=t;!1!==i.select&&e.select(n)}))}ud.$inject=["modeling","eventBus"],ud.prototype.replaceElement=function(e,t,n){if(e.waypoints)return null;var i=this._modeling,o=this._eventBus;o.fire("replace.start",{element:e,attrs:t,hints:n});var r=t.width||e.width,s=t.height||e.height,a=t.x||e.x,l=t.y||e.y,c=cd(a+r/2),u=cd(l+s/2),h=i.replaceShape(e,M({},t,{x:c,y:u,width:r,height:s}),n);return o.fire("replace.end",{element:e,newElement:h,hints:n}),h},hd.$inject=["selection","eventBus"];var dd={__init__:["replace","replaceSelectionBehavior"],replaceSelectionBehavior:["type",hd],replace:["type",ud]};function pd(e,t,n,i){this.replaceElement=function(n,i,o){o=o||{};var r=i.type,s=n.businessObject,a=e.create(r),l={type:r,businessObject:a};if(l.width=n.width,l.height=n.height,a.name=s.name,i.table){var c=e.create("dmn:DecisionTable");c.$parent=a;var u=e.create("dmn:OutputClause");u.typeRef="string",u.$parent=c,c.output=[u];var h=e.create("dmn:InputClause");h.$parent=c;var d=e.create("dmn:LiteralExpression",{typeRef:"string"});h.inputExpression=d,d.$parent=h,c.input=[h],fd(a,c,e)}if(i.expression){var p=e.create("dmn:LiteralExpression"),f=e.create("dmn:InformationItem",{name:s.name});fd(a,p,e,f)}return t.replaceElement(n,l,o)}}function fd(e,t,n,i){if(hn(e,"dmn:Decision"))e.decisionLogic=t,t.$parent=e;else if(hn(e,"dmn:BusinessKnowledgeModel")){var o=n.create("dmn:FunctionDefinition",{body:t});e.encapsulatedLogic=o,o.$parent=e,t.$parent=o}i&&(e.variable=i,i.$parent=e)}pd.$inject=["drdFactory","replace","selection","modeling"];var gd={__depends__:[dd,Aa],drdReplace:["type",pd]},md=[{label:"Empty",actionName:"replace-with-empty-decision",className:"dmn-icon-clear",target:{type:"dmn:Decision",table:!1,expression:!1}},{label:"Decision table",actionName:"replace-with-decision-table",className:"dmn-icon-decision-table",target:{type:"dmn:Decision",table:!0,expression:!1}},{label:"Literal expression",actionName:"replace-with-literal-expression",className:"dmn-icon-literal-expression",target:{type:"dmn:Decision",table:!1,expression:!0}}],vd=[{label:"Empty",actionName:"replace-with-empty",className:"dmn-icon-clear",target:{type:"dmn:BusinessKnowledgeModel",table:!1,expression:!1}},{label:"Literal Expression",actionName:"replace-with-literal-expression",className:"dmn-icon-literal-expression",target:{type:"dmn:BusinessKnowledgeModel",table:!1,expression:!0}}];function yd(e,t,n,i,o,r){this._popupMenu=e,this._modeling=t,this._moddle=n,this._drdReplace=i,this._rules=o,this._translate=r,this.register()}yd.$inject=["popupMenu","modeling","moddle","drdReplace","rules","translate"],yd.prototype.register=function(){this._popupMenu.registerProvider("dmn-replace",this)},yd.prototype.getEntries=function(e){var t,n,i=e.businessObject;return this._rules.allowed("shape.replace",{element:e})?hn(i,"dmn:Decision")?(n=mn(i),t=d(md,(function(e){var t="replace-with-empty-decision"===e.actionName&&n,i="replace-with-decision-table"===e.actionName&&!hn(n,"dmn:DecisionTable"),o="replace-with-literal-expression"===e.actionName&&!hn(n,"dmn:LiteralExpression");return t||i||o})),this._createEntries(e,t)):hn(i,"dmn:BusinessKnowledgeModel")?(n=mn(i),t=d(vd,(function(e){var t="replace-with-empty"===e.actionName&&n,i="replace-with-decision-table"===e.actionName&&!hn(n,"dmn:DecisionTable"),o="replace-with-literal-expression"===e.actionName&&!hn(n,"dmn:LiteralExpression");return t||i||o})),this._createEntries(e,t)):[]:[]},yd.prototype._createEntries=function(e,t){var n=[],i=this;return p(t,(function(t){var o=i._createMenuEntry(t,e);n.push(o)})),n},yd.prototype._createMenuEntry=function(e,t,n){var i=this._drdReplace.replaceElement;return n=n||function(){return i(t,e.target)},{label:(0,this._translate)(e.label),className:e.className,id:e.actionName,action:n}},yd.prototype.getHeaderEntries=function(e){return[]};var xd={__depends__:[ha,ld,gd],__init__:["replaceMenuProvider"],replaceMenuProvider:["type",yd]};function bd(e,t,n,i,o,r,s,a,l,c,u,h){u=u||{},t.registerProvider(this),this._contextPad=t,this._modeling=n,this._elementFactory=i,this._connect=o,this._create=r,this._rules=s,this._popupMenu=a,this._canvas=l,this._translate=c,!1!==u.autoPlace&&(this._autoPlace=h.get("autoPlace",!1)),e.on("create.end",250,(function(e){var n=e.context.shape;if(xa(e)){var i=t.getEntries(n);i.replace&&i.replace.action.click(e,n)}}))}bd.$inject=["eventBus","contextPad","modeling","elementFactory","connect","create","rules","popupMenu","canvas","translate","config.contextPad","injector"],bd.prototype.getContextPadEntries=function(e){var t=this._modeling,n=this._elementFactory,i=this._connect,o=this._create,s=this._popupMenu,a=this._contextPad,l=this._rules,c=this._translate,u=this._autoPlace,h={};if("label"===e.type)return h;var d=e.businessObject;function p(e,t,n){i.start(e,t,n)}function f(e,t,i,r){function s(t,i){var s=n.createShape(M({type:e},r));o.start(t,s,{source:i,hints:{connectionTarget:i}})}var a=u?function(t,i){var o=n.createShape(M({type:e},r));u.append(i,o,{connectionTarget:i})}:s;return{group:"model",className:t,title:i,action:{dragstart:s,click:a}}}hn(d,"dmn:Decision")&&M(h,{"append.decision":f("dmn:Decision","dmn-icon-decision",c("Append decision"))}),gn(d,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:KnowledgeSource"])&&M(h,{"append.knowledge-source":f("dmn:KnowledgeSource","dmn-icon-knowledge-source",c("Append knowledge source"))}),gn(d,["dmn:BusinessKnowledgeModel","dmn:Decision"])&&M(h,{"append.business-knowledge-model":f("dmn:BusinessKnowledgeModel","dmn-icon-business-knowledge",c("Append business knowledge model"))}),gn(d,["dmn:Decision","dmn:KnowledgeSource"])&&M(h,{"append.input-data":f("dmn:InputData","dmn-icon-input-data",c("Append input data"))}),hn(d,"dmn:DRGElement")&&M(h,{"append.text-annotation":f("dmn:TextAnnotation","dmn-icon-text-annotation",c("Add text annotation")),connect:{group:"connect",className:"dmn-icon-connection-multi",title:c("Connect to other element"),action:{click:p,dragstart:p}}}),hn(d,"dmn:TextAnnotation")&&M(h,{connect:{group:"connect",className:"dmn-icon-connection-multi",title:c("Connect to other element"),action:{click:p,dragstart:p}}}),s.isEmpty(e,"dmn-replace")||M(h,{replace:{group:"edit",className:"dmn-icon-screw-wrench",title:c("Change type"),action:{click:function(e,t){var n=M(function(e){var t=a.getPad(e).html.getBoundingClientRect();return{x:t.left,y:t.bottom+5}}(t),{cursor:{x:e.x,y:e.y}});s.open(t,"dmn-replace",n)}}}});var g=l.allowed("elements.delete",{elements:[e]});return r(g)&&(g=g[0]===e),g&&M(h,{delete:{group:"edit",className:"dmn-icon-trash",title:c("Delete"),action:{click:function(n){t.removeElements([e])}}}}),h};var _d={__depends__:[ha,du,Aa,yu,zu,xd],__init__:["contextPadProvider"],contextPadProvider:["type",bd]};function wd(e,t,n,i){this._canvas=t,this._graphicsFactory=n,this._elementFactory=i,this._connectionDocking=e.get("connectionDocking",!1),this._layouter=e.get("layouter",!1)}wd.$inject=["injector","canvas","graphicsFactory","elementFactory"],wd.prototype.drawPreview=function(e,t,n){n=n||{};var i,o,r,s=e.connectionPreviewGfx,a=e.getConnection,l=n.source,c=n.target,u=n.waypoints,h=n.connectionStart,d=n.connectionEnd,p=n.noLayout,f=n.noCropping,g=n.noNoop,m=this;s||(s=e.connectionPreviewGfx=this.createConnectionPreviewGfx()),Nn(s),a||(a=e.getConnection=(o=function(e,t,n){return m.getConnection(e,t,n)},r={},function(e){var t=JSON.stringify(e),n=r[t];return n||(n=r[t]=o.apply(null,arguments)),n})),t&&(i=a(t,l,c)),i?(i.waypoints=u||[],this._layouter&&!p&&(i.waypoints=this._layouter.layoutConnection(i,{source:l,target:c,connectionStart:h,connectionEnd:d,waypoints:n.waypoints||i.waypoints})),i.waypoints&&i.waypoints.length||(i.waypoints=[l?mo(l):h,c?mo(c):d]),this._connectionDocking&&(l||c)&&!f&&(i.waypoints=this._connectionDocking.getCroppedWaypoints(i,l,c)),this._graphicsFactory.drawConnection(s,i,{stroke:"var(--element-dragger-color)"})):!g&&this.drawNoopPreview(s,n)},wd.prototype.drawNoopPreview=function(e,t){var n=t.source,i=t.target,o=t.connectionStart||mo(n),r=t.connectionEnd||mo(i),s=this.cropWaypoints(o,r,n,i);An(e,this.createNoopConnection(s[0],s[1]))},wd.prototype.cropWaypoints=function(e,t,n,i){var o=this._graphicsFactory,r=n&&o.getShapePath(n),s=i&&o.getShapePath(i),a=o.getConnectionPath({waypoints:[e,t]});return[e=n&&yo(r,a,!0)||e,t=i&&yo(s,a,!1)||t]},wd.prototype.cleanUp=function(e){e&&e.connectionPreviewGfx&&ti(e.connectionPreviewGfx)},wd.prototype.getConnection=function(e){var t=function(e){return s(e)?e:{}}(e);return this._elementFactory.createConnection(t)},wd.prototype.createConnectionPreviewGfx=function(){var e=Qn("g");return jn(e,{pointerEvents:"none"}),Bn(e).add("djs-dragger"),An(this._canvas.getActiveLayer(),e),e},wd.prototype.createNoopConnection=function(e,t){return ci([e,t],{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"})};var Cd={__init__:["connectionPreview"],connectionPreview:["type",wd]};const Od=/\s/,kd=/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i,Ed=/^[a-z_][\w-.]*$/i,Sd=/\$\{([^}]*)\}/g;function Rd(e,t){const n=e.$model.ids.assigned(t);return t?n&&n!==e?"Element must have unique ID.":function(e){if(e=function(e){return e.replace(Sd,"$1")}(e),function(e){return Od.test(e)}(e))return"Id must not contain spaces.";if(!Ed.test(e))return kd.test(e)?"Id must not contain prefix.":"Id must be a valid QName."}(t):"Element must have ID."}function Td(e,t,n,i,o){this._eventBus=e,this._modeling=t,this._canvas=n,this._definitionPropertiesView=i,this._translate=o,e.on("definitionIdView.create",(function(e){this._container=e.html;var t=Zt(".dmn-definitions-name",this._container),n=Zt(".dmn-definitions-id",this._container);this._setup(t,"name"),this._setup(n,"id")}),this)}Td.$inject=["eventBus","modeling","canvas","definitionPropertiesView","translate"],Td.prototype.update=function(e,t){var n=this._canvas.getRootElement(),i={};if(i[e]=t,"id"===e){var o=Rd(fn(n),t);if(o)return void this._addErrorMessage(o);this._clearErrorMessage()}this._modeling.updateProperties(n,i)},Td.prototype._setup=function(e,t){var n=this;e.setAttribute("contenteditable",!0),e.addEventListener("input",R((function(e){var i=e.target.value||e.target.textContent;n.update(t,i.trim())}),300)),e.addEventListener("keydown",(function(t){13===t.keyCode&&(e.blur(),window.getSelection().removeAllRanges())})),e.addEventListener("blur",(function(){n._clearErrorMessage(),n._definitionPropertiesView.update()}))},Td.prototype._addErrorMessage=function(e){const t='<span class="dmn-definitions-error-message">'+this._translate(e)+"</span>";var n=Zt(".dmn-definitions-id",this._container);this._clearErrorMessage(),$t(n).add("dmn-definitions-error"),n.parentElement.appendChild(Gt(t))},Td.prototype._clearErrorMessage=function(){var e=Zt(".dmn-definitions-id",this._container);if($t(e).has("dmn-definitions-error")){$t(e).remove("dmn-definitions-error");const t=Zt(".dmn-definitions-error-message",this._container);e.parentNode.removeChild(t)}};var Md={__depends__:[Va],__init__:["definitionPropertiesEdit","definitionPropertiesPaletteAdapter"],definitionPropertiesEdit:["type",Td],definitionPropertiesPaletteAdapter:["type",qa]},Ad={horizontal:["x","width"],vertical:["y","height"]};function Pd(e,t){this._modeling=e,this._filters=[],this.registerFilter((function(e){var n=t.allowed("elements.distribute",{elements:e});return r(n)?n:n?e:[]}))}Pd.$inject=["modeling","rules"],Pd.prototype.registerFilter=function(e){if("function"!=typeof e)throw new Error("the filter has to be a function");this._filters.push(e)},Pd.prototype.trigger=function(e,t){var n,i,o=this._modeling;if(!(e.length<3||(this._setOrientation(t),i=this._filterElements(e),(n=this._createGroups(i)).length<=2)))return o.distributeElements(n,this._axis,this._dimension),n},Pd.prototype._filterElements=function(e){var t=this._filters,n=this._axis,i=this._dimension,o=[].concat(e);return t.length?(p(t,(function(e){o=e(o,n,i)})),o):e},Pd.prototype._createGroups=function(e){var t=[],n=this,i=this._axis,o=this._dimension;if(!i)throw new Error('must have a defined "axis" and "dimension"');return p(w(e,i),(function(e,r){var s,a=n._findRange(e,i,o),l=t[t.length-1];l&&n._hasIntersection(l.range,a)?t[t.length-1].elements.push(e):(s={range:a,elements:[e]},t.push(s))})),t},Pd.prototype._setOrientation=function(e){var t=Ad[e];this._axis=t[0],this._dimension=t[1]},Pd.prototype._hasIntersection=function(e,t){return Math.max(e.min,e.max)>=Math.min(t.min,t.max)&&Math.min(e.min,e.max)<=Math.max(t.min,t.max)},Pd.prototype._findRange=function(e){var t=e[this._axis];return{min:t+5,max:t+e[this._dimension]-5}};var Dd={__init__:["distributeElements"],distributeElements:["type",Pd]};function $d(e){e.registerFilter((function(e){return d(e,(function(e){var t=gn(e,["dmn:AuthorityRequirement","dmn:InformationRequirement","dmn:KnowledgeRequirement","dmn:Association","dmn:TextAnnotation"]);return!(e.labelTarget||t)}))}))}$d.$inject=["distributeElements"];var jd={__depends__:[Dd],__init__:["drdDistributeElements"],drdDistributeElements:["type",$d]},Id="is not a registered action";function Bd(e,t){this._actions={};var n=this;e.on("diagram.init",(function(){n._registerDefaultActions(t),e.fire("editorActions.init",{editorActions:n})}))}function Ld(e,t){return new Error(e+" "+t)}Bd.$inject=["eventBus","injector"],Bd.prototype._registerDefaultActions=function(e){var t=e.get("commandStack",!1),n=e.get("modeling",!1),i=e.get("selection",!1),o=e.get("zoomScroll",!1),s=e.get("copyPaste",!1),a=e.get("canvas",!1),l=e.get("rules",!1),c=e.get("keyboardMove",!1),u=e.get("keyboardMoveSelection",!1);t&&(this.register("undo",(function(){t.undo()})),this.register("redo",(function(){t.redo()}))),s&&i&&this.register("copy",(function(){var e=i.get();if(e.length)return s.copy(e)})),s&&this.register("paste",(function(){s.paste()})),o&&this.register("stepZoom",(function(e){o.stepZoom(e.value)})),a&&this.register("zoom",(function(e){a.zoom(e.value)})),n&&i&&l&&this.register("removeSelection",(function(){var e=i.get();if(e.length){var t,o=l.allowed("elements.delete",{elements:e});!1!==o&&(t=r(o)?o:e).length&&n.removeElements(t.slice())}})),c&&this.register("moveCanvas",(function(e){c.moveCanvas(e)})),u&&this.register("moveSelection",(function(e){u.moveSelection(e.direction,e.accelerated)}))},Bd.prototype.trigger=function(e,t){if(!this._actions[e])throw Ld(e,Id);return this._actions[e](t)},Bd.prototype.register=function(e,t){var n=this;if("string"==typeof e)return this._registerAction(e,t);p(e,(function(e,t){n._registerAction(t,e)}))},Bd.prototype._registerAction=function(e,t){if(this.isRegistered(e))throw Ld(e,"is already registered");this._actions[e]=t},Bd.prototype.unregister=function(e){if(!this.isRegistered(e))throw Ld(e,Id);this._actions[e]=void 0},Bd.prototype.getActions=function(){return Object.keys(this._actions)},Bd.prototype.isRegistered=function(e){return!!this._actions[e]};var Nd={__init__:["editorActions"],editorActions:["type",Bd]};function qd(e){e.invoke(Bd,this)}yn(qd,Bd),qd.$inject=["injector"],qd.prototype._registerDefaultActions=function(e){Bd.prototype._registerDefaultActions.call(this,e);const t=e.get("canvas",!1),n=e.get("elementRegistry",!1),i=e.get("selection",!1),o=e.get("lassoTool",!1),r=e.get("handTool",!1),s=e.get("directEditing",!1),a=e.get("distributeElements",!1),l=e.get("alignElements",!1),c=e.get("searchPad",!1);t&&n&&i&&this._registerAction("selectElements",(function(){var e=t.getRootElement(),o=n.filter((function(t){return t!==e}));return i.select(o),o})),i&&a&&this._registerAction("distributeElements",(function(e){var t=i.get(),n=e.type;t.length>2&&a.trigger(t,n)})),i&&l&&this._registerAction("alignElements",(function(e){var t=i.get(),n=e.type;t.length>1&&l.trigger(t,n)})),o&&this._registerAction("lassoTool",(function(){o.toggle()})),r&&this._registerAction("handTool",(function(){r.toggle()})),i&&s&&this._registerAction("directEditing",(function(){var e=i.get();e.length&&s.activate(e[0])})),i&&c&&this._registerAction("find",(function(){c.toggle()}))};var Vd={__depends__:[Nd],editorActions:["type",qd]};function Fd(e){return e.dmnDI&&e.dmnDI.diagrams&&e.dmnDI.diagrams[0]}function zd(e,t,n,i){n.on("import.start",(({definitions:n})=>{Fd(n)||function(n){var o=n.dmnDI;o||(o=e.create("dmndi:DMNDI"),n.set("dmnDI",o));var r=e.create("dmndi:DMNDiagram");o.set("diagrams",[r]);var s=0;p(n.get("drgElement"),(function(n){if(hn(n,"dmn:Decision")){var o=t._getDefaultSize(n),a=e.createDiShape(n,{x:150+30*s,y:150+30*s,width:o.width,height:o.height});i.updateDiParent(a,r),s++}}))}(n)}))}zd.$inject=["drdFactory","elementFactory","eventBus","drdUpdater"];var Qd={__init__:["diGenerator"],diGenerator:["type",zd]};function Hd(e,t,n){return n||(n="round"),Math[n](e/t)*t}function Wd(e,t,n){var i=!n||!1!==n.active;this._eventBus=t;var o=this;t.on("diagram.init",800,(function(){o.setActive(i)})),t.on(["create.move","create.end","bendpoint.move.move","bendpoint.move.end","connect.move","connect.end","connectionSegment.move.move","connectionSegment.move.end","resize.move","resize.end","shape.move.move","shape.move.end"],1200,(function(t){var n=t.originalEvent;if(!(!o.active||n&&pl(n))){var i=t.context,r=i.gridSnappingContext;r||(r=i.gridSnappingContext={}),["x","y"].forEach((function(n){var i={},r=function(e,t,n){var i=e.context,o=e.shape,r=i.gridSnappingContext,s=r.snapLocation,l=r.snapOffset;if(l&&a(l[t]))return l[t];l||(l=r.snapOffset={});a(l[t])||(l[t]=0);if(!o)return l[t];n.get(o.id)||(Ud(t)?l[t]+=o[t]+o.width/2:l[t]+=o[t]+o.height/2);if(!s)return l[t];"x"===t?/left/.test(s)?l[t]-=o.width/2:/right/.test(s)&&(l[t]+=o.width/2):/top/.test(s)?l[t]-=o.height/2:/bottom/.test(s)&&(l[t]+=o.height/2);return l[t]}(t,n,e);r&&(i.offset=r);var s=function(e,t){var n=e.context,i=n.createConstraints,o=n.resizeConstraints||{},r=n.gridSnappingContext,s=r.snapConstraints;if(s&&s[t])return s[t];s||(s=r.snapConstraints={});s[t]||(s[t]={});var a=n.direction;i&&(Ud(t)?(s.x.min=i.left,s.x.max=i.right):(s.y.min=i.top,s.y.max=i.bottom));var l=o.min,c=o.max;l&&(Ud(t)?Kd(a)?s.x.max=l.left:s.x.min=l.right:Xd(a)?s.y.max=l.top:s.y.min=l.bottom);c&&(Ud(t)?Kd(a)?s.x.min=c.left:s.x.max=c.right:Xd(a)?s.y.min=c.top:s.y.max=c.bottom);return s[t]}(t,n);s&&M(i,s),eu(t,n)||o.snapEvent(t,n,i)}))}}))}function Ud(e){return"x"===e}function Xd(e){return-1!==e.indexOf("n")}function Kd(e){return-1!==e.indexOf("w")}Wd.prototype.snapEvent=function(e,t,n){tu(e,t,this.snapValue(e[t],n))},Wd.prototype.getGridSpacing=function(){return 10},Wd.prototype.snapValue=function(e,t){var n,i,o=0;return t&&t.offset&&(o=t.offset),e=Hd(e+=o,10),t&&t.min&&a(n=t.min)&&(n=Hd(n+o,10,"ceil"),e=Math.max(e,n)),t&&t.max&&a(i=t.max)&&(i=Hd(i+o,10,"floor"),e=Math.min(e,i)),e-=o},Wd.prototype.isActive=function(){return this.active},Wd.prototype.setActive=function(e){this.active=e,this._eventBus.fire("gridSnapping.toggle",{active:e})},Wd.prototype.toggleActive=function(){this.setActive(!this.active)},Wd.$inject=["elementRegistry","eventBus","config.gridSnapping"];function Gd(e){this._eventBus=e}function Yd(e){return function(t,n,i,o,r){(l(t)||a(t))&&(r=o,o=i,i=n,n=t,t=null),this.on(t,e,n,i,o,r)}}function Zd(e,t){Gd.call(this,e),this._gridSnapping=t;var n=this;this.preExecute("shape.resize",(function(e){var t=e.context,i=(t.hints||{}).autoResize;if(i){var o=t.shape,r=t.newBounds;c(i)?t.newBounds=n.snapComplex(r,i):t.newBounds=n.snapSimple(o,r)}}))}Gd.$inject=["eventBus"],Gd.prototype.on=function(e,t,n,i,o,c){if((l(t)||a(t))&&(c=o,o=i,i=n,n=t,t=null),l(n)&&(c=o,o=i,i=n,n=1e3),s(o)&&(c=o,o=!1),!l(i))throw new Error("handlerFn must be a function");r(e)||(e=[e]);var u=this._eventBus;p(e,(function(e){var r=["commandStack",e,t].filter((function(e){return e})).join(".");u.on(r,n,o?function(e,t){return function(n){return e.call(t||null,n.context,n.command,n)}}(i,c):i,c)}))},Gd.prototype.canExecute=Yd("canExecute"),Gd.prototype.preExecute=Yd("preExecute"),Gd.prototype.preExecuted=Yd("preExecuted"),Gd.prototype.execute=Yd("execute"),Gd.prototype.executed=Yd("executed"),Gd.prototype.postExecute=Yd("postExecute"),Gd.prototype.postExecuted=Yd("postExecuted"),Gd.prototype.revert=Yd("revert"),Gd.prototype.reverted=Yd("reverted"),Zd.$inject=["eventBus","gridSnapping","modeling"],yn(Zd,Gd),Zd.prototype.snapSimple=function(e,t){var n=this._gridSnapping;return t.width=n.snapValue(t.width,{min:t.width}),t.height=n.snapValue(t.height,{min:t.height}),t.x=e.x+e.width/2-t.width/2,t.y=e.y+e.height/2-t.height/2,t},Zd.prototype.snapComplex=function(e,t){return/w|e/.test(t)&&(e=this.snapHorizontally(e,t)),/n|s/.test(t)&&(e=this.snapVertically(e,t)),e},Zd.prototype.snapHorizontally=function(e,t){var n=this._gridSnapping,i=/w/.test(t),o=/e/.test(t),r={};return r.width=n.snapValue(e.width,{min:e.width}),o&&(i?(r.x=n.snapValue(e.x,{max:e.x}),r.width+=n.snapValue(e.x-r.x,{min:e.x-r.x})):e.x=e.x+e.width-r.width),M(e,r),e},Zd.prototype.snapVertically=function(e,t){var n=this._gridSnapping,i=/n/.test(t),o=/s/.test(t),r={};return r.height=n.snapValue(e.height,{min:e.height}),i&&(o?(r.y=n.snapValue(e.y,{max:e.y}),r.height+=n.snapValue(e.y-r.y,{min:e.y-r.y})):e.y=e.y+e.height-r.height),M(e,r),e};function Jd(e,t){e.on(["spaceTool.move","spaceTool.end"],2e3,(function(e){var n,i=e.context;i.initialized&&("x"===i.axis?(n=t.snapValue(e.dx),e.x=e.x+n-e.dx,e.dx=n):(n=t.snapValue(e.dy),e.y=e.y+n-e.dy,e.dy=n))}))}Jd.$inject=["eventBus","gridSnapping"];var ep={__depends__:[{__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",Zd],gridSnappingSpaceToolBehavior:["type",Jd]}],__init__:["gridSnapping"],gridSnapping:["type",Wd]},tp="keyboard.keydown",np="Keyboard binding is now implicit; explicit binding to an element got removed. For more information, see https://github.com/bpmn-io/diagram-js/issues/661";function ip(e,t){var n=this;this._config=e=e||{},this._eventBus=t,this._keydownHandler=this._keydownHandler.bind(this),this._keyupHandler=this._keyupHandler.bind(this),t.on("diagram.destroy",(function(){n._fire("destroy"),n.unbind()})),e.bindTo&&console.error("unsupported configuration <keyboard.bindTo>",new Error(np));var i=e&&!1!==e.bind;t.on("canvas.init",(function(e){n._target=e.svg,i&&n.bind(),n._fire("init")}))}ip.$inject=["config.keyboard","eventBus"],ip.prototype._keydownHandler=function(e){this._keyHandler(e,tp)},ip.prototype._keyupHandler=function(e){this._keyHandler(e,"keyboard.keyup")},ip.prototype._keyHandler=function(e,t){if(!this._isEventIgnored(e)){var n={keyEvent:e};this._eventBus.fire(t||tp,n)&&e.preventDefault()}},ip.prototype._isEventIgnored=function(e){return!1},ip.prototype.bind=function(e){e&&console.error("unsupported argument <node>",new Error(np)),this.unbind(),e=this._node=this._target,zt.bind(e,"keydown",this._keydownHandler),zt.bind(e,"keyup",this._keyupHandler),this._fire("bind")},ip.prototype.getBinding=function(){return this._node},ip.prototype.unbind=function(){var e=this._node;e&&(this._fire("unbind"),zt.unbind(e,"keydown",this._keydownHandler),zt.unbind(e,"keyup",this._keyupHandler)),this._node=null},ip.prototype._fire=function(e){this._eventBus.fire("keyboard."+e,{node:this._node})},ip.prototype.addListener=function(e,t,n){l(e)&&(n=t,t=e,e=1e3),this._eventBus.on(n||tp,e,t)},ip.prototype.removeListener=function(e,t){this._eventBus.off(t||tp,e)},ip.prototype.hasModifier=function(e){return e.ctrlKey||e.metaKey||e.shiftKey||e.altKey},ip.prototype.isCmd=pl,ip.prototype.isShift=gl,ip.prototype.isKey=fl;var op=500;function rp(e,t){var n=this;e.on("editorActions.init",op,(function(e){var i=e.editorActions;n.registerBindings(t,i)}))}rp.$inject=["eventBus","keyboard"],rp.prototype.registerBindings=function(e,t){function n(n,i){t.isRegistered(n)&&e.addListener(i)}n("undo",(function(e){if(ml(e.keyEvent))return t.trigger("undo"),!0})),n("redo",(function(e){if(vl(e.keyEvent))return t.trigger("redo"),!0})),n("copy",(function(e){if(function(e){return pl(e)&&fl(cl,e)}(e.keyEvent))return t.trigger("copy"),!0})),n("paste",(function(e){if(function(e){return pl(e)&&fl(ul,e)}(e.keyEvent))return t.trigger("paste"),!0})),n("stepZoom",(function(e){var n=e.keyEvent;if(fl(["+","Add","="],n)&&pl(n))return t.trigger("stepZoom",{value:1}),!0})),n("stepZoom",(function(e){var n=e.keyEvent;if(fl(["-","Subtract"],n)&&pl(n))return t.trigger("stepZoom",{value:-1}),!0})),n("zoom",(function(e){var n=e.keyEvent;if(fl("0",n)&&pl(n))return t.trigger("zoom",{value:1}),!0})),n("removeSelection",(function(e){if(fl(["Backspace","Delete","Del"],e.keyEvent))return t.trigger("removeSelection"),!0}))};var sp={__init__:["keyboard","keyboardBindings"],keyboard:["type",ip],keyboardBindings:["type",rp]};function ap(e){e.invoke(rp,this)}yn(ap,rp),ap.$inject=["injector"],ap.prototype.registerBindings=function(e,t){function n(n,i){t.isRegistered(n)&&e.addListener(i)}rp.prototype.registerBindings.call(this,e,t),n("selectElements",(function(n){var i=n.keyEvent;if(e.isKey(["a","A"],i)&&e.isCmd(i))return t.trigger("selectElements"),!0})),n("lassoTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["l","L"],i)?(t.trigger("lassoTool"),!0):void 0})),n("handTool",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["h","H"],i)?(t.trigger("handTool"),!0):void 0})),n("directEditing",(function(n){var i=n.keyEvent;if(!e.hasModifier(i))return e.isKey(["e","E"],i)?(t.trigger("directEditing"),!0):void 0})),n("find",(function(n){var i=n.keyEvent;if(e.isKey(["f","F"],i)&&e.isCmd(i))return t.trigger("find"),!0}))};var lp={__depends__:[sp],__init__:["keyboardBindings"],keyboardBindings:["type",ap]},cp={moveSpeed:50,moveSpeedAccelerated:200};function up(e,t,n){var i=this;this._config=M({},cp,e||{}),t.addListener((function(e){var n=e.keyEvent,o=i._config;if(!t.isCmd(n))return;if(t.isKey(["ArrowLeft","Left","ArrowUp","Up","ArrowDown","Down","ArrowRight","Right"],n)){var r,s=t.isShift(n)?o.moveSpeedAccelerated:o.moveSpeed;switch(n.key){case"ArrowLeft":case"Left":r="left";break;case"ArrowUp":case"Up":r="up";break;case"ArrowRight":case"Right":r="right";break;case"ArrowDown":case"Down":r="down"}return i.moveCanvas({speed:s,direction:r}),!0}})),this.moveCanvas=function(e){var t=0,i=0,o=e.speed/Math.min(Math.sqrt(n.viewbox().scale),1);switch(e.direction){case"left":t=o;break;case"up":i=o;break;case"right":t=-o;break;case"down":i=-o}n.scroll({dx:t,dy:i})}}up.$inject=["config.keyboardMove","keyboard","canvas"];var hp={__depends__:[sp],__init__:["keyboardMove"],keyboardMove:["type",up]},dp={moveSpeed:1,moveSpeedAccelerated:10},pp="left",fp="right",gp="down",mp={ArrowLeft:pp,Left:pp,ArrowUp:"up",Up:"up",ArrowRight:fp,Right:fp,ArrowDown:gp,Down:gp},vp={left:function(e){return{x:-e,y:0}},up:function(e){return{x:0,y:-e}},right:function(e){return{x:e,y:0}},down:function(e){return{x:0,y:e}}};function yp(e,t,n,i,o){var r=this;this._config=M({},dp,e||{}),t.addListener(1500,(function(e){var n=e.keyEvent,i=mp[n.key];if(i&&!t.isCmd(n)){var o=t.isShift(n);return r.moveSelection(i,o),!0}})),this.moveSelection=function(e,t){var r=o.get();if(r.length){var s=this._config[t?"moveSpeedAccelerated":"moveSpeed"],a=vp[e](s);i.allowed("elements.move",{shapes:r})&&n.moveElements(r,a)}}}yp.$inject=["config.keyboardMoveSelection","keyboard","modeling","rules","selection"];var xp={__depends__:[sp,Aa],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",yp]};function bp(e,t){this._handlerMap={},this._stack=[],this._stackIdx=-1,this._currentExecution={actions:[],dirty:[],trigger:null},this._injector=t,this._eventBus=e,this._uid=1,e.on(["diagram.destroy","diagram.clear"],(function(){this.clear(!1)}),this)}bp.$inject=["eventBus","injector"],bp.prototype.execute=function(e,t){if(!e)throw new Error("command required");this._currentExecution.trigger="execute";const n={command:e,context:t};this._pushAction(n),this._internalExecute(n),this._popAction()},bp.prototype.canExecute=function(e,t){const n={command:e,context:t},i=this._getHandler(e);let o=this._fire(e,"canExecute",n);if(void 0===o){if(!i)return!1;i.canExecute&&(o=i.canExecute(t))}return o},bp.prototype.clear=function(e){this._stack.length=0,this._stackIdx=-1,!1!==e&&this._fire("changed",{trigger:"clear"})},bp.prototype.undo=function(){let e,t=this._getUndoAction();if(t){for(this._currentExecution.trigger="undo",this._pushAction(t);t&&(this._internalUndo(t),e=this._getUndoAction(),e&&e.id===t.id);)t=e;this._popAction()}},bp.prototype.redo=function(){let e,t=this._getRedoAction();if(t){for(this._currentExecution.trigger="redo",this._pushAction(t);t&&(this._internalExecute(t,!0),e=this._getRedoAction(),e&&e.id===t.id);)t=e;this._popAction()}},bp.prototype.register=function(e,t){this._setHandler(e,t)},bp.prototype.registerHandler=function(e,t){if(!e||!t)throw new Error("command and handlerCls must be defined");const n=this._injector.instantiate(t);this.register(e,n)},bp.prototype.canUndo=function(){return!!this._getUndoAction()},bp.prototype.canRedo=function(){return!!this._getRedoAction()},bp.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]},bp.prototype._getUndoAction=function(){return this._stack[this._stackIdx]},bp.prototype._internalUndo=function(e){const t=e.command,n=e.context,i=this._getHandler(t);this._atomicDo((()=>{this._fire(t,"revert",e),i.revert&&this._markDirty(i.revert(n)),this._revertedAction(e),this._fire(t,"reverted",e)}))},bp.prototype._fire=function(e,t,n){arguments.length<3&&(n=t,t=null);const i=t?[e+"."+t,t]:[e];let o;n=this._eventBus.createEvent(n);for(const e of i)if(o=this._eventBus.fire("commandStack."+e,n),n.cancelBubble)break;return o},bp.prototype._createId=function(){return this._uid++},bp.prototype._atomicDo=function(e){const t=this._currentExecution;t.atomic=!0;try{e()}finally{t.atomic=!1}},bp.prototype._internalExecute=function(e,t){const n=e.command,i=e.context,o=this._getHandler(n);if(!o)throw new Error("no command handler registered for <"+n+">");this._pushAction(e),t||(this._fire(n,"preExecute",e),o.preExecute&&o.preExecute(i),this._fire(n,"preExecuted",e)),this._atomicDo((()=>{this._fire(n,"execute",e),o.execute&&this._markDirty(o.execute(i)),this._executedAction(e,t),this._fire(n,"executed",e)})),t||(this._fire(n,"postExecute",e),o.postExecute&&o.postExecute(i),this._fire(n,"postExecuted",e)),this._popAction()},bp.prototype._pushAction=function(e){const t=this._currentExecution,n=t.actions,i=n[0];if(t.atomic)throw new Error("illegal invocation in <execute> or <revert> phase (action: "+e.command+")");e.id||(e.id=i&&i.id||this._createId()),n.push(e)},bp.prototype._popAction=function(){const e=this._currentExecution,t=e.trigger,n=e.actions,i=e.dirty;n.pop(),n.length||(this._eventBus.fire("elements.changed",{elements:_("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:t}),e.trigger=null)},bp.prototype._markDirty=function(e){const t=this._currentExecution;e&&(e=r(e)?e:[e],t.dirty=t.dirty.concat(e))},bp.prototype._executedAction=function(e,t){const n=++this._stackIdx;t||this._stack.splice(n,this._stack.length,e)},bp.prototype._revertedAction=function(e){this._stackIdx--},bp.prototype._getHandler=function(e){return this._handlerMap[e]},bp.prototype._setHandler=function(e,t){if(!e||!t)throw new Error("command and handler required");if(this._handlerMap[e])throw new Error("overriding handler for command <"+e+">");this._handlerMap[e]=t};var _p={commandStack:["type",bp]};function wp(e,t,n,i){e.on("element.changed",(function(i){var o=i.element;(o.parent||o===t.getRootElement())&&(i.gfx=n.getGraphics(o)),i.gfx&&e.fire(vi(o)+".changed",i)})),e.on("elements.changed",(function(t){var n=t.elements;n.forEach((function(t){e.fire("element.changed",{element:t})})),i.updateContainments(n)})),e.on("shape.changed",(function(e){i.update("shape",e.element,e.gfx)})),e.on("connection.changed",(function(e){i.update("connection",e.element,e.gfx)}))}wp.$inject=["eventBus","canvas","elementRegistry","graphicsFactory"];var Cp={__init__:["changeSupport"],changeSupport:["type",wp]},Op=Math.min,kp=Math.max;function Ep(e){e.preventDefault()}function Sp(e){e.stopPropagation()}function Rp(e){this.container=e.container,this.parent=Gt('<div class="djs-direct-editing-parent"><div class="djs-direct-editing-content" contenteditable="true"></div></div>'),this.content=Zt("[contenteditable]",this.parent),this.keyHandler=e.keyHandler||function(){},this.resizeHandler=e.resizeHandler||function(){},this.autoResize=T(this.autoResize,this),this.handlePaste=T(this.handlePaste,this)}function Tp(e,t){this._eventBus=e,this._canvas=t,this._providers=[],this._textbox=new Rp({container:t.getContainer(),keyHandler:T(this._handleKey,this),resizeHandler:T(this._handleResize,this)})}Rp.prototype.create=function(e,t,n,i){var o=this.parent,r=this.content,s=this.container;i=this.options=i||{};var a=A(t=this.style=t||{},["width","height","maxWidth","maxHeight","minWidth","minHeight","left","top","backgroundColor","position","overflow","border","wordWrap","textAlign","outline","transform"]);M(o.style,{width:e.width+"px",height:e.height+"px",maxWidth:e.maxWidth+"px",maxHeight:e.maxHeight+"px",minWidth:e.minWidth+"px",minHeight:e.minHeight+"px",left:e.x+"px",top:e.y+"px",backgroundColor:"#ffffff",position:"absolute",overflow:"visible",border:"1px solid #ccc",boxSizing:"border-box",wordWrap:"normal",textAlign:"center",outline:"none"},a);var l=A(t,["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"]);return M(r.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},l),i.centerVertically&&M(r.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},l),r.innerText=n,zt.bind(r,"keydown",this.keyHandler),zt.bind(r,"mousedown",Sp),zt.bind(r,"paste",this.handlePaste),i.autoResize&&zt.bind(r,"input",this.autoResize),i.resizable&&this.resizable(t),s.appendChild(o),this.setSelection(r.lastChild,r.lastChild&&r.lastChild.length),o},Rp.prototype.handlePaste=function(e){var t,n=this.options,i=this.style;if(e.preventDefault(),t=e.clipboardData?e.clipboardData.getData("text/plain"):window.clipboardData.getData("Text"),this.insertText(t),n.autoResize){var o=this.autoResize(i);o&&this.resizeHandler(o)}},Rp.prototype.insertText=function(e){e=function(e){return e.replace(/\r\n|\r|\n/g,"\n")}(e),document.execCommand("insertText",!1,e)||this._insertTextIE(e)},Rp.prototype._insertTextIE=function(e){var t,n,i,o=this.getSelection(),r=o.startContainer,s=o.endContainer,a=o.startOffset,l=o.endOffset,c=o.commonAncestorContainer,u=(t=c.childNodes,[].slice.call(t));if(function(e){return e.nodeType===Node.TEXT_NODE}(c)){var h=r.textContent;r.textContent=h.substring(0,a)+e+h.substring(l),n=r,i=a+e.length}else if(r===this.content&&s===this.content){var d=document.createTextNode(e);this.content.insertBefore(d,u[a]),n=d,i=d.textContent.length}else{var p=u.indexOf(r),f=u.indexOf(s);u.forEach((function(t,n){n===p?t.textContent=r.textContent.substring(0,a)+e+s.textContent.substring(l):n>p&&n<=f&&en(t)})),n=r,i=a+e.length}n&&void 0!==i&&setTimeout((function(){self.setSelection(n,i)}))},Rp.prototype.autoResize=function(){var e=this.parent,t=this.content,n=parseInt(this.style.fontSize)||12;if(t.scrollHeight>e.offsetHeight||t.scrollHeight<e.offsetHeight-n){var i=e.getBoundingClientRect(),o=t.scrollHeight;e.style.height=o+"px",this.resizeHandler({width:i.width,height:i.height,dx:0,dy:o-i.height})}},Rp.prototype.resizable=function(){var e=this,t=this.parent,n=this.resizeHandle,i=parseInt(this.style.minWidth)||0,o=parseInt(this.style.minHeight)||0,r=parseInt(this.style.maxWidth)||1/0,s=parseInt(this.style.maxHeight)||1/0;if(!n){var a,l,c,u;n=this.resizeHandle=Gt('<div class="djs-direct-editing-resize-handle"></div>');var h=function(n){Ep(n),Sp(n);var h=Op(kp(c+n.clientX-a,i),r),d=Op(kp(u+n.clientY-l,o),s);t.style.width=h+"px",t.style.height=d+"px",e.resizeHandler({width:c,height:u,dx:n.clientX-a,dy:n.clientY-l})},d=function(e){Ep(e),Sp(e),zt.unbind(document,"mousemove",h,!1),zt.unbind(document,"mouseup",d,!1)};zt.bind(n,"mousedown",(function(e){Ep(e),Sp(e),a=e.clientX,l=e.clientY;var n=t.getBoundingClientRect();c=n.width,u=n.height,zt.bind(document,"mousemove",h),zt.bind(document,"mouseup",d)}))}M(n.style,{position:"absolute",bottom:"0px",right:"0px",cursor:"nwse-resize",width:"0",height:"0",borderTop:(parseInt(this.style.fontSize)/4||3)+"px solid transparent",borderRight:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderBottom:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderLeft:(parseInt(this.style.fontSize)/4||3)+"px solid transparent"}),t.appendChild(n)},Rp.prototype.destroy=function(){var e=this.parent,t=this.content,n=this.resizeHandle;t.innerText="",e.removeAttribute("style"),t.removeAttribute("style"),zt.unbind(t,"keydown",this.keyHandler),zt.unbind(t,"mousedown",Sp),zt.unbind(t,"input",this.autoResize),zt.unbind(t,"paste",this.handlePaste),n&&(n.removeAttribute("style"),en(n)),en(e)},Rp.prototype.getValue=function(){return this.content.innerText.trim()},Rp.prototype.getSelection=function(){return window.getSelection().getRangeAt(0)},Rp.prototype.setSelection=function(e,t){var n=document.createRange();null===e?n.selectNodeContents(this.content):(n.setStart(e,t),n.setEnd(e,t));var i=window.getSelection();i.removeAllRanges(),i.addRange(n)},Tp.$inject=["eventBus","canvas"],Tp.prototype.registerProvider=function(e){this._providers.push(e)},Tp.prototype.isActive=function(e){return!(!this._active||e&&this._active.element!==e)},Tp.prototype.cancel=function(){this._active&&(this._fire("cancel"),this.close())},Tp.prototype._fire=function(e,t){this._eventBus.fire("directEditing."+e,t||{active:this._active})},Tp.prototype.close=function(){this._textbox.destroy(),this._fire("deactivate"),this._active=null,this.resizable=void 0,this._canvas.restoreFocus&&this._canvas.restoreFocus()},Tp.prototype.complete=function(){var e=this._active;if(e){var t,n=e.context.bounds,i=this.$textbox.getBoundingClientRect(),o=this.getValue();o===e.context.text&&i.height===n.height&&i.width===n.width||(t=this._textbox.container.getBoundingClientRect(),e.provider.update(e.element,o,e.context.text,{x:i.left-t.left,y:i.top-t.top,width:i.width,height:i.height})),this._fire("complete"),this.close()}},Tp.prototype.getValue=function(){return this._textbox.getValue()},Tp.prototype._handleKey=function(e){e.stopPropagation();var t=e.keyCode||e.charCode;return 27===t?(e.preventDefault(),this.cancel()):13!==t||e.shiftKey?void 0:(e.preventDefault(),this.complete())},Tp.prototype._handleResize=function(e){this._fire("resize",e)},Tp.prototype.activate=function(e){var t;this.isActive()&&this.cancel();var n=h(this._providers,(function(n){return(t=n.activate(e))?n:null}));return t&&(this.$textbox=this._textbox.create(t.bounds,t.style,t.text,t.options),this._active={element:e,context:t,provider:n},t.options&&t.options.resizable&&(this.resizable=!0),this._fire("activate")),!!t};var Mp={__depends__:[Oa],__init__:["directEditing"],directEditing:["type",Tp]},Ap="djs-label-hidden";function Pp(e,t,n,i,o){this._canvas=e,this._modeling=i,this._textRenderer=o,this._eventBus=n,t.registerProvider(this),n.on("element.dblclick",(function(e){t.activate(e.element)})),n.on(["autoPlace.start","canvas.viewbox.changing","drag.init","drillDown.click","element.mousedown","popupMenu.open","selection.changed"],(function(){t.complete()})),n.on(["commandStack.changed"],(function(){t.cancel()})),n.on("create.end",500,(function(e){var n=e.shape;(hn(n,"dmn:Decision")||hn(n,"dmn:InputData")||hn(n,"dmn:BusinessKnowledgeModel")||hn(n,"dmn:KnowledgeSource")||hn(n,"dmn:TextAnnotation"))&&t.activate(n)})),n.on("autoPlace.end",500,(function(e){t.activate(e.shape)})),this._eventBus.on(["directEditing.complete","directEditing.cancel"],(function(t){var n=t.active;if(n){var i=n.element.label||n.element;e.removeMarker(i,Ap)}}))}Pp.$inject=["canvas","directEditing","eventBus","modeling","textRenderer"],Pp.prototype.activate=function(e){var t=wl(e);if(i(t)){var n={text:t};M(n,this.getEditingBBox(e));var o={},r=n.style||{};return hn(e,"dmn:DRGElement")&&(M(o,{centerVertically:!0}),M(r,{backgroundColor:null,border:null})),hn(e,"dmn:TextAnnotation")&&M(o,{resizable:!0}),M(n,{options:o,style:r}),this._canvas.addMarker(e,Ap),n}},Pp.prototype.getEditingBBox=function(e){var t=this._canvas,n=e.label||e,i=t.getAbsoluteBBox(n),o={x:i.x,y:i.y},r=t.zoom(),s=this._textRenderer.getDefaultStyle(),a=s.fontSize*r,l=s.lineHeight,c={fontFamily:this._textRenderer.getDefaultStyle().fontFamily,fontWeight:this._textRenderer.getDefaultStyle().fontWeight};return hn(e,"dmn:DRGElement")&&(M(o,{width:i.width,height:i.height}),M(c,{fontSize:a+"px",lineHeight:l,paddingTop:7*r+"px",paddingBottom:7*r+"px",paddingLeft:5*r+"px",paddingRight:5*r+"px"})),hn(e,"dmn:TextAnnotation")&&(M(o,{width:i.width,height:i.height,minWidth:30*r,minHeight:10*r}),M(c,{textAlign:"left",paddingTop:5*r+"px",paddingBottom:7*r+"px",paddingLeft:7*r+"px",paddingRight:5*r+"px",fontSize:a+"px",lineHeight:l})),{bounds:o,style:c}},Pp.prototype.update=function(e,t,n,i){var o,r,s;hn(e,"dmn:TextAnnotation")&&(r=this._canvas.getAbsoluteBBox(e),o={x:e.x,y:e.y,width:e.width/r.width*i.width,height:e.height/r.height*i.height}),(s=t)&&s.trim()||(t=null),this._modeling.updateLabel(e,t,o)};var Dp={__depends__:[_p,Cp,Mp],__init__:["labelEditingProvider"],labelEditingProvider:["type",Pp]};function $p(e,t){t.invoke(Gd,this),this.preExecute("connection.create",(function(t){var n=t.connection,i=n.businessObject,o=t.source,r=t.target;hn(n,"dmn:Association")?((i.sourceRef=e.create("dmn:DMNElementReference",{href:"#"+o.id})).$parent=i,(i.targetRef=e.create("dmn:DMNElementReference",{href:"#"+r.id})).$parent=i):(i["required"+function(e){if(hn(e,"dmn:BusinessKnowledgeModel"))return"Knowledge";if(hn(e,"dmn:Decision"))return"Decision";if(hn(e,"dmn:InputData"))return"Input";if(hn(e,"dmn:KnowledgeSource"))return"Authority"}(o)]=e.create("dmn:DMNElementReference",{href:"#"+o.id})).$parent=i}),!0)}$p.$inject=["drdFactory","injector"],yn($p,Gd);function jp(e,t,n,i){function o(e,i,o){i||(i=e.incoming.filter((function(e){return hn(e,"dmn:InformationRequirement")})));var r={};o?r[o]=i:r=function(e,t){var n={};return t.forEach((function(t){var i=vo(t.source,e).split("-").shift();n[i]||(n[i]=[]),n[i].push(t)})),n}(e,i),p(r,(function(i,o){i=function(e,t){var n;n=t.includes("top")||t.includes("bottom")?"x":"y";return e.sort((function(e,t){return mo(e.source)[n]-mo(t.source)[n]}))}(i,o);var r=function(e,t,n){return e.map((function(i,o){var r=i.source,s=mo(r),a=po(r),l=po(t),c=e.length;return n.includes("bottom")?{start:{x:s.x,y:a.top},end:{x:l.left+t.width/(c+1)*(o+1),y:l.bottom}}:n.includes("top")?{start:{x:s.x,y:a.bottom},end:{x:l.left+t.width/(c+1)*(o+1),y:l.top}}:n.includes("right")?{start:{x:a.left,y:s.y},end:{x:l.right,y:l.top+t.height/(c+1)*(o+1)}}:{start:{x:a.right,y:s.y},end:{x:l.left,y:l.top+t.height/(c+1)*(o+1)}}}))}(i,e,o);i.forEach(((e,i)=>{var o=r[i].start,s=r[i].end,a=t.layoutConnection(e,{connectionStart:o,connectionEnd:s});n.updateWaypoints(e,a)}))}))}e.invoke(Gd,this),this.preExecute(["connection.create","connection.reconnect"],(function(e){var t=e.connection,n=e.newSource||e.source,o=e.newTarget||e.target;if((!hn(t,"dmn:InformationRequirement")||i.allowed("connection.connect",{connection:t,source:n,target:o}))&&hn(t,"dmn:InformationRequirement")){var r=vo(n,o);e.hints||(e.hints={}),M(e.hints,function(e,t,n){var i=mo(e),o=mo(t);n.includes("bottom")?(i.y=e.y,o.y=t.y+t.height):n.includes("top")?(i.y=e.y+e.height,o.y=t.y):n.includes("right")?(i.x=e.x,o.x=t.x+t.width):(i.x=e.x+e.width,o.x=t.x);return{connectionStart:i,connectionEnd:o}}(n,o,r))}}),!0),this.postExecuted(["connection.create","connection.delete","connection.reconnect"],(function(e){var t=e.connection,n=t.source||e.source,i=t.target||e.target;if(hn(t,"dmn:InformationRequirement")){var r=vo(n,i),s=i.incoming.filter((e=>{var t=vo(e.source,e.target);return hn(e,"dmn:InformationRequirement")&&Ip(t,r)}));s.length&&o(i,s,r)}}),!0),this.preExecute("connection.reconnect",(function(e){var t=e.connection,n=t.source,i=t.target;if(hn(t,"dmn:InformationRequirement")){var r=vo(n,i),s=i.incoming.filter((e=>{var n=vo(e.source,e.target);return e!==t&&hn(e,"dmn:InformationRequirement")&&Ip(n,r)}));s.length&&o(i,s,r)}}),!0),this.postExecuted("elements.move",500,(function(e){var t=e.shapes,n=e.closure.enclosedConnections;t.forEach((function(e){if(gn(e,["dmn:Decision","dmn:InputData"])){var t=e.incoming.filter((function(e){return hn(e,"dmn:InformationRequirement")&&!n[e.id]}));t.length&&o(e,t),e.outgoing.forEach((function(e){hn(e,"dmn:InformationRequirement")&&!n[e.id]&&o(e.target)}))}}))}),!0)}function Ip(e,t){return e&&t&&e.split("-").shift()===t.split("-").shift()}function Bp(e,t,n){e.invoke(Gd,this),this.preExecute("connection.reconnect",(function(e){var i=e.connection,o=e.newSource||i.source,r=e.newTarget||i.target,s=i.waypoints.slice(),a=n.allowed("connection.reconnect",{connection:i,source:o,target:r});a&&a.type!==i.type&&(e.connection=t.connect(o,r,{type:a.type,waypoints:s}),t.removeConnection(i))}),!0)}function Lp(e,t,n){Gd.call(this,e),this._modeling=t,this.postExecuted(["shape.replace"],1500,(function(e){var i=e.context,o=i.oldShape,r=i.newShape;t.unclaimId(o.businessObject.id,o.businessObject),t.updateProperties(r,{id:o.id}),n.select(r)}))}jp.$inject=["injector","layouter","modeling","rules"],yn(jp,Gd),yn(Bp,Gd),Bp.$inject=["injector","modeling","rules"],yn(Lp,Gd),Lp.$inject=["eventBus","modeling","selection"];const Np="id";class qp extends Gd{constructor(e){super(e),this.executed("element.updateProperties",this.updateIds.bind(this))}updateIds({context:e}){const{element:t,oldProperties:n,properties:i}=e,o=fn(t);if(this.shouldSkipUpdate(o,n,i))return;const r=function(e){let t=e;for(;!hn(t,"dmn:Definitions");)t=t.$parent;return t}(o);r.get("drgElement").forEach((e=>{!function(e,t,n){const i={authorityRequirement:()=>{e.authorityRequirement.forEach((e=>{const{requiredAuthority:i,requiredDecision:o,requiredInput:r}=e;i&&i.href===`#${t}`&&(i.href=`#${n}`),o&&o.href===`#${t}`&&(o.href=`#${n}`),r&&r.href===`#${t}`&&(r.href=`#${n}`)}))},informationRequirement:()=>{e.informationRequirement.forEach((e=>{const{requiredDecision:i,requiredInput:o}=e;i&&i.href===`#${t}`&&(i.href=`#${n}`),o&&o.href===`#${t}`&&(o.href=`#${n}`)}))},knowledgeRequirement:()=>{e.knowledgeRequirement.forEach((e=>{const{requiredKnowledge:i}=e;i&&i.href===`#${t}`&&(i.href=`#${n}`)}))}};p(i,((t,n)=>{e[n]&&t()}))}(e,n.id,i.id)}));r.get("artifact").forEach((e=>{!function(e,t,n){const i={sourceRef:()=>{const{sourceRef:i}=e;i.href===`#${t}`&&(i.href=`#${n}`)},targetRef:()=>{const{targetRef:i}=e;i.href===`#${t}`&&(i.href=`#${n}`)}};p(i,((t,n)=>{e[n]&&t()}))}(e,n.id,i.id)}))}shouldSkipUpdate(e,t,n){return!function(e,t){return Np in e&&Np in t}(t,n)||!hn(e,"dmn:DRGElement")&&!hn(e,"dmn:TextAnnotation")}}qp.$inject=["eventBus"];let Vp=class extends Gd{static $inject=["eventBus","modeling"];constructor(e,t){super(e),this._modeling=t,this.postExecuted("element.updateProperties",this.updateVariableFromElement),this.postExecuted("element.updateLabel",this.updateVariableFromLabel)}updateVariableFromLabel=({context:e})=>{const{element:t,newLabel:n}=e,i=fn(t).variable;i&&this._modeling.updateProperties(i,{name:n})};updateVariableFromElement=({context:e})=>{const{element:t,properties:n}=e,i=fn(t);i.variable&&(hn(t,"dmn:Decision")||hn(t,"dmn:BusinessKnowledgeModel"))&&this.isNameChanged(n)&&(this.isVariable(t)||this.shouldSyncVariable(t)||this.syncElementVariableChange(i))};isNameChanged(e){return"name"in e}isVariable(e){const t=function(e){return e.$parent}(e);return hn(e,"dmn:InformationItem")&&t&&t.get("variable")===e}shouldSyncVariable(e){const t=fn(e),n=t.get("variable");return n&&t.name===n.name}syncElementVariableChange(e){const t=e.get("name"),n=e.variable;this._modeling.updateProperties(n,{name:t})}};var Fp={__init__:["createConnectionBehavior","idChangeBehavior","nameChangeBehavior","layoutConnectionBehavior","replaceConnectionBehavior","replaceElementBehavior"],createConnectionBehavior:["type",$p],idChangeBehavior:["type",qp],nameChangeBehavior:["type",Vp],layoutConnectionBehavior:["type",jp],replaceConnectionBehavior:["type",Bp],replaceElementBehavior:["type",Lp]};function zp(e){Gd.call(this,e),this.init()}function Qp(e){e.invoke(zp,this)}function Hp(e,t){if(!e||Xp(e)||!t||Xp(t))return null;if(e===t)return!1;if(hn(e,"dmn:BusinessKnowledgeModel")&&gn(t,["dmn:BusinessKnowledgeModel","dmn:Decision"]))return{type:"dmn:KnowledgeRequirement"};if(hn(e,"dmn:Decision")){if(hn(t,"dmn:Decision"))return{type:"dmn:InformationRequirement"};if(hn(t,"dmn:KnowledgeSource"))return{type:"dmn:AuthorityRequirement"}}if(hn(e,"dmn:Definitions")||hn(t,"dmn:Definitions"))return!1;if(hn(e,"dmn:InputData")){if(hn(t,"dmn:Decision"))return{type:"dmn:InformationRequirement"};if(hn(t,"dmn:KnowledgeSource"))return{type:"dmn:AuthorityRequirement"}}return hn(e,"dmn:KnowledgeSource")&&gn(t,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:KnowledgeSource"])?{type:"dmn:AuthorityRequirement"}:!!(hn(e,"dmn:TextAnnotation")&&!hn(t,"dmn:TextAnnotation")||!hn(e,"dmn:TextAnnotation")&&hn(t,"dmn:TextAnnotation"))&&{type:"dmn:Association"}}function Wp(e,t){return gn(e,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:InputData","dmn:KnowledgeSource","dmn:TextAnnotation"])&&hn(t,"dmn:Definitions")}function Up(e,t){return r(e)||(e=[e]),!t||!(!g(e,(function(e){return gn(e,["dmn:BusinessKnowledgeModel","dmn:Decision","dmn:InputData","dmn:KnowledgeSource","dmn:TextAnnotation","dmn:InformationRequirement","dmn:AuthorityRequirement","dmn:KnowledgeRequirement","dmn:Association"])}))||!hn(t,"dmn:Definitions"))}function Xp(e){return!!e.labelTarget}zp.$inject=["eventBus"],yn(zp,Gd),zp.prototype.addRule=function(e,t,n){var i=this;"string"==typeof e&&(e=[e]),e.forEach((function(e){i.canExecute(e,t,(function(e,t,i){return n(e)}),!0)}))},zp.prototype.init=function(){},yn(Qp,zp),Qp.$inject=["injector"],Qp.prototype.init=function(){this.addRule("connection.create",(function(e){return Hp(e.source,e.target)})),this.addRule("connection.reconnect",(function(e){return e.connection,Hp(e.source,e.target)})),this.addRule("connection.updateWaypoints",(function(e){const t=e.connection;return{type:t.type,businessObject:t.businessObject}})),this.addRule("elements.move",(function(e){var t=e.target,n=e.shapes;return e.position,Up(n,t)})),this.addRule("shape.create",(function(e){return Wp(e.shape,e.target)})),this.addRule("shape.resize",(function(e){return hn(e.shape,"dmn:TextAnnotation")}))},Qp.prototype.canConnect=Hp,Qp.prototype.canCreate=Wp,Qp.prototype.canMove=Up;var Kp={__depends__:[gc],__init__:["drdRules"],drdRules:["type",Qp]};function Gp(e){this._model=e}function Yp(e,t,n,i,o){o.invoke(Gd,this),this._definitionPropertiesView=t,this._drdFactory=n,this._drdRules=i;var r=this;function s(e){var t=e.connection,n=e.parent,i=e.shape;t&&!hn(t,"dmn:Association")&&(n=t.target),r.updateParent(i||t,n)}function a(e){var t=e.connection,n=e.shape,i=e.parent||e.newParent;t&&!hn(t,"dmn:Association")&&(i=t.target),r.updateParent(n||t,i)}function l(e){var t=e.shape;(hn(t,"dmn:DRGElement")||hn(t,"dmn:TextAnnotation"))&&r.updateBounds(t)}function c(e){r.updateConnectionWaypoints(e)}this.executed(["connection.create","connection.layout"],(function(t){var n=t.connection;t.cropped||(n.waypoints=e.getCroppedWaypoints(n),t.cropped=!0)}),!0),this.reverted(["connection.layout"],(function(e){delete e.cropped}),!0),this.executed(["connection.create","connection.delete","connection.move","shape.create","shape.delete"],s,!0),this.reverted(["connection.create","connection.delete","connection.move","shape.create","shape.delete"],a,!0),this.executed(["shape.create","shape.move","shape.resize"],l,!0),this.reverted(["shape.create","shape.move","shape.resize"],l,!0),this.executed(["connection.create","connection.layout","connection.move","connection.updateWaypoints"],c,!0),this.reverted(["connection.create","connection.layout","connection.move","connection.updateWaypoints"],c,!0),this.executed("connection.create",(function(e){var t=e.connection,n=t.businessObject,i=e.target.businessObject;hn(t,"dmn:Association")?s(e):r.updateSemanticParent(n,i)}),!0),this.reverted("connection.create",(function(e){a(e)}),!0),this.executed("connection.reconnect",(function(e){var t=e.connection.businessObject,n=e.newTarget.businessObject;hn(t,"dmn:Association")||r.updateSemanticParent(t,n)}),!0),this.reverted("connection.reconnect",(function(e){var t=e.connection.businessObject,n=e.oldTarget.businessObject;hn(t,"dmn:Association")||r.updateSemanticParent(t,n)}),!0),this.executed("element.updateProperties",(function(e){t.update()}),!0),this.reverted("element.updateProperties",(function(e){t.update()}),!0)}function Zp(e,t){this._modeling=e,this._canvas=t}function Jp(e){this._modeling=e}function ef(e,t){this._canvas=e,this._layouter=t}Gp.$inject=["moddle"],Gp.prototype._needsId=function(e){return gn(e,["dmn:Artifact","dmn:DMNElement","dmn:DRGElement","dmndi:DMNDiagram","dmndi:DMNDiagramElement"])},Gp.prototype._ensureId=function(e){var t=(e.$type||"").replace(/^[^:]*:/g,"")+"_";!e.id&&this._needsId(e)&&(e.id=this._model.ids.nextPrefixed(t,e))},Gp.prototype.create=function(e,t){var n=this._model.create(e,t||{});return this._ensureId(n),n},Gp.prototype.createDiShape=function(e,t,n){return this.create("dmndi:DMNShape",M({dmnElementRef:e,bounds:this.createDiBounds(t)},n))},Gp.prototype.createDiBounds=function(e){return this.create("dc:Bounds",e)},Gp.prototype.createDiEdge=function(e,t,n){return this.create("dmndi:DMNEdge",{dmnElementRef:e,waypoint:this.createDiWaypoints(t)},n)},Gp.prototype.createDiWaypoints=function(e){var t=this;return e.map((function(e){return t.createDiWaypoint(e)}))},Gp.prototype.createDiWaypoint=function(e){return this.create("dc:Point",A(e,["x","y"]))},Gp.prototype.createExtensionElements=function(){return this.create("dmn:ExtensionElements",{values:[]})},yn(Yp,Gd),Yp.$inject=["connectionDocking","definitionPropertiesView","drdFactory","drdRules","injector"],Yp.prototype.updateBounds=function(e){M(e.businessObject.di.bounds,{x:e.x,y:e.y,width:e.width,height:e.height})},Yp.prototype.updateConnectionWaypoints=function(e){var t=this._drdFactory,n=e.connection,i=n.businessObject.di;i.waypoint=t.createDiWaypoints(n.waypoints).map((function(e){return e.$parent=i,e}))},Yp.prototype.updateParent=function(e,t){var n=e.parent;hn(e,"dmn:DRGElement")||hn(e,"dmn:Artifact")||(n=t);var i=e.businessObject,o=n&&n.businessObject;this.updateSemanticParent(i,o),this.updateDiParent(i.di,o&&o.di)},Yp.prototype.updateSemanticParent=function(e,t){var n,i;e.$parent!==t&&(hn(e,"dmn:DRGElement")?i="drgElement":hn(e,"dmn:Artifact")?i="artifact":hn(e,"dmn:InformationRequirement")?i="informationRequirement":hn(e,"dmn:AuthorityRequirement")?i="authorityRequirement":hn(e,"dmn:KnowledgeRequirement")&&(i="knowledgeRequirement"),e.$parent&&wi(n=e.$parent.get(i),e),t?(n=t.get(i))&&(n.push(e),e.$parent=t):e.$parent=null)},Yp.prototype.updateDiParent=function(e,t){if(e.$parent!==t){if(!gn(e,["dmndi:DMNEdge","dmndi:DMNShape"]))throw new Error("unsupported");for(var n=t||e;!hn(n,"dmndi:DMNDiagram");)n=n.$parent;var i=n.get("diagramElements");t?(e.$parent=n,Ci(i,e)):(e.$parent=null,wi(i,e))}},Zp.$inject=["modeling","canvas"],Zp.prototype.preExecute=function(e){var t=this._modeling,n=e.elements,o=e.alignment;p(n,(function(e){var n={x:0,y:0};i(o.left)?n.x=o.left-e.x:i(o.right)?n.x=o.right-e.width-e.x:i(o.center)?n.x=o.center-Math.round(e.width/2)-e.x:i(o.top)?n.y=o.top-e.y:i(o.bottom)?n.y=o.bottom-e.height-e.y:i(o.middle)&&(n.y=o.middle-Math.round(e.height/2)-e.y),t.moveElements([e],n,e.parent)}))},Zp.prototype.postExecute=function(e){},Jp.$inject=["modeling"],Jp.prototype.preExecute=function(e){var t=e.source;if(!t)throw new Error("source required");var n=e.target||t.parent,i=e.shape,o=e.hints||{};i=e.shape=this._modeling.createShape(i,e.position,n,{attach:o.attach}),e.shape=i},Jp.prototype.postExecute=function(e){var t,n,i=e.hints||{};t=e.source,n=e.shape,m(t.outgoing,(function(e){return e.target===n}))||(i.connectionTarget===e.source?this._modeling.connect(e.shape,e.source,e.connection):this._modeling.connect(e.source,e.shape,e.connection))},ef.$inject=["canvas","layouter"],ef.prototype.execute=function(e){var t=e.connection,n=e.source,i=e.target,o=e.parent,r=e.parentIndex,s=e.hints;if(!n||!i)throw new Error("source and target required");if(!o)throw new Error("parent required");return t.source=n,t.target=i,t.waypoints||(t.waypoints=this._layouter.layoutConnection(t,s)),this._canvas.addConnection(t,o,r),t},ef.prototype.revert=function(e){var t=e.connection;return this._canvas.removeConnection(t),t.source=null,t.target=null,t};var tf=Math.round;function nf(e){this._modeling=e}nf.$inject=["modeling"],nf.prototype.preExecute=function(e){var t=e.elements,n=e.parent,i=e.parentIndex,o=e.position,r=e.hints,s=this._modeling;p(t,(function(e){a(e.x)||(e.x=0),a(e.y)||(e.y=0)}));var l=mi(d(t,(function(e){return!e.hidden})));p(t,(function(e){co(e)&&(e.waypoints=v(e.waypoints,(function(e){return{x:tf(e.x-l.x-l.width/2+o.x),y:tf(e.y-l.y-l.height/2+o.y)}}))),M(e,{x:tf(e.x-l.x-l.width/2+o.x),y:tf(e.y-l.y-l.height/2+o.y)})}));var c=hi(t),u={};p(t,(function(e){if(co(e))u[e.id]=a(i)?s.createConnection(u[e.source.id],u[e.target.id],i,e,e.parent||n,r):s.createConnection(u[e.source.id],u[e.target.id],e,e.parent||n,r);else{var t=M({},r);-1===c.indexOf(e)&&(t.autoResize=!1),uo(e)&&(t=P(t,["attach"])),u[e.id]=a(i)?s.createShape(e,A(e,["x","y","width","height"]),e.parent||n,i,t):s.createShape(e,A(e,["x","y","width","height"]),e.parent||n,t)}})),e.elements=x(u)};var of=Math.round;function rf(e){this._canvas=e}function sf(e){rf.call(this,e)}rf.$inject=["canvas"],rf.prototype.execute=function(e){var t=e.shape,n=e.position,i=e.parent,o=e.parentIndex;if(!i)throw new Error("parent required");if(!n)throw new Error("position required");return void 0!==n.width?M(t,n):M(t,{x:n.x-of(t.width/2),y:n.y-of(t.height/2)}),this._canvas.addShape(t,i,o),t},rf.prototype.revert=function(e){var t=e.shape;return this._canvas.removeShape(t),t},yn(sf,rf),sf.$inject=["canvas"];var af=rf.prototype.execute;sf.prototype.execute=function(e){var t=e.shape;return function(e){["width","height"].forEach((function(t){void 0===e[t]&&(e[t]=0)}))}(t),t.labelTarget=e.labelTarget,af.call(this,e)};var lf=rf.prototype.revert;function cf(e,t){if("function"!=typeof t)throw new Error("removeFn iterator must be a function");if(e){for(var n;n=e[0];)t(n);return e}}function uf(e,t){this._canvas=e,this._modeling=t}function hf(e,t){this._modeling=e,this._elementRegistry=t}function df(e,t){this._canvas=e,this._modeling=t}function pf(e){this._modeling=e}sf.prototype.revert=function(e){return e.shape.labelTarget=null,lf.call(this,e)},uf.$inject=["canvas","modeling"],uf.prototype.preExecute=function(e){var t=this._modeling,n=e.connection;cf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),cf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})}))},uf.prototype.execute=function(e){var t=e.connection,n=t.parent;return e.parent=n,e.parentIndex=Oi(n.children,t),e.source=t.source,e.target=t.target,this._canvas.removeConnection(t),t.source=null,t.target=null,t},uf.prototype.revert=function(e){var t=e.connection,n=e.parent,i=e.parentIndex;return t.source=e.source,t.target=e.target,Ci(n.children,t,i),this._canvas.addConnection(t,n),t},hf.$inject=["modeling","elementRegistry"],hf.prototype.postExecute=function(e){var t=this._modeling,n=this._elementRegistry;p(e.elements,(function(e){n.get(e.id)&&(e.waypoints?t.removeConnection(e):t.removeShape(e))}))},df.$inject=["canvas","modeling"],df.prototype.preExecute=function(e){var t=this._modeling,n=e.shape;cf(n.incoming,(function(e){t.removeConnection(e,{nested:!0})})),cf(n.outgoing,(function(e){t.removeConnection(e,{nested:!0})})),cf(n.children,(function(e){co(e)?t.removeConnection(e,{nested:!0}):t.removeShape(e,{nested:!0})}))},df.prototype.execute=function(e){var t=this._canvas,n=e.shape,i=n.parent;return e.oldParent=i,e.oldParentIndex=Oi(i.children,n),t.removeShape(n),n},df.prototype.revert=function(e){var t=this._canvas,n=e.shape,i=e.oldParent,o=e.oldParentIndex;return Ci(i.children,n,o),t.addShape(n,i),n},pf.$inject=["modeling"];var ff={x:"y",y:"x"};function gf(e,t){this._layouter=e,this._canvas=t}function mf(){}function vf(e,t,n){var i=Wa(t),o=Wa(n),r=Ua(e,i),s=r.x*(n.width/t.width),a=r.y*(n.height/t.height);return ho({x:o.x+s,y:o.y+a})}function yf(e,t,n){var i=Cf(e),o=Of(i,t),r=i[0];return o.length?o[o.length-1]:vf(r.original||r,n,t)}function xf(e,t,n){var i=Cf(e),o=Of(i,t),r=i[i.length-1];return o.length?o[0]:vf(r.original||r,n,t)}function bf(e,t,n){var i=Cf(e),o=wf(t,n),r=i[0];return vf(r.original||r,o,t)}function _f(e,t,n){var i=Cf(e),o=wf(t,n),r=i[i.length-1];return vf(r.original||r,o,t)}function wf(e,t){return{x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}}function Cf(e){var t=e.waypoints;if(!t.length)throw new Error("connection#"+e.id+": no waypoints");return t}function Of(e,t){return d(v(e,kf),(function(e){return function(e,t){return"intersect"===vo(t,e,1)}(e,t)}))}function kf(e){return e.original||e}function Ef(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}function Sf(e){this._modeling=e}function Rf(e){this._helper=new Sf(e)}function Tf(e){this._modeling=e,this._helper=new Sf(e)}function Mf(e){this._modeling=e}function Af(e){return e.original||e}function Pf(e,t){this._modeling=e,this._rules=t}function Df(e){this._modeling=e}function $f(e,t){return-1!==e.indexOf(t)}function jf(e){this._modeling=e}function If(e){return M({},e)}function Bf(e){switch(e){case"n":case"s":return"y";case"w":case"e":return"x"}}function Lf(e,t,n){var i=Bf(n);return/e|s/.test(n)?e[i]>t:/n|w/.test(n)?e[i]<t:void 0}function Nf(e,t){return-1!==e.indexOf(t)}function qf(e){this._modeling=e}function Vf(e){var t={};return p(e,(function(e){t[e.id]=e.hidden,e.children&&(t=M({},t,Vf(e.children)))})),t}function Ff(e,t){var n=[];return p(e,(function(e){e.hidden=t,n=n.concat(e),e.children&&(n=n.concat(Ff(e.children,e.collapsed||t)))})),n}function zf(e,t){var n=[];return p(e,(function(e){e.hidden=t[e.id],n=n.concat(e),e.children&&(n=n.concat(zf(e.children,t)))})),n}function Qf(e){this._modeling=e}function Hf(e,t){return wi(e&&e.attachers,t)}function Wf(e,t,n){if(e){var i=e.attachers;i||(e.attachers=i=[]),Ci(i,t,n)}}function Uf(){}function Xf(e,t,n){this._eventBus=e,this._elementFactory=t,this._commandStack=n;var i=this;e.on("diagram.init",(function(){i.registerHandlers(n)}))}function Kf(e){this._moddle=e}function Gf(){function e(e,t){var n=e.label||e,i=e.labelTarget||e;return function(e,t,n){var i=e.businessObject,o=_l(i);o&&(i[o]=t),n&&(e.hidden=!t)}(n,t,i!==n),[n,i]}this.execute=function(t){return t.oldLabel=wl(t.element),e(t.element,t.newLabel)},this.revert=function(t){return e(t.element,t.oldLabel)}}pf.prototype.preExecute=function(e){var t=this._modeling,n=e.groups,i=e.axis,o=e.dimension;function r(e,t){e.range.min=Math.min(t[i],e.range.min),e.range.max=Math.max(t[i]+t[o],e.range.max)}function s(e){return e[i]+e[o]/2}function a(e){return e.length-1}function l(e){return e.max-e.min}var c,u,h=n[0],d=a(n),f=n[d],g=0;p(n,(function(e,c){var u,h,f;e.elements.length<2?c&&c!==n.length-1&&(r(e,e.elements[0]),g+=l(e.range)):(h=(u=w(e.elements,i))[0],c===d&&(h=u[a(u)]),f=s(h),e.range=null,p(u,(function(n){!function(e,n){var o={y:0};o[i]=e-s(n),o[i]&&(o[ff[i]]=0,t.moveElements([n],o,n.parent))}(f,n),null!==e.range?r(e,n):e.range={min:n[i],max:n[i]+n[o]}})),c&&c!==n.length-1&&(g+=l(e.range)))})),u=Math.abs(f.range.min-h.range.max),(c=Math.round((u-g)/(n.length-1)))<n.length-1||p(n,(function(e,r){var s,a={};e!==h&&e!==f&&(s=n[r-1],e.range.max=0,p(e.elements,(function(n,r){a[ff[i]]=0,a[i]=s.range.max-n[i]+c,e.range.min!==n[i]&&(a[i]+=n[i]-e.range.min),a[i]&&t.moveElements([n],a,n.parent),e.range.max=Math.max(n[i]+n[o],r?e.range.max:0)})))}))},pf.prototype.postExecute=function(e){},gf.$inject=["layouter","canvas"],gf.prototype.execute=function(e){var t=e.connection;return M(e,{oldWaypoints:t.waypoints}),t.waypoints=this._layouter.layoutConnection(t,e.hints),t},gf.prototype.revert=function(e){var t=e.connection;return t.waypoints=e.oldWaypoints,t},mf.prototype.execute=function(e){var t=e.connection,n=e.delta,i=e.newParent||t.parent,o=e.newParentIndex,r=t.parent;return e.oldParent=r,e.oldParentIndex=wi(r.children,t),Ci(i.children,t,o),t.parent=i,p(t.waypoints,(function(e){e.x+=n.x,e.y+=n.y,e.original&&(e.original.x+=n.x,e.original.y+=n.y)})),t},mf.prototype.revert=function(e){var t=e.connection,n=t.parent,i=e.oldParent,o=e.oldParentIndex,r=e.delta;return wi(n.children,t),Ci(i.children,t,o),t.parent=i,p(t.waypoints,(function(e){e.x-=r.x,e.y-=r.y,e.original&&(e.original.x-=r.x,e.original.y-=r.y)})),t},Ef.prototype.add=function(e,t){return this.addAll([e],t)},Ef.prototype.addAll=function(e,t){var i=function(e,t,i){n(t)&&(t=!0),s(t)&&(i=t,t=!0);var o=xi((i=i||{}).allShapes),r=xi(i.allConnections),a=xi(i.enclosedElements),l=xi(i.enclosedConnections),c=xi(i.topLevel,t&&b(e,(function(e){return e.id})));function u(e){c[e.source.id]&&c[e.target.id]&&(c[e.id]=[e]),o[e.source.id]&&o[e.target.id]&&(l[e.id]=a[e.id]=e),r[e.id]=e}return fi(e,(function(e){if(a[e.id]=e,!e.waypoints)return o[e.id]=e,p(e.incoming,u),p(e.outgoing,u),e.children;l[e.id]=r[e.id]=e})),{allShapes:o,allConnections:r,topLevel:c,enclosedConnections:l,enclosedElements:a}}(e,!!t,this);return M(this,i),this},Sf.prototype.moveRecursive=function(e,t,n){return e?this.moveClosure(this.getClosure(e),t,n):[]},Sf.prototype.moveClosure=function(e,t,n,i,o){var r=this._modeling,s=e.allShapes,a=e.allConnections,l=e.enclosedConnections,c=e.topLevel,u=!1;o&&o.parent===n&&(u=!0),p(s,(function(e){r.moveShape(e,t,c[e.id]&&!u&&n,{recurse:!1,layout:!1})})),p(a,(function(e){var i=!!s[e.source.id],o=!!s[e.target.id];l[e.id]&&i&&o?r.moveConnection(e,t,c[e.id]&&!u&&n):r.layoutConnection(e,{connectionStart:i&&bf(e,e.source,t),connectionEnd:o&&_f(e,e.target,t)})}))},Sf.prototype.getClosure=function(e){return(new Ef).addAll(e,!0)},Rf.$inject=["modeling"],Rf.prototype.preExecute=function(e){e.closure=this._helper.getClosure(e.shapes)},Rf.prototype.postExecute=function(e){var t,n=e.hints;n&&n.primaryShape&&(t=n.primaryShape,n.oldParent=t.parent),this._helper.moveClosure(e.closure,e.delta,e.newParent,e.newHost,t)},Tf.$inject=["modeling"],Tf.prototype.execute=function(e){var t=e.shape,n=e.delta,i=e.newParent||t.parent,o=e.newParentIndex,r=t.parent;return e.oldBounds=A(t,["x","y","width","height"]),e.oldParent=r,e.oldParentIndex=wi(r.children,t),Ci(i.children,t,o),M(t,{parent:i,x:t.x+n.x,y:t.y+n.y}),t},Tf.prototype.postExecute=function(e){var t=e.shape,n=e.delta,i=e.hints,o=this._modeling;!1!==i.layout&&(p(t.incoming,(function(e){o.layoutConnection(e,{connectionEnd:_f(e,t,n)})})),p(t.outgoing,(function(e){o.layoutConnection(e,{connectionStart:bf(e,t,n)})}))),!1!==i.recurse&&this.moveChildren(e)},Tf.prototype.revert=function(e){var t=e.shape,n=e.oldParent,i=e.oldParentIndex,o=e.delta;return Ci(n.children,t,i),M(t,{parent:n,x:t.x-o.x,y:t.y-o.y}),t},Tf.prototype.moveChildren=function(e){var t=e.delta,n=e.shape;this._helper.moveRecursive(n.children,t,null)},Tf.prototype.getNewParent=function(e){return e.newParent||e.shape.parent},Mf.$inject=["modeling"],Mf.prototype.execute=function(e){var t=e.newSource,n=e.newTarget,i=e.connection,o=e.dockingOrPoints;if(!t&&!n)throw new Error("newSource or newTarget required");return r(o)&&(e.oldWaypoints=i.waypoints,i.waypoints=o),t&&(e.oldSource=i.source,i.source=t),n&&(e.oldTarget=i.target,i.target=n),i},Mf.prototype.postExecute=function(e){var t=e.connection,n=e.newSource,i=e.newTarget,o=e.dockingOrPoints,s=e.hints||{},a={};s.connectionStart&&(a.connectionStart=s.connectionStart),s.connectionEnd&&(a.connectionEnd=s.connectionEnd),!1!==s.layoutConnection&&(!n||i&&"source"!==s.docking||(a.connectionStart=a.connectionStart||Af(r(o)?o[0]:o)),!i||n&&"target"!==s.docking||(a.connectionEnd=a.connectionEnd||Af(r(o)?o[o.length-1]:o)),s.newWaypoints&&(a.waypoints=s.newWaypoints),this._modeling.layoutConnection(t,a))},Mf.prototype.revert=function(e){var t=e.oldSource,n=e.oldTarget,i=e.oldWaypoints,o=e.connection;return t&&(o.source=t),n&&(o.target=n),i&&(o.waypoints=i),o},Pf.$inject=["modeling","rules"],Pf.prototype.preExecute=function(e){var t,n=this,i=this._modeling,o=this._rules,r=e.oldShape,s=e.newData,a=e.hints||{};function l(e,t,n){return o.allowed("connection.reconnect",{connection:n,source:e,target:t})}var c,u={x:s.x,y:s.y},h={x:r.x,y:r.y,width:r.width,height:r.height};t=e.newShape=e.newShape||n.createShape(s,u,r.parent,a),r.host&&i.updateAttachment(t,r.host),!1!==a.moveChildren&&(c=r.children.slice(),i.moveElements(c,{x:0,y:0},t,a));var d=r.incoming.slice(),f=r.outgoing.slice();p(d,(function(e){l(e.source,t,e)&&n.reconnectEnd(e,t,xf(e,t,h),a)})),p(f,(function(e){var i=e.target;l(t,i,e)&&n.reconnectStart(e,t,yf(e,t,h),a)}))},Pf.prototype.postExecute=function(e){var t=e.oldShape;this._modeling.removeShape(t)},Pf.prototype.execute=function(e){},Pf.prototype.revert=function(e){},Pf.prototype.createShape=function(e,t,n,i){return this._modeling.createShape(e,t,n,i)},Pf.prototype.reconnectStart=function(e,t,n,i){this._modeling.reconnectStart(e,t,n,i)},Pf.prototype.reconnectEnd=function(e,t,n,i){this._modeling.reconnectEnd(e,t,n,i)},Df.$inject=["modeling"],Df.prototype.execute=function(e){var t=e.shape,n=e.newBounds,i=e.minBounds;if(void 0===n.x||void 0===n.y||void 0===n.width||void 0===n.height)throw new Error("newBounds must have {x, y, width, height} properties");if(i&&(n.width<i.width||n.height<i.height))throw new Error("width and height cannot be less than minimum height and width");if(!i&&n.width<10||n.height<10)throw new Error("width and height cannot be less than 10px");return e.oldBounds={width:t.width,height:t.height,x:t.x,y:t.y},M(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Df.prototype.postExecute=function(e){var t=this._modeling,n=e.shape,i=e.oldBounds;!1!==(e.hints||{}).layout&&(p(n.incoming,(function(e){t.layoutConnection(e,{connectionEnd:xf(e,n,i)})})),p(n.outgoing,(function(e){t.layoutConnection(e,{connectionStart:yf(e,n,i)})})))},Df.prototype.revert=function(e){var t=e.shape,n=e.oldBounds;return M(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},jf.$inject=["modeling"],jf.prototype.preExecute=function(e){var t=e.delta,n=e.direction,i=e.movingShapes,o=e.resizingShapes,r=e.start,s={};this.moveShapes(i,t),p(o,(function(e){s[e.id]=function(e){return{x:e.x,y:e.y,height:e.height,width:e.width}}(e)})),this.resizeShapes(o,t,n),this.updateConnectionWaypoints(function(e,t){var n=[];return p(e.concat(t),(function(i){var o=i.incoming,r=i.outgoing;p(o.concat(r),(function(i){var o=i.source,r=i.target;($f(e,o)||$f(e,r)||$f(t,o)||$f(t,r))&&($f(n,i)||n.push(i))}))})),n}(i,o),t,n,r,i,o,s)},jf.prototype.execute=function(){},jf.prototype.revert=function(){},jf.prototype.moveShapes=function(e,t){var n=this;p(e,(function(e){n._modeling.moveShape(e,t,null,{autoResize:!1,layout:!1,recurse:!1})}))},jf.prototype.resizeShapes=function(e,t,n){var i=this;p(e,(function(e){var o=function(e,t,n){var i=e.x,o=e.y,r=e.width,s=e.height,a=n.x,l=n.y;switch(t){case"n":return{x:i,y:o+l,width:r,height:s-l};case"s":return{x:i,y:o,width:r,height:s+l};case"w":return{x:i+a,y:o,width:r-a,height:s};case"e":return{x:i,y:o,width:r+a,height:s};default:throw new Error("unknown direction: "+t)}}(e,n,t);i._modeling.resizeShape(e,o,null,{attachSupport:!1,autoResize:!1,layout:!1})}))},jf.prototype.updateConnectionWaypoints=function(e,t,n,i,o,r,s){var a=this,l=o.concat(r);p(e,(function(e){var c=e.source,u=e.target,h=function(e){return v(e.waypoints,(function(e){return(e=If(e)).original&&(e.original=If(e.original)),e}))}(e),d=Bf(n),p={};Nf(l,c)&&Nf(l,u)?(h=v(h,(function(e){return Lf(e,i,n)&&(e[d]=e[d]+t[d]),e.original&&Lf(e.original,i,n)&&(e.original[d]=e.original[d]+t[d]),e})),a._modeling.updateWaypoints(e,h,{labelBehavior:!1})):(Nf(l,c)||Nf(l,u))&&(Nf(o,c)?p.connectionStart=bf(e,c,t):Nf(o,u)?p.connectionEnd=_f(e,u,t):Nf(r,c)?p.connectionStart=yf(e,c,s[c.id]):Nf(r,u)&&(p.connectionEnd=xf(e,u,s[u.id])),a._modeling.layoutConnection(e,p))}))},qf.$inject=["modeling"],qf.prototype.execute=function(e){var t=e.shape,n=t.children;e.oldChildrenVisibility=Vf(n),t.collapsed=!t.collapsed;var i=Ff(n,t.collapsed);return[t].concat(i)},qf.prototype.revert=function(e){var t=e.shape,n=e.oldChildrenVisibility,i=zf(t.children,n);return t.collapsed=!t.collapsed,[t].concat(i)},Qf.$inject=["modeling"],Qf.prototype.execute=function(e){var t=e.shape,n=e.newHost,i=t.host;return e.oldHost=i,e.attacherIdx=Hf(i,t),Wf(n,t),t.host=n,t},Qf.prototype.revert=function(e){var t=e.shape,n=e.newHost,i=e.oldHost,o=e.attacherIdx;return t.host=i,Hf(n,t),Wf(i,t,o),t},Uf.prototype.execute=function(e){var t=e.connection,n=e.newWaypoints;return e.oldWaypoints=t.waypoints,t.waypoints=n,t},Uf.prototype.revert=function(e){var t=e.connection,n=e.oldWaypoints;return t.waypoints=n,t},Xf.$inject=["eventBus","elementFactory","commandStack"],Xf.prototype.getHandlers=function(){return{"shape.append":Jp,"shape.create":rf,"shape.delete":df,"shape.move":Tf,"shape.resize":Df,"shape.replace":Pf,"shape.toggleCollapse":qf,spaceTool:jf,"label.create":sf,"connection.create":ef,"connection.delete":uf,"connection.move":mf,"connection.layout":gf,"connection.updateWaypoints":Uf,"connection.reconnect":Mf,"elements.create":nf,"elements.move":Rf,"elements.delete":hf,"elements.distribute":pf,"elements.align":Zp,"element.updateAttachment":Qf}},Xf.prototype.registerHandlers=function(e){p(this.getHandlers(),(function(t,n){e.registerHandler(n,t)}))},Xf.prototype.moveShape=function(e,t,n,i,o){"object"==typeof i&&(o=i,i=null);var r={shape:e,delta:t,newParent:n,newParentIndex:i,hints:o||{}};this._commandStack.execute("shape.move",r)},Xf.prototype.updateAttachment=function(e,t){var n={shape:e,newHost:t};this._commandStack.execute("element.updateAttachment",n)},Xf.prototype.moveElements=function(e,t,n,i){var o,r=(i=i||{}).attach,s=n;!0===r?(o=n,s=n.parent):!1===r&&(o=null);var a={shapes:e,delta:t,newParent:s,newHost:o,hints:i};this._commandStack.execute("elements.move",a)},Xf.prototype.moveConnection=function(e,t,n,i,o){"object"==typeof i&&(o=i,i=void 0);var r={connection:e,delta:t,newParent:n,newParentIndex:i,hints:o||{}};this._commandStack.execute("connection.move",r)},Xf.prototype.layoutConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.layout",n)},Xf.prototype.createConnection=function(e,t,n,i,o,r){"object"==typeof n&&(r=o,o=i,i=n,n=void 0);var s={source:e,target:t,parent:o,parentIndex:n,connection:i=this._create("connection",i),hints:r};return this._commandStack.execute("connection.create",s),s.connection},Xf.prototype.createShape=function(e,t,n,i,o){"number"!=typeof i&&(o=i,i=void 0);var r,s,a=(o=o||{}).attach;e=this._create("shape",e),a?(r=n.parent,s=n):r=n;var l={position:t,shape:e,parent:r,parentIndex:i,host:s,hints:o};return this._commandStack.execute("shape.create",l),l.shape},Xf.prototype.createElements=function(e,t,n,i,o){r(e)||(e=[e]),"number"!=typeof i&&(o=i,i=void 0);var s={position:t,elements:e,parent:n,parentIndex:i,hints:o=o||{}};return this._commandStack.execute("elements.create",s),s.elements},Xf.prototype.createLabel=function(e,t,n,i){n=this._create("label",n);var o={labelTarget:e,position:t,parent:i||e.parent,shape:n};return this._commandStack.execute("label.create",o),o.shape},Xf.prototype.appendShape=function(e,t,n,i,o){o=o||{};var r={source:e,position:n,target:i,shape:t=this._create("shape",t),connection:o.connection,connectionParent:o.connectionParent,hints:o};return this._commandStack.execute("shape.append",r),r.shape},Xf.prototype.removeElements=function(e){var t={elements:e};this._commandStack.execute("elements.delete",t)},Xf.prototype.distributeElements=function(e,t,n){var i={groups:e,axis:t,dimension:n};this._commandStack.execute("elements.distribute",i)},Xf.prototype.removeShape=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.delete",n)},Xf.prototype.removeConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.delete",n)},Xf.prototype.replaceShape=function(e,t,n){var i={oldShape:e,newData:t,hints:n||{}};return this._commandStack.execute("shape.replace",i),i.newShape},Xf.prototype.alignElements=function(e,t){var n={elements:e,alignment:t};this._commandStack.execute("elements.align",n)},Xf.prototype.resizeShape=function(e,t,n,i){var o={shape:e,newBounds:t,minBounds:n,hints:i};this._commandStack.execute("shape.resize",o)},Xf.prototype.createSpace=function(e,t,n,i,o){var r={delta:n,direction:i,movingShapes:e,resizingShapes:t,start:o};this._commandStack.execute("spaceTool",r)},Xf.prototype.updateWaypoints=function(e,t,n){var i={connection:e,newWaypoints:t,hints:n||{}};this._commandStack.execute("connection.updateWaypoints",i)},Xf.prototype.reconnect=function(e,t,n,i,o){var r={connection:e,newSource:t,newTarget:n,dockingOrPoints:i,hints:o||{}};this._commandStack.execute("connection.reconnect",r)},Xf.prototype.reconnectStart=function(e,t,n,i){i||(i={}),this.reconnect(e,t,e.target,n,M(i,{docking:"source"}))},Xf.prototype.reconnectEnd=function(e,t,n,i){i||(i={}),this.reconnect(e,e.source,t,n,M(i,{docking:"target"}))},Xf.prototype.connect=function(e,t,n,i){return this.createConnection(e,t,n||{},e.parent,i)},Xf.prototype._create=function(e,t){return t instanceof $o?t:this._elementFactory.create(e,t)},Xf.prototype.toggleCollapse=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.toggleCollapse",n)},Kf.$inject=["moddle"],Kf.prototype.execute=function(e){var t=this._moddle.ids,n=e.id,i=e.element;e.claiming?t.claim(n,i):t.unclaim(n)},Kf.prototype.revert=function(e){var t=this._moddle.ids,n=e.id,i=e.element;e.claiming?t.unclaim(n):t.claim(n,i)};const Yf="id";function Zf(e,t){this._elementRegistry=e,this._moddle=t}function Jf(e,t){return Yf in e&&e[Yf]!==t[Yf]}function eg(e,t){p(t,(function(t,n){e.set(n,t)}))}function tg(e){this._elementRegistry=e}function ng(e,t){p(t,(function(t,n){e.set(n,t)}))}function ig(e,t,n){this._canvas=e,this._drdRules=t,n.invoke(Xf,this)}function og(){}Zf.$inject=["elementRegistry","moddle"],Zf.prototype.execute=function(e){const{element:t,properties:n}=e,i=[t];if(!t)throw new Error("element required");const o=this._elementRegistry,r=this._moddle.ids,s=fn(t),a=e.oldProperties||function(e,t){return f(t,(function(t,n){return t[n]=e.get(n),t}),{})}(s,y(n));return Jf(n,s)&&(r.unclaim(s[Yf]),o.updateId(t,n[Yf]),r.claim(n[Yf],s)),"name"in n&&t.label&&i.push(t.label),eg(s,n),e.oldProperties=a,e.changed=i,i},Zf.prototype.revert=function(e){const{element:t,properties:n,oldProperties:i}=e,o=fn(t),r=this._elementRegistry,s=this._moddle.ids;return eg(o,i),Jf(n,o)&&(s.unclaim(n[Yf]),r.updateId(t,i[Yf]),s.claim(i[Yf],o)),e.changed},tg.$inject=["elementRegistry"],tg.prototype.execute=function(e){var t=e.element,n=e.moddleElement,i=e.properties;if(!n)throw new Error("<moddleElement> required");var o=e.changed||[t],r=e.oldProperties||function(e,t){return f(t,(function(t,n){return t[n]=e.get(n),t}),{})}(n,y(i));return ng(n,i),e.oldProperties=r,e.changed=o,o},tg.prototype.revert=function(e){var t=e.oldProperties,n=e.moddleElement,i=e.changed;return ng(n,t),i},yn(ig,Xf),ig.$inject=["canvas","drdRules","injector"],ig.prototype.claimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t,claiming:!0})},ig.prototype.connect=function(e,t,n,i){var o=this._drdRules,r=this._canvas.getRootElement();return n||(n=o.canConnect(e,t)||{type:"dmn:Association"}),this.createConnection(e,t,n,r,i)},ig.prototype.getHandlers=function(){var e=Xf.prototype.getHandlers.call(this);return e["id.updateClaim"]=Kf,e["element.updateLabel"]=Gf,e["element.updateProperties"]=Zf,e["element.updateModdleProperties"]=tg,e},ig.prototype.unclaimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t})},ig.prototype.updateModdleProperties=function(e,t,n){this._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:t,properties:n})},ig.prototype.updateProperties=function(e,t){this._commandStack.execute("element.updateProperties",{element:e,properties:t})},ig.prototype.updateLabel=function(e,t,n,i){this._commandStack.execute("element.updateLabel",{element:e,newLabel:t,newBounds:n,hints:i||{}})},og.prototype.layoutConnection=function(e,t){return[(t=t||{}).connectionStart||mo(t.source||e.source),t.connectionEnd||mo(t.target||e.target)]};function rg(e){this._connectionDocking=e}function sg(e,t){return e?e.original||e:mo(t)}function ag(e){return M({original:e.point.original||e.point},e.actual)}function lg(e,t){this._elementRegistry=e,this._graphicsFactory=t}yn(rg,og),rg.$inject=["connectionDocking"],rg.prototype.layoutConnection=function(e,t){var n=this._connectionDocking;t||(t={});var i=t.source||e.source,o=t.target||e.target,r=t.waypoints||e.waypoints||[],s=t.connectionStart,a=t.connectionEnd,l=vo(i,o);if(s||(s=sg(r[0],i)),a||(a=sg(r[r.length-1],o)),hn(e,"dmn:InformationRequirement")){r=[s,a];var c=n.getCroppedWaypoints(M({},e,{waypoints:r}),i,o),u={x:(a=c.pop()).x,y:a.y};return l.includes("bottom")?u.y+=20:l.includes("top")?u.y-=20:l.includes("right")?u.x+=20:u.x-=20,r=c.concat([u,a])}return[s,a]},lg.$inject=["elementRegistry","graphicsFactory"],lg.prototype.getCroppedWaypoints=function(e,t,n){t=t||e.source,n=n||e.target;var i=this.getDockingPoint(e,t,!0),o=this.getDockingPoint(e,n),r=e.waypoints.slice(i.idx+1,o.idx);return r.unshift(ag(i)),r.push(ag(o)),r},lg.prototype.getDockingPoint=function(e,t,n){var i,o,r=e.waypoints;return{point:o=r[i=n?0:r.length-1],actual:this._getIntersection(t,e,n)||o,idx:i}},lg.prototype._getIntersection=function(e,t,n){return yo(this._getShapePath(e),this._getConnectionPath(t),n)},lg.prototype._getConnectionPath=function(e){return this._graphicsFactory.getConnectionPath(e)},lg.prototype._getShapePath=function(e){return this._graphicsFactory.getShapePath(e)},lg.prototype._getGfx=function(e){return this._elementRegistry.getGraphics(e)};var cg={__init__:["modeling","drdUpdater"],__depends__:[Fp,Kp,Va,_p,Aa,Cp],drdFactory:["type",Gp],drdUpdater:["type",Yp],elementFactory:["type",Xl],modeling:["type",ig],layouter:["type",rg],connectionDocking:["type",lg]};function ug(e,t){this._eventBus=e,this.offset=5;var n=t.cls("djs-outline",["no-fill"]),i=this;function o(e){var t=Qn("rect");return jn(t,M({x:0,y:0,rx:4,width:100,height:100},n)),t}e.on(["shape.added","shape.changed"],500,(function(e){var t=e.element,n=e.gfx,r=Zt(".djs-outline",n);r||An(n,r=i.getOutline(t)||o()),i.updateShapeOutline(r,t)})),e.on(["connection.added","connection.changed"],(function(e){var t=e.element,n=e.gfx,r=Zt(".djs-outline",n);r||An(n,r=o()),i.updateConnectionOutline(r,t)}))}ug.prototype.updateShapeOutline=function(e,t){var n=!1,i=this._getProviders();i.length&&p(i,(function(i){n=n||i.updateOutline(t,e)})),n||jn(e,{x:-this.offset,y:-this.offset,width:t.width+2*this.offset,height:t.height+2*this.offset})},ug.prototype.updateConnectionOutline=function(e,t){var n=mi(t);jn(e,{x:n.x-this.offset,y:n.y-this.offset,width:n.width+2*this.offset,height:n.height+2*this.offset})},ug.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("outline.getProviders",e,(function(e){e.providers.push(t)}))},ug.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"outline.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},ug.prototype.getOutline=function(e){var t;return p(this._getProviders(),(function(n){l(n.getOutline)&&(t=t||n.getOutline(e))})),t},ug.$inject=["eventBus","styles","elementRegistry"];function hg(e,t,n){this._canvas=t;var i=this;e.on("element.changed",(function(e){n.isSelected(e.element)&&i._updateMultiSelectionOutline(n.get())})),e.on("selection.changed",(function(e){var t=e.newSelection;i._updateMultiSelectionOutline(t)}))}hg.prototype._updateMultiSelectionOutline=function(e){var t=this._canvas.getLayer("selectionOutline");Nn(t);var n=e.length>1;if(Bn(this._canvas.getContainer())[n?"add":"remove"]("djs-multi-select"),n){var i=function(e){return{x:e.x-6,y:e.y-6,width:e.width+12,height:e.height+12}}(mi(e)),o=Qn("rect");jn(o,M({rx:3},i)),Bn(o).add("djs-selection-outline"),An(t,o)}},hg.$inject=["eventBus","canvas","selection"];var dg={__depends__:[Aa],__init__:["outline","multiSelectionOutline"],outline:["type",ug],multiSelectionOutline:["type",hg]},pg=Math.round;function fg(e,t,n,i,o){function r(e,t,n,i){return o.allowed("elements.move",{shapes:e,delta:t,position:n,target:i})}function a(e,n,i,o){if(s(i)&&(o=i,i=!1),!n.waypoints&&n.parent&&!Bn(e.target).has("djs-hit-no-move")){var r=function(e){return{x:e.x+pg(e.width/2),y:e.y+pg(e.height/2)}}(n);return t.init(e,r,"shape.move",{cursor:"grabbing",autoActivate:i,data:{shape:n,context:o||{}}}),!0}}e.on("shape.move.start",1500,(function(e){var t=e.context,n=e.shape,o=i.get().slice();-1===o.indexOf(n)&&(o=[n]),o=function(e){var t=b(e,"id");return d(e,(function(e){for(;e=e.parent;)if(t[e.id])return!1;return!0}))}(o),M(t,{shapes:o,validatedShapes:o,shape:n})})),e.on("shape.move.start",1250,(function(e){var t=e.context,n=t.validatedShapes;if(!(t.canExecute=r(n)))return!1})),e.on("shape.move.move",500,(function(e){var t,n=e.context,i=n.validatedShapes,o=e.hover,s={x:e.dx,y:e.dy};t=r(i,s,{x:e.x,y:e.y},o),n.delta=s,n.canExecute=t,n.target=null!==t?o:null})),e.on("shape.move.end",(function(e){var t=e.context,i=t.delta,o=t.canExecute,r="attach"===o,s=t.shapes;if(!1===o)return!1;i.x=pg(i.x),i.y=pg(i.y),0===i.x&&0===i.y||n.moveElements(s,i,t.target,{primaryShape:t.shape,attach:r})})),e.on("element.mousedown",(function(e){if(ya(e)){var t=pa(e);if(!t)throw new Error("must supply DOM mousedown event");return a(t,e.element)}})),this.start=a}fg.$inject=["eventBus","dragging","modeling","selection","rules"];var gg="djs-dragging",mg="drop-ok",vg="drop-not-ok",yg="new-parent",xg="attach-ok";function bg(e,t,n,i){function o(e){var t=function(e){var t=d(e,(function(t){return!co(t)||h(e,C({id:t.source.id}))&&h(e,C({id:t.target.id}))}));return t}(r(e));return t}function r(e){var t=gi(e,!0),n=t.flatMap((e=>(e.incoming||[]).concat(e.outgoing||[]))),i=t.concat(n);return[...new Set(i)]}function s(e,n){[xg,mg,vg,yg].forEach((function(i){i===n?t.addMarker(e,i):t.removeMarker(e,i)}))}e.on("shape.move.start",499,(function(e){var s,a,l=e.context,c=l.shapes,u=l.allDraggedElements,h=o(c);if(!l.dragGroup){var d=Qn("g");jn(d,n.cls("djs-drag-group",["no-events"])),An(t.getActiveLayer(),d),l.dragGroup=d}h.forEach((function(e){i.addDragger(e,l.dragGroup)})),u?(s=[u,r(c)],u=Array.prototype.concat.apply([],s)):u=r(c),p(u,(function(e){t.addMarker(e,gg)})),l.allDraggedElements=u,l.differentParents=1!==(a=b(c,(function(e){return e.parent&&e.parent.id})),y(a).length)})),e.on("shape.move.move",499,(function(e){var t=e.context,n=t.dragGroup,i=t.target,o=t.shape.parent,r=t.canExecute;i&&("attach"===r?s(i,xg):t.canExecute&&o&&i.id!==o.id?s(i,yg):s(i,t.canExecute?mg:vg)),Fo(n,e.dx,e.dy)})),e.on(["shape.move.out","shape.move.cleanup"],(function(e){var t=e.context.target;t&&s(t,null)})),e.on("shape.move.cleanup",(function(e){var n=e.context,i=n.allDraggedElements,o=n.dragGroup;p(i,(function(e){t.removeMarker(e,gg)})),o&&ti(o)})),this.makeDraggable=function(e,n,o){i.addDragger(n,e.dragGroup),o&&t.addMarker(n,gg),e.allDraggedElements?e.allDraggedElements.push(n):e.allDraggedElements=[n]}}bg.$inject=["eventBus","canvas","styles","previewSupport"];var _g={__depends__:[Oa,Aa,dg,gc,uc,Cu],__init__:["move","movePreview"],move:["type",fg],movePreview:["type",bg]};const wg={width:135,height:46},Cg={width:100,height:63};function Og(e,t,n){return Qn("path",{d:e,strokeWidth:2,transform:`translate(${t.x}, ${t.y})`,...n})}function kg(e,t){this._styles=t,e.registerProvider(this)}function Eg(e,t){var n;return"dmn:BusinessKnowledgeModel"===t?n=wg:"dmn:KnowledgeSource"===t&&(n=Cg),e.width===n.width&&e.height===n.height}kg.$inject=["outline","styles"],kg.prototype.getOutline=function(e){const t=this._styles.cls("djs-outline",["no-fill"]);var n;return hn(e,"dmn:InputData")?jn(n=Qn("rect"),M({x:-5,y:-5,rx:27,width:e.width+10,height:e.height+10},t)):hn(e,"dmn:BusinessKnowledgeModel")&&Eg(e,"dmn:BusinessKnowledgeModel")?n=Og("\nM2.45221 16.0068L18.7175 1.74436L18.0615 0.996331L18.7175 1.74436C19.2646 1.26455 19.9676 \n1 20.6953 1H140.926C142.583 1 143.926 2.34295 143.926 3.99967L143.93 37.5457C143.93 \n38.3668 143.593 39.152 142.999 39.7183L143.689 40.4424L142.999 39.7183L127.299 \n54.6723C126.741 55.2036 126 55.5 125.23 55.5H4.53787C2.88599 55.5 1.54491 54.1646 1.5379 \n52.5127L1.43066 27.229L1.43065 27.2248L1.4301 18.2626C1.43005 \n17.3986 1.80255 16.5765 2.45221 16.0068Z\n",{x:-6,y:-6},t):hn(e,"dmn:KnowledgeSource")&&Eg(e,"dmn:KnowledgeSource")&&(n=Og("\nM1.79494 63.0032L1.2941 63.6423L1.79493 63.0032C1.71778 62.9427 1.6428 62.8741 1.57288 \n62.8L1.01736 63.3241L1.57288 62.8C1.20495 62.41 1 61.8941 1 61.3579V2.65067C1 1.74066 \n1.73867 1.00345 2.64868 1.00526L108.006 1.2145C109.66 1.21778 111 2.55996 111 \n4.21449V21.7015V61.6762C111 63.3188 109.679 64.656 108.037 64.676L107.06 64.6879C106.66 \n64.6927 106.26 64.6165 105.89 64.4652C105.04 64.1176 104.222 63.78 103.43 \n63.4531C93.4866 59.3517 87.6891 56.9603 76.3991 58.1057C71.7035 58.5821 66.8747 60.74 \n61.5721 63.1744C61.3243 63.2881 61.0753 63.4026 60.825 63.5177C55.6712 65.8868 49.9696 \n68.5077 43.2365 70.3468C31.101 73.6617 15.2135 73.5179 1.79494 63.0032Z\n",{x:-6,y:-1.5},t)),n},kg.prototype.updateOutline=function(e){return!!gn(e,["dmn:InputData","dmn:BusinessKnowledgeModel","dmn:KnowledgeSource"])};var Sg={__depends__:[dg],__init__:["outlineProvider"],outlineProvider:["type",kg]},Rg=".djs-palette-toggle",Tg=".entry",Mg=Rg+", "+Tg,Ag="djs-palette-",Pg="open",Dg="two-column";function $g(e,t){this._eventBus=e,this._canvas=t;var n=this;e.on("tool-manager.update",(function(e){var t=e.tool;n.updateToolHighlight(t)})),e.on("i18n.changed",(function(){n._update()})),e.on("diagram.init",(function(){n._diagramInitialized=!0,n._rebuild()}))}function jg(e,t){var n=t.getPaletteEntries();return l(n)?n(e):(p(n,(function(t,n){e[n]=t})),e)}$g.$inject=["eventBus","canvas"],$g.prototype.registerProvider=function(e,t){t||(t=e,e=1e3),this._eventBus.on("palette.getProviders",e,(function(e){e.providers.push(t)})),this._rebuild()},$g.prototype.getEntries=function(){return this._getProviders().reduce(jg,{})},$g.prototype._rebuild=function(){this._diagramInitialized&&(this._getProviders().length&&(this._container||this._init(),this._update()))},$g.prototype._init=function(){var e=this,t=this._eventBus,n=this._getParentContainer(),i=this._container=Gt($g.HTML_MARKUP);n.appendChild(i),$t(n).add(Ag+"shown"),Wt.bind(i,Mg,"click",(function(t){if(Yt(t.delegateTarget,Rg))return e.toggle();e.trigger("click",t)})),zt.bind(i,"mousedown",(function(e){e.stopPropagation()})),Wt.bind(i,Tg,"dragstart",(function(t){e.trigger("dragstart",t)})),t.on("canvas.resized",this._layoutChanged,this),t.fire("palette.create",{container:i})},$g.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(t),t.providers},$g.prototype._toggleState=function(e){e=e||{};var t,n=this._getParentContainer(),i=this._container,o=this._eventBus,r=$t(i),s=$t(n);t="twoColumn"in e?e.twoColumn:this._needsCollapse(n.clientHeight,this._entries||{}),r.toggle(Dg,t),s.toggle(Ag+Dg,t),"open"in e&&(r.toggle(Pg,e.open),s.toggle(Ag+Pg,e.open)),o.fire("palette.changed",{twoColumn:t,open:this.isOpen()})},$g.prototype._update=function(){var e=Zt(".djs-palette-entries",this._container),t=this._entries=this.getEntries();It(e),p(t,(function(t,n){var i=t.group||"default",o=Zt("[data-group="+al(i)+"]",e);o||(Pt(o=Gt('<div class="group"></div>'),"data-group",i),e.appendChild(o));var s=t.html||(t.separator?'<hr class="separator" />':'<div class="entry" draggable="true"></div>'),a=Gt(s);if(o.appendChild(a),!t.separator&&(Pt(a,"data-action",n),t.title&&Pt(a,"title",t.title),t.className&&function(e,t){var n=$t(e),i=r(t)?t:t.split(/\s+/g);i.forEach((function(e){n.add(e)}))}(a,t.className),t.imageUrl)){var l=Gt("<img>");Pt(l,"src",t.imageUrl),a.appendChild(l)}})),this.open()},$g.prototype.trigger=function(e,t,n){var i,o,r=t.delegateTarget||t.target;return r?(i=Pt(r,"data-action"),o=t.originalEvent||t,this.triggerEntry(i,e,o,n)):t.preventDefault()},$g.prototype.triggerEntry=function(e,t,n,i){var o,r;if((o=this._entries[e])&&(r=o.action,!1!==this._eventBus.fire("palette.trigger",{entry:o,event:n}))){if(l(r)){if("click"===t)return r(n,i)}else if(r[t])return r[t](n,i);n.preventDefault()}},$g.prototype._layoutChanged=function(){this._toggleState({})},$g.prototype._needsCollapse=function(e,t){return e<46*Object.keys(t).length+50},$g.prototype.close=function(){this._toggleState({open:!1,twoColumn:!1})},$g.prototype.open=function(){this._toggleState({open:!0})},$g.prototype.toggle=function(){this.isOpen()?this.close():this.open()},$g.prototype.isActiveTool=function(e){return e&&this._activeTool===e},$g.prototype.updateToolHighlight=function(e){var t;this._toolsContainer||(t=Zt(".djs-palette-entries",this._container),this._toolsContainer=Zt("[data-group=tools]",t)),p(this._toolsContainer.children,(function(t){var n=t.getAttribute("data-action");if(n){var i=$t(t);n=n.replace("-tool",""),i.contains("entry")&&n===e?i.add("highlighted-entry"):i.remove("highlighted-entry")}}))},$g.prototype.isOpen=function(){return $t(this._container).has(Pg)},$g.prototype._getParentContainer=function(){return this._canvas.getContainer()},$g.HTML_MARKUP='<div class="djs-palette"><div class="djs-palette-entries"></div><div class="djs-palette-toggle"></div></div>';var Ig={__init__:["palette"],palette:["type",$g]};function Bg(e){this._eventBus=e,this._tools=[],this._active=null}Bg.$inject=["eventBus"],Bg.prototype.registerTool=function(e,t){var n=this._tools;if(!t)throw new Error('A tool has to be registered with it\'s "events"');n.push(e),this.bindEvents(e,t)},Bg.prototype.isActive=function(e){return e&&this._active===e},Bg.prototype.length=function(e){return this._tools.length},Bg.prototype.setActive=function(e){var t=this._eventBus;this._active!==e&&(this._active=e,t.fire("tool-manager.update",{tool:e}))},Bg.prototype.bindEvents=function(e,t){var n=this._eventBus,i=[];n.on(t.tool+".init",(function(t){t.context.reactivate||!this.isActive(e)?this.setActive(e):this.setActive(null)}),this),p(t,(function(e){i.push(e+".ended"),i.push(e+".canceled")})),n.on(i,250,(function(e){this._active&&(function(e){var t=e.originalEvent&&e.originalEvent.target;return t&&Bt(t,'.group[data-group="tools"]')}(e)||this.setActive(null))}),this)};var Lg={__depends__:[uc],__init__:["toolManager"],toolManager:["type",Bg]};function Ng(e){var t=this;function n(e){t._lastMoveEvent=e}this._lastMoveEvent=null,e.on("canvas.init",(function(e){(t._svg=e.svg).addEventListener("mousemove",n)})),e.on("canvas.destroy",(function(){t._lastMouseEvent=null,t._svg.removeEventListener("mousemove",n)}))}Ng.$inject=["eventBus"],Ng.prototype.getLastMoveEvent=function(){return this._lastMoveEvent||function(e,t){var n=document.createEvent("MouseEvent"),i=e,o=t,r=e,s=t;n.initMouseEvent&&n.initMouseEvent("mousemove",!0,!0,window,0,i,o,r,s,!1,!1,!1,!1,0,null);return n}(0,0)};var qg={__init__:["mouse"],mouse:["type",Ng]},Vg="crosshair";function Fg(e,t,n,i,o,r,s){this._selection=o,this._dragging=n,this._mouse=s;var a=this,l=function(e){var n,i=t.getActiveLayer();jn(n=e.frame=Qn("rect"),{class:"djs-lasso-overlay",width:1,height:1,x:0,y:0}),An(i,n)},c=function(e){var t=e.frame,n=e.bbox;jn(t,{x:n.x,y:n.y,width:n.width,height:n.height})},u=function(e){e.frame&&ti(e.frame)};r.registerTool("lasso",{tool:"lasso.selection",dragging:"lasso"}),e.on("lasso.selection.end",(function(t){var n=t.originalEvent.target;(t.hover||n instanceof SVGElement)&&e.once("lasso.selection.ended",(function(){a.activateLasso(t.originalEvent,!0)}))})),e.on("lasso.end",0,(function(e){var t=e.context,n=zg(e),o=i.filter((function(e){return e})),r=ba(e);a.select(o,n,r?t.selection:[])})),e.on("lasso.start",(function(e){var t=e.context;t.bbox=zg(e),l(t),t.selection=o.get()})),e.on("lasso.move",(function(e){var t=e.context;t.bbox=zg(e),c(t)})),e.on("lasso.cleanup",(function(e){var t=e.context;u(t)})),e.on("element.mousedown",1500,(function(e){if(ba(e))return a.activateLasso(e.originalEvent),!0}))}function zg(e){var t={x:e.x-e.dx,y:e.y-e.dy},n={x:e.x,y:e.y};return t.x<=n.x&&t.y<n.y||t.x<n.x&&t.y<=n.y?{x:t.x,y:t.y,width:n.x-t.x,height:n.y-t.y}:t.x>=n.x&&t.y<n.y||t.x>n.x&&t.y<=n.y?{x:n.x,y:t.y,width:t.x-n.x,height:n.y-t.y}:t.x<=n.x&&t.y>n.y||t.x<n.x&&t.y>=n.y?{x:t.x,y:n.y,width:n.x-t.x,height:t.y-n.y}:t.x>=n.x&&t.y>n.y||t.x>n.x&&t.y>=n.y?{x:n.x,y:n.y,width:t.x-n.x,height:t.y-n.y}:{x:n.x,y:n.y,width:0,height:0}}Fg.$inject=["eventBus","canvas","dragging","elementRegistry","selection","toolManager","mouse"],Fg.prototype.activateLasso=function(e,t){this._dragging.init(e,"lasso",{autoActivate:t,cursor:Vg,data:{context:{}}})},Fg.prototype.activateSelection=function(e,t){this._dragging.init(e,"lasso.selection",{trapClick:!1,autoActivate:t,cursor:Vg,data:{context:{}},keepSelection:!0})},Fg.prototype.select=function(e,t,n=[]){var i=function(e,t){var n={};return p(e,(function(e){var i=e;i.waypoints&&(i=mi(i)),!a(t.y)&&i.x>t.x&&(n[e.id]=e),!a(t.x)&&i.y>t.y&&(n[e.id]=e),i.x>t.x&&i.y>t.y&&(a(t.width)&&a(t.height)&&i.width+i.x<t.width+t.x&&i.height+i.y<t.height+t.y?n[e.id]=e:a(t.width)&&a(t.height)||(n[e.id]=e))})),n}(e,t);this._selection.select([...n,...x(i)])},Fg.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},Fg.prototype.isActive=function(){var e=this._dragging.context();return e&&/^lasso/.test(e.prefix)};var Qg={__depends__:[Lg,qg],__init__:["lassoTool"],lassoTool:["type",Fg]},Hg=1500,Wg="grab";function Ug(e,t,n,i,o,r){this._dragging=n,this._mouse=r;var s=this,a=i.get("keyboard",!1);o.registerTool("hand",{tool:"hand",dragging:"hand.move"}),e.on("element.mousedown",Hg,(function(e){if(xa(e))return s.activateMove(e.originalEvent,!0),!1})),a&&a.addListener(Hg,(function(e){if(Xg(e.keyEvent)&&!s.isActive()){var t=s._mouse.getLastMoveEvent();s.activateMove(t,!!t)}}),"keyboard.keydown"),a&&a.addListener(Hg,(function(e){Xg(e.keyEvent)&&s.isActive()&&s.toggle()}),"keyboard.keyup"),e.on("hand.end",(function(t){var n=t.originalEvent.target;if(!(t.hover||n instanceof SVGElement))return!1;e.once("hand.ended",(function(){s.activateMove(t.originalEvent,{reactivate:!0})}))})),e.on("hand.move.move",(function(e){var n=t.viewbox().scale;t.scroll({dx:e.dx*n,dy:e.dy*n})})),e.on("hand.move.end",(function(t){var n=t.context.reactivate;return!xa(t)&&n&&e.once("hand.move.ended",(function(e){s.activateHand(e.originalEvent,!0,!0)})),!1}))}function Xg(e){return fl("Space",e)}Ug.$inject=["eventBus","canvas","dragging","injector","toolManager","mouse"],Ug.prototype.activateMove=function(e,t,n){"object"==typeof t&&(n=t,t=!1),this._dragging.init(e,"hand.move",{autoActivate:t,cursor:Wg,data:{context:n||{}}})},Ug.prototype.activateHand=function(e,t,n){this._dragging.init(e,"hand",{trapClick:!1,autoActivate:t,cursor:Wg,data:{context:{reactivate:n}}})},Ug.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateHand(e,!!e)},Ug.prototype.isActive=function(){var e=this._dragging.context();return!!e&&/^(hand|hand\.move)$/.test(e.prefix)};var Kg={__depends__:[Lg,qg],__init__:["handTool"],handTool:["type",Ug]};function Gg(e,t,n,i,o,r){this._palette=e,this._create=t,this._elementFactory=n,this._handTool=i,this._lassoTool=o,this._translate=r,e.registerProvider(this)}Gg.$inject=["palette","create","elementFactory","handTool","lassoTool","translate"],Gg.prototype.getPaletteEntries=function(e){var t={},n=this._create,i=this._elementFactory,o=this._handTool,r=this._lassoTool,s=this._translate;function a(e,t,o,r,s){function a(t){var o=i.createShape(M({type:e},s));n.start(t,o)}return{group:t,className:o,title:r,action:{dragstart:a,click:a}}}return M(t,{"hand-tool":{group:"tools",className:"dmn-icon-hand-tool",title:s("Activate hand tool"),action:{click:function(e){o.activateHand(e)}}},"lasso-tool":{group:"tools",className:"dmn-icon-lasso-tool",title:s("Activate lasso tool"),action:{click:function(e){r.activateSelection(e)}}},"tool-separator":{group:"tools",separator:!0},"create.decision":a("dmn:Decision","drd","dmn-icon-decision",s("Create decision")),"create.input-data":a("dmn:InputData","drd","dmn-icon-input-data",s("Create input data")),"create.knowledge-source":a("dmn:KnowledgeSource","drd","dmn-icon-knowledge-source",s("Create knowledge source")),"create.business-knowledge-model":a("dmn:BusinessKnowledgeModel","drd","dmn-icon-business-knowledge",s("Create knowledge model"))}),t};var Yg={__depends__:[ha,Ig,zu,Qg,Kg],__init__:["paletteProvider"],paletteProvider:["type",Gg]},Zg=Math.max,Jg=Math.min,em=20;function tm(e,t,n){var i=t[e],o=n.min&&n.min[e],r=n.max&&n.max[e];return a(o)&&(i=(/top|left/.test(e)?Jg:Zg)(i,o)),a(r)&&(i=(/top|left/.test(e)?Zg:Jg)(i,r)),i}function nm(e,t){return void 0!==e?e:em}function im(e){return!e.waypoints&&"label"!==e.type}function om(e,t){var n;if((n=void 0===e.length?d(e.children,im):e).length)return function(e,t){var n,i,o,r;return"object"==typeof t?(n=nm(t.left),i=nm(t.right),o=nm(t.top),r=nm(t.bottom)):n=i=o=r=nm(t),{x:e.x-n,y:e.y-o,width:e.width+n+i,height:e.height+o+r}}(mi(n),t)}function rm(e,t,n,i){this._dragging=i,this._rules=t;var o=this;function r(e,t){var n,i=e.shape,r=e.direction,s=e.resizeConstraints;e.delta=t,n=function(e,t,n){var i=n.x,o=n.y,r={x:e.x,y:e.y,width:e.width,height:e.height};return-1!==t.indexOf("n")?(r.y=e.y+o,r.height=e.height-o):-1!==t.indexOf("s")&&(r.height=e.height+o),-1!==t.indexOf("e")?r.width=e.width+i:-1!==t.indexOf("w")&&(r.x=e.x+i,r.width=e.width-i),r}(i,r,t),e.newBounds=function(e,t){if(!t)return e;var n=po(e);return fo({top:tm("top",n,t),right:tm("right",n,t),bottom:tm("bottom",n,t),left:tm("left",n,t)})}(n,s),e.canExecute=o.canResize(e)}function s(e){var t,i=e.shape,o=e.canExecute,r=e.newBounds;if(o){if(t=r,!function(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}(i,r={x:Math.round(t.x),y:Math.round(t.y),width:Math.round(t.width),height:Math.round(t.height)}))return;n.resizeShape(i,r)}}e.on("resize.start",(function(e){var t,n,i;t=e.context,n=t.resizeConstraints,i=t.minBounds,void 0===n&&(void 0===i&&(i=o.computeMinResizeBox(t)),t.resizeConstraints={min:po(i)})})),e.on("resize.move",(function(e){var t={x:e.dx,y:e.dy};r(e.context,t)})),e.on("resize.end",(function(e){s(e.context)}))}function sm(e,t){var n=mo(e),i=po(e),o={x:n.x,y:n.y};return-1!==t.indexOf("n")?o.y=i.top:-1!==t.indexOf("s")&&(o.y=i.bottom),-1!==t.indexOf("e")?o.x=i.right:-1!==t.indexOf("w")&&(o.x=i.left),o}function am(e){var t="resize-";return"n"===e||"s"===e?t+"ns":"e"===e||"w"===e?t+"ew":"nw"===e||"se"===e?t+"nwse":t+"nesw"}rm.prototype.canResize=function(e){var t=this._rules,n=A(e,["newBounds","shape","delta","direction"]);return t.allowed("shape.resize",n)},rm.prototype.activate=function(e,t,n){var i,o,r=this._dragging;if("string"==typeof n&&(n={direction:n}),!(o=(i=M({shape:t},n)).direction))throw new Error("must provide a direction (n|w|s|e|nw|se|ne|sw)");r.init(e,sm(t,o),"resize",{autoActivate:!0,cursor:am(o),data:{shape:t,context:i}})},rm.prototype.computeMinResizeBox=function(e){var t=e.shape;return function(e,t,n,i){var o=po(t),r={top:/n/.test(e)?o.bottom-n.height:o.top,left:/w/.test(e)?o.right-n.width:o.left,bottom:/s/.test(e)?o.top+n.height:o.bottom,right:/e/.test(e)?o.left+n.width:o.right},s=i?po(i):r;return fo({top:Jg(r.top,s.top),left:Jg(r.left,s.left),bottom:Zg(r.bottom,s.bottom),right:Zg(r.right,s.right)})}(e.direction,t,e.minDimensions||{width:10,height:10},om(t,e.childrenBoxPadding))},rm.$inject=["eventBus","rules","modeling","dragging"];var lm="djs-resizing",cm="resize-not-ok";function um(e,t,n){e.on("resize.move",500,(function(e){var i,o,r,s;i=e.context,o=i.shape,r=i.newBounds,(s=i.frame)||(s=i.frame=n.addFrame(o,t.getActiveLayer()),t.addMarker(o,lm)),r.width>5&&jn(s,{x:r.x,width:r.width}),r.height>5&&jn(s,{y:r.y,height:r.height}),i.canExecute?Bn(s).remove(cm):Bn(s).add(cm)})),e.on("resize.cleanup",(function(e){var n,i;n=e.context,i=n.shape,n.frame&&ti(n.frame),t.removeMarker(i,lm)}))}um.$inject=["eventBus","canvas","previewSupport"];var hm=-6,dm="djs-resizer",pm=["n","w","s","e","nw","ne","se","sw"];function fm(e,t,n,i){this._resize=i,this._canvas=t;var o=this;e.on("selection.changed",(function(e){var t=e.newSelection;o.removeResizers(),1===t.length&&p(t,T(o.addResizer,o))})),e.on("shape.changed",(function(e){var t=e.element;n.isSelected(t)&&(o.removeResizers(),o.addResizer(t))}))}fm.prototype.makeDraggable=function(e,t,n){var i=this._resize;function o(t){ya(t)&&i.activate(t,e,n)}zt.bind(t,"mousedown",o),zt.bind(t,"touchstart",o)},fm.prototype._createResizer=function(e,t,n,i){var o=this._getResizersParent(),r=function(e){var t={x:0,y:0};-1!==e.indexOf("e")?t.x=6:-1!==e.indexOf("w")&&(t.x=hm);-1!==e.indexOf("s")?t.y=6:-1!==e.indexOf("n")&&(t.y=hm);return t}(i),s=Qn("g");Bn(s).add(dm),Bn(s).add(dm+"-"+e.id),Bn(s).add(dm+"-"+i),An(o,s);var a=Qn("rect");jn(a,{x:-4+r.x,y:-4+r.y,width:8,height:8}),Bn(a).add(dm+"-visual"),An(s,a);var l=Qn("rect");return jn(l,{x:-10+r.x,y:-10+r.y,width:20,height:20}),Bn(l).add(dm+"-hit"),An(s,l),function(e,t,n,i,o){var r=Xn();r.setTranslate(t,n);var s=Xn();s.setRotate(0,0,0);var a=Xn();a.setScale(1,1),ii(e,[r,s,a])}(s,t,n),s},fm.prototype.createResizer=function(e,t){var n=sm(e,t),i=this._createResizer(e,n.x,n.y,t);this.makeDraggable(e,i,t)},fm.prototype.addResizer=function(e){var t=this;!co(e)&&this._resize.canResize({shape:e})&&p(pm,(function(n){t.createResizer(e,n)}))},fm.prototype.removeResizers=function(){Nn(this._getResizersParent())},fm.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")},fm.$inject=["eventBus","canvas","selection","resize"];var gm={__depends__:[gc,uc,Cu],__init__:["resize","resizePreview","resizeHandles"],resize:["type",rm],resizePreview:["type",um],resizeHandles:["type",fm]};function mm(e){e.on(["bendpoint.move.move","bendpoint.move.end"],2e3,(function(e){var t=e.context,n=t.allowed,i=t.hover,o=t.source,r=t.target,s=t.type;if(t.hints||(t.hints={}),delete t.hints.connectionStart,delete t.hints.connectionEnd,(!n||"dmn:InformationRequirement"===n.type)&&i&&gn(i,["dmn:Decision","dmn:InputData"])&&o!==r){var a="reconnectStart"===s||"reconnectEnd"===s,l=vo(o,r);a&&i===o?(!function(e,t){var n=e.context,i=n.source,o=vm(i,t),r=e.x-o.x,s=e.y-o.y;e.x-=r,e.y-=s,e.dx-=r,e.dy-=s}(e,l),t.hints.connectionEnd=ym(r,l)):a&&i===r&&(t.hints.connectionStart=vm(o,l),function(e,t){var n=e.context,i=n.target,o=ym(i,t),r=0,s=0;t.includes("top")||t.includes("bottom")?s=e.y-o.y:r=e.x-o.x;e.x-=r,e.y-=s,e.dx-=r,e.dy-=s}(e,l))}}))}function vm(e,t){var n=po(e),i=mo(e);return t.includes("bottom")?i.y=n.top:t.includes("top")?i.y=n.bottom:t.includes("right")?i.x=n.left:i.x=n.right,i}function ym(e,t){var n=po(e),i=mo(e);return t.includes("bottom")?i.y=n.bottom:t.includes("top")?i.y=n.top:t.includes("right")?i.x=n.right:i.x=n.left,i}mm.$inject=["eventBus"];function xm(e){e.on(["connect.hover","connect.move","connect.end"],250,(function(e){var t=e.context,n=t.canExecute,i=t.hover,o=t.source,r=t.target;if(n&&"dmn:InformationRequirement"===n.type){var s=vo(o,r);t.connectionStart=mo(o),t.connectionEnd=i===o?mo(r):{x:e.x,y:e.y},s.includes("bottom")?(t.connectionStart.y=po(o).top,t.connectionEnd.y=po(r).bottom):s.includes("top")?(t.connectionStart.y=po(o).bottom,t.connectionEnd.y=po(r).top):s.includes("right")?(t.connectionStart.x=po(o).left,t.connectionEnd.x=po(r).right):(t.connectionStart.x=po(o).right,t.connectionEnd.x=po(r).left)}else delete t.connectionStart,delete t.connectionEnd}))}function bm(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}function _m(){this._snapValues={}}xm.$inject=["eventBus"],bm.prototype.getSnapOrigin=function(e){return this._snapOrigins[e]},bm.prototype.setSnapOrigin=function(e,t){this._snapOrigins[e]=t,-1===this._snapLocations.indexOf(e)&&this._snapLocations.push(e)},bm.prototype.addDefaultSnap=function(e,t){var n=this._defaultSnaps[e];n||(n=this._defaultSnaps[e]=[]),n.push(t)},bm.prototype.getSnapLocations=function(){return this._snapLocations},bm.prototype.setSnapLocations=function(e){this._snapLocations=e},bm.prototype.pointsForTarget=function(e){var t=e.id||e,n=this._targets[t];return n||(n=this._targets[t]=new _m).initDefaults(this._defaultSnaps),n},_m.prototype.add=function(e,t){var n=this._snapValues[e];n||(n=this._snapValues[e]={x:[],y:[]}),-1===n.x.indexOf(t.x)&&n.x.push(t.x),-1===n.y.indexOf(t.y)&&n.y.push(t.y)},_m.prototype.snap=function(e,t,n,i){var o=this._snapValues[t];return o&&function(e,t,n){var i,o;for(n=void 0===n?10:n,i=0;i<t.length;i++)if(o=t[i],Yc(o-e)<=n)return o}(e[n],o[n],i)},_m.prototype.initDefaults=function(e){var t=this;p(e||{},(function(e,n){p(e,(function(e){t.add(n,e)}))}))};function wm(e,t,n){var i=this;this._elementRegistry=e,t.on(["create.start","shape.move.start"],(function(e){i.initSnap(e)})),t.on(["create.move","create.end","shape.move.move","shape.move.end"],1250,(function(e){var t=e.context,o=t.shape,r=t.snapContext,s=t.target;if((!e.originalEvent||!pl(e.originalEvent))&&!eu(e)&&s){var a=r.pointsForTarget(s);a.initialized||((a=i.addSnapTargetPoints(a,o,s)).initialized=!0),n.snap(e,a)}})),t.on(["create.cleanup","shape.move.cleanup"],(function(){n.hide()}))}wm.$inject=["elementRegistry","eventBus","snapping"],wm.prototype.initSnap=function(e){var t,n=this._elementRegistry,i=e.context,o=i.shape,r=i.snapContext;r||(r=i.snapContext=new bm);var s=(t=n.get(o.id)?Jc(o,e):{x:e.x+Jc(o).x,y:e.y+Jc(o).y}).x-o.width/2,a=t.y-o.height/2,l=t.x+o.width/2,c=t.y+o.height/2;return r.setSnapOrigin("mid",{x:t.x-e.x,y:t.y-e.y}),uo(o)||(r.setSnapOrigin("top-left",{x:s-e.x,y:a-e.y}),r.setSnapOrigin("bottom-right",{x:l-e.x,y:c-e.y})),r},wm.prototype.addSnapTargetPoints=function(e,t,n){return p(this.getSnapTargets(t,n),(function(n){if(uo(n))uo(t)&&e.add("mid",Jc(n));else if(co(n)){if(n.waypoints.length<3)return;p(n.waypoints.slice(1,-1),(function(t){e.add("mid",t)}))}else e.add("mid",Jc(n))})),a(t.x)&&a(t.y)?(this._elementRegistry.get(t.id)&&e.add("mid",Jc(t)),e):e},wm.prototype.getSnapTargets=function(e,t){return nu(t).filter((function(e){return!e.hidden}))};function Cm(e,t){var n=this;e.on(["resize.start"],(function(e){n.initSnap(e)})),e.on(["resize.move","resize.end"],1250,(function(e){var i=e.context,o=i.shape,r=o.parent,s=i.direction,a=i.snapContext;if(!(e.originalEvent&&pl(e.originalEvent)||eu(e))){var l=a.pointsForTarget(r);l.initialized||((l=n.addSnapTargetPoints(l,o,r,s)).initialized=!0),function(e){return"n"===e||"s"===e}(s)&&tu(e,"x",e.x),function(e){return"e"===e||"w"===e}(s)&&tu(e,"y",e.y),t.snap(e,l)}})),e.on(["resize.cleanup"],(function(){t.hide()}))}function Om(e,t){var n=mo(e),i=po(e),o={x:n.x,y:n.y};return-1!==t.indexOf("n")?o.y=i.top:-1!==t.indexOf("s")&&(o.y=i.bottom),-1!==t.indexOf("e")?o.x=i.right:-1!==t.indexOf("w")&&(o.x=i.left),o}Cm.prototype.initSnap=function(e){var t=e.context,n=t.shape,i=t.direction,o=t.snapContext;o||(o=t.snapContext=new bm);var r=Om(n,i);return o.setSnapOrigin("corner",{x:r.x-e.x,y:r.y-e.y}),o},Cm.prototype.addSnapTargetPoints=function(e,t,n,i){return p(this.getSnapTargets(t,n),(function(t){var n;e.add("corner",{x:(n=t).x+n.width,y:n.y+n.height}),e.add("corner",function(e){return{x:e.x,y:e.y}}(t))})),e.add("corner",Om(t,i)),e},Cm.$inject=["eventBus","snapping"],Cm.prototype.getSnapTargets=function(e,t){return nu(t).filter((function(t){return!(n=t,i=e,n.host===i||co(t)||function(e){return!!e.hidden}(t)||uo(t));var n,i}))};function km(e){this._canvas=e,this._asyncHide=R(T(this.hide,this),1e3)}km.$inject=["canvas"],km.prototype.snap=function(e,t){var n=e.context.snapContext,i=n.getSnapLocations(),o={x:eu(e,"x"),y:eu(e,"y")};p(i,(function(i){var r=n.getSnapOrigin(i),s={x:e.x+r.x,y:e.y+r.y};if(p(["x","y"],(function(e){var n;o[e]||void 0!==(n=t.snap(s,i,e,7))&&(o[e]={value:n,originValue:n-r[e]})})),o.x&&o.y)return!1})),this.showSnapLine("vertical",o.x&&o.x.value),this.showSnapLine("horizontal",o.y&&o.y.value),p(["x","y"],(function(t){var n=o[t];s(n)&&tu(e,t,n.originValue)}))},km.prototype._createLine=function(e){var t=this._canvas.getLayer("snap"),n=Qn("path");return jn(n,{d:"M0,0 L0,0"}),Bn(n).add("djs-snap-line"),An(t,n),{update:function(t){a(t)?jn(n,"horizontal"===e?{d:"M-100000,"+t+" L+100000,"+t,display:""}:{d:"M "+t+",-100000 L "+t+", +100000",display:""}):jn(n,{display:"none"})}}},km.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}},km.prototype.showSnapLine=function(e,t){var n=this.getSnapLine(e);n&&n.update(t),this._asyncHide()},km.prototype.getSnapLine=function(e){return this._snapLines||this._createSnapLines(),this._snapLines[e]},km.prototype.hide=function(){p(this._snapLines,(function(e){e.update()}))};var Em={__depends__:[{__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",wm],resizeSnapping:["type",Cm],snapping:["type",km]}],__init__:["bendpointSnapping","connectSnapping"],bendpointSnapping:["type",mm],connectSnapping:["type",xm]};function Sm(e){Sl.call(this,e)}function Rm(e,t){jm(e,"dmn:Decision")?function(e,t){for(const n of e.get("informationRequirement"))Tm(n,t);for(const n of e.get("knowledgeRequirement"))Am(n,t)}(e,t):jm(e,"dmn:BusinessKnowledgeModel")?function(e,t){for(const n of e.get("knowledgeRequirement"))Am(n,t)}(e,t):jm(e,"dmn:Expression")&&function(e,t){jm(e,"dmn:FunctionDefinition")&&function(e,t){const n=e.get("formalParameter");for(const e of n)Pm(e,t)}(e,t)}(e,t)}function Tm(e,t){const n=e.get("requiredInput");n&&function(e,t){const n=$m(e,t.rootElement);if(!n)return;const i=n.get("name");if(!i)return;t.variables.push({name:i,origin:n})}(n,t);const i=e.get("requiredDecision");i&&function(e,t){const n=$m(e,t.rootElement);if(!n)return;const i=n.get("name");if(!i)return;const o={name:i,origin:n},r=n.get("decisionLogic");r&&function(e,t,n){if(jm(e,"dmn:DecisionTable")){!function(e,t,n){if(1===e.length){const n={...Mm(e[0]),name:t.name};return void Object.assign(t,n)}const i=e.map(Mm);t.entries=i.filter((e=>!!e.name))}(e.get("output"),t)}}(r,o);t.variables.push(o)}(i,t)}function Mm(e){const t={name:e.name};return e.typeRef&&(t.detail=e.typeRef),t}function Am(e,t){const n=e.get("requiredKnowledge");n&&function(e,t){const n=$m(e,t.rootElement);if(!n)return;jm(n,"dmn:BusinessKnowledgeModel")&&function(e,t){const n=e.get("name");if(!n)return;const i={name:n,origin:e},o=e.get("encapsulatedLogic");o&&function(e,t,n){const i=e.get("formalParameter"),o=i.map(((e,t)=>{const n={name:e.get("name")||`param ${t+1}`,type:e.get("typeRef")};return n.type||delete n.type,n}));Object.assign(t,{type:"function",params:o})}(o,i);t.variables.push(i)}(n,t)}(n,t)}function Pm(e,t){const n=e.get("name");if(!n)return;const i={name:n,origin:e};e.get("typeRef")&&(i.detail=e.get("typeRef")),t.variables.push(i)}function Dm(e){let t=e;for(;t.$parent;)t=t.$parent;return t}function $m(e,t){const n=e.get("href");if(!n||!n.startsWith("#"))return;const i=n.slice(1);return t.get("drgElement").find((e=>e.get("id")===i))}function jm(e,t){return e.$instanceOf(t)}yn(Sm,Sl),Sm.prototype._modelingModules=[Dl,ic,pc,su,_d,Cd,Md,jd,Vd,Qd,ep,lp,hp,xp,Dp,cg,_g,Sg,Yg,gm,Em],Sm.prototype._modules=[].concat(Sm.prototype._modules,Sm.prototype._modelingModules);class Im{constructor(e){e.registerProvider(this)}getVariables(e,t){return e.concat(function(e){const t={variables:[],rootElement:Dm(e)};for(let n=e;n;n=n.$parent)Rm(n,t);return t.variables}(t))}}Im.$inject=["variableResolver"];const Bm={__init__:["dmnVariableProvider"],dmnVariableProvider:["type",Im],variableResolver:["type",class{constructor(){this._providers=[]}registerProvider(e){this._providers.push(e)}getVariables(e){return this._providers.reduce(((t,n)=>n.getVariables(t,e)),[])}}]};class Lm{constructor(e){M(this,e),zm(this,"businessObject",{writable:!0})}}class Nm extends Lm{constructor(e){super(e),zm(this,"root",{writable:!0}),zm(this,"cells",{enumerable:!0,value:this.cells||[]})}}class qm extends Lm{constructor(e){super(e),zm(this,"root",{writable:!0}),zm(this,"cells",{enumerable:!0,value:this.cells||[]})}}class Vm extends Lm{constructor(e){super(e),zm(this,"row",{writable:!0}),zm(this,"col",{writable:!0})}}const Fm={root:class extends Lm{constructor(e){super(e),zm(this,"rows",{enumerable:!0,value:this.rows||[]}),zm(this,"cols",{enumerable:!0,value:this.cols||[]})}},row:Nm,col:qm,cell:Vm};function zm(e,t,n){Object.defineProperty(e,t,n)}let Qm=class{constructor(){this._uid=12}create(e,t={}){return t.id||(t.id=e+"_"+this._uid++),function(e,t){const n=Fm[e];if(!n)throw new Error("unknown type "+e);return new n(t)}(e,t)}createRoot(e){return this.create("root",e)}createRow(e){return this.create("row",e)}createCol(e){return this.create("col",e)}createCell(e){return this.create("cell",e)}},Hm=class{constructor(e){this._eventBus=e,this._elements={},e.on("table.clear",this.clear.bind(this))}add(e,t){const{id:n}=e;this._elements[n]=e}remove(e){const t=e.id||e;delete this._elements[t]}get(e){return this._elements[e]}getAll(){return Wm(this._elements)}forEach(e){Wm(this._elements).forEach((t=>e(t)))}filter(e){return Wm(this._elements).filter((t=>e(t)))}clear(){this._elements={}}updateId(e,t){this._validateId(t),"string"==typeof e&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t}),this.remove(e),e.id=t,this.add(e)}_validateId(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")}};function Wm(e){return Object.keys(e).map((function(t){return e[t]}))}Hm.$inject=["eventBus"];let Um=class{constructor(e){this._listeners={},e.on("elements.changed",(({elements:e})=>{this.elementsChanged(e)})),e.on("root.remove",(t=>{const n=t.root.id;this._listeners[n]&&e.once("root.add",(e=>{const t=e.root.id;this.updateId(n,t)}))})),e.on("element.updateId",(({element:e,newId:t})=>{this.updateId(e.id,t)}))}elementsChanged(e){const t={},n=e.length;for(let i=0;i<n;i++){const{id:n}=e[i];if(t[n])return;t[n]=!0;const o=this._listeners[n]&&this._listeners[n].length;if(o)for(let e=0;e<o;e++)this._listeners[n][e]&&this._listeners[n][e]()}}onElementsChanged(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e][this._listeners[e].length]=t}offElementsChanged(e,t){if(this._listeners[e])if(t){const n=this._listeners[e].indexOf(t);-1!==n&&this._listeners[e].splice(n,1)}else this._listeners[e].length=0}updateId(e,t){this._listeners[e]&&(this._listeners[t]=this._listeners[e],delete this._listeners[e])}};Um.$inject=["eventBus"];class Xm extends Ds{constructor(e){super(e);const t=this._injector=e.injector;this._sheet=t.get("sheet"),this._changeSupport=t.get("changeSupport"),this._components=t.get("components"),this._eventBus=t.get("eventBus");const n=t.get("throttle");this.onElementsChanged=this.onElementsChanged.bind(this),this.onScroll=n(this.onScroll.bind(this))}onElementsChanged(){this.forceUpdate()}onScroll(){this._eventBus.fire("sheet.scroll")}getChildContext(){return{changeSupport:this._changeSupport,components:this._components,injector:this._injector}}componentWillMount(){const{id:e}=this._sheet.getRoot();this._changeSupport.onElementsChanged(e,this.onElementsChanged)}componentWillUnmount(){const{id:e}=this._sheet.getRoot();this._changeSupport.offElementsChanged(e,this.onElementsChanged)}render(){const{rows:e,cols:t}=this._sheet.getRoot(),n=this._components.getComponents("table.before"),i=this._components.getComponents("table.after"),o=this._components.getComponent("table.head"),r=this._components.getComponent("table.body"),s=this._components.getComponent("table.foot");return vr(1,"div","tjs-container",[n&&n.map(((e,t)=>yr(2,e,null,t))),vr(1,"div","tjs-table-container",vr(1,"table","tjs-table",[o&&yr(2,o,{rows:e,cols:t}),r&&yr(2,r,{rows:e,cols:t}),s&&yr(2,s,{rows:e,cols:t})],0),2,{onScroll:this.onScroll}),i&&i.map(((e,t)=>yr(2,e,null,t)))],0)}}let Km=class{constructor(e,t,n,i,o){const{container:r}=n;this._container=r,i.on("root.added",(()=>{Rs(yr(2,Xm,{injector:o}),r)})),i.on("root.remove",(()=>{Rs(null,r)}))}getContainer(){return this._container}};Km.$inject=["changeSupport","components","config.renderer","eventBus","injector"];var Gm={__init__:["changeSupport","components","renderer"],changeSupport:["type",Um],components:["type",class{constructor(){this._listeners={}}getComponent(e,t){const n=this._listeners[e];if(!n)return;let i;for(let e=0;e<n.length&&(i=n[e].callback(t),!i);e++);return i}getComponents(e,t){const n=this._listeners[e],i=[];if(!n)return i;for(let e=0;e<n.length;e++){const o=n[e].callback(t);o&&i.push(o)}return i.length,i}onGetComponent(e,t,n){if(l(t)&&(n=t,t=1e3),!a(t))throw new Error("priority must be a number");const i=this._getListeners(e);let o,r;const s={priority:t,callback:n};for(r=0;o=i[r];r++)if(o.priority<t)return void i.splice(r,0,s);i.push(s)}offGetComponent(e,t){const n=this._getListeners(e);let i,o,r;if(t)for(r=n.length-1;i=n[r];r--)o=i.callback,o===t&&n.splice(r,1);else n.length=0}_getListeners(e){let t=this._listeners[e];return t||(this._listeners[e]=t=[]),t}}],renderer:["type",Km]};class Ym{constructor(e,t){this._elementRegistry=e,this._eventBus=t,this._root=null,t.on("table.clear",(()=>{this.setRoot(null)}))}setRoot(e){if(this._root){const e=this._root;this._eventBus.fire("root.remove",{root:e}),this._root=null,this._eventBus.fire("root.removed",{root:e})}e&&this._eventBus.fire("root.add",{root:e}),this._root=e,e&&this._eventBus.fire("root.added",{root:e})}getRoot(){return this._root||this.setRoot({id:"__implicitroot",rows:[],cols:[]}),this._root}addRow(e,t){const n=this.getRoot();if(n.cols.length!=e.cells.length)throw new Error("number of cells is not equal to number of cols");return void 0===t&&(t=n.rows.length),Zm(t,n.rows,e),e.root=n,this._elementRegistry.add(e),e.cells.forEach(((i,o)=>{this._elementRegistry.add(i),i.row=e,i.col=n.cols[o],Zm(t,n.cols[o].cells,i)})),this._eventBus.fire("row.add",{row:e}),e}removeRow(e){const t=this.getRoot();"string"==typeof e&&(e=this._elementRegistry.get(e));const n=t.rows.indexOf(e);-1!==n&&(Jm(n,t.rows),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach(((e,i)=>{this._elementRegistry.remove(e),e.col=void 0,Jm(n,t.cols[i].cells)})),this._eventBus.fire("row.remove",{row:e}))}addCol(e,t){const n=this.getRoot();if(this._elementRegistry.add(e),n.rows.length!=e.cells.length)throw new Error("number of cells is not equal to number of rows");return void 0===t&&(t=n.cols.length),Zm(t,n.cols,e),e.root=n,e.cells.forEach(((i,o)=>{this._elementRegistry.add(i),i.col=e,i.row=n.rows[o],Zm(t,n.rows[o].cells,i)})),this._eventBus.fire("col.add",{col:e}),e}removeCol(e){const t=this.getRoot();"string"==typeof e&&(e=this._elementRegistry.get(e));const n=t.cols.indexOf(e);-1!==n&&(Jm(n,t.cols),e.root=void 0,this._elementRegistry.remove(e),e.cells.forEach(((e,i)=>{this._elementRegistry.remove(e),e.row=void 0,Jm(n,t.rows[i].cells)})),this._eventBus.fire("col.remove",{col:e}))}resized(){this._eventBus.fire("sheet.resized")}}function Zm(e,t,n){return t.splice(e,0,n)}function Jm(e,t){return t.splice(e,1)}function ev(e=!0){const t="number"==typeof e?e:e?300:0;return t?e=>function(e,t){let n=!1;return function(...i){n||(e(...i),n=!0,setTimeout((()=>{n=!1}),t))}}(e,t):e=>e}Ym.$inject=["elementRegistry","eventBus"],ev.$inject=["config.throttle"];var tv={__depends__:[Gm],__init__:["elementFactory","sheet"],elementFactory:["type",Qm],elementRegistry:["type",Hm],eventBus:["type",j],sheet:["type",Ym],throttle:["factory",ev]};class nv{constructor(e={}){let{injector:t}=e;if(!t){let{modules:n,config:i}=this._init(e);t=function(e,t){const n=[{config:["value",e]},tv].concat(t||[]),i=new Sn(n);return i.init(),i}(i,n)}this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("table.init"),this.get("eventBus").fire("diagram.init")}_init(e){let{modules:t,...n}=e;return{modules:t,config:n}}destroy(){const e=this.get("eventBus");e.fire("table.destroy"),e.fire("diagram.destroy")}clear(){const e=this.get("eventBus");e.fire("table.clear"),e.fire("diagram.clear")}}function iv(e){if(!e)return"<null>";const t=e.id?` id="${e.id}"`:"";return`<${e.$type}${t} />`}function ov(e,t){function n(t,n,i){if(t.gfx)throw new Error(`already rendered ${iv(t)}`);return e.element(t,n,i)}function i(e,t,i){p(e,(function(e){n(e,t,i)}))}function o(e,t,i){p(e,(function(e){n(e,t,i)}))}return{handleDecision:function(t){t.id||(t.id="decision");const r=t.decisionLogic;if(!r)throw new Error(`no table for ${iv(t)}`);{if(!r.output)throw new Error(`missing output for ${iv(r)}`);const t=(c=r,e.table(c));r.input&&i(r.input,t,r),i(r.output,t,r),s=r.rule,a=t,l=r,p(s,(function(e){n(e,a,l),o(e.inputEntry,e),o(e.outputEntry,e)}))}var s,a,l,c}}}function rv(e,t){const{elements:n,index:i}=e;return i[t]?e:{elements:[...n,t],index:{...i,[t]:!0}}}function sv(...e){let t={elements:[],index:{}};return e.forEach((function(e){const n=typeof e;"string"===n&&e.length>0?t=rv(t,e):"object"===n&&null!==e&&Object.keys(e).forEach((function(n){e[n]&&(t=rv(t,n))}))})),function(e,t){return e.elements.join(t)}(t," ")}function av(e){return lv(e.constructor,e)}function lv(e,t){const n=e.$inject;if(!n)return;const{injector:i}=t.context,o=[...n,function(...e){for(const i in e){const o=n[i],r=e[i];t[o]=r}}];i.invoke(o)}function cv(e,t){Object.keys(t).forEach((function(n){if("$inject"===n||"__init"===n)return;const i=t[n];"constructor"===n&&i.call(e,e.props,e.context);const o=e[n];if(void 0!==o){if("function"!=typeof o)throw new Error(`failed to mixin <${n}>: cannot combine with non-fn component value`);e[n]=function(e,...t){return function(...n){let i;return t.forEach((function(t){if(i=t.call(e,...n),void 0!==i)return!1})),i}.bind(e)}(e,o,i)}else e[n]=i.bind(e)})),"$inject"in t&&lv(t,e),"__init"in t&&t.__init.call(e,e.props,e.context)}const uv={getSelectionClasses(){const{selected:e,selectedSecondary:t,focussed:n}=this.state;return sv({selected:e,"selected-secondary":t,focussed:n})},selectionChanged(e){this.setState(e)},componentWillUpdate(e){e.elementId!==this.props.elementId&&this.updateSelectionSubscription(!1)},componentDidUpdate(e){e.elementId!==this.props.elementId&&this.updateSelectionSubscription(!0)},componentDidMount(){this.updateSelectionSubscription(!0)},componentWillUnmount(){this.updateSelectionSubscription(!1)},updateSelectionSubscription(e){const{elementId:t}=this.props;t&&t&&this.eventBus[e?"on":"off"](`selection.${t}.changed`,this.selectionChanged)},$inject:["eventBus"]};class hv extends Ds{constructor(e,t){super(e,t),cv(this,uv),av(this)}getRenderProps(...e){const{className:t,elementId:n,coords:i,...o}=this.props,r={className:sv(...e,this.getSelectionClasses(),t)};return n&&(r["data-element-id"]=n),i&&(r["data-coords"]=i),{...r,...o}}}class dv extends hv{constructor(e,t){super(e,t),this.state={}}render(){const{children:e}=this.props;return br(vr(1,"td",null,e,0,{...this.getRenderProps("cell")}))}}const pv={slotFill(e,t){const{type:n,context:i,...o}=e,r=this.components.getComponent(n,i)||t;return r?br(yr(2,r,{...i,...o})):null},slotFills(e){const{type:t,context:n,...i}=e;return this.components.getComponents(t,n).map((e=>br(yr(2,e,{...n,...i}))))},$inject:["components"]};class fv extends Ds{constructor(e,t){super(e,t),cv(this,pv),av(this)}componentDidMount(){this.changeSupport.onElementsChanged(this.getRoot(),this.onElementsChanged)}componentWillUnmount(){this.changeSupport.offElementsChanged(this.getRoot(),this.onElementsChanged)}onElementsChanged=()=>{this.forceUpdate()};getRoot(){return this.sheet.getRoot()}render(){const e=(this.getRoot().businessObject.get("annotationsWidth")||400)+"px";return vr(1,"th","annotation header",[this.slotFills({type:"cell-inner",context:{cellType:"annotations",col:this.sheet.getRoot(),minWidth:400}}),this.translate("Annotations")],0,{style:{width:e}})}}function gv(e){const{row:t}=e,{id:n,description:i}=t.businessObject;return yr(2,dv,{className:"annotation",elementId:n,children:i||"-"})}function mv(e){e.onGetComponent("cell",(({cellType:e})=>"after-label-cells"===e?fv:"after-rule-cells"===e?gv:void 0))}fv.$inject=["changeSupport","sheet","translate"],mv.$inject=["components"];var vv={__init__:["annotationsProvider"],annotationsProvider:["type",mv]};function yv(e,t){return M({id:e.id,type:e.$type,businessObject:e},t)}class xv{constructor(e,t,n){this._elementFactory=e,this._eventBus=t,this._sheet=n}add(e){let t;if(hn(e,"dmn:DecisionTable"))t=this._elementFactory.createRoot(yv(e)),this._sheet.setRoot(t);else if(hn(e,"dmn:InputClause"))t=this._elementFactory.createCol(yv(e)),this._sheet.addCol(t);else if(hn(e,"dmn:OutputClause"))t=this._elementFactory.createCol(yv(e)),this._sheet.addCol(t);else if(hn(e,"dmn:DecisionRule")){e.inputEntry||(e.inputEntry=[]),e.outputEntry||(e.outputEntry=[]);const n=[...e.inputEntry,...e.outputEntry].map((e=>this._elementFactory.createCell(yv(e))));t=this._elementFactory.createRow(M(yv(e),{cells:n})),this._sheet.addRow(t)}return this._eventBus.fire("dmnElement.added",{element:t}),t}}xv.$inject=["elementFactory","eventBus","sheet"];var bv={__depends__:[{__depends__:[ha],tableImporter:["type",xv]},Gm]};class _v extends Ds{constructor(e,t){super(e,t),cv(this,pv),this._sheet=t.injector.get("sheet"),this._changeSupport=t.changeSupport}onElementsChanged=()=>{this.forceUpdate()};componentWillMount(){const e=this._sheet.getRoot();this._changeSupport.onElementsChanged(e.id,this.onElementsChanged)}componentWillUnmount(){const e=this._sheet.getRoot();this._changeSupport.offElementsChanged(e.id,this.onElementsChanged)}render(){const e=this._sheet.getRoot();if(!hn(e,"dmn:DMNElement"))return null;const t=fn(e),n=t.input,i=t.output;return vr(1,"thead",null,vr(1,"tr",null,[vr(1,"th","index-column"),this.slotFills({type:"cell",context:{cellType:"before-label-cells"}}),n&&n.map(((e,t)=>{const i=e.width||"192px";return this.slotFill({type:"cell",context:{cellType:"input-header",input:e,index:t,inputsLength:n.length,width:i},key:e.id},wv)})),i.map(((e,t)=>this.slotFill({type:"cell",context:{cellType:"output-header",output:e,index:t,outputsLength:i.length},key:e.id},Cv))),this.slotFills({type:"cell",context:{cellType:"after-label-cells"}})],0),2)}}function wv(e,t){const{input:n,className:i,index:o}=e,{label:r,inputExpression:s,inputValues:a}=n,l=t.injector.get("translate");return vr(1,"th",(i||"")+" input-cell",[vr(1,"div","clause",l(0===o?"When":"And"),0),r?vr(1,"div","input-label",r,0,{title:l("Input label: ")+r}):vr(1,"div","input-expression",s.text,0,{title:l("Input expression: ")+s.text}),vr(1,"div","input-variable",a&&a.text||s.typeRef,0,{title:a&&a.text?l("Input values"):l("Input type")})],0,{"data-col-id":n.id},n.id)}function Cv(e,t){const{output:n,className:i,index:o}=e,{label:r,name:s,outputValues:a,typeRef:l}=n,c=t.injector.get("translate");return vr(1,"th",(i||"")+" output-cell",[vr(1,"div","clause",c(0===o?"Then":"And"),0),r?vr(1,"div","output-label",r,0,{title:c("Output label")}):vr(1,"div","output-name",s,0,{title:c("Output name")}),vr(1,"div","output-variable",a&&a.text||l,0,{title:a&&a.text?c("Output values"):c("Output type")})],0,null,n.id)}function Ov(e){e.onGetComponent("table.head",(()=>_v))}Ov.$inject=["components"];var kv={__init__:["decisionTableHeadProvider"],decisionTableHeadProvider:["type",Ov]};let Ev=class extends Ds{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),av(this)}render(){const e=this.sheet.getRoot();if(!hn(e,"dmn:DMNElement"))return null;const{name:t}=e.businessObject.$parent,n=this.components.getComponent("hit-policy")||Sv;return vr(1,"div","decision-table-properties",[vr(1,"div","decision-table-name",t,0,{title:this._translate("Decision name: ")+t}),vr(1,"div","decision-table-header-separator"),yr(2,n)],4)}};function Sv(){return null}Ev.$inject=["sheet","components"];let Rv=class{constructor(e){e.onGetComponent("table.before",500,(()=>Ev))}};Rv.$inject=["components"];var Tv={__init__:["decisionTableProperties"],decisionTableProperties:["type",Rv]};class Mv extends Ds{render(){const{row:e,rowIndex:t}=this.props,{components:n}=this.context,i=n.getComponents("cell-inner",{cellType:"rule-index",row:e,rowIndex:t});return vr(1,"td","rule-index",[i&&i.map((n=>yr(2,n,{row:e,rowIndex:t}))),t+1],0,{"data-element-id":e.id,"data-row-id":e.id})}}class Av{constructor(e){e.onGetComponent("cell",(({cellType:e})=>{if("before-rule-cells"===e)return Mv}))}}Av.$inject=["components"];var Pv={__init__:["decisionRuleIndices"],decisionRuleIndices:["type",Av]};const Dv=[{label:"FEEL",value:"feel"}];class $v{constructor(e){this._injector=e;const t=e.get("config.expressionLanguages")||{};this._config={options:Dv,defaults:{editor:"feel"}},t.options&&(this._config.options=t.options);const n=this._getLegacyDefaults();M(this._config.defaults,n,t.defaults)}getDefault(e){const{defaults:t}=this._config,n=t[e]||t.editor;return this._getLanguageByValue(n)||this.getAll()[0]}getLabel(e){const t=this._getLanguageByValue(e);return t?t.label:e}getAll(){return this._config.options}_getLegacyDefaults(){const e={},t=this._injector,n=t.get("config.defaultInputExpressionLanguage"),i=t.get("config.defaultOutputExpressionLanguage");return n&&(e.inputCell=n),i&&(e.outputCell=i),e}_getLanguageByValue(e){return h(this.getAll(),(t=>e===t.value))}}$v.$inject=["injector"];var jv={__init__:["expressionLanguages"],expressionLanguages:["type",$v]};class Iv extends Ds{render({rows:e,cols:t}){const{components:n}=this.context;return vr(1,"tbody",null,e.map(((e,i)=>{const o=n.getComponent("row",{rowType:"rule"});return o&&yr(2,o,{row:e,rowIndex:i,cols:t},e.id)})),0)}}class Bv extends Ds{constructor(e,t){super(e,t),cv(this,pv)}render(){const{row:e,rowIndex:t,cols:n}=this.props,{cells:i}=e;return vr(1,"tr",null,[this.slotFills({type:"cell",context:{cellType:"before-rule-cells",row:e,rowIndex:t}}),i.map(((i,o)=>this.slotFill({type:"cell",context:{cellType:"rule",cell:i,rowIndex:t,colIndex:o},key:i.id,row:e,col:n[o]}))),this.slotFills({type:"cell",context:{cellType:"after-rule-cells",row:e,rowIndex:t}})],0)}}class Lv extends Ds{render(){const{cell:e,row:t,col:n}=this.props;return hn(e,"dmn:UnaryTests")?yr(2,dv,{className:"input-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":n.id,children:e.businessObject.text}):yr(2,dv,{className:"output-cell",elementId:e.id,"data-row-id":t.id,"data-col-id":n.id,children:e.businessObject.text})}}let Nv=class{constructor(e){e.onGetComponent("table.body",(()=>Iv)),e.onGetComponent("row",(({rowType:e})=>{if("rule"===e)return Bv})),e.onGetComponent("cell",(({cellType:e})=>{if("rule"===e)return Lv}))}};Nv.$inject=["components"];var qv={__depends__:[jv],__init__:["decisionRules"],decisionRules:["type",Nv]};const Vv=[{label:"Unique",value:{hitPolicy:"UNIQUE",aggregation:void 0},explanation:"No overlap is possible and all rules are disjoint. Only a single rule can be matched"},{label:"First",value:{hitPolicy:"FIRST",aggregation:void 0},explanation:"Rules may overlap. The first matching rule will be chosen"},{label:"Priority",value:{hitPolicy:"PRIORITY",aggregation:void 0},explanation:"Rules may overlap. The one with the highest priority will be chosen"},{label:"Any",value:{hitPolicy:"ANY",aggregation:void 0},explanation:"Rules may overlap. Their output have to match"},{label:"Collect",value:{hitPolicy:"COLLECT",aggregation:void 0},explanation:"Collects the values of all matching rules"},{label:"Collect (Sum)",value:{hitPolicy:"COLLECT",aggregation:"SUM"},explanation:"Collects the values of all matching rules and sums up to a single value"},{label:"Collect (Min)",value:{hitPolicy:"COLLECT",aggregation:"MIN"},explanation:"Collects the values of all matching rules and uses the lowest value"},{label:"Collect (Max)",value:{hitPolicy:"COLLECT",aggregation:"MAX"},explanation:"Collects the values of all matching rules and uses the highest value"},{label:"Collect (Count)",value:{hitPolicy:"COLLECT",aggregation:"COUNT"},explanation:"Collects the values of all matching rules and counts the number of them"},{label:"Rule order",value:{hitPolicy:"RULE ORDER",aggregation:void 0},explanation:"Collects the values of all matching rules in rule order"},{label:"Output order",value:{hitPolicy:"OUTPUT ORDER",aggregation:void 0},explanation:"Collects the values of all matching rules in decreasing output priority order"}];class Fv extends Ds{constructor(e,t){super(e,t),this._translate=t.injector.get("translate"),av(this)}getRoot(){return this.sheet.getRoot()}render(){const e=this.getRoot().businessObject,{aggregation:t,hitPolicy:n}=e,i=h(Vv,(e=>function(e,t){return e.hitPolicy===t.hitPolicy&&e.aggregation===t.aggregation}(e.value,{aggregation:t,hitPolicy:n})));return vr(1,"div","hit-policy header",[vr(1,"label","dms-label",this._translate("Hit policy:"),0),vr(1,"span","hit-policy-value",this._translate(i.label),0)],4,{title:this._translate(i.explanation)})}}function zv(e){e.onGetComponent("hit-policy",(()=>Fv))}Fv.$inject=["sheet"],zv.$inject=["components"];var Qv={__init__:["hitPolicyProvider"],hitPolicyProvider:["type",zv]};let Hv=class extends Ds{constructor(e,t){super(e,t);const{injector:n}=t;this._translate=n.get("translate"),this._eventBus=n.get("eventBus")}onClick=()=>{this._eventBus.fire("showDrd")};render(){return vr(1,"div","view-drd",vr(1,"button","view-drd-button",this._translate("View DRD"),0,{type:"button",onClick:this.onClick}),2,null,null,(e=>this.node=e))}},Wv=class{constructor(e,t,n,i){this._injector=n,this._sheet=i,e.onGetComponent("table.before",(()=>{if(this.canViewDrd())return Hv})),t.on("showDrd",(()=>{const e=n.get("_parent",!1),t=Uv(i.getRoot());if(!t)return;const o=e.getView(t);e.open(o)}))}canViewDrd(){const e=this._injector.get("_parent",!1);if(!e)return!1;const t=Uv(this._sheet.getRoot());return!!e.getView(t)}};function Uv(e){const{businessObject:t}=e;if(!t)return;return t.$parent.$parent}Wv.$inject=["components","eventBus","injector","sheet"];var Xv={__init__:["viewDrd"],viewDrd:["type",Wv]};let Kv=class{constructor(e){e.onGetComponent("table.before",(()=>Bs))}};Kv.$inject=["components"];var Gv={__init__:["poweredBy"],poweredBy:["type",Kv]};let Yv=class e extends nv{constructor(t={}){const n=e._createContainer();super(M(t,{renderer:{container:n}})),this._container=n}open(e){var t=this;return new Promise(((n,i)=>{var o;try{return t._decision&&t.clear(),t._decision=e,function(e,t,n){const i=e.get("tableImporter"),o=e.get("eventBus"),r=e.get("sheet");e.get("modeling",!1);let s,a=[];o.fire("import.render.start",{decision:t});try{!function(e){new ov({create:(e,t,n,o)=>i.create(e,t,n,o),table:e=>i.add(e),element:(e,t,n)=>i.add(e,t,n),error(e,t){a.push({message:e,context:t})}}).handleDecision(e)}(t)}catch(e){s=e}o.fire("import.render.complete",{error:s,warnings:a}),o.fire("elements.changed",{elements:[r.getRoot()]}),n(s,a)}(t,e,(function(e,t){e?(e.warnings=t||[],i(e)):n({warnings:t||[]})}))}catch(e){o=e}o?(o.warnings=o.warnings||[],i(o)):n({warnings:[]})}))}_init(e){let{modules:t,additionalModules:n,...i}=e,o=t||this.getModules();return{modules:[Gv,...o,...n||[],...[{decisionTable:["value",this]}]],config:i}}on(e,t,n,i){return this.get("eventBus").on(e,t,n,i)}off(e,t){this.get("eventBus").off(e,t)}_emit(e,t){return this.get("eventBus").fire(e,t)}attachTo(e){if(!e)throw new Error("parentNode required");this.detach();const t=this._container;e.appendChild(t),this._emit("attach",{})}detach(){const e=this._container;e.parentNode&&(this._emit("detach",{}),en(e))}destroy(){super.destroy(),this.detach()}getModules(){return e._getModules()}static _getModules(){return[vv,bv,ha,kv,Tv,Pv,qv,Qv,Xv]}static _createContainer(){return Gt('<div class="dmn-decision-table-container"></div>')}};class Zv extends Ds{constructor(e,t){super(e,t),av(this),this.addRule=this.addRule.bind(this)}componentWillMount(){this._eventBus=this.context.injector.get("eventBus")}handleClick=e=>{e.stopPropagation(),this.addRule(e.target.dataset.colIndex)};addRule(e){this._eventBus.fire("addRule",{colIndex:e})}render(){const{cols:e}=this.props,t=[vr(1,"td","add-rule-add",vr(1,"button","dmn-icon-plus action-icon",null,1,{title:this.translate("Add rule")}),2)],{businessObject:n}=this.sheet.getRoot();n.input&&n.input.length||t.push(vr(1,"td","input-cell",xr("-"),2));for(let n=0;n<e.length+1;n++){let i="add-rule";const o=e[n]&&e[n].businessObject;let r="";o?(o.$instanceOf("dmn:InputClause")&&(i+=" input-cell",r="-"),o.$instanceOf("dmn:OutputClause")&&(i+=" output-cell")):i+=" annotation",t.push(vr(1,"td",i,r,0,{"data-col-index":n}))}return vr(1,"tfoot","actionable add-rule",vr(1,"tr",null,t,0),2,{onClick:this.handleClick})}}Zv.$inject=["sheet","translate"];class Jv{constructor(e,t,n,i){e.onGetComponent("table.foot",(()=>Zv)),n.on("addRule",((e,n)=>{const o=t.trigger("addRule"),r=n.colIndex;o.cells[r]?i.select(o.cells[r]):i.select(o.cells[0])}))}}Jv.$inject=["components","editorActions","eventBus","selection"];class ey{constructor(e,t,n){this._elementRegistry=e,this._eventBus=t,this._renderer=n,this._selection=void 0,t.on("diagram.clear",(()=>{this._selection=void 0}))}select(e){c(e)&&(e=this._elementRegistry.get(e));const t=this._selection;t!==e&&(this._selection=e,this._eventBus.fire("selection.changed",{oldSelection:t,selection:e}))}deselect(){const e=this._selection;this._selection=void 0,this._eventBus.fire("selection.changed",{oldSelection:e,selection:this._selection})}get(){return this._selection}hasSelection(){return!!this._selection}}ey.$inject=["elementRegistry","eventBus","renderer"];class ty{constructor(e,t,n,i){this._elementRegistry=e,this._renderer=n,this._selection=i,t.on(["cell.click","cell.contextmenu"],(({id:t})=>{const n=e.get(t);n&&i.select(n)})),t.on("row.remove",(({row:e})=>{const t=i.get();t&&e===t.row&&i.deselect()})),t.on("col.remove",(({col:e})=>{const t=i.get();t&&e===t.col&&i.deselect()}))}}ty.$inject=["elementRegistry","eventBus","renderer","selection"];var ny={__init__:["selection","selectionBehavior"],selection:["type",ey],selectionBehavior:["type",ty]};const iy=["click","dblclick","contextmenu","mousedown","mouseup","mouseenter","mouseleave","mouseout","mouseover","mousemove","focusin","focusout","drag","dragstart","dragend","dragover","dragenter","dragleave","drop"];class oy{constructor(e,t){var n,i,o;o=e=>{const{target:t,type:n}=e,i=Bt(t,"[data-element-id]",!0);if(!i)return;const o=i.getAttribute("data-element-id");if(o){const t=this._eventBus.createEvent({id:o,event:e,node:i,target:i});this._eventBus.fire(`cell.${n}`,t),t.defaultPrevented&&e.preventDefault(),t.cancelBubble&&e.stopPropagation()}},(i="_handleEvent")in(n=this)?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o,this._eventBus=t,this._container=e.container,t.on("table.init",(()=>{this._addEventListeners(iy)})),t.on("table.destroy",(()=>{this._removeEventListeners(iy)}))}_addEventListeners(e){const t=this._container;e.forEach((e=>{t.addEventListener(e,this._handleEvent)}))}_removeEventListeners(e){const t=this._container;e.forEach((e=>{t.removeEventListener(e,this._handleEvent)}))}}oy.$inject=["config.renderer","eventBus"];var ry={__init__:["interactionEvents"],interactionEvents:["type",oy]},sy="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ay(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ly,cy={exports:{}},uy=cy.exports; 21 var t,n;this._container=this._createContainer(),t=this._container,n=xn('<a href="http://bpmn.io" target="_blank" class="bjs-powered-by" title="Powered by bpmn.io" style="position global() method in mp
|