@g1cloud/bpmn-modeler-next 5.0.0-beta.14 → 5.0.0-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@
3
3
  column: `+P+`
4
4
  nested error: `+_.message;if(T)return a.addWarning({message:F,error:_}),!0;throw Er(F)}function u(_,E){return l(_,E,!0)}function p(){var _=a.elementsById,E=a.references,T,O;for(T=0;O=E[T];T++){var N=O.element,P=_[O.id],D=er(N).propertiesByName[O.property];if(P||a.addWarning({message:"unresolved reference <"+O.id+">",element:O.element,property:O.property,value:O.id}),D.isMany){var F=N.get(D.name),J=F.indexOf(O);J===-1&&(J=F.length),P?F[J]=P:F.splice(J,1)}else N.set(D.name,P)}}function f(){c.pop().handleEnd()}var d=/^<\?xml /i,g=/ encoding="([^"]+)"/i,h=/^utf-8$/i;function y(_){if(d.test(_)){var E=g.exec(_),T=E&&E[1];!T||h.test(T)||a.addWarning({message:"unsupported document encoding <"+T+">, falling back to UTF-8"})}}function C(_,E){var T=c.peek();try{c.push(T.handleNode(_))}catch(O){l(O,E,o)&&c.push(new dp)}}function x(_,E){try{c.peek().handleText(_)}catch(T){u(T,E)}}function m(_,E){_.trim()&&x(_,E)}var v=r.getPackages().reduce(function(_,E){return _[E.uri]=E.prefix,_},Object.entries(fp).reduce(function(_,[E,T]){return _[T]=E,_},r.config&&r.config.nsMap||{}));return s.ns(v).on("openTag",function(_,E,T,O){var N=_.attrs||{},P=Object.keys(N).reduce(function(F,J){var ge=E(N[J]);return F[J]=ge,F},{}),D={name:_.name,originalName:_.originalName,attributes:P,ns:_.ns};C(D,O)}).on("question",y).on("closeTag",f).on("cdata",x).on("text",function(_,E,T){m(E(_),T)}).on("error",l).on("warn",u),new Promise(function(_,E){var T;try{s.parse(e),p()}catch(F){T=F}var O=i.element;!T&&!O&&(T=Er("failed to parse document as <"+i.type.$descriptor.name+">"));var N=a.warnings,P=a.references,D=a.elementsById;return T?(T.warnings=N,E(T)):_({rootElement:O,elementsById:D,references:P,warnings:N})})},gp.prototype.handler=function(e){return new mp(this.model,e)};function j1(){var e=[];return Object.defineProperty(e,"peek",{value:function(){return this[this.length-1]}}),e}var H1=`<?xml version="1.0" encoding="UTF-8"?>
5
5
  `,z1=/<|>|'|"|&|\n\r|\n/g,vm=/<|>|&/g;function $i(e){this.prefixMap={},this.uriMap={},this.used={},this.wellknown=[],this.custom=[],this.parent=e,this.defaultPrefixMap=e&&e.defaultPrefixMap||{}}$i.prototype.mapDefaultPrefixes=function(e){this.defaultPrefixMap=e},$i.prototype.defaultUriByPrefix=function(e){return this.defaultPrefixMap[e]},$i.prototype.byUri=function(e){return this.uriMap[e]||this.parent&&this.parent.byUri(e)},$i.prototype.add=function(e,t){this.uriMap[e.uri]=e,t?this.wellknown.push(e):this.custom.push(e),this.mapPrefix(e.prefix,e.uri)},$i.prototype.uriByPrefix=function(e){return this.prefixMap[e||"xmlns"]||this.parent&&this.parent.uriByPrefix(e)},$i.prototype.mapPrefix=function(e,t){this.prefixMap[e||"xmlns"]=t},$i.prototype.getNSKey=function(e){return e.prefix!==void 0?e.uri+"|"+e.prefix:e.uri},$i.prototype.logUsed=function(e){var t=e.uri,n=this.getNSKey(e);this.used[n]=this.byUri(t),this.parent&&this.parent.logUsed(e)},$i.prototype.getUsed=function(e){var t=[].concat(this.wellknown,this.custom);return t.filter(n=>{var i=this.getNSKey(n);return this.used[i]})};function G1(e){return e.charAt(0).toLowerCase()+e.slice(1)}function V1(e,t){return hm(t)?G1(e):e}function bm(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}function xm(e){return qn(e)?e:(e.prefix?e.prefix+":":"")+e.localName}function W1(e){return e.getUsed().filter(function(t){return t.prefix!=="xml"}).map(function(t){var n="xmlns"+(t.prefix?":"+t.prefix:"");return{name:n,value:t.uri}})}function U1(e,t){return t.isGeneric?U({localName:t.ns.localName},e):U({localName:V1(t.ns.localName,t.$pkg)},e)}function q1(e,t){return U({localName:t.ns.localName},e)}function Y1(e){var t=e.$descriptor;return nt(t.properties,function(n){var i=n.name;if(n.isVirtual||!Yn(e,i))return!1;var r=e[i];return r===n.default||r===null?!1:n.isMany?r.length:!0})}var K1={"\n":"#10","\n\r":"#10",'"':"#34","'":"#39","<":"#60",">":"#62","&":"#38"},X1={"<":"lt",">":"gt","&":"amp"};function _m(e,t,n){return e=qn(e)?e:""+e,e.replace(t,function(i){return"&"+n[i]+";"})}function Z1(e){return _m(e,z1,K1)}function Q1(e){return _m(e,vm,X1)}function J1(e){return nt(e,function(t){return t.isAttr})}function eS(e){return nt(e,function(t){return!t.isAttr})}function yp(e){this.tagName=e}yp.prototype.build=function(e){return this.element=e,this},yp.prototype.serializeTo=function(e){e.appendIndent().append("<"+this.tagName+">"+this.element.id+"</"+this.tagName+">").appendNewLine()};function so(){}so.prototype.serializeValue=so.prototype.serializeTo=function(e){e.append(this.escape?Q1(this.value):this.value)},so.prototype.build=function(e,t){return this.value=t,e.type==="String"&&t.search(vm)!==-1&&(this.escape=!0),this};function vp(e){this.tagName=e}bm(vp,so),vp.prototype.serializeTo=function(e){e.appendIndent().append("<"+this.tagName+">"),this.serializeValue(e),e.append("</"+this.tagName+">").appendNewLine()};function Nt(e,t){this.body=[],this.attrs=[],this.parent=e,this.propertyDescriptor=t}Nt.prototype.build=function(e){this.element=e;var t=e.$descriptor,n=this.propertyDescriptor,i,r,o=t.isGeneric;return o?i=this.parseGenericNsAttributes(e):i=this.parseNsAttributes(e),n?this.ns=this.nsPropertyTagName(n):this.ns=this.nsTagName(t),this.tagName=this.addTagName(this.ns),o?this.parseGenericContainments(e):(r=Y1(e),this.parseAttributes(J1(r)),this.parseContainments(eS(r))),this.parseGenericAttributes(e,i),this},Nt.prototype.nsTagName=function(e){var t=this.logNamespaceUsed(e.ns);return U1(t,e)},Nt.prototype.nsPropertyTagName=function(e){var t=this.logNamespaceUsed(e.ns);return q1(t,e)},Nt.prototype.isLocalNs=function(e){return e.uri===this.ns.uri},Nt.prototype.nsAttributeName=function(e){var t;if(qn(e)?t=Dn(e):t=e.ns,e.inherited)return{localName:t.localName};var n=this.logNamespaceUsed(t);return this.getNamespaces().logUsed(n),this.isLocalNs(n)?{localName:t.localName}:U({localName:t.localName},n)},Nt.prototype.parseGenericNsAttributes=function(e){return Object.entries(e).filter(([t,n])=>!t.startsWith("$")&&this.parseNsAttribute(e,t,n)).map(([t,n])=>({name:t,value:n}))},Nt.prototype.parseGenericContainments=function(e){var t=e.$body;t&&this.body.push(new so().build({type:"String"},t));var n=e.$children;n&&z(n,i=>{this.body.push(new Nt(this).build(i))})},Nt.prototype.parseNsAttribute=function(e,t,n){var i=e.$model,r=Dn(t),o;if(r.prefix==="xmlns"&&(o={prefix:r.localName,uri:n}),!r.prefix&&r.localName==="xmlns"&&(o={uri:n}),!o)return{name:t,value:n};if(i&&i.getPackage(n))this.logNamespace(o,!0,!0);else{var a=this.logNamespaceUsed(o,!0);this.getNamespaces().logUsed(a)}},Nt.prototype.parseNsAttributes=function(e){var t=this,n=e.$attrs,i=[];return z(n,function(r,o){var a=t.parseNsAttribute(e,o,r);a&&i.push(a)}),i},Nt.prototype.parseGenericAttributes=function(e,t){var n=this;z(t,function(i){try{n.addAttribute(n.nsAttributeName(i.name),i.value)}catch(r){typeof console<"u"&&console.warn(`missing namespace information for <${i.name}=${i.value}> on`,e,r)}})},Nt.prototype.parseContainments=function(e){var t=this,n=this.body,i=this.element;z(e,function(r){var o=i.get(r.name),a=r.isReference,s=r.isMany;if(s||(o=[o]),r.isBody)n.push(new so().build(r,o[0]));else if(sm(r.type))z(o,function(l){n.push(new vp(t.addTagName(t.nsPropertyTagName(r))).build(r,l))});else if(a)z(o,function(l){n.push(new yp(t.addTagName(t.nsPropertyTagName(r))).build(l))});else{var c=gm(r);z(o,function(l){var u;c?c===mm?u=new Nt(t,r):u=new lc(t,r,c):u=new Nt(t),n.push(u.build(l))})}})},Nt.prototype.getNamespaces=function(e){var t=this.namespaces,n=this.parent,i;return t||(i=n&&n.getNamespaces(),e||!i?this.namespaces=t=new $i(i):t=i),t},Nt.prototype.logNamespace=function(e,t,n){var i=this.getNamespaces(n),r=e.uri,o=e.prefix,a=i.byUri(r);return(!a||n)&&i.add(e,t),i.mapPrefix(o,r),e},Nt.prototype.logNamespaceUsed=function(e,t){var n=this.getNamespaces(t),i=e.prefix,r=e.uri,o,a,s;if(!i&&!r)return{localName:e.localName};if(s=n.defaultUriByPrefix(i),r=r||s||n.uriByPrefix(i),!r)throw new Error("no namespace uri given for prefix <"+i+">");if(e=n.byUri(r),!e&&!i&&(e=this.logNamespace({uri:r},s===r,!0)),!e){for(o=i,a=1;n.uriByPrefix(o);)o=i+"_"+a++;e=this.logNamespace({prefix:o,uri:r},s===r)}return i&&n.mapPrefix(i,r),e},Nt.prototype.parseAttributes=function(e){var t=this,n=this.element;z(e,function(i){var r=n.get(i.name);if(i.isReference)if(!i.isMany)r=r.id;else{var o=[];z(r,function(a){o.push(a.id)}),r=o.join(" ")}t.addAttribute(t.nsAttributeName(i),r)})},Nt.prototype.addTagName=function(e){var t=this.logNamespaceUsed(e);return this.getNamespaces().logUsed(t),xm(e)},Nt.prototype.addAttribute=function(e,t){var n=this.attrs;qn(t)&&(t=Z1(t));var i=em(n,function(o){return o.name.localName===e.localName&&o.name.uri===e.uri&&o.name.prefix===e.prefix}),r={name:e,value:t};i!==-1?n.splice(i,1,r):n.push(r)},Nt.prototype.serializeAttributes=function(e){var t=this.attrs,n=this.namespaces;n&&(t=W1(n).concat(t)),z(t,function(i){e.append(" ").append(xm(i.name)).append('="').append(i.value).append('"')})},Nt.prototype.serializeTo=function(e){var t=this.body[0],n=t&&t.constructor!==so;e.appendIndent().append("<"+this.tagName),this.serializeAttributes(e),e.append(t?">":" />"),t&&(n&&e.appendNewLine().indent(),z(this.body,function(i){i.serializeTo(e)}),n&&e.unindent().appendIndent(),e.append("</"+this.tagName+">")),e.appendNewLine()};function lc(e,t,n){Nt.call(this,e,t),this.serialization=n}bm(lc,Nt),lc.prototype.parseNsAttributes=function(e){var t=Nt.prototype.parseNsAttributes.call(this,e).filter(a=>a.name!==this.serialization),n=e.$descriptor;if(n.name===this.propertyDescriptor.type)return t;var i=this.typeNs=this.nsTagName(n);this.getNamespaces().logUsed(this.typeNs);var r=e.$model.getPackage(i.uri),o=r.xml&&r.xml.typePrefix||"";return this.addAttribute(this.nsAttributeName(this.serialization),(i.prefix?i.prefix+":":"")+o+n.ns.localName),t},lc.prototype.isLocalNs=function(e){return e.uri===(this.typeNs||this.ns).uri};function tS(){this.value="",this.write=function(e){this.value+=e}}function nS(e,t){var n=[""];this.append=function(i){return e.write(i),this},this.appendNewLine=function(){return t&&e.write(`
6
- `),this},this.appendIndent=function(){return t&&e.write(n.join(" ")),this},this.indent=function(){return n.push(""),this},this.unindent=function(){return n.pop(),this}}function iS(e){e=U({format:!1,preamble:!0},e||{});function t(n,i){var r=i||new tS,o=new nS(r,e.format);e.preamble&&o.append(H1);var a=new Nt,s=n.$model;if(a.getNamespaces().mapDefaultPrefixes(rS(s)),a.build(n).serializeTo(o),!i)return r.value}return{toXML:t}}function rS(e){const t=e.config&&e.config.nsMap||{},n={};for(const i in fp)n[i]=fp[i];for(const i in t){const r=t[i];n[r]=i}for(const i of e.getPackages())n[i.prefix]=i.uri;return n}function uc(e,t){di.call(this,e,t)}uc.prototype=Object.create(di.prototype),uc.prototype.fromXML=function(e,t,n){qn(t)||(n=t,t="bpmn:Definitions");var i=new gp(U({model:this,lax:!0},n)),r=i.handler(t);return i.fromXML(e,r)},uc.prototype.toXML=function(e,t){var n=new iS(t);return new Promise(function(i,r){try{var o=n.toXML(e);return i({xml:o})}catch(a){return r(a)}})};var oS="BPMN20",aS="http://www.omg.org/spec/BPMN/20100524/MODEL",sS="bpmn",cS=[],lS=[{name:"Interface",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"operations",type:"Operation",isMany:!0},{name:"implementationRef",isAttr:!0,type:"String"}]},{name:"Operation",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"inMessageRef",type:"Message",isReference:!0},{name:"outMessageRef",type:"Message",isReference:!0},{name:"errorRef",type:"Error",isMany:!0,isReference:!0},{name:"implementationRef",isAttr:!0,type:"String"}]},{name:"EndPoint",superClass:["RootElement"]},{name:"Auditing",superClass:["BaseElement"]},{name:"GlobalTask",superClass:["CallableElement"],properties:[{name:"resources",type:"ResourceRole",isMany:!0}]},{name:"Monitoring",superClass:["BaseElement"]},{name:"Performer",superClass:["ResourceRole"]},{name:"Process",superClass:["FlowElementsContainer","CallableElement"],properties:[{name:"processType",type:"ProcessType",isAttr:!0},{name:"isClosed",isAttr:!0,type:"Boolean"},{name:"auditing",type:"Auditing"},{name:"monitoring",type:"Monitoring"},{name:"properties",type:"Property",isMany:!0},{name:"laneSets",isMany:!0,replaces:"FlowElementsContainer#laneSets",type:"LaneSet"},{name:"flowElements",isMany:!0,replaces:"FlowElementsContainer#flowElements",type:"FlowElement"},{name:"artifacts",type:"Artifact",isMany:!0},{name:"resources",type:"ResourceRole",isMany:!0},{name:"correlationSubscriptions",type:"CorrelationSubscription",isMany:!0},{name:"supports",type:"Process",isMany:!0,isReference:!0},{name:"definitionalCollaborationRef",type:"Collaboration",isAttr:!0,isReference:!0},{name:"isExecutable",isAttr:!0,type:"Boolean"}]},{name:"LaneSet",superClass:["BaseElement"],properties:[{name:"lanes",type:"Lane",isMany:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Lane",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"partitionElementRef",type:"BaseElement",isAttr:!0,isReference:!0},{name:"partitionElement",type:"BaseElement"},{name:"flowNodeRef",type:"FlowNode",isMany:!0,isReference:!0},{name:"childLaneSet",type:"LaneSet",xml:{serialize:"xsi:type"}}]},{name:"GlobalManualTask",superClass:["GlobalTask"]},{name:"ManualTask",superClass:["Task"]},{name:"UserTask",superClass:["Task"],properties:[{name:"renderings",type:"Rendering",isMany:!0},{name:"implementation",isAttr:!0,type:"String"}]},{name:"Rendering",superClass:["BaseElement"]},{name:"HumanPerformer",superClass:["Performer"]},{name:"PotentialOwner",superClass:["HumanPerformer"]},{name:"GlobalUserTask",superClass:["GlobalTask"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"renderings",type:"Rendering",isMany:!0}]},{name:"Gateway",isAbstract:!0,superClass:["FlowNode"],properties:[{name:"gatewayDirection",type:"GatewayDirection",default:"Unspecified",isAttr:!0}]},{name:"EventBasedGateway",superClass:["Gateway"],properties:[{name:"instantiate",default:!1,isAttr:!0,type:"Boolean"},{name:"eventGatewayType",type:"EventBasedGatewayType",isAttr:!0,default:"Exclusive"}]},{name:"ComplexGateway",superClass:["Gateway"],properties:[{name:"activationCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0}]},{name:"ExclusiveGateway",superClass:["Gateway"],properties:[{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0}]},{name:"InclusiveGateway",superClass:["Gateway"],properties:[{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0}]},{name:"ParallelGateway",superClass:["Gateway"]},{name:"RootElement",isAbstract:!0,superClass:["BaseElement"]},{name:"Relationship",superClass:["BaseElement"],properties:[{name:"type",isAttr:!0,type:"String"},{name:"direction",type:"RelationshipDirection",isAttr:!0},{name:"source",isMany:!0,isReference:!0,type:"Element"},{name:"target",isMany:!0,isReference:!0,type:"Element"}]},{name:"BaseElement",isAbstract:!0,properties:[{name:"id",isAttr:!0,type:"String",isId:!0},{name:"documentation",type:"Documentation",isMany:!0},{name:"extensionDefinitions",type:"ExtensionDefinition",isMany:!0,isReference:!0},{name:"extensionElements",type:"ExtensionElements"}]},{name:"Extension",properties:[{name:"mustUnderstand",default:!1,isAttr:!0,type:"Boolean"},{name:"definition",type:"ExtensionDefinition",isAttr:!0,isReference:!0}]},{name:"ExtensionDefinition",properties:[{name:"name",isAttr:!0,type:"String"},{name:"extensionAttributeDefinitions",type:"ExtensionAttributeDefinition",isMany:!0}]},{name:"ExtensionAttributeDefinition",properties:[{name:"name",isAttr:!0,type:"String"},{name:"type",isAttr:!0,type:"String"},{name:"isReference",default:!1,isAttr:!0,type:"Boolean"},{name:"extensionDefinition",type:"ExtensionDefinition",isAttr:!0,isReference:!0}]},{name:"ExtensionElements",properties:[{name:"valueRef",isAttr:!0,isReference:!0,type:"Element"},{name:"values",type:"Element",isMany:!0},{name:"extensionAttributeDefinition",type:"ExtensionAttributeDefinition",isAttr:!0,isReference:!0}]},{name:"Documentation",superClass:["BaseElement"],properties:[{name:"text",type:"String",isBody:!0},{name:"textFormat",default:"text/plain",isAttr:!0,type:"String"}]},{name:"Event",isAbstract:!0,superClass:["FlowNode","InteractionNode"],properties:[{name:"properties",type:"Property",isMany:!0}]},{name:"IntermediateCatchEvent",superClass:["CatchEvent"]},{name:"IntermediateThrowEvent",superClass:["ThrowEvent"]},{name:"EndEvent",superClass:["ThrowEvent"]},{name:"StartEvent",superClass:["CatchEvent"],properties:[{name:"isInterrupting",default:!0,isAttr:!0,type:"Boolean"}]},{name:"ThrowEvent",isAbstract:!0,superClass:["Event"],properties:[{name:"dataInputs",type:"DataInput",isMany:!0},{name:"dataInputAssociations",type:"DataInputAssociation",isMany:!0},{name:"inputSet",type:"InputSet"},{name:"eventDefinitions",type:"EventDefinition",isMany:!0},{name:"eventDefinitionRef",type:"EventDefinition",isMany:!0,isReference:!0}]},{name:"CatchEvent",isAbstract:!0,superClass:["Event"],properties:[{name:"parallelMultiple",isAttr:!0,type:"Boolean",default:!1},{name:"dataOutputs",type:"DataOutput",isMany:!0},{name:"dataOutputAssociations",type:"DataOutputAssociation",isMany:!0},{name:"outputSet",type:"OutputSet"},{name:"eventDefinitions",type:"EventDefinition",isMany:!0},{name:"eventDefinitionRef",type:"EventDefinition",isMany:!0,isReference:!0}]},{name:"BoundaryEvent",superClass:["CatchEvent"],properties:[{name:"cancelActivity",default:!0,isAttr:!0,type:"Boolean"},{name:"attachedToRef",type:"Activity",isAttr:!0,isReference:!0}]},{name:"EventDefinition",isAbstract:!0,superClass:["RootElement"]},{name:"CancelEventDefinition",superClass:["EventDefinition"]},{name:"ErrorEventDefinition",superClass:["EventDefinition"],properties:[{name:"errorRef",type:"Error",isAttr:!0,isReference:!0}]},{name:"TerminateEventDefinition",superClass:["EventDefinition"]},{name:"EscalationEventDefinition",superClass:["EventDefinition"],properties:[{name:"escalationRef",type:"Escalation",isAttr:!0,isReference:!0}]},{name:"Escalation",properties:[{name:"structureRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"},{name:"escalationCode",isAttr:!0,type:"String"}],superClass:["RootElement"]},{name:"CompensateEventDefinition",superClass:["EventDefinition"],properties:[{name:"waitForCompletion",isAttr:!0,type:"Boolean",default:!0},{name:"activityRef",type:"Activity",isAttr:!0,isReference:!0}]},{name:"TimerEventDefinition",superClass:["EventDefinition"],properties:[{name:"timeDate",type:"Expression",xml:{serialize:"xsi:type"}},{name:"timeCycle",type:"Expression",xml:{serialize:"xsi:type"}},{name:"timeDuration",type:"Expression",xml:{serialize:"xsi:type"}}]},{name:"LinkEventDefinition",superClass:["EventDefinition"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"target",type:"LinkEventDefinition",isReference:!0},{name:"source",type:"LinkEventDefinition",isMany:!0,isReference:!0}]},{name:"MessageEventDefinition",superClass:["EventDefinition"],properties:[{name:"messageRef",type:"Message",isAttr:!0,isReference:!0},{name:"operationRef",type:"Operation",isReference:!0}]},{name:"ConditionalEventDefinition",superClass:["EventDefinition"],properties:[{name:"condition",type:"Expression",xml:{serialize:"xsi:type"}}]},{name:"SignalEventDefinition",superClass:["EventDefinition"],properties:[{name:"signalRef",type:"Signal",isAttr:!0,isReference:!0}]},{name:"Signal",superClass:["RootElement"],properties:[{name:"structureRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"ImplicitThrowEvent",superClass:["ThrowEvent"]},{name:"DataState",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"ItemAwareElement",superClass:["BaseElement"],properties:[{name:"itemSubjectRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"dataState",type:"DataState"}]},{name:"DataAssociation",superClass:["BaseElement"],properties:[{name:"sourceRef",type:"ItemAwareElement",isMany:!0,isReference:!0},{name:"targetRef",type:"ItemAwareElement",isReference:!0},{name:"transformation",type:"FormalExpression",xml:{serialize:"property"}},{name:"assignment",type:"Assignment",isMany:!0}]},{name:"DataInput",superClass:["ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"},{name:"inputSetRef",type:"InputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"inputSetWithOptional",type:"InputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"inputSetWithWhileExecuting",type:"InputSet",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"DataOutput",superClass:["ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"},{name:"outputSetRef",type:"OutputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"outputSetWithOptional",type:"OutputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"outputSetWithWhileExecuting",type:"OutputSet",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"InputSet",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"dataInputRefs",type:"DataInput",isMany:!0,isReference:!0},{name:"optionalInputRefs",type:"DataInput",isMany:!0,isReference:!0},{name:"whileExecutingInputRefs",type:"DataInput",isMany:!0,isReference:!0},{name:"outputSetRefs",type:"OutputSet",isMany:!0,isReference:!0}]},{name:"OutputSet",superClass:["BaseElement"],properties:[{name:"dataOutputRefs",type:"DataOutput",isMany:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"},{name:"inputSetRefs",type:"InputSet",isMany:!0,isReference:!0},{name:"optionalOutputRefs",type:"DataOutput",isMany:!0,isReference:!0},{name:"whileExecutingOutputRefs",type:"DataOutput",isMany:!0,isReference:!0}]},{name:"Property",superClass:["ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"DataInputAssociation",superClass:["DataAssociation"]},{name:"DataOutputAssociation",superClass:["DataAssociation"]},{name:"InputOutputSpecification",superClass:["BaseElement"],properties:[{name:"dataInputs",type:"DataInput",isMany:!0},{name:"dataOutputs",type:"DataOutput",isMany:!0},{name:"inputSets",type:"InputSet",isMany:!0},{name:"outputSets",type:"OutputSet",isMany:!0}]},{name:"DataObject",superClass:["FlowElement","ItemAwareElement"],properties:[{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"}]},{name:"InputOutputBinding",properties:[{name:"inputDataRef",type:"InputSet",isAttr:!0,isReference:!0},{name:"outputDataRef",type:"OutputSet",isAttr:!0,isReference:!0},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0}]},{name:"Assignment",superClass:["BaseElement"],properties:[{name:"from",type:"Expression",xml:{serialize:"xsi:type"}},{name:"to",type:"Expression",xml:{serialize:"xsi:type"}}]},{name:"DataStore",superClass:["RootElement","ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"capacity",isAttr:!0,type:"Integer"},{name:"isUnlimited",default:!0,isAttr:!0,type:"Boolean"}]},{name:"DataStoreReference",superClass:["ItemAwareElement","FlowElement"],properties:[{name:"dataStoreRef",type:"DataStore",isAttr:!0,isReference:!0}]},{name:"DataObjectReference",superClass:["ItemAwareElement","FlowElement"],properties:[{name:"dataObjectRef",type:"DataObject",isAttr:!0,isReference:!0}]},{name:"ConversationLink",superClass:["BaseElement"],properties:[{name:"sourceRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"targetRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"ConversationAssociation",superClass:["BaseElement"],properties:[{name:"innerConversationNodeRef",type:"ConversationNode",isAttr:!0,isReference:!0},{name:"outerConversationNodeRef",type:"ConversationNode",isAttr:!0,isReference:!0}]},{name:"CallConversation",superClass:["ConversationNode"],properties:[{name:"calledCollaborationRef",type:"Collaboration",isAttr:!0,isReference:!0},{name:"participantAssociations",type:"ParticipantAssociation",isMany:!0}]},{name:"Conversation",superClass:["ConversationNode"]},{name:"SubConversation",superClass:["ConversationNode"],properties:[{name:"conversationNodes",type:"ConversationNode",isMany:!0}]},{name:"ConversationNode",isAbstract:!0,superClass:["InteractionNode","BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"participantRef",type:"Participant",isMany:!0,isReference:!0},{name:"messageFlowRefs",type:"MessageFlow",isMany:!0,isReference:!0},{name:"correlationKeys",type:"CorrelationKey",isMany:!0}]},{name:"GlobalConversation",superClass:["Collaboration"]},{name:"PartnerEntity",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"participantRef",type:"Participant",isMany:!0,isReference:!0}]},{name:"PartnerRole",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"participantRef",type:"Participant",isMany:!0,isReference:!0}]},{name:"CorrelationProperty",superClass:["RootElement"],properties:[{name:"correlationPropertyRetrievalExpression",type:"CorrelationPropertyRetrievalExpression",isMany:!0},{name:"name",isAttr:!0,type:"String"},{name:"type",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"Error",superClass:["RootElement"],properties:[{name:"structureRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"},{name:"errorCode",isAttr:!0,type:"String"}]},{name:"CorrelationKey",superClass:["BaseElement"],properties:[{name:"correlationPropertyRef",type:"CorrelationProperty",isMany:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Expression",superClass:["BaseElement"],isAbstract:!1,properties:[{name:"body",isBody:!0,type:"String"}]},{name:"FormalExpression",superClass:["Expression"],properties:[{name:"language",isAttr:!0,type:"String"},{name:"evaluatesToTypeRef",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"Message",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"itemRef",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"ItemDefinition",superClass:["RootElement"],properties:[{name:"itemKind",type:"ItemKind",isAttr:!0},{name:"structureRef",isAttr:!0,type:"String"},{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"},{name:"import",type:"Import",isAttr:!0,isReference:!0}]},{name:"FlowElement",isAbstract:!0,superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"auditing",type:"Auditing"},{name:"monitoring",type:"Monitoring"},{name:"categoryValueRef",type:"CategoryValue",isMany:!0,isReference:!0}]},{name:"SequenceFlow",superClass:["FlowElement"],properties:[{name:"isImmediate",isAttr:!0,type:"Boolean"},{name:"conditionExpression",type:"Expression",xml:{serialize:"xsi:type"}},{name:"sourceRef",type:"FlowNode",isAttr:!0,isReference:!0},{name:"targetRef",type:"FlowNode",isAttr:!0,isReference:!0}]},{name:"FlowElementsContainer",isAbstract:!0,superClass:["BaseElement"],properties:[{name:"laneSets",type:"LaneSet",isMany:!0},{name:"flowElements",type:"FlowElement",isMany:!0}]},{name:"CallableElement",isAbstract:!0,superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"ioSpecification",type:"InputOutputSpecification",xml:{serialize:"property"}},{name:"supportedInterfaceRef",type:"Interface",isMany:!0,isReference:!0},{name:"ioBinding",type:"InputOutputBinding",isMany:!0,xml:{serialize:"property"}}]},{name:"FlowNode",isAbstract:!0,superClass:["FlowElement"],properties:[{name:"incoming",type:"SequenceFlow",isMany:!0,isReference:!0},{name:"outgoing",type:"SequenceFlow",isMany:!0,isReference:!0},{name:"lanes",type:"Lane",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"CorrelationPropertyRetrievalExpression",superClass:["BaseElement"],properties:[{name:"messagePath",type:"FormalExpression"},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"CorrelationPropertyBinding",superClass:["BaseElement"],properties:[{name:"dataPath",type:"FormalExpression"},{name:"correlationPropertyRef",type:"CorrelationProperty",isAttr:!0,isReference:!0}]},{name:"Resource",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"resourceParameters",type:"ResourceParameter",isMany:!0}]},{name:"ResourceParameter",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isRequired",isAttr:!0,type:"Boolean"},{name:"type",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"CorrelationSubscription",superClass:["BaseElement"],properties:[{name:"correlationKeyRef",type:"CorrelationKey",isAttr:!0,isReference:!0},{name:"correlationPropertyBinding",type:"CorrelationPropertyBinding",isMany:!0}]},{name:"MessageFlow",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"sourceRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"targetRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"MessageFlowAssociation",superClass:["BaseElement"],properties:[{name:"innerMessageFlowRef",type:"MessageFlow",isAttr:!0,isReference:!0},{name:"outerMessageFlowRef",type:"MessageFlow",isAttr:!0,isReference:!0}]},{name:"InteractionNode",isAbstract:!0,properties:[{name:"incomingConversationLinks",type:"ConversationLink",isMany:!0,isVirtual:!0,isReference:!0},{name:"outgoingConversationLinks",type:"ConversationLink",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"Participant",superClass:["InteractionNode","BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"interfaceRef",type:"Interface",isMany:!0,isReference:!0},{name:"participantMultiplicity",type:"ParticipantMultiplicity"},{name:"endPointRefs",type:"EndPoint",isMany:!0,isReference:!0},{name:"processRef",type:"Process",isAttr:!0,isReference:!0}]},{name:"ParticipantAssociation",superClass:["BaseElement"],properties:[{name:"innerParticipantRef",type:"Participant",isAttr:!0,isReference:!0},{name:"outerParticipantRef",type:"Participant",isAttr:!0,isReference:!0}]},{name:"ParticipantMultiplicity",properties:[{name:"minimum",default:0,isAttr:!0,type:"Integer"},{name:"maximum",default:1,isAttr:!0,type:"Integer"}],superClass:["BaseElement"]},{name:"Collaboration",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isClosed",isAttr:!0,type:"Boolean"},{name:"participants",type:"Participant",isMany:!0},{name:"messageFlows",type:"MessageFlow",isMany:!0},{name:"artifacts",type:"Artifact",isMany:!0},{name:"conversations",type:"ConversationNode",isMany:!0},{name:"conversationAssociations",type:"ConversationAssociation"},{name:"participantAssociations",type:"ParticipantAssociation",isMany:!0},{name:"messageFlowAssociations",type:"MessageFlowAssociation",isMany:!0},{name:"correlationKeys",type:"CorrelationKey",isMany:!0},{name:"choreographyRef",type:"Choreography",isMany:!0,isReference:!0},{name:"conversationLinks",type:"ConversationLink",isMany:!0}]},{name:"ChoreographyActivity",isAbstract:!0,superClass:["FlowNode"],properties:[{name:"participantRef",type:"Participant",isMany:!0,isReference:!0},{name:"initiatingParticipantRef",type:"Participant",isAttr:!0,isReference:!0},{name:"correlationKeys",type:"CorrelationKey",isMany:!0},{name:"loopType",type:"ChoreographyLoopType",default:"None",isAttr:!0}]},{name:"CallChoreography",superClass:["ChoreographyActivity"],properties:[{name:"calledChoreographyRef",type:"Choreography",isAttr:!0,isReference:!0},{name:"participantAssociations",type:"ParticipantAssociation",isMany:!0}]},{name:"SubChoreography",superClass:["ChoreographyActivity","FlowElementsContainer"],properties:[{name:"artifacts",type:"Artifact",isMany:!0}]},{name:"ChoreographyTask",superClass:["ChoreographyActivity"],properties:[{name:"messageFlowRef",type:"MessageFlow",isMany:!0,isReference:!0}]},{name:"Choreography",superClass:["Collaboration","FlowElementsContainer"]},{name:"GlobalChoreographyTask",superClass:["Choreography"],properties:[{name:"initiatingParticipantRef",type:"Participant",isAttr:!0,isReference:!0}]},{name:"TextAnnotation",superClass:["Artifact"],properties:[{name:"text",type:"String"},{name:"textFormat",default:"text/plain",isAttr:!0,type:"String"}]},{name:"Group",superClass:["Artifact"],properties:[{name:"categoryValueRef",type:"CategoryValue",isAttr:!0,isReference:!0}]},{name:"Association",superClass:["Artifact"],properties:[{name:"associationDirection",type:"AssociationDirection",isAttr:!0},{name:"sourceRef",type:"BaseElement",isAttr:!0,isReference:!0},{name:"targetRef",type:"BaseElement",isAttr:!0,isReference:!0}]},{name:"Category",superClass:["RootElement"],properties:[{name:"categoryValue",type:"CategoryValue",isMany:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Artifact",isAbstract:!0,superClass:["BaseElement"]},{name:"CategoryValue",superClass:["BaseElement"],properties:[{name:"categorizedFlowElements",type:"FlowElement",isMany:!0,isVirtual:!0,isReference:!0},{name:"value",isAttr:!0,type:"String"}]},{name:"Activity",isAbstract:!0,superClass:["FlowNode"],properties:[{name:"isForCompensation",default:!1,isAttr:!0,type:"Boolean"},{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0},{name:"ioSpecification",type:"InputOutputSpecification",xml:{serialize:"property"}},{name:"boundaryEventRefs",type:"BoundaryEvent",isMany:!0,isReference:!0},{name:"properties",type:"Property",isMany:!0},{name:"dataInputAssociations",type:"DataInputAssociation",isMany:!0},{name:"dataOutputAssociations",type:"DataOutputAssociation",isMany:!0},{name:"startQuantity",default:1,isAttr:!0,type:"Integer"},{name:"resources",type:"ResourceRole",isMany:!0},{name:"completionQuantity",default:1,isAttr:!0,type:"Integer"},{name:"loopCharacteristics",type:"LoopCharacteristics"}]},{name:"ServiceTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0}]},{name:"SubProcess",superClass:["Activity","FlowElementsContainer","InteractionNode"],properties:[{name:"triggeredByEvent",default:!1,isAttr:!0,type:"Boolean"},{name:"artifacts",type:"Artifact",isMany:!0}]},{name:"LoopCharacteristics",isAbstract:!0,superClass:["BaseElement"]},{name:"MultiInstanceLoopCharacteristics",superClass:["LoopCharacteristics"],properties:[{name:"isSequential",default:!1,isAttr:!0,type:"Boolean"},{name:"behavior",type:"MultiInstanceBehavior",default:"All",isAttr:!0},{name:"loopCardinality",type:"Expression",xml:{serialize:"xsi:type"}},{name:"loopDataInputRef",type:"ItemAwareElement",isReference:!0},{name:"loopDataOutputRef",type:"ItemAwareElement",isReference:!0},{name:"inputDataItem",type:"DataInput",xml:{serialize:"property"}},{name:"outputDataItem",type:"DataOutput",xml:{serialize:"property"}},{name:"complexBehaviorDefinition",type:"ComplexBehaviorDefinition",isMany:!0},{name:"completionCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"oneBehaviorEventRef",type:"EventDefinition",isAttr:!0,isReference:!0},{name:"noneBehaviorEventRef",type:"EventDefinition",isAttr:!0,isReference:!0}]},{name:"StandardLoopCharacteristics",superClass:["LoopCharacteristics"],properties:[{name:"testBefore",default:!1,isAttr:!0,type:"Boolean"},{name:"loopCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"loopMaximum",type:"Integer",isAttr:!0}]},{name:"CallActivity",superClass:["Activity","InteractionNode"],properties:[{name:"calledElement",type:"String",isAttr:!0}]},{name:"Task",superClass:["Activity","InteractionNode"]},{name:"SendTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"ReceiveTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"instantiate",default:!1,isAttr:!0,type:"Boolean"},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"ScriptTask",superClass:["Task"],properties:[{name:"scriptFormat",isAttr:!0,type:"String"},{name:"script",type:"String"}]},{name:"BusinessRuleTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"}]},{name:"AdHocSubProcess",superClass:["SubProcess"],properties:[{name:"completionCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"ordering",type:"AdHocOrdering",isAttr:!0},{name:"cancelRemainingInstances",default:!0,isAttr:!0,type:"Boolean"}]},{name:"Transaction",superClass:["SubProcess"],properties:[{name:"protocol",isAttr:!0,type:"String"},{name:"method",isAttr:!0,type:"String"}]},{name:"GlobalScriptTask",superClass:["GlobalTask"],properties:[{name:"scriptLanguage",isAttr:!0,type:"String"},{name:"script",isAttr:!0,type:"String"}]},{name:"GlobalBusinessRuleTask",superClass:["GlobalTask"],properties:[{name:"implementation",isAttr:!0,type:"String"}]},{name:"ComplexBehaviorDefinition",superClass:["BaseElement"],properties:[{name:"condition",type:"FormalExpression"},{name:"event",type:"ImplicitThrowEvent"}]},{name:"ResourceRole",superClass:["BaseElement"],properties:[{name:"resourceRef",type:"Resource",isReference:!0},{name:"resourceParameterBindings",type:"ResourceParameterBinding",isMany:!0},{name:"resourceAssignmentExpression",type:"ResourceAssignmentExpression"},{name:"name",isAttr:!0,type:"String"}]},{name:"ResourceParameterBinding",properties:[{name:"expression",type:"Expression",xml:{serialize:"xsi:type"}},{name:"parameterRef",type:"ResourceParameter",isAttr:!0,isReference:!0}],superClass:["BaseElement"]},{name:"ResourceAssignmentExpression",properties:[{name:"expression",type:"Expression",xml:{serialize:"xsi:type"}}],superClass:["BaseElement"]},{name:"Import",properties:[{name:"importType",isAttr:!0,type:"String"},{name:"location",isAttr:!0,type:"String"},{name:"namespace",isAttr:!0,type:"String"}]},{name:"Definitions",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"targetNamespace",isAttr:!0,type:"String"},{name:"expressionLanguage",default:"http://www.w3.org/1999/XPath",isAttr:!0,type:"String"},{name:"typeLanguage",default:"http://www.w3.org/2001/XMLSchema",isAttr:!0,type:"String"},{name:"imports",type:"Import",isMany:!0},{name:"extensions",type:"Extension",isMany:!0},{name:"rootElements",type:"RootElement",isMany:!0},{name:"diagrams",isMany:!0,type:"bpmndi:BPMNDiagram"},{name:"exporter",isAttr:!0,type:"String"},{name:"relationships",type:"Relationship",isMany:!0},{name:"exporterVersion",isAttr:!0,type:"String"}]}],uS=[{name:"ProcessType",literalValues:[{name:"None"},{name:"Public"},{name:"Private"}]},{name:"GatewayDirection",literalValues:[{name:"Unspecified"},{name:"Converging"},{name:"Diverging"},{name:"Mixed"}]},{name:"EventBasedGatewayType",literalValues:[{name:"Parallel"},{name:"Exclusive"}]},{name:"RelationshipDirection",literalValues:[{name:"None"},{name:"Forward"},{name:"Backward"},{name:"Both"}]},{name:"ItemKind",literalValues:[{name:"Physical"},{name:"Information"}]},{name:"ChoreographyLoopType",literalValues:[{name:"None"},{name:"Standard"},{name:"MultiInstanceSequential"},{name:"MultiInstanceParallel"}]},{name:"AssociationDirection",literalValues:[{name:"None"},{name:"One"},{name:"Both"}]},{name:"MultiInstanceBehavior",literalValues:[{name:"None"},{name:"One"},{name:"All"},{name:"Complex"}]},{name:"AdHocOrdering",literalValues:[{name:"Parallel"},{name:"Sequential"}]}],pS={tagAlias:"lowerCase",typePrefix:"t"},fS={name:oS,uri:aS,prefix:sS,associations:cS,types:lS,enumerations:uS,xml:pS},dS="BPMNDI",hS="http://www.omg.org/spec/BPMN/20100524/DI",mS="bpmndi",gS=[{name:"BPMNDiagram",properties:[{name:"plane",type:"BPMNPlane",redefines:"di:Diagram#rootElement"},{name:"labelStyle",type:"BPMNLabelStyle",isMany:!0}],superClass:["di:Diagram"]},{name:"BPMNPlane",properties:[{name:"bpmnElement",isAttr:!0,isReference:!0,type:"bpmn:BaseElement",redefines:"di:DiagramElement#modelElement"}],superClass:["di:Plane"]},{name:"BPMNShape",properties:[{name:"bpmnElement",isAttr:!0,isReference:!0,type:"bpmn:BaseElement",redefines:"di:DiagramElement#modelElement"},{name:"isHorizontal",isAttr:!0,type:"Boolean"},{name:"isExpanded",isAttr:!0,type:"Boolean"},{name:"isMarkerVisible",isAttr:!0,type:"Boolean"},{name:"label",type:"BPMNLabel"},{name:"isMessageVisible",isAttr:!0,type:"Boolean"},{name:"participantBandKind",type:"ParticipantBandKind",isAttr:!0},{name:"choreographyActivityShape",type:"BPMNShape",isAttr:!0,isReference:!0}],superClass:["di:LabeledShape"]},{name:"BPMNEdge",properties:[{name:"label",type:"BPMNLabel"},{name:"bpmnElement",isAttr:!0,isReference:!0,type:"bpmn:BaseElement",redefines:"di:DiagramElement#modelElement"},{name:"sourceElement",isAttr:!0,isReference:!0,type:"di:DiagramElement",redefines:"di:Edge#source"},{name:"targetElement",isAttr:!0,isReference:!0,type:"di:DiagramElement",redefines:"di:Edge#target"},{name:"messageVisibleKind",type:"MessageVisibleKind",isAttr:!0,default:"initiating"}],superClass:["di:LabeledEdge"]},{name:"BPMNLabel",properties:[{name:"labelStyle",type:"BPMNLabelStyle",isAttr:!0,isReference:!0,redefines:"di:DiagramElement#style"}],superClass:["di:Label"]},{name:"BPMNLabelStyle",properties:[{name:"font",type:"dc:Font"}],superClass:["di:Style"]}],yS=[{name:"ParticipantBandKind",literalValues:[{name:"top_initiating"},{name:"middle_initiating"},{name:"bottom_initiating"},{name:"top_non_initiating"},{name:"middle_non_initiating"},{name:"bottom_non_initiating"}]},{name:"MessageVisibleKind",literalValues:[{name:"initiating"},{name:"non_initiating"}]}],vS=[],bS={name:dS,uri:hS,prefix:mS,types:gS,enumerations:yS,associations:vS},xS="DC",_S="http://www.omg.org/spec/DD/20100524/DC",wS="dc",ES=[{name:"Boolean"},{name:"Integer"},{name:"Real"},{name:"String"},{name:"Font",properties:[{name:"name",type:"String",isAttr:!0},{name:"size",type:"Real",isAttr:!0},{name:"isBold",type:"Boolean",isAttr:!0},{name:"isItalic",type:"Boolean",isAttr:!0},{name:"isUnderline",type:"Boolean",isAttr:!0},{name:"isStrikeThrough",type:"Boolean",isAttr:!0}]},{name:"Point",properties:[{name:"x",type:"Real",default:"0",isAttr:!0},{name:"y",type:"Real",default:"0",isAttr:!0}]},{name:"Bounds",properties:[{name:"x",type:"Real",default:"0",isAttr:!0},{name:"y",type:"Real",default:"0",isAttr:!0},{name:"width",type:"Real",isAttr:!0},{name:"height",type:"Real",isAttr:!0}]}],SS=[],RS={name:xS,uri:_S,prefix:wS,types:ES,associations:SS},CS="DI",MS="http://www.omg.org/spec/DD/20100524/DI",AS="di",PS=[{name:"DiagramElement",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"extension",type:"Extension"},{name:"owningDiagram",type:"Diagram",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"owningElement",type:"DiagramElement",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"modelElement",isReadOnly:!0,isVirtual:!0,isReference:!0,type:"Element"},{name:"style",type:"Style",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"ownedElement",type:"DiagramElement",isReadOnly:!0,isMany:!0,isVirtual:!0}]},{name:"Node",isAbstract:!0,superClass:["DiagramElement"]},{name:"Edge",isAbstract:!0,superClass:["DiagramElement"],properties:[{name:"source",type:"DiagramElement",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"target",type:"DiagramElement",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"waypoint",isUnique:!1,isMany:!0,type:"dc:Point",xml:{serialize:"xsi:type"}}]},{name:"Diagram",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"rootElement",type:"DiagramElement",isReadOnly:!0,isVirtual:!0},{name:"name",isAttr:!0,type:"String"},{name:"documentation",isAttr:!0,type:"String"},{name:"resolution",isAttr:!0,type:"Real"},{name:"ownedStyle",type:"Style",isReadOnly:!0,isMany:!0,isVirtual:!0}]},{name:"Shape",isAbstract:!0,superClass:["Node"],properties:[{name:"bounds",type:"dc:Bounds"}]},{name:"Plane",isAbstract:!0,superClass:["Node"],properties:[{name:"planeElement",type:"DiagramElement",subsettedProperty:"DiagramElement-ownedElement",isMany:!0}]},{name:"LabeledEdge",isAbstract:!0,superClass:["Edge"],properties:[{name:"ownedLabel",type:"Label",isReadOnly:!0,subsettedProperty:"DiagramElement-ownedElement",isMany:!0,isVirtual:!0}]},{name:"LabeledShape",isAbstract:!0,superClass:["Shape"],properties:[{name:"ownedLabel",type:"Label",isReadOnly:!0,subsettedProperty:"DiagramElement-ownedElement",isMany:!0,isVirtual:!0}]},{name:"Label",isAbstract:!0,superClass:["Node"],properties:[{name:"bounds",type:"dc:Bounds"}]},{name:"Style",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"}]},{name:"Extension",properties:[{name:"values",isMany:!0,type:"Element"}]}],TS=[],kS={tagAlias:"lowerCase"},OS={name:CS,uri:MS,prefix:AS,types:PS,associations:TS,xml:kS},DS="bpmn.io colors for BPMN",LS="http://bpmn.io/schema/bpmn/biocolor/1.0",IS="bioc",BS=[{name:"ColoredShape",extends:["bpmndi:BPMNShape"],properties:[{name:"stroke",isAttr:!0,type:"String"},{name:"fill",isAttr:!0,type:"String"}]},{name:"ColoredEdge",extends:["bpmndi:BPMNEdge"],properties:[{name:"stroke",isAttr:!0,type:"String"},{name:"fill",isAttr:!0,type:"String"}]}],NS=[],$S=[],FS={name:DS,uri:LS,prefix:IS,types:BS,enumerations:NS,associations:$S},jS="BPMN in Color",HS="http://www.omg.org/spec/BPMN/non-normative/color/1.0",zS="color",GS=[{name:"ColoredLabel",extends:["bpmndi:BPMNLabel"],properties:[{name:"color",isAttr:!0,type:"String"}]},{name:"ColoredShape",extends:["bpmndi:BPMNShape"],properties:[{name:"background-color",isAttr:!0,type:"String"},{name:"border-color",isAttr:!0,type:"String"}]},{name:"ColoredEdge",extends:["bpmndi:BPMNEdge"],properties:[{name:"border-color",isAttr:!0,type:"String"}]}],VS=[],WS=[],US={name:jS,uri:HS,prefix:zS,types:GS,enumerations:VS,associations:WS};const qS={bpmn:fS,bpmndi:bS,dc:RS,di:OS,bioc:FS,color:US};function wm(e,t){const n=U({},qS,e);return new uc(n,t)}const YS={name:"bpmn-i18n",uri:"http://www.omg.org/spec/BPMN/non-normative/extensions/i18n/1.0",prefix:"i18n",types:[{name:"Translation",superClass:["Element"],properties:[{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"body",isBody:!0,type:"String"},{name:"target",isAttr:!0,type:"String",default:"@name"},{name:"textFormat",isAttr:"true",type:"String",default:"text/plain"}]}],enumerations:[],associations:[],xml:{tagAlias:"lowerCase",typePrefix:"t"}},pc={[nm]:YS,[qu]:Zh};function Em(){return wm(pc)}const Sm=Em();async function zo(e){const{rootElement:t,warnings:n}=await Sm.fromXML(e,"bpmn:Definitions");return{definitions:t,warnings:n}}async function KS(e){const{xml:t}=await Sm.toXML(e,{format:!0});return t}function bp(e){return e.map(t=>typeof t=="string"?t:t.message??String(t))}const Go={cjkEm:.865,upperEm:.68,lowerEm:.5,digitEm:.556,spaceEm:.278,otherEm:.35,ascentEm:.9,descentEm:.25},XS=/[ᄀ-ᇿ -〿぀-ヿ㐀-鿿가-힯＀-⦆]/;function ZS(e){const t=Go;return XS.test(e)?t.cjkEm:e===" "?t.spaceEm:e>="0"&&e<="9"?t.digitEm:e>="A"&&e<="Z"?t.upperEm:e>="a"&&e<="z"?t.lowerEm:t.otherEm}function Vo(e,t){let n=0;for(const i of e)n+=t*ZS(i);return n}function Rm(e=globalThis,{textMeasurement:t="approximate"}={}){if(!(e!=null&&e.SVGElement))throw new Error("installHeadlessBpmnDom: DOM 전역이 없다 — jsdom window 를 전역에 올린 뒤 호출할 것");t==="approximate"&&QS(e),JS(e),eR(e),tR(e)}function QS(e){var i;const t=(i=e.HTMLCanvasElement)==null?void 0:i.prototype;if(!t||t.__headlessTextMeasurement)return;t.__headlessTextMeasurement=!0;const n={font:"12px sans-serif",letterSpacing:"0px",measureText(r){var a;const o=Number.parseFloat(((a=String(n.font).match(/(\d+(?:\.\d+)?)px/))==null?void 0:a[1])??"12");return{width:Vo(r,o),fontBoundingBoxAscent:o*Go.ascentEm,fontBoundingBoxDescent:o*Go.descentEm,actualBoundingBoxAscent:o*Go.ascentEm,actualBoundingBoxDescent:o*Go.descentEm}}};t.getContext=()=>n}function JS(e){if(e.SVGMatrix)return;class t{constructor(){fi(this,"a",1);fi(this,"b",0);fi(this,"c",0);fi(this,"d",1);fi(this,"e",0);fi(this,"f",0)}static of(i,r,o,a,s,c){return Object.assign(new t,{a:i,b:r,c:o,d:a,e:s,f:c})}multiply(i){return t.of(this.a*i.a+this.c*i.b,this.b*i.a+this.d*i.b,this.a*i.c+this.c*i.d,this.b*i.c+this.d*i.d,this.a*i.e+this.c*i.f+this.e,this.b*i.e+this.d*i.f+this.f)}translate(i,r){return this.multiply(t.of(1,0,0,1,i,r))}scale(i,r=i){return this.multiply(t.of(i,0,0,r,0,0))}inverse(){const i=this.a*this.d-this.b*this.c;return t.of(this.d/i,-this.b/i,-this.c/i,this.a/i,(this.c*this.f-this.d*this.e)/i,(this.b*this.e-this.a*this.f)/i)}}e.SVGMatrix=t}function eR(e){var o;const t=()=>{const a=new e.SVGMatrix;return{type:0,matrix:a,setTranslate(s,c){a.e=s,a.f=c},setScale(s,c){a.a=s,a.d=c},setRotate(s,c=0,l=0){const u=s*Math.PI/180,p=Math.cos(u),f=Math.sin(u);a.a=p,a.b=f,a.c=-f,a.d=p,a.e=c-p*c+f*l,a.f=l-f*c-p*l},setMatrix(s){Object.assign(a,s)}}},n=a=>{const s=t();return Object.assign(s.matrix,a),s},i=(o=e.SVGSVGElement)==null?void 0:o.prototype;i&&!i.createSVGTransform&&(i.createSVGTransform=t,i.createSVGTransformFromMatrix=n,i.createSVGMatrix=()=>new e.SVGMatrix,i.createSVGPoint=()=>({x:0,y:0,matrixTransform:()=>({x:0,y:0})}));const r=e.SVGElement.prototype;Object.getOwnPropertyDescriptor(r,"transform")||Object.defineProperty(r,"transform",{configurable:!0,get(){if(!this.__headlessTransformList){const a=[];this.__headlessTransformList={baseVal:{get numberOfItems(){return a.length},clear:()=>{a.length=0},appendItem:s=>(a.push(s),s),getItem:s=>a[s],createSVGTransformFromMatrix:n,consolidate:()=>a[a.length-1]??null}}}return this.__headlessTransformList}})}function tR(e){const t=e.SVGElement.prototype;if(!t.getCTM){const n=()=>new e.SVGMatrix;t.getCTM=n,t.getScreenCTM=n}t.getBBox||(t.getBBox=function(){const n=String(this.textContent??"");return{x:0,y:0,width:Vo(n,12),height:14}})}const fc=new Set(["bpmn:Participant","bpmn:Lane","bpmn:Group","bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),nR=new Set(["bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),iR=1,dc=new Set(["bpmn:TextAnnotation","bpmn:DataStoreReference","bpmn:DataObjectReference","bpmn:DataInput","bpmn:DataOutput"]),rR=2;function lt(e){switch(e.kind){case"label-over-line":return`L|${e.edge}|${e.line}`;case"label-over-shape":return`ls|${e.edge}|${e.shape}`;case"edge-crosses-shape":return`x|${e.edge}|${e.shape}`;case"edge-endpoint-detached":return`d|${e.edge}|${e.shape}`;case"shape-overlap":return`o|${e.shapes[0]}|${e.shapes[1]}`;case"shape-outside-container":return`c|${e.shape}|${e.container}`;case"edge-overlap-opposite":return`p|${e.edges[0]}|${e.edges[1]}`;case"edge-overlap-mixed":return`m|${e.edges[0]}|${e.edges[1]}`;case"edge-overlap-unrelated":return`u|${e.edges[0]}|${e.edges[1]}`;case"label-on-shared-segment":return`l|${e.edge}|${e.other}`;case"annotation-over-label":return`a|${e.annotation}|${e.label}`;case"pool-overlap":return`P|${e.pools[0]}|${e.pools[1]}`;case"edge-crosses-subprocess":return`S|${e.edge}|${e.subProcess}`;case"group-overlap-unintended":return`g|${e.groups[0]}|${e.groups[1]}${e.container?`|⊃${e.container}`:""}`;case"group-overlap-unreadable":return e.reason==="minority"?`gu*|${e.group}|${e.shapes.join(",")}`:e.reason==="throughpass"?`gu>|${e.group}|${e.shapes.join(",")}`:`gu|${e.groups[0]}|${e.groups[1]}|${e.shapes.join(",")}`;case"group-stack-unreadable":return`gs|${e.groups.join("|")}|${e.shapes.join(",")}`;case"group-on-container-boundary":return`gb|${e.group}|${e.container}|${e.side}`;case"group-on-group-boundary":return`gg|${e.groups[0]}|${e.groups[1]}|${e.axis}`;case"group-cuts-shape":return`gc|${e.group}|${e.shape}|${e.side}`;case"edge-along-group-boundary":return`eg|${e.edge}|${e.group}`;case"pool-name-over-label":return`pn|${e.pool}|${e.label}`}}const Cm=20,hc=5,Mm=3,oR=8,Wo=15,xp=50,Am=12,aR=Am*1.2;function _p(e,t){const n=t.split(/\r?\n/),i=Math.max(...n.map(o=>Vo(o,Am))),r=n.length*aR;return{x:e.x+e.width/2-i/2,y:e.y+e.height/2-r/2,width:i,height:r}}const Pm=1;function gn(e){const t=[];for(let n=0;n+1<e.waypoints.length;n++){const i=e.waypoints[n],r=e.waypoints[n+1];Math.abs(i.y-r.y)<.5&&Math.abs(i.x-r.x)>=.5?t.push({axis:"h",at:i.y,lo:Math.min(i.x,r.x),hi:Math.max(i.x,r.x),dir:r.x>i.x?1:-1}):Math.abs(i.x-r.x)<.5&&Math.abs(i.y-r.y)>=.5&&t.push({axis:"v",at:i.x,lo:Math.min(i.y,r.y),hi:Math.max(i.y,r.y),dir:r.y>i.y?1:-1})}return t}function Uo(e,t){let n=null;const i=e.type!==t.type,o=!!(e.source&&e.target&&t.source&&t.target)&&e.source!==t.source&&e.source!==t.target&&e.target!==t.source&&e.target!==t.target;for(const a of gn(e))for(const s of gn(t)){if(a.axis!==s.axis||Math.abs(a.at-s.at)>Pm)continue;const c=a.dir!==s.dir?"opposite":i?"mixed":o?"unrelated":null;if(!c)continue;const l=Math.min(a.hi,s.hi)-Math.max(a.lo,s.lo);l>=Cm&&(!n||l>n.length)&&(n={axis:a.axis,length:l,kind:c})}return n}function wp(e){return e.kind==="edge-overlap-opposite"||e.kind==="edge-overlap-mixed"||e.kind==="edge-overlap-unrelated"}function Tm(e,t){const n=Uo(e,t);return n&&n.kind==="opposite"?{axis:n.axis,length:n.length}:null}function sR(e,t){let n=0;for(const i of t)i.id!==e.id&&Tm(e,i)&&n++;return n}function ai(e,t){let n=0;for(const i of t)i.id!==e.id&&Uo(e,i)&&n++;return n}const km=15,Om=20;function cR(e,t){const n=t.axis==="v"?[e.x,e.x+e.width]:[e.y,e.y+e.height];if(t.at<n[0]-Om||t.at>n[1]+Om)return null;const i=t.axis==="v"?[e.y,e.y+e.height]:[e.x,e.x+e.width],r=Math.max(i[0],t.lo),o=Math.min(i[1],t.hi);return o>r?[r,o]:null}const Ep=20;function mc(e,t){const n=[];for(const i of t){if(i.axis!==e.axis||Math.abs(i.at-e.at)>Pm)continue;const r=Math.max(e.lo,i.lo),o=Math.min(e.hi,i.hi);o-r<Cm||n.push([r-Ep,o+Ep])}return n}function gc(e,t){const n=e.label;if(!n)return null;let i=null;for(const r of gn(e)){const o=cR(n,r);if(o){for(const a of t)if(a.id!==e.id&&!(i&&a.id>=i.other)){for(const[s,c]of mc(r,gn(a)))if(Math.min(c,o[1])>Math.max(s,o[0])){i={other:a.id,axis:r.axis};break}}}}return i}const lR=10,uR=1,pR=(e,t,n)=>t.x>=e.x-n&&t.y>=e.y-n&&t.x+t.width<=e.x+e.width+n&&t.y+t.height<=e.y+e.height+n;function fR(e,t,n,i){const r=n.x+i,o=n.y+i,a=n.x+n.width-i,s=n.y+n.height-i;if(a<=r||s<=o)return!1;const c=t.x-e.x,l=t.y-e.y;let u=0,p=1;const f=(d,g)=>{if(g===0)return d<=0;const h=d/g;if(g>0){if(h>p)return!1;h>u&&(u=h)}else{if(h<u)return!1;h<p&&(p=h)}return!0};return f(r-e.x,c)&&f(e.x-a,-c)&&f(o-e.y,l)&&f(e.y-s,-l)&&p>u}function Sp(e,t,n){return e.x+n<t.x+t.width-n&&t.x+n<e.x+e.width-n&&e.y+n<t.y+t.height-n&&t.y+n<e.y+e.height-n}const dR=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,qo=1;function Fi(e,t){const n=e.x+qo,i=e.x+e.width-qo,r=e.y+qo,o=e.y+e.height-qo;return t.axis==="h"?t.at>r&&t.at<o&&t.lo<i&&t.hi>n:t.at>n&&t.at<i&&t.lo<o&&t.hi>r}function Yo(e){return[{axis:"h",at:e.y,lo:e.x,hi:e.x+e.width,dir:1},{axis:"h",at:e.y+e.height,lo:e.x,hi:e.x+e.width,dir:1},{axis:"v",at:e.x,lo:e.y,hi:e.y+e.height,dir:1},{axis:"v",at:e.x+e.width,lo:e.y,hi:e.y+e.height,dir:1}]}function Dm(e,t){const n=e.label;if(!n)return null;if(gn(e).some(i=>Fi(n,i)))return e.id;for(const i of[...t.edges].filter(r=>r.id!==e.id).sort((r,o)=>r.id.localeCompare(o.id)))if(gn(i).some(r=>Fi(n,r)))return i.id;for(const i of t.shapes.filter(r=>r.container).sort((r,o)=>r.id.localeCompare(o.id)))if(Yo(i).some(r=>Fi(n,r)))return i.id;return null}function xn(e,t){const n=new Set(e.endpoints),i=[];for(const r of t)if(!n.has(r.id)){for(let o=0;o+1<e.waypoints.length;o++)if(fR(e.waypoints[o],e.waypoints[o+1],r,rR)){i.push(r);break}}return i}const ja=(e,t,n)=>{const i=n.x-t.x,r=n.y-t.y,o=i*i+r*r,a=o===0?0:Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*r)/o));return Math.hypot(e.x-(t.x+a*i),e.y-(t.y+a*r))},hR=(e,t,n,i)=>Im(e,t,n,i)?0:Math.min(ja(e,n,i),ja(t,n,i),ja(n,e,t),ja(i,e,t)),Lm=(e,t)=>{let n=!1;for(let i=0,r=t.length-1;i<t.length;r=i++){const o=t[i],a=t[r];o.y>e.y!=a.y>e.y&&e.x<(a.x-o.x)*(e.y-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n};function yc(e,t,n){const{x:i,y:r,width:o,height:a}=n;if(/Event$/.test(n.type)){const l=Math.min(o,a)/2;return Math.max(0,ja({x:i+o/2,y:r+a/2},e,t)-l)}const s=/Gateway$/.test(n.type)?[{x:i+o/2,y:r},{x:i+o,y:r+a/2},{x:i+o/2,y:r+a},{x:i,y:r+a/2}]:[{x:i,y:r},{x:i+o,y:r},{x:i+o,y:r+a},{x:i,y:r+a}];if(Lm(e,s)||Lm(t,s))return 0;let c=1/0;for(let l=0;l<s.length;l++)c=Math.min(c,hR(e,t,s[l],s[(l+1)%s.length]));return c}function Im(e,t,n,i){const r=(l,u,p)=>(u.x-l.x)*(p.y-l.y)-(u.y-l.y)*(p.x-l.x),o=r(n,i,e),a=r(n,i,t),s=r(e,t,n),c=r(e,t,i);return o*a<0&&s*c<0}const Bm=(e,t)=>e.endpoints.some(n=>t.endpoints.includes(n));function Ha(e,t){let n=0;for(const i of t){if(i.id===e.id||Bm(e,i))continue;let r=!1;for(let o=0;o+1<e.waypoints.length&&!r;o++)for(let a=0;a+1<i.waypoints.length&&!r;a++)Im(e.waypoints[o],e.waypoints[o+1],i.waypoints[a],i.waypoints[a+1])&&(r=!0);r&&n++}return n}function si(e,t){let n=0;for(const i of t)i.id===e.id||Bm(e,i)||Ha(e,[i])>0&&(n+=i.type===e.type?2:1);return n}function Nm(e){let t=0;const n=e.edges;for(let i=0;i<n.length;i++)for(let r=i+1;r<n.length;r++)Ha(n[i],[n[r]])>0&&(t+=n[i].type===n[r].type?2:1);return t}function vc(e){const t=[],n=e.edges;for(let i=0;i<n.length;i++)for(let r=i+1;r<n.length;r++)if(Ha(n[i],[n[r]])>0){const o=n[i].id,a=n[r].id;t.push(o<a?[o,a]:[a,o])}return t.sort((i,r)=>`${i[0]}|${i[1]}`.localeCompare(`${r[0]}|${r[1]}`))}function $m(e){const t=vc(e),n=a=>a==="bpmn:MessageFlow"||a.endsWith("Association")?"dashed":"solid",i=new Map(e.edges.map(a=>[a.id,a]));let r=0,o=0;for(const[a,s]of t){const c=i.get(a),l=i.get(s);if(!c||!l)continue;const u=n(c.type),p=n(l.type);u==="solid"&&p==="solid"?r++:u==="dashed"&&p==="dashed"&&o++}return{pairs:t,solidPairs:r,dashedPairs:o,mixedPairs:t.length-r-o,crossPoolMessages:mR(e)}}function mR(e){const t=e.shapes.filter(r=>r.type==="bpmn:Participant");if(t.length<3)return 0;const n=r=>{const o=e.shapes.find(a=>a.id===r);if(o)return t.find(a=>o.x>=a.x&&o.y>=a.y&&o.x+o.width<=a.x+a.width&&o.y+o.height<=a.y+a.height)};let i=0;for(const r of e.edges){if(r.type!=="bpmn:MessageFlow"||r.endpoints.length<2)continue;const o=n(r.endpoints[0]),a=n(r.endpoints[1]);if(!o||!a||o.id===a.id)continue;const s=Math.min(o.y,a.y),c=Math.max(o.y+o.height,a.y+a.height);t.some(l=>l.id!==o.id&&l.id!==a.id&&l.y>s&&l.y+l.height<c)&&i++}return i}function Fm(e,t,n){const i=new Set(t.flatMap(r=>[...r.members]));return e.shapes.filter(r=>!r.container&&!dc.has(r.type)&&!i.has(r.id)&&r.x>=n.x&&r.y>=n.y&&r.x+r.width<=n.right&&r.y+r.height<=n.bottom).map(r=>r.id).sort()}function jm(e){var n;const t=(n=Lt(e==null?void 0:e.extensionElements))==null?void 0:n.values;if(Array.isArray(t))for(const i of t){const r=Lt(i);if((r==null?void 0:r.$type)!=="bwl:Members"||typeof r.refs!="string")continue;const o=r.refs.split(/\s+/).filter(Boolean);return o.length?o:void 0}}const Hm=e=>e?{members:e}:{},ci=e=>e.shapes.filter(t=>!t.container);function gR(e,t,n){if(e.type==="bpmn:TextAnnotation")for(const i of t.edges){if(!/Association$/.test(i.type)||!i.endpoints.includes(e.id))continue;const r=i.endpoints.find(a=>a!==e.id),o=r?n.get(r):void 0;if(o&&o.type!=="bpmn:Group"){if(o.container)return o.id;if(o.parent)return o.parent}}}function yR(e,t,n){if(e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height)return!0;const r=e.x+e.width/2,o=e.y+e.height/2;return n.shapes.some(a=>a.container&&a.id!==t.id&&a.id!==e.id&&a.type!=="bpmn:Group"&&r>=a.x&&r<=a.x+a.width&&o>=a.y&&o<=a.y+a.height)}function zm(e,t){const n=e.label;if(!n)return null;for(const i of[...t.edges].sort((r,o)=>r.id.localeCompare(o.id)))if(gn(i).some(r=>Fi(n,r)))return i.id;for(const i of[...t.shapes].filter(r=>r.container).sort((r,o)=>r.id.localeCompare(o.id)))if(Yo(i).some(r=>Fi(n,r)))return i.id;return null}function co(e){const t=[];for(const n of e.shapes)n.label&&t.push({owner:n.id,rect:n.label});for(const n of e.edges)n.label&&t.push({owner:n.id,rect:n.label});return t}const Gm=3;function Vm(e,t){const n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),i=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);if(n<=0||i<=0)return 0;const r=/Event$/.test(t.type);if(!r&&!/Gateway$/.test(t.type))return Math.min(n,i);const o=t.x+t.width/2,a=t.y+t.height/2,s=Math.min(Math.max(o,e.x),e.x+e.width),c=Math.min(Math.max(a,e.y),e.y+e.height);if(r)return Math.max(0,t.width/2-Math.hypot(s-o,c-a));const l=t.width/2,u=t.height/2;return Math.max(0,(1-(Math.abs(s-o)/l+Math.abs(c-a)/u))*Math.min(l,u))}function za(e,t){const n=[];for(const i of t.shapes){if(i.container||dc.has(i.type))continue;const r=Vm(e,i);r>=Gm&&n.push({shape:i.id,depth:r})}return n.sort((i,r)=>i.shape.localeCompare(r.shape))}function dt(e,t={}){const n=[],i=e.shapes.filter(m=>!m.container);for(const m of e.edges)for(const v of xn(m,i))n.push({kind:"edge-crosses-shape",edge:m.id,shape:v.id});const r=e.shapes.filter(m=>m.container&&nR.has(m.type));if(r.length){const m=(v,_)=>{const E=e.shapes.find(T=>T.id===_);return!!E&&E.x>=v.x&&E.y>=v.y&&E.x+E.width<=v.x+v.width&&E.y+E.height<=v.y+v.height};for(const v of e.edges)for(const _ of xn(v,r))v.endpoints.includes(_.id)||v.endpoints.some(E=>m(_,E))||n.push({kind:"edge-crosses-subprocess",edge:v.id,subProcess:_.id})}for(const m of e.edges){if(m.waypoints.length<2)continue;const v=[[m.source,m.waypoints[0]],[m.target,m.waypoints[m.waypoints.length-1]]];for(const[_,E]of v){if(!_)continue;const T=e.shapes.find(D=>D.id===_);if(!T||T.container)continue;const O=Math.max(T.x-E.x,E.x-(T.x+T.width),0),N=Math.max(T.y-E.y,E.y-(T.y+T.height),0),P=Math.hypot(O,N);P>lR&&n.push({kind:"edge-endpoint-detached",edge:m.id,shape:_,distance:Math.round(P)})}}const o=e.shapes.filter(m=>m.type==="bpmn:Participant");for(let m=0;m<o.length;m++)for(let v=m+1;v<o.length;v++){const _=o[m],E=o[v];if(_.x+_.width<=E.x||E.x+E.width<=_.x||_.y+_.height<=E.y||E.y+E.height<=_.y)continue;const T=(O,N)=>O.x<=N.x&&O.y<=N.y&&O.x+O.width>=N.x+N.width&&O.y+O.height>=N.y+N.height;n.push({kind:"pool-overlap",pools:[_.id,E.id],contained:T(_,E)||T(E,_)})}const a=i.filter(m=>!m.attached);for(let m=0;m<a.length;m++)for(let v=m+1;v<a.length;v++){const _=a[m],E=a[v];if(!Sp(_,E,iR))continue;const T=_.id<E.id?[_.id,E.id]:[E.id,_.id];n.push({kind:"shape-overlap",shapes:T,identical:dR(_,E)})}const s=e.shapes.filter(m=>m.type==="bpmn:Group"&&Array.isArray(m.members)&&m.members.length>0);for(let m=0;m<s.length;m++)for(let v=m+1;v<s.length;v++){const _=s[m],E=s[v],T=Math.min(_.x+_.width,E.x+E.width)-Math.max(_.x,E.x),O=Math.min(_.y+_.height,E.y+E.height)-Math.max(_.y,E.y);if(T<=hc||O<=hc)continue;const N=_.id<E.id?[_.id,E.id]:[E.id,_.id],P=new Set(E.members);if(_.members.some(F=>P.has(F))){const F=Fm(e,s,{x:Math.max(_.x,E.x),y:Math.max(_.y,E.y),right:Math.min(_.x+_.width,E.x+E.width),bottom:Math.min(_.y+_.height,E.y+E.height)});F.length&&n.push({kind:"group-overlap-unreadable",reason:"orphan",groups:N,shapes:F});continue}const D=_.x<=E.x&&_.y<=E.y&&_.x+_.width>=E.x+E.width&&_.y+_.height>=E.y+E.height?_.id:E.x<=_.x&&E.y<=_.y&&E.x+E.width>=_.x+_.width&&E.y+E.height>=_.y+_.height?E.id:void 0;n.push({kind:"group-overlap-unintended",groups:N,...D?{container:D}:{}})}const c=new Set(s.flatMap(m=>[...m.members])),l=m=>e.shapes.filter(v=>!v.container&&!dc.has(v.type)&&v.x>=m.x&&v.y>=m.y&&v.x+v.width<=m.x+m.width&&v.y+v.height<=m.y+m.height);for(const m of s){const v=l(m);if(!v.length)continue;const _=new Set(m.members),E=v.filter(T=>!_.has(T.id));E.some(T=>c.has(T.id))&&(E.length*2<v.length||n.push({kind:"group-overlap-unreadable",reason:"minority",group:m.id,shapes:E.map(T=>T.id).sort()}))}for(const m of s){const v=new Set(l(m).map(P=>P.id)),_=new Set(m.members),E=new Set([...v].filter(P=>!_.has(P)&&c.has(P)));if(!E.size)continue;let T=!1,O=!1,N=!1;for(const P of e.edges){if(P.type!=="bpmn:SequenceFlow"||!P.source||!P.target)continue;const D=E.has(P.source),F=E.has(P.target);!D&&F&&!v.has(P.source)?T=!0:D&&!F&&!v.has(P.target)?O=!0:D&&F&&(N=!0)}T&&O&&N&&n.push({kind:"group-overlap-unreadable",reason:"throughpass",group:m.id,shapes:[...E].sort()})}const u=e.shapes.filter(m=>m.type==="bpmn:Group");for(let m=0;m<u.length;m++)for(let v=m+1;v<u.length;v++)for(let _=v+1;_<u.length;_++){const E=[u[m],u[v],u[_]],T={x:Math.max(...E.map(P=>P.x)),y:Math.max(...E.map(P=>P.y)),right:Math.min(...E.map(P=>P.x+P.width)),bottom:Math.min(...E.map(P=>P.y+P.height))};if(T.right-T.x<=hc||T.bottom-T.y<=hc)continue;const O=Fm(e,[],T);if(!O.length)continue;const N=E.map(P=>P.id).sort();n.push({kind:"group-stack-unreadable",groups:N,shapes:O})}for(const m of e.shapes.filter(v=>v.type==="bpmn:Group"))for(const v of e.shapes){if(v.container||v.attached||dc.has(v.type)||v.width<=0||v.height<=0)continue;const _=[["top",m.y,"h",m.x,m.x+m.width],["bottom",m.y+m.height,"h",m.x,m.x+m.width],["left",m.x,"v",m.y,m.y+m.height],["right",m.x+m.width,"v",m.y,m.y+m.height]];for(const[E,T,O,N,P]of _){const D=O==="h"?v.x:v.y,F=O==="h"?v.x+v.width:v.y+v.height;if(!(D<P&&N<F))continue;const J=O==="h"?v.y:v.x,ge=O==="h"?v.y+v.height:v.x+v.width;if(!(J<T&&T<ge))continue;const Ae=Math.min(T-J,ge-T);Ae<oR||n.push({kind:"group-cuts-shape",group:m.id,shape:v.id,side:E,depth:Ae})}}const p=t.includeObservationOnly?e.shapes.filter(m=>m.type==="bpmn:Group"&&m.width>0&&m.height>0):[];if(p.length){const m=new Map(e.shapes.filter(v=>!v.container).map(v=>[v.id,{x:v.x+v.width/2,y:v.y+v.height/2}]));for(const v of e.edges){if(v.type!=="bpmn:SequenceFlow"&&v.type!=="bpmn:MessageFlow")continue;const _=gn(v);if(_.length)for(const E of p){const T=E.x+E.width,O=E.y+E.height,N=v.endpoints.some(D=>{const F=m.get(D);return!!F&&E.x<F.x&&F.x<T&&E.y<F.y&&F.y<O});let P=null;for(const D of _){const[F,J,ge]=D.axis==="v"?[E.y,O,[["left",E.x],["right",T]]]:[E.x,T,[["top",E.y],["bottom",O]]],Ae=Math.min(D.hi,J)-Math.max(D.lo,F);if(Ae<xp)continue;const De=D.axis==="v"?E.x<D.at&&D.at<T:E.y<D.at&&D.at<O;if(!(De&&N))for(const[qe,rt]of ge){const Me=Math.abs(D.at-rt);Me<=Wo&&(!P||Me<P.distance)&&(P={side:qe,inside:De,distance:Me,length:Ae})}}P&&n.push({kind:"edge-along-group-boundary",edge:v.id,group:E.id,side:P.side,inside:P.inside,distance:Math.round(P.distance),length:Math.round(P.length)})}}}const f=e.shapes.filter(m=>m.container&&m.type!=="bpmn:Group"&&m.type!=="bpmn:Lane");for(const m of e.shapes.filter(v=>v.type==="bpmn:Group"))for(const v of f){const _=m.x<v.x+v.width&&v.x<m.x+m.width,E=m.y<v.y+v.height&&v.y<m.y+m.height,T=[["top",m.y,v.y,_],["bottom",m.y+m.height,v.y+v.height,_],["left",m.x,v.x,E],["right",m.x+m.width,v.x+v.width,E]];for(const[O,N,P,D]of T)D&&Math.abs(N-P)<=Mm&&n.push({kind:"group-on-container-boundary",group:m.id,container:v.id,side:O})}const d=e.shapes.filter(m=>m.type==="bpmn:Group");for(let m=0;m<d.length;m++)for(let v=m+1;v<d.length;v++){const _=d[m],E=d[v],T=_.x<E.x+E.width&&E.x<_.x+_.width,O=_.y<E.y+E.height&&E.y<_.y+_.height,N=[["x",_.x+_.width,E.x,O],["x",E.x+E.width,_.x,O],["y",_.y+_.height,E.y,T],["y",E.y+E.height,_.y,T]];for(const[P,D,F,J]of N)if(J&&Math.abs(D-F)<=Mm){n.push({kind:"group-on-group-boundary",groups:_.id<E.id?[_.id,E.id]:[E.id,_.id],axis:P});break}}for(let m=0;m<e.edges.length;m++)for(let v=m+1;v<e.edges.length;v++){const _=e.edges[m],E=e.edges[v],T=Uo(_,E);if(!T)continue;const O=_.id<E.id?[_.id,E.id]:[E.id,_.id];n.push({kind:T.kind==="opposite"?"edge-overlap-opposite":T.kind==="mixed"?"edge-overlap-mixed":"edge-overlap-unrelated",edges:O,axis:T.axis,length:Math.round(T.length)})}for(const m of e.edges){if(!m.label)continue;const v=gc(m,e.edges);v&&n.push({kind:"label-on-shared-segment",edge:m.id,other:v.other,axis:v.axis})}for(const m of e.edges){if(!m.label)continue;const v=Dm(m,e);v&&n.push({kind:"label-over-line",edge:m.id,line:v})}if(t.includeObservationOnly){for(const m of e.edges)if(!(!m.label||m.type!=="bpmn:SequenceFlow"))for(const{shape:v,depth:_}of za(m.label,e))n.push({kind:"label-over-shape",edge:m.id,shape:v,depth:Math.round(_)})}const g=new Set(i.map(m=>m.id)),h=e.shapes.filter(m=>m.type==="bpmn:Participant"&&m.label);for(const m of[...i,...h.filter(v=>!g.has(v.id))]){if(!m.label)continue;const v=zm(m,e);v&&n.push({kind:"label-over-line",edge:m.id,line:v})}const y=new Set(e.shapes.filter(m=>m.type==="bpmn:TextAnnotation").map(m=>m.id));for(const m of h)for(const{owner:v,rect:_}of co(e))v===m.id||y.has(v)||Sp(m.label,_,qo)&&n.push({kind:"pool-name-over-label",pool:m.id,label:v});const C=co(e);for(const m of i)if(m.type==="bpmn:TextAnnotation")for(const{owner:v,rect:_}of C)v!==m.id&&Sp(m,_,qo)&&n.push({kind:"annotation-over-label",annotation:m.id,label:v});const x=new Map(e.shapes.map(m=>[m.id,m]));for(const m of i){const v=m.parent??gR(m,e,x);if(!v)continue;const _=x.get(v);!_||!_.container||pR(_,m,uR)||m.type==="bpmn:TextAnnotation"&&!yR(m,_,e)||n.push({kind:"shape-outside-container",shape:m.id,container:_.id})}return n.sort((m,v)=>lt(m).localeCompare(lt(v)))}const Lt=e=>typeof e=="object"&&e!==null?e:void 0,Ut=e=>typeof e=="number"?e:0,tr=e=>{const t=Lt(e);return typeof(t==null?void 0:t.id)=="string"?t.id:void 0};function vR(e){const t=Lt(e);if(!t)return[];const n=[];for(const i of["sourceRef","targetRef"]){const r=t[i];for(const o of Array.isArray(r)?r:[r]){const a=tr(o);a&&n.push(a)}}return n}function bR(e){const t=Lt(e);if(!t)return{};const n=Array.isArray(t.sourceRef)?void 0:tr(t.sourceRef),i=Array.isArray(t.targetRef)?void 0:tr(t.targetRef);return n&&i?{source:n,target:i}:{}}function xR(e,t){const n=Lt(e.$parent);if(!n)return;const i=typeof n.$type=="string"?n.$type:"";if(i==="bpmn:Process"){const r=tr(n);return r?t.get(r):void 0}if(fc.has(i)&&i!=="bpmn:Lane"&&i!=="bpmn:Group")return tr(n)}function Wm(e){var a,s,c,l,u;const t=[],n=[],i=((a=Lt(e))==null?void 0:a.diagrams)??[],r=new Map,o=new Set;for(const p of((s=Lt(e))==null?void 0:s.rootElements)??[]){const f=Lt(p);if((f==null?void 0:f.$type)==="bpmn:Collaboration")for(const d of f.participants??[]){const g=Lt(d),h=tr(g),y=tr(g==null?void 0:g.processRef);h&&y?r.set(y,h):h&&o.add(h)}}for(const p of i){const f=Lt((c=Lt(p))==null?void 0:c.plane),d=(f==null?void 0:f.planeElement)??[];for(const g of d){const h=Lt(g);if(!h)continue;const y=Lt(h.bpmnElement),C=typeof(y==null?void 0:y.id)=="string"?y.id:void 0;if(!C)continue;const x=typeof(y==null?void 0:y.$type)=="string"?y.$type:"",m=Lt(h.bounds);if(m){const _=h.isExpanded===!1&&x!=="bpmn:Participant",E=Lt((l=Lt(h.label))==null?void 0:l.bounds),T={id:C,type:x,x:Ut(m.x),y:Ut(m.y),width:Ut(m.width),height:Ut(m.height),container:fc.has(x)&&!_,attached:(y==null?void 0:y.attachedToRef)!==void 0,...y?{parent:xR(y,r)}:{},...E?{label:{x:Ut(E.x),y:Ut(E.y),width:Ut(E.width),height:Ut(E.height)}}:{},...x==="bpmn:Group"?Hm(jm(y)):{}},O=h.isHorizontal!==!1,N=typeof(y==null?void 0:y.name)=="string"?y.name:"";o.has(C)&&O&&N&&(T.label=_p(T,N)),t.push(T);continue}const v=h.waypoint;if(Array.isArray(v)){const _=Lt((u=Lt(h.label))==null?void 0:u.bounds);n.push({id:C,type:x,waypoints:v.map(E=>{var T,O;return{x:Ut((T=Lt(E))==null?void 0:T.x),y:Ut((O=Lt(E))==null?void 0:O.y)}}),endpoints:vR(y),...bR(y),..._?{label:{x:Ut(_.x),y:Ut(_.y),width:Ut(_.width),height:Ut(_.height)}}:{}})}}}return{shapes:t,edges:n}}function Um(e){return dt(Wm(e),{includeObservationOnly:!0})}async function _R(e){const{definitions:t,warnings:n}=await zo(e);return{findings:Um(t),warnings:n}}function Ze(e){var i;const t=[],n=[];for(const r of e.getAll()){const o=r;if(o.type==="label"||o.labelTarget)continue;const a=typeof o.type=="string"?o.type:"";if(a==="bpmn:Definitions"||a.startsWith("bpmndi:"))continue;const s=o.waypoints;if(s){const h=Lt(o.label),y=tr(o.source),C=tr(o.target);n.push({id:o.id,type:a,waypoints:s.map(x=>({x:Ut(x.x),y:Ut(x.y)})),endpoints:[y,C].filter(x=>!!x),...y&&C?{source:y,target:C}:{},...h&&typeof h.x=="number"?{label:{x:h.x,y:Ut(h.y),width:Ut(h.width),height:Ut(h.height)}}:{}});continue}if(typeof o.x!="number"||typeof o.y!="number")continue;const c=Lt(o.businessObject),l=Lt(o.label);let u=Lt(o.parent);for(;u&&u.type==="bpmn:Lane";)u=Lt(u.parent);const p=typeof(u==null?void 0:u.type)=="string"?u.type:"",f=u&&fc.has(p)&&p!=="bpmn:Group"&&typeof u.id=="string"?u.id:void 0,d={id:o.id,type:a,x:o.x,y:o.y,width:Ut(o.width),height:Ut(o.height),container:fc.has(a)&&(a==="bpmn:Participant"||o.collapsed!==!0),attached:(c==null?void 0:c.attachedToRef)!==void 0,...f!==void 0?{parent:f}:{},...l&&typeof l.x=="number"?{label:{x:l.x,y:Ut(l.y),width:Ut(l.width),height:Ut(l.height)}}:{},...a==="bpmn:Group"?Hm(jm(c)):{}},g=typeof(c==null?void 0:c.name)=="string"?c.name:"";a==="bpmn:Participant"&&!(c!=null&&c.processRef)&&g&&((i=Lt(o.di))==null?void 0:i.isHorizontal)!==!1&&(d.label=_p(d,g)),t.push(d)}return{shapes:t,edges:n}}const wR={"bpmn:Participant":"participant","bpmn:Lane":"lane","bpmn:SequenceFlow":"sequenceFlow","bpmn:MessageFlow":"messageFlow","bpmn:DataStoreReference":"dataStore","bpmn:DataInputAssociation":"dataAssociation","bpmn:DataOutputAssociation":"dataAssociation","bpmn:TextAnnotation":"annotation","bpmn:Association":"association","bpmn:Group":"group"};function ER(e,t){const n=wR[e];return n||(e==="label"||e.startsWith("bpmndi:")?"other":e.startsWith("bpmn:")&&!("waypoints"in t&&t.waypoints)?"flowNode":"other")}function qm(e){let t=e.parent;for(;t;){if(t.type==="bpmn:Participant")return t.id;t=t.parent}}function Ym(e){const t=()=>e.getAll().filter(n=>n.type!=="label"&&!("labelTarget"in n&&n.labelTarget));return{isCollaboration:()=>t().some(n=>n.type==="bpmn:Participant"),categoryOf:n=>{const i=e.get(n);if(!(!i||i.type==="label"))return ER(i.type,i)},lanesOf:n=>t().filter(i=>i.type==="bpmn:Lane"&&qm(i)===n).sort((i,r)=>i.y-r.y).map(i=>i.id),participantOf:n=>{const i=e.get(n);return i?qm(i):void 0},endpointsOf:n=>{var r,o;const i=e.get(n);if(!(!i||i.type==="label")&&"waypoints"in i)return{source:(r=i.source)==null?void 0:r.id,target:(o=i.target)==null?void 0:o.id}},eventDefinitionOf:n=>{var o;const i=e.get(n);if(!i||i.type!=="bpmn:IntermediateCatchEvent")return;const r=(((o=i.businessObject)==null?void 0:o.eventDefinitions)??[]).map(a=>a.$type);return Uu(r)},reviewRequestLocalesOf:n=>{const i=e.get(n);return!i||i.type==="label"?[]:xr(i.businessObject).map(r=>r.locale)}}}const Rp=20,SR=4,Ot=(e,t)=>Math.abs(e-t)<.5;function bc(e,t,n,i=Rp){if(Ot(e.y,t.y)&&!Ot(e.x,t.x)){const r=Math.min(e.x,t.x),o=Math.max(e.x,t.x);if(!(r<n.x-i&&n.x+n.width+i<o))return null;const a=e.x<t.x?n.x-i:n.x+n.width+i,s=e.x<t.x?n.x+n.width+i:n.x-i,c=l=>[{x:a,y:e.y},{x:a,y:l},{x:s,y:l},{x:s,y:e.y}];return[c(n.y-i),c(n.y+n.height+i)]}if(Ot(e.x,t.x)&&!Ot(e.y,t.y)){const r=Math.min(e.y,t.y),o=Math.max(e.y,t.y);if(!(r<n.y-i&&n.y+n.height+i<o))return null;const a=e.y<t.y?n.y-i:n.y+n.height+i,s=e.y<t.y?n.y+n.height+i:n.y-i,c=l=>[{x:e.x,y:a},{x:l,y:a},{x:l,y:s},{x:e.x,y:s}];return[c(n.x-i),c(n.x+n.width+i)]}return null}function Km(e,t,n,i=Rp){if(n.length<2)return null;if(Ot(e.y,t.y)&&!Ot(e.x,t.x)){const r=Math.min(e.x,t.x),o=Math.max(e.x,t.x),a=Math.min(...n.map(d=>d.x))-i,s=Math.max(...n.map(d=>d.x+d.width))+i;if(!(r<a&&s<o))return null;const c=e.x<t.x?a:s,l=e.x<t.x?s:a,u=Math.min(...n.map(d=>d.y))-i,p=Math.max(...n.map(d=>d.y+d.height))+i,f=d=>[{x:c,y:e.y},{x:c,y:d},{x:l,y:d},{x:l,y:e.y}];return[f(u),f(p)]}if(Ot(e.x,t.x)&&!Ot(e.y,t.y)){const r=Math.min(e.y,t.y),o=Math.max(e.y,t.y),a=Math.min(...n.map(d=>d.y))-i,s=Math.max(...n.map(d=>d.y+d.height))+i;if(!(r<a&&s<o))return null;const c=e.y<t.y?a:s,l=e.y<t.y?s:a,u=Math.min(...n.map(d=>d.x))-i,p=Math.max(...n.map(d=>d.x+d.width))+i,f=d=>[{x:e.x,y:c},{x:d,y:c},{x:d,y:l},{x:e.x,y:l}];return[f(u),f(p)]}return null}function Xm(e,t,n=Rp){if(e.length!==4)return null;const[i,r,o,a]=e;if(Ot(i.y,r.y)&&Ot(r.x,o.x)&&Ot(o.y,a.y)){const s=c=>[i,{x:c,y:i.y},{x:c,y:a.y},a];return[s(t.x-n),s(t.x+t.width+n)]}if(Ot(i.x,r.x)&&Ot(r.y,o.y)&&Ot(o.x,a.x)){const s=c=>[i,{x:i.x,y:c},{x:a.x,y:c},a];return[s(t.y-n),s(t.y+t.height+n)]}return null}function xc(e,t){if(e.endpoints.length!==2)return[];const n=t.find(p=>p.id===e.endpoints[0]),i=t.find(p=>p.id===e.endpoints[1]);if(!n||!i)return[];if(i.x<=n.x+n.width)return[];const r=n.y+n.height/2,o=i.y+i.height/2;if(r>=i.y&&r<=i.y+i.height)return[];const a=i.x+i.width/2,s=n.x+n.width/2,c=r>o,l=[{x:n.x+n.width,y:r},{x:a,y:r},{x:a,y:c?i.y+i.height:i.y}],u=[{x:s,y:c?n.y:n.y+n.height},{x:s,y:o},{x:i.x,y:o}];return[l,u]}const Zm=30,RR=[0,-25,25,-40,40];function CR(e,t){if(e.type!=="bpmn:MessageFlow"||e.endpoints.length!==2)return[];const n=t.find(f=>f.id===e.endpoints[0]),i=t.find(f=>f.id===e.endpoints[1]);if(!n||!i)return[];const r=n.y+n.height/2,o=i.y+i.height/2;if(i.y<n.y+n.height&&i.y+i.height>n.y)return[];const a=o<r,s=a?n.y+n.height:n.y,c=a?s+Zm:s-Zm,l=a?i.y+i.height:i.y,u=n.x+n.width/2,p=i.x+i.width/2;return RR.map(f=>[{x:u,y:s},{x:u,y:c},{x:p+f,y:c},{x:p+f,y:l}]).filter(f=>xn({...e,endpoints:[],waypoints:f},[n]).length===0)}const Cp=(e,t,n)=>[...e.slice(0,t+1),...n,...e.slice(t+1)],Ko=(e,t,n)=>xn({...e,waypoints:t},n).length;function Mp(e,t,n,i){let r=[...e.waypoints],o=Ko(e,r,t);if(o===0)return null;let a=!1;for(const p of xc(e,t))if(Ko(e,p,t)===0)return p;const s=(i??[]).filter(p=>p.id!==e.id).flatMap(gn),c=p=>gn({...e,waypoints:p}).some(f=>mc(f,s).length>0),l=CR(e,t).filter(p=>Ko(e,p,t)===0);if(l.length)return l.find(p=>!c(p))??l[0];const u=p=>!n||p.every(f=>f.x>=n.x&&f.x<=n.x+n.width&&f.y>=n.y&&f.y<=n.y+n.height);if(e.endpoints.length===2&&r.length>2){const p=t.find(d=>d.id===e.endpoints[0]),f=t.find(d=>d.id===e.endpoints[1]);if(p&&f&&Ot(p.y+p.height/2,f.y+f.height/2)){const d=[r[0],r[r.length-1]];if(Ot(d[0].y,d[1].y)&&!Ot(d[0].x,d[1].x)){const g=t.filter(x=>!e.endpoints.includes(x.id)&&xn({...e,waypoints:d},[x]).length>0),h=g.length>=2?Km(d[0],d[1],g):null,C=(h?h.map(x=>[d[0],...x,d[1]]):g.length===1?(bc(d[0],d[1],g[0])??[]).map(x=>[d[0],...x,d[1]]):g.length===0?[d]:[]).filter(x=>Ko(e,x,t)===0&&x.length<=r.length).sort((x,m)=>Number(u(m))-Number(u(x)));if(C.length)return C.find(x=>!c(x))??C[0]}}}for(let p=0;p+1<r.length;p++){const f=r[p],d=r[p+1],g=t.filter(C=>!e.endpoints.includes(C.id)&&xn({...e,waypoints:[f,d]},[C]).length>0);if(g.length<2)continue;const h=Km(f,d,g);if(!h)continue;const y=h.map(C=>Cp(r,p,C)).filter(C=>Ko(e,C,t)===0).sort((C,x)=>Number(u(x))-Number(u(C)));if(y.length)return y.find(C=>!c(C))??y[0]}for(let p=0;p<SR&&o>0;p++){let f=!1;for(let d=0;d+1<r.length&&!f;d++){const g=r[d],h=r[d+1];for(const y of t){if(e.endpoints.includes(y.id)||xn({...e,waypoints:[g,h]},[y]).length===0)continue;const C=bc(g,h,y),x=C?C.map(v=>Cp(r,d,v)):Xm(r,y)??[];if(!x.length)continue;const m=[...x].sort((v,_)=>Number(u(_))-Number(u(v)));for(const v of m){const _=Ko(e,v,t);if(_<o){r=v,o=_,f=!0,a=!0;break}}if(f)break}}if(!f)break}return a&&o===0?r:null}function Ap(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i),a=ci(o),s=new Set,c=dt(o).filter(u=>u.kind==="edge-crosses-shape"&&!t.has(lt(u)));if(!c.length)return s;const l=new Map;for(const u of c){if(u.kind!=="edge-crosses-shape"||l.has(u.edge))continue;const p=o.edges.find(f=>f.id===u.edge);p&&l.set(u.edge,p)}for(const[u,p]of l){if(n&&!n.has(u))continue;const f=i.get(u);if(!f)continue;const d=f.parent,g=d&&typeof d.x=="number"&&typeof d.width=="number"?{x:d.x,y:d.y,width:d.width,height:d.height}:void 0,h=Mp(p,a,g,o.edges);if(!h){xn(p,a).some(m=>m.type==="bpmn:TextAnnotation")&&s.add(u);continue}const y=o.edges.filter(m=>m.id!==u),C=ai(p,y);ai({...p,waypoints:h},y)>C||r.updateWaypoints(f,h)}return s}const MR=e=>{const t=[];for(let n=0;n+1<e.waypoints.length;n++){const i=e.waypoints[n],r=e.waypoints[n+1];t.push({id:`__ghost:${e.id}:${n}`,type:"bpmn:Task",x:Math.min(i.x,r.x)-1,y:Math.min(i.y,r.y)-1,width:Math.max(2,Math.abs(r.x-i.x)+2),height:Math.max(2,Math.abs(r.y-i.y)+2),container:!1,attached:!1})}return t},Pp=(e,t)=>Ha(e,[t])>0;function Qm(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i),a=ci(o);let s=o;const c=new Set(dt(o).map(lt));for(const[l,u]of vc(o))if(!t.has(`${l}|${u}`))for(const[p,f]of[[l,u],[u,l]]){if(n.has(p))continue;const d=s.edges.find(N=>N.id===p),g=s.edges.find(N=>N.id===f);if(!d||!g)continue;const h=i.get(p);if(!h)continue;const y=h.parent,C=y&&typeof y.x=="number"&&typeof y.width=="number"?{x:y.x,y:y.y,width:y.width,height:y.height}:void 0,x=MR(g),m=[...xc(d,a)??[]],v=Mp(d,[...a,...x],C,o.edges);v&&m.push(v);for(let N=0;N+1<d.waypoints.length;N++)for(const P of x)for(const D of bc(d.waypoints[N],d.waypoints[N+1],P)??[])m.push(Cp(d.waypoints,N,D));const _=s.edges.filter(N=>N.id!==p),E=N=>({...s,edges:s.edges.map(P=>P.id===p?{...P,waypoints:N}:P)}),T=N=>!C||N.every(P=>P.x>=C.x&&P.x<=C.x+C.width&&P.y>=C.y&&P.y<=C.y+C.height),O=m.find(N=>{const P={...d,waypoints:N};return Pp(P,g)||!T(N)||_.some(D=>D.id!==f&&!Pp(d,D)&&Pp(P,D))?!1:dt(E(N)).every(D=>c.has(lt(D)))});if(O){r.updateWaypoints(h,O),s=E(O);break}}}const AR=10;function Jm(e,t){if(e.parent){const r=t.find(o=>o.id===e.parent);if(r)return r}const n=e.x+e.width/2,i=e.y+e.height/2;return t.find(r=>n>=r.x&&n<=r.x+r.width&&i>=r.y&&i<=r.y+r.height)}function eg(e,t){if(e.waypoints.length<2||e.endpoints.length!==2)return null;const n=t.shapes.filter(F=>F.type==="bpmn:Participant"&&F.container),i=t.shapes.find(F=>F.id===e.endpoints[0]),r=t.shapes.find(F=>F.id===e.endpoints[1]);if(!i||!r)return null;const o=Jm(i,n),a=Jm(r,n);if(!o||!a||o.id===a.id)return null;const s=a.y>o.y,c=s?o:a,l=s?a:o,u=n.filter(F=>F.id!==o.id&&F.id!==a.id&&F.y>=c.y+c.height&&F.y+F.height<=l.y).sort((F,J)=>F.y-J.y);if(!u.length)return null;const p=u[0],f=u[u.length-1],d=(c.y+c.height+p.y)/2,g=(f.y+f.height+l.y)/2,h=s?d:g,y=s?g:d,C=e.waypoints[0],x=e.waypoints[e.waypoints.length-1],m=ci(t),v=t.edges.filter(F=>F.id!==e.id),_=si(e,v),E=xn(e,m).length;if(_===0&&E===0||E===0&&e.waypoints.length===2)return null;const T=Math.min(...u.map(F=>F.x)),O=Math.max(...u.map(F=>F.x+F.width)),N=(C.x+x.x)/2,P=F=>F.filter((J,ge)=>ge===0||!(Ot(J.x,F[ge-1].x)&&Ot(J.y,F[ge-1].y)));let D;for(let F=T;F<=O;F+=AR){const J=P([C,{x:C.x,y:h},{x:F,y:h},{x:F,y},{x:x.x,y},x]),ge={...e,waypoints:J};if(xn(ge,m).length>0)continue;const Ae=si(ge,v),De=Math.abs(F-N);(!D||Ae<D.cross||Ae===D.cross&&De<D.detour)&&(D={pts:J,cross:Ae,detour:De})}return D&&(E>0?D.cross<=_:D.cross<_)?D.pts:null}function tg(e,t){const{elementRegistry:n}=e,i=e.modeling,r=Ze(n);for(const o of r.edges){if(o.type!=="bpmn:MessageFlow"||t.has(o.id))continue;const a=Ze(n),s=a.edges.find(u=>u.id===o.id);if(!s)continue;const c=eg(s,a);if(!c)continue;const l=n.get(o.id);l&&i.updateWaypoints(l,c)}}const ji=[25,-25,40,-40],Xo=35;function PR(e,t){const n=e.x+e.width/2,i=t.x+t.width/2,r=[];for(const o of[!0,!1]){const a=o?e.y:e.y+e.height,s=o?t.y:t.y+t.height,c=o?Math.min(e.y,t.y)-Xo:Math.max(e.y+e.height,t.y+t.height)+Xo;for(const l of[0,...ji])if(!(Math.abs(l)>=e.width/2-5))for(const u of[0,...ji]){if(Math.abs(u)>=t.width/2-5)continue;const p=n+l,f=i+u;r.push({pts:[{x:p,y:a},{x:p,y:c},{x:f,y:c},{x:f,y:s}],cost:Math.abs(u)+Math.abs(l)})}}return r}function _c(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];if(i.x+i.width>n.x)return[];const r=n.y+n.height/2;if(r>=i.y&&r<=i.y+i.height)return PR(n,i);const o=i.x+i.width/2,a=n.x+n.width/2,s=r<i.y,c=s?i.y:i.y+i.height,l=s?n.y:n.y+n.height,u=s?n.y-Xo:n.y+n.height+Xo,p=[];for(const x of[0,...ji]){if(Math.abs(x)>=i.width/2-5)continue;const m=o+x;p.push({pts:[{x:n.x,y:r},{x:m,y:r},{x:m,y:c}],cost:Math.abs(x)});for(const v of[0,...ji]){if(Math.abs(v)>=n.width/2-5)continue;const _=a+v;p.push({pts:[{x:_,y:l},{x:_,y:u},{x:m,y:u},{x:m,y:c}],cost:Math.abs(x)+Math.abs(v)})}}const f=50,d=i.y+i.height/2,g=s?n.y+n.height:n.y;for(const x of[0,...ji]){if(Math.abs(x)>=n.width/2-5)continue;const m=a+x;p.push({pts:[{x:m,y:g},{x:m,y:d},{x:i.x+i.width,y:d}],cost:f+Math.abs(x)})}const h=60,y=s?i.y+i.height:i.y,C=s?i.y+i.height+Xo:i.y-Xo;for(const x of[0,...ji]){if(Math.abs(x)>=i.width/2-5)continue;const m=o+x;for(const v of[0,...ji]){if(Math.abs(v)>=n.width/2-5)continue;const _=a+v;p.push({pts:[{x:_,y:g},{x:_,y:C},{x:m,y:C},{x:m,y}],cost:h+Math.abs(x)+Math.abs(v)})}}return p}const wc=30;function ng(e,t){for(let n=1;n<e.length-2;n++){const i=e[n],r=e[n+1],o=Ot(i.y,r.y)&&!Ot(i.x,r.x),a=Ot(i.x,r.x)&&!Ot(i.y,r.y);if(!(!o&&!a))for(const s of t)if(o){const c=Math.min(i.x,r.x);if(Math.max(i.x,r.x)<=s.x||c>=s.x+s.width)continue;if(Math.abs(i.y-s.y)<wc||Math.abs(i.y-(s.y+s.height))<wc)return!0}else{const c=Math.min(i.y,r.y);if(Math.max(i.y,r.y)<=s.y||c>=s.y+s.height)continue;if(Math.abs(i.x-s.x)<wc||Math.abs(i.x-(s.x+s.width))<wc)return!0}}return!1}const Ec=40;function TR(e,t,n){let i=0;for(const r of t){if(r.container||n.includes(r.id))continue;const o=r.x-Ec,a=r.x+r.width+Ec,s=r.y-Ec,c=r.y+r.height+Ec;for(let l=1;l<e.length-2;l++){const u=e[l],p=e[l+1],f={x:Math.min(u.x,p.x),y:Math.min(u.y,p.y)},d={x:Math.max(u.x,p.x),y:Math.max(u.y,p.y)};if(f.x<a&&d.x>o&&f.y<c&&d.y>s){i++;break}}}return i}function ig(e,t){if(e.type!=="bpmn:SequenceFlow")return null;const n=t.shapes.filter(E=>E.container),i=new Map(t.shapes.map(E=>[E.id,E])),r=ci(t),o=t.edges.filter(E=>E.id!==e.id),a=ai(e,o),s=si(e,o),c=E=>TR(E,t.shapes,e.endpoints)+(ng(E,n)?1:0),l=c(e.waypoints),u=E=>{if(!E)return;const T=E.x+E.width/2,O=E.y+E.height/2;return n.find(N=>N.type==="bpmn:Lane"&&T>=N.x&&T<=N.x+N.width&&O>=N.y&&O<=N.y+N.height)},p=u(i.get(e.endpoints[0]??"")),f=u(i.get(e.endpoints[1]??"")),d=!!p&&!!f&&p.id!==f.id,g=E=>{if(!d||!f)return!1;for(let T=1;T<E.length-2;T++){const O=E[T],N=E[T+1];if(Ot(O.y,N.y)&&!Ot(O.x,N.x)&&O.y>f.y&&O.y<f.y+f.height)return!0}return!1},h=g(e.waypoints),C=(E=>{if(!E)return;const T=E.x+E.width/2,O=E.y+E.height/2;return n.filter(N=>N.type==="bpmn:Participant"&&T>=N.x&&T<=N.x+N.width&&O>=N.y&&O<=N.y+N.height).sort((N,P)=>N.width*N.height-P.width*P.height)[0]})(i.get(e.endpoints[0]??"")),x=E=>{if(!C)return 0;let T=0;for(let O=1;O<E.length-1;O++){const N=E[O];(N.x<C.x||N.x>C.x+C.width||N.y<C.y||N.y>C.y+C.height)&&T++}return T},m=x(e.waypoints);if(!ng(e.waypoints,n)&&!(d&&!h)&&m===0)return null;const v=E=>E.reduce((T,O,N)=>N?T+Math.abs(O.x-E[N-1].x)+Math.abs(O.y-E[N-1].y):0,0);let _;for(const{pts:E,cost:T}of _c(e,i)){const O={...e,waypoints:E};if(xn(O,r).length>0)continue;const N=ai(O,o);if(N>a)continue;const P=x(E);if(P>m)continue;const D=P<m&&N===0;if(!D&&si(O,o)>s)continue;const F=c(E),J=g(E);if(!D&&!(J&&!h)&&F>=l)continue;const Ae=J?0:1,De=v(E);(!_||P<_.out||P===_.out&&(Ae<_.lane||Ae===_.lane&&(N<_.opp||N===_.opp&&(F<_.sc||F===_.sc&&(T<_.cost||T===_.cost&&De<_.len)))))&&(_={pts:E,out:P,sc:F,lane:Ae,opp:N,cost:T,len:De})}return(_==null?void 0:_.pts)??null}function kR(e,t){if(e.type!=="bpmn:SequenceFlow"||e.endpoints.length!==2)return!1;const[n,i]=e.endpoints,r=t.edges.filter(p=>p.type==="bpmn:SequenceFlow"&&p.endpoints.length===2),o=r.filter(p=>p.endpoints[1]===i),a=r.filter(p=>p.endpoints[0]===i);if(o.length!==1||a.length!==1)return!1;const s=t.shapes.find(p=>p.id===n),c=t.shapes.find(p=>p.id===i),l=t.shapes.find(p=>p.id===a[0].endpoints[1]);if(!s||!c||!l||!(s.x+s.width<c.x&&c.x+c.width<l.x))return!1;const u=s.y+s.height/2;return u<l.y||u>l.y+l.height?!1:u<c.y||u>c.y+c.height}function OR(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i).edges.filter(a=>(!t.has(a.id)||n.has(a.id))&&a.waypoints.length>=4).map(a=>a.id).sort();for(const a of o){const s=Ze(i),c=s.edges.find(y=>y.id===a);if(!c||c.waypoints.length<4)continue;const l=ci(s),u=s.edges.filter(y=>y.id!==a),p=xn(c,l).length,f=ai(c,u),d=si(c,u),g=n.has(a)?new Set(dt(s).map(lt)):null,h=xc(c,s.shapes);h.length===2&&kR(c,s)&&h.reverse();for(const y of h){if(y.length>=c.waypoints.length)continue;const C={...c,waypoints:y};if(xn(C,l).length>p||ai(C,u)>f||si(C,u)>d)continue;if(g){const m=new Set(dt({...s,edges:s.edges.map(E=>E.id===a?C:E)}).map(lt)),v=[...m].filter(E=>!g.has(E)).length,_=[...g].filter(E=>!m.has(E)).length;if(v>_)continue}const x=i.get(a);x&&r.updateWaypoints(x,y);break}}}function rg(e,t){const{elementRegistry:n}=e,i=e.modeling,r=Ze(n).edges.filter(o=>o.type==="bpmn:SequenceFlow"&&!t.has(o.id)).map(o=>o.id).sort();for(const o of r){const a=Ze(n),s=a.edges.find(u=>u.id===o);if(!s)continue;const c=ig(s,a);if(!c)continue;const l=n.get(o);l&&i.updateWaypoints(l,c)}}function Tp(e,t){const n=e.waypoints;if(n.length<3)return[];const i=[],r=t.get(e.endpoints[0]??""),o=t.get(e.endpoints[1]??""),a=Ot(n[0].x,n[1].x)&&!Ot(n[0].y,n[1].y),s=Ot(n[n.length-1].x,n[n.length-2].x)&&!Ot(n[n.length-1].y,n[n.length-2].y);for(const c of ji){if(a&&r&&Math.abs(c)<r.width/2-5){const l=n.map(u=>({...u}));l[0].x+=c,l[1].x+=c,i.push({pts:l,cost:Math.abs(c)})}if(s&&o&&Math.abs(c)<o.width/2-5){const l=n.map(u=>({...u}));l[l.length-1].x+=c,l[l.length-2].x+=c,i.push({pts:l,cost:Math.abs(c)})}}return i}function DR(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];if(Math.min(n.x+n.width,i.x+i.width)-Math.max(n.x,i.x)>=1)return[];const r=i.y+i.height<=n.y,o=n.y+n.height<=i.y;if(!r&&!o)return[];const a=i.x>=n.x+n.width,s=i.x+i.width<=n.x;if(!a&&!s)return[];const c=n.x+n.width/2,l=n.y+n.height/2,u=i.x+i.width/2,p=i.y+i.height/2,f=a?n.x+n.width:n.x,d=o?n.y+n.height:n.y,g=a?i.x:i.x+i.width,h=o?i.y:i.y+i.height,y=[];for(const C of[0,...ji])Math.abs(C)<i.width/2-5&&y.push({pts:[{x:f,y:l},{x:u+C,y:l},{x:u+C,y:h}],cost:Math.abs(C)}),Math.abs(C)<i.height/2-5&&y.push({pts:[{x:c,y:d},{x:c,y:p+C},{x:g,y:p+C}],cost:Math.abs(C)});return y}function kp(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];const r=Math.max(n.x,i.x),o=Math.min(n.x+n.width,i.x+i.width);if(o-r<1)return[];const a=i.y+i.height<=n.y,s=n.y+n.height<=i.y;if(!a&&!s)return[];const c=a?n.y:n.y+n.height,l=a?i.y+i.height:i.y,u=(r+o)/2,p=[];for(const f of[0,...ji]){const d=u+f;d<=r||d>=o||p.push({pts:[{x:d,y:c},{x:d,y:l}],cost:Math.abs(f)})}return p}function og(e,t){const n=new Map(t.shapes.map(d=>[d.id,d])),i=ci(t),r=t.edges.filter(d=>d.id!==e.id),o=ai(e,r);if(o===0)return null;const a=si(e,r);let s;const c=d=>d.reduce((g,h,y)=>y?g+Math.abs(h.x-d[y-1].x)+Math.abs(h.y-d[y-1].y):0,0),l=3,u=d=>{const g=d[0],h=d[d.length-1],y=Math.hypot(h.x-g.x,h.y-g.y);return y>=1&&c(d)/y>=l?1:0},p=u(e.waypoints),f=[..._c(e,n),...kp(e,n),...Tp(e,n)];for(const{pts:d,cost:g}of f){const h={...e,waypoints:d};if(xn(h,i).length>0)continue;const y=ai(h,r),C=si(h,r),x=o-y+(p-u(d));if(y>=o||C-a>x)continue;const m=c(d);(!s||y<s.opposite||y===s.opposite&&(C<s.cross||C===s.cross&&(g<s.cost||g===s.cost&&m<s.len)))&&(s={pts:d,opposite:y,cross:C,cost:g,len:m})}return(s==null?void 0:s.pts)??null}function ag(e,t){var i;let n=0;for(const r of t)r.id!==e.id&&((i=Uo(e,r))==null?void 0:i.kind)==="unrelated"&&n++;return n}function LR(e,t){const n=new Map(t.shapes.map(f=>[f.id,f])),i=ci(t),r=t.edges.filter(f=>f.id!==e.id),o=ag(e,r);if(o===0)return null;const a=ai(e,r),s=si(e,r),c=f=>f.reduce((d,g,h)=>h?d+Math.abs(g.x-f[h-1].x)+Math.abs(g.y-f[h-1].y):0,0),l=2;let u;const p=[..._c(e,n),...kp(e,n),...DR(e,n),...Tp(e,n)];for(const{pts:f,cost:d}of p){const g={...e,waypoints:f};if(xn(g,i).length>0)continue;const h=ag(g,r);if(h>=o)continue;const y=ai(g,r);if(y-h>a-o)continue;const C=si(g,r);if(C-s>(o-h)*l)continue;const x=c(f);(!u||h<u.fake||h===u.fake&&(y<u.unreadable||y===u.unreadable&&(C<u.cross||C===u.cross&&(d<u.cost||d===u.cost&&x<u.length))))&&(u={pts:f,fake:h,unreadable:y,cross:C,cost:d,length:x})}return(u==null?void 0:u.pts)??null}function sg(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=dt(Ze(i)).filter(s=>s.kind==="edge-overlap-unrelated"&&!t.has(lt(s)));if(!o.length)return;const a=new Set;for(const s of o)if(s.kind==="edge-overlap-unrelated")for(const c of s.edges)n.has(c)||a.add(c);for(const s of[...a].sort()){const c=Ze(i),l=c.edges.find(f=>f.id===s);if(!l)continue;const u=LR(l,c);if(!u)continue;const p=i.get(s);p&&r.updateWaypoints(p,u)}}function cg(e,t){const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");return!!n&&!!i&&i.x+i.width>n.x}function lg(e,t,n){var l;if(e.type!=="bpmn:SequenceFlow"||t.type!=="bpmn:SequenceFlow"||((l=Uo(e,t))==null?void 0:l.kind)!=="opposite")return!1;const[i,r]=e.endpoints,[o,a]=t.endpoints,s=[i,r].filter(u=>u&&(u===o||u===a)).length;return!(!!r&&r===o||!!a&&a===i)||s!==1?!1:cg(e,n)&&cg(t,n)}function ug(e,t,n){let i=0;for(const r of t)r.id!==e.id&&lg(e,r,n)&&i++;return i}function IR(e,t){const n=new Map(t.shapes.map(f=>[f.id,f])),i=ci(t),r=t.edges.filter(f=>f.id!==e.id),o=ug(e,r,n);if(o===0)return null;const a=ai(e,r),s=si(e,r),c=f=>f.reduce((d,g,h)=>h?d+Math.abs(g.x-f[h-1].x)+Math.abs(g.y-f[h-1].y):0,0),l=2;let u;const p=[..._c(e,n),...kp(e,n),...Tp(e,n)];for(const{pts:f,cost:d}of p){const g={...e,waypoints:f};if(xn(g,i).length>0)continue;const h=ug(g,r,n);if(h>=o)continue;const y=ai(g,r);if(y-h>a-o)continue;const C=si(g,r);if(C-s>(o-h)*l)continue;const x=c(f);(!u||h<u.chain||h===u.chain&&(y<u.unreadable||y===u.unreadable&&(C<u.cross||C===u.cross&&(d<u.cost||d===u.cost&&x<u.length))))&&(u={pts:f,chain:h,unreadable:y,cross:C,cost:d,length:x})}return(u==null?void 0:u.pts)??null}function BR(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i),a=new Map(o.shapes.map(l=>[l.id,l])),s=dt(o).filter(l=>l.kind==="edge-overlap-opposite"&&!t.has(lt(l)));if(!s.length)return;const c=new Set;for(const l of s){if(l.kind!=="edge-overlap-opposite")continue;const[u,p]=l.edges.map(f=>o.edges.find(d=>d.id===f));if(!(!u||!p||!lg(u,p,a)))for(const f of l.edges)n.has(f)||c.add(f)}for(const l of[...c].sort()){const u=Ze(i),p=u.edges.find(g=>g.id===l);if(!p)continue;const f=IR(p,u);if(!f)continue;const d=i.get(l);d&&r.updateWaypoints(d,f)}}function pg(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i),a=dt(o).filter(u=>wp(u)&&!t.has(lt(u)));if(!a.length)return;const s=new Set;for(const u of a)if(wp(u))for(const p of u.edges)n.has(p)||s.add(p);const c=u=>{var p;return((p=o.edges.find(f=>f.id===u))==null?void 0:p.type)??""},l=[...s].sort((u,p)=>{const f=c(u)==="bpmn:SequenceFlow"?0:1,d=c(p)==="bpmn:SequenceFlow"?0:1;return f!==d?f-d:u.localeCompare(p)});for(const u of l){const p=Ze(i),f=p.edges.find(h=>h.id===u);if(!f)continue;const d=og(f,p);if(!d)continue;const g=i.get(u);g&&r.updateWaypoints(g,d)}}const NR=10,$R=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height;function fg(e,t){const n=e.label;if(!n)return null;const i=t.edges.filter(a=>a.id!==e.id);if(!gc(e,i))return null;const r=ci(t),o=i.flatMap(gn);for(const a of gn(e)){let s=[[a.lo,a.hi]];for(const[d,g]of mc(a,o))s=s.flatMap(([h,y])=>{const C=[];return d>h&&C.push([h,Math.min(y,d)]),g<y&&C.push([Math.max(h,g),y]),C.filter(([x,m])=>m>x)});const c=a.axis==="h"?n.width:n.height,l=s.find(([d,g])=>g-d>=c+NR*2);if(!l)continue;const u=(l[0]+l[1])/2,p=a.axis==="h"?{x:u,y:a.at-km}:{x:a.at+Sn+n.width/2,y:u},f={x:p.x-n.width/2,y:p.y-n.height/2,width:n.width,height:n.height};if(!gc({...e,label:f},i)&&!r.some(d=>!e.endpoints.includes(d.id)&&$R(f,d)))return f}return null}const Sn=8;function Op(e,t){const n=e.label;if(!n)return null;const i=gn(e);if(!i.length)return null;const r=n.x+n.width/2,o=n.y+n.height/2,a=f=>{const d=f.axis==="h"?r:o,g=f.axis==="h"?o-f.at:r-f.at,h=d<f.lo?f.lo-d:d>f.hi?d-f.hi:0;return Math.hypot(g,h)},s=i.reduce((f,d)=>a(d)<a(f)?d:f,i[0]),c=[...i,...t.edges.filter(f=>f.id!==e.id).flatMap(gn),...t.shapes.filter(f=>f.container).flatMap(Yo)],l=f=>!c.some(d=>Fi(f,d));if(l(n))return null;const u=(s.axis==="v"?n.height:n.width)+Sn,p=[0,-u,u,-2*u,2*u];if(s.axis==="v")for(const f of[s.at+Sn,s.at-Sn-n.width])for(const d of p){const g=n.y+d;if(g<s.lo||g+n.height>s.hi)continue;const h={...n,x:f,y:g};if(l(h))return h}else for(const f of[s.at-Sn-n.height,s.at+Sn])for(const d of p){const g=n.x+d;if(g<s.lo||g+n.width>s.hi)continue;const h={...n,x:g,y:f};if(l(h))return h}return null}const dg=30,FR=(e,t)=>{let n=1/0;for(let i=0;i+1<t.length;i++){const r=t[i],o=t[i+1],a=o.x-r.x,s=o.y-r.y,c=a*a+s*s,l=c?Math.max(0,Math.min(1,((e.x-r.x)*a+(e.y-r.y)*s)/c)):0;n=Math.min(n,Math.hypot(e.x-(r.x+l*a),e.y-(r.y+l*s)))}return n},hg=(e,t)=>FR({x:e.x+e.width/2,y:e.y+e.height/2},t);function jR(e,t){const n=e.label;if(!n)return null;const i=gn(e);if(!i.length)return null;const r=[...i,...t.edges.filter(c=>c.id!==e.id).flatMap(gn),...t.shapes.filter(c=>c.container).flatMap(Yo)],o=co(t).filter(c=>c.owner!==e.id).map(c=>c.rect),a=(c,l)=>c.x<l.x+l.width&&l.x<c.x+c.width&&c.y<l.y+l.height&&l.y<c.y+c.height,s=c=>!r.some(l=>Fi(c,l))&&!za(c,t).length&&!o.some(l=>a(c,l));for(const c of i){const l=(c.lo+c.hi)/2,u=c.axis==="h"?[c.at+Sn,c.at-Sn-n.height].map(p=>({...n,x:l-n.width/2,y:p})):[c.at+Sn,c.at-Sn-n.width].map(p=>({...n,x:p,y:l-n.height/2}));for(const p of u)if(s(p))return p}return null}function mg(e,t){var a,s;const{elementRegistry:n}=e,i=e.modeling;let r=Ze(n),o=new Set(dt(r).map(lt));for(const[c,l]of t){const u=l.wps,p=n.get(c),f=p==null?void 0:p.label;if(!f||!(p!=null&&p.waypoints))continue;const d=p.waypoints[0].x-u[0].x,g=p.waypoints[0].y-u[0].y;if(!(p.waypoints.length===u.length&&p.waypoints.every((E,T)=>E.x-u[T].x===d&&E.y-u[T].y===g))){if(((a=p.source)==null?void 0:a.id)===l.source&&((s=p.target)==null?void 0:s.id)===l.target)continue;const E=r.edges.find(D=>D.id===c);if(!(E!=null&&E.label)||!za(E.label,r).length)continue;let T={...E.label,x:l.label.x,y:l.label.y};if((za(T,r).length||hg(T,E.waypoints)>dg)&&(T=null),!T&&hg(E.label,E.waypoints)>dg&&(T=jR(E,r)),!T)continue;const O=T,N={...r,edges:r.edges.map(D=>D.id===c?{...D,label:O}:D)},P=dt(N);if(P.some(D=>!o.has(lt(D))))continue;i.moveElements([f],{x:O.x-f.x,y:O.y-f.y}),r=N,o=new Set(P.map(lt));continue}const y=l.label.x+d-f.x,C=l.label.y+g-f.y;if(y===0&&C===0)continue;const x=r.edges.find(E=>E.id===c);if(!(x!=null&&x.label))continue;const m={...x.label,x:x.label.x+y,y:x.label.y+C},v={...r,edges:r.edges.map(E=>E.id===c?{...E,label:m}:E)},_=dt(v);_.some(E=>!o.has(lt(E)))||(i.moveElements([f],{x:y,y:C}),r=v,o=new Set(_.map(lt)))}}function gg(e,t,n=new Set){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i);for(const a of o.edges){if(!a.label||t.has(a.id)&&!n.has(a.id))continue;const s=Op(a,o);if(!s)continue;const c=i.get(a.id),l=c==null?void 0:c.label;l&&r.moveElements([l],{x:s.x-l.x,y:s.y-l.y})}}function yg(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i),a=dt(o).filter(s=>s.kind==="label-on-shared-segment"&&!t.has(lt(s)));for(const s of a){if(s.kind!=="label-on-shared-segment"||n.has(s.edge))continue;const c=o.edges.find(f=>f.id===s.edge);if(!c)continue;const l=fg(c,o);if(!l)continue;const u=i.get(s.edge),p=u==null?void 0:u.label;p&&r.moveElements([p],{x:l.x-p.x,y:l.y-p.y})}}function vg(e,t){const n=e.label;if(!n)return null;const i=[...t.edges.flatMap(gn),...t.shapes.filter(f=>f.container).flatMap(Yo)],r=i.filter(f=>Fi(n,f));if(!r.length)return null;const o=t.shapes.filter(f=>!f.container&&f.id!==e.id),a=co(t).filter(f=>f.owner!==e.id).map(f=>f.rect),s=(f,d)=>f.x<d.x+d.width&&d.x<f.x+f.width&&f.y<d.y+d.height&&d.y<f.y+f.height,c=f=>!i.some(d=>Fi(f,d))&&!o.some(d=>s(f,d))&&!a.some(d=>s(f,d)),l=[];for(const f of r)f.axis==="h"?l.push({...n,y:f.at-Sn-n.height},{...n,y:f.at+Sn}):l.push({...n,x:f.at-Sn-n.width},{...n,x:f.at+Sn});const u=e.x+e.width/2,p=e.y+e.height/2;return l.push({...n,x:u-n.width/2,y:e.y+e.height+Sn},{...n,x:u-n.width/2,y:e.y-Sn-n.height},{...n,x:e.x+e.width+Sn,y:p-n.height/2},{...n,x:e.x-Sn-n.width,y:p-n.height/2}),l.find(c)??null}function bg(e,t){const{elementRegistry:n}=e,i=e.modeling,r=Ze(n);for(const o of r.shapes){if(o.container||!o.label||t.has(o.id))continue;const a=vg(o,Ze(n));if(!a)continue;const s=n.get(o.id),c=s==null?void 0:s.label;c&&i.moveElements([c],{x:a.x-c.x,y:a.y-c.y})}}function HR(e,t){const n=e.x,i=e.x+e.width,r=e.y,o=e.y+e.height;if(t.x<n||t.x>i||t.y<r||t.y>o)return{x:Math.round(Math.min(Math.max(t.x,n),i)),y:Math.round(Math.min(Math.max(t.y,r),o))};const s=[[t.x-n,{x:n,y:t.y}],[i-t.x,{x:i,y:t.y}],[t.y-r,{x:t.x,y:r}],[o-t.y,{x:t.x,y:o}]].reduce((c,l)=>l[0]<c[0]?l:c);return{x:Math.round(s[1].x),y:Math.round(s[1].y)}}function xg(e,t){const{elementRegistry:n}=e,i=e.modeling;let r=Ze(n),o=new Set(dt(r).map(lt));const a=[...new Set(dt(r).filter(s=>s.kind==="edge-endpoint-detached"&&!t.has(lt(s))).map(s=>s.edge))].sort();for(const s of a){const c=r.edges.find(h=>h.id===s);if(!c||c.waypoints.length<2)continue;const l=c.waypoints.map(h=>({...h})),u=[[c.endpoints[0],0],[c.endpoints[1],l.length-1]];let p=!1;for(const[h,y]of u){const C=h?r.shapes.find(m=>m.id===h):void 0;if(!C)continue;const x=HR(C,l[y]);x.x===l[y].x&&x.y===l[y].y||(l[y]=x,p=!0)}if(!p)continue;const f={...r,edges:r.edges.map(h=>h.id===s?{...h,waypoints:l}:h)},d=dt(f);if(d.some(h=>!o.has(lt(h))))continue;const g=n.get(s);g&&(i.updateWaypoints(g,l),r=f,o=new Set(d.map(lt)))}}const Dp=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function _g(e,t){const n=(r,o,a,s="name")=>{const c=s==="text"?"texts":"names",l=u=>o?`${o}.${u}`:u;return{id:r,plainField:l(s),mapField:l(c),plain:a[s],map:a[c]}},i=e;switch(e.kind){case"participant.add":return[n(e.participant.id,"participant",e.participant),...(e.participant.lanes??[]).map((r,o)=>n(r.id,`participant.lanes[${o}]`,r))];case"participant.update":return[n(e.id,"",i),...(e.lanes??[]).map((r,o)=>({...n(r.id,`lanes[${o}]`,r),omittedMeansRemove:(t==null?void 0:t.categoryOf(r.id))==="lane"}))];case"node.add":return[n(e.node.id,"node",e.node)];case"sequenceFlow.add":return[{...n(e.flow.id,"flow",e.flow),condition:e.flow.condition,conditionField:"flow.condition"}];case"sequenceFlow.update":return[{...n(e.id,"",i),condition:e.condition,conditionField:"condition"}];case"messageFlow.add":return[n(e.flow.id,"flow",e.flow)];case"dataStore.add":return[n(e.dataStore.id,"dataStore",e.dataStore)];case"annotation.add":return[n(e.annotation.id,"annotation",e.annotation,"text")];case"annotation.update":return[n(e.id,"",i,"text")];case"group.add":return[n(e.group.id,"group",e.group)];case"node.update":case"messageFlow.update":case"dataStore.update":case"group.update":return[n(e.id,"",i)];default:return[]}}function zR(e,t,n){const i=[],r=n?Ba(n):[];return e.forEach((o,a)=>{if(o.kind==="translation.confirm"){if(!n){i.push({kind:"locale-texts-not-enabled",opIndex:a,id:o.id,field:"locale"});return}if(!r.includes(o.locale)){i.push({kind:"locale-not-in-document",opIndex:a,id:o.id,field:"locale",locale:o.locale,locales:r});return}t.categoryOf(o.id)!==void 0&&!t.reviewRequestLocalesOf(o.id).includes(o.locale)&&i.push({kind:"review-request-missing",opIndex:a,id:o.id,locale:o.locale});return}for(const s of _g(o,t)){const c=s.plain!==void 0,l=s.map!==void 0;if(c&&l){i.push({kind:"locale-texts-conflict",opIndex:a,id:s.id,field:s.mapField});continue}if(l&&s.condition!==void 0&&s.condition!==null){i.push({kind:"locale-texts-conflict",opIndex:a,id:s.id,field:s.conditionField});continue}if(!n){l&&i.push({kind:"locale-texts-not-enabled",opIndex:a,id:s.id,field:s.mapField});continue}if(c&&s.plain!==null){i.push({kind:"locale-texts-required",opIndex:a,id:s.id,field:s.plainField,locales:r});continue}if(s.condition!==void 0&&s.condition!==null){i.push({kind:"locale-texts-required",opIndex:a,id:s.id,field:s.conditionField,locales:r});continue}if(!l)continue;if(!Dp(s.map)){i.push({kind:"payload-invalid",opIndex:a,field:s.mapField});continue}const u=s.map;let p=!0;for(const[d,g]of Object.entries(u))typeof g!="string"||g===""?(i.push({kind:"payload-invalid",opIndex:a,field:`${s.mapField}.${d}`}),p=!1):r.includes(d)||(i.push({kind:"locale-not-in-document",opIndex:a,id:s.id,field:s.mapField,locale:d,locales:r}),p=!1);if(!p)continue;const f=r.filter(d=>!(d in u));f.length&&i.push({kind:"locale-texts-incomplete",opIndex:a,id:s.id,field:s.mapField,missing:f})}}),i}function hi(e,t,n){const i=t==="text"?"texts":"names",{[i]:r,...o}=e;return n===void 0?o:{...o,[t]:n}}function GR(e,t,n){const i=new Map;if(!n)return{ops:[...e],writes:i};const{designLocale:r}=n,o=c=>{let l=i.get(c);return l||i.set(c,l={}),l},a=c=>{if(Dp(c.map)){const l=c.map;return o(c.id).texts={...l},l[r]}if(c.plain===null||c.condition===null&&c.plain===void 0){o(c.id).texts=null;return}c.plain===void 0&&c.omittedMeansRemove&&(o(c.id).texts=null)},s=[];for(const c of e){if(c.kind==="translation.confirm"){const u=o(c.id);u.confirm=[...u.confirm??[],c.locale];continue}const l=_g(c,t);if(!l.length){s.push(c);continue}switch(c.kind){case"participant.add":{const[u,...p]=l,f=hi(c.participant,"name",a(u));c.participant.lanes&&(f.lanes=c.participant.lanes.map((d,g)=>hi(d,"name",a(p[g])))),s.push({...c,participant:f});break}case"participant.update":{const[u,...p]=l,f=hi(c,"name",a(u));c.lanes&&(f.lanes=c.lanes.map((d,g)=>hi(d,"name",a(p[g])))),s.push(f);break}case"node.add":s.push({...c,node:hi(c.node,"name",a(l[0]))});break;case"sequenceFlow.add":s.push({...c,flow:hi(c.flow,"name",a(l[0]))});break;case"messageFlow.add":s.push({...c,flow:hi(c.flow,"name",a(l[0]))});break;case"dataStore.add":s.push({...c,dataStore:hi(c.dataStore,"name",a(l[0]))});break;case"annotation.add":s.push({...c,annotation:hi(c.annotation,"text",a(l[0]))});break;case"group.add":s.push({...c,group:hi(c.group,"name",a(l[0]))});break;case"annotation.update":s.push(hi(c,"text",a(l[0])));break;default:s.push(Dp(l[0].map)?hi(c,"name",a(l[0])):(a(l[0]),c))}}return{ops:s,writes:i}}const VR=/^[\p{L}_][\p{L}\p{N}_.\-]*$/u,wg=new Set(["sequenceFlow","messageFlow","dataAssociation","association"]),Eg={"participant.add":[{path:"participant",shape:["id"]},{path:"participant.lanes[]",shape:["id"],optional:!0}],"participant.update":[{path:"id",shape:null},{path:"lanes[]",shape:["id"],optional:!0}],"node.add":[{path:"node",shape:["id","type"]}],"node.update":[{path:"id",shape:null}],"sequenceFlow.add":[{path:"flow",shape:["id","source","target"]}],"sequenceFlow.update":[{path:"id",shape:null}],"messageFlow.add":[{path:"flow",shape:["id","source","target"]}],"messageFlow.update":[{path:"id",shape:null}],"dataStore.add":[{path:"dataStore",shape:["id"]},{path:"associations[]",shape:["source","target"],optional:!0}],"dataStore.update":[{path:"id",shape:null}],"dataAssociation.add":[{path:"association",shape:["source","target"]}],"association.add":[{path:"association",shape:["source","target"]}],"annotation.add":[{path:"annotation",shape:["id"]},{path:"association",shape:["source","target"],optional:!0},{path:"placement",shape:["anchor","side"],optional:!0}],"annotation.update":[{path:"id",shape:null},{path:"placement",shape:["anchor","side"],optional:!0}],"group.add":[{path:"group",shape:["id"]},{path:"group.members[]",shape:null,optional:!0}],"group.update":[{path:"id",shape:null},{path:"members[]",shape:null,optional:!0}],"translation.confirm":[{path:"id",shape:null},{path:"locale",shape:null}],"element.remove":[{path:"id",shape:null}]},Ga=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Sc=e=>typeof e=="string"&&e!=="";function WR(e){const t=[];function n(i,r,o,a){if(a===null){Sc(o)||t.push({kind:"payload-invalid",opIndex:i,field:r});return}if(!Ga(o)){t.push({kind:"payload-invalid",opIndex:i,field:r});return}for(const s of a)Sc(o[s])||t.push({kind:"payload-invalid",opIndex:i,field:`${r}.${s}`})}return e.forEach((i,r)=>{var o,a,s;if(!Ga(i)||!Sc(i.kind)||!(i.kind in Eg)){t.push({kind:"payload-invalid",opIndex:r,field:"kind"});return}for(const c of Eg[i.kind]){const l=c.path.endsWith("[]"),u=l?c.path.slice(0,-2):c.path,p=u.split(".");let f=i;for(const g of p.slice(0,-1)){if(!Ga(f))break;f=f[g]}if(!Ga(f))continue;const d=f[p[p.length-1]];if(!(d===void 0&&c.optional)&&!(d===null&&c.optional)){if(!l){n(r,c.path,d,c.shape);continue}if(!Array.isArray(d)){t.push({kind:"payload-invalid",opIndex:r,field:c.path});continue}d.forEach((g,h)=>n(r,`${u}[${h}]`,g,c.shape))}}if(i.kind==="annotation.add"){const c=i.annotation;Ga(c)&&!Sc(c.text)&&c.texts===void 0&&t.push({kind:"payload-invalid",opIndex:r,field:"annotation.text"})}if(i.kind==="node.add"||i.kind==="node.update"){const c=i.band;c!==void 0&&(!Number.isInteger(c)||c<0)&&t.push({kind:"payload-invalid",opIndex:r,field:"band"});const l=i.kind==="node.add"?(o=i.node)==null?void 0:o.type:i.type,u=(i.kind==="node.add"?(a=i.node)==null?void 0:a.id:i.id)??"";if(typeof l=="string"&&!Yh(l)){t.push({kind:"node-type-unsupported",opIndex:r,id:u,type:l});return}const p=i.kind==="node.add"?(s=i.node)==null?void 0:s.eventDefinition:i.eventDefinition;if(p!==void 0&&!Kh(p)){t.push({kind:"payload-invalid",opIndex:r,field:i.kind==="node.add"?"node.eventDefinition":"eventDefinition"});return}l==="intermediateCatchEvent"!==(p!==void 0)&&t.push({kind:"event-definition-mismatch",opIndex:r,id:u,...typeof l=="string"?{type:l}:{},...p!==void 0?{eventDefinition:p}:{}})}}),t}function Sg(e,t,n={}){const i=WR(e);if(i.length>0)return i;const r=[],o=new Map,a=new Map;function s(h,y,C){if(!VR.test(y)){r.push({kind:"id-invalid",opIndex:h,id:y});return}if(t.categoryOf(y)!==void 0||o.has(y)){r.push({kind:"id-duplicate",opIndex:h,id:y});return}o.set(y,{...C,opIndex:h})}e.forEach((h,y)=>{var C;switch(h.kind){case"participant.add":s(y,h.participant.id,{category:"participant",lanes:(h.participant.lanes??[]).map(x=>x.id)});for(const x of h.participant.lanes??[])s(y,x.id,{category:"lane"});break;case"node.add":s(y,h.node.id,{category:"flowNode",participant:h.node.participant});break;case"sequenceFlow.add":s(y,h.flow.id,{category:"sequenceFlow"});break;case"messageFlow.add":s(y,h.flow.id,{category:"messageFlow"});break;case"dataStore.add":s(y,h.dataStore.id,{category:"dataStore"});for(const x of h.associations??[])x.id&&s(y,x.id,{category:"dataAssociation"});break;case"dataAssociation.add":h.association.id&&s(y,h.association.id,{category:"dataAssociation"});break;case"association.add":h.association.id&&s(y,h.association.id,{category:"association"});break;case"annotation.add":s(y,h.annotation.id,{category:"annotation"}),(C=h.association)!=null&&C.id&&s(y,h.association.id,{category:"association"});break;case"group.add":s(y,h.group.id,{category:"group"});break;case"participant.update":if(h.lanes){a.set(h.id,h.lanes.map(x=>x.id));for(const x of h.lanes)t.categoryOf(x.id)===void 0&&s(y,x.id,{category:"lane"})}break}});const c=h=>{var y;return((y=o.get(h))==null?void 0:y.category)??t.categoryOf(h)},l=h=>{const y=o.get(h);return y?y.category==="participant"?h:y.participant:t.categoryOf(h)==="participant"?h:t.participantOf(h)};function u(h,y,C,x){const m=c(y);if(m===void 0){r.push({kind:"ref-missing",opIndex:h,ref:y,role:C});return}if(x&&!x.includes(m)){r.push({kind:"ref-category",opIndex:h,ref:y,role:C,expected:x.join("|"),actual:m});return}return m}const p=t.isCollaboration()||e.some(h=>h.kind==="participant.add"),f=new Map;for(const h of e)h.kind==="node.add"?f.set(h.node.id,h.node.eventDefinition):h.kind==="node.update"&&h.type!==void 0&&f.set(h.id,h.eventDefinition);const d=h=>f.has(h)?f.get(h)==="timer":t.eventDefinitionOf(h)==="timer";return e.forEach((h,y)=>{var C;switch(h.kind){case"participant.add":break;case"node.add":{const{participant:x,lane:m}=h.node;if(x===void 0){(p||m!==void 0)&&r.push({kind:"participant-required",opIndex:y,id:h.node.id});break}if(u(y,x,"participant",["participant"])===void 0)break;m!==void 0&&((((C=o.get(x))==null?void 0:C.lanes)??a.get(x)??t.lanesOf(x)).includes(m)||r.push({kind:"lane-unknown",opIndex:y,lane:m,participant:x}));break}case"sequenceFlow.add":{const{id:x,source:m,target:v,name:_,condition:E}=h.flow,T=u(y,m,"source",["flowNode"]),O=u(y,v,"target",["flowNode"]);T&&O&&l(m)!==l(v)&&r.push({kind:"flow-cross-pool",opIndex:y,id:x}),_!==void 0&&E!==void 0&&r.push({kind:"condition-name-conflict",opIndex:y,id:x});break}case"messageFlow.add":{const{id:x,source:m,target:v}=h.flow,_=u(y,m,"source",["flowNode","participant"]),E=u(y,v,"target",["flowNode","participant"]);if(_&&E){const T=l(m),O=l(v);T!==void 0&&T===O&&r.push({kind:"message-flow-same-pool",opIndex:y,id:x})}for(const T of[m,v])d(T)&&r.push({kind:"message-flow-timer-endpoint",opIndex:y,id:x,ref:T});break}case"dataStore.add":{for(const x of h.associations??[]){if([x.source,x.target].filter(_=>_===h.dataStore.id).length!==1){r.push({kind:"data-association-ends",opIndex:y,source:x.source,target:x.target});continue}const v=x.source===h.dataStore.id?x.target:x.source;u(y,v,"dataAssociation",["flowNode"])}break}case"dataAssociation.add":{const{source:x,target:m}=h.association,v=u(y,x,"source"),_=u(y,m,"target");if(v&&_){const E=new Set([v,_]);E.has("dataStore")&&E.has("flowNode")||r.push({kind:"data-association-ends",opIndex:y,source:x,target:m})}break}case"association.add":{const{id:x,source:m,target:v}=h.association,_=u(y,m,"source"),E=u(y,v,"target");_&&E&&_!=="annotation"&&E!=="annotation"&&r.push({kind:"association-detached",opIndex:y,annotation:x??`${m}->${v}`});break}case"annotation.add":{if(h.association){const{source:x,target:m}=h.association;if(x!==h.annotation.id&&m!==h.annotation.id)r.push({kind:"association-detached",opIndex:y,annotation:h.annotation.id});else{const v=x===h.annotation.id?m:x;u(y,v,"association")}}h.placement&&u(y,h.placement.anchor,"anchor");break}case"group.add":{for(const x of h.group.members??[]){const m=u(y,x,"member");m&&wg.has(m)&&r.push({kind:"ref-category",opIndex:y,ref:x,role:"member",expected:"shape",actual:m})}break}case"participant.update":{if(g(y,h.id,"participant")===void 0)break;if(h.lanes){const x=t.lanesOf(h.id),m=h.lanes.map(_=>_.id);for(const _ of x)m.includes(_)||r.push({kind:"lane-shrink-unsupported",opIndex:y,participant:h.id,lane:_});for(const _ of m)t.categoryOf(_)!==void 0&&!x.includes(_)&&r.push({kind:"id-duplicate",opIndex:y,id:_});const v=m.filter(_=>x.includes(_));v.length===x.length&&v.some((_,E)=>_!==x[E])&&r.push({kind:"lane-reorder-unsupported",opIndex:y,participant:h.id})}break}case"node.update":{if(g(y,h.id,"flowNode")===void 0)break;if(h.lane!==void 0){const x=t.participantOf(h.id);(x?a.get(x)??t.lanesOf(x):[]).includes(h.lane)||r.push({kind:"lane-unknown",opIndex:y,lane:h.lane,participant:x??""})}break}case"sequenceFlow.update":{if(g(y,h.id,"sequenceFlow")===void 0)break;if(h.name!==void 0&&h.condition!==void 0&&r.push({kind:"condition-name-conflict",opIndex:y,id:h.id}),h.source!==void 0||h.target!==void 0){const x=h.source===void 0||u(y,h.source,"source",["flowNode"])!==void 0,m=h.target===void 0||u(y,h.target,"target",["flowNode"])!==void 0,v=t.endpointsOf(h.id),_=h.source??(v==null?void 0:v.source),E=h.target??(v==null?void 0:v.target);x&&m&&_!==void 0&&E!==void 0&&new Set([l(_),l(E),l(h.id)]).size>1&&r.push({kind:"flow-cross-pool",opIndex:y,id:h.id})}break}case"messageFlow.update":g(y,h.id,"messageFlow");break;case"dataStore.update":g(y,h.id,"dataStore");break;case"annotation.update":{if(g(y,h.id,"annotation")===void 0)break;h.placement&&u(y,h.placement.anchor,"anchor");break}case"group.update":{if(g(y,h.id,"group")===void 0)break;for(const x of h.members??[]){const m=u(y,x,"member");m&&wg.has(m)&&r.push({kind:"ref-category",opIndex:y,ref:x,role:"member",expected:"shape",actual:m})}break}case"translation.confirm":g(y,h.id);break;case"element.remove":{g(y,h.id)==="lane"&&r.push({kind:"ref-category",opIndex:y,ref:h.id,role:"target",expected:"removable",actual:"lane"});break}}}),r.push(...zR(e,t,n.i18n)),r;function g(h,y,C){if(o.has(y)){r.push({kind:"target-added-in-batch",opIndex:h,id:y});return}const x=t.categoryOf(y);if(x===void 0){r.push({kind:"ref-missing",opIndex:h,ref:y,role:"target"});return}if(C&&x!==C){r.push({kind:"ref-category",opIndex:h,ref:y,role:"target",expected:C,actual:x});return}return x}}function Rg(e){return{modeling:e.get("modeling"),bpmnFactory:e.get("bpmnFactory"),elementFactory:e.get("elementFactory"),elementRegistry:e.get("elementRegistry"),canvas:e.get("canvas"),autoPlace:e.get("autoPlace"),bpmnReplace:e.get("bpmnReplace"),spaceTool:e.get("spaceTool")}}function Rc(e){return`bpmn:${e[0].toUpperCase()}${e.slice(1)}`}const Cc={"top-left":[-1,-1],top:[0,-1],"top-right":[1,-1],right:[1,0],"bottom-right":[1,1],bottom:[0,1],"bottom-left":[-1,1],left:[-1,0]},Rn=10,UR=300,qR=160,Cg=20,Lp=100,Mg=40,YR=10;function Ip(e,t,n,i,r){const o=n,a=(P,D)=>{const[F,J]=Cc[P];let ge={x:t.x+t.width/2+F*(t.width/2+o.width/2+D),y:t.y+t.height/2+J*(t.height/2+o.height/2+D)};const Ae=i.x+Rn+o.width/2,De=i.x+i.width-Rn-o.width/2,qe=i.y+Rn+o.height/2,rt=i.y+i.height-Rn-o.height/2,Me={x:Math.min(De,Math.max(Ae,ge.x)),y:Math.min(rt,Math.max(qe,ge.y))};return(Me.x!==ge.x||Me.y!==ge.y)&&(ge=Math.abs(Me.x-(t.x+t.width/2))<(t.width+o.width)/2+Rn&&Math.abs(Me.y-(t.y+t.height/2))<(t.height+o.height)/2+Rn?{x:t.x+t.width+Rn+o.width/2,y:Me.y}:Me),ge},s=(i.children??[]).filter(P=>!("waypoints"in P&&P.waypoints)&&P.type!=="bpmn:Lane"&&P.type!=="label"&&typeof P.x=="number"&&P.id!==r.selfId),c=Ze(e),l=P=>{var F,J;if(!r.selfId)return!1;const D=e.get(P);return!!D&&(((F=D.source)==null?void 0:F.id)===r.selfId||((J=D.target)==null?void 0:J.id)===r.selfId)},u=c.edges.filter(P=>!l(P.id)).flatMap(gn),p=co(c).filter(P=>P.owner!==r.selfId).map(P=>P.rect),f=P=>({x0:P.x-o.width/2-Rn,x1:P.x+o.width/2+Rn,y0:P.y-o.height/2-Rn,y1:P.y+o.height/2+Rn}),d=P=>{const D=f(P);return s.some(F=>D.x0<F.x+F.width&&D.x1>F.x&&D.y0<F.y+F.height&&D.y1>F.y)},g=P=>{const D=f(P);return u.some(F=>F.axis==="h"?F.at>D.y0&&F.at<D.y1&&F.lo<D.x1&&F.hi>D.x0:F.at>D.x0&&F.at<D.x1&&F.lo<D.y1&&F.hi>D.y0)},h=P=>{const D=f(P);return p.some(F=>D.x0<F.x+F.width&&D.x1>F.x&&D.y0<F.y+F.height&&D.y1>F.y)},y=c.shapes.filter(P=>P.type==="bpmn:Group").flatMap(P=>[{axis:"h",at:P.y,lo:P.x,hi:P.x+P.width},{axis:"h",at:P.y+P.height,lo:P.x,hi:P.x+P.width},{axis:"v",at:P.x,lo:P.y,hi:P.y+P.height},{axis:"v",at:P.x+P.width,lo:P.y,hi:P.y+P.height}]),C=P=>{const D=f(P);return y.some(F=>F.axis==="h"?F.at>D.y0&&F.at<D.y1&&F.lo<D.x1&&F.hi>D.x0:F.at>D.x0&&F.at<D.x1&&F.lo<D.y1&&F.hi>D.y0)},x=P=>d(P)||g(P)||h(P)||C(P),m=P=>P.x-o.width/2>=i.x&&P.x+o.width/2<=i.x+i.width&&P.y-o.height/2>=i.y&&P.y+o.height/2<=i.y+i.height;if(r.placement){const P=De=>De.startsWith("top")?De.replace(/^top/,"bottom"):De.replace(/^bottom/,"top"),D=De=>De.endsWith("left")?De.replace(/left$/,"right"):De.replace(/right$/,"left"),F=r.placement.side,J=[F,P(F),D(F),P(D(F)),"top","bottom","left","right","top-left","top-right","bottom-left","bottom-right"],ge=r.placement.offset??50;let Ae=a(F,ge);if(x(Ae)){const De=new Set;for(const qe of J){if(De.has(qe))continue;De.add(qe);const rt=a(qe,ge);if(m(rt)&&!x(rt)){Ae=rt;break}}}return Ae}const v=r.from,_=i.x+Rn+o.width/2,E=i.x+i.width-Rn-o.width/2,T=i.y+Rn+o.height/2,O=i.y+i.height-Rn-o.height/2;let N={x:Math.min(E,Math.max(_,v.x)),y:Math.min(O,Math.max(T,v.y))};if(x(N)){const P=(t.width+o.width)/2+Rn,F=[{x:N.x+P,y:N.y},{x:N.x-P,y:N.y},{x:N.x,y:N.y-o.height-Rn},{x:N.x,y:N.y+o.height+Rn}].filter(m).find(J=>!x(J));F&&(N=F)}return N}function Kt(e,t){return e.filter(n=>n.kind===t)}class Ag extends Error{constructor(t){super(t.kind),this.issue=t,this.name="LowerIssueError"}}function Pg(e,t){var AE,PE,TE,kE,OE,DE,LE,IE,BE,NE,$E,FE,jE,HE,zE,GE,VE,WE,UE,qE,YE,KE,XE;const{modeling:n,bpmnFactory:i,elementFactory:r,elementRegistry:o,canvas:a,autoPlace:s,bpmnReplace:c,spaceTool:l}=t,u=()=>a.getRootElement(),p=b=>o.get(b),f=b=>{const S=p(b);if(!S)throw new Error(`하강 참조 해소 실패: ${b}`);return S},d=b=>{let S=b.parent;for(;S;){if(S.type==="bpmn:Participant")return S;S=S.parent}},g=new Map;for(const b of o.filter(S=>!("waypoints"in S&&S.waypoints)&&S.type!=="bpmn:Lane"&&S.type!=="label"&&typeof S.x=="number"))g.set(b.id,{x:b.x,y:b.y});const h=Kt(e,"participant.add"),y=Kt(e,"node.add"),C=Kt(e,"sequenceFlow.add"),x=Kt(e,"messageFlow.add"),m=Kt(e,"dataStore.add"),v=Kt(e,"dataAssociation.add"),_=Kt(e,"annotation.add"),E=Kt(e,"group.add"),T=new Map(y.map(b=>[b.node.id,b])),O=(b,S,A)=>{var j;const k=b.businessObject,I=(((j=k.extensionElements)==null?void 0:j.values)??[]).filter(B=>B.$type!==S),L=A?[...I,i.create(S,A)]:I;if(!L.length){k.extensionElements&&n.updateProperties(b,{extensionElements:void 0});return}const H=i.create("bpmn:ExtensionElements",{values:L});L.forEach(B=>{B.$parent=H}),n.updateProperties(b,{extensionElements:H})},N=b=>({anchor:b.anchor,side:b.side,...b.offset!==void 0?{offset:b.offset}:{}});for(const b of Kt(e,"element.remove")){const S=p(b.id);S&&n.removeElements([S])}const P=b=>o.filter(S=>{var A;return S.type==="bpmn:Lane"&&((A=d(S))==null?void 0:A.id)===b}).sort((S,A)=>S.y-A.y);for(const b of Kt(e,"participant.update")){const S=f(b.id);if(b.name!==void 0&&n.updateProperties(S,{name:b.name??void 0}),!b.lanes)continue;const A=P(b.id);if(!A.length){n.splitLane(S,b.lanes.length),P(b.id).forEach((I,L)=>{const H=b.lanes[L];H&&n.updateProperties(I,{id:H.id,name:H.name})});continue}const k=new Set(A.map(I=>I.id));b.lanes.forEach((I,L)=>{if(k.has(I.id)){n.updateProperties(f(I.id),{name:I.name});return}const H=L===0?n.addLane(P(b.id)[0],"top"):n.addLane(f(b.lanes[L-1].id),"bottom");n.updateProperties(H,{id:I.id,name:I.name})})}const D=150,F=130,J=80,ge=90,Ae=180,De=30,qe=30,rt=(b,S,A,k,I)=>{const L=A-S.width/2,H=k-S.height/2;return(b.children??[]).find(j=>!("waypoints"in j&&j.waypoints)&&j.type!=="bpmn:Lane"&&j.type!=="label"&&!(I!=null&&I.has(j.id))&&typeof j.x=="number"&&L<j.x+j.width+qe&&L+S.width+qe>j.x&&H<j.y+j.height&&H+S.height>j.y)},Me=new Set;for(const b of h){Me.add(`pool:${b.participant.id}`);for(const S of b.participant.lanes??[])Me.add(S.id)}const X=new Map;for(const b of y){const S=b.node.lane??`pool:${b.node.participant??""}`;let A=X.get(S);A||X.set(S,A=new Set([0])),b.band!==void 0&&A.add(b.band)}const ne=new Map;for(const[b,S]of X){if(!Me.has(b))continue;const A=[...S].sort((L,H)=>L-H),k=A.map((L,H)=>H===0?0:H%2===1?Math.ceil(H/2):-(H/2)),I=Math.min(...k);ne.set(b,new Map(A.map((L,H)=>[L,k[H]-I])))}{const b=new Map;for(const S of h)(S.participant.lanes??[]).forEach((A,k)=>b.set(A.id,k));for(const[S,A]of ne){if(!b.has(S)||A.size<2)continue;const k=b.get(S),I=A.get(0)??0,L=new Set;for(const ee of y){if(ee.node.lane!==S||(ee.band??0)!==0||!ee.node.type.endsWith("Gateway"))continue;const de={in:new Set,out:new Set,cross:new Set};for(const pe of C){const me=pe.flow.source===ee.node.id;if(!me&&pe.flow.target!==ee.node.id)continue;const Ye=T.get(me?pe.flow.target:pe.flow.source);if(!Ye||Ye.node.participant!==ee.node.participant||!Ye.node.lane)continue;let Ce,Q=!1;if(Ye.node.lane!==S){const ie=b.get(Ye.node.lane);if(ie===void 0)continue;Ce=ie>k?"down":"up",Q=!0}else{const ie=A.get(Ye.band??0)??I;Ce=ie>I?"down":ie<I?"up":void 0}Ce&&(de[me?"out":"in"].add(Ce),Q&&de.cross.add(Ce))}for(const pe of["up","down"])de.in.has(pe)&&de.out.has(pe)&&de.cross.has(pe)&&L.add(pe)}if(L.size!==1)continue;const[H]=L,j=Math.max(...A.values()),B=H==="down"?j:0;if(I===B)continue;const W=[...A.entries()].filter(([ee])=>ee!==0).sort((ee,de)=>ee[1]-de[1]),Y=[...Array(j+1).keys()].filter(ee=>ee!==B),ae=new Map([[0,B]]);W.forEach(([ee],de)=>ae.set(ee,Y[de])),ne.set(S,ae)}}const q=b=>{var S;return(((S=X.get(b))==null?void 0:S.size)??0)>1},K=b=>b.band??(b.node.lane||!q(`pool:${b.node.participant??""}`)?void 0:0),oe=new Map,fe=b=>oe.get(b.node.id)??K(b),Te=new Set,$=new Set;{const b=new Map;for(const k of C)b.set(k.flow.target,(b.get(k.flow.target)??0)+1);const S=k=>{const I=[],L=new Set([k]),H=[k];for(;H.length;){const j=H.shift();I.push(j);for(const B of C)B.flow.source!==j||L.has(B.flow.target)||(b.get(B.flow.target)??0)!==1||(L.add(B.flow.target),H.push(B.flow.target))}return I},A=(k,I)=>{var L;return((L=ne.get(k))==null?void 0:L.get(I))??I};for(const k of y){if(!k.node.type.endsWith("Gateway"))continue;const I=k.node.lane??`pool:${k.node.participant??""}`,L=ne.get(I);if(!L||L.size<2)continue;const H=fe(k);if(H===void 0||A(I,H)!==A(I,0))continue;const j=A(I,H),B=C.filter(pe=>pe.flow.source===k.node.id).map(pe=>T.get(pe.flow.target)).filter(pe=>!!pe&&(pe.node.lane??`pool:${pe.node.participant??""}`)===I),W=B.filter(pe=>{const me=fe(pe);return me!==void 0&&A(I,me)===j&&(b.get(pe.node.id)??0)===1}),Y=B.some(pe=>{const me=fe(pe);return me!==void 0&&A(I,me)>j});if(W.length!==1||!Y)continue;const ae=new Set(B.flatMap(pe=>S(pe.node.id)));if(!C.some(pe=>pe.flow.target===k.node.id&&ae.has(pe.flow.source)))continue;const de=new Map;for(const[pe,me]of L)de.set(pe,me+1);de.set(-1,0),ne.set(I,de);for(const pe of S(W[0].node.id))T.has(pe)&&(oe.set(pe,-1),$.add(pe));Te.add(k.node.id)}}const R=(b,S)=>{var A;return((A=ne.get(b))==null?void 0:A.get(S))??S},w=(b,S,A,k)=>{const I=b?p(b):S?p(S):void 0;if(!I)return!1;const L=b?I.y+Math.min(I.height/2,ge):I.y+J;return Math.abs(L+R(b??`pool:${S??""}`,A)*D-k)<=D/2},G=new Map;for(const[b,S]of X){let A=0;for(const k of S)A=Math.max(A,R(b,k));G.set(b,A)}const V=b=>Ae+D*b,te=(b,S,A)=>{const k=u().children.filter(I=>!("waypoints"in I&&I.waypoints)&&I.type!=="label"&&I.id!==S&&typeof I.y=="number"&&I.y>=b);k.length&&n.moveElements(k,{x:0,y:A})},Re=(b,S,A)=>{const k=b.type==="bpmn:Participant"?b:void 0;if(!k||k.children.some(j=>j.type==="bpmn:Lane"))return;const I=A+S.height/2+De-k.y;if(k.height>=I)return;const L=I-k.height,H=k.y+k.height;n.resizeShape(k,{x:k.x,y:k.y,width:k.width,height:I}),te(H,k.id,L)},Qe=(b,S)=>{const A=S-b.height;if(A<=0)return;const k=d(b)??b,I=[],L=B=>{I.push(B);for(const W of B.children??[])L(W)};L(k);const H=b.y+b.height-10,j=l.calculateAdjustments(I,"y",A,H);l.makeSpace(j.movingShapes,j.resizingShapes,{x:0,y:A},"s",H)},ht=(b,S,A)=>{if(b){const H=f(b),j=V(S);if(H.height>=j)return;const B=j-H.height,W=d(H),Y=W?W.y+W.height:H.y+H.height;Qe(H,j),te(Y,W==null?void 0:W.id,B);return}if(!A)return;const k=D*(S+1);if(A.height>=k)return;const I=k-A.height,L=A.y+A.height;n.resizeShape(A,{x:A.x,y:A.y,width:A.width,height:k}),te(L,A.id,I)},Wt=new Map;for(const b of C)Wt.set(b.flow.target,(Wt.get(b.flow.target)??0)+1);const xt=b=>(Wt.get(b)??0)<=1,dn=new Set(y.map(b=>b.node.id).filter(b=>Kt(e,"sequenceFlow.update").filter(S=>S.target===b).length===1&&!C.some(S=>S.flow.target===b||S.flow.source===b&&T.has(S.flow.target)))),wn=new Map,jn=(b,S)=>{if(!b)return;const A=p(b);if(!A||A.height>=V(S))return;const k=A.y+A.height-10,I=d(A);if(I)return new Set((I.children??[]).filter(L=>L.type!=="bpmn:Lane"&&typeof L.y=="number"&&L.y>k).map(L=>L.id))},Ct=(b,S,A)=>{if(!b)return!0;const k=p(b);return k?A-S.height/2>=k.y&&A+S.height/2<=k.y+k.height:!0},Yt=h.map((b,S)=>({op:b,declared:S}));Yt.sort((b,S)=>{const A=b.op.order??Number.POSITIVE_INFINITY,k=S.op.order??Number.POSITIVE_INFINITY;return A!==k?A-k:b.declared-S.declared});let vn=80;for(const b of o.getAll())b.parent===u()&&"height"in b&&typeof b.y=="number"&&(vn=Math.max(vn,b.y+b.height+60));for(const{op:b}of Yt){const S=b.participant,A=y.filter(ee=>ee.node.participant===S.id).length,k=((AE=S.lanes)==null?void 0:AE.length)??0,I=Math.max(1200,A*160+300),L=(S.lanes??[]).map(ee=>V(G.get(ee.id)??0)),H=L.reduce((ee,de)=>ee+de,0);k&&H<300&&(L[k-1]+=300-H);const j=Math.max(300,D*((G.get(`pool:${S.id}`)??0)+1)),B=S.blackBox||A+k===0?120:k?Math.max(300,H):j,W=r.createShape({type:"bpmn:Participant",businessObject:i.create("bpmn:Participant",{id:S.id,name:S.name,...b.order!==void 0?{"bwl:poolOrder":b.order}:{},...S.blackBox?{}:{processRef:i.create("bpmn:Process")}}),width:I,height:B,isExpanded:!0}),Y=n.createShape(W,{x:100+I/2,y:vn+B/2},u()),ae=S.lanes??[];if(ae.length&&n.splitLane(Y,ae.length),ae.length){const ee=o.filter(de=>{var pe;return de.type==="bpmn:Lane"&&((pe=d(de))==null?void 0:pe.id)===S.id}).sort((de,pe)=>de.y-pe.y);if(ee.forEach((de,pe)=>{const me=ae[pe];me&&n.updateProperties(de,{id:me.id,name:me.name})}),L.some(de=>de!==Y.height/k)){let de=Y.y;ee.forEach((pe,me)=>{const Ye=L[me];n.resizeShape(pe,{x:pe.x,y:de,width:pe.width,height:Ye}),de+=Ye})}}vn=Y.y+Y.height+60}const ka=b=>{var k;const S=T.get(b);if(S)return S.node.participant??"";const A=p(b);return A?A.type==="bpmn:Participant"?A.id:((k=d(A))==null?void 0:k.id)??"":""},Hn=new Map,Di=b=>{let S=Hn.get(b);return S||Hn.set(b,S={nodes:[],flows:[]}),S};for(const b of y)Di(b.node.participant??"").nodes.push(b);for(const b of C)Di(ka(b.flow.source)).flows.push(b);const ri=b=>{var S;return i.create("bpmn:SequenceFlow",{id:b.id,name:b.name??((S=b.condition)==null?void 0:S.label)})},Zt=(b,S,A)=>r.createShape({type:Rc(b.type),...b.eventDefinition?{eventDefinitionType:ec[b.eventDefinition]}:{},businessObject:i.create(Rc(b.type),{id:b.id,name:b.name,...S!==void 0?{"bwl:band":S}:{},...A!==void 0?{"bwl:afterColumn":A}:{}})}),Mo=[...Yt.map(({op:b})=>b.participant.id).filter(b=>Hn.has(b)),...[...Hn.keys()].filter(b=>!h.some(S=>S.participant.id===b))],Oa=b=>b.endsWith("Gateway");for(const b of Mo){const S=Hn.get(b),A=b?f(b):void 0,k=A?A.x+150:250;let I=A?A.y+80:120;const L=(Q,ie,se)=>{if(Q){const ve=f(Q);return ve.y+Math.min(ve.height/2,ge)+R(Q,ie??0)*D}return ie!==void 0&&A?A.y+J+R(`pool:${b}`,ie)*D:se},H=(Q,ie,se)=>{if(Q){const ve=f(Q);return ve.y+Math.min(ve.height/2,ge)+ie*D}return A?A.y+J+ie*D:se},j=Q=>Q.participant?f(Q.participant):u(),B=(Q,ie,se,ve,et,Ve,gt,Tt)=>{const xe=se!==void 0||ve!==void 0,be=Be=>{const we=()=>ht(se,Be,A);Tt?Tt(we):we()},re=R(se??`pool:${b}`,ve??0);if((ve===void 0||w(se,b,ve,gt??Number.NaN))&&gt!==void 0&&Ct(se,ie,gt)&&!rt(Q,ie,et,gt))return{x:et,y:gt};if(xe)for(let Be=0;Be<4;Be++){const we=H(se,re+Be,Ve);if(!rt(Q,ie,et,we,jn(se,re+Be)))return be(re+Be),{x:et,y:we}}const ye=L(se,ve,Ve);xe?be(re):Tt?Tt(()=>Re(Q,ie,ie.y+ie.height/2)):Re(Q,ie,ye);let Ie=et;for(let Be=0;Be<64;Be++){const we=rt(Q,ie,Ie,ye);if(!we)break;Ie=we.x+we.width+F+ie.width/2}return{x:Ie,y:ye}},W=new Set(S.flows.map(Q=>Q.flow.target)),Y=new Map,ae=Q=>{if(Q===void 0)return;const ie=o.get(Q);if(!(!ie||typeof ie.x!="number"||typeof ie.width!="number"))return ie.x+ie.width+F};for(const Q of S.nodes){if(W.has(Q.node.id))continue;const ie=Zt(Q.node,Q.band,Q.afterColumn),se=K(Q),ve=Q.node.lane?`${Q.node.lane}|${se??""}`:se!==void 0?`band:${se}`:"",et=j(Q.node),Ve=Y.get(ve)??k,gt=ae(Q.afterColumn),Tt=gt===void 0?Ve:Math.max(Ve,gt);let xe;const be=B(et,ie,Q.node.lane,se,Tt,I,void 0,dn.has(Q.node.id)&&Q.node.participant!==void 0?re=>xe=re:void 0);if(xe?n.createShape(ie,be,et,{autoResize:!1}):n.createShape(ie,be,et),xe){const re=Q.node.lane?f(Q.node.lane):et;wn.set(Q.node.id,{container:re,relCy:be.y-re.y,grow:xe})}Y.set(ve,be.x+ie.width+F),!Q.node.lane&&se===void 0&&(I+=160)}const ee=new Set,de=new Map,pe=new Map,me=new Map;if(b&&Me.has(`pool:${b}`)){const Q=new Map;for(const xe of S.flows)Q.set(xe.flow.target,(Q.get(xe.flow.target)??0)+1);const ie=xe=>L(xe.node.lane,fe(xe),Number.NaN),se=new Set,ve=xe=>{var ye;const be=(ye=T.get(xe))==null?void 0:ye.node.participant;if(be)return p(be);const re=p(xe);if(re)return re.type==="bpmn:Participant"?re:d(re)},et=xe=>{const be=[],re=new Set([xe]),ye=[xe];for(;ye.length;){const Ie=ye.shift(),Be=T.get(Ie);Be&&be.push(Be);for(const we of S.flows)we.flow.source!==Ie||re.has(we.flow.target)||(Q.get(we.flow.target)??0)!==1||(re.add(we.flow.target),ye.push(we.flow.target))}return be},Ve=xe=>{if(!A)return;const be=new Set(xe.map(Ie=>Ie.node.id));let re=!1,ye=!1;for(const Ie of x){if(!be.has(Ie.flow.source))continue;const Be=ve(Ie.flow.target);!Be||Be.id===A.id||(Be.y<A.y?re=!0:ye=!0)}return re&&!ye?"up":ye&&!re?"down":void 0};for(const xe of S.nodes){if(!Oa(xe.node.type))continue;const be=L(xe.node.lane,K(xe),Number.NaN);if(Number.isNaN(be))continue;const re=[];for(const we of S.flows){if(we.flow.source!==xe.node.id)continue;const ot=T.get(we.flow.target);if(!ot||ot.node.lane!==xe.node.lane||(Q.get(ot.node.id)??0)!==1)continue;const Ke=K(ot);if(Ke===void 0)continue;const Mt=L(ot.node.lane,Ke,Number.NaN);if(Number.isNaN(Mt))continue;const Pe=et(ot.node.id),ke=Ve(Pe);ke&&re.push({subtree:Pe,band:Ke,row:Mt,dir:ke})}if(!re.some(we=>we.dir==="up")||!re.some(we=>we.dir==="down")||!re.some(we=>we.dir==="up"&&re.some(ot=>ot.dir==="down"&&ot.row<we.row)))continue;const Ie=[...re].sort((we,ot)=>we.row-ot.row);[...re.filter(we=>we.dir==="up"),...re.filter(we=>we.dir==="down")].sort((we,ot)=>we.dir===ot.dir?we.row-ot.row:we.dir==="up"?-1:1).forEach((we,ot)=>{const Ke=Ie[ot].band;if(Ke!==we.band){se.add(xe.node.id);for(const Mt of we.subtree)K(Mt)===we.band&&oe.set(Mt.node.id,Ke)}})}const gt=xe=>{if(!A)return;const be=new Set(xe.map(Ie=>Ie.node.id));let re=!1,ye=!1;for(const Ie of x){if(!be.has(Ie.flow.target))continue;const Be=ve(Ie.flow.source);!Be||Be.id===A.id||(Be.y<A.y?re=!0:ye=!0)}return re&&!ye?"up":ye&&!re?"down":void 0};for(const xe of S.nodes){if(!Oa(xe.node.type))continue;const be=xe.node.lane??`pool:${b}`,re=ne.get(be);if(!re||re.size<2)continue;const ye=re.get(0);if(ye===void 0)continue;const Ie=Math.max(...re.values()),Be=ye===Ie&&ye!==0?"down":void 0;if(!Be)continue;const we=[];for(const ke of S.flows){if(ke.flow.source!==xe.node.id)continue;const Xe=T.get(ke.flow.target);if(!Xe||Xe.node.lane!==xe.node.lane||(Q.get(Xe.node.id)??0)!==1)continue;const bn=fe(Xe);bn!==void 0&&we.push({t:Xe,subtree:et(Xe.node.id),band:bn})}const ot=we.find(ke=>(re.get(ke.band)??ke.band)===ye);if(!ot||gt(ot.subtree)===Be||Ve(ot.subtree)===Be)continue;const Ke=we.find(ke=>ke!==ot&&gt(ke.subtree)===Be);if(!Ke)continue;const Mt=ot.band,Pe=Ke.band;for(const ke of ot.subtree)fe(ke)===Mt&&oe.set(ke.node.id,Pe);for(const ke of Ke.subtree)fe(ke)===Pe&&oe.set(ke.node.id,Mt);se.add(xe.node.id)}for(const xe of S.nodes){if(!Oa(xe.node.type))continue;const be=ie(xe);if(Number.isNaN(be)||_.some(we=>{var ot,Ke;return(((ot=we.placement)==null?void 0:ot.anchor)??(we.association?we.association.source===we.annotation.id?we.association.target:we.association.source:void 0))===xe.node.id&&((Ke=we.placement)==null?void 0:Ke.side.startsWith("bottom"))}))continue;let ye,Ie=!1,Be;for(const we of S.flows){if(we.flow.source!==xe.node.id)continue;const ot=T.get(we.flow.target);if(!ot||!ot.node.lane&&K(ot)===void 0)continue;const Ke=ie(ot);Number.isNaN(Ke)||(Math.abs(Ke-be)<.5&&(Ie=!0),Ke>be?!ye||Ke>ye.row?ye={id:ot.node.id,row:Ke,count:1}:Ke===ye.row&&ye.count++:Ke<be&&ot.node.lane===xe.node.lane&&(!Be||Ke>Be.row?Be={op:ot,row:Ke,count:1}:Ke===Be.row&&Be.count++))}ye&&ye.count===1&&(Q.get(ye.id)??0)===1&&!se.has(xe.node.id)&&ee.add(ye.id),!Ie&&Be&&Be.count===1&&(Q.get(Be.op.node.id)??0)===1&&!Te.has(xe.node.id)&&de.set(Be.op.node.id,{lane:xe.node.lane,band:fe(xe)})}const Tt=new Map;for(const xe of x)Tt.set(xe.flow.target,[...Tt.get(xe.flow.target)??[],xe]);for(const xe of S.nodes){const be=Tt.get(xe.node.id);if(!be||be.length!==1||!Q.get(xe.node.id)||!xe.node.lane&&K(xe)===void 0||$.has(xe.node.id))continue;const re=(PE=T.get(be[0].flow.source))==null?void 0:PE.node.participant,ye=re?p(re):void 0;if(!ye||!A||ye.id===A.id)continue;const Ie=xe.node.lane??`pool:${b}`,Be=ne.get(Ie);if(!Be)continue;const we=Be.get(0)??0,ot=(Be.get(fe(xe)??0)??we)-we;if(ot===0)continue;const Ke=ye.y<A.y;if(Ke&&ot<0||!Ke&&ot>0)continue;let Mt;for(const[Pe,ke]of Be){const Xe=ke-we;(Ke&&Xe<0&&(!Mt||Xe<Mt.row)||!Ke&&Xe>0&&(!Mt||Xe>Mt.row))&&(Mt={band:Pe,row:Xe})}Mt&&pe.set(xe.node.id,{lane:xe.node.lane,band:Mt.band})}}const Ye=new Set;let Ce=0;for(;Ce++<S.nodes.length+2;){for(let se=0;se<S.nodes.length+S.flows.length+2;se++){let ve=!1;for(const et of S.flows){const Ve=et.flow;if(Ye.has(Ve.id))continue;const gt=p(Ve.source);if(!gt)continue;const Tt=p(Ve.target),xe=T.get(Ve.target);if(!Tt&&xe){const be=Zt(xe.node,xe.band),re=fe(xe);if(xe.node.lane||re!==void 0){const ye=j(xe.node),Ie=gt,Be=Ie.x+(me.get(Ve.source)??0)+Ie.width+F,we=de.get(Ve.target)??pe.get(Ve.target),ot=B(ye,be,we?we.lane:xe.node.lane,we?we.band:re,ee.has(Ve.target)?Ie.x+Ie.width/2:Be,Number.NaN,we||!xt(Ve.target)?void 0:Ie.y+Ie.height/2),Ke=n.createShape(be,ot,ye);ee.has(Ve.target)&&me.set(Ve.target,Be-(Ke.x+Ke.width/2)),n.connect(gt,Ke,{type:"bpmn:SequenceFlow",businessObject:ri(Ve)})}else s.append(gt,be,{connection:{type:"bpmn:SequenceFlow",businessObject:ri(Ve)}})}else if(Tt)n.connect(gt,Tt,{type:"bpmn:SequenceFlow",businessObject:ri(Ve)});else continue;Ye.add(Ve.id),ve=!0}if(!ve)break}const Q=S.nodes.filter(se=>!p(se.node.id));if(!Q.length)break;const ie=Q[0];{const se=Zt(ie.node,ie.band),ve=j(ie.node),et=K(ie);n.createShape(se,B(ve,se,ie.node.lane,et,k,I),ve),!ie.node.lane&&et===void 0&&(I+=160)}}}const Tn=40,pt=b=>{const S=Y=>Y.kind==="label-over-line"||Y.kind==="label-over-shape"||Y.kind==="label-on-shared-segment"?Y.edge===b.id:Y.kind==="annotation-over-label"||Y.kind==="pool-name-over-label"?Y.label===b.id:!1,A=()=>new Set(dt(Ze(o)).filter(Y=>!S(Y)).map(Y=>lt(Y))),k=A(),I=b.waypoints.map(Y=>({x:Y.x,y:Y.y})),L=b.label,H=L&&{x:L.x,y:L.y};n.layoutConnection(b,{waypoints:[]});const j=A(),B=[...j].filter(Y=>!k.has(Y)).length,W=[...k].filter(Y=>!j.has(Y)).length;B<=W||(n.updateWaypoints(b,I),L&&H&&(L.x!==H.x||L.y!==H.y)&&n.moveElements([L],{x:H.x-L.x,y:H.y-L.y}))},yt=5,Ao=10,nE=200,Nu=new Set([...C.map(b=>b.flow.id),...x.map(b=>b.flow.id),...Kt(e,"sequenceFlow.update").map(b=>b.id),...Kt(e,"messageFlow.update").map(b=>b.id)].filter(b=>!!b)),BN=(b,S,A,k,I,L)=>{const H=new Set(b.map(Q=>Q.id)),j=Math.min(...b.map(Q=>Q.x))+S-Ao,B=Math.max(...b.map(Q=>Q.x+Q.width))+S+nE+Ao,W=Math.min(...b.map(Q=>Q.y+Math.min(0,...A)))-Ao,Y=Math.max(...b.map(Q=>Q.y+Q.height+Math.max(0,...A)))+Ao,ae=o.getAll().filter(Q=>{if(Q.type!=="bpmn:SequenceFlow"&&Q.type!=="bpmn:MessageFlow")return!1;const ie=Q;return Nu.has(ie.id)||!ie.waypoints||ie.waypoints.length<2||[ie.source,ie.target].some(ve=>!ve||H.has(ve.id)||ve.x>=k)?!1:ie.waypoints.some((ve,et)=>{const Ve=ie.waypoints[et+1];return!!Ve&&Math.max(ve.x,Ve.x)>=j&&Math.min(ve.x,Ve.x)<=B&&Math.max(ve.y,Ve.y)>=W&&Math.min(ve.y,Ve.y)<=Y})});if(!ae.length)return 0;const ee=Q=>{const ie=new Map;for(const se of b)for(const ve of A){const et={id:se.id,type:se.type,x:se.x+S+Q,y:se.y+ve,width:se.width,height:se.height};for(const Ve of ae){let gt=1/0;for(let xe=0;xe+1<Ve.waypoints.length;xe++)gt=Math.min(gt,yc(Ve.waypoints[xe],Ve.waypoints[xe+1],et));const Tt=`${Ve.id}|${se.id}`;ie.set(Tt,Math.min(ie.get(Tt)??1/0,gt))}}return ie},de=[...ee(0)].filter(([,Q])=>Q<=yt).map(([Q])=>Q);if(!de.length)return 0;let pe=0;for(let Q=1;Q<=nE;Q++){const ie=ee(Q);if([...ie.values()].every(se=>se>yt)&&de.every(se=>(ie.get(se)??1/0)>=Ao)){pe=Q;break}}if(!pe)return 0;const me=Math.min(...b.map(Q=>Q.x))+S+pe,Ye=new Set(de.map(Q=>Q.slice(0,Q.indexOf("|"))));return ae.some(Q=>Q.type==="bpmn:SequenceFlow"&&Ye.has(Q.id)&&Q.waypoints.some((ie,se)=>{const ve=Q.waypoints[se+1];if(!ve||Math.min(ie.y,ve.y)>L||Math.max(ie.y,ve.y)<L||ie.y===ve.y)return!1;const et=ie.x+(L-ie.y)*(ve.x-ie.x)/(ve.y-ie.y);return et>I&&et<me}))?0:pe},Po=(b,S=()=>!0)=>{const A=p(b);if(!A)return[];const k=[A],I=new Set([b]);for(let L=0;L<k.length;L++){const H=k[L].id;for(const j of C){const B=j.flow.target;if(j.flow.source!==H||I.has(B)||!T.has(B))continue;I.add(B);const W=p(B);W&&S(W)&&k.push(W)}}return k},NN=(b,S=()=>!0)=>{const A=p(b);if(!A)return[];const k=[A],I=new Set([b]);for(let L=0;L<k.length;L++){const H=k[L].id;for(const j of C){const B=j.flow.source;if(j.flow.target!==H||I.has(B)||!T.has(B))continue;I.add(B);const W=p(B);W&&S(W)&&k.push(W)}}return k},Mi=30,vr=b=>!("waypoints"in b&&b.waypoints)&&b.type!=="bpmn:Lane"&&b.type!=="label"&&typeof b.x=="number",$u=(b,S)=>Np(n,b,S),Us=(b,S,A=!1)=>{const k=new Set(b.flatMap(B=>B.subtree.map(W=>W.id)));for(const B of b){const W=(B.pool.children??[]).filter(vr).filter(ae=>!k.has(ae.id));if(B.subtree.some(ae=>W.some(ee=>ae.x+S<ee.x+ee.width+Mi&&ae.x+S+ae.width+Mi>ee.x&&ae.y<ee.y+ee.height&&ae.y+ae.height>ee.y)))return null}const I=b.map(B=>B.pool.width),L=A?o.filter(B=>Array.isArray(B.waypoints)).map(B=>({c:B,wps:B.waypoints.map(W=>({x:W.x,y:W.y}))})):[],H=o.filter(B=>B.type==="label").map(B=>({label:B,x:B.x,y:B.y}));n.moveElements(b.flatMap(B=>B.subtree),{x:S,y:0});const j=b.map(B=>{const Y=Math.max(...B.subtree.map(ae=>ae.x+ae.width))+Tg-(B.pool.x+B.pool.width);return Y>0&&$u(B.pool,B.pool.width+Y),Y});return()=>{n.moveElements(b.flatMap(B=>B.subtree),{x:-S,y:0}),b.forEach((B,W)=>{j[W]>0&&$u(B.pool,I[W])});for(const{c:B,wps:W}of L){const Y=B.waypoints??[];Y.length===W.length&&Y.every((ee,de)=>Math.abs(ee.x-W[de].x)<=.5&&Math.abs(ee.y-W[de].y)<=.5)||n.updateWaypoints(B,W.map(ee=>({x:ee.x,y:ee.y})))}for(let B=0;B<3;B++){let W=0;for(const Y of H){const ae=Y.x-Y.label.x,ee=Y.y-Y.label.y;Math.abs(ae)<=.5&&Math.abs(ee)<=.5||(n.moveElements([Y.label],{x:ae,y:ee}),W++)}if(!W)break}}},Nh=b=>{var I,L;const S=new Map,A=new Map;for(const H of o.getAll()){if(H.type!=="bpmn:Participant")continue;const j=H;(j.children??[]).length||(S.set(j.id,j),A.set(j.id,[]))}for(const H of o.getAll()){if(H.type!=="bpmn:MessageFlow")continue;const j=H,B=(I=j.source)==null?void 0:I.id,W=(L=j.target)==null?void 0:L.id;B&&W&&A.has(B)&&A.get(B).push(W),B&&W&&A.has(W)&&A.get(W).push(B)}const k=[];for(const[H,j]of A)j.length&&j.every(B=>b.has(B))&&k.push(S.get(H));return k},iE=(b,S)=>{if(!b.length)return null;const A=new Set(b.map(Y=>Y.id)),k=o.getAll().filter(Y=>Y.type==="bpmn:Participant"&&!A.has(Y.id)),I=Math.min(...k.filter(Y=>(Y.children??[]).length>0).map(Y=>Y.x)),L=new Set(b.filter(Y=>Math.abs(Y.x-I)<=2).map(Y=>Y.id));if(b.some(Y=>{const ae=L.has(Y.id)?Y.x:Y.x+S,ee=L.has(Y.id)?Y.width+S:Y.width;return k.some(de=>ae<de.x+de.width+Mi&&ae+ee+Mi>de.x&&Y.y<de.y+de.height&&Y.y+Y.height>de.y)}))return null;const j=o.filter(Y=>Y.type==="label").map(Y=>({label:Y,x:Y.x,y:Y.y})),B=b.filter(Y=>!L.has(Y.id)),W=b.filter(Y=>L.has(Y.id)).map(Y=>({pool:Y,was:{x:Y.x,y:Y.y,width:Y.width,height:Y.height}}));B.length&&n.moveElements(B,{x:S,y:0});for(const{pool:Y,was:ae}of W)n.resizeShape(Y,{...ae,width:ae.width+S});return()=>{for(const{pool:Y,was:ae}of W)n.resizeShape(Y,ae);B.length&&n.moveElements(B,{x:-S,y:0});for(let Y=0;Y<3;Y++){let ae=0;for(const ee of j){const de=ee.x-ee.label.x,pe=ee.y-ee.label.y;Math.abs(de)<=.5&&Math.abs(pe)<=.5||(n.moveElements([ee.label],{x:de,y:pe}),ae++)}if(!ae)break}}},rE=(b,S,A)=>{const k=A.x+A.width/2,I=S.y>A.y,L=I?A.y+A.height:A.y,H=I?S.y:S.y+S.height,j=b.source===S?[{x:k,y:H},{x:k,y:L}]:[{x:k,y:L},{x:k,y:H}],B=Ze(o),W={...B.edges.find(Y=>Y.id===b.id),waypoints:j};return xn(W,ci(B)).length?!1:(n.updateWaypoints(b,j),!0)},$N=()=>{const b=o.filter(I=>I.type==="bpmn:Participant"),S=Math.min(...b.filter(I=>(I.children??[]).length>0).map(I=>I.x)),A=I=>!!I&&I.type==="bpmn:Participant"&&!(I.children??[]).length&&Math.abs(I.x-S)<=2&&!h.some(L=>L.participant.id===I.id),k=new Set;for(const I of o.getAll()){if(I.type!=="bpmn:MessageFlow")continue;const L=I;if((L.waypoints??[]).length!==2)continue;const H=[L.source,L.target].find(B=>A(B)),j=H===L.source?L.target:L.source;H&&j&&j.type!=="bpmn:Participant"&&k.add(L.id)}return k},FN=b=>{var A;const S=new Map;for(const k of b){const I=o.get(k);if(!I||(I.waypoints??[]).length===2)continue;const L=((A=I.source)==null?void 0:A.type)==="bpmn:Participant"?I.source:I.target,H=L===I.source?I.target:I.source;if(H.x+H.width/2<=L.x+L.width)continue;const j=S.get(L.id)??{pool:L,msgs:[]};j.msgs.push({conn:I,other:H}),S.set(L.id,j)}for(const{pool:k,msgs:I}of S.values()){const L=Math.max(...I.map(({other:pe})=>pe.x+pe.width/2))+Lp;if(o.getAll().some(pe=>{if(pe.type!=="bpmn:Participant"||pe.id===k.id)return!1;const me=pe;return k.x<me.x+me.width+Mi&&L+Mi>me.x&&k.y<me.y+me.height&&k.y+k.height>me.y}))continue;const j={x:k.x,y:k.y,width:k.width,height:k.height},B=[...k.incoming??[],...k.outgoing??[]],W=B.map(pe=>({c:pe,wps:(pe.waypoints??[]).map(me=>({x:me.x,y:me.y}))})),Y=B.flatMap(pe=>{const me=pe.label;return me?[{label:me,x:me.x,y:me.y}]:[]}),ae=Qr();n.resizeShape(k,{...j,width:L-k.x});const ee=I.filter(({conn:pe,other:me})=>rE(pe,k,me)).length,de=Qr();if(!(ee>0&&de.messages>ae.messages&&de.lines>=ae.lines)){n.resizeShape(k,j);for(const{c:pe,wps:me}of W){const Ye=pe.waypoints??[];Ye.length===me.length&&Ye.every((Q,ie)=>Math.abs(Q.x-me[ie].x)<=.5&&Math.abs(Q.y-me[ie].y)<=.5)||n.updateWaypoints(pe,me.map(Q=>({x:Q.x,y:Q.y})))}for(let pe=0;pe<3;pe++){let me=0;for(const Ye of Y){const Ce=Ye.x-Ye.label.x,Q=Ye.y-Ye.label.y;Math.abs(Ce)<=.5&&Math.abs(Q)<=.5||(n.moveElements([Ye.label],{x:Ce,y:Q}),me++)}if(!me)break}}}},oE=()=>{let b=0;for(const S of o.getAll()){if(S.type!=="bpmn:DataInputAssociation"&&S.type!=="bpmn:DataOutputAssociation")continue;const A=S.waypoints??[];for(let k=1;k<A.length;k++)b+=Math.hypot(A[k].x-A[k-1].x,A[k].y-A[k-1].y)}return b},aE=()=>{let b=0;for(const S of o.getAll()){if(S.type!=="bpmn:Association")continue;const A=S.waypoints??[];for(let k=1;k<A.length;k++)b+=Math.hypot(A[k].x-A[k-1].x,A[k].y-A[k-1].y)}return b},jN=b=>{const S=[];for(const A of o.getAll()){if(A.type!=="bpmn:TextAnnotation")continue;const k=A;if(b.has(k.id))continue;const L=[...k.incoming??[],...k.outgoing??[]].filter(B=>B.type==="bpmn:Association").map(B=>B.source===k?B.target:B.source);if(!L.length||L.some(B=>B===void 0))continue;const H=B=>{if(!("waypoints"in B&&B.waypoints))return[B.id];const W=B,Y=[W.source,W.target];return Y.some(ae=>!ae)?[]:Y.map(ae=>ae.id)},j=L.flatMap(B=>H(B));j.length&&j.every(B=>b.has(B))&&S.push(k)}return S},sE=()=>dt(Ze(o)).filter(b=>b.kind==="edge-crosses-shape").length,cE=b=>{const S=(b.children??[]).filter(vr);let A=0;for(let k=0;k<S.length;k++)for(let I=k+1;I<S.length;I++){const L=S[k],H=S[I];L.x<H.x+H.width&&L.x+L.width>H.x&&L.y<H.y+H.height&&L.y+L.height>H.y&&A++}return A},Qr=()=>{const b=Ze(o),S=A=>A.length>=2&&(A.every(k=>Math.abs(k.x-A[0].x)<.01)||A.every(k=>Math.abs(k.y-A[0].y)<.01));return{messages:b.edges.filter(A=>A.type==="bpmn:MessageFlow"&&A.waypoints.length===2).length,lines:b.edges.filter(A=>S(A.waypoints)).length}},lE=b=>{const S=new Map;for(const k of o.getAll()){if(k.type!=="bpmn:MessageFlow")continue;const I=k;if(!I.waypoints||I.waypoints.length!==2)continue;const L=I.source,H=I.target;if(!L||!H)continue;const j=b.has(L.id);if(j===b.has(H.id))continue;const B=j?H:L,W=d(B);if(!W||b.has(B.id))continue;const Y=S.get(W.id);Y?B.x<Y.minX&&(Y.minX=B.x):S.set(W.id,{pool:W,minX:B.x})}const A=[];for(const{pool:k,minX:I}of S.values()){const L=(k.children??[]).filter(H=>vr(H)&&!b.has(H.id)&&H.x>=I);L.length&&A.push({subtree:L,pool:k})}return A},HN=(b,S,A)=>{const k=new Map(S.map(H=>[H.pool.id,{subtree:[...H.subtree],pool:H.pool}])),I=new Set(b);for(const H of S)for(const j of H.subtree)I.add(j.id);let L=!1;for(;;){let H=0;for(const j of lE(I)){if(j.pool===A)continue;const B=k.get(j.pool.id);B?B.subtree.push(...j.subtree):k.set(j.pool.id,{subtree:[...j.subtree],pool:j.pool});for(const W of j.subtree)I.add(W.id);H+=j.subtree.length}if(!H)break;L=!0}return L?[...k.values()]:null},uE=new Map;for(const b of Kt(e,"sequenceFlow.update")){if(b.target===void 0)continue;const S=T.get(b.target);if(!S)continue;const A=p(b.target),k=p(b.id);if(!A||!k)continue;const I=b.source!==void 0?p(b.source):k.source,L=k.target;if(!I||!L||L.id===A.id)continue;const H=k.waypoints&&k.waypoints.length>=3&&Math.abs(k.waypoints[0].x-k.waypoints[1].x)<1&&Math.abs(k.waypoints[0].y-k.waypoints[1].y)>1?{x:k.waypoints[0].x,y:k.waypoints[0].y}:void 0,j=H?k.waypoints[1].y:void 0,B=H&&k.label?{x:k.label.x,y:k.label.y}:void 0,W=B&&k.label&&Math.abs(B.y+k.label.height/2-j)<=D/5&&B.x+k.label.width>H.x?B.x+k.label.width+6:void 0,Y=(I.outgoing??[]).filter(Pe=>Pe.type==="bpmn:SequenceFlow"&&Pe.id!==k.id&&Pe.target&&!Nu.has(Pe.id)),ae=new Set(Y.map(Pe=>Pe.target.id)),ee=Pe=>{const ke={type:"bpmn:Task",x:Pe.x+2,y:Pe.y+2,width:Pe.width-4,height:Pe.height-4};return Y.find(Xe=>(Xe.waypoints??[]).some((bn,_t)=>!!Xe.waypoints[_t+1]&&yc(bn,Xe.waypoints[_t+1],ke)===0))},de=Po(b.target),pe=new Set(de.map(Pe=>Pe.id)),me=wn.has(b.target)?{autoResize:!1}:void 0,Ye=Math.min(...de.map(Pe=>Pe.x)),Ce=Math.max(...de.map(Pe=>Pe.x+Pe.width)),Q=I.x+I.width,ie=A.y+A.height/2,se=BN(de,Q+Tn-Ye,[0,I.y+I.height/2-ie,L.y+L.height/2-ie],L.x,Q,I.y+I.height/2),ve=Q+Tn+se,et=(()=>{if(W===void 0)return 0;const Pe=Q+Tn,ke=I.y+I.height/2-A.height/2,Xe={x:Pe,y:ke,width:Ce-Ye,height:A.height},bn=d(I);return((bn==null?void 0:bn.children)??[]).some(mt=>vr(mt)&&!pe.has(mt.id)&&mt.id!==I.id&&mt.id!==L.id&&mt.type!=="bpmn:Group"&&mt.type!=="bpmn:Participant"&&mt.x<Xe.x+Xe.width&&mt.x+mt.width>Xe.x&&mt.y<Xe.y+Xe.height&&mt.y+mt.height>Xe.y)||ee(Xe)?Math.max(0,W-Pe):0})(),Ve=Ce-Ye+Tn*2+se+et-(L.x-Q);let gt=[];if(Ve>0){const Pe=d(A),ke=(Pe==null?void 0:Pe.children)??[],Xe=Ne=>Ne.type==="bpmn:Lane";gt=(()=>{const Ne=new Set;for(const $e of ke)vr($e)&&!pe.has($e.id)&&$e.id!==I.id&&$e.x>=L.x&&Ne.add($e.id);const At=[];for(const $e of ke){if($e.type!=="bpmn:DataStoreReference"&&$e.type!=="bpmn:DataObjectReference")continue;const vt=$e,Un=[...vt.incoming??[],...vt.outgoing??[]].filter(Qt=>Qt.type==="bpmn:DataInputAssociation"||Qt.type==="bpmn:DataOutputAssociation").map(Qt=>Qt.source===vt?Qt.target:Qt.source);Un.length&&Un.every(Qt=>Qt!==void 0&&Ne.has(Qt.id))&&At.push(vt)}return At})();const _t=ke.filter(Ne=>!("waypoints"in Ne&&Ne.waypoints)&&!Xe(Ne)&&Ne.type!=="label"&&!pe.has(Ne.id)&&Ne.id!==I.id&&Ne.x>=L.x),mt=_t.flatMap(Ne=>Ne.labels??[]),It=Pe?[Pe,...ke.filter(Ne=>Xe(Ne))]:[];if(_t.length){const Ne=new Set(_t.map(bt=>bt.id)),At=lE(Ne),$e=At.length?HN(Ne,At,Pe):null,vt=bt=>{const kt=new Set(Ne);for(const jt of bt)for(const Ii of jt.subtree)kt.add(Ii.id);return jN(kt)},zn=vt(At),Un=$e?vt($e):zn,Qt=Nh(Ne),Gu=new Set(Ne);for(const bt of At)for(const kt of bt.subtree)Gu.add(kt.id);const Vu=At.length?Nh(Gu):Qt,Wu=(()=>{if(!$e)return[];const bt=new Set(Ne);for(const kt of $e)for(const jt of kt.subtree)bt.add(jt.id);return Nh(bt)})(),Ks=new Set([..._t,...It].map(bt=>bt.id)),Wh=ke.filter(bt=>{const kt=bt.labelTarget;return bt.type==="label"&&!!kt&&"waypoints"in kt&&!!kt.source&&!!kt.target&&Ks.has(kt.source.id)&&Ks.has(kt.target.id)}),Uh=$N();n.createSpace([..._t,...mt,...Wh],It,{x:Ve,y:0},"e",L.x-1);const Li=(bt,kt)=>{const jt=Qr(),Ii=Us(bt,Ve);if(!Ii)return!1;const Bt=kt.length?iE(kt,Ve):null,Ai=Qr();return Ai.messages>jt.messages&&Ai.lines>=jt.lines?!0:(Bt==null||Bt(),Ii(),!1)},ft=$e?Li($e,Wu):!1;let sn=ft;!sn&&At.length&&(sn=Li(At,Vu));const Ft=ft?Un:zn;if(!sn){for(const bt of At){const kt=Qr(),jt=Us([bt],Ve);if(!jt)continue;const Ii=Qr();(Ii.messages<=kt.messages||Ii.lines<kt.lines)&&jt()}if(Qt.length){const bt=Qr(),kt=iE(Qt,Ve);if(kt){const jt=Qr();(jt.messages<=bt.messages||jt.lines<bt.lines)&&kt()}}}if(FN(Uh),Ft.length){const bt=()=>new Set(dt(Ze(o)).map(jt=>lt(jt))),kt=jt=>{const Ii=aE(),Bt=bt(),Ai=jt.map(Jt=>({a:Jt,x:Jt.x,y:Jt.y})),Do=o.filter(Jt=>Jt.type==="label").map(Jt=>({label:Jt,x:Jt.x,y:Jt.y}));n.moveElements(jt,{x:Ve,y:0});const u$=[...bt()].filter(Jt=>!Bt.has(Jt));if(aE()<Ii&&u$.length===0)return!0;for(const{a:Jt,x:Xs,y:Zs}of Ai)(Jt.x!==Xs||Jt.y!==Zs)&&n.moveElements([Jt],{x:Xs-Jt.x,y:Zs-Jt.y});for(const Jt of Do){const Xs=Jt.x-Jt.label.x,Zs=Jt.y-Jt.label.y;(Xs!==0||Zs!==0)&&n.moveElements([Jt.label],{x:Xs,y:Zs})}return!1};if(!kt(Ft)&&Ft.length>1)for(const jt of Ft)kt([jt])}}}const Tt=S.node.lane!==void 0?p(S.node.lane):S.node.participant!==void 0?p(S.node.participant):void 0,xe=Pe=>{if(!Tt)return!0;const ke=Pe.y+Pe.height/2;return ke>=Tt.y&&ke<=Tt.y+Tt.height},be=!xe(I)&&xe(L)?L:I,re=be.y+be.height/2,ye=re-(A.y+A.height/2),Ie=S.band!==void 0,Be=Ie?[A]:de,we=(S.band===void 0||w(S.node.lane,S.node.participant,S.band,re))&&xt(b.target)&&Be.every(Pe=>{var ke;return Ct((ke=T.get(Pe.id))==null?void 0:ke.node.lane,Pe,Pe.y+Pe.height/2+ye)}),ot=Pe=>Math.abs(Pe.y+Pe.height/2-(A.y+A.height/2))<=D/2;if(we&&Ie){const Pe=Math.abs(ye)<=D/2?de.filter(ke=>ke.id!==A.id&&ot(ke)):[];if(n.moveElements(de,{x:ve-Ye,y:0},void 0,me),n.moveElements([A],{x:0,y:ye},void 0,me),Pe.length){const ke=()=>new Set(dt(Ze(o)).map(Ne=>lt(Ne))),Xe=ke(),bn=o.filter(Ne=>Ne.type==="label").map(Ne=>({label:Ne,x:Ne.x,y:Ne.y}));n.moveElements(Pe,{x:0,y:ye});const _t=ke(),mt=[..._t].filter(Ne=>!Xe.has(Ne)).length,It=[...Xe].filter(Ne=>!_t.has(Ne)).length;if(mt>It){n.moveElements(Pe,{x:0,y:-ye});for(const Ne of bn){const At=Ne.x-Ne.label.x,$e=Ne.y-Ne.label.y;(At!==0||$e!==0)&&n.moveElements([Ne.label],{x:At,y:$e})}}}}else n.moveElements(de,{x:ve-Ye,y:we?ye:0},void 0,me);const Ke=d(A);if(!we&&S.node.lane===void 0&&S.band!==void 0&&Ke){const Pe=Ke.y+J+R(`pool:${S.node.participant??""}`,S.band)*D,ke=Pe-(A.y+A.height/2);ke!==0&&!rt(Ke,A,A.x+A.width/2,Pe,pe)&&n.moveElements([A],{x:0,y:ke},void 0,me)}if(Ke){const Pe=(Ke.children??[]).filter(_t=>vr(_t)&&!pe.has(_t.id)&&_t.type!=="bpmn:Group"&&_t.type!=="bpmn:Participant"),ke=(_t,mt,It,Ne,At)=>_t.x+mt<At.x+At.width+Ne&&_t.x+mt+_t.width+Ne>At.x&&_t.y+It<At.y+At.height+Ne&&_t.y+It+_t.height+Ne>At.y,Xe=Pe.find(_t=>ke(A,0,0,0,_t)),bn=Xe?void 0:ee(A);if(Xe||bn){const _t=["bpmn:SequenceFlow","bpmn:MessageFlow","bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation"],mt=o.getAll().filter(ft=>{if(!_t.includes(ft.type))return!1;const sn=ft;return Nu.has(sn.id)||!sn.waypoints||sn.waypoints.length<2?!1:![sn.source,sn.target].some(Ft=>!Ft||pe.has(Ft.id))}),It=(ft,sn,Ft)=>{var bt;return Ct((bt=T.get(ft.id))==null?void 0:bt.node.lane,ft,ft.y+Ft+ft.height/2)&&ft.x+sn>=Ke.x&&ft.x+sn+ft.width<=Ke.x+Ke.width&&ft.y+Ft>=Ke.y&&ft.y+Ft+ft.height<=Ke.y+Ke.height},Ne=(ft,sn)=>de.every(Ft=>It(Ft,ft,sn)&&!Pe.some(bt=>ke(Ft,ft,sn,Ao,bt))&&mt.every(bt=>{const kt={id:Ft.id,type:Ft.type,x:Ft.x+ft,y:Ft.y+sn,width:Ft.width,height:Ft.height};for(let jt=0;jt+1<bt.waypoints.length;jt++)if(yc(bt.waypoints[jt],bt.waypoints[jt+1],kt)<Ao)return!1;return!0})),At=A.y+A.height/2,$e=[j,L.y+L.height/2].filter(ft=>ft!==void 0&&Math.abs(ft-At)>=1),vt=Xe&&ae.has(Xe.id)?Xe:bn==null?void 0:bn.target,zn=vt?vt.x-A.x:0,Un=Math.max(...de.map(ft=>ft.x+ft.width)),Qt=[...zn!==0?[zn]:[],...se!==0?[-se]:[],0],Gu=W===void 0?[]:Qt.map(ft=>Math.max(ft,W-A.x)),Vu=ft=>Un+ft+Tn<=L.x,Wu=[...new Set([...Gu,...Qt])].filter(Vu),Ks=Xe&&ae.has(Xe.id)?[Xe.x+Xe.width+Tn-A.x]:[],Wh=W===void 0?[]:Ks.map(ft=>Math.max(ft,W-A.x)),Uh=[...new Set([...Wh,...Ks])].filter(ft=>Vu(ft)&&!Wu.includes(ft));let Li;for(const ft of[Wu,Uh]){for(const sn of $e){for(const Ft of ft)if(Ne(Ft,sn-At)){Li={dx:Ft,dy:sn-At};break}if(Li)break}if(Li)break}if(Li){const ft=Bt=>{const Ai=Bt;return[Ai.edge,Ai.other,...Array.isArray(Ai.edges)?Ai.edges:[]].some(Do=>typeof Do=="string"&&Nu.has(Do))},sn=()=>new Set(dt(Ze(o)).filter(Bt=>!ft(Bt)).map(Bt=>lt(Bt))),Ft=sn(),bt=o.filter(Bt=>Bt.type==="label").map(Bt=>({label:Bt,x:Bt.x,y:Bt.y}));n.moveElements(de,{x:Li.dx,y:Li.dy},void 0,me);const kt=sn(),jt=[...kt].filter(Bt=>!Ft.has(Bt)).length,Ii=[...Ft].filter(Bt=>!kt.has(Bt)).length;if(jt>Ii){n.moveElements(de,{x:-Li.dx,y:-Li.dy},void 0,me);for(const Bt of bt){const Ai=Bt.x-Bt.label.x,Do=Bt.y-Bt.label.y;(Ai!==0||Do!==0)&&n.moveElements([Bt.label],{x:Ai,y:Do})}}else H&&uE.set(k.id,{exit:H,channelY:j,label:B})}}}{const Pe=new Set(de.map(mt=>mt.id)),ke=new Set(C.map(mt=>mt.flow.id)),Xe=20,bn=mt=>{const It=mt.source,Ne=mt.target,At=Math.min(It.x,Ne.x)-Xe,$e=Math.max(It.x+It.width,Ne.x+Ne.width)+Xe,vt=Math.min(It.y,Ne.y)-Xe,zn=Math.max(It.y+It.height,Ne.y+Ne.height)+Xe;return mt.waypoints.some(Un=>Un.x<At||Un.x>$e||Un.y<vt||Un.y>zn)},_t=new Map;for(const mt of de)for(const It of[...mt.incoming??[],...mt.outgoing??[]])It.id!==b.id&&ke.has(It.id)&&!(Pe.has(It.source.id)&&Pe.has(It.target.id))&&_t.set(It.id,It);for(const mt of _t.values())bn(mt)&&pt(mt)}const Mt=gt.length?d(gt[0]):void 0;if(Mt){const Pe={assoc:oE(),overlaps:cE(Mt),crosses:sE()},ke=gt.map($e=>({st:$e,x:$e.x})),Xe=o.filter($e=>$e.type==="label").map($e=>({label:$e,x:$e.x,y:$e.y})),bn=Math.min(...gt.flatMap($e=>[...$e.incoming??[],...$e.outgoing??[]].filter(vt=>vt.type==="bpmn:DataInputAssociation"||vt.type==="bpmn:DataOutputAssociation").map(vt=>(vt.source===$e?vt.target:vt.source).x))),_t=new Set(gt.map($e=>$e.id)),mt=(Mt.children??[]).filter(vr).filter($e=>!_t.has($e.id));let It=bn;for(const $e of[...gt].sort((vt,zn)=>vt.x-zn.x)){let vt=It;for(let zn=0;zn<100;zn++){const Un=mt.find(Qt=>vt<Qt.x+Qt.width+Mi&&vt+$e.width+Mi>Qt.x&&$e.y<Qt.y+Qt.height&&$e.y+$e.height>Qt.y);if(!Un)break;vt=Un.x+Un.width+Mi}vt!==$e.x&&n.moveElements([$e],{x:vt-$e.x,y:0}),It=vt+$e.width+Mi}const Ne=It+150-(Mt.x+Mt.width);Ne>0&&$u(Mt,Mt.width+Ne);const At={assoc:oE(),overlaps:cE(Mt),crosses:sE()};if(At.assoc>=Pe.assoc||At.overlaps>Pe.overlaps||At.crosses>Pe.crosses){for(const{st:$e,x:vt}of ke)$e.x!==vt&&n.moveElements([$e],{x:vt-$e.x,y:0});Ne>0&&$u(Mt,Mt.width-Ne);for(const $e of Xe){const vt=$e.x-$e.label.x,zn=$e.y-$e.label.y;(vt!==0||zn!==0)&&n.moveElements([$e.label],{x:vt,y:zn})}}}}for(const[b,S]of wn){const A=p(b);if(!A)continue;const k=S.container,I=Math.abs(A.y+A.height/2-k.y-S.relCy)>=.5,L=A.label,H=Math.min(A.y,L&&!L.hidden?L.y:A.y),j=Math.max(A.y+A.height,L&&!L.hidden?L.y+L.height:0);if(I&&H>=k.y&&j<=k.y+k.height)continue;const B=A.y;S.grow(),A.y!==B&&n.moveElements([A],{x:0,y:B-A.y},void 0,{autoResize:!1})}const pE=(b,S)=>{const A=S.target===b,k=f(S.source),I=f(S.target),L=A?"bpmn:DataOutputAssociation":"bpmn:DataInputAssociation";n.connect(k,I,S.id?{type:L,businessObject:i.create(L,{id:S.id})}:{type:L})},fE=b=>{for(const S of h){if(!S.participant.blackBox)continue;const A=p(S.participant.id);if(!A)continue;const k=[];for(const L of x){const H=L.flow.source===S.participant.id?L.flow.target:L.flow.target===S.participant.id?L.flow.source:void 0,j=H?p(H):void 0;j&&typeof j.x=="number"&&j.type!=="bpmn:Participant"&&k.push(j)}if(!k.length)continue;if(!b&&S.order===void 0){const L=(()=>{var j;const H=new Map;for(const B of k){const W=d(B);if(!W)continue;const Y=H.get(W.id);Y?Y.n+=1:H.set(W.id,{shape:W,n:1})}return(j=[...H.values()].sort((B,W)=>W.n-B.n)[0])==null?void 0:j.shape})();if(L){const H=W=>W.reduce((Y,ae)=>Y+ae,0)/W.length,j=H(k.map(W=>W.y+W.height/2))<L.y+L.height/2,B=o.filter(W=>W.type==="bpmn:Participant"&&W.id!==S.participant.id&&W.id!==L.id).filter(W=>j?W.y+W.height<=L.y+5:W.y>=L.y+L.height-5);if(B.length){const W=[...B.reduce((se,ve)=>se.set(ve.y,(se.get(ve.y)??0)+1),new Map)].sort((se,ve)=>ve[1]-se[1]||(j?ve[0]-se[0]:se[0]-ve[0]))[0][0],Y=Math.min(A.width,UR),ae=qR,ee=k.map(se=>se.x+se.width/2),de=Math.round(H(ee)-Y/2),pe=Math.max(...ee)+Lp,me=se=>({x:se,width:Math.max(Y,pe-se)}),Ye=B.filter(se=>Math.min(se.y+se.height,W+ae)-Math.max(se.y,W)>0),Ce=se=>{const ve=me(se);return Ye.some(et=>et.x<ve.x+ve.width&&ve.x<et.x+et.width)},Q=se=>{const ve=me(se);return ee.filter(et=>et>=ve.x+10&&et<=ve.x+ve.width-10).length},ie=(()=>{if(!Ce(de))return de;const se=Q(de);return Ye.flatMap(ve=>[ve.x+ve.width+Cg,ve.x-Cg-Y]).map(ve=>Math.round(ve)).filter(ve=>!Ce(ve)&&Q(ve)>=se).sort((ve,et)=>Math.abs(ve-de)-Math.abs(et-de))[0]??de})();if(ie!==A.x||W!==A.y||Y!==A.width||ae!==A.height){const se=()=>new Set(dt(Ze(o)).map(xe=>lt(xe))),ve=se(),et={x:A.x,y:A.y,width:A.width,height:A.height};n.resizeShape(A,{x:ie,y:W,width:Y,height:ae});const Ve=se(),gt=[...Ve].filter(xe=>!ve.has(xe)).length,Tt=[...ve].filter(xe=>!Ve.has(xe)).length;gt>Tt&&n.resizeShape(A,et)}}}}const I=Math.max(...k.map(L=>L.x+L.width/2))+Lp;if(I>A.x+A.width&&n.resizeShape(A,{x:A.x,y:A.y,width:I-A.x,height:A.height}),!!b)for(const L of x){const H=p(L.flow.id),j=L.flow.source===S.participant.id?L.flow.target:L.flow.target===S.participant.id?L.flow.source:void 0,B=j?p(j):void 0;if(!H||!B||B.type==="bpmn:Participant")continue;const W=B.x+B.width/2;W<A.x+10||W>A.x+A.width-10||rE(H,A,B)}}};fE(!1);for(const b of x){const S=b.flow;n.connect(f(S.source),f(S.target),{type:"bpmn:MessageFlow",businessObject:i.create("bpmn:MessageFlow",{id:S.id,name:S.name})})}{const A=new Set([...C.map(B=>B.flow.id),...x.map(B=>B.flow.id)].filter(B=>!!B)),k=o.filter(B=>!!B.waypoints),I=(B,W)=>Math.abs(W.x-B.x)<2?"L":Math.abs(W.x-(B.x+B.width))<2?"R":Math.abs(W.y-B.y)<2?"T":Math.abs(W.y-(B.y+B.height))<2?"B":void 0,L=new Map,H=(B,W,Y)=>{if(!B||!W||typeof B.x!="number")return;const ae=I(B,W);if(!ae)return;let ee=L.get(B.id);ee||L.set(B.id,ee=new Map),ee.set(ae,[...ee.get(ae)??[],Y])};for(const B of k){const W=B.waypoints;!W||W.length<2||(H(B.source,W[0],{id:B.id,dir:"out"}),H(B.target,W[W.length-1],{id:B.id,dir:"in"}))}const j=new Set;for(const[B,W]of L){const Y=p(B);if(!Y||typeof Y.x!="number"||![...W.values()].some(Ce=>{const Q=Ce.filter(ie=>ie.dir==="in");return Ce.length>=3&&Q.length>=1&&Ce.some(ie=>ie.dir==="out")&&Q.some(ie=>A.has(ie.id))}))continue;const ee=d(Y);if(!ee||j.has(ee.id)||(ee.children??[]).some(Ce=>Ce.type==="bpmn:Lane"))continue;const de=(TE=W.get("T"))!=null&&TE.length?(kE=W.get("B"))!=null&&kE.length?void 0:"B":"T";if(!de||(de==="T"?Y.y-ee.y:ee.y+ee.height-(Y.y+Y.height))>=D)continue;const me=(ee.children??[]).filter(Ce=>!("waypoints"in Ce&&Ce.waypoints)&&Ce.type!=="label"&&typeof Ce.x=="number"),Ye=ee.y+ee.height;n.resizeShape(ee,{x:ee.x,y:ee.y,width:ee.width,height:ee.height+D}),te(Ye,ee.id,D),de==="T"&&me.length&&n.moveElements(me,{x:0,y:D}),j.add(ee.id)}}const $h=20,dE=4,zN=3,GN=2,VN=[10,30,80],Jr=()=>{const b=Ze(o);return{bad:dt(b).filter(S=>S.kind==="edge-crosses-shape"||S.kind==="edge-overlap-opposite"||S.kind==="edge-overlap-mixed").length,crossings:Nm(b),straight:b.edges.filter(S=>S.type==="bpmn:MessageFlow"&&S.waypoints.length===2).length}},Da=b=>{const S=Ze(o),A=S.edges.find(k=>k.id===b);return A?xn(A,ci(S)).length:0},Fu=b=>Da(b)>0,ju=b=>Ze(o).edges.filter(S=>S.type==="bpmn:MessageFlow"&&S.id!==b&&S.waypoints.length===2).length,WN=(b,S,A)=>Us([{subtree:b,pool:S}],A),hE=(b,S)=>S.bad>b.bad||S.crossings>b.crossings&&S.straight<=b.straight&&S.bad>=b.bad,La=(b,S)=>hE(b,S)||S.straight<b.straight,To=(b,S,A=()=>!0,k=hE,I=!1)=>{const L=Jr(),H=Us(b,S,I);if(!H)return!1;const j=Jr();return k(L,j)||!A()?(H(),!1):!0},UN=(b,S,A,k=()=>!0)=>To([{subtree:b,pool:S}],A,k),ko=b=>{var S;return!!((S=T.get(b))!=null&&S.node.participant)},qs=new Map;for(const b of x){if(!ko(b.flow.target))continue;const S=qs.get(b.flow.target)??[];S.push(b),qs.set(b.flow.target,S)}const Hu=[...qs.keys()],Fh=new Set(C.map(b=>b.flow.target)),mE=b=>Yt.findIndex(({op:S})=>S.participant.id===b);Hu.sort((b,S)=>{var I,L;const A=Fh.has(b)?1:0,k=Fh.has(S)?1:0;return A!==k?A-k:mE((I=T.get(b))==null?void 0:I.node.participant)-mE((L=T.get(S))==null?void 0:L.node.participant)});const eo=b=>b.x+b.width/2,qN=b=>{const S=new Map;for(const I of o.getAll()){const L=I;if(!L.waypoints||!L.source||!L.target)continue;(S.get(L.source.id)??S.set(L.source.id,[]).get(L.source.id)).push(L.target.id)}const A=new Set([b]),k=[b];for(let I=0;I<k.length;I++)for(const L of S.get(k[I])??[])A.has(L)||(A.add(L),k.push(L));return A},YN=(b,S)=>{const A=qN(S);let k;for(const I of o.getAll()){const L=I;if(L.type!=="bpmn:MessageFlow"||!L.source||!L.target||L.target.id!==b||A.has(L.source.id))continue;const H=L.source;if(typeof H.x!="number"||H.type==="bpmn:Participant")continue;const j=eo(H);(k===void 0||j>k)&&(k=j)}return k},jh=(b,S)=>{const A=p(b.flow.source);if(A)return A.type==="bpmn:Participant"?YN(A.id,S):eo(A)},gE=b=>{let S;for(const A of qs.get(b)??[]){const k=jh(A,b);k!==void 0&&(!S||k>S.cx)&&(S={op:A,cx:k})}return S==null?void 0:S.op},KN=b=>{const S=gE(b),A=p(b),k=S?jh(S,b):void 0;return A&&k!==void 0?k-eo(A):void 0},XN=b=>{const S=KN(b);return S!==void 0&&Math.abs(S)<$h},Hh=(b,S,A,k,I)=>{var L;for(let H=!0;H;){H=!1;for(const j of x){if(j.flow.id===A)continue;const B=S.has(j.flow.source),W=S.has(j.flow.target);if(B===W||k(B?j.flow.source:j.flow.target))continue;const Y=B?j.flow.target:j.flow.source;if(I(Y)||!ko(Y))continue;const ae=p(j.flow.id);if(!(ae!=null&&ae.waypoints)||ae.waypoints.length!==2)continue;const ee=p(Y),de=(L=T.get(Y))==null?void 0:L.node.participant;if(!ee||!de)continue;const pe=Po(Y,me=>me.x>=ee.x).filter(me=>!S.has(me.id));if(!(!pe.length||pe.some(me=>I(me.id)))){for(const me of pe)S.add(me.id);b.set(de,[...b.get(de)??[],...pe]),H=!0}}}return[...b].map(([H,j])=>({subtree:j,pool:f(H)}))},yE=(b,S,A,k,I)=>Hh(new Map([[S,[...b]]]),new Set(b.map(L=>L.id)),k,L=>L===A,L=>L===I),zh=b=>{const S=gE(b);if(!S)return null;const A=p(b),k=p(S.flow.source),I=jh(S,b);if(!A||!k||I===void 0)return null;const L=I-eo(A);if(L>=$h){const H=T.get(b).node.participant,j=Po(b,B=>B.x>=A.x);return{groups:yE(j,H,b,S.flow.id,S.flow.source),dx:L}}if(-L>=$h&&ko(S.flow.source)){const H=T.get(S.flow.source).node.participant,j=Po(S.flow.source,B=>B.x>=k.x&&!XN(B.id));return{groups:yE(j,H,S.flow.source,S.flow.id,b),dx:-L}}return null},vE=()=>Hu.map(b=>({id:b,plan:zh(b)})).filter(b=>!!b.plan).sort((b,S)=>Math.min(...b.plan.groups.flatMap(A=>A.subtree.map(k=>k.x)))-Math.min(...S.plan.groups.flatMap(A=>A.subtree.map(k=>k.x)))).map(b=>b.id);for(let b=0;b<3;b++){const S=Jr(),A=[];for(const I of vE()){const L=zh(I);if(!L)continue;const H=Us(L.groups,L.dx);H&&A.push(H)}if(!A.length)break;if(!La(S,Jr()))continue;for(const I of A.reverse())I();let k=!1;for(const I of vE()){const L=zh(I);L&&To(L.groups,L.dx,()=>!0,La)&&(k=!0)}if(!k)break}for(const b of Hu){if(Fh.has(b))continue;const S=T.get(b);if(!S||S.node.lane!==void 0)continue;const A=K(S);if(A===void 0)continue;const k=p(b),I=k?d(k):void 0;if(!k||!I)continue;const L=I.y+J+R(`pool:${S.node.participant??""}`,A)*D,H=L-(k.y+k.height/2);H!==0&&!rt(I,k,k.x+k.width/2,L)&&n.moveElements([k],{x:0,y:H})}const bE=new Set;for(let b=0,S=!0;S&&b<zN;b++){S=!1;for(const A of Hu.flatMap(k=>qs.get(k)??[])){if(bE.has(A.flow.id)||!Fu(A.flow.id))continue;const k=p(A.flow.target);if(!k)continue;const I=f(T.get(A.flow.target).node.participant),L=Po(A.flow.target,W=>W.x>=k.x),H=k.width+F,j=Da(A.flow.id),B=ju(A.flow.id);for(let W=1;W<=dE;W++){const Y=()=>Da(A.flow.id)<j&&ju(A.flow.id)>=B;if(UN(L,I,H*W,Y)){bE.add(A.flow.id),S=!0;break}}}}const Gh=x.map(b=>({id:b.flow.id,source:b.flow.source,target:b.flow.target,preexisting:!1})),xE=new Set(Gh.map(b=>b.id));for(const b of o.filter(S=>S.type==="bpmn:MessageFlow"))xE.has(b.id)||!b.source||!b.target||b.source.type==="bpmn:Participant"!=(b.target.type==="bpmn:Participant")&&Gh.push({id:b.id,source:b.source.id,target:b.target.id,preexisting:!0});for(const b of Gh){if(!Fu(b.id))continue;const S=p(b.source),A=p(b.target);if(!S||!A)continue;let k,I,L;if(b.preexisting){const[j,B]=S.type==="bpmn:Participant"?[A,S]:[S,A];if(k=eo(j),k<B.x||k>B.x+B.width)continue;[I,L]=j.y<B.y?[j.y+j.height,B.y]:[B.y+B.height,j.y]}else{if(S.type==="bpmn:Participant"||A.type==="bpmn:Participant"||(k=S.x+S.width/2,Math.abs(k-(A.x+A.width/2))>15))continue;[I,L]=S.y<A.y?[S.y+S.height,A.y]:[A.y+A.height,S.y]}const H=[...T.values()].map(j=>p(j.node.id)).filter(j=>!!j&&j.id!==S.id&&j.id!==A.id).filter(j=>j.x<=k&&k<=j.x+j.width&&j.y+j.height>I&&j.y<L).sort((j,B)=>j.x-B.x);for(const j of H){const B=(OE=T.get(j.id))==null?void 0:OE.node.participant,W=B?p(B):void 0;if(!B||!W)continue;const Y=[...T.values()].filter(ie=>ie.node.participant===B).map(ie=>ie.node.id),ae=ie=>ie.map(se=>p(se)).filter(se=>!!se),de=[NN(j.id,ie=>{var se;return((se=T.get(ie.id))==null?void 0:se.node.participant)===B}),ae(Y)].filter(ie=>ie.length).map(ie=>[{subtree:ie,pool:W}]);if(b.preexisting){const ie=ae(Y);ie.length&&de.push(Hh(new Map([[B,[...ie]]]),new Set(ie.map(se=>se.id)),b.id,()=>!1,se=>se===S.id||se===A.id))}const pe=j.width+F,me=Da(b.id),Ye=ju(b.id),Ce=()=>Da(b.id)<me&&ju(b.id)>=Ye;let Q=!1;for(const ie of de){for(let se=1;se<=dE;se++)if(To(ie,pe*se,Ce)){Q=!0;break}if(Q)break}if(!Fu(b.id))break}}const zu=()=>{var S;const b=new Set;for(const A of dt(Ze(o)))A.kind!=="edge-crosses-shape"||xE.has(A.edge)||((S=p(A.edge))==null?void 0:S.type)==="bpmn:MessageFlow"&&b.add(`${A.edge}>${A.shape}`);return b},ZN=(b,S)=>Jr().bad>=b&&[...zu()].some(A=>!S.has(A)),_E=b=>{var S,A;return Da(b)===0&&((A=(S=p(b))==null?void 0:S.waypoints)==null?void 0:A.length)===2},QN=(b,S,A)=>{const k=new Set(b.flatMap(L=>L.subtree.map(H=>H.id))),I=[...zu()].filter(L=>!A.has(L)).map(L=>L.split(">")[1]);return[...new Set(I)].filter(L=>k.has(L)&&L!==S.source&&L!==S.target)},JN=(b,S,A,k,I)=>{const L=b.map(W=>({...W,subtree:W.subtree.filter(Y=>!I.includes(Y.id))})).filter(W=>W.subtree.length),H=new Set(L.flatMap(W=>W.subtree.map(Y=>Y.id))),j=()=>I.every(W=>{const Y=p(W);return!!Y&&C.filter(ae=>ae.flow.target===W&&H.has(ae.flow.source)).every(ae=>{const ee=p(ae.flow.source);return!!ee&&ee.x+ee.width<=Y.x})});return To(L,S,()=>_E(A.id)&&[...zu()].every(W=>k.has(W))&&j(),La,!0)};for(const b of x){if(!Fu(b.flow.id))continue;const S=p(b.flow.id);if(((DE=S==null?void 0:S.waypoints)==null?void 0:DE.length)!==2)continue;const A=p(b.flow.source),k=p(b.flow.target);if(!A||!k||A.type==="bpmn:Participant"||k.type==="bpmn:Participant"||!ko(b.flow.source)||!ko(b.flow.target)||Math.abs(eo(A)-eo(k))>GN)continue;const I=eo(A),L=S.waypoints.map(me=>me.y),[H,j]=[Math.min(...L),Math.max(...L)],B=ci(Ze(o)).filter(me=>me.id!==A.id&&me.id!==k.id&&me.x<I&&I<me.x+me.width&&H<me.y+me.height&&me.y<j);if(!B.length)continue;const W=(LE=T.get(b.flow.source))==null?void 0:LE.node.participant,Y=(IE=T.get(b.flow.target))==null?void 0:IE.node.participant;if(!W||!Y)continue;const ae=new Map;for(const[me,Ye,Ce]of[[b.flow.source,A,W],[b.flow.target,k,Y]]){const Q=ae.get(Ce)??[],ie=Po(me,se=>se.x>=Ye.x).filter(se=>!Q.some(ve=>ve.id===se.id));ae.set(Ce,[...Q,...ie])}const ee=new Set([...ae.values()].flat().map(me=>me.id)),de=Hh(ae,ee,b.flow.id,me=>me===b.flow.source||me===b.flow.target,()=>!1),pe=Math.max(...B.map(me=>me.x+me.width));for(const me of VN){const Ye=pe+me-I;if(Ye<=0)continue;const Ce=Jr().bad,Q=zu();let ie=[],se=!0;const ve=()=>!_E(b.flow.id)||se&&(ie=QN(de,b.flow,Q),ie.length)?!1:!ZN(Ce,Q);if(To(de,Ye,ve,La))break;if(ie.length&&(JN(de,Ye,b.flow,Q,ie)||(se=!1,To(de,Ye,ve,La))))break}}{const b=A=>A.y+A.height/2,S=[];for(const A of T.keys()){if(!ko(A))continue;const k=C.filter(H=>H.flow.target===A);if(k.length!==1)continue;const I=p(k[0].flow.source),L=p(A);!I||!L||!T.has(I.id)||Math.abs(b(I)-b(L))>1||L.x-(I.x+I.width)<=F+1||S.push({id:A,pred:I,node:L})}S.sort((A,k)=>A.node.x-k.node.x);for(const{id:A}of S){const k=T.get(A),I=p(A),L=p(C.find(ee=>ee.flow.target===A).flow.source);if(!I||!L)continue;const H=I.x-(L.x+L.width);if(H<=F+1)continue;const j=f(k.node.participant),B=Po(A,ee=>ee.x>=I.x),W=Jr(),Y=WN(B,j,-(H-F));if(!Y)continue;const ae=Jr();(ae.bad>W.bad||ae.crossings>=W.crossings||ae.straight<W.straight)&&Y()}}fE(!0);const e$=10,t$=400,n$=b=>[...b.incoming??[],...b.outgoing??[]].filter(S=>S.type==="bpmn:DataInputAssociation"||S.type==="bpmn:DataOutputAssociation").map(S=>S.source===b?S.target:S.source).filter(S=>!!S&&typeof S.y=="number"),i$=o.filter(b=>b.type==="bpmn:DataStoreReference"&&g.has(b.id)),r$=(b,S)=>{const A=b.x+b.width/2,k=b.y+b.height/2;let I;for(const L of i$){if((d(L)??u())!==S||L.y<b.y+b.height)continue;const H=Math.abs(L.x+L.width/2-A);H>t$||H<L.width||!n$(L).some(B=>B.height===b.height&&Math.abs(B.y+B.height/2-k)<=e$&&L.y>=B.y+B.height)||(!I||H<I.dx||H===I.dx&&L.id<I.id)&&(I={dx:H,id:L.id,cy:L.y+L.height/2})}return I==null?void 0:I.cy};for(const b of m){const S=b.associations??[],A=S.map(L=>L.source===b.dataStore.id?L.target:L.source).map(p).find(Boolean),k=A?d(A)??u():u(),I=A?{x:A.x+A.width/2,y:r$(A,k)??A.y+A.height+110}:{x:200,y:vn+60};n.createShape({type:"bpmn:DataStoreReference",businessObject:i.create("bpmn:DataStoreReference",{id:b.dataStore.id,name:b.dataStore.name})},I,k);for(const L of S)pE(b.dataStore.id,L)}for(const b of v){const A=f(b.association.target).type==="bpmn:DataStoreReference"?b.association.target:b.association.source;pE(A,b.association)}let wE=0;const Oo=10,EE=40,o$=(b,S)=>{const A=S.map(B=>d(B)).filter(B=>!!B);for(const B of A){const W=Oo,Y=B.y,ae=B.y+B.height,ee=B.x,de=B.x+B.width;if(Math.abs(b.y-Y)<W){const pe=Y+W-b.y;b.y+=pe,b.height-=pe}if(Math.abs(b.y+b.height-ae)<W&&(b.height=ae-W-b.y),Math.abs(b.x-ee)<W){const pe=ee+W-b.x;b.x+=pe,b.width-=pe}Math.abs(b.x+b.width-de)<W&&(b.width=de-W-b.x)}if(!A.length)return;const k=Math.min(...A.map(B=>B.y)),I=Math.max(...A.map(B=>B.y+B.height)),L=k-b.y,H=b.y+b.height-I,j=EE-Oo;if(L>0!=H>0)if(L>0&&L<j){const B=L+Oo;b.y+=B,b.height-=B}else H>0&&H<j&&(b.height-=H+Oo)},a$=(b,S)=>{const A=Oo,k=30,I=o.filter(L=>L.type==="bpmn:Group"&&L.id!==S);for(const L of I){const H=L.x,j=L.x+L.width,B=L.y,W=L.y+L.height,Y=b.y<W&&B<b.y+b.height,ae=b.x<j&&H<b.x+b.width;if(Y){if(Math.abs(b.x-j)<A){const ee=Math.min(j+A-b.x,k);ee>0&&b.width-ee>0&&(b.x+=ee,b.width-=ee)}if(Math.abs(b.x+b.width-H)<A){const ee=Math.min(b.x+b.width-(H-A),k);ee>0&&b.width-ee>0&&(b.width-=ee)}}if(ae){if(Math.abs(b.y-W)<A){const ee=Math.min(W+A-b.y,k);ee>0&&b.height-ee>0&&(b.y+=ee,b.height-=ee)}if(Math.abs(b.y+b.height-B)<A){const ee=Math.min(b.y+b.height-(B-A),k);ee>0&&b.height-ee>0&&(b.height-=ee)}}}},Vh=(b,S)=>{const A=EE,k=Math.min(...b.map(B=>B.x))-A,I=Math.min(...b.map(B=>B.y))-A,L=Math.max(...b.map(B=>B.x+B.width))+A,H=Math.max(...b.map(B=>B.y+B.height))+A,j={x:k,y:I,width:L-k,height:H-I};return o$(j,b),a$(j,S),j};for(const b of E){const S=(b.group.members??[]).map(p).filter(I=>!!I);let A;S.length?A=Vh(S,b.group.id):(A={x:300+wE*350,y:40,width:300,height:200},wE++);const k=n.createShape({type:"bpmn:Group",businessObject:i.create("bpmn:Group",{id:b.group.id}),width:A.width,height:A.height},{x:A.x+A.width/2,y:A.y+A.height/2},u());b.group.name&&n.updateLabel(k,b.group.name),(BE=b.group.members)!=null&&BE.length&&O(k,"bwl:Members",{refs:b.group.members.join(" ")})}{const b=o.filter(I=>!!I.waypoints),S=new Map,A=(I,L)=>{!I||!L||(S.has(I)||S.set(I,new Set),S.get(I).add(L))};for(const I of b){const L=(NE=I.source)==null?void 0:NE.id,H=($E=I.target)==null?void 0:$E.id;A(L,H),((FE=I.type)!=null&&FE.includes("DataOutputAssociation")||(jE=I.type)!=null&&jE.includes("DataInputAssociation")||I.type==="bpmn:Association")&&A(H,L)}const k=o.filter(I=>I.type==="bpmn:Group");for(const I of k){const H=(((HE=I.businessObject.extensionElements)==null?void 0:HE.values)??[]).find(Ce=>Ce.$type==="bwl:Members"),j=((H==null?void 0:H.refs)??"").split(" ").filter(Boolean);if(!j.length)continue;const B=new Set(j),W=[...j];for(;W.length;){const Ce=W.shift();for(const Q of S.get(Ce)??[])B.has(Q)||(B.add(Q),W.push(Q))}const Y=I.x,ae=I.x+I.width,ee=I.y,de=I.y+I.height,pe=Ce=>C.filter(Q=>Q.flow.target===Ce).length,me=Ce=>{var ie;const Q=((ie=p(Ce))==null?void 0:ie.type)??"";if(Q==="bpmn:StartEvent"&&pe(Ce)===0)return!1;if(Q.endsWith("Gateway")){const se=C.filter(ve=>ve.flow.target===Ce).map(ve=>ve.flow.source);if(se.length&&se.every(ve=>{var et;return((et=p(ve))==null?void 0:et.type)==="bpmn:StartEvent"&&pe(ve)===0}))return!1}return!0},Ye=o.filter(Ce=>vr(Ce)).filter(Ce=>Ce.type!=="bpmn:Group"&&Ce.type!=="bpmn:Participant"&&Ce.type!=="bpmn:TextAnnotation"&&!B.has(Ce.id)&&ko(Ce.id)&&me(Ce.id)&&Ce.x<ae&&Ce.x+Ce.width>Y&&Ce.y<de&&Ce.y+Ce.height>ee);if(Ye.length)for(const Ce of[-1,1]){const Q=Ye.filter(be=>(be.x+be.width-Y<=ae-be.x?-1:1)===Ce);if(!Q.length)continue;const ie=[];for(const be of Q){const re=ie.find(ye=>ye.some(Ie=>be.y<Ie.y+Ie.height&&be.y+be.height>Ie.y));re?re.push(be):ie.push([be])}const se=new Map;for(const be of ie){let re=Ce<0?Y-Oo:ae+Oo;for(const ye of[...be].sort((Ie,Be)=>Ce<0?Be.x-Ie.x:Ie.x-Be.x)){const Ie=Ce<0?Math.min(ye.x,re-ye.width):Math.max(ye.x,re);re=Ce<0?Ie-Mi:Ie+ye.width+Mi,Ie!==ye.x&&Math.sign(Ie-ye.x)===Ce&&se.set(ye.id,Ie-ye.x)}}const ve=new Map,et=be=>ve.get(be)===be||!ve.get(be)?be:et(ve.get(be));for(const be of Q)ve.set(be.id,be.id);for(const be of x){const re=se.has(be.flow.source)?be.flow.source:void 0,ye=se.has(be.flow.target)?be.flow.target:void 0;if(!re||!ye)continue;const Ie=p(be.flow.id);((zE=Ie==null?void 0:Ie.waypoints)==null?void 0:zE.length)===2&&ve.set(et(re),et(ye))}const Ve=new Map;for(const be of Q){if(!se.has(be.id))continue;const re=et(be.id);Ve.set(re,[...Ve.get(re)??[],be])}const gt=[...Ve.values()].sort((be,re)=>Ce<0?Math.min(...be.map(ye=>ye.x))-Math.min(...re.map(ye=>ye.x)):Math.max(...re.map(ye=>ye.x))-Math.max(...be.map(ye=>ye.x))),Tt=[];let xe=!0;for(const be of gt){const re=be.map(Be=>se.get(Be.id)??0).reduce((Be,we)=>Math.abs(we)>Math.abs(Be)?we:Be,0),ye=new Map;let Ie=!0;for(const Be of be){const we=d(Be);if(!we){Ie=!1;break}ye.has(we.id)||ye.set(we.id,{subtree:[],pool:we}),ye.get(we.id).subtree.push(Be)}Ie&&To([...ye.values()],re,()=>!0,La)?Tt.push({shapes:be,dx:re}):xe=!1}if(!xe)for(const be of Tt.reverse())n.moveElements(be.shapes,{x:-be.dx,y:0})}}}{const b=new Set([...E.map(S=>S.group.id),...Kt(e,"group.update").map(S=>S.id)]);for(const S of o.filter(A=>A.type==="bpmn:Group")){if(b.has(S.id))continue;const k=(((GE=S.businessObject.extensionElements)==null?void 0:GE.values)??[]).find(j=>j.$type==="bwl:Members"),I=((k==null?void 0:k.refs)??"").split(" ").filter(Boolean).map(p).filter(j=>!!j);!I.length||!I.some(j=>{const B=g.get(j.id);return!B||B.x!==j.x||B.y!==j.y})||!I.some(j=>j.x<S.x||j.y<S.y||j.x+j.width>S.x+S.width||j.y+j.height>S.y+S.height)||n.resizeShape(S,Vh(I,S.id))}}{const S=new Map(co(Ze(o)).map(j=>[j.owner,j.rect])),A=o.filter(j=>!!j.waypoints),k=new Map,I=(j,B)=>{!j||!B||(k.has(j)||k.set(j,new Set),k.get(j).add(B))};for(const j of A){const B=(VE=j.source)==null?void 0:VE.id,W=(WE=j.target)==null?void 0:WE.id;I(B,W),((UE=j.type)!=null&&UE.includes("DataOutputAssociation")||(qE=j.type)!=null&&qE.includes("DataInputAssociation")||j.type==="bpmn:Association")&&I(W,B)}const L=j=>C.filter(B=>B.flow.target===j).length,H=j=>{var W;const B=((W=p(j))==null?void 0:W.type)??"";if(B==="bpmn:StartEvent"&&L(j)===0)return!1;if(B.endsWith("Gateway")){const Y=C.filter(ae=>ae.flow.target===j).map(ae=>ae.flow.source);if(Y.length&&Y.every(ae=>{var ee;return((ee=p(ae))==null?void 0:ee.type)==="bpmn:StartEvent"&&L(ae)===0}))return!1}return!0};for(const j of o.filter(B=>B.type==="bpmn:Group")){const W=(((YE=j.businessObject.extensionElements)==null?void 0:YE.values)??[]).find(re=>re.$type==="bwl:Members"),Y=((W==null?void 0:W.refs)??"").split(" ").filter(Boolean);if(!Y.length)continue;const ae=Y.map(p).filter(re=>!!re);if(!ae.length||!(E.some(re=>re.group.id===j.id)||Kt(e,"group.update").some(re=>re.id===j.id)||ae.some(re=>{const ye=g.get(re.id);return!ye||ye.x!==re.x||ye.y!==re.y})))continue;const de=new Set(Y),pe=[...Y];for(;pe.length;){const re=pe.shift();for(const ye of k.get(re)??[])de.has(ye)||(de.add(ye),pe.push(ye))}const me=j.x,Ye=j.x+j.width,Ce=j.y,Q=j.y+j.height,ie=re=>{const ye=S.get(re.id),Ie={x:re.x,y:re.y,width:re.width,height:re.height};return ye?[Ie,{x:ye.x,y:ye.y,width:ye.width,height:ye.height}]:[Ie]},se=ae.flatMap(ie),ve=Math.min(...se.map(re=>re.x)),et=Math.max(...se.map(re=>re.x+re.width)),Ve=Math.min(...se.map(re=>re.y)),gt=Math.max(...se.map(re=>re.y+re.height)),Tt={L:ve-me,R:Ye-et,T:Ve-Ce,B:Q-gt},xe=o.filter(re=>vr(re)).filter(re=>re.type!=="bpmn:Group"&&re.type!=="bpmn:Participant"&&re.type!=="bpmn:TextAnnotation"&&!de.has(re.id)&&H(re.id)&&re.x<Ye&&re.x+re.width>me&&re.y<Q&&re.y+re.height>Ce);if(!xe.length)continue;const be={L:0,R:0,T:0,B:0};for(const re of xe){const ye=ie(re),Ie=Math.min(...ye.map(ke=>ke.x)),Be=Math.max(...ye.map(ke=>ke.x+ke.width)),we=Math.min(...ye.map(ke=>ke.y)),ot=Math.max(...ye.map(ke=>ke.y+ke.height)),Ke={L:Be-me,R:Ye-Ie,T:ot-Ce,B:Q-we},Mt=["L","R","T","B"].filter(ke=>Ke[ke]<=Tt[ke]+.001);if(!Mt.length)continue;const Pe=Mt.reduce((ke,Xe)=>Ke[Xe]<Ke[ke]?Xe:ke,Mt[0]);be[Pe]=Math.max(be[Pe],Math.min(Ke[Pe]+10,Tt[Pe]))}!be.L&&!be.R&&!be.T&&!be.B||n.resizeShape(j,{x:j.x+be.L,y:j.y+be.T,width:j.width-be.L-be.R,height:j.height-be.T-be.B})}}const SE=b=>{const S=b.waypoints;if(S!=null&&S.length){const k=S[Math.floor((S.length-1)/2)];return{x:k.x,y:k.y,width:0,height:0}}const A=b;return{x:A.x,y:A.y,width:A.width,height:A.height}};let Ys=0;const RE=12,CE=14,s$=15,c$=300,l$=b=>{const S=b.split(`
6
+ `),this},this.appendIndent=function(){return t&&e.write(n.join(" ")),this},this.indent=function(){return n.push(""),this},this.unindent=function(){return n.pop(),this}}function iS(e){e=U({format:!1,preamble:!0},e||{});function t(n,i){var r=i||new tS,o=new nS(r,e.format);e.preamble&&o.append(H1);var a=new Nt,s=n.$model;if(a.getNamespaces().mapDefaultPrefixes(rS(s)),a.build(n).serializeTo(o),!i)return r.value}return{toXML:t}}function rS(e){const t=e.config&&e.config.nsMap||{},n={};for(const i in fp)n[i]=fp[i];for(const i in t){const r=t[i];n[r]=i}for(const i of e.getPackages())n[i.prefix]=i.uri;return n}function uc(e,t){di.call(this,e,t)}uc.prototype=Object.create(di.prototype),uc.prototype.fromXML=function(e,t,n){qn(t)||(n=t,t="bpmn:Definitions");var i=new gp(U({model:this,lax:!0},n)),r=i.handler(t);return i.fromXML(e,r)},uc.prototype.toXML=function(e,t){var n=new iS(t);return new Promise(function(i,r){try{var o=n.toXML(e);return i({xml:o})}catch(a){return r(a)}})};var oS="BPMN20",aS="http://www.omg.org/spec/BPMN/20100524/MODEL",sS="bpmn",cS=[],lS=[{name:"Interface",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"operations",type:"Operation",isMany:!0},{name:"implementationRef",isAttr:!0,type:"String"}]},{name:"Operation",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"inMessageRef",type:"Message",isReference:!0},{name:"outMessageRef",type:"Message",isReference:!0},{name:"errorRef",type:"Error",isMany:!0,isReference:!0},{name:"implementationRef",isAttr:!0,type:"String"}]},{name:"EndPoint",superClass:["RootElement"]},{name:"Auditing",superClass:["BaseElement"]},{name:"GlobalTask",superClass:["CallableElement"],properties:[{name:"resources",type:"ResourceRole",isMany:!0}]},{name:"Monitoring",superClass:["BaseElement"]},{name:"Performer",superClass:["ResourceRole"]},{name:"Process",superClass:["FlowElementsContainer","CallableElement"],properties:[{name:"processType",type:"ProcessType",isAttr:!0},{name:"isClosed",isAttr:!0,type:"Boolean"},{name:"auditing",type:"Auditing"},{name:"monitoring",type:"Monitoring"},{name:"properties",type:"Property",isMany:!0},{name:"laneSets",isMany:!0,replaces:"FlowElementsContainer#laneSets",type:"LaneSet"},{name:"flowElements",isMany:!0,replaces:"FlowElementsContainer#flowElements",type:"FlowElement"},{name:"artifacts",type:"Artifact",isMany:!0},{name:"resources",type:"ResourceRole",isMany:!0},{name:"correlationSubscriptions",type:"CorrelationSubscription",isMany:!0},{name:"supports",type:"Process",isMany:!0,isReference:!0},{name:"definitionalCollaborationRef",type:"Collaboration",isAttr:!0,isReference:!0},{name:"isExecutable",isAttr:!0,type:"Boolean"}]},{name:"LaneSet",superClass:["BaseElement"],properties:[{name:"lanes",type:"Lane",isMany:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Lane",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"partitionElementRef",type:"BaseElement",isAttr:!0,isReference:!0},{name:"partitionElement",type:"BaseElement"},{name:"flowNodeRef",type:"FlowNode",isMany:!0,isReference:!0},{name:"childLaneSet",type:"LaneSet",xml:{serialize:"xsi:type"}}]},{name:"GlobalManualTask",superClass:["GlobalTask"]},{name:"ManualTask",superClass:["Task"]},{name:"UserTask",superClass:["Task"],properties:[{name:"renderings",type:"Rendering",isMany:!0},{name:"implementation",isAttr:!0,type:"String"}]},{name:"Rendering",superClass:["BaseElement"]},{name:"HumanPerformer",superClass:["Performer"]},{name:"PotentialOwner",superClass:["HumanPerformer"]},{name:"GlobalUserTask",superClass:["GlobalTask"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"renderings",type:"Rendering",isMany:!0}]},{name:"Gateway",isAbstract:!0,superClass:["FlowNode"],properties:[{name:"gatewayDirection",type:"GatewayDirection",default:"Unspecified",isAttr:!0}]},{name:"EventBasedGateway",superClass:["Gateway"],properties:[{name:"instantiate",default:!1,isAttr:!0,type:"Boolean"},{name:"eventGatewayType",type:"EventBasedGatewayType",isAttr:!0,default:"Exclusive"}]},{name:"ComplexGateway",superClass:["Gateway"],properties:[{name:"activationCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0}]},{name:"ExclusiveGateway",superClass:["Gateway"],properties:[{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0}]},{name:"InclusiveGateway",superClass:["Gateway"],properties:[{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0}]},{name:"ParallelGateway",superClass:["Gateway"]},{name:"RootElement",isAbstract:!0,superClass:["BaseElement"]},{name:"Relationship",superClass:["BaseElement"],properties:[{name:"type",isAttr:!0,type:"String"},{name:"direction",type:"RelationshipDirection",isAttr:!0},{name:"source",isMany:!0,isReference:!0,type:"Element"},{name:"target",isMany:!0,isReference:!0,type:"Element"}]},{name:"BaseElement",isAbstract:!0,properties:[{name:"id",isAttr:!0,type:"String",isId:!0},{name:"documentation",type:"Documentation",isMany:!0},{name:"extensionDefinitions",type:"ExtensionDefinition",isMany:!0,isReference:!0},{name:"extensionElements",type:"ExtensionElements"}]},{name:"Extension",properties:[{name:"mustUnderstand",default:!1,isAttr:!0,type:"Boolean"},{name:"definition",type:"ExtensionDefinition",isAttr:!0,isReference:!0}]},{name:"ExtensionDefinition",properties:[{name:"name",isAttr:!0,type:"String"},{name:"extensionAttributeDefinitions",type:"ExtensionAttributeDefinition",isMany:!0}]},{name:"ExtensionAttributeDefinition",properties:[{name:"name",isAttr:!0,type:"String"},{name:"type",isAttr:!0,type:"String"},{name:"isReference",default:!1,isAttr:!0,type:"Boolean"},{name:"extensionDefinition",type:"ExtensionDefinition",isAttr:!0,isReference:!0}]},{name:"ExtensionElements",properties:[{name:"valueRef",isAttr:!0,isReference:!0,type:"Element"},{name:"values",type:"Element",isMany:!0},{name:"extensionAttributeDefinition",type:"ExtensionAttributeDefinition",isAttr:!0,isReference:!0}]},{name:"Documentation",superClass:["BaseElement"],properties:[{name:"text",type:"String",isBody:!0},{name:"textFormat",default:"text/plain",isAttr:!0,type:"String"}]},{name:"Event",isAbstract:!0,superClass:["FlowNode","InteractionNode"],properties:[{name:"properties",type:"Property",isMany:!0}]},{name:"IntermediateCatchEvent",superClass:["CatchEvent"]},{name:"IntermediateThrowEvent",superClass:["ThrowEvent"]},{name:"EndEvent",superClass:["ThrowEvent"]},{name:"StartEvent",superClass:["CatchEvent"],properties:[{name:"isInterrupting",default:!0,isAttr:!0,type:"Boolean"}]},{name:"ThrowEvent",isAbstract:!0,superClass:["Event"],properties:[{name:"dataInputs",type:"DataInput",isMany:!0},{name:"dataInputAssociations",type:"DataInputAssociation",isMany:!0},{name:"inputSet",type:"InputSet"},{name:"eventDefinitions",type:"EventDefinition",isMany:!0},{name:"eventDefinitionRef",type:"EventDefinition",isMany:!0,isReference:!0}]},{name:"CatchEvent",isAbstract:!0,superClass:["Event"],properties:[{name:"parallelMultiple",isAttr:!0,type:"Boolean",default:!1},{name:"dataOutputs",type:"DataOutput",isMany:!0},{name:"dataOutputAssociations",type:"DataOutputAssociation",isMany:!0},{name:"outputSet",type:"OutputSet"},{name:"eventDefinitions",type:"EventDefinition",isMany:!0},{name:"eventDefinitionRef",type:"EventDefinition",isMany:!0,isReference:!0}]},{name:"BoundaryEvent",superClass:["CatchEvent"],properties:[{name:"cancelActivity",default:!0,isAttr:!0,type:"Boolean"},{name:"attachedToRef",type:"Activity",isAttr:!0,isReference:!0}]},{name:"EventDefinition",isAbstract:!0,superClass:["RootElement"]},{name:"CancelEventDefinition",superClass:["EventDefinition"]},{name:"ErrorEventDefinition",superClass:["EventDefinition"],properties:[{name:"errorRef",type:"Error",isAttr:!0,isReference:!0}]},{name:"TerminateEventDefinition",superClass:["EventDefinition"]},{name:"EscalationEventDefinition",superClass:["EventDefinition"],properties:[{name:"escalationRef",type:"Escalation",isAttr:!0,isReference:!0}]},{name:"Escalation",properties:[{name:"structureRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"},{name:"escalationCode",isAttr:!0,type:"String"}],superClass:["RootElement"]},{name:"CompensateEventDefinition",superClass:["EventDefinition"],properties:[{name:"waitForCompletion",isAttr:!0,type:"Boolean",default:!0},{name:"activityRef",type:"Activity",isAttr:!0,isReference:!0}]},{name:"TimerEventDefinition",superClass:["EventDefinition"],properties:[{name:"timeDate",type:"Expression",xml:{serialize:"xsi:type"}},{name:"timeCycle",type:"Expression",xml:{serialize:"xsi:type"}},{name:"timeDuration",type:"Expression",xml:{serialize:"xsi:type"}}]},{name:"LinkEventDefinition",superClass:["EventDefinition"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"target",type:"LinkEventDefinition",isReference:!0},{name:"source",type:"LinkEventDefinition",isMany:!0,isReference:!0}]},{name:"MessageEventDefinition",superClass:["EventDefinition"],properties:[{name:"messageRef",type:"Message",isAttr:!0,isReference:!0},{name:"operationRef",type:"Operation",isReference:!0}]},{name:"ConditionalEventDefinition",superClass:["EventDefinition"],properties:[{name:"condition",type:"Expression",xml:{serialize:"xsi:type"}}]},{name:"SignalEventDefinition",superClass:["EventDefinition"],properties:[{name:"signalRef",type:"Signal",isAttr:!0,isReference:!0}]},{name:"Signal",superClass:["RootElement"],properties:[{name:"structureRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"ImplicitThrowEvent",superClass:["ThrowEvent"]},{name:"DataState",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"ItemAwareElement",superClass:["BaseElement"],properties:[{name:"itemSubjectRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"dataState",type:"DataState"}]},{name:"DataAssociation",superClass:["BaseElement"],properties:[{name:"sourceRef",type:"ItemAwareElement",isMany:!0,isReference:!0},{name:"targetRef",type:"ItemAwareElement",isReference:!0},{name:"transformation",type:"FormalExpression",xml:{serialize:"property"}},{name:"assignment",type:"Assignment",isMany:!0}]},{name:"DataInput",superClass:["ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"},{name:"inputSetRef",type:"InputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"inputSetWithOptional",type:"InputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"inputSetWithWhileExecuting",type:"InputSet",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"DataOutput",superClass:["ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"},{name:"outputSetRef",type:"OutputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"outputSetWithOptional",type:"OutputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"outputSetWithWhileExecuting",type:"OutputSet",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"InputSet",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"dataInputRefs",type:"DataInput",isMany:!0,isReference:!0},{name:"optionalInputRefs",type:"DataInput",isMany:!0,isReference:!0},{name:"whileExecutingInputRefs",type:"DataInput",isMany:!0,isReference:!0},{name:"outputSetRefs",type:"OutputSet",isMany:!0,isReference:!0}]},{name:"OutputSet",superClass:["BaseElement"],properties:[{name:"dataOutputRefs",type:"DataOutput",isMany:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"},{name:"inputSetRefs",type:"InputSet",isMany:!0,isReference:!0},{name:"optionalOutputRefs",type:"DataOutput",isMany:!0,isReference:!0},{name:"whileExecutingOutputRefs",type:"DataOutput",isMany:!0,isReference:!0}]},{name:"Property",superClass:["ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"DataInputAssociation",superClass:["DataAssociation"]},{name:"DataOutputAssociation",superClass:["DataAssociation"]},{name:"InputOutputSpecification",superClass:["BaseElement"],properties:[{name:"dataInputs",type:"DataInput",isMany:!0},{name:"dataOutputs",type:"DataOutput",isMany:!0},{name:"inputSets",type:"InputSet",isMany:!0},{name:"outputSets",type:"OutputSet",isMany:!0}]},{name:"DataObject",superClass:["FlowElement","ItemAwareElement"],properties:[{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"}]},{name:"InputOutputBinding",properties:[{name:"inputDataRef",type:"InputSet",isAttr:!0,isReference:!0},{name:"outputDataRef",type:"OutputSet",isAttr:!0,isReference:!0},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0}]},{name:"Assignment",superClass:["BaseElement"],properties:[{name:"from",type:"Expression",xml:{serialize:"xsi:type"}},{name:"to",type:"Expression",xml:{serialize:"xsi:type"}}]},{name:"DataStore",superClass:["RootElement","ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"capacity",isAttr:!0,type:"Integer"},{name:"isUnlimited",default:!0,isAttr:!0,type:"Boolean"}]},{name:"DataStoreReference",superClass:["ItemAwareElement","FlowElement"],properties:[{name:"dataStoreRef",type:"DataStore",isAttr:!0,isReference:!0}]},{name:"DataObjectReference",superClass:["ItemAwareElement","FlowElement"],properties:[{name:"dataObjectRef",type:"DataObject",isAttr:!0,isReference:!0}]},{name:"ConversationLink",superClass:["BaseElement"],properties:[{name:"sourceRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"targetRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"ConversationAssociation",superClass:["BaseElement"],properties:[{name:"innerConversationNodeRef",type:"ConversationNode",isAttr:!0,isReference:!0},{name:"outerConversationNodeRef",type:"ConversationNode",isAttr:!0,isReference:!0}]},{name:"CallConversation",superClass:["ConversationNode"],properties:[{name:"calledCollaborationRef",type:"Collaboration",isAttr:!0,isReference:!0},{name:"participantAssociations",type:"ParticipantAssociation",isMany:!0}]},{name:"Conversation",superClass:["ConversationNode"]},{name:"SubConversation",superClass:["ConversationNode"],properties:[{name:"conversationNodes",type:"ConversationNode",isMany:!0}]},{name:"ConversationNode",isAbstract:!0,superClass:["InteractionNode","BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"participantRef",type:"Participant",isMany:!0,isReference:!0},{name:"messageFlowRefs",type:"MessageFlow",isMany:!0,isReference:!0},{name:"correlationKeys",type:"CorrelationKey",isMany:!0}]},{name:"GlobalConversation",superClass:["Collaboration"]},{name:"PartnerEntity",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"participantRef",type:"Participant",isMany:!0,isReference:!0}]},{name:"PartnerRole",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"participantRef",type:"Participant",isMany:!0,isReference:!0}]},{name:"CorrelationProperty",superClass:["RootElement"],properties:[{name:"correlationPropertyRetrievalExpression",type:"CorrelationPropertyRetrievalExpression",isMany:!0},{name:"name",isAttr:!0,type:"String"},{name:"type",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"Error",superClass:["RootElement"],properties:[{name:"structureRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"},{name:"errorCode",isAttr:!0,type:"String"}]},{name:"CorrelationKey",superClass:["BaseElement"],properties:[{name:"correlationPropertyRef",type:"CorrelationProperty",isMany:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Expression",superClass:["BaseElement"],isAbstract:!1,properties:[{name:"body",isBody:!0,type:"String"}]},{name:"FormalExpression",superClass:["Expression"],properties:[{name:"language",isAttr:!0,type:"String"},{name:"evaluatesToTypeRef",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"Message",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"itemRef",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"ItemDefinition",superClass:["RootElement"],properties:[{name:"itemKind",type:"ItemKind",isAttr:!0},{name:"structureRef",isAttr:!0,type:"String"},{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"},{name:"import",type:"Import",isAttr:!0,isReference:!0}]},{name:"FlowElement",isAbstract:!0,superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"auditing",type:"Auditing"},{name:"monitoring",type:"Monitoring"},{name:"categoryValueRef",type:"CategoryValue",isMany:!0,isReference:!0}]},{name:"SequenceFlow",superClass:["FlowElement"],properties:[{name:"isImmediate",isAttr:!0,type:"Boolean"},{name:"conditionExpression",type:"Expression",xml:{serialize:"xsi:type"}},{name:"sourceRef",type:"FlowNode",isAttr:!0,isReference:!0},{name:"targetRef",type:"FlowNode",isAttr:!0,isReference:!0}]},{name:"FlowElementsContainer",isAbstract:!0,superClass:["BaseElement"],properties:[{name:"laneSets",type:"LaneSet",isMany:!0},{name:"flowElements",type:"FlowElement",isMany:!0}]},{name:"CallableElement",isAbstract:!0,superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"ioSpecification",type:"InputOutputSpecification",xml:{serialize:"property"}},{name:"supportedInterfaceRef",type:"Interface",isMany:!0,isReference:!0},{name:"ioBinding",type:"InputOutputBinding",isMany:!0,xml:{serialize:"property"}}]},{name:"FlowNode",isAbstract:!0,superClass:["FlowElement"],properties:[{name:"incoming",type:"SequenceFlow",isMany:!0,isReference:!0},{name:"outgoing",type:"SequenceFlow",isMany:!0,isReference:!0},{name:"lanes",type:"Lane",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"CorrelationPropertyRetrievalExpression",superClass:["BaseElement"],properties:[{name:"messagePath",type:"FormalExpression"},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"CorrelationPropertyBinding",superClass:["BaseElement"],properties:[{name:"dataPath",type:"FormalExpression"},{name:"correlationPropertyRef",type:"CorrelationProperty",isAttr:!0,isReference:!0}]},{name:"Resource",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"resourceParameters",type:"ResourceParameter",isMany:!0}]},{name:"ResourceParameter",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isRequired",isAttr:!0,type:"Boolean"},{name:"type",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"CorrelationSubscription",superClass:["BaseElement"],properties:[{name:"correlationKeyRef",type:"CorrelationKey",isAttr:!0,isReference:!0},{name:"correlationPropertyBinding",type:"CorrelationPropertyBinding",isMany:!0}]},{name:"MessageFlow",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"sourceRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"targetRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"MessageFlowAssociation",superClass:["BaseElement"],properties:[{name:"innerMessageFlowRef",type:"MessageFlow",isAttr:!0,isReference:!0},{name:"outerMessageFlowRef",type:"MessageFlow",isAttr:!0,isReference:!0}]},{name:"InteractionNode",isAbstract:!0,properties:[{name:"incomingConversationLinks",type:"ConversationLink",isMany:!0,isVirtual:!0,isReference:!0},{name:"outgoingConversationLinks",type:"ConversationLink",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"Participant",superClass:["InteractionNode","BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"interfaceRef",type:"Interface",isMany:!0,isReference:!0},{name:"participantMultiplicity",type:"ParticipantMultiplicity"},{name:"endPointRefs",type:"EndPoint",isMany:!0,isReference:!0},{name:"processRef",type:"Process",isAttr:!0,isReference:!0}]},{name:"ParticipantAssociation",superClass:["BaseElement"],properties:[{name:"innerParticipantRef",type:"Participant",isAttr:!0,isReference:!0},{name:"outerParticipantRef",type:"Participant",isAttr:!0,isReference:!0}]},{name:"ParticipantMultiplicity",properties:[{name:"minimum",default:0,isAttr:!0,type:"Integer"},{name:"maximum",default:1,isAttr:!0,type:"Integer"}],superClass:["BaseElement"]},{name:"Collaboration",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isClosed",isAttr:!0,type:"Boolean"},{name:"participants",type:"Participant",isMany:!0},{name:"messageFlows",type:"MessageFlow",isMany:!0},{name:"artifacts",type:"Artifact",isMany:!0},{name:"conversations",type:"ConversationNode",isMany:!0},{name:"conversationAssociations",type:"ConversationAssociation"},{name:"participantAssociations",type:"ParticipantAssociation",isMany:!0},{name:"messageFlowAssociations",type:"MessageFlowAssociation",isMany:!0},{name:"correlationKeys",type:"CorrelationKey",isMany:!0},{name:"choreographyRef",type:"Choreography",isMany:!0,isReference:!0},{name:"conversationLinks",type:"ConversationLink",isMany:!0}]},{name:"ChoreographyActivity",isAbstract:!0,superClass:["FlowNode"],properties:[{name:"participantRef",type:"Participant",isMany:!0,isReference:!0},{name:"initiatingParticipantRef",type:"Participant",isAttr:!0,isReference:!0},{name:"correlationKeys",type:"CorrelationKey",isMany:!0},{name:"loopType",type:"ChoreographyLoopType",default:"None",isAttr:!0}]},{name:"CallChoreography",superClass:["ChoreographyActivity"],properties:[{name:"calledChoreographyRef",type:"Choreography",isAttr:!0,isReference:!0},{name:"participantAssociations",type:"ParticipantAssociation",isMany:!0}]},{name:"SubChoreography",superClass:["ChoreographyActivity","FlowElementsContainer"],properties:[{name:"artifacts",type:"Artifact",isMany:!0}]},{name:"ChoreographyTask",superClass:["ChoreographyActivity"],properties:[{name:"messageFlowRef",type:"MessageFlow",isMany:!0,isReference:!0}]},{name:"Choreography",superClass:["Collaboration","FlowElementsContainer"]},{name:"GlobalChoreographyTask",superClass:["Choreography"],properties:[{name:"initiatingParticipantRef",type:"Participant",isAttr:!0,isReference:!0}]},{name:"TextAnnotation",superClass:["Artifact"],properties:[{name:"text",type:"String"},{name:"textFormat",default:"text/plain",isAttr:!0,type:"String"}]},{name:"Group",superClass:["Artifact"],properties:[{name:"categoryValueRef",type:"CategoryValue",isAttr:!0,isReference:!0}]},{name:"Association",superClass:["Artifact"],properties:[{name:"associationDirection",type:"AssociationDirection",isAttr:!0},{name:"sourceRef",type:"BaseElement",isAttr:!0,isReference:!0},{name:"targetRef",type:"BaseElement",isAttr:!0,isReference:!0}]},{name:"Category",superClass:["RootElement"],properties:[{name:"categoryValue",type:"CategoryValue",isMany:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Artifact",isAbstract:!0,superClass:["BaseElement"]},{name:"CategoryValue",superClass:["BaseElement"],properties:[{name:"categorizedFlowElements",type:"FlowElement",isMany:!0,isVirtual:!0,isReference:!0},{name:"value",isAttr:!0,type:"String"}]},{name:"Activity",isAbstract:!0,superClass:["FlowNode"],properties:[{name:"isForCompensation",default:!1,isAttr:!0,type:"Boolean"},{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0},{name:"ioSpecification",type:"InputOutputSpecification",xml:{serialize:"property"}},{name:"boundaryEventRefs",type:"BoundaryEvent",isMany:!0,isReference:!0},{name:"properties",type:"Property",isMany:!0},{name:"dataInputAssociations",type:"DataInputAssociation",isMany:!0},{name:"dataOutputAssociations",type:"DataOutputAssociation",isMany:!0},{name:"startQuantity",default:1,isAttr:!0,type:"Integer"},{name:"resources",type:"ResourceRole",isMany:!0},{name:"completionQuantity",default:1,isAttr:!0,type:"Integer"},{name:"loopCharacteristics",type:"LoopCharacteristics"}]},{name:"ServiceTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0}]},{name:"SubProcess",superClass:["Activity","FlowElementsContainer","InteractionNode"],properties:[{name:"triggeredByEvent",default:!1,isAttr:!0,type:"Boolean"},{name:"artifacts",type:"Artifact",isMany:!0}]},{name:"LoopCharacteristics",isAbstract:!0,superClass:["BaseElement"]},{name:"MultiInstanceLoopCharacteristics",superClass:["LoopCharacteristics"],properties:[{name:"isSequential",default:!1,isAttr:!0,type:"Boolean"},{name:"behavior",type:"MultiInstanceBehavior",default:"All",isAttr:!0},{name:"loopCardinality",type:"Expression",xml:{serialize:"xsi:type"}},{name:"loopDataInputRef",type:"ItemAwareElement",isReference:!0},{name:"loopDataOutputRef",type:"ItemAwareElement",isReference:!0},{name:"inputDataItem",type:"DataInput",xml:{serialize:"property"}},{name:"outputDataItem",type:"DataOutput",xml:{serialize:"property"}},{name:"complexBehaviorDefinition",type:"ComplexBehaviorDefinition",isMany:!0},{name:"completionCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"oneBehaviorEventRef",type:"EventDefinition",isAttr:!0,isReference:!0},{name:"noneBehaviorEventRef",type:"EventDefinition",isAttr:!0,isReference:!0}]},{name:"StandardLoopCharacteristics",superClass:["LoopCharacteristics"],properties:[{name:"testBefore",default:!1,isAttr:!0,type:"Boolean"},{name:"loopCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"loopMaximum",type:"Integer",isAttr:!0}]},{name:"CallActivity",superClass:["Activity","InteractionNode"],properties:[{name:"calledElement",type:"String",isAttr:!0}]},{name:"Task",superClass:["Activity","InteractionNode"]},{name:"SendTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"ReceiveTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"instantiate",default:!1,isAttr:!0,type:"Boolean"},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"ScriptTask",superClass:["Task"],properties:[{name:"scriptFormat",isAttr:!0,type:"String"},{name:"script",type:"String"}]},{name:"BusinessRuleTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"}]},{name:"AdHocSubProcess",superClass:["SubProcess"],properties:[{name:"completionCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"ordering",type:"AdHocOrdering",isAttr:!0},{name:"cancelRemainingInstances",default:!0,isAttr:!0,type:"Boolean"}]},{name:"Transaction",superClass:["SubProcess"],properties:[{name:"protocol",isAttr:!0,type:"String"},{name:"method",isAttr:!0,type:"String"}]},{name:"GlobalScriptTask",superClass:["GlobalTask"],properties:[{name:"scriptLanguage",isAttr:!0,type:"String"},{name:"script",isAttr:!0,type:"String"}]},{name:"GlobalBusinessRuleTask",superClass:["GlobalTask"],properties:[{name:"implementation",isAttr:!0,type:"String"}]},{name:"ComplexBehaviorDefinition",superClass:["BaseElement"],properties:[{name:"condition",type:"FormalExpression"},{name:"event",type:"ImplicitThrowEvent"}]},{name:"ResourceRole",superClass:["BaseElement"],properties:[{name:"resourceRef",type:"Resource",isReference:!0},{name:"resourceParameterBindings",type:"ResourceParameterBinding",isMany:!0},{name:"resourceAssignmentExpression",type:"ResourceAssignmentExpression"},{name:"name",isAttr:!0,type:"String"}]},{name:"ResourceParameterBinding",properties:[{name:"expression",type:"Expression",xml:{serialize:"xsi:type"}},{name:"parameterRef",type:"ResourceParameter",isAttr:!0,isReference:!0}],superClass:["BaseElement"]},{name:"ResourceAssignmentExpression",properties:[{name:"expression",type:"Expression",xml:{serialize:"xsi:type"}}],superClass:["BaseElement"]},{name:"Import",properties:[{name:"importType",isAttr:!0,type:"String"},{name:"location",isAttr:!0,type:"String"},{name:"namespace",isAttr:!0,type:"String"}]},{name:"Definitions",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"targetNamespace",isAttr:!0,type:"String"},{name:"expressionLanguage",default:"http://www.w3.org/1999/XPath",isAttr:!0,type:"String"},{name:"typeLanguage",default:"http://www.w3.org/2001/XMLSchema",isAttr:!0,type:"String"},{name:"imports",type:"Import",isMany:!0},{name:"extensions",type:"Extension",isMany:!0},{name:"rootElements",type:"RootElement",isMany:!0},{name:"diagrams",isMany:!0,type:"bpmndi:BPMNDiagram"},{name:"exporter",isAttr:!0,type:"String"},{name:"relationships",type:"Relationship",isMany:!0},{name:"exporterVersion",isAttr:!0,type:"String"}]}],uS=[{name:"ProcessType",literalValues:[{name:"None"},{name:"Public"},{name:"Private"}]},{name:"GatewayDirection",literalValues:[{name:"Unspecified"},{name:"Converging"},{name:"Diverging"},{name:"Mixed"}]},{name:"EventBasedGatewayType",literalValues:[{name:"Parallel"},{name:"Exclusive"}]},{name:"RelationshipDirection",literalValues:[{name:"None"},{name:"Forward"},{name:"Backward"},{name:"Both"}]},{name:"ItemKind",literalValues:[{name:"Physical"},{name:"Information"}]},{name:"ChoreographyLoopType",literalValues:[{name:"None"},{name:"Standard"},{name:"MultiInstanceSequential"},{name:"MultiInstanceParallel"}]},{name:"AssociationDirection",literalValues:[{name:"None"},{name:"One"},{name:"Both"}]},{name:"MultiInstanceBehavior",literalValues:[{name:"None"},{name:"One"},{name:"All"},{name:"Complex"}]},{name:"AdHocOrdering",literalValues:[{name:"Parallel"},{name:"Sequential"}]}],pS={tagAlias:"lowerCase",typePrefix:"t"},fS={name:oS,uri:aS,prefix:sS,associations:cS,types:lS,enumerations:uS,xml:pS},dS="BPMNDI",hS="http://www.omg.org/spec/BPMN/20100524/DI",mS="bpmndi",gS=[{name:"BPMNDiagram",properties:[{name:"plane",type:"BPMNPlane",redefines:"di:Diagram#rootElement"},{name:"labelStyle",type:"BPMNLabelStyle",isMany:!0}],superClass:["di:Diagram"]},{name:"BPMNPlane",properties:[{name:"bpmnElement",isAttr:!0,isReference:!0,type:"bpmn:BaseElement",redefines:"di:DiagramElement#modelElement"}],superClass:["di:Plane"]},{name:"BPMNShape",properties:[{name:"bpmnElement",isAttr:!0,isReference:!0,type:"bpmn:BaseElement",redefines:"di:DiagramElement#modelElement"},{name:"isHorizontal",isAttr:!0,type:"Boolean"},{name:"isExpanded",isAttr:!0,type:"Boolean"},{name:"isMarkerVisible",isAttr:!0,type:"Boolean"},{name:"label",type:"BPMNLabel"},{name:"isMessageVisible",isAttr:!0,type:"Boolean"},{name:"participantBandKind",type:"ParticipantBandKind",isAttr:!0},{name:"choreographyActivityShape",type:"BPMNShape",isAttr:!0,isReference:!0}],superClass:["di:LabeledShape"]},{name:"BPMNEdge",properties:[{name:"label",type:"BPMNLabel"},{name:"bpmnElement",isAttr:!0,isReference:!0,type:"bpmn:BaseElement",redefines:"di:DiagramElement#modelElement"},{name:"sourceElement",isAttr:!0,isReference:!0,type:"di:DiagramElement",redefines:"di:Edge#source"},{name:"targetElement",isAttr:!0,isReference:!0,type:"di:DiagramElement",redefines:"di:Edge#target"},{name:"messageVisibleKind",type:"MessageVisibleKind",isAttr:!0,default:"initiating"}],superClass:["di:LabeledEdge"]},{name:"BPMNLabel",properties:[{name:"labelStyle",type:"BPMNLabelStyle",isAttr:!0,isReference:!0,redefines:"di:DiagramElement#style"}],superClass:["di:Label"]},{name:"BPMNLabelStyle",properties:[{name:"font",type:"dc:Font"}],superClass:["di:Style"]}],yS=[{name:"ParticipantBandKind",literalValues:[{name:"top_initiating"},{name:"middle_initiating"},{name:"bottom_initiating"},{name:"top_non_initiating"},{name:"middle_non_initiating"},{name:"bottom_non_initiating"}]},{name:"MessageVisibleKind",literalValues:[{name:"initiating"},{name:"non_initiating"}]}],vS=[],bS={name:dS,uri:hS,prefix:mS,types:gS,enumerations:yS,associations:vS},xS="DC",_S="http://www.omg.org/spec/DD/20100524/DC",wS="dc",ES=[{name:"Boolean"},{name:"Integer"},{name:"Real"},{name:"String"},{name:"Font",properties:[{name:"name",type:"String",isAttr:!0},{name:"size",type:"Real",isAttr:!0},{name:"isBold",type:"Boolean",isAttr:!0},{name:"isItalic",type:"Boolean",isAttr:!0},{name:"isUnderline",type:"Boolean",isAttr:!0},{name:"isStrikeThrough",type:"Boolean",isAttr:!0}]},{name:"Point",properties:[{name:"x",type:"Real",default:"0",isAttr:!0},{name:"y",type:"Real",default:"0",isAttr:!0}]},{name:"Bounds",properties:[{name:"x",type:"Real",default:"0",isAttr:!0},{name:"y",type:"Real",default:"0",isAttr:!0},{name:"width",type:"Real",isAttr:!0},{name:"height",type:"Real",isAttr:!0}]}],SS=[],RS={name:xS,uri:_S,prefix:wS,types:ES,associations:SS},CS="DI",MS="http://www.omg.org/spec/DD/20100524/DI",AS="di",PS=[{name:"DiagramElement",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"extension",type:"Extension"},{name:"owningDiagram",type:"Diagram",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"owningElement",type:"DiagramElement",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"modelElement",isReadOnly:!0,isVirtual:!0,isReference:!0,type:"Element"},{name:"style",type:"Style",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"ownedElement",type:"DiagramElement",isReadOnly:!0,isMany:!0,isVirtual:!0}]},{name:"Node",isAbstract:!0,superClass:["DiagramElement"]},{name:"Edge",isAbstract:!0,superClass:["DiagramElement"],properties:[{name:"source",type:"DiagramElement",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"target",type:"DiagramElement",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"waypoint",isUnique:!1,isMany:!0,type:"dc:Point",xml:{serialize:"xsi:type"}}]},{name:"Diagram",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"rootElement",type:"DiagramElement",isReadOnly:!0,isVirtual:!0},{name:"name",isAttr:!0,type:"String"},{name:"documentation",isAttr:!0,type:"String"},{name:"resolution",isAttr:!0,type:"Real"},{name:"ownedStyle",type:"Style",isReadOnly:!0,isMany:!0,isVirtual:!0}]},{name:"Shape",isAbstract:!0,superClass:["Node"],properties:[{name:"bounds",type:"dc:Bounds"}]},{name:"Plane",isAbstract:!0,superClass:["Node"],properties:[{name:"planeElement",type:"DiagramElement",subsettedProperty:"DiagramElement-ownedElement",isMany:!0}]},{name:"LabeledEdge",isAbstract:!0,superClass:["Edge"],properties:[{name:"ownedLabel",type:"Label",isReadOnly:!0,subsettedProperty:"DiagramElement-ownedElement",isMany:!0,isVirtual:!0}]},{name:"LabeledShape",isAbstract:!0,superClass:["Shape"],properties:[{name:"ownedLabel",type:"Label",isReadOnly:!0,subsettedProperty:"DiagramElement-ownedElement",isMany:!0,isVirtual:!0}]},{name:"Label",isAbstract:!0,superClass:["Node"],properties:[{name:"bounds",type:"dc:Bounds"}]},{name:"Style",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"}]},{name:"Extension",properties:[{name:"values",isMany:!0,type:"Element"}]}],TS=[],kS={tagAlias:"lowerCase"},OS={name:CS,uri:MS,prefix:AS,types:PS,associations:TS,xml:kS},DS="bpmn.io colors for BPMN",LS="http://bpmn.io/schema/bpmn/biocolor/1.0",IS="bioc",BS=[{name:"ColoredShape",extends:["bpmndi:BPMNShape"],properties:[{name:"stroke",isAttr:!0,type:"String"},{name:"fill",isAttr:!0,type:"String"}]},{name:"ColoredEdge",extends:["bpmndi:BPMNEdge"],properties:[{name:"stroke",isAttr:!0,type:"String"},{name:"fill",isAttr:!0,type:"String"}]}],NS=[],$S=[],FS={name:DS,uri:LS,prefix:IS,types:BS,enumerations:NS,associations:$S},jS="BPMN in Color",HS="http://www.omg.org/spec/BPMN/non-normative/color/1.0",zS="color",GS=[{name:"ColoredLabel",extends:["bpmndi:BPMNLabel"],properties:[{name:"color",isAttr:!0,type:"String"}]},{name:"ColoredShape",extends:["bpmndi:BPMNShape"],properties:[{name:"background-color",isAttr:!0,type:"String"},{name:"border-color",isAttr:!0,type:"String"}]},{name:"ColoredEdge",extends:["bpmndi:BPMNEdge"],properties:[{name:"border-color",isAttr:!0,type:"String"}]}],VS=[],WS=[],US={name:jS,uri:HS,prefix:zS,types:GS,enumerations:VS,associations:WS};const qS={bpmn:fS,bpmndi:bS,dc:RS,di:OS,bioc:FS,color:US};function wm(e,t){const n=U({},qS,e);return new uc(n,t)}const YS={name:"bpmn-i18n",uri:"http://www.omg.org/spec/BPMN/non-normative/extensions/i18n/1.0",prefix:"i18n",types:[{name:"Translation",superClass:["Element"],properties:[{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"body",isBody:!0,type:"String"},{name:"target",isAttr:!0,type:"String",default:"@name"},{name:"textFormat",isAttr:"true",type:"String",default:"text/plain"}]}],enumerations:[],associations:[],xml:{tagAlias:"lowerCase",typePrefix:"t"}},pc={[nm]:YS,[qu]:Zh};function Em(){return wm(pc)}const Sm=Em();async function zo(e){const{rootElement:t,warnings:n}=await Sm.fromXML(e,"bpmn:Definitions");return{definitions:t,warnings:n}}async function KS(e){const{xml:t}=await Sm.toXML(e,{format:!0});return t}function bp(e){return e.map(t=>typeof t=="string"?t:t.message??String(t))}const Go={cjkEm:.865,upperEm:.68,lowerEm:.5,digitEm:.556,spaceEm:.278,otherEm:.35,ascentEm:.9,descentEm:.25},XS=/[ᄀ-ᇿ -〿぀-ヿ㐀-鿿가-힯＀-⦆]/;function ZS(e){const t=Go;return XS.test(e)?t.cjkEm:e===" "?t.spaceEm:e>="0"&&e<="9"?t.digitEm:e>="A"&&e<="Z"?t.upperEm:e>="a"&&e<="z"?t.lowerEm:t.otherEm}function Vo(e,t){let n=0;for(const i of e)n+=t*ZS(i);return n}function Rm(e=globalThis,{textMeasurement:t="approximate"}={}){if(!(e!=null&&e.SVGElement))throw new Error("installHeadlessBpmnDom: DOM 전역이 없다 — jsdom window 를 전역에 올린 뒤 호출할 것");t==="approximate"&&QS(e),JS(e),eR(e),tR(e)}function QS(e){var i;const t=(i=e.HTMLCanvasElement)==null?void 0:i.prototype;if(!t||t.__headlessTextMeasurement)return;t.__headlessTextMeasurement=!0;const n={font:"12px sans-serif",letterSpacing:"0px",measureText(r){var a;const o=Number.parseFloat(((a=String(n.font).match(/(\d+(?:\.\d+)?)px/))==null?void 0:a[1])??"12");return{width:Vo(r,o),fontBoundingBoxAscent:o*Go.ascentEm,fontBoundingBoxDescent:o*Go.descentEm,actualBoundingBoxAscent:o*Go.ascentEm,actualBoundingBoxDescent:o*Go.descentEm}}};t.getContext=()=>n}function JS(e){if(e.SVGMatrix)return;class t{constructor(){fi(this,"a",1);fi(this,"b",0);fi(this,"c",0);fi(this,"d",1);fi(this,"e",0);fi(this,"f",0)}static of(i,r,o,a,s,c){return Object.assign(new t,{a:i,b:r,c:o,d:a,e:s,f:c})}multiply(i){return t.of(this.a*i.a+this.c*i.b,this.b*i.a+this.d*i.b,this.a*i.c+this.c*i.d,this.b*i.c+this.d*i.d,this.a*i.e+this.c*i.f+this.e,this.b*i.e+this.d*i.f+this.f)}translate(i,r){return this.multiply(t.of(1,0,0,1,i,r))}scale(i,r=i){return this.multiply(t.of(i,0,0,r,0,0))}inverse(){const i=this.a*this.d-this.b*this.c;return t.of(this.d/i,-this.b/i,-this.c/i,this.a/i,(this.c*this.f-this.d*this.e)/i,(this.b*this.e-this.a*this.f)/i)}}e.SVGMatrix=t}function eR(e){var o;const t=()=>{const a=new e.SVGMatrix;return{type:0,matrix:a,setTranslate(s,c){a.e=s,a.f=c},setScale(s,c){a.a=s,a.d=c},setRotate(s,c=0,l=0){const u=s*Math.PI/180,p=Math.cos(u),f=Math.sin(u);a.a=p,a.b=f,a.c=-f,a.d=p,a.e=c-p*c+f*l,a.f=l-f*c-p*l},setMatrix(s){Object.assign(a,s)}}},n=a=>{const s=t();return Object.assign(s.matrix,a),s},i=(o=e.SVGSVGElement)==null?void 0:o.prototype;i&&!i.createSVGTransform&&(i.createSVGTransform=t,i.createSVGTransformFromMatrix=n,i.createSVGMatrix=()=>new e.SVGMatrix,i.createSVGPoint=()=>({x:0,y:0,matrixTransform:()=>({x:0,y:0})}));const r=e.SVGElement.prototype;Object.getOwnPropertyDescriptor(r,"transform")||Object.defineProperty(r,"transform",{configurable:!0,get(){if(!this.__headlessTransformList){const a=[];this.__headlessTransformList={baseVal:{get numberOfItems(){return a.length},clear:()=>{a.length=0},appendItem:s=>(a.push(s),s),getItem:s=>a[s],createSVGTransformFromMatrix:n,consolidate:()=>a[a.length-1]??null}}}return this.__headlessTransformList}})}function tR(e){const t=e.SVGElement.prototype;if(!t.getCTM){const n=()=>new e.SVGMatrix;t.getCTM=n,t.getScreenCTM=n}t.getBBox||(t.getBBox=function(){const n=String(this.textContent??"");return{x:0,y:0,width:Vo(n,12),height:14}})}const fc=new Set(["bpmn:Participant","bpmn:Lane","bpmn:Group","bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),nR=new Set(["bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),iR=1,dc=new Set(["bpmn:TextAnnotation","bpmn:DataStoreReference","bpmn:DataObjectReference","bpmn:DataInput","bpmn:DataOutput"]),rR=2;function lt(e){switch(e.kind){case"label-over-line":return`L|${e.edge}|${e.line}`;case"label-over-shape":return`ls|${e.edge}|${e.shape}`;case"edge-crosses-shape":return`x|${e.edge}|${e.shape}`;case"edge-endpoint-detached":return`d|${e.edge}|${e.shape}`;case"shape-overlap":return`o|${e.shapes[0]}|${e.shapes[1]}`;case"shape-outside-container":return`c|${e.shape}|${e.container}`;case"edge-overlap-opposite":return`p|${e.edges[0]}|${e.edges[1]}`;case"edge-overlap-mixed":return`m|${e.edges[0]}|${e.edges[1]}`;case"edge-overlap-unrelated":return`u|${e.edges[0]}|${e.edges[1]}`;case"label-on-shared-segment":return`l|${e.edge}|${e.other}`;case"annotation-over-label":return`a|${e.annotation}|${e.label}`;case"pool-overlap":return`P|${e.pools[0]}|${e.pools[1]}`;case"edge-crosses-subprocess":return`S|${e.edge}|${e.subProcess}`;case"group-overlap-unintended":return`g|${e.groups[0]}|${e.groups[1]}${e.container?`|⊃${e.container}`:""}`;case"group-overlap-unreadable":return e.reason==="minority"?`gu*|${e.group}|${e.shapes.join(",")}`:e.reason==="throughpass"?`gu>|${e.group}|${e.shapes.join(",")}`:`gu|${e.groups[0]}|${e.groups[1]}|${e.shapes.join(",")}`;case"group-stack-unreadable":return`gs|${e.groups.join("|")}|${e.shapes.join(",")}`;case"group-on-container-boundary":return`gb|${e.group}|${e.container}|${e.side}`;case"group-on-group-boundary":return`gg|${e.groups[0]}|${e.groups[1]}|${e.axis}`;case"group-cuts-shape":return`gc|${e.group}|${e.shape}|${e.side}`;case"edge-along-group-boundary":return`eg|${e.edge}|${e.group}`;case"pool-name-over-label":return`pn|${e.pool}|${e.label}`}}const Cm=20,hc=5,Mm=3,oR=8,Wo=15,xp=50,Am=12,aR=Am*1.2;function _p(e,t){const n=t.split(/\r?\n/),i=Math.max(...n.map(o=>Vo(o,Am))),r=n.length*aR;return{x:e.x+e.width/2-i/2,y:e.y+e.height/2-r/2,width:i,height:r}}const Pm=1;function gn(e){const t=[];for(let n=0;n+1<e.waypoints.length;n++){const i=e.waypoints[n],r=e.waypoints[n+1];Math.abs(i.y-r.y)<.5&&Math.abs(i.x-r.x)>=.5?t.push({axis:"h",at:i.y,lo:Math.min(i.x,r.x),hi:Math.max(i.x,r.x),dir:r.x>i.x?1:-1}):Math.abs(i.x-r.x)<.5&&Math.abs(i.y-r.y)>=.5&&t.push({axis:"v",at:i.x,lo:Math.min(i.y,r.y),hi:Math.max(i.y,r.y),dir:r.y>i.y?1:-1})}return t}function Uo(e,t){let n=null;const i=e.type!==t.type,o=!!(e.source&&e.target&&t.source&&t.target)&&e.source!==t.source&&e.source!==t.target&&e.target!==t.source&&e.target!==t.target;for(const a of gn(e))for(const s of gn(t)){if(a.axis!==s.axis||Math.abs(a.at-s.at)>Pm)continue;const c=a.dir!==s.dir?"opposite":i?"mixed":o?"unrelated":null;if(!c)continue;const l=Math.min(a.hi,s.hi)-Math.max(a.lo,s.lo);l>=Cm&&(!n||l>n.length)&&(n={axis:a.axis,length:l,kind:c})}return n}function wp(e){return e.kind==="edge-overlap-opposite"||e.kind==="edge-overlap-mixed"||e.kind==="edge-overlap-unrelated"}function Tm(e,t){const n=Uo(e,t);return n&&n.kind==="opposite"?{axis:n.axis,length:n.length}:null}function sR(e,t){let n=0;for(const i of t)i.id!==e.id&&Tm(e,i)&&n++;return n}function ai(e,t){let n=0;for(const i of t)i.id!==e.id&&Uo(e,i)&&n++;return n}const km=15,Om=20;function cR(e,t){const n=t.axis==="v"?[e.x,e.x+e.width]:[e.y,e.y+e.height];if(t.at<n[0]-Om||t.at>n[1]+Om)return null;const i=t.axis==="v"?[e.y,e.y+e.height]:[e.x,e.x+e.width],r=Math.max(i[0],t.lo),o=Math.min(i[1],t.hi);return o>r?[r,o]:null}const Ep=20;function mc(e,t){const n=[];for(const i of t){if(i.axis!==e.axis||Math.abs(i.at-e.at)>Pm)continue;const r=Math.max(e.lo,i.lo),o=Math.min(e.hi,i.hi);o-r<Cm||n.push([r-Ep,o+Ep])}return n}function gc(e,t){const n=e.label;if(!n)return null;let i=null;for(const r of gn(e)){const o=cR(n,r);if(o){for(const a of t)if(a.id!==e.id&&!(i&&a.id>=i.other)){for(const[s,c]of mc(r,gn(a)))if(Math.min(c,o[1])>Math.max(s,o[0])){i={other:a.id,axis:r.axis};break}}}}return i}const lR=10,uR=1,pR=(e,t,n)=>t.x>=e.x-n&&t.y>=e.y-n&&t.x+t.width<=e.x+e.width+n&&t.y+t.height<=e.y+e.height+n;function fR(e,t,n,i){const r=n.x+i,o=n.y+i,a=n.x+n.width-i,s=n.y+n.height-i;if(a<=r||s<=o)return!1;const c=t.x-e.x,l=t.y-e.y;let u=0,p=1;const f=(d,g)=>{if(g===0)return d<=0;const h=d/g;if(g>0){if(h>p)return!1;h>u&&(u=h)}else{if(h<u)return!1;h<p&&(p=h)}return!0};return f(r-e.x,c)&&f(e.x-a,-c)&&f(o-e.y,l)&&f(e.y-s,-l)&&p>u}function Sp(e,t,n){return e.x+n<t.x+t.width-n&&t.x+n<e.x+e.width-n&&e.y+n<t.y+t.height-n&&t.y+n<e.y+e.height-n}const dR=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,qo=1;function Fi(e,t){const n=e.x+qo,i=e.x+e.width-qo,r=e.y+qo,o=e.y+e.height-qo;return t.axis==="h"?t.at>r&&t.at<o&&t.lo<i&&t.hi>n:t.at>n&&t.at<i&&t.lo<o&&t.hi>r}function Yo(e){return[{axis:"h",at:e.y,lo:e.x,hi:e.x+e.width,dir:1},{axis:"h",at:e.y+e.height,lo:e.x,hi:e.x+e.width,dir:1},{axis:"v",at:e.x,lo:e.y,hi:e.y+e.height,dir:1},{axis:"v",at:e.x+e.width,lo:e.y,hi:e.y+e.height,dir:1}]}function Dm(e,t){const n=e.label;if(!n)return null;if(gn(e).some(i=>Fi(n,i)))return e.id;for(const i of[...t.edges].filter(r=>r.id!==e.id).sort((r,o)=>r.id.localeCompare(o.id)))if(gn(i).some(r=>Fi(n,r)))return i.id;for(const i of t.shapes.filter(r=>r.container).sort((r,o)=>r.id.localeCompare(o.id)))if(Yo(i).some(r=>Fi(n,r)))return i.id;return null}function xn(e,t){const n=new Set(e.endpoints),i=[];for(const r of t)if(!n.has(r.id)){for(let o=0;o+1<e.waypoints.length;o++)if(fR(e.waypoints[o],e.waypoints[o+1],r,rR)){i.push(r);break}}return i}const ja=(e,t,n)=>{const i=n.x-t.x,r=n.y-t.y,o=i*i+r*r,a=o===0?0:Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*r)/o));return Math.hypot(e.x-(t.x+a*i),e.y-(t.y+a*r))},hR=(e,t,n,i)=>Im(e,t,n,i)?0:Math.min(ja(e,n,i),ja(t,n,i),ja(n,e,t),ja(i,e,t)),Lm=(e,t)=>{let n=!1;for(let i=0,r=t.length-1;i<t.length;r=i++){const o=t[i],a=t[r];o.y>e.y!=a.y>e.y&&e.x<(a.x-o.x)*(e.y-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n};function yc(e,t,n){const{x:i,y:r,width:o,height:a}=n;if(/Event$/.test(n.type)){const l=Math.min(o,a)/2;return Math.max(0,ja({x:i+o/2,y:r+a/2},e,t)-l)}const s=/Gateway$/.test(n.type)?[{x:i+o/2,y:r},{x:i+o,y:r+a/2},{x:i+o/2,y:r+a},{x:i,y:r+a/2}]:[{x:i,y:r},{x:i+o,y:r},{x:i+o,y:r+a},{x:i,y:r+a}];if(Lm(e,s)||Lm(t,s))return 0;let c=1/0;for(let l=0;l<s.length;l++)c=Math.min(c,hR(e,t,s[l],s[(l+1)%s.length]));return c}function Im(e,t,n,i){const r=(l,u,p)=>(u.x-l.x)*(p.y-l.y)-(u.y-l.y)*(p.x-l.x),o=r(n,i,e),a=r(n,i,t),s=r(e,t,n),c=r(e,t,i);return o*a<0&&s*c<0}const Bm=(e,t)=>e.endpoints.some(n=>t.endpoints.includes(n));function Ha(e,t){let n=0;for(const i of t){if(i.id===e.id||Bm(e,i))continue;let r=!1;for(let o=0;o+1<e.waypoints.length&&!r;o++)for(let a=0;a+1<i.waypoints.length&&!r;a++)Im(e.waypoints[o],e.waypoints[o+1],i.waypoints[a],i.waypoints[a+1])&&(r=!0);r&&n++}return n}function si(e,t){let n=0;for(const i of t)i.id===e.id||Bm(e,i)||Ha(e,[i])>0&&(n+=i.type===e.type?2:1);return n}function Nm(e){let t=0;const n=e.edges;for(let i=0;i<n.length;i++)for(let r=i+1;r<n.length;r++)Ha(n[i],[n[r]])>0&&(t+=n[i].type===n[r].type?2:1);return t}function vc(e){const t=[],n=e.edges;for(let i=0;i<n.length;i++)for(let r=i+1;r<n.length;r++)if(Ha(n[i],[n[r]])>0){const o=n[i].id,a=n[r].id;t.push(o<a?[o,a]:[a,o])}return t.sort((i,r)=>`${i[0]}|${i[1]}`.localeCompare(`${r[0]}|${r[1]}`))}function $m(e){const t=vc(e),n=a=>a==="bpmn:MessageFlow"||a.endsWith("Association")?"dashed":"solid",i=new Map(e.edges.map(a=>[a.id,a]));let r=0,o=0;for(const[a,s]of t){const c=i.get(a),l=i.get(s);if(!c||!l)continue;const u=n(c.type),p=n(l.type);u==="solid"&&p==="solid"?r++:u==="dashed"&&p==="dashed"&&o++}return{pairs:t,solidPairs:r,dashedPairs:o,mixedPairs:t.length-r-o,crossPoolMessages:mR(e)}}function mR(e){const t=e.shapes.filter(r=>r.type==="bpmn:Participant");if(t.length<3)return 0;const n=r=>{const o=e.shapes.find(a=>a.id===r);if(o)return t.find(a=>o.x>=a.x&&o.y>=a.y&&o.x+o.width<=a.x+a.width&&o.y+o.height<=a.y+a.height)};let i=0;for(const r of e.edges){if(r.type!=="bpmn:MessageFlow"||r.endpoints.length<2)continue;const o=n(r.endpoints[0]),a=n(r.endpoints[1]);if(!o||!a||o.id===a.id)continue;const s=Math.min(o.y,a.y),c=Math.max(o.y+o.height,a.y+a.height);t.some(l=>l.id!==o.id&&l.id!==a.id&&l.y>s&&l.y+l.height<c)&&i++}return i}function Fm(e,t,n){const i=new Set(t.flatMap(r=>[...r.members]));return e.shapes.filter(r=>!r.container&&!dc.has(r.type)&&!i.has(r.id)&&r.x>=n.x&&r.y>=n.y&&r.x+r.width<=n.right&&r.y+r.height<=n.bottom).map(r=>r.id).sort()}function jm(e){var n;const t=(n=Lt(e==null?void 0:e.extensionElements))==null?void 0:n.values;if(Array.isArray(t))for(const i of t){const r=Lt(i);if((r==null?void 0:r.$type)!=="bwl:Members"||typeof r.refs!="string")continue;const o=r.refs.split(/\s+/).filter(Boolean);return o.length?o:void 0}}const Hm=e=>e?{members:e}:{},ci=e=>e.shapes.filter(t=>!t.container);function gR(e,t,n){if(e.type==="bpmn:TextAnnotation")for(const i of t.edges){if(!/Association$/.test(i.type)||!i.endpoints.includes(e.id))continue;const r=i.endpoints.find(a=>a!==e.id),o=r?n.get(r):void 0;if(o&&o.type!=="bpmn:Group"){if(o.container)return o.id;if(o.parent)return o.parent}}}function yR(e,t,n){if(e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height)return!0;const r=e.x+e.width/2,o=e.y+e.height/2;return n.shapes.some(a=>a.container&&a.id!==t.id&&a.id!==e.id&&a.type!=="bpmn:Group"&&r>=a.x&&r<=a.x+a.width&&o>=a.y&&o<=a.y+a.height)}function zm(e,t){const n=e.label;if(!n)return null;for(const i of[...t.edges].sort((r,o)=>r.id.localeCompare(o.id)))if(gn(i).some(r=>Fi(n,r)))return i.id;for(const i of[...t.shapes].filter(r=>r.container).sort((r,o)=>r.id.localeCompare(o.id)))if(Yo(i).some(r=>Fi(n,r)))return i.id;return null}function co(e){const t=[];for(const n of e.shapes)n.label&&t.push({owner:n.id,rect:n.label});for(const n of e.edges)n.label&&t.push({owner:n.id,rect:n.label});return t}const Gm=3;function Vm(e,t){const n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),i=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);if(n<=0||i<=0)return 0;const r=/Event$/.test(t.type);if(!r&&!/Gateway$/.test(t.type))return Math.min(n,i);const o=t.x+t.width/2,a=t.y+t.height/2,s=Math.min(Math.max(o,e.x),e.x+e.width),c=Math.min(Math.max(a,e.y),e.y+e.height);if(r)return Math.max(0,t.width/2-Math.hypot(s-o,c-a));const l=t.width/2,u=t.height/2;return Math.max(0,(1-(Math.abs(s-o)/l+Math.abs(c-a)/u))*Math.min(l,u))}function za(e,t){const n=[];for(const i of t.shapes){if(i.container||dc.has(i.type))continue;const r=Vm(e,i);r>=Gm&&n.push({shape:i.id,depth:r})}return n.sort((i,r)=>i.shape.localeCompare(r.shape))}function dt(e,t={}){const n=[],i=e.shapes.filter(m=>!m.container);for(const m of e.edges)for(const v of xn(m,i))n.push({kind:"edge-crosses-shape",edge:m.id,shape:v.id});const r=e.shapes.filter(m=>m.container&&nR.has(m.type));if(r.length){const m=(v,_)=>{const E=e.shapes.find(T=>T.id===_);return!!E&&E.x>=v.x&&E.y>=v.y&&E.x+E.width<=v.x+v.width&&E.y+E.height<=v.y+v.height};for(const v of e.edges)for(const _ of xn(v,r))v.endpoints.includes(_.id)||v.endpoints.some(E=>m(_,E))||n.push({kind:"edge-crosses-subprocess",edge:v.id,subProcess:_.id})}for(const m of e.edges){if(m.waypoints.length<2)continue;const v=[[m.source,m.waypoints[0]],[m.target,m.waypoints[m.waypoints.length-1]]];for(const[_,E]of v){if(!_)continue;const T=e.shapes.find(D=>D.id===_);if(!T||T.container)continue;const O=Math.max(T.x-E.x,E.x-(T.x+T.width),0),N=Math.max(T.y-E.y,E.y-(T.y+T.height),0),P=Math.hypot(O,N);P>lR&&n.push({kind:"edge-endpoint-detached",edge:m.id,shape:_,distance:Math.round(P)})}}const o=e.shapes.filter(m=>m.type==="bpmn:Participant");for(let m=0;m<o.length;m++)for(let v=m+1;v<o.length;v++){const _=o[m],E=o[v];if(_.x+_.width<=E.x||E.x+E.width<=_.x||_.y+_.height<=E.y||E.y+E.height<=_.y)continue;const T=(O,N)=>O.x<=N.x&&O.y<=N.y&&O.x+O.width>=N.x+N.width&&O.y+O.height>=N.y+N.height;n.push({kind:"pool-overlap",pools:[_.id,E.id],contained:T(_,E)||T(E,_)})}const a=i.filter(m=>!m.attached);for(let m=0;m<a.length;m++)for(let v=m+1;v<a.length;v++){const _=a[m],E=a[v];if(!Sp(_,E,iR))continue;const T=_.id<E.id?[_.id,E.id]:[E.id,_.id];n.push({kind:"shape-overlap",shapes:T,identical:dR(_,E)})}const s=e.shapes.filter(m=>m.type==="bpmn:Group"&&Array.isArray(m.members)&&m.members.length>0);for(let m=0;m<s.length;m++)for(let v=m+1;v<s.length;v++){const _=s[m],E=s[v],T=Math.min(_.x+_.width,E.x+E.width)-Math.max(_.x,E.x),O=Math.min(_.y+_.height,E.y+E.height)-Math.max(_.y,E.y);if(T<=hc||O<=hc)continue;const N=_.id<E.id?[_.id,E.id]:[E.id,_.id],P=new Set(E.members);if(_.members.some(F=>P.has(F))){const F=Fm(e,s,{x:Math.max(_.x,E.x),y:Math.max(_.y,E.y),right:Math.min(_.x+_.width,E.x+E.width),bottom:Math.min(_.y+_.height,E.y+E.height)});F.length&&n.push({kind:"group-overlap-unreadable",reason:"orphan",groups:N,shapes:F});continue}const D=_.x<=E.x&&_.y<=E.y&&_.x+_.width>=E.x+E.width&&_.y+_.height>=E.y+E.height?_.id:E.x<=_.x&&E.y<=_.y&&E.x+E.width>=_.x+_.width&&E.y+E.height>=_.y+_.height?E.id:void 0;n.push({kind:"group-overlap-unintended",groups:N,...D?{container:D}:{}})}const c=new Set(s.flatMap(m=>[...m.members])),l=m=>e.shapes.filter(v=>!v.container&&!dc.has(v.type)&&v.x>=m.x&&v.y>=m.y&&v.x+v.width<=m.x+m.width&&v.y+v.height<=m.y+m.height);for(const m of s){const v=l(m);if(!v.length)continue;const _=new Set(m.members),E=v.filter(T=>!_.has(T.id));E.some(T=>c.has(T.id))&&(E.length*2<v.length||n.push({kind:"group-overlap-unreadable",reason:"minority",group:m.id,shapes:E.map(T=>T.id).sort()}))}for(const m of s){const v=new Set(l(m).map(P=>P.id)),_=new Set(m.members),E=new Set([...v].filter(P=>!_.has(P)&&c.has(P)));if(!E.size)continue;let T=!1,O=!1,N=!1;for(const P of e.edges){if(P.type!=="bpmn:SequenceFlow"||!P.source||!P.target)continue;const D=E.has(P.source),F=E.has(P.target);!D&&F&&!v.has(P.source)?T=!0:D&&!F&&!v.has(P.target)?O=!0:D&&F&&(N=!0)}T&&O&&N&&n.push({kind:"group-overlap-unreadable",reason:"throughpass",group:m.id,shapes:[...E].sort()})}const u=e.shapes.filter(m=>m.type==="bpmn:Group");for(let m=0;m<u.length;m++)for(let v=m+1;v<u.length;v++)for(let _=v+1;_<u.length;_++){const E=[u[m],u[v],u[_]],T={x:Math.max(...E.map(P=>P.x)),y:Math.max(...E.map(P=>P.y)),right:Math.min(...E.map(P=>P.x+P.width)),bottom:Math.min(...E.map(P=>P.y+P.height))};if(T.right-T.x<=hc||T.bottom-T.y<=hc)continue;const O=Fm(e,[],T);if(!O.length)continue;const N=E.map(P=>P.id).sort();n.push({kind:"group-stack-unreadable",groups:N,shapes:O})}for(const m of e.shapes.filter(v=>v.type==="bpmn:Group"))for(const v of e.shapes){if(v.container||v.attached||dc.has(v.type)||v.width<=0||v.height<=0)continue;const _=[["top",m.y,"h",m.x,m.x+m.width],["bottom",m.y+m.height,"h",m.x,m.x+m.width],["left",m.x,"v",m.y,m.y+m.height],["right",m.x+m.width,"v",m.y,m.y+m.height]];for(const[E,T,O,N,P]of _){const D=O==="h"?v.x:v.y,F=O==="h"?v.x+v.width:v.y+v.height;if(!(D<P&&N<F))continue;const J=O==="h"?v.y:v.x,ge=O==="h"?v.y+v.height:v.x+v.width;if(!(J<T&&T<ge))continue;const Ae=Math.min(T-J,ge-T);Ae<oR||n.push({kind:"group-cuts-shape",group:m.id,shape:v.id,side:E,depth:Ae})}}const p=t.includeObservationOnly?e.shapes.filter(m=>m.type==="bpmn:Group"&&m.width>0&&m.height>0):[];if(p.length){const m=new Map(e.shapes.filter(v=>!v.container).map(v=>[v.id,{x:v.x+v.width/2,y:v.y+v.height/2}]));for(const v of e.edges){if(v.type!=="bpmn:SequenceFlow"&&v.type!=="bpmn:MessageFlow")continue;const _=gn(v);if(_.length)for(const E of p){const T=E.x+E.width,O=E.y+E.height,N=v.endpoints.some(D=>{const F=m.get(D);return!!F&&E.x<F.x&&F.x<T&&E.y<F.y&&F.y<O});let P=null;for(const D of _){const[F,J,ge]=D.axis==="v"?[E.y,O,[["left",E.x],["right",T]]]:[E.x,T,[["top",E.y],["bottom",O]]],Ae=Math.min(D.hi,J)-Math.max(D.lo,F);if(Ae<xp)continue;const De=D.axis==="v"?E.x<D.at&&D.at<T:E.y<D.at&&D.at<O;if(!(De&&N))for(const[qe,rt]of ge){const Me=Math.abs(D.at-rt);Me<=Wo&&(!P||Me<P.distance)&&(P={side:qe,inside:De,distance:Me,length:Ae})}}P&&n.push({kind:"edge-along-group-boundary",edge:v.id,group:E.id,side:P.side,inside:P.inside,distance:Math.round(P.distance),length:Math.round(P.length)})}}}const f=e.shapes.filter(m=>m.container&&m.type!=="bpmn:Group"&&m.type!=="bpmn:Lane");for(const m of e.shapes.filter(v=>v.type==="bpmn:Group"))for(const v of f){const _=m.x<v.x+v.width&&v.x<m.x+m.width,E=m.y<v.y+v.height&&v.y<m.y+m.height,T=[["top",m.y,v.y,_],["bottom",m.y+m.height,v.y+v.height,_],["left",m.x,v.x,E],["right",m.x+m.width,v.x+v.width,E]];for(const[O,N,P,D]of T)D&&Math.abs(N-P)<=Mm&&n.push({kind:"group-on-container-boundary",group:m.id,container:v.id,side:O})}const d=e.shapes.filter(m=>m.type==="bpmn:Group");for(let m=0;m<d.length;m++)for(let v=m+1;v<d.length;v++){const _=d[m],E=d[v],T=_.x<E.x+E.width&&E.x<_.x+_.width,O=_.y<E.y+E.height&&E.y<_.y+_.height,N=[["x",_.x+_.width,E.x,O],["x",E.x+E.width,_.x,O],["y",_.y+_.height,E.y,T],["y",E.y+E.height,_.y,T]];for(const[P,D,F,J]of N)if(J&&Math.abs(D-F)<=Mm){n.push({kind:"group-on-group-boundary",groups:_.id<E.id?[_.id,E.id]:[E.id,_.id],axis:P});break}}for(let m=0;m<e.edges.length;m++)for(let v=m+1;v<e.edges.length;v++){const _=e.edges[m],E=e.edges[v],T=Uo(_,E);if(!T)continue;const O=_.id<E.id?[_.id,E.id]:[E.id,_.id];n.push({kind:T.kind==="opposite"?"edge-overlap-opposite":T.kind==="mixed"?"edge-overlap-mixed":"edge-overlap-unrelated",edges:O,axis:T.axis,length:Math.round(T.length)})}for(const m of e.edges){if(!m.label)continue;const v=gc(m,e.edges);v&&n.push({kind:"label-on-shared-segment",edge:m.id,other:v.other,axis:v.axis})}for(const m of e.edges){if(!m.label)continue;const v=Dm(m,e);v&&n.push({kind:"label-over-line",edge:m.id,line:v})}if(t.includeObservationOnly){for(const m of e.edges)if(!(!m.label||m.type!=="bpmn:SequenceFlow"))for(const{shape:v,depth:_}of za(m.label,e))n.push({kind:"label-over-shape",edge:m.id,shape:v,depth:Math.round(_)})}const g=new Set(i.map(m=>m.id)),h=e.shapes.filter(m=>m.type==="bpmn:Participant"&&m.label);for(const m of[...i,...h.filter(v=>!g.has(v.id))]){if(!m.label)continue;const v=zm(m,e);v&&n.push({kind:"label-over-line",edge:m.id,line:v})}const y=new Set(e.shapes.filter(m=>m.type==="bpmn:TextAnnotation").map(m=>m.id));for(const m of h)for(const{owner:v,rect:_}of co(e))v===m.id||y.has(v)||Sp(m.label,_,qo)&&n.push({kind:"pool-name-over-label",pool:m.id,label:v});const C=co(e);for(const m of i)if(m.type==="bpmn:TextAnnotation")for(const{owner:v,rect:_}of C)v!==m.id&&Sp(m,_,qo)&&n.push({kind:"annotation-over-label",annotation:m.id,label:v});const x=new Map(e.shapes.map(m=>[m.id,m]));for(const m of i){const v=m.parent??gR(m,e,x);if(!v)continue;const _=x.get(v);!_||!_.container||pR(_,m,uR)||m.type==="bpmn:TextAnnotation"&&!yR(m,_,e)||n.push({kind:"shape-outside-container",shape:m.id,container:_.id})}return n.sort((m,v)=>lt(m).localeCompare(lt(v)))}const Lt=e=>typeof e=="object"&&e!==null?e:void 0,Ut=e=>typeof e=="number"?e:0,tr=e=>{const t=Lt(e);return typeof(t==null?void 0:t.id)=="string"?t.id:void 0};function vR(e){const t=Lt(e);if(!t)return[];const n=[];for(const i of["sourceRef","targetRef"]){const r=t[i];for(const o of Array.isArray(r)?r:[r]){const a=tr(o);a&&n.push(a)}}return n}function bR(e){const t=Lt(e);if(!t)return{};const n=Array.isArray(t.sourceRef)?void 0:tr(t.sourceRef),i=Array.isArray(t.targetRef)?void 0:tr(t.targetRef);return n&&i?{source:n,target:i}:{}}function xR(e,t){const n=Lt(e.$parent);if(!n)return;const i=typeof n.$type=="string"?n.$type:"";if(i==="bpmn:Process"){const r=tr(n);return r?t.get(r):void 0}if(fc.has(i)&&i!=="bpmn:Lane"&&i!=="bpmn:Group")return tr(n)}function Wm(e){var a,s,c,l,u;const t=[],n=[],i=((a=Lt(e))==null?void 0:a.diagrams)??[],r=new Map,o=new Set;for(const p of((s=Lt(e))==null?void 0:s.rootElements)??[]){const f=Lt(p);if((f==null?void 0:f.$type)==="bpmn:Collaboration")for(const d of f.participants??[]){const g=Lt(d),h=tr(g),y=tr(g==null?void 0:g.processRef);h&&y?r.set(y,h):h&&o.add(h)}}for(const p of i){const f=Lt((c=Lt(p))==null?void 0:c.plane),d=(f==null?void 0:f.planeElement)??[];for(const g of d){const h=Lt(g);if(!h)continue;const y=Lt(h.bpmnElement),C=typeof(y==null?void 0:y.id)=="string"?y.id:void 0;if(!C)continue;const x=typeof(y==null?void 0:y.$type)=="string"?y.$type:"",m=Lt(h.bounds);if(m){const _=h.isExpanded===!1&&x!=="bpmn:Participant",E=Lt((l=Lt(h.label))==null?void 0:l.bounds),T={id:C,type:x,x:Ut(m.x),y:Ut(m.y),width:Ut(m.width),height:Ut(m.height),container:fc.has(x)&&!_,attached:(y==null?void 0:y.attachedToRef)!==void 0,...y?{parent:xR(y,r)}:{},...E?{label:{x:Ut(E.x),y:Ut(E.y),width:Ut(E.width),height:Ut(E.height)}}:{},...x==="bpmn:Group"?Hm(jm(y)):{}},O=h.isHorizontal!==!1,N=typeof(y==null?void 0:y.name)=="string"?y.name:"";o.has(C)&&O&&N&&(T.label=_p(T,N)),t.push(T);continue}const v=h.waypoint;if(Array.isArray(v)){const _=Lt((u=Lt(h.label))==null?void 0:u.bounds);n.push({id:C,type:x,waypoints:v.map(E=>{var T,O;return{x:Ut((T=Lt(E))==null?void 0:T.x),y:Ut((O=Lt(E))==null?void 0:O.y)}}),endpoints:vR(y),...bR(y),..._?{label:{x:Ut(_.x),y:Ut(_.y),width:Ut(_.width),height:Ut(_.height)}}:{}})}}}return{shapes:t,edges:n}}function Um(e){return dt(Wm(e),{includeObservationOnly:!0})}async function _R(e){const{definitions:t,warnings:n}=await zo(e);return{findings:Um(t),warnings:n}}function Ze(e){var i;const t=[],n=[];for(const r of e.getAll()){const o=r;if(o.type==="label"||o.labelTarget)continue;const a=typeof o.type=="string"?o.type:"";if(a==="bpmn:Definitions"||a.startsWith("bpmndi:"))continue;const s=o.waypoints;if(s){const h=Lt(o.label),y=tr(o.source),C=tr(o.target);n.push({id:o.id,type:a,waypoints:s.map(x=>({x:Ut(x.x),y:Ut(x.y)})),endpoints:[y,C].filter(x=>!!x),...y&&C?{source:y,target:C}:{},...h&&typeof h.x=="number"?{label:{x:h.x,y:Ut(h.y),width:Ut(h.width),height:Ut(h.height)}}:{}});continue}if(typeof o.x!="number"||typeof o.y!="number")continue;const c=Lt(o.businessObject),l=Lt(o.label);let u=Lt(o.parent);for(;u&&u.type==="bpmn:Lane";)u=Lt(u.parent);const p=typeof(u==null?void 0:u.type)=="string"?u.type:"",f=u&&fc.has(p)&&p!=="bpmn:Group"&&typeof u.id=="string"?u.id:void 0,d={id:o.id,type:a,x:o.x,y:o.y,width:Ut(o.width),height:Ut(o.height),container:fc.has(a)&&(a==="bpmn:Participant"||o.collapsed!==!0),attached:(c==null?void 0:c.attachedToRef)!==void 0,...f!==void 0?{parent:f}:{},...l&&typeof l.x=="number"?{label:{x:l.x,y:Ut(l.y),width:Ut(l.width),height:Ut(l.height)}}:{},...a==="bpmn:Group"?Hm(jm(c)):{}},g=typeof(c==null?void 0:c.name)=="string"?c.name:"";a==="bpmn:Participant"&&!(c!=null&&c.processRef)&&g&&((i=Lt(o.di))==null?void 0:i.isHorizontal)!==!1&&(d.label=_p(d,g)),t.push(d)}return{shapes:t,edges:n}}const wR={"bpmn:Participant":"participant","bpmn:Lane":"lane","bpmn:SequenceFlow":"sequenceFlow","bpmn:MessageFlow":"messageFlow","bpmn:DataStoreReference":"dataStore","bpmn:DataInputAssociation":"dataAssociation","bpmn:DataOutputAssociation":"dataAssociation","bpmn:TextAnnotation":"annotation","bpmn:Association":"association","bpmn:Group":"group"};function ER(e,t){const n=wR[e];return n||(e==="label"||e.startsWith("bpmndi:")?"other":e.startsWith("bpmn:")&&!("waypoints"in t&&t.waypoints)?"flowNode":"other")}function qm(e){let t=e.parent;for(;t;){if(t.type==="bpmn:Participant")return t.id;t=t.parent}}function Ym(e){const t=()=>e.getAll().filter(n=>n.type!=="label"&&!("labelTarget"in n&&n.labelTarget));return{isCollaboration:()=>t().some(n=>n.type==="bpmn:Participant"),categoryOf:n=>{const i=e.get(n);if(!(!i||i.type==="label"))return ER(i.type,i)},lanesOf:n=>t().filter(i=>i.type==="bpmn:Lane"&&qm(i)===n).sort((i,r)=>i.y-r.y).map(i=>i.id),participantOf:n=>{const i=e.get(n);return i?qm(i):void 0},endpointsOf:n=>{var r,o;const i=e.get(n);if(!(!i||i.type==="label")&&"waypoints"in i)return{source:(r=i.source)==null?void 0:r.id,target:(o=i.target)==null?void 0:o.id}},eventDefinitionOf:n=>{var o;const i=e.get(n);if(!i||i.type!=="bpmn:IntermediateCatchEvent")return;const r=(((o=i.businessObject)==null?void 0:o.eventDefinitions)??[]).map(a=>a.$type);return Uu(r)},reviewRequestLocalesOf:n=>{const i=e.get(n);return!i||i.type==="label"?[]:xr(i.businessObject).map(r=>r.locale)}}}const Rp=20,SR=4,Ot=(e,t)=>Math.abs(e-t)<.5;function bc(e,t,n,i=Rp){if(Ot(e.y,t.y)&&!Ot(e.x,t.x)){const r=Math.min(e.x,t.x),o=Math.max(e.x,t.x);if(!(r<n.x-i&&n.x+n.width+i<o))return null;const a=e.x<t.x?n.x-i:n.x+n.width+i,s=e.x<t.x?n.x+n.width+i:n.x-i,c=l=>[{x:a,y:e.y},{x:a,y:l},{x:s,y:l},{x:s,y:e.y}];return[c(n.y-i),c(n.y+n.height+i)]}if(Ot(e.x,t.x)&&!Ot(e.y,t.y)){const r=Math.min(e.y,t.y),o=Math.max(e.y,t.y);if(!(r<n.y-i&&n.y+n.height+i<o))return null;const a=e.y<t.y?n.y-i:n.y+n.height+i,s=e.y<t.y?n.y+n.height+i:n.y-i,c=l=>[{x:e.x,y:a},{x:l,y:a},{x:l,y:s},{x:e.x,y:s}];return[c(n.x-i),c(n.x+n.width+i)]}return null}function Km(e,t,n,i=Rp){if(n.length<2)return null;if(Ot(e.y,t.y)&&!Ot(e.x,t.x)){const r=Math.min(e.x,t.x),o=Math.max(e.x,t.x),a=Math.min(...n.map(d=>d.x))-i,s=Math.max(...n.map(d=>d.x+d.width))+i;if(!(r<a&&s<o))return null;const c=e.x<t.x?a:s,l=e.x<t.x?s:a,u=Math.min(...n.map(d=>d.y))-i,p=Math.max(...n.map(d=>d.y+d.height))+i,f=d=>[{x:c,y:e.y},{x:c,y:d},{x:l,y:d},{x:l,y:e.y}];return[f(u),f(p)]}if(Ot(e.x,t.x)&&!Ot(e.y,t.y)){const r=Math.min(e.y,t.y),o=Math.max(e.y,t.y),a=Math.min(...n.map(d=>d.y))-i,s=Math.max(...n.map(d=>d.y+d.height))+i;if(!(r<a&&s<o))return null;const c=e.y<t.y?a:s,l=e.y<t.y?s:a,u=Math.min(...n.map(d=>d.x))-i,p=Math.max(...n.map(d=>d.x+d.width))+i,f=d=>[{x:e.x,y:c},{x:d,y:c},{x:d,y:l},{x:e.x,y:l}];return[f(u),f(p)]}return null}function Xm(e,t,n=Rp){if(e.length!==4)return null;const[i,r,o,a]=e;if(Ot(i.y,r.y)&&Ot(r.x,o.x)&&Ot(o.y,a.y)){const s=c=>[i,{x:c,y:i.y},{x:c,y:a.y},a];return[s(t.x-n),s(t.x+t.width+n)]}if(Ot(i.x,r.x)&&Ot(r.y,o.y)&&Ot(o.x,a.x)){const s=c=>[i,{x:i.x,y:c},{x:a.x,y:c},a];return[s(t.y-n),s(t.y+t.height+n)]}return null}function xc(e,t){if(e.endpoints.length!==2)return[];const n=t.find(p=>p.id===e.endpoints[0]),i=t.find(p=>p.id===e.endpoints[1]);if(!n||!i)return[];if(i.x<=n.x+n.width)return[];const r=n.y+n.height/2,o=i.y+i.height/2;if(r>=i.y&&r<=i.y+i.height)return[];const a=i.x+i.width/2,s=n.x+n.width/2,c=r>o,l=[{x:n.x+n.width,y:r},{x:a,y:r},{x:a,y:c?i.y+i.height:i.y}],u=[{x:s,y:c?n.y:n.y+n.height},{x:s,y:o},{x:i.x,y:o}];return[l,u]}const Zm=30,RR=[0,-25,25,-40,40];function CR(e,t){if(e.type!=="bpmn:MessageFlow"||e.endpoints.length!==2)return[];const n=t.find(f=>f.id===e.endpoints[0]),i=t.find(f=>f.id===e.endpoints[1]);if(!n||!i)return[];const r=n.y+n.height/2,o=i.y+i.height/2;if(i.y<n.y+n.height&&i.y+i.height>n.y)return[];const a=o<r,s=a?n.y+n.height:n.y,c=a?s+Zm:s-Zm,l=a?i.y+i.height:i.y,u=n.x+n.width/2,p=i.x+i.width/2;return RR.map(f=>[{x:u,y:s},{x:u,y:c},{x:p+f,y:c},{x:p+f,y:l}]).filter(f=>xn({...e,endpoints:[],waypoints:f},[n]).length===0)}const Cp=(e,t,n)=>[...e.slice(0,t+1),...n,...e.slice(t+1)],Ko=(e,t,n)=>xn({...e,waypoints:t},n).length;function Mp(e,t,n,i){let r=[...e.waypoints],o=Ko(e,r,t);if(o===0)return null;let a=!1;for(const p of xc(e,t))if(Ko(e,p,t)===0)return p;const s=(i??[]).filter(p=>p.id!==e.id).flatMap(gn),c=p=>gn({...e,waypoints:p}).some(f=>mc(f,s).length>0),l=CR(e,t).filter(p=>Ko(e,p,t)===0);if(l.length)return l.find(p=>!c(p))??l[0];const u=p=>!n||p.every(f=>f.x>=n.x&&f.x<=n.x+n.width&&f.y>=n.y&&f.y<=n.y+n.height);if(e.endpoints.length===2&&r.length>2){const p=t.find(d=>d.id===e.endpoints[0]),f=t.find(d=>d.id===e.endpoints[1]);if(p&&f&&Ot(p.y+p.height/2,f.y+f.height/2)){const d=[r[0],r[r.length-1]];if(Ot(d[0].y,d[1].y)&&!Ot(d[0].x,d[1].x)){const g=t.filter(x=>!e.endpoints.includes(x.id)&&xn({...e,waypoints:d},[x]).length>0),h=g.length>=2?Km(d[0],d[1],g):null,C=(h?h.map(x=>[d[0],...x,d[1]]):g.length===1?(bc(d[0],d[1],g[0])??[]).map(x=>[d[0],...x,d[1]]):g.length===0?[d]:[]).filter(x=>Ko(e,x,t)===0&&x.length<=r.length).sort((x,m)=>Number(u(m))-Number(u(x)));if(C.length)return C.find(x=>!c(x))??C[0]}}}for(let p=0;p+1<r.length;p++){const f=r[p],d=r[p+1],g=t.filter(C=>!e.endpoints.includes(C.id)&&xn({...e,waypoints:[f,d]},[C]).length>0);if(g.length<2)continue;const h=Km(f,d,g);if(!h)continue;const y=h.map(C=>Cp(r,p,C)).filter(C=>Ko(e,C,t)===0).sort((C,x)=>Number(u(x))-Number(u(C)));if(y.length)return y.find(C=>!c(C))??y[0]}for(let p=0;p<SR&&o>0;p++){let f=!1;for(let d=0;d+1<r.length&&!f;d++){const g=r[d],h=r[d+1];for(const y of t){if(e.endpoints.includes(y.id)||xn({...e,waypoints:[g,h]},[y]).length===0)continue;const C=bc(g,h,y),x=C?C.map(v=>Cp(r,d,v)):Xm(r,y)??[];if(!x.length)continue;const m=[...x].sort((v,_)=>Number(u(_))-Number(u(v)));for(const v of m){const _=Ko(e,v,t);if(_<o){r=v,o=_,f=!0,a=!0;break}}if(f)break}}if(!f)break}return a&&o===0?r:null}function Ap(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i),a=ci(o),s=new Set,c=dt(o).filter(u=>u.kind==="edge-crosses-shape"&&!t.has(lt(u)));if(!c.length)return s;const l=new Map;for(const u of c){if(u.kind!=="edge-crosses-shape"||l.has(u.edge))continue;const p=o.edges.find(f=>f.id===u.edge);p&&l.set(u.edge,p)}for(const[u,p]of l){if(n&&!n.has(u))continue;const f=i.get(u);if(!f)continue;const d=f.parent,g=d&&typeof d.x=="number"&&typeof d.width=="number"?{x:d.x,y:d.y,width:d.width,height:d.height}:void 0,h=xn(p,a);if(!n&&h.length&&h.every(v=>v.type==="bpmn:TextAnnotation")){s.add(u);continue}const y=Mp(p,a,g,o.edges);if(!y){h.some(v=>v.type==="bpmn:TextAnnotation")&&s.add(u);continue}const C=o.edges.filter(v=>v.id!==u),x=ai(p,C);ai({...p,waypoints:y},C)>x||r.updateWaypoints(f,y)}return s}const MR=e=>{const t=[];for(let n=0;n+1<e.waypoints.length;n++){const i=e.waypoints[n],r=e.waypoints[n+1];t.push({id:`__ghost:${e.id}:${n}`,type:"bpmn:Task",x:Math.min(i.x,r.x)-1,y:Math.min(i.y,r.y)-1,width:Math.max(2,Math.abs(r.x-i.x)+2),height:Math.max(2,Math.abs(r.y-i.y)+2),container:!1,attached:!1})}return t},Pp=(e,t)=>Ha(e,[t])>0;function Qm(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i),a=ci(o);let s=o;const c=new Set(dt(o).map(lt));for(const[l,u]of vc(o))if(!t.has(`${l}|${u}`))for(const[p,f]of[[l,u],[u,l]]){if(n.has(p))continue;const d=s.edges.find(N=>N.id===p),g=s.edges.find(N=>N.id===f);if(!d||!g)continue;const h=i.get(p);if(!h)continue;const y=h.parent,C=y&&typeof y.x=="number"&&typeof y.width=="number"?{x:y.x,y:y.y,width:y.width,height:y.height}:void 0,x=MR(g),m=[...xc(d,a)??[]],v=Mp(d,[...a,...x],C,o.edges);v&&m.push(v);for(let N=0;N+1<d.waypoints.length;N++)for(const P of x)for(const D of bc(d.waypoints[N],d.waypoints[N+1],P)??[])m.push(Cp(d.waypoints,N,D));const _=s.edges.filter(N=>N.id!==p),E=N=>({...s,edges:s.edges.map(P=>P.id===p?{...P,waypoints:N}:P)}),T=N=>!C||N.every(P=>P.x>=C.x&&P.x<=C.x+C.width&&P.y>=C.y&&P.y<=C.y+C.height),O=m.find(N=>{const P={...d,waypoints:N};return Pp(P,g)||!T(N)||_.some(D=>D.id!==f&&!Pp(d,D)&&Pp(P,D))?!1:dt(E(N)).every(D=>c.has(lt(D)))});if(O){r.updateWaypoints(h,O),s=E(O);break}}}const AR=10;function Jm(e,t){if(e.parent){const r=t.find(o=>o.id===e.parent);if(r)return r}const n=e.x+e.width/2,i=e.y+e.height/2;return t.find(r=>n>=r.x&&n<=r.x+r.width&&i>=r.y&&i<=r.y+r.height)}function eg(e,t){if(e.waypoints.length<2||e.endpoints.length!==2)return null;const n=t.shapes.filter(F=>F.type==="bpmn:Participant"&&F.container),i=t.shapes.find(F=>F.id===e.endpoints[0]),r=t.shapes.find(F=>F.id===e.endpoints[1]);if(!i||!r)return null;const o=Jm(i,n),a=Jm(r,n);if(!o||!a||o.id===a.id)return null;const s=a.y>o.y,c=s?o:a,l=s?a:o,u=n.filter(F=>F.id!==o.id&&F.id!==a.id&&F.y>=c.y+c.height&&F.y+F.height<=l.y).sort((F,J)=>F.y-J.y);if(!u.length)return null;const p=u[0],f=u[u.length-1],d=(c.y+c.height+p.y)/2,g=(f.y+f.height+l.y)/2,h=s?d:g,y=s?g:d,C=e.waypoints[0],x=e.waypoints[e.waypoints.length-1],m=ci(t),v=t.edges.filter(F=>F.id!==e.id),_=si(e,v),E=xn(e,m).length;if(_===0&&E===0||E===0&&e.waypoints.length===2)return null;const T=Math.min(...u.map(F=>F.x)),O=Math.max(...u.map(F=>F.x+F.width)),N=(C.x+x.x)/2,P=F=>F.filter((J,ge)=>ge===0||!(Ot(J.x,F[ge-1].x)&&Ot(J.y,F[ge-1].y)));let D;for(let F=T;F<=O;F+=AR){const J=P([C,{x:C.x,y:h},{x:F,y:h},{x:F,y},{x:x.x,y},x]),ge={...e,waypoints:J};if(xn(ge,m).length>0)continue;const Ae=si(ge,v),De=Math.abs(F-N);(!D||Ae<D.cross||Ae===D.cross&&De<D.detour)&&(D={pts:J,cross:Ae,detour:De})}return D&&(E>0?D.cross<=_:D.cross<_)?D.pts:null}function tg(e,t){const{elementRegistry:n}=e,i=e.modeling,r=Ze(n);for(const o of r.edges){if(o.type!=="bpmn:MessageFlow"||t.has(o.id))continue;const a=Ze(n),s=a.edges.find(u=>u.id===o.id);if(!s)continue;const c=eg(s,a);if(!c)continue;const l=n.get(o.id);l&&i.updateWaypoints(l,c)}}const ji=[25,-25,40,-40],Xo=35;function PR(e,t){const n=e.x+e.width/2,i=t.x+t.width/2,r=[];for(const o of[!0,!1]){const a=o?e.y:e.y+e.height,s=o?t.y:t.y+t.height,c=o?Math.min(e.y,t.y)-Xo:Math.max(e.y+e.height,t.y+t.height)+Xo;for(const l of[0,...ji])if(!(Math.abs(l)>=e.width/2-5))for(const u of[0,...ji]){if(Math.abs(u)>=t.width/2-5)continue;const p=n+l,f=i+u;r.push({pts:[{x:p,y:a},{x:p,y:c},{x:f,y:c},{x:f,y:s}],cost:Math.abs(u)+Math.abs(l)})}}return r}function _c(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];if(i.x+i.width>n.x)return[];const r=n.y+n.height/2;if(r>=i.y&&r<=i.y+i.height)return PR(n,i);const o=i.x+i.width/2,a=n.x+n.width/2,s=r<i.y,c=s?i.y:i.y+i.height,l=s?n.y:n.y+n.height,u=s?n.y-Xo:n.y+n.height+Xo,p=[];for(const x of[0,...ji]){if(Math.abs(x)>=i.width/2-5)continue;const m=o+x;p.push({pts:[{x:n.x,y:r},{x:m,y:r},{x:m,y:c}],cost:Math.abs(x)});for(const v of[0,...ji]){if(Math.abs(v)>=n.width/2-5)continue;const _=a+v;p.push({pts:[{x:_,y:l},{x:_,y:u},{x:m,y:u},{x:m,y:c}],cost:Math.abs(x)+Math.abs(v)})}}const f=50,d=i.y+i.height/2,g=s?n.y+n.height:n.y;for(const x of[0,...ji]){if(Math.abs(x)>=n.width/2-5)continue;const m=a+x;p.push({pts:[{x:m,y:g},{x:m,y:d},{x:i.x+i.width,y:d}],cost:f+Math.abs(x)})}const h=60,y=s?i.y+i.height:i.y,C=s?i.y+i.height+Xo:i.y-Xo;for(const x of[0,...ji]){if(Math.abs(x)>=i.width/2-5)continue;const m=o+x;for(const v of[0,...ji]){if(Math.abs(v)>=n.width/2-5)continue;const _=a+v;p.push({pts:[{x:_,y:g},{x:_,y:C},{x:m,y:C},{x:m,y}],cost:h+Math.abs(x)+Math.abs(v)})}}return p}const wc=30;function ng(e,t){for(let n=1;n<e.length-2;n++){const i=e[n],r=e[n+1],o=Ot(i.y,r.y)&&!Ot(i.x,r.x),a=Ot(i.x,r.x)&&!Ot(i.y,r.y);if(!(!o&&!a))for(const s of t)if(o){const c=Math.min(i.x,r.x);if(Math.max(i.x,r.x)<=s.x||c>=s.x+s.width)continue;if(Math.abs(i.y-s.y)<wc||Math.abs(i.y-(s.y+s.height))<wc)return!0}else{const c=Math.min(i.y,r.y);if(Math.max(i.y,r.y)<=s.y||c>=s.y+s.height)continue;if(Math.abs(i.x-s.x)<wc||Math.abs(i.x-(s.x+s.width))<wc)return!0}}return!1}const Ec=40;function TR(e,t,n){let i=0;for(const r of t){if(r.container||n.includes(r.id))continue;const o=r.x-Ec,a=r.x+r.width+Ec,s=r.y-Ec,c=r.y+r.height+Ec;for(let l=1;l<e.length-2;l++){const u=e[l],p=e[l+1],f={x:Math.min(u.x,p.x),y:Math.min(u.y,p.y)},d={x:Math.max(u.x,p.x),y:Math.max(u.y,p.y)};if(f.x<a&&d.x>o&&f.y<c&&d.y>s){i++;break}}}return i}function ig(e,t){if(e.type!=="bpmn:SequenceFlow")return null;const n=t.shapes.filter(E=>E.container),i=new Map(t.shapes.map(E=>[E.id,E])),r=ci(t),o=t.edges.filter(E=>E.id!==e.id),a=ai(e,o),s=si(e,o),c=E=>TR(E,t.shapes,e.endpoints)+(ng(E,n)?1:0),l=c(e.waypoints),u=E=>{if(!E)return;const T=E.x+E.width/2,O=E.y+E.height/2;return n.find(N=>N.type==="bpmn:Lane"&&T>=N.x&&T<=N.x+N.width&&O>=N.y&&O<=N.y+N.height)},p=u(i.get(e.endpoints[0]??"")),f=u(i.get(e.endpoints[1]??"")),d=!!p&&!!f&&p.id!==f.id,g=E=>{if(!d||!f)return!1;for(let T=1;T<E.length-2;T++){const O=E[T],N=E[T+1];if(Ot(O.y,N.y)&&!Ot(O.x,N.x)&&O.y>f.y&&O.y<f.y+f.height)return!0}return!1},h=g(e.waypoints),C=(E=>{if(!E)return;const T=E.x+E.width/2,O=E.y+E.height/2;return n.filter(N=>N.type==="bpmn:Participant"&&T>=N.x&&T<=N.x+N.width&&O>=N.y&&O<=N.y+N.height).sort((N,P)=>N.width*N.height-P.width*P.height)[0]})(i.get(e.endpoints[0]??"")),x=E=>{if(!C)return 0;let T=0;for(let O=1;O<E.length-1;O++){const N=E[O];(N.x<C.x||N.x>C.x+C.width||N.y<C.y||N.y>C.y+C.height)&&T++}return T},m=x(e.waypoints);if(!ng(e.waypoints,n)&&!(d&&!h)&&m===0)return null;const v=E=>E.reduce((T,O,N)=>N?T+Math.abs(O.x-E[N-1].x)+Math.abs(O.y-E[N-1].y):0,0);let _;for(const{pts:E,cost:T}of _c(e,i)){const O={...e,waypoints:E};if(xn(O,r).length>0)continue;const N=ai(O,o);if(N>a)continue;const P=x(E);if(P>m)continue;const D=P<m&&N===0;if(!D&&si(O,o)>s)continue;const F=c(E),J=g(E);if(!D&&!(J&&!h)&&F>=l)continue;const Ae=J?0:1,De=v(E);(!_||P<_.out||P===_.out&&(Ae<_.lane||Ae===_.lane&&(N<_.opp||N===_.opp&&(F<_.sc||F===_.sc&&(T<_.cost||T===_.cost&&De<_.len)))))&&(_={pts:E,out:P,sc:F,lane:Ae,opp:N,cost:T,len:De})}return(_==null?void 0:_.pts)??null}function kR(e,t){if(e.type!=="bpmn:SequenceFlow"||e.endpoints.length!==2)return!1;const[n,i]=e.endpoints,r=t.edges.filter(p=>p.type==="bpmn:SequenceFlow"&&p.endpoints.length===2),o=r.filter(p=>p.endpoints[1]===i),a=r.filter(p=>p.endpoints[0]===i);if(o.length!==1||a.length!==1)return!1;const s=t.shapes.find(p=>p.id===n),c=t.shapes.find(p=>p.id===i),l=t.shapes.find(p=>p.id===a[0].endpoints[1]);if(!s||!c||!l||!(s.x+s.width<c.x&&c.x+c.width<l.x))return!1;const u=s.y+s.height/2;return u<l.y||u>l.y+l.height?!1:u<c.y||u>c.y+c.height}function OR(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i).edges.filter(a=>(!t.has(a.id)||n.has(a.id))&&a.waypoints.length>=4).map(a=>a.id).sort();for(const a of o){const s=Ze(i),c=s.edges.find(y=>y.id===a);if(!c||c.waypoints.length<4)continue;const l=ci(s),u=s.edges.filter(y=>y.id!==a),p=xn(c,l).length,f=ai(c,u),d=si(c,u),g=n.has(a)?new Set(dt(s).map(lt)):null,h=xc(c,s.shapes);h.length===2&&kR(c,s)&&h.reverse();for(const y of h){if(y.length>=c.waypoints.length)continue;const C={...c,waypoints:y};if(xn(C,l).length>p||ai(C,u)>f||si(C,u)>d)continue;if(g){const m=new Set(dt({...s,edges:s.edges.map(E=>E.id===a?C:E)}).map(lt)),v=[...m].filter(E=>!g.has(E)).length,_=[...g].filter(E=>!m.has(E)).length;if(v>_)continue}const x=i.get(a);x&&r.updateWaypoints(x,y);break}}}function rg(e,t){const{elementRegistry:n}=e,i=e.modeling,r=Ze(n).edges.filter(o=>o.type==="bpmn:SequenceFlow"&&!t.has(o.id)).map(o=>o.id).sort();for(const o of r){const a=Ze(n),s=a.edges.find(u=>u.id===o);if(!s)continue;const c=ig(s,a);if(!c)continue;const l=n.get(o);l&&i.updateWaypoints(l,c)}}function Tp(e,t){const n=e.waypoints;if(n.length<3)return[];const i=[],r=t.get(e.endpoints[0]??""),o=t.get(e.endpoints[1]??""),a=Ot(n[0].x,n[1].x)&&!Ot(n[0].y,n[1].y),s=Ot(n[n.length-1].x,n[n.length-2].x)&&!Ot(n[n.length-1].y,n[n.length-2].y);for(const c of ji){if(a&&r&&Math.abs(c)<r.width/2-5){const l=n.map(u=>({...u}));l[0].x+=c,l[1].x+=c,i.push({pts:l,cost:Math.abs(c)})}if(s&&o&&Math.abs(c)<o.width/2-5){const l=n.map(u=>({...u}));l[l.length-1].x+=c,l[l.length-2].x+=c,i.push({pts:l,cost:Math.abs(c)})}}return i}function DR(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];if(Math.min(n.x+n.width,i.x+i.width)-Math.max(n.x,i.x)>=1)return[];const r=i.y+i.height<=n.y,o=n.y+n.height<=i.y;if(!r&&!o)return[];const a=i.x>=n.x+n.width,s=i.x+i.width<=n.x;if(!a&&!s)return[];const c=n.x+n.width/2,l=n.y+n.height/2,u=i.x+i.width/2,p=i.y+i.height/2,f=a?n.x+n.width:n.x,d=o?n.y+n.height:n.y,g=a?i.x:i.x+i.width,h=o?i.y:i.y+i.height,y=[];for(const C of[0,...ji])Math.abs(C)<i.width/2-5&&y.push({pts:[{x:f,y:l},{x:u+C,y:l},{x:u+C,y:h}],cost:Math.abs(C)}),Math.abs(C)<i.height/2-5&&y.push({pts:[{x:c,y:d},{x:c,y:p+C},{x:g,y:p+C}],cost:Math.abs(C)});return y}function kp(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];const r=Math.max(n.x,i.x),o=Math.min(n.x+n.width,i.x+i.width);if(o-r<1)return[];const a=i.y+i.height<=n.y,s=n.y+n.height<=i.y;if(!a&&!s)return[];const c=a?n.y:n.y+n.height,l=a?i.y+i.height:i.y,u=(r+o)/2,p=[];for(const f of[0,...ji]){const d=u+f;d<=r||d>=o||p.push({pts:[{x:d,y:c},{x:d,y:l}],cost:Math.abs(f)})}return p}function og(e,t){const n=new Map(t.shapes.map(d=>[d.id,d])),i=ci(t),r=t.edges.filter(d=>d.id!==e.id),o=ai(e,r);if(o===0)return null;const a=si(e,r);let s;const c=d=>d.reduce((g,h,y)=>y?g+Math.abs(h.x-d[y-1].x)+Math.abs(h.y-d[y-1].y):0,0),l=3,u=d=>{const g=d[0],h=d[d.length-1],y=Math.hypot(h.x-g.x,h.y-g.y);return y>=1&&c(d)/y>=l?1:0},p=u(e.waypoints),f=[..._c(e,n),...kp(e,n),...Tp(e,n)];for(const{pts:d,cost:g}of f){const h={...e,waypoints:d};if(xn(h,i).length>0)continue;const y=ai(h,r),C=si(h,r),x=o-y+(p-u(d));if(y>=o||C-a>x)continue;const m=c(d);(!s||y<s.opposite||y===s.opposite&&(C<s.cross||C===s.cross&&(g<s.cost||g===s.cost&&m<s.len)))&&(s={pts:d,opposite:y,cross:C,cost:g,len:m})}return(s==null?void 0:s.pts)??null}function ag(e,t){var i;let n=0;for(const r of t)r.id!==e.id&&((i=Uo(e,r))==null?void 0:i.kind)==="unrelated"&&n++;return n}function LR(e,t){const n=new Map(t.shapes.map(f=>[f.id,f])),i=ci(t),r=t.edges.filter(f=>f.id!==e.id),o=ag(e,r);if(o===0)return null;const a=ai(e,r),s=si(e,r),c=f=>f.reduce((d,g,h)=>h?d+Math.abs(g.x-f[h-1].x)+Math.abs(g.y-f[h-1].y):0,0),l=2;let u;const p=[..._c(e,n),...kp(e,n),...DR(e,n),...Tp(e,n)];for(const{pts:f,cost:d}of p){const g={...e,waypoints:f};if(xn(g,i).length>0)continue;const h=ag(g,r);if(h>=o)continue;const y=ai(g,r);if(y-h>a-o)continue;const C=si(g,r);if(C-s>(o-h)*l)continue;const x=c(f);(!u||h<u.fake||h===u.fake&&(y<u.unreadable||y===u.unreadable&&(C<u.cross||C===u.cross&&(d<u.cost||d===u.cost&&x<u.length))))&&(u={pts:f,fake:h,unreadable:y,cross:C,cost:d,length:x})}return(u==null?void 0:u.pts)??null}function sg(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=dt(Ze(i)).filter(s=>s.kind==="edge-overlap-unrelated"&&!t.has(lt(s)));if(!o.length)return;const a=new Set;for(const s of o)if(s.kind==="edge-overlap-unrelated")for(const c of s.edges)n.has(c)||a.add(c);for(const s of[...a].sort()){const c=Ze(i),l=c.edges.find(f=>f.id===s);if(!l)continue;const u=LR(l,c);if(!u)continue;const p=i.get(s);p&&r.updateWaypoints(p,u)}}function cg(e,t){const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");return!!n&&!!i&&i.x+i.width>n.x}function lg(e,t,n){var l;if(e.type!=="bpmn:SequenceFlow"||t.type!=="bpmn:SequenceFlow"||((l=Uo(e,t))==null?void 0:l.kind)!=="opposite")return!1;const[i,r]=e.endpoints,[o,a]=t.endpoints,s=[i,r].filter(u=>u&&(u===o||u===a)).length;return!(!!r&&r===o||!!a&&a===i)||s!==1?!1:cg(e,n)&&cg(t,n)}function ug(e,t,n){let i=0;for(const r of t)r.id!==e.id&&lg(e,r,n)&&i++;return i}function IR(e,t){const n=new Map(t.shapes.map(f=>[f.id,f])),i=ci(t),r=t.edges.filter(f=>f.id!==e.id),o=ug(e,r,n);if(o===0)return null;const a=ai(e,r),s=si(e,r),c=f=>f.reduce((d,g,h)=>h?d+Math.abs(g.x-f[h-1].x)+Math.abs(g.y-f[h-1].y):0,0),l=2;let u;const p=[..._c(e,n),...kp(e,n),...Tp(e,n)];for(const{pts:f,cost:d}of p){const g={...e,waypoints:f};if(xn(g,i).length>0)continue;const h=ug(g,r,n);if(h>=o)continue;const y=ai(g,r);if(y-h>a-o)continue;const C=si(g,r);if(C-s>(o-h)*l)continue;const x=c(f);(!u||h<u.chain||h===u.chain&&(y<u.unreadable||y===u.unreadable&&(C<u.cross||C===u.cross&&(d<u.cost||d===u.cost&&x<u.length))))&&(u={pts:f,chain:h,unreadable:y,cross:C,cost:d,length:x})}return(u==null?void 0:u.pts)??null}function BR(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i),a=new Map(o.shapes.map(l=>[l.id,l])),s=dt(o).filter(l=>l.kind==="edge-overlap-opposite"&&!t.has(lt(l)));if(!s.length)return;const c=new Set;for(const l of s){if(l.kind!=="edge-overlap-opposite")continue;const[u,p]=l.edges.map(f=>o.edges.find(d=>d.id===f));if(!(!u||!p||!lg(u,p,a)))for(const f of l.edges)n.has(f)||c.add(f)}for(const l of[...c].sort()){const u=Ze(i),p=u.edges.find(g=>g.id===l);if(!p)continue;const f=IR(p,u);if(!f)continue;const d=i.get(l);d&&r.updateWaypoints(d,f)}}function pg(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i),a=dt(o).filter(u=>wp(u)&&!t.has(lt(u)));if(!a.length)return;const s=new Set;for(const u of a)if(wp(u))for(const p of u.edges)n.has(p)||s.add(p);const c=u=>{var p;return((p=o.edges.find(f=>f.id===u))==null?void 0:p.type)??""},l=[...s].sort((u,p)=>{const f=c(u)==="bpmn:SequenceFlow"?0:1,d=c(p)==="bpmn:SequenceFlow"?0:1;return f!==d?f-d:u.localeCompare(p)});for(const u of l){const p=Ze(i),f=p.edges.find(h=>h.id===u);if(!f)continue;const d=og(f,p);if(!d)continue;const g=i.get(u);g&&r.updateWaypoints(g,d)}}const NR=10,$R=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height;function fg(e,t){const n=e.label;if(!n)return null;const i=t.edges.filter(a=>a.id!==e.id);if(!gc(e,i))return null;const r=ci(t),o=i.flatMap(gn);for(const a of gn(e)){let s=[[a.lo,a.hi]];for(const[d,g]of mc(a,o))s=s.flatMap(([h,y])=>{const C=[];return d>h&&C.push([h,Math.min(y,d)]),g<y&&C.push([Math.max(h,g),y]),C.filter(([x,m])=>m>x)});const c=a.axis==="h"?n.width:n.height,l=s.find(([d,g])=>g-d>=c+NR*2);if(!l)continue;const u=(l[0]+l[1])/2,p=a.axis==="h"?{x:u,y:a.at-km}:{x:a.at+Sn+n.width/2,y:u},f={x:p.x-n.width/2,y:p.y-n.height/2,width:n.width,height:n.height};if(!gc({...e,label:f},i)&&!r.some(d=>!e.endpoints.includes(d.id)&&$R(f,d)))return f}return null}const Sn=8;function Op(e,t){const n=e.label;if(!n)return null;const i=gn(e);if(!i.length)return null;const r=n.x+n.width/2,o=n.y+n.height/2,a=f=>{const d=f.axis==="h"?r:o,g=f.axis==="h"?o-f.at:r-f.at,h=d<f.lo?f.lo-d:d>f.hi?d-f.hi:0;return Math.hypot(g,h)},s=i.reduce((f,d)=>a(d)<a(f)?d:f,i[0]),c=[...i,...t.edges.filter(f=>f.id!==e.id).flatMap(gn),...t.shapes.filter(f=>f.container).flatMap(Yo)],l=f=>!c.some(d=>Fi(f,d));if(l(n))return null;const u=(s.axis==="v"?n.height:n.width)+Sn,p=[0,-u,u,-2*u,2*u];if(s.axis==="v")for(const f of[s.at+Sn,s.at-Sn-n.width])for(const d of p){const g=n.y+d;if(g<s.lo||g+n.height>s.hi)continue;const h={...n,x:f,y:g};if(l(h))return h}else for(const f of[s.at-Sn-n.height,s.at+Sn])for(const d of p){const g=n.x+d;if(g<s.lo||g+n.width>s.hi)continue;const h={...n,x:g,y:f};if(l(h))return h}return null}const dg=30,FR=(e,t)=>{let n=1/0;for(let i=0;i+1<t.length;i++){const r=t[i],o=t[i+1],a=o.x-r.x,s=o.y-r.y,c=a*a+s*s,l=c?Math.max(0,Math.min(1,((e.x-r.x)*a+(e.y-r.y)*s)/c)):0;n=Math.min(n,Math.hypot(e.x-(r.x+l*a),e.y-(r.y+l*s)))}return n},hg=(e,t)=>FR({x:e.x+e.width/2,y:e.y+e.height/2},t);function jR(e,t){const n=e.label;if(!n)return null;const i=gn(e);if(!i.length)return null;const r=[...i,...t.edges.filter(c=>c.id!==e.id).flatMap(gn),...t.shapes.filter(c=>c.container).flatMap(Yo)],o=co(t).filter(c=>c.owner!==e.id).map(c=>c.rect),a=(c,l)=>c.x<l.x+l.width&&l.x<c.x+c.width&&c.y<l.y+l.height&&l.y<c.y+c.height,s=c=>!r.some(l=>Fi(c,l))&&!za(c,t).length&&!o.some(l=>a(c,l));for(const c of i){const l=(c.lo+c.hi)/2,u=c.axis==="h"?[c.at+Sn,c.at-Sn-n.height].map(p=>({...n,x:l-n.width/2,y:p})):[c.at+Sn,c.at-Sn-n.width].map(p=>({...n,x:p,y:l-n.height/2}));for(const p of u)if(s(p))return p}return null}function mg(e,t){var a,s;const{elementRegistry:n}=e,i=e.modeling;let r=Ze(n),o=new Set(dt(r).map(lt));for(const[c,l]of t){const u=l.wps,p=n.get(c),f=p==null?void 0:p.label;if(!f||!(p!=null&&p.waypoints))continue;const d=p.waypoints[0].x-u[0].x,g=p.waypoints[0].y-u[0].y;if(!(p.waypoints.length===u.length&&p.waypoints.every((E,T)=>E.x-u[T].x===d&&E.y-u[T].y===g))){if(((a=p.source)==null?void 0:a.id)===l.source&&((s=p.target)==null?void 0:s.id)===l.target)continue;const E=r.edges.find(D=>D.id===c);if(!(E!=null&&E.label)||!za(E.label,r).length)continue;let T={...E.label,x:l.label.x,y:l.label.y};if((za(T,r).length||hg(T,E.waypoints)>dg)&&(T=null),!T&&hg(E.label,E.waypoints)>dg&&(T=jR(E,r)),!T)continue;const O=T,N={...r,edges:r.edges.map(D=>D.id===c?{...D,label:O}:D)},P=dt(N);if(P.some(D=>!o.has(lt(D))))continue;i.moveElements([f],{x:O.x-f.x,y:O.y-f.y}),r=N,o=new Set(P.map(lt));continue}const y=l.label.x+d-f.x,C=l.label.y+g-f.y;if(y===0&&C===0)continue;const x=r.edges.find(E=>E.id===c);if(!(x!=null&&x.label))continue;const m={...x.label,x:x.label.x+y,y:x.label.y+C},v={...r,edges:r.edges.map(E=>E.id===c?{...E,label:m}:E)},_=dt(v);_.some(E=>!o.has(lt(E)))||(i.moveElements([f],{x:y,y:C}),r=v,o=new Set(_.map(lt)))}}function gg(e,t,n=new Set){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i);for(const a of o.edges){if(!a.label||t.has(a.id)&&!n.has(a.id))continue;const s=Op(a,o);if(!s)continue;const c=i.get(a.id),l=c==null?void 0:c.label;l&&r.moveElements([l],{x:s.x-l.x,y:s.y-l.y})}}function yg(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=Ze(i),a=dt(o).filter(s=>s.kind==="label-on-shared-segment"&&!t.has(lt(s)));for(const s of a){if(s.kind!=="label-on-shared-segment"||n.has(s.edge))continue;const c=o.edges.find(f=>f.id===s.edge);if(!c)continue;const l=fg(c,o);if(!l)continue;const u=i.get(s.edge),p=u==null?void 0:u.label;p&&r.moveElements([p],{x:l.x-p.x,y:l.y-p.y})}}function vg(e,t){const n=e.label;if(!n)return null;const i=[...t.edges.flatMap(gn),...t.shapes.filter(f=>f.container).flatMap(Yo)],r=i.filter(f=>Fi(n,f));if(!r.length)return null;const o=t.shapes.filter(f=>!f.container&&f.id!==e.id),a=co(t).filter(f=>f.owner!==e.id).map(f=>f.rect),s=(f,d)=>f.x<d.x+d.width&&d.x<f.x+f.width&&f.y<d.y+d.height&&d.y<f.y+f.height,c=f=>!i.some(d=>Fi(f,d))&&!o.some(d=>s(f,d))&&!a.some(d=>s(f,d)),l=[];for(const f of r)f.axis==="h"?l.push({...n,y:f.at-Sn-n.height},{...n,y:f.at+Sn}):l.push({...n,x:f.at-Sn-n.width},{...n,x:f.at+Sn});const u=e.x+e.width/2,p=e.y+e.height/2;return l.push({...n,x:u-n.width/2,y:e.y+e.height+Sn},{...n,x:u-n.width/2,y:e.y-Sn-n.height},{...n,x:e.x+e.width+Sn,y:p-n.height/2},{...n,x:e.x-Sn-n.width,y:p-n.height/2}),l.find(c)??null}function bg(e,t){const{elementRegistry:n}=e,i=e.modeling,r=Ze(n);for(const o of r.shapes){if(o.container||!o.label||t.has(o.id))continue;const a=vg(o,Ze(n));if(!a)continue;const s=n.get(o.id),c=s==null?void 0:s.label;c&&i.moveElements([c],{x:a.x-c.x,y:a.y-c.y})}}function HR(e,t){const n=e.x,i=e.x+e.width,r=e.y,o=e.y+e.height;if(t.x<n||t.x>i||t.y<r||t.y>o)return{x:Math.round(Math.min(Math.max(t.x,n),i)),y:Math.round(Math.min(Math.max(t.y,r),o))};const s=[[t.x-n,{x:n,y:t.y}],[i-t.x,{x:i,y:t.y}],[t.y-r,{x:t.x,y:r}],[o-t.y,{x:t.x,y:o}]].reduce((c,l)=>l[0]<c[0]?l:c);return{x:Math.round(s[1].x),y:Math.round(s[1].y)}}function xg(e,t){const{elementRegistry:n}=e,i=e.modeling;let r=Ze(n),o=new Set(dt(r).map(lt));const a=[...new Set(dt(r).filter(s=>s.kind==="edge-endpoint-detached"&&!t.has(lt(s))).map(s=>s.edge))].sort();for(const s of a){const c=r.edges.find(h=>h.id===s);if(!c||c.waypoints.length<2)continue;const l=c.waypoints.map(h=>({...h})),u=[[c.endpoints[0],0],[c.endpoints[1],l.length-1]];let p=!1;for(const[h,y]of u){const C=h?r.shapes.find(m=>m.id===h):void 0;if(!C)continue;const x=HR(C,l[y]);x.x===l[y].x&&x.y===l[y].y||(l[y]=x,p=!0)}if(!p)continue;const f={...r,edges:r.edges.map(h=>h.id===s?{...h,waypoints:l}:h)},d=dt(f);if(d.some(h=>!o.has(lt(h))))continue;const g=n.get(s);g&&(i.updateWaypoints(g,l),r=f,o=new Set(d.map(lt)))}}const Dp=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function _g(e,t){const n=(r,o,a,s="name")=>{const c=s==="text"?"texts":"names",l=u=>o?`${o}.${u}`:u;return{id:r,plainField:l(s),mapField:l(c),plain:a[s],map:a[c]}},i=e;switch(e.kind){case"participant.add":return[n(e.participant.id,"participant",e.participant),...(e.participant.lanes??[]).map((r,o)=>n(r.id,`participant.lanes[${o}]`,r))];case"participant.update":return[n(e.id,"",i),...(e.lanes??[]).map((r,o)=>({...n(r.id,`lanes[${o}]`,r),omittedMeansRemove:(t==null?void 0:t.categoryOf(r.id))==="lane"}))];case"node.add":return[n(e.node.id,"node",e.node)];case"sequenceFlow.add":return[{...n(e.flow.id,"flow",e.flow),condition:e.flow.condition,conditionField:"flow.condition"}];case"sequenceFlow.update":return[{...n(e.id,"",i),condition:e.condition,conditionField:"condition"}];case"messageFlow.add":return[n(e.flow.id,"flow",e.flow)];case"dataStore.add":return[n(e.dataStore.id,"dataStore",e.dataStore)];case"annotation.add":return[n(e.annotation.id,"annotation",e.annotation,"text")];case"annotation.update":return[n(e.id,"",i,"text")];case"group.add":return[n(e.group.id,"group",e.group)];case"node.update":case"messageFlow.update":case"dataStore.update":case"group.update":return[n(e.id,"",i)];default:return[]}}function zR(e,t,n){const i=[],r=n?Ba(n):[];return e.forEach((o,a)=>{if(o.kind==="translation.confirm"){if(!n){i.push({kind:"locale-texts-not-enabled",opIndex:a,id:o.id,field:"locale"});return}if(!r.includes(o.locale)){i.push({kind:"locale-not-in-document",opIndex:a,id:o.id,field:"locale",locale:o.locale,locales:r});return}t.categoryOf(o.id)!==void 0&&!t.reviewRequestLocalesOf(o.id).includes(o.locale)&&i.push({kind:"review-request-missing",opIndex:a,id:o.id,locale:o.locale});return}for(const s of _g(o,t)){const c=s.plain!==void 0,l=s.map!==void 0;if(c&&l){i.push({kind:"locale-texts-conflict",opIndex:a,id:s.id,field:s.mapField});continue}if(l&&s.condition!==void 0&&s.condition!==null){i.push({kind:"locale-texts-conflict",opIndex:a,id:s.id,field:s.conditionField});continue}if(!n){l&&i.push({kind:"locale-texts-not-enabled",opIndex:a,id:s.id,field:s.mapField});continue}if(c&&s.plain!==null){i.push({kind:"locale-texts-required",opIndex:a,id:s.id,field:s.plainField,locales:r});continue}if(s.condition!==void 0&&s.condition!==null){i.push({kind:"locale-texts-required",opIndex:a,id:s.id,field:s.conditionField,locales:r});continue}if(!l)continue;if(!Dp(s.map)){i.push({kind:"payload-invalid",opIndex:a,field:s.mapField});continue}const u=s.map;let p=!0;for(const[d,g]of Object.entries(u))typeof g!="string"||g===""?(i.push({kind:"payload-invalid",opIndex:a,field:`${s.mapField}.${d}`}),p=!1):r.includes(d)||(i.push({kind:"locale-not-in-document",opIndex:a,id:s.id,field:s.mapField,locale:d,locales:r}),p=!1);if(!p)continue;const f=r.filter(d=>!(d in u));f.length&&i.push({kind:"locale-texts-incomplete",opIndex:a,id:s.id,field:s.mapField,missing:f})}}),i}function hi(e,t,n){const i=t==="text"?"texts":"names",{[i]:r,...o}=e;return n===void 0?o:{...o,[t]:n}}function GR(e,t,n){const i=new Map;if(!n)return{ops:[...e],writes:i};const{designLocale:r}=n,o=c=>{let l=i.get(c);return l||i.set(c,l={}),l},a=c=>{if(Dp(c.map)){const l=c.map;return o(c.id).texts={...l},l[r]}if(c.plain===null||c.condition===null&&c.plain===void 0){o(c.id).texts=null;return}c.plain===void 0&&c.omittedMeansRemove&&(o(c.id).texts=null)},s=[];for(const c of e){if(c.kind==="translation.confirm"){const u=o(c.id);u.confirm=[...u.confirm??[],c.locale];continue}const l=_g(c,t);if(!l.length){s.push(c);continue}switch(c.kind){case"participant.add":{const[u,...p]=l,f=hi(c.participant,"name",a(u));c.participant.lanes&&(f.lanes=c.participant.lanes.map((d,g)=>hi(d,"name",a(p[g])))),s.push({...c,participant:f});break}case"participant.update":{const[u,...p]=l,f=hi(c,"name",a(u));c.lanes&&(f.lanes=c.lanes.map((d,g)=>hi(d,"name",a(p[g])))),s.push(f);break}case"node.add":s.push({...c,node:hi(c.node,"name",a(l[0]))});break;case"sequenceFlow.add":s.push({...c,flow:hi(c.flow,"name",a(l[0]))});break;case"messageFlow.add":s.push({...c,flow:hi(c.flow,"name",a(l[0]))});break;case"dataStore.add":s.push({...c,dataStore:hi(c.dataStore,"name",a(l[0]))});break;case"annotation.add":s.push({...c,annotation:hi(c.annotation,"text",a(l[0]))});break;case"group.add":s.push({...c,group:hi(c.group,"name",a(l[0]))});break;case"annotation.update":s.push(hi(c,"text",a(l[0])));break;default:s.push(Dp(l[0].map)?hi(c,"name",a(l[0])):(a(l[0]),c))}}return{ops:s,writes:i}}const VR=/^[\p{L}_][\p{L}\p{N}_.\-]*$/u,wg=new Set(["sequenceFlow","messageFlow","dataAssociation","association"]),Eg={"participant.add":[{path:"participant",shape:["id"]},{path:"participant.lanes[]",shape:["id"],optional:!0}],"participant.update":[{path:"id",shape:null},{path:"lanes[]",shape:["id"],optional:!0}],"node.add":[{path:"node",shape:["id","type"]}],"node.update":[{path:"id",shape:null}],"sequenceFlow.add":[{path:"flow",shape:["id","source","target"]}],"sequenceFlow.update":[{path:"id",shape:null}],"messageFlow.add":[{path:"flow",shape:["id","source","target"]}],"messageFlow.update":[{path:"id",shape:null}],"dataStore.add":[{path:"dataStore",shape:["id"]},{path:"associations[]",shape:["source","target"],optional:!0}],"dataStore.update":[{path:"id",shape:null}],"dataAssociation.add":[{path:"association",shape:["source","target"]}],"association.add":[{path:"association",shape:["source","target"]}],"annotation.add":[{path:"annotation",shape:["id"]},{path:"association",shape:["source","target"],optional:!0},{path:"placement",shape:["anchor","side"],optional:!0}],"annotation.update":[{path:"id",shape:null},{path:"placement",shape:["anchor","side"],optional:!0}],"group.add":[{path:"group",shape:["id"]},{path:"group.members[]",shape:null,optional:!0}],"group.update":[{path:"id",shape:null},{path:"members[]",shape:null,optional:!0}],"translation.confirm":[{path:"id",shape:null},{path:"locale",shape:null}],"element.remove":[{path:"id",shape:null}]},Ga=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Sc=e=>typeof e=="string"&&e!=="";function WR(e){const t=[];function n(i,r,o,a){if(a===null){Sc(o)||t.push({kind:"payload-invalid",opIndex:i,field:r});return}if(!Ga(o)){t.push({kind:"payload-invalid",opIndex:i,field:r});return}for(const s of a)Sc(o[s])||t.push({kind:"payload-invalid",opIndex:i,field:`${r}.${s}`})}return e.forEach((i,r)=>{var o,a,s;if(!Ga(i)||!Sc(i.kind)||!(i.kind in Eg)){t.push({kind:"payload-invalid",opIndex:r,field:"kind"});return}for(const c of Eg[i.kind]){const l=c.path.endsWith("[]"),u=l?c.path.slice(0,-2):c.path,p=u.split(".");let f=i;for(const g of p.slice(0,-1)){if(!Ga(f))break;f=f[g]}if(!Ga(f))continue;const d=f[p[p.length-1]];if(!(d===void 0&&c.optional)&&!(d===null&&c.optional)){if(!l){n(r,c.path,d,c.shape);continue}if(!Array.isArray(d)){t.push({kind:"payload-invalid",opIndex:r,field:c.path});continue}d.forEach((g,h)=>n(r,`${u}[${h}]`,g,c.shape))}}if(i.kind==="annotation.add"){const c=i.annotation;Ga(c)&&!Sc(c.text)&&c.texts===void 0&&t.push({kind:"payload-invalid",opIndex:r,field:"annotation.text"})}if(i.kind==="node.add"||i.kind==="node.update"){const c=i.band;c!==void 0&&(!Number.isInteger(c)||c<0)&&t.push({kind:"payload-invalid",opIndex:r,field:"band"});const l=i.kind==="node.add"?(o=i.node)==null?void 0:o.type:i.type,u=(i.kind==="node.add"?(a=i.node)==null?void 0:a.id:i.id)??"";if(typeof l=="string"&&!Yh(l)){t.push({kind:"node-type-unsupported",opIndex:r,id:u,type:l});return}const p=i.kind==="node.add"?(s=i.node)==null?void 0:s.eventDefinition:i.eventDefinition;if(p!==void 0&&!Kh(p)){t.push({kind:"payload-invalid",opIndex:r,field:i.kind==="node.add"?"node.eventDefinition":"eventDefinition"});return}l==="intermediateCatchEvent"!==(p!==void 0)&&t.push({kind:"event-definition-mismatch",opIndex:r,id:u,...typeof l=="string"?{type:l}:{},...p!==void 0?{eventDefinition:p}:{}})}}),t}function Sg(e,t,n={}){const i=WR(e);if(i.length>0)return i;const r=[],o=new Map,a=new Map;function s(h,y,C){if(!VR.test(y)){r.push({kind:"id-invalid",opIndex:h,id:y});return}if(t.categoryOf(y)!==void 0||o.has(y)){r.push({kind:"id-duplicate",opIndex:h,id:y});return}o.set(y,{...C,opIndex:h})}e.forEach((h,y)=>{var C;switch(h.kind){case"participant.add":s(y,h.participant.id,{category:"participant",lanes:(h.participant.lanes??[]).map(x=>x.id)});for(const x of h.participant.lanes??[])s(y,x.id,{category:"lane"});break;case"node.add":s(y,h.node.id,{category:"flowNode",participant:h.node.participant});break;case"sequenceFlow.add":s(y,h.flow.id,{category:"sequenceFlow"});break;case"messageFlow.add":s(y,h.flow.id,{category:"messageFlow"});break;case"dataStore.add":s(y,h.dataStore.id,{category:"dataStore"});for(const x of h.associations??[])x.id&&s(y,x.id,{category:"dataAssociation"});break;case"dataAssociation.add":h.association.id&&s(y,h.association.id,{category:"dataAssociation"});break;case"association.add":h.association.id&&s(y,h.association.id,{category:"association"});break;case"annotation.add":s(y,h.annotation.id,{category:"annotation"}),(C=h.association)!=null&&C.id&&s(y,h.association.id,{category:"association"});break;case"group.add":s(y,h.group.id,{category:"group"});break;case"participant.update":if(h.lanes){a.set(h.id,h.lanes.map(x=>x.id));for(const x of h.lanes)t.categoryOf(x.id)===void 0&&s(y,x.id,{category:"lane"})}break}});const c=h=>{var y;return((y=o.get(h))==null?void 0:y.category)??t.categoryOf(h)},l=h=>{const y=o.get(h);return y?y.category==="participant"?h:y.participant:t.categoryOf(h)==="participant"?h:t.participantOf(h)};function u(h,y,C,x){const m=c(y);if(m===void 0){r.push({kind:"ref-missing",opIndex:h,ref:y,role:C});return}if(x&&!x.includes(m)){r.push({kind:"ref-category",opIndex:h,ref:y,role:C,expected:x.join("|"),actual:m});return}return m}const p=t.isCollaboration()||e.some(h=>h.kind==="participant.add"),f=new Map;for(const h of e)h.kind==="node.add"?f.set(h.node.id,h.node.eventDefinition):h.kind==="node.update"&&h.type!==void 0&&f.set(h.id,h.eventDefinition);const d=h=>f.has(h)?f.get(h)==="timer":t.eventDefinitionOf(h)==="timer";return e.forEach((h,y)=>{var C;switch(h.kind){case"participant.add":break;case"node.add":{const{participant:x,lane:m}=h.node;if(x===void 0){(p||m!==void 0)&&r.push({kind:"participant-required",opIndex:y,id:h.node.id});break}if(u(y,x,"participant",["participant"])===void 0)break;m!==void 0&&((((C=o.get(x))==null?void 0:C.lanes)??a.get(x)??t.lanesOf(x)).includes(m)||r.push({kind:"lane-unknown",opIndex:y,lane:m,participant:x}));break}case"sequenceFlow.add":{const{id:x,source:m,target:v,name:_,condition:E}=h.flow,T=u(y,m,"source",["flowNode"]),O=u(y,v,"target",["flowNode"]);T&&O&&l(m)!==l(v)&&r.push({kind:"flow-cross-pool",opIndex:y,id:x}),_!==void 0&&E!==void 0&&r.push({kind:"condition-name-conflict",opIndex:y,id:x});break}case"messageFlow.add":{const{id:x,source:m,target:v}=h.flow,_=u(y,m,"source",["flowNode","participant"]),E=u(y,v,"target",["flowNode","participant"]);if(_&&E){const T=l(m),O=l(v);T!==void 0&&T===O&&r.push({kind:"message-flow-same-pool",opIndex:y,id:x})}for(const T of[m,v])d(T)&&r.push({kind:"message-flow-timer-endpoint",opIndex:y,id:x,ref:T});break}case"dataStore.add":{for(const x of h.associations??[]){if([x.source,x.target].filter(_=>_===h.dataStore.id).length!==1){r.push({kind:"data-association-ends",opIndex:y,source:x.source,target:x.target});continue}const v=x.source===h.dataStore.id?x.target:x.source;u(y,v,"dataAssociation",["flowNode"])}break}case"dataAssociation.add":{const{source:x,target:m}=h.association,v=u(y,x,"source"),_=u(y,m,"target");if(v&&_){const E=new Set([v,_]);E.has("dataStore")&&E.has("flowNode")||r.push({kind:"data-association-ends",opIndex:y,source:x,target:m})}break}case"association.add":{const{id:x,source:m,target:v}=h.association,_=u(y,m,"source"),E=u(y,v,"target");_&&E&&_!=="annotation"&&E!=="annotation"&&r.push({kind:"association-detached",opIndex:y,annotation:x??`${m}->${v}`});break}case"annotation.add":{if(h.association){const{source:x,target:m}=h.association;if(x!==h.annotation.id&&m!==h.annotation.id)r.push({kind:"association-detached",opIndex:y,annotation:h.annotation.id});else{const v=x===h.annotation.id?m:x;u(y,v,"association")}}h.placement&&u(y,h.placement.anchor,"anchor");break}case"group.add":{for(const x of h.group.members??[]){const m=u(y,x,"member");m&&wg.has(m)&&r.push({kind:"ref-category",opIndex:y,ref:x,role:"member",expected:"shape",actual:m})}break}case"participant.update":{if(g(y,h.id,"participant")===void 0)break;if(h.lanes){const x=t.lanesOf(h.id),m=h.lanes.map(_=>_.id);for(const _ of x)m.includes(_)||r.push({kind:"lane-shrink-unsupported",opIndex:y,participant:h.id,lane:_});for(const _ of m)t.categoryOf(_)!==void 0&&!x.includes(_)&&r.push({kind:"id-duplicate",opIndex:y,id:_});const v=m.filter(_=>x.includes(_));v.length===x.length&&v.some((_,E)=>_!==x[E])&&r.push({kind:"lane-reorder-unsupported",opIndex:y,participant:h.id})}break}case"node.update":{if(g(y,h.id,"flowNode")===void 0)break;if(h.lane!==void 0){const x=t.participantOf(h.id);(x?a.get(x)??t.lanesOf(x):[]).includes(h.lane)||r.push({kind:"lane-unknown",opIndex:y,lane:h.lane,participant:x??""})}break}case"sequenceFlow.update":{if(g(y,h.id,"sequenceFlow")===void 0)break;if(h.name!==void 0&&h.condition!==void 0&&r.push({kind:"condition-name-conflict",opIndex:y,id:h.id}),h.source!==void 0||h.target!==void 0){const x=h.source===void 0||u(y,h.source,"source",["flowNode"])!==void 0,m=h.target===void 0||u(y,h.target,"target",["flowNode"])!==void 0,v=t.endpointsOf(h.id),_=h.source??(v==null?void 0:v.source),E=h.target??(v==null?void 0:v.target);x&&m&&_!==void 0&&E!==void 0&&new Set([l(_),l(E),l(h.id)]).size>1&&r.push({kind:"flow-cross-pool",opIndex:y,id:h.id})}break}case"messageFlow.update":g(y,h.id,"messageFlow");break;case"dataStore.update":g(y,h.id,"dataStore");break;case"annotation.update":{if(g(y,h.id,"annotation")===void 0)break;h.placement&&u(y,h.placement.anchor,"anchor");break}case"group.update":{if(g(y,h.id,"group")===void 0)break;for(const x of h.members??[]){const m=u(y,x,"member");m&&wg.has(m)&&r.push({kind:"ref-category",opIndex:y,ref:x,role:"member",expected:"shape",actual:m})}break}case"translation.confirm":g(y,h.id);break;case"element.remove":{g(y,h.id)==="lane"&&r.push({kind:"ref-category",opIndex:y,ref:h.id,role:"target",expected:"removable",actual:"lane"});break}}}),r.push(...zR(e,t,n.i18n)),r;function g(h,y,C){if(o.has(y)){r.push({kind:"target-added-in-batch",opIndex:h,id:y});return}const x=t.categoryOf(y);if(x===void 0){r.push({kind:"ref-missing",opIndex:h,ref:y,role:"target"});return}if(C&&x!==C){r.push({kind:"ref-category",opIndex:h,ref:y,role:"target",expected:C,actual:x});return}return x}}function Rg(e){return{modeling:e.get("modeling"),bpmnFactory:e.get("bpmnFactory"),elementFactory:e.get("elementFactory"),elementRegistry:e.get("elementRegistry"),canvas:e.get("canvas"),autoPlace:e.get("autoPlace"),bpmnReplace:e.get("bpmnReplace"),spaceTool:e.get("spaceTool")}}function Rc(e){return`bpmn:${e[0].toUpperCase()}${e.slice(1)}`}const Cc={"top-left":[-1,-1],top:[0,-1],"top-right":[1,-1],right:[1,0],"bottom-right":[1,1],bottom:[0,1],"bottom-left":[-1,1],left:[-1,0]},Rn=10,UR=300,qR=160,Cg=20,Lp=100,Mg=40,YR=10;function Ip(e,t,n,i,r){const o=n,a=(P,D)=>{const[F,J]=Cc[P];let ge={x:t.x+t.width/2+F*(t.width/2+o.width/2+D),y:t.y+t.height/2+J*(t.height/2+o.height/2+D)};const Ae=i.x+Rn+o.width/2,De=i.x+i.width-Rn-o.width/2,qe=i.y+Rn+o.height/2,rt=i.y+i.height-Rn-o.height/2,Me={x:Math.min(De,Math.max(Ae,ge.x)),y:Math.min(rt,Math.max(qe,ge.y))};return(Me.x!==ge.x||Me.y!==ge.y)&&(ge=Math.abs(Me.x-(t.x+t.width/2))<(t.width+o.width)/2+Rn&&Math.abs(Me.y-(t.y+t.height/2))<(t.height+o.height)/2+Rn?{x:t.x+t.width+Rn+o.width/2,y:Me.y}:Me),ge},s=(i.children??[]).filter(P=>!("waypoints"in P&&P.waypoints)&&P.type!=="bpmn:Lane"&&P.type!=="label"&&typeof P.x=="number"&&P.id!==r.selfId),c=Ze(e),l=P=>{var F,J;if(!r.selfId)return!1;const D=e.get(P);return!!D&&(((F=D.source)==null?void 0:F.id)===r.selfId||((J=D.target)==null?void 0:J.id)===r.selfId)},u=c.edges.filter(P=>!l(P.id)).flatMap(gn),p=co(c).filter(P=>P.owner!==r.selfId).map(P=>P.rect),f=P=>({x0:P.x-o.width/2-Rn,x1:P.x+o.width/2+Rn,y0:P.y-o.height/2-Rn,y1:P.y+o.height/2+Rn}),d=P=>{const D=f(P);return s.some(F=>D.x0<F.x+F.width&&D.x1>F.x&&D.y0<F.y+F.height&&D.y1>F.y)},g=P=>{const D=f(P);return u.some(F=>F.axis==="h"?F.at>D.y0&&F.at<D.y1&&F.lo<D.x1&&F.hi>D.x0:F.at>D.x0&&F.at<D.x1&&F.lo<D.y1&&F.hi>D.y0)},h=P=>{const D=f(P);return p.some(F=>D.x0<F.x+F.width&&D.x1>F.x&&D.y0<F.y+F.height&&D.y1>F.y)},y=c.shapes.filter(P=>P.type==="bpmn:Group").flatMap(P=>[{axis:"h",at:P.y,lo:P.x,hi:P.x+P.width},{axis:"h",at:P.y+P.height,lo:P.x,hi:P.x+P.width},{axis:"v",at:P.x,lo:P.y,hi:P.y+P.height},{axis:"v",at:P.x+P.width,lo:P.y,hi:P.y+P.height}]),C=P=>{const D=f(P);return y.some(F=>F.axis==="h"?F.at>D.y0&&F.at<D.y1&&F.lo<D.x1&&F.hi>D.x0:F.at>D.x0&&F.at<D.x1&&F.lo<D.y1&&F.hi>D.y0)},x=P=>d(P)||g(P)||h(P)||C(P),m=P=>P.x-o.width/2>=i.x&&P.x+o.width/2<=i.x+i.width&&P.y-o.height/2>=i.y&&P.y+o.height/2<=i.y+i.height;if(r.placement){const P=De=>De.startsWith("top")?De.replace(/^top/,"bottom"):De.replace(/^bottom/,"top"),D=De=>De.endsWith("left")?De.replace(/left$/,"right"):De.replace(/right$/,"left"),F=r.placement.side,J=[F,P(F),D(F),P(D(F)),"top","bottom","left","right","top-left","top-right","bottom-left","bottom-right"],ge=r.placement.offset??50;let Ae=a(F,ge);if(x(Ae)){const De=new Set;for(const qe of J){if(De.has(qe))continue;De.add(qe);const rt=a(qe,ge);if(m(rt)&&!x(rt)){Ae=rt;break}}}return Ae}const v=r.from,_=i.x+Rn+o.width/2,E=i.x+i.width-Rn-o.width/2,T=i.y+Rn+o.height/2,O=i.y+i.height-Rn-o.height/2;let N={x:Math.min(E,Math.max(_,v.x)),y:Math.min(O,Math.max(T,v.y))};if(x(N)){const P=(t.width+o.width)/2+Rn,F=[{x:N.x+P,y:N.y},{x:N.x-P,y:N.y},{x:N.x,y:N.y-o.height-Rn},{x:N.x,y:N.y+o.height+Rn}].filter(m).find(J=>!x(J));F&&(N=F)}return N}function Kt(e,t){return e.filter(n=>n.kind===t)}class Ag extends Error{constructor(t){super(t.kind),this.issue=t,this.name="LowerIssueError"}}function Pg(e,t){var AE,PE,TE,kE,OE,DE,LE,IE,BE,NE,$E,FE,jE,HE,zE,GE,VE,WE,UE,qE,YE,KE,XE;const{modeling:n,bpmnFactory:i,elementFactory:r,elementRegistry:o,canvas:a,autoPlace:s,bpmnReplace:c,spaceTool:l}=t,u=()=>a.getRootElement(),p=b=>o.get(b),f=b=>{const S=p(b);if(!S)throw new Error(`하강 참조 해소 실패: ${b}`);return S},d=b=>{let S=b.parent;for(;S;){if(S.type==="bpmn:Participant")return S;S=S.parent}},g=new Map;for(const b of o.filter(S=>!("waypoints"in S&&S.waypoints)&&S.type!=="bpmn:Lane"&&S.type!=="label"&&typeof S.x=="number"))g.set(b.id,{x:b.x,y:b.y});const h=Kt(e,"participant.add"),y=Kt(e,"node.add"),C=Kt(e,"sequenceFlow.add"),x=Kt(e,"messageFlow.add"),m=Kt(e,"dataStore.add"),v=Kt(e,"dataAssociation.add"),_=Kt(e,"annotation.add"),E=Kt(e,"group.add"),T=new Map(y.map(b=>[b.node.id,b])),O=(b,S,A)=>{var j;const k=b.businessObject,I=(((j=k.extensionElements)==null?void 0:j.values)??[]).filter(B=>B.$type!==S),L=A?[...I,i.create(S,A)]:I;if(!L.length){k.extensionElements&&n.updateProperties(b,{extensionElements:void 0});return}const H=i.create("bpmn:ExtensionElements",{values:L});L.forEach(B=>{B.$parent=H}),n.updateProperties(b,{extensionElements:H})},N=b=>({anchor:b.anchor,side:b.side,...b.offset!==void 0?{offset:b.offset}:{}});for(const b of Kt(e,"element.remove")){const S=p(b.id);S&&n.removeElements([S])}const P=b=>o.filter(S=>{var A;return S.type==="bpmn:Lane"&&((A=d(S))==null?void 0:A.id)===b}).sort((S,A)=>S.y-A.y);for(const b of Kt(e,"participant.update")){const S=f(b.id);if(b.name!==void 0&&n.updateProperties(S,{name:b.name??void 0}),!b.lanes)continue;const A=P(b.id);if(!A.length){n.splitLane(S,b.lanes.length),P(b.id).forEach((I,L)=>{const H=b.lanes[L];H&&n.updateProperties(I,{id:H.id,name:H.name})});continue}const k=new Set(A.map(I=>I.id));b.lanes.forEach((I,L)=>{if(k.has(I.id)){n.updateProperties(f(I.id),{name:I.name});return}const H=L===0?n.addLane(P(b.id)[0],"top"):n.addLane(f(b.lanes[L-1].id),"bottom");n.updateProperties(H,{id:I.id,name:I.name})})}const D=150,F=130,J=80,ge=90,Ae=180,De=30,qe=30,rt=(b,S,A,k,I)=>{const L=A-S.width/2,H=k-S.height/2;return(b.children??[]).find(j=>!("waypoints"in j&&j.waypoints)&&j.type!=="bpmn:Lane"&&j.type!=="label"&&!(I!=null&&I.has(j.id))&&typeof j.x=="number"&&L<j.x+j.width+qe&&L+S.width+qe>j.x&&H<j.y+j.height&&H+S.height>j.y)},Me=new Set;for(const b of h){Me.add(`pool:${b.participant.id}`);for(const S of b.participant.lanes??[])Me.add(S.id)}const X=new Map;for(const b of y){const S=b.node.lane??`pool:${b.node.participant??""}`;let A=X.get(S);A||X.set(S,A=new Set([0])),b.band!==void 0&&A.add(b.band)}const ne=new Map;for(const[b,S]of X){if(!Me.has(b))continue;const A=[...S].sort((L,H)=>L-H),k=A.map((L,H)=>H===0?0:H%2===1?Math.ceil(H/2):-(H/2)),I=Math.min(...k);ne.set(b,new Map(A.map((L,H)=>[L,k[H]-I])))}{const b=new Map;for(const S of h)(S.participant.lanes??[]).forEach((A,k)=>b.set(A.id,k));for(const[S,A]of ne){if(!b.has(S)||A.size<2)continue;const k=b.get(S),I=A.get(0)??0,L=new Set;for(const ee of y){if(ee.node.lane!==S||(ee.band??0)!==0||!ee.node.type.endsWith("Gateway"))continue;const de={in:new Set,out:new Set,cross:new Set};for(const pe of C){const me=pe.flow.source===ee.node.id;if(!me&&pe.flow.target!==ee.node.id)continue;const Ye=T.get(me?pe.flow.target:pe.flow.source);if(!Ye||Ye.node.participant!==ee.node.participant||!Ye.node.lane)continue;let Ce,Q=!1;if(Ye.node.lane!==S){const ie=b.get(Ye.node.lane);if(ie===void 0)continue;Ce=ie>k?"down":"up",Q=!0}else{const ie=A.get(Ye.band??0)??I;Ce=ie>I?"down":ie<I?"up":void 0}Ce&&(de[me?"out":"in"].add(Ce),Q&&de.cross.add(Ce))}for(const pe of["up","down"])de.in.has(pe)&&de.out.has(pe)&&de.cross.has(pe)&&L.add(pe)}if(L.size!==1)continue;const[H]=L,j=Math.max(...A.values()),B=H==="down"?j:0;if(I===B)continue;const W=[...A.entries()].filter(([ee])=>ee!==0).sort((ee,de)=>ee[1]-de[1]),Y=[...Array(j+1).keys()].filter(ee=>ee!==B),ae=new Map([[0,B]]);W.forEach(([ee],de)=>ae.set(ee,Y[de])),ne.set(S,ae)}}const q=b=>{var S;return(((S=X.get(b))==null?void 0:S.size)??0)>1},K=b=>b.band??(b.node.lane||!q(`pool:${b.node.participant??""}`)?void 0:0),oe=new Map,fe=b=>oe.get(b.node.id)??K(b),Te=new Set,$=new Set;{const b=new Map;for(const k of C)b.set(k.flow.target,(b.get(k.flow.target)??0)+1);const S=k=>{const I=[],L=new Set([k]),H=[k];for(;H.length;){const j=H.shift();I.push(j);for(const B of C)B.flow.source!==j||L.has(B.flow.target)||(b.get(B.flow.target)??0)!==1||(L.add(B.flow.target),H.push(B.flow.target))}return I},A=(k,I)=>{var L;return((L=ne.get(k))==null?void 0:L.get(I))??I};for(const k of y){if(!k.node.type.endsWith("Gateway"))continue;const I=k.node.lane??`pool:${k.node.participant??""}`,L=ne.get(I);if(!L||L.size<2)continue;const H=fe(k);if(H===void 0||A(I,H)!==A(I,0))continue;const j=A(I,H),B=C.filter(pe=>pe.flow.source===k.node.id).map(pe=>T.get(pe.flow.target)).filter(pe=>!!pe&&(pe.node.lane??`pool:${pe.node.participant??""}`)===I),W=B.filter(pe=>{const me=fe(pe);return me!==void 0&&A(I,me)===j&&(b.get(pe.node.id)??0)===1}),Y=B.some(pe=>{const me=fe(pe);return me!==void 0&&A(I,me)>j});if(W.length!==1||!Y)continue;const ae=new Set(B.flatMap(pe=>S(pe.node.id)));if(!C.some(pe=>pe.flow.target===k.node.id&&ae.has(pe.flow.source)))continue;const de=new Map;for(const[pe,me]of L)de.set(pe,me+1);de.set(-1,0),ne.set(I,de);for(const pe of S(W[0].node.id))T.has(pe)&&(oe.set(pe,-1),$.add(pe));Te.add(k.node.id)}}const R=(b,S)=>{var A;return((A=ne.get(b))==null?void 0:A.get(S))??S},w=(b,S,A,k)=>{const I=b?p(b):S?p(S):void 0;if(!I)return!1;const L=b?I.y+Math.min(I.height/2,ge):I.y+J;return Math.abs(L+R(b??`pool:${S??""}`,A)*D-k)<=D/2},G=new Map;for(const[b,S]of X){let A=0;for(const k of S)A=Math.max(A,R(b,k));G.set(b,A)}const V=b=>Ae+D*b,te=(b,S,A)=>{const k=u().children.filter(I=>!("waypoints"in I&&I.waypoints)&&I.type!=="label"&&I.id!==S&&typeof I.y=="number"&&I.y>=b);k.length&&n.moveElements(k,{x:0,y:A})},Re=(b,S,A)=>{const k=b.type==="bpmn:Participant"?b:void 0;if(!k||k.children.some(j=>j.type==="bpmn:Lane"))return;const I=A+S.height/2+De-k.y;if(k.height>=I)return;const L=I-k.height,H=k.y+k.height;n.resizeShape(k,{x:k.x,y:k.y,width:k.width,height:I}),te(H,k.id,L)},Qe=(b,S)=>{const A=S-b.height;if(A<=0)return;const k=d(b)??b,I=[],L=B=>{I.push(B);for(const W of B.children??[])L(W)};L(k);const H=b.y+b.height-10,j=l.calculateAdjustments(I,"y",A,H);l.makeSpace(j.movingShapes,j.resizingShapes,{x:0,y:A},"s",H)},ht=(b,S,A)=>{if(b){const H=f(b),j=V(S);if(H.height>=j)return;const B=j-H.height,W=d(H),Y=W?W.y+W.height:H.y+H.height;Qe(H,j),te(Y,W==null?void 0:W.id,B);return}if(!A)return;const k=D*(S+1);if(A.height>=k)return;const I=k-A.height,L=A.y+A.height;n.resizeShape(A,{x:A.x,y:A.y,width:A.width,height:k}),te(L,A.id,I)},Wt=new Map;for(const b of C)Wt.set(b.flow.target,(Wt.get(b.flow.target)??0)+1);const xt=b=>(Wt.get(b)??0)<=1,dn=new Set(y.map(b=>b.node.id).filter(b=>Kt(e,"sequenceFlow.update").filter(S=>S.target===b).length===1&&!C.some(S=>S.flow.target===b||S.flow.source===b&&T.has(S.flow.target)))),wn=new Map,jn=(b,S)=>{if(!b)return;const A=p(b);if(!A||A.height>=V(S))return;const k=A.y+A.height-10,I=d(A);if(I)return new Set((I.children??[]).filter(L=>L.type!=="bpmn:Lane"&&typeof L.y=="number"&&L.y>k).map(L=>L.id))},Ct=(b,S,A)=>{if(!b)return!0;const k=p(b);return k?A-S.height/2>=k.y&&A+S.height/2<=k.y+k.height:!0},Yt=h.map((b,S)=>({op:b,declared:S}));Yt.sort((b,S)=>{const A=b.op.order??Number.POSITIVE_INFINITY,k=S.op.order??Number.POSITIVE_INFINITY;return A!==k?A-k:b.declared-S.declared});let vn=80;for(const b of o.getAll())b.parent===u()&&"height"in b&&typeof b.y=="number"&&(vn=Math.max(vn,b.y+b.height+60));for(const{op:b}of Yt){const S=b.participant,A=y.filter(ee=>ee.node.participant===S.id).length,k=((AE=S.lanes)==null?void 0:AE.length)??0,I=Math.max(1200,A*160+300),L=(S.lanes??[]).map(ee=>V(G.get(ee.id)??0)),H=L.reduce((ee,de)=>ee+de,0);k&&H<300&&(L[k-1]+=300-H);const j=Math.max(300,D*((G.get(`pool:${S.id}`)??0)+1)),B=S.blackBox||A+k===0?120:k?Math.max(300,H):j,W=r.createShape({type:"bpmn:Participant",businessObject:i.create("bpmn:Participant",{id:S.id,name:S.name,...b.order!==void 0?{"bwl:poolOrder":b.order}:{},...S.blackBox?{}:{processRef:i.create("bpmn:Process")}}),width:I,height:B,isExpanded:!0}),Y=n.createShape(W,{x:100+I/2,y:vn+B/2},u()),ae=S.lanes??[];if(ae.length&&n.splitLane(Y,ae.length),ae.length){const ee=o.filter(de=>{var pe;return de.type==="bpmn:Lane"&&((pe=d(de))==null?void 0:pe.id)===S.id}).sort((de,pe)=>de.y-pe.y);if(ee.forEach((de,pe)=>{const me=ae[pe];me&&n.updateProperties(de,{id:me.id,name:me.name})}),L.some(de=>de!==Y.height/k)){let de=Y.y;ee.forEach((pe,me)=>{const Ye=L[me];n.resizeShape(pe,{x:pe.x,y:de,width:pe.width,height:Ye}),de+=Ye})}}vn=Y.y+Y.height+60}const ka=b=>{var k;const S=T.get(b);if(S)return S.node.participant??"";const A=p(b);return A?A.type==="bpmn:Participant"?A.id:((k=d(A))==null?void 0:k.id)??"":""},Hn=new Map,Di=b=>{let S=Hn.get(b);return S||Hn.set(b,S={nodes:[],flows:[]}),S};for(const b of y)Di(b.node.participant??"").nodes.push(b);for(const b of C)Di(ka(b.flow.source)).flows.push(b);const ri=b=>{var S;return i.create("bpmn:SequenceFlow",{id:b.id,name:b.name??((S=b.condition)==null?void 0:S.label)})},Zt=(b,S,A)=>r.createShape({type:Rc(b.type),...b.eventDefinition?{eventDefinitionType:ec[b.eventDefinition]}:{},businessObject:i.create(Rc(b.type),{id:b.id,name:b.name,...S!==void 0?{"bwl:band":S}:{},...A!==void 0?{"bwl:afterColumn":A}:{}})}),Mo=[...Yt.map(({op:b})=>b.participant.id).filter(b=>Hn.has(b)),...[...Hn.keys()].filter(b=>!h.some(S=>S.participant.id===b))],Oa=b=>b.endsWith("Gateway");for(const b of Mo){const S=Hn.get(b),A=b?f(b):void 0,k=A?A.x+150:250;let I=A?A.y+80:120;const L=(Q,ie,se)=>{if(Q){const ve=f(Q);return ve.y+Math.min(ve.height/2,ge)+R(Q,ie??0)*D}return ie!==void 0&&A?A.y+J+R(`pool:${b}`,ie)*D:se},H=(Q,ie,se)=>{if(Q){const ve=f(Q);return ve.y+Math.min(ve.height/2,ge)+ie*D}return A?A.y+J+ie*D:se},j=Q=>Q.participant?f(Q.participant):u(),B=(Q,ie,se,ve,et,Ve,gt,Tt)=>{const xe=se!==void 0||ve!==void 0,be=Be=>{const we=()=>ht(se,Be,A);Tt?Tt(we):we()},re=R(se??`pool:${b}`,ve??0);if((ve===void 0||w(se,b,ve,gt??Number.NaN))&&gt!==void 0&&Ct(se,ie,gt)&&!rt(Q,ie,et,gt))return{x:et,y:gt};if(xe)for(let Be=0;Be<4;Be++){const we=H(se,re+Be,Ve);if(!rt(Q,ie,et,we,jn(se,re+Be)))return be(re+Be),{x:et,y:we}}const ye=L(se,ve,Ve);xe?be(re):Tt?Tt(()=>Re(Q,ie,ie.y+ie.height/2)):Re(Q,ie,ye);let Ie=et;for(let Be=0;Be<64;Be++){const we=rt(Q,ie,Ie,ye);if(!we)break;Ie=we.x+we.width+F+ie.width/2}return{x:Ie,y:ye}},W=new Set(S.flows.map(Q=>Q.flow.target)),Y=new Map,ae=Q=>{if(Q===void 0)return;const ie=o.get(Q);if(!(!ie||typeof ie.x!="number"||typeof ie.width!="number"))return ie.x+ie.width+F};for(const Q of S.nodes){if(W.has(Q.node.id))continue;const ie=Zt(Q.node,Q.band,Q.afterColumn),se=K(Q),ve=Q.node.lane?`${Q.node.lane}|${se??""}`:se!==void 0?`band:${se}`:"",et=j(Q.node),Ve=Y.get(ve)??k,gt=ae(Q.afterColumn),Tt=gt===void 0?Ve:Math.max(Ve,gt);let xe;const be=B(et,ie,Q.node.lane,se,Tt,I,void 0,dn.has(Q.node.id)&&Q.node.participant!==void 0?re=>xe=re:void 0);if(xe?n.createShape(ie,be,et,{autoResize:!1}):n.createShape(ie,be,et),xe){const re=Q.node.lane?f(Q.node.lane):et;wn.set(Q.node.id,{container:re,relCy:be.y-re.y,grow:xe})}Y.set(ve,be.x+ie.width+F),!Q.node.lane&&se===void 0&&(I+=160)}const ee=new Set,de=new Map,pe=new Map,me=new Map;if(b&&Me.has(`pool:${b}`)){const Q=new Map;for(const xe of S.flows)Q.set(xe.flow.target,(Q.get(xe.flow.target)??0)+1);const ie=xe=>L(xe.node.lane,fe(xe),Number.NaN),se=new Set,ve=xe=>{var ye;const be=(ye=T.get(xe))==null?void 0:ye.node.participant;if(be)return p(be);const re=p(xe);if(re)return re.type==="bpmn:Participant"?re:d(re)},et=xe=>{const be=[],re=new Set([xe]),ye=[xe];for(;ye.length;){const Ie=ye.shift(),Be=T.get(Ie);Be&&be.push(Be);for(const we of S.flows)we.flow.source!==Ie||re.has(we.flow.target)||(Q.get(we.flow.target)??0)!==1||(re.add(we.flow.target),ye.push(we.flow.target))}return be},Ve=xe=>{if(!A)return;const be=new Set(xe.map(Ie=>Ie.node.id));let re=!1,ye=!1;for(const Ie of x){if(!be.has(Ie.flow.source))continue;const Be=ve(Ie.flow.target);!Be||Be.id===A.id||(Be.y<A.y?re=!0:ye=!0)}return re&&!ye?"up":ye&&!re?"down":void 0};for(const xe of S.nodes){if(!Oa(xe.node.type))continue;const be=L(xe.node.lane,K(xe),Number.NaN);if(Number.isNaN(be))continue;const re=[];for(const we of S.flows){if(we.flow.source!==xe.node.id)continue;const ot=T.get(we.flow.target);if(!ot||ot.node.lane!==xe.node.lane||(Q.get(ot.node.id)??0)!==1)continue;const Ke=K(ot);if(Ke===void 0)continue;const Mt=L(ot.node.lane,Ke,Number.NaN);if(Number.isNaN(Mt))continue;const Pe=et(ot.node.id),ke=Ve(Pe);ke&&re.push({subtree:Pe,band:Ke,row:Mt,dir:ke})}if(!re.some(we=>we.dir==="up")||!re.some(we=>we.dir==="down")||!re.some(we=>we.dir==="up"&&re.some(ot=>ot.dir==="down"&&ot.row<we.row)))continue;const Ie=[...re].sort((we,ot)=>we.row-ot.row);[...re.filter(we=>we.dir==="up"),...re.filter(we=>we.dir==="down")].sort((we,ot)=>we.dir===ot.dir?we.row-ot.row:we.dir==="up"?-1:1).forEach((we,ot)=>{const Ke=Ie[ot].band;if(Ke!==we.band){se.add(xe.node.id);for(const Mt of we.subtree)K(Mt)===we.band&&oe.set(Mt.node.id,Ke)}})}const gt=xe=>{if(!A)return;const be=new Set(xe.map(Ie=>Ie.node.id));let re=!1,ye=!1;for(const Ie of x){if(!be.has(Ie.flow.target))continue;const Be=ve(Ie.flow.source);!Be||Be.id===A.id||(Be.y<A.y?re=!0:ye=!0)}return re&&!ye?"up":ye&&!re?"down":void 0};for(const xe of S.nodes){if(!Oa(xe.node.type))continue;const be=xe.node.lane??`pool:${b}`,re=ne.get(be);if(!re||re.size<2)continue;const ye=re.get(0);if(ye===void 0)continue;const Ie=Math.max(...re.values()),Be=ye===Ie&&ye!==0?"down":void 0;if(!Be)continue;const we=[];for(const ke of S.flows){if(ke.flow.source!==xe.node.id)continue;const Xe=T.get(ke.flow.target);if(!Xe||Xe.node.lane!==xe.node.lane||(Q.get(Xe.node.id)??0)!==1)continue;const bn=fe(Xe);bn!==void 0&&we.push({t:Xe,subtree:et(Xe.node.id),band:bn})}const ot=we.find(ke=>(re.get(ke.band)??ke.band)===ye);if(!ot||gt(ot.subtree)===Be||Ve(ot.subtree)===Be)continue;const Ke=we.find(ke=>ke!==ot&&gt(ke.subtree)===Be);if(!Ke)continue;const Mt=ot.band,Pe=Ke.band;for(const ke of ot.subtree)fe(ke)===Mt&&oe.set(ke.node.id,Pe);for(const ke of Ke.subtree)fe(ke)===Pe&&oe.set(ke.node.id,Mt);se.add(xe.node.id)}for(const xe of S.nodes){if(!Oa(xe.node.type))continue;const be=ie(xe);if(Number.isNaN(be)||_.some(we=>{var ot,Ke;return(((ot=we.placement)==null?void 0:ot.anchor)??(we.association?we.association.source===we.annotation.id?we.association.target:we.association.source:void 0))===xe.node.id&&((Ke=we.placement)==null?void 0:Ke.side.startsWith("bottom"))}))continue;let ye,Ie=!1,Be;for(const we of S.flows){if(we.flow.source!==xe.node.id)continue;const ot=T.get(we.flow.target);if(!ot||!ot.node.lane&&K(ot)===void 0)continue;const Ke=ie(ot);Number.isNaN(Ke)||(Math.abs(Ke-be)<.5&&(Ie=!0),Ke>be?!ye||Ke>ye.row?ye={id:ot.node.id,row:Ke,count:1}:Ke===ye.row&&ye.count++:Ke<be&&ot.node.lane===xe.node.lane&&(!Be||Ke>Be.row?Be={op:ot,row:Ke,count:1}:Ke===Be.row&&Be.count++))}ye&&ye.count===1&&(Q.get(ye.id)??0)===1&&!se.has(xe.node.id)&&ee.add(ye.id),!Ie&&Be&&Be.count===1&&(Q.get(Be.op.node.id)??0)===1&&!Te.has(xe.node.id)&&de.set(Be.op.node.id,{lane:xe.node.lane,band:fe(xe)})}const Tt=new Map;for(const xe of x)Tt.set(xe.flow.target,[...Tt.get(xe.flow.target)??[],xe]);for(const xe of S.nodes){const be=Tt.get(xe.node.id);if(!be||be.length!==1||!Q.get(xe.node.id)||!xe.node.lane&&K(xe)===void 0||$.has(xe.node.id))continue;const re=(PE=T.get(be[0].flow.source))==null?void 0:PE.node.participant,ye=re?p(re):void 0;if(!ye||!A||ye.id===A.id)continue;const Ie=xe.node.lane??`pool:${b}`,Be=ne.get(Ie);if(!Be)continue;const we=Be.get(0)??0,ot=(Be.get(fe(xe)??0)??we)-we;if(ot===0)continue;const Ke=ye.y<A.y;if(Ke&&ot<0||!Ke&&ot>0)continue;let Mt;for(const[Pe,ke]of Be){const Xe=ke-we;(Ke&&Xe<0&&(!Mt||Xe<Mt.row)||!Ke&&Xe>0&&(!Mt||Xe>Mt.row))&&(Mt={band:Pe,row:Xe})}Mt&&pe.set(xe.node.id,{lane:xe.node.lane,band:Mt.band})}}const Ye=new Set;let Ce=0;for(;Ce++<S.nodes.length+2;){for(let se=0;se<S.nodes.length+S.flows.length+2;se++){let ve=!1;for(const et of S.flows){const Ve=et.flow;if(Ye.has(Ve.id))continue;const gt=p(Ve.source);if(!gt)continue;const Tt=p(Ve.target),xe=T.get(Ve.target);if(!Tt&&xe){const be=Zt(xe.node,xe.band),re=fe(xe);if(xe.node.lane||re!==void 0){const ye=j(xe.node),Ie=gt,Be=Ie.x+(me.get(Ve.source)??0)+Ie.width+F,we=de.get(Ve.target)??pe.get(Ve.target),ot=B(ye,be,we?we.lane:xe.node.lane,we?we.band:re,ee.has(Ve.target)?Ie.x+Ie.width/2:Be,Number.NaN,we||!xt(Ve.target)?void 0:Ie.y+Ie.height/2),Ke=n.createShape(be,ot,ye);ee.has(Ve.target)&&me.set(Ve.target,Be-(Ke.x+Ke.width/2)),n.connect(gt,Ke,{type:"bpmn:SequenceFlow",businessObject:ri(Ve)})}else s.append(gt,be,{connection:{type:"bpmn:SequenceFlow",businessObject:ri(Ve)}})}else if(Tt)n.connect(gt,Tt,{type:"bpmn:SequenceFlow",businessObject:ri(Ve)});else continue;Ye.add(Ve.id),ve=!0}if(!ve)break}const Q=S.nodes.filter(se=>!p(se.node.id));if(!Q.length)break;const ie=Q[0];{const se=Zt(ie.node,ie.band),ve=j(ie.node),et=K(ie);n.createShape(se,B(ve,se,ie.node.lane,et,k,I),ve),!ie.node.lane&&et===void 0&&(I+=160)}}}const Tn=40,pt=b=>{const S=Y=>Y.kind==="label-over-line"||Y.kind==="label-over-shape"||Y.kind==="label-on-shared-segment"?Y.edge===b.id:Y.kind==="annotation-over-label"||Y.kind==="pool-name-over-label"?Y.label===b.id:!1,A=()=>new Set(dt(Ze(o)).filter(Y=>!S(Y)).map(Y=>lt(Y))),k=A(),I=b.waypoints.map(Y=>({x:Y.x,y:Y.y})),L=b.label,H=L&&{x:L.x,y:L.y};n.layoutConnection(b,{waypoints:[]});const j=A(),B=[...j].filter(Y=>!k.has(Y)).length,W=[...k].filter(Y=>!j.has(Y)).length;B<=W||(n.updateWaypoints(b,I),L&&H&&(L.x!==H.x||L.y!==H.y)&&n.moveElements([L],{x:H.x-L.x,y:H.y-L.y}))},yt=5,Ao=10,nE=200,Nu=new Set([...C.map(b=>b.flow.id),...x.map(b=>b.flow.id),...Kt(e,"sequenceFlow.update").map(b=>b.id),...Kt(e,"messageFlow.update").map(b=>b.id)].filter(b=>!!b)),BN=(b,S,A,k,I,L)=>{const H=new Set(b.map(Q=>Q.id)),j=Math.min(...b.map(Q=>Q.x))+S-Ao,B=Math.max(...b.map(Q=>Q.x+Q.width))+S+nE+Ao,W=Math.min(...b.map(Q=>Q.y+Math.min(0,...A)))-Ao,Y=Math.max(...b.map(Q=>Q.y+Q.height+Math.max(0,...A)))+Ao,ae=o.getAll().filter(Q=>{if(Q.type!=="bpmn:SequenceFlow"&&Q.type!=="bpmn:MessageFlow")return!1;const ie=Q;return Nu.has(ie.id)||!ie.waypoints||ie.waypoints.length<2||[ie.source,ie.target].some(ve=>!ve||H.has(ve.id)||ve.x>=k)?!1:ie.waypoints.some((ve,et)=>{const Ve=ie.waypoints[et+1];return!!Ve&&Math.max(ve.x,Ve.x)>=j&&Math.min(ve.x,Ve.x)<=B&&Math.max(ve.y,Ve.y)>=W&&Math.min(ve.y,Ve.y)<=Y})});if(!ae.length)return 0;const ee=Q=>{const ie=new Map;for(const se of b)for(const ve of A){const et={id:se.id,type:se.type,x:se.x+S+Q,y:se.y+ve,width:se.width,height:se.height};for(const Ve of ae){let gt=1/0;for(let xe=0;xe+1<Ve.waypoints.length;xe++)gt=Math.min(gt,yc(Ve.waypoints[xe],Ve.waypoints[xe+1],et));const Tt=`${Ve.id}|${se.id}`;ie.set(Tt,Math.min(ie.get(Tt)??1/0,gt))}}return ie},de=[...ee(0)].filter(([,Q])=>Q<=yt).map(([Q])=>Q);if(!de.length)return 0;let pe=0;for(let Q=1;Q<=nE;Q++){const ie=ee(Q);if([...ie.values()].every(se=>se>yt)&&de.every(se=>(ie.get(se)??1/0)>=Ao)){pe=Q;break}}if(!pe)return 0;const me=Math.min(...b.map(Q=>Q.x))+S+pe,Ye=new Set(de.map(Q=>Q.slice(0,Q.indexOf("|"))));return ae.some(Q=>Q.type==="bpmn:SequenceFlow"&&Ye.has(Q.id)&&Q.waypoints.some((ie,se)=>{const ve=Q.waypoints[se+1];if(!ve||Math.min(ie.y,ve.y)>L||Math.max(ie.y,ve.y)<L||ie.y===ve.y)return!1;const et=ie.x+(L-ie.y)*(ve.x-ie.x)/(ve.y-ie.y);return et>I&&et<me}))?0:pe},Po=(b,S=()=>!0)=>{const A=p(b);if(!A)return[];const k=[A],I=new Set([b]);for(let L=0;L<k.length;L++){const H=k[L].id;for(const j of C){const B=j.flow.target;if(j.flow.source!==H||I.has(B)||!T.has(B))continue;I.add(B);const W=p(B);W&&S(W)&&k.push(W)}}return k},NN=(b,S=()=>!0)=>{const A=p(b);if(!A)return[];const k=[A],I=new Set([b]);for(let L=0;L<k.length;L++){const H=k[L].id;for(const j of C){const B=j.flow.source;if(j.flow.target!==H||I.has(B)||!T.has(B))continue;I.add(B);const W=p(B);W&&S(W)&&k.push(W)}}return k},Mi=30,vr=b=>!("waypoints"in b&&b.waypoints)&&b.type!=="bpmn:Lane"&&b.type!=="label"&&typeof b.x=="number",$u=(b,S)=>Np(n,b,S),Us=(b,S,A=!1)=>{const k=new Set(b.flatMap(B=>B.subtree.map(W=>W.id)));for(const B of b){const W=(B.pool.children??[]).filter(vr).filter(ae=>!k.has(ae.id));if(B.subtree.some(ae=>W.some(ee=>ae.x+S<ee.x+ee.width+Mi&&ae.x+S+ae.width+Mi>ee.x&&ae.y<ee.y+ee.height&&ae.y+ae.height>ee.y)))return null}const I=b.map(B=>B.pool.width),L=A?o.filter(B=>Array.isArray(B.waypoints)).map(B=>({c:B,wps:B.waypoints.map(W=>({x:W.x,y:W.y}))})):[],H=o.filter(B=>B.type==="label").map(B=>({label:B,x:B.x,y:B.y}));n.moveElements(b.flatMap(B=>B.subtree),{x:S,y:0});const j=b.map(B=>{const Y=Math.max(...B.subtree.map(ae=>ae.x+ae.width))+Tg-(B.pool.x+B.pool.width);return Y>0&&$u(B.pool,B.pool.width+Y),Y});return()=>{n.moveElements(b.flatMap(B=>B.subtree),{x:-S,y:0}),b.forEach((B,W)=>{j[W]>0&&$u(B.pool,I[W])});for(const{c:B,wps:W}of L){const Y=B.waypoints??[];Y.length===W.length&&Y.every((ee,de)=>Math.abs(ee.x-W[de].x)<=.5&&Math.abs(ee.y-W[de].y)<=.5)||n.updateWaypoints(B,W.map(ee=>({x:ee.x,y:ee.y})))}for(let B=0;B<3;B++){let W=0;for(const Y of H){const ae=Y.x-Y.label.x,ee=Y.y-Y.label.y;Math.abs(ae)<=.5&&Math.abs(ee)<=.5||(n.moveElements([Y.label],{x:ae,y:ee}),W++)}if(!W)break}}},Nh=b=>{var I,L;const S=new Map,A=new Map;for(const H of o.getAll()){if(H.type!=="bpmn:Participant")continue;const j=H;(j.children??[]).length||(S.set(j.id,j),A.set(j.id,[]))}for(const H of o.getAll()){if(H.type!=="bpmn:MessageFlow")continue;const j=H,B=(I=j.source)==null?void 0:I.id,W=(L=j.target)==null?void 0:L.id;B&&W&&A.has(B)&&A.get(B).push(W),B&&W&&A.has(W)&&A.get(W).push(B)}const k=[];for(const[H,j]of A)j.length&&j.every(B=>b.has(B))&&k.push(S.get(H));return k},iE=(b,S)=>{if(!b.length)return null;const A=new Set(b.map(Y=>Y.id)),k=o.getAll().filter(Y=>Y.type==="bpmn:Participant"&&!A.has(Y.id)),I=Math.min(...k.filter(Y=>(Y.children??[]).length>0).map(Y=>Y.x)),L=new Set(b.filter(Y=>Math.abs(Y.x-I)<=2).map(Y=>Y.id));if(b.some(Y=>{const ae=L.has(Y.id)?Y.x:Y.x+S,ee=L.has(Y.id)?Y.width+S:Y.width;return k.some(de=>ae<de.x+de.width+Mi&&ae+ee+Mi>de.x&&Y.y<de.y+de.height&&Y.y+Y.height>de.y)}))return null;const j=o.filter(Y=>Y.type==="label").map(Y=>({label:Y,x:Y.x,y:Y.y})),B=b.filter(Y=>!L.has(Y.id)),W=b.filter(Y=>L.has(Y.id)).map(Y=>({pool:Y,was:{x:Y.x,y:Y.y,width:Y.width,height:Y.height}}));B.length&&n.moveElements(B,{x:S,y:0});for(const{pool:Y,was:ae}of W)n.resizeShape(Y,{...ae,width:ae.width+S});return()=>{for(const{pool:Y,was:ae}of W)n.resizeShape(Y,ae);B.length&&n.moveElements(B,{x:-S,y:0});for(let Y=0;Y<3;Y++){let ae=0;for(const ee of j){const de=ee.x-ee.label.x,pe=ee.y-ee.label.y;Math.abs(de)<=.5&&Math.abs(pe)<=.5||(n.moveElements([ee.label],{x:de,y:pe}),ae++)}if(!ae)break}}},rE=(b,S,A)=>{const k=A.x+A.width/2,I=S.y>A.y,L=I?A.y+A.height:A.y,H=I?S.y:S.y+S.height,j=b.source===S?[{x:k,y:H},{x:k,y:L}]:[{x:k,y:L},{x:k,y:H}],B=Ze(o),W={...B.edges.find(Y=>Y.id===b.id),waypoints:j};return xn(W,ci(B)).length?!1:(n.updateWaypoints(b,j),!0)},$N=()=>{const b=o.filter(I=>I.type==="bpmn:Participant"),S=Math.min(...b.filter(I=>(I.children??[]).length>0).map(I=>I.x)),A=I=>!!I&&I.type==="bpmn:Participant"&&!(I.children??[]).length&&Math.abs(I.x-S)<=2&&!h.some(L=>L.participant.id===I.id),k=new Set;for(const I of o.getAll()){if(I.type!=="bpmn:MessageFlow")continue;const L=I;if((L.waypoints??[]).length!==2)continue;const H=[L.source,L.target].find(B=>A(B)),j=H===L.source?L.target:L.source;H&&j&&j.type!=="bpmn:Participant"&&k.add(L.id)}return k},FN=b=>{var A;const S=new Map;for(const k of b){const I=o.get(k);if(!I||(I.waypoints??[]).length===2)continue;const L=((A=I.source)==null?void 0:A.type)==="bpmn:Participant"?I.source:I.target,H=L===I.source?I.target:I.source;if(H.x+H.width/2<=L.x+L.width)continue;const j=S.get(L.id)??{pool:L,msgs:[]};j.msgs.push({conn:I,other:H}),S.set(L.id,j)}for(const{pool:k,msgs:I}of S.values()){const L=Math.max(...I.map(({other:pe})=>pe.x+pe.width/2))+Lp;if(o.getAll().some(pe=>{if(pe.type!=="bpmn:Participant"||pe.id===k.id)return!1;const me=pe;return k.x<me.x+me.width+Mi&&L+Mi>me.x&&k.y<me.y+me.height&&k.y+k.height>me.y}))continue;const j={x:k.x,y:k.y,width:k.width,height:k.height},B=[...k.incoming??[],...k.outgoing??[]],W=B.map(pe=>({c:pe,wps:(pe.waypoints??[]).map(me=>({x:me.x,y:me.y}))})),Y=B.flatMap(pe=>{const me=pe.label;return me?[{label:me,x:me.x,y:me.y}]:[]}),ae=Qr();n.resizeShape(k,{...j,width:L-k.x});const ee=I.filter(({conn:pe,other:me})=>rE(pe,k,me)).length,de=Qr();if(!(ee>0&&de.messages>ae.messages&&de.lines>=ae.lines)){n.resizeShape(k,j);for(const{c:pe,wps:me}of W){const Ye=pe.waypoints??[];Ye.length===me.length&&Ye.every((Q,ie)=>Math.abs(Q.x-me[ie].x)<=.5&&Math.abs(Q.y-me[ie].y)<=.5)||n.updateWaypoints(pe,me.map(Q=>({x:Q.x,y:Q.y})))}for(let pe=0;pe<3;pe++){let me=0;for(const Ye of Y){const Ce=Ye.x-Ye.label.x,Q=Ye.y-Ye.label.y;Math.abs(Ce)<=.5&&Math.abs(Q)<=.5||(n.moveElements([Ye.label],{x:Ce,y:Q}),me++)}if(!me)break}}}},oE=()=>{let b=0;for(const S of o.getAll()){if(S.type!=="bpmn:DataInputAssociation"&&S.type!=="bpmn:DataOutputAssociation")continue;const A=S.waypoints??[];for(let k=1;k<A.length;k++)b+=Math.hypot(A[k].x-A[k-1].x,A[k].y-A[k-1].y)}return b},aE=()=>{let b=0;for(const S of o.getAll()){if(S.type!=="bpmn:Association")continue;const A=S.waypoints??[];for(let k=1;k<A.length;k++)b+=Math.hypot(A[k].x-A[k-1].x,A[k].y-A[k-1].y)}return b},jN=b=>{const S=[];for(const A of o.getAll()){if(A.type!=="bpmn:TextAnnotation")continue;const k=A;if(b.has(k.id))continue;const L=[...k.incoming??[],...k.outgoing??[]].filter(B=>B.type==="bpmn:Association").map(B=>B.source===k?B.target:B.source);if(!L.length||L.some(B=>B===void 0))continue;const H=B=>{if(!("waypoints"in B&&B.waypoints))return[B.id];const W=B,Y=[W.source,W.target];return Y.some(ae=>!ae)?[]:Y.map(ae=>ae.id)},j=L.flatMap(B=>H(B));j.length&&j.every(B=>b.has(B))&&S.push(k)}return S},sE=()=>dt(Ze(o)).filter(b=>b.kind==="edge-crosses-shape").length,cE=b=>{const S=(b.children??[]).filter(vr);let A=0;for(let k=0;k<S.length;k++)for(let I=k+1;I<S.length;I++){const L=S[k],H=S[I];L.x<H.x+H.width&&L.x+L.width>H.x&&L.y<H.y+H.height&&L.y+L.height>H.y&&A++}return A},Qr=()=>{const b=Ze(o),S=A=>A.length>=2&&(A.every(k=>Math.abs(k.x-A[0].x)<.01)||A.every(k=>Math.abs(k.y-A[0].y)<.01));return{messages:b.edges.filter(A=>A.type==="bpmn:MessageFlow"&&A.waypoints.length===2).length,lines:b.edges.filter(A=>S(A.waypoints)).length}},lE=b=>{const S=new Map;for(const k of o.getAll()){if(k.type!=="bpmn:MessageFlow")continue;const I=k;if(!I.waypoints||I.waypoints.length!==2)continue;const L=I.source,H=I.target;if(!L||!H)continue;const j=b.has(L.id);if(j===b.has(H.id))continue;const B=j?H:L,W=d(B);if(!W||b.has(B.id))continue;const Y=S.get(W.id);Y?B.x<Y.minX&&(Y.minX=B.x):S.set(W.id,{pool:W,minX:B.x})}const A=[];for(const{pool:k,minX:I}of S.values()){const L=(k.children??[]).filter(H=>vr(H)&&!b.has(H.id)&&H.x>=I);L.length&&A.push({subtree:L,pool:k})}return A},HN=(b,S,A)=>{const k=new Map(S.map(H=>[H.pool.id,{subtree:[...H.subtree],pool:H.pool}])),I=new Set(b);for(const H of S)for(const j of H.subtree)I.add(j.id);let L=!1;for(;;){let H=0;for(const j of lE(I)){if(j.pool===A)continue;const B=k.get(j.pool.id);B?B.subtree.push(...j.subtree):k.set(j.pool.id,{subtree:[...j.subtree],pool:j.pool});for(const W of j.subtree)I.add(W.id);H+=j.subtree.length}if(!H)break;L=!0}return L?[...k.values()]:null},uE=new Map;for(const b of Kt(e,"sequenceFlow.update")){if(b.target===void 0)continue;const S=T.get(b.target);if(!S)continue;const A=p(b.target),k=p(b.id);if(!A||!k)continue;const I=b.source!==void 0?p(b.source):k.source,L=k.target;if(!I||!L||L.id===A.id)continue;const H=k.waypoints&&k.waypoints.length>=3&&Math.abs(k.waypoints[0].x-k.waypoints[1].x)<1&&Math.abs(k.waypoints[0].y-k.waypoints[1].y)>1?{x:k.waypoints[0].x,y:k.waypoints[0].y}:void 0,j=H?k.waypoints[1].y:void 0,B=H&&k.label?{x:k.label.x,y:k.label.y}:void 0,W=B&&k.label&&Math.abs(B.y+k.label.height/2-j)<=D/5&&B.x+k.label.width>H.x?B.x+k.label.width+6:void 0,Y=(I.outgoing??[]).filter(Pe=>Pe.type==="bpmn:SequenceFlow"&&Pe.id!==k.id&&Pe.target&&!Nu.has(Pe.id)),ae=new Set(Y.map(Pe=>Pe.target.id)),ee=Pe=>{const ke={type:"bpmn:Task",x:Pe.x+2,y:Pe.y+2,width:Pe.width-4,height:Pe.height-4};return Y.find(Xe=>(Xe.waypoints??[]).some((bn,_t)=>!!Xe.waypoints[_t+1]&&yc(bn,Xe.waypoints[_t+1],ke)===0))},de=Po(b.target),pe=new Set(de.map(Pe=>Pe.id)),me=wn.has(b.target)?{autoResize:!1}:void 0,Ye=Math.min(...de.map(Pe=>Pe.x)),Ce=Math.max(...de.map(Pe=>Pe.x+Pe.width)),Q=I.x+I.width,ie=A.y+A.height/2,se=BN(de,Q+Tn-Ye,[0,I.y+I.height/2-ie,L.y+L.height/2-ie],L.x,Q,I.y+I.height/2),ve=Q+Tn+se,et=(()=>{if(W===void 0)return 0;const Pe=Q+Tn,ke=I.y+I.height/2-A.height/2,Xe={x:Pe,y:ke,width:Ce-Ye,height:A.height},bn=d(I);return((bn==null?void 0:bn.children)??[]).some(mt=>vr(mt)&&!pe.has(mt.id)&&mt.id!==I.id&&mt.id!==L.id&&mt.type!=="bpmn:Group"&&mt.type!=="bpmn:Participant"&&mt.x<Xe.x+Xe.width&&mt.x+mt.width>Xe.x&&mt.y<Xe.y+Xe.height&&mt.y+mt.height>Xe.y)||ee(Xe)?Math.max(0,W-Pe):0})(),Ve=Ce-Ye+Tn*2+se+et-(L.x-Q);let gt=[];if(Ve>0){const Pe=d(A),ke=(Pe==null?void 0:Pe.children)??[],Xe=Ne=>Ne.type==="bpmn:Lane";gt=(()=>{const Ne=new Set;for(const $e of ke)vr($e)&&!pe.has($e.id)&&$e.id!==I.id&&$e.x>=L.x&&Ne.add($e.id);const At=[];for(const $e of ke){if($e.type!=="bpmn:DataStoreReference"&&$e.type!=="bpmn:DataObjectReference")continue;const vt=$e,Un=[...vt.incoming??[],...vt.outgoing??[]].filter(Qt=>Qt.type==="bpmn:DataInputAssociation"||Qt.type==="bpmn:DataOutputAssociation").map(Qt=>Qt.source===vt?Qt.target:Qt.source);Un.length&&Un.every(Qt=>Qt!==void 0&&Ne.has(Qt.id))&&At.push(vt)}return At})();const _t=ke.filter(Ne=>!("waypoints"in Ne&&Ne.waypoints)&&!Xe(Ne)&&Ne.type!=="label"&&!pe.has(Ne.id)&&Ne.id!==I.id&&Ne.x>=L.x),mt=_t.flatMap(Ne=>Ne.labels??[]),It=Pe?[Pe,...ke.filter(Ne=>Xe(Ne))]:[];if(_t.length){const Ne=new Set(_t.map(bt=>bt.id)),At=lE(Ne),$e=At.length?HN(Ne,At,Pe):null,vt=bt=>{const kt=new Set(Ne);for(const jt of bt)for(const Ii of jt.subtree)kt.add(Ii.id);return jN(kt)},zn=vt(At),Un=$e?vt($e):zn,Qt=Nh(Ne),Gu=new Set(Ne);for(const bt of At)for(const kt of bt.subtree)Gu.add(kt.id);const Vu=At.length?Nh(Gu):Qt,Wu=(()=>{if(!$e)return[];const bt=new Set(Ne);for(const kt of $e)for(const jt of kt.subtree)bt.add(jt.id);return Nh(bt)})(),Ks=new Set([..._t,...It].map(bt=>bt.id)),Wh=ke.filter(bt=>{const kt=bt.labelTarget;return bt.type==="label"&&!!kt&&"waypoints"in kt&&!!kt.source&&!!kt.target&&Ks.has(kt.source.id)&&Ks.has(kt.target.id)}),Uh=$N();n.createSpace([..._t,...mt,...Wh],It,{x:Ve,y:0},"e",L.x-1);const Li=(bt,kt)=>{const jt=Qr(),Ii=Us(bt,Ve);if(!Ii)return!1;const Bt=kt.length?iE(kt,Ve):null,Ai=Qr();return Ai.messages>jt.messages&&Ai.lines>=jt.lines?!0:(Bt==null||Bt(),Ii(),!1)},ft=$e?Li($e,Wu):!1;let sn=ft;!sn&&At.length&&(sn=Li(At,Vu));const Ft=ft?Un:zn;if(!sn){for(const bt of At){const kt=Qr(),jt=Us([bt],Ve);if(!jt)continue;const Ii=Qr();(Ii.messages<=kt.messages||Ii.lines<kt.lines)&&jt()}if(Qt.length){const bt=Qr(),kt=iE(Qt,Ve);if(kt){const jt=Qr();(jt.messages<=bt.messages||jt.lines<bt.lines)&&kt()}}}if(FN(Uh),Ft.length){const bt=()=>new Set(dt(Ze(o)).map(jt=>lt(jt))),kt=jt=>{const Ii=aE(),Bt=bt(),Ai=jt.map(Jt=>({a:Jt,x:Jt.x,y:Jt.y})),Do=o.filter(Jt=>Jt.type==="label").map(Jt=>({label:Jt,x:Jt.x,y:Jt.y}));n.moveElements(jt,{x:Ve,y:0});const u$=[...bt()].filter(Jt=>!Bt.has(Jt));if(aE()<Ii&&u$.length===0)return!0;for(const{a:Jt,x:Xs,y:Zs}of Ai)(Jt.x!==Xs||Jt.y!==Zs)&&n.moveElements([Jt],{x:Xs-Jt.x,y:Zs-Jt.y});for(const Jt of Do){const Xs=Jt.x-Jt.label.x,Zs=Jt.y-Jt.label.y;(Xs!==0||Zs!==0)&&n.moveElements([Jt.label],{x:Xs,y:Zs})}return!1};if(!kt(Ft)&&Ft.length>1)for(const jt of Ft)kt([jt])}}}const Tt=S.node.lane!==void 0?p(S.node.lane):S.node.participant!==void 0?p(S.node.participant):void 0,xe=Pe=>{if(!Tt)return!0;const ke=Pe.y+Pe.height/2;return ke>=Tt.y&&ke<=Tt.y+Tt.height},be=!xe(I)&&xe(L)?L:I,re=be.y+be.height/2,ye=re-(A.y+A.height/2),Ie=S.band!==void 0,Be=Ie?[A]:de,we=(S.band===void 0||w(S.node.lane,S.node.participant,S.band,re))&&xt(b.target)&&Be.every(Pe=>{var ke;return Ct((ke=T.get(Pe.id))==null?void 0:ke.node.lane,Pe,Pe.y+Pe.height/2+ye)}),ot=Pe=>Math.abs(Pe.y+Pe.height/2-(A.y+A.height/2))<=D/2;if(we&&Ie){const Pe=Math.abs(ye)<=D/2?de.filter(ke=>ke.id!==A.id&&ot(ke)):[];if(n.moveElements(de,{x:ve-Ye,y:0},void 0,me),n.moveElements([A],{x:0,y:ye},void 0,me),Pe.length){const ke=()=>new Set(dt(Ze(o)).map(Ne=>lt(Ne))),Xe=ke(),bn=o.filter(Ne=>Ne.type==="label").map(Ne=>({label:Ne,x:Ne.x,y:Ne.y}));n.moveElements(Pe,{x:0,y:ye});const _t=ke(),mt=[..._t].filter(Ne=>!Xe.has(Ne)).length,It=[...Xe].filter(Ne=>!_t.has(Ne)).length;if(mt>It){n.moveElements(Pe,{x:0,y:-ye});for(const Ne of bn){const At=Ne.x-Ne.label.x,$e=Ne.y-Ne.label.y;(At!==0||$e!==0)&&n.moveElements([Ne.label],{x:At,y:$e})}}}}else n.moveElements(de,{x:ve-Ye,y:we?ye:0},void 0,me);const Ke=d(A);if(!we&&S.node.lane===void 0&&S.band!==void 0&&Ke){const Pe=Ke.y+J+R(`pool:${S.node.participant??""}`,S.band)*D,ke=Pe-(A.y+A.height/2);ke!==0&&!rt(Ke,A,A.x+A.width/2,Pe,pe)&&n.moveElements([A],{x:0,y:ke},void 0,me)}if(Ke){const Pe=(Ke.children??[]).filter(_t=>vr(_t)&&!pe.has(_t.id)&&_t.type!=="bpmn:Group"&&_t.type!=="bpmn:Participant"),ke=(_t,mt,It,Ne,At)=>_t.x+mt<At.x+At.width+Ne&&_t.x+mt+_t.width+Ne>At.x&&_t.y+It<At.y+At.height+Ne&&_t.y+It+_t.height+Ne>At.y,Xe=Pe.find(_t=>ke(A,0,0,0,_t)),bn=Xe?void 0:ee(A);if(Xe||bn){const _t=["bpmn:SequenceFlow","bpmn:MessageFlow","bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation"],mt=o.getAll().filter(ft=>{if(!_t.includes(ft.type))return!1;const sn=ft;return Nu.has(sn.id)||!sn.waypoints||sn.waypoints.length<2?!1:![sn.source,sn.target].some(Ft=>!Ft||pe.has(Ft.id))}),It=(ft,sn,Ft)=>{var bt;return Ct((bt=T.get(ft.id))==null?void 0:bt.node.lane,ft,ft.y+Ft+ft.height/2)&&ft.x+sn>=Ke.x&&ft.x+sn+ft.width<=Ke.x+Ke.width&&ft.y+Ft>=Ke.y&&ft.y+Ft+ft.height<=Ke.y+Ke.height},Ne=(ft,sn)=>de.every(Ft=>It(Ft,ft,sn)&&!Pe.some(bt=>ke(Ft,ft,sn,Ao,bt))&&mt.every(bt=>{const kt={id:Ft.id,type:Ft.type,x:Ft.x+ft,y:Ft.y+sn,width:Ft.width,height:Ft.height};for(let jt=0;jt+1<bt.waypoints.length;jt++)if(yc(bt.waypoints[jt],bt.waypoints[jt+1],kt)<Ao)return!1;return!0})),At=A.y+A.height/2,$e=[j,L.y+L.height/2].filter(ft=>ft!==void 0&&Math.abs(ft-At)>=1),vt=Xe&&ae.has(Xe.id)?Xe:bn==null?void 0:bn.target,zn=vt?vt.x-A.x:0,Un=Math.max(...de.map(ft=>ft.x+ft.width)),Qt=[...zn!==0?[zn]:[],...se!==0?[-se]:[],0],Gu=W===void 0?[]:Qt.map(ft=>Math.max(ft,W-A.x)),Vu=ft=>Un+ft+Tn<=L.x,Wu=[...new Set([...Gu,...Qt])].filter(Vu),Ks=Xe&&ae.has(Xe.id)?[Xe.x+Xe.width+Tn-A.x]:[],Wh=W===void 0?[]:Ks.map(ft=>Math.max(ft,W-A.x)),Uh=[...new Set([...Wh,...Ks])].filter(ft=>Vu(ft)&&!Wu.includes(ft));let Li;for(const ft of[Wu,Uh]){for(const sn of $e){for(const Ft of ft)if(Ne(Ft,sn-At)){Li={dx:Ft,dy:sn-At};break}if(Li)break}if(Li)break}if(Li){const ft=Bt=>{const Ai=Bt;return[Ai.edge,Ai.other,...Array.isArray(Ai.edges)?Ai.edges:[]].some(Do=>typeof Do=="string"&&Nu.has(Do))},sn=()=>new Set(dt(Ze(o)).filter(Bt=>!ft(Bt)).map(Bt=>lt(Bt))),Ft=sn(),bt=o.filter(Bt=>Bt.type==="label").map(Bt=>({label:Bt,x:Bt.x,y:Bt.y}));n.moveElements(de,{x:Li.dx,y:Li.dy},void 0,me);const kt=sn(),jt=[...kt].filter(Bt=>!Ft.has(Bt)).length,Ii=[...Ft].filter(Bt=>!kt.has(Bt)).length;if(jt>Ii){n.moveElements(de,{x:-Li.dx,y:-Li.dy},void 0,me);for(const Bt of bt){const Ai=Bt.x-Bt.label.x,Do=Bt.y-Bt.label.y;(Ai!==0||Do!==0)&&n.moveElements([Bt.label],{x:Ai,y:Do})}}else H&&uE.set(k.id,{exit:H,channelY:j,label:B})}}}{const Pe=new Set(de.map(mt=>mt.id)),ke=new Set(C.map(mt=>mt.flow.id)),Xe=20,bn=mt=>{const It=mt.source,Ne=mt.target,At=Math.min(It.x,Ne.x)-Xe,$e=Math.max(It.x+It.width,Ne.x+Ne.width)+Xe,vt=Math.min(It.y,Ne.y)-Xe,zn=Math.max(It.y+It.height,Ne.y+Ne.height)+Xe;return mt.waypoints.some(Un=>Un.x<At||Un.x>$e||Un.y<vt||Un.y>zn)},_t=new Map;for(const mt of de)for(const It of[...mt.incoming??[],...mt.outgoing??[]])It.id!==b.id&&ke.has(It.id)&&!(Pe.has(It.source.id)&&Pe.has(It.target.id))&&_t.set(It.id,It);for(const mt of _t.values())bn(mt)&&pt(mt)}const Mt=gt.length?d(gt[0]):void 0;if(Mt){const Pe={assoc:oE(),overlaps:cE(Mt),crosses:sE()},ke=gt.map($e=>({st:$e,x:$e.x})),Xe=o.filter($e=>$e.type==="label").map($e=>({label:$e,x:$e.x,y:$e.y})),bn=Math.min(...gt.flatMap($e=>[...$e.incoming??[],...$e.outgoing??[]].filter(vt=>vt.type==="bpmn:DataInputAssociation"||vt.type==="bpmn:DataOutputAssociation").map(vt=>(vt.source===$e?vt.target:vt.source).x))),_t=new Set(gt.map($e=>$e.id)),mt=(Mt.children??[]).filter(vr).filter($e=>!_t.has($e.id));let It=bn;for(const $e of[...gt].sort((vt,zn)=>vt.x-zn.x)){let vt=It;for(let zn=0;zn<100;zn++){const Un=mt.find(Qt=>vt<Qt.x+Qt.width+Mi&&vt+$e.width+Mi>Qt.x&&$e.y<Qt.y+Qt.height&&$e.y+$e.height>Qt.y);if(!Un)break;vt=Un.x+Un.width+Mi}vt!==$e.x&&n.moveElements([$e],{x:vt-$e.x,y:0}),It=vt+$e.width+Mi}const Ne=It+150-(Mt.x+Mt.width);Ne>0&&$u(Mt,Mt.width+Ne);const At={assoc:oE(),overlaps:cE(Mt),crosses:sE()};if(At.assoc>=Pe.assoc||At.overlaps>Pe.overlaps||At.crosses>Pe.crosses){for(const{st:$e,x:vt}of ke)$e.x!==vt&&n.moveElements([$e],{x:vt-$e.x,y:0});Ne>0&&$u(Mt,Mt.width-Ne);for(const $e of Xe){const vt=$e.x-$e.label.x,zn=$e.y-$e.label.y;(vt!==0||zn!==0)&&n.moveElements([$e.label],{x:vt,y:zn})}}}}for(const[b,S]of wn){const A=p(b);if(!A)continue;const k=S.container,I=Math.abs(A.y+A.height/2-k.y-S.relCy)>=.5,L=A.label,H=Math.min(A.y,L&&!L.hidden?L.y:A.y),j=Math.max(A.y+A.height,L&&!L.hidden?L.y+L.height:0);if(I&&H>=k.y&&j<=k.y+k.height)continue;const B=A.y;S.grow(),A.y!==B&&n.moveElements([A],{x:0,y:B-A.y},void 0,{autoResize:!1})}const pE=(b,S)=>{const A=S.target===b,k=f(S.source),I=f(S.target),L=A?"bpmn:DataOutputAssociation":"bpmn:DataInputAssociation";n.connect(k,I,S.id?{type:L,businessObject:i.create(L,{id:S.id})}:{type:L})},fE=b=>{for(const S of h){if(!S.participant.blackBox)continue;const A=p(S.participant.id);if(!A)continue;const k=[];for(const L of x){const H=L.flow.source===S.participant.id?L.flow.target:L.flow.target===S.participant.id?L.flow.source:void 0,j=H?p(H):void 0;j&&typeof j.x=="number"&&j.type!=="bpmn:Participant"&&k.push(j)}if(!k.length)continue;if(!b&&S.order===void 0){const L=(()=>{var j;const H=new Map;for(const B of k){const W=d(B);if(!W)continue;const Y=H.get(W.id);Y?Y.n+=1:H.set(W.id,{shape:W,n:1})}return(j=[...H.values()].sort((B,W)=>W.n-B.n)[0])==null?void 0:j.shape})();if(L){const H=W=>W.reduce((Y,ae)=>Y+ae,0)/W.length,j=H(k.map(W=>W.y+W.height/2))<L.y+L.height/2,B=o.filter(W=>W.type==="bpmn:Participant"&&W.id!==S.participant.id&&W.id!==L.id).filter(W=>j?W.y+W.height<=L.y+5:W.y>=L.y+L.height-5);if(B.length){const W=[...B.reduce((se,ve)=>se.set(ve.y,(se.get(ve.y)??0)+1),new Map)].sort((se,ve)=>ve[1]-se[1]||(j?ve[0]-se[0]:se[0]-ve[0]))[0][0],Y=Math.min(A.width,UR),ae=qR,ee=k.map(se=>se.x+se.width/2),de=Math.round(H(ee)-Y/2),pe=Math.max(...ee)+Lp,me=se=>({x:se,width:Math.max(Y,pe-se)}),Ye=B.filter(se=>Math.min(se.y+se.height,W+ae)-Math.max(se.y,W)>0),Ce=se=>{const ve=me(se);return Ye.some(et=>et.x<ve.x+ve.width&&ve.x<et.x+et.width)},Q=se=>{const ve=me(se);return ee.filter(et=>et>=ve.x+10&&et<=ve.x+ve.width-10).length},ie=(()=>{if(!Ce(de))return de;const se=Q(de);return Ye.flatMap(ve=>[ve.x+ve.width+Cg,ve.x-Cg-Y]).map(ve=>Math.round(ve)).filter(ve=>!Ce(ve)&&Q(ve)>=se).sort((ve,et)=>Math.abs(ve-de)-Math.abs(et-de))[0]??de})();if(ie!==A.x||W!==A.y||Y!==A.width||ae!==A.height){const se=()=>new Set(dt(Ze(o)).map(xe=>lt(xe))),ve=se(),et={x:A.x,y:A.y,width:A.width,height:A.height};n.resizeShape(A,{x:ie,y:W,width:Y,height:ae});const Ve=se(),gt=[...Ve].filter(xe=>!ve.has(xe)).length,Tt=[...ve].filter(xe=>!Ve.has(xe)).length;gt>Tt&&n.resizeShape(A,et)}}}}const I=Math.max(...k.map(L=>L.x+L.width/2))+Lp;if(I>A.x+A.width&&n.resizeShape(A,{x:A.x,y:A.y,width:I-A.x,height:A.height}),!!b)for(const L of x){const H=p(L.flow.id),j=L.flow.source===S.participant.id?L.flow.target:L.flow.target===S.participant.id?L.flow.source:void 0,B=j?p(j):void 0;if(!H||!B||B.type==="bpmn:Participant")continue;const W=B.x+B.width/2;W<A.x+10||W>A.x+A.width-10||rE(H,A,B)}}};fE(!1);for(const b of x){const S=b.flow;n.connect(f(S.source),f(S.target),{type:"bpmn:MessageFlow",businessObject:i.create("bpmn:MessageFlow",{id:S.id,name:S.name})})}{const A=new Set([...C.map(B=>B.flow.id),...x.map(B=>B.flow.id)].filter(B=>!!B)),k=o.filter(B=>!!B.waypoints),I=(B,W)=>Math.abs(W.x-B.x)<2?"L":Math.abs(W.x-(B.x+B.width))<2?"R":Math.abs(W.y-B.y)<2?"T":Math.abs(W.y-(B.y+B.height))<2?"B":void 0,L=new Map,H=(B,W,Y)=>{if(!B||!W||typeof B.x!="number")return;const ae=I(B,W);if(!ae)return;let ee=L.get(B.id);ee||L.set(B.id,ee=new Map),ee.set(ae,[...ee.get(ae)??[],Y])};for(const B of k){const W=B.waypoints;!W||W.length<2||(H(B.source,W[0],{id:B.id,dir:"out"}),H(B.target,W[W.length-1],{id:B.id,dir:"in"}))}const j=new Set;for(const[B,W]of L){const Y=p(B);if(!Y||typeof Y.x!="number"||![...W.values()].some(Ce=>{const Q=Ce.filter(ie=>ie.dir==="in");return Ce.length>=3&&Q.length>=1&&Ce.some(ie=>ie.dir==="out")&&Q.some(ie=>A.has(ie.id))}))continue;const ee=d(Y);if(!ee||j.has(ee.id)||(ee.children??[]).some(Ce=>Ce.type==="bpmn:Lane"))continue;const de=(TE=W.get("T"))!=null&&TE.length?(kE=W.get("B"))!=null&&kE.length?void 0:"B":"T";if(!de||(de==="T"?Y.y-ee.y:ee.y+ee.height-(Y.y+Y.height))>=D)continue;const me=(ee.children??[]).filter(Ce=>!("waypoints"in Ce&&Ce.waypoints)&&Ce.type!=="label"&&typeof Ce.x=="number"),Ye=ee.y+ee.height;n.resizeShape(ee,{x:ee.x,y:ee.y,width:ee.width,height:ee.height+D}),te(Ye,ee.id,D),de==="T"&&me.length&&n.moveElements(me,{x:0,y:D}),j.add(ee.id)}}const $h=20,dE=4,zN=3,GN=2,VN=[10,30,80],Jr=()=>{const b=Ze(o);return{bad:dt(b).filter(S=>S.kind==="edge-crosses-shape"||S.kind==="edge-overlap-opposite"||S.kind==="edge-overlap-mixed").length,crossings:Nm(b),straight:b.edges.filter(S=>S.type==="bpmn:MessageFlow"&&S.waypoints.length===2).length}},Da=b=>{const S=Ze(o),A=S.edges.find(k=>k.id===b);return A?xn(A,ci(S)).length:0},Fu=b=>Da(b)>0,ju=b=>Ze(o).edges.filter(S=>S.type==="bpmn:MessageFlow"&&S.id!==b&&S.waypoints.length===2).length,WN=(b,S,A)=>Us([{subtree:b,pool:S}],A),hE=(b,S)=>S.bad>b.bad||S.crossings>b.crossings&&S.straight<=b.straight&&S.bad>=b.bad,La=(b,S)=>hE(b,S)||S.straight<b.straight,To=(b,S,A=()=>!0,k=hE,I=!1)=>{const L=Jr(),H=Us(b,S,I);if(!H)return!1;const j=Jr();return k(L,j)||!A()?(H(),!1):!0},UN=(b,S,A,k=()=>!0)=>To([{subtree:b,pool:S}],A,k),ko=b=>{var S;return!!((S=T.get(b))!=null&&S.node.participant)},qs=new Map;for(const b of x){if(!ko(b.flow.target))continue;const S=qs.get(b.flow.target)??[];S.push(b),qs.set(b.flow.target,S)}const Hu=[...qs.keys()],Fh=new Set(C.map(b=>b.flow.target)),mE=b=>Yt.findIndex(({op:S})=>S.participant.id===b);Hu.sort((b,S)=>{var I,L;const A=Fh.has(b)?1:0,k=Fh.has(S)?1:0;return A!==k?A-k:mE((I=T.get(b))==null?void 0:I.node.participant)-mE((L=T.get(S))==null?void 0:L.node.participant)});const eo=b=>b.x+b.width/2,qN=b=>{const S=new Map;for(const I of o.getAll()){const L=I;if(!L.waypoints||!L.source||!L.target)continue;(S.get(L.source.id)??S.set(L.source.id,[]).get(L.source.id)).push(L.target.id)}const A=new Set([b]),k=[b];for(let I=0;I<k.length;I++)for(const L of S.get(k[I])??[])A.has(L)||(A.add(L),k.push(L));return A},YN=(b,S)=>{const A=qN(S);let k;for(const I of o.getAll()){const L=I;if(L.type!=="bpmn:MessageFlow"||!L.source||!L.target||L.target.id!==b||A.has(L.source.id))continue;const H=L.source;if(typeof H.x!="number"||H.type==="bpmn:Participant")continue;const j=eo(H);(k===void 0||j>k)&&(k=j)}return k},jh=(b,S)=>{const A=p(b.flow.source);if(A)return A.type==="bpmn:Participant"?YN(A.id,S):eo(A)},gE=b=>{let S;for(const A of qs.get(b)??[]){const k=jh(A,b);k!==void 0&&(!S||k>S.cx)&&(S={op:A,cx:k})}return S==null?void 0:S.op},KN=b=>{const S=gE(b),A=p(b),k=S?jh(S,b):void 0;return A&&k!==void 0?k-eo(A):void 0},XN=b=>{const S=KN(b);return S!==void 0&&Math.abs(S)<$h},Hh=(b,S,A,k,I)=>{var L;for(let H=!0;H;){H=!1;for(const j of x){if(j.flow.id===A)continue;const B=S.has(j.flow.source),W=S.has(j.flow.target);if(B===W||k(B?j.flow.source:j.flow.target))continue;const Y=B?j.flow.target:j.flow.source;if(I(Y)||!ko(Y))continue;const ae=p(j.flow.id);if(!(ae!=null&&ae.waypoints)||ae.waypoints.length!==2)continue;const ee=p(Y),de=(L=T.get(Y))==null?void 0:L.node.participant;if(!ee||!de)continue;const pe=Po(Y,me=>me.x>=ee.x).filter(me=>!S.has(me.id));if(!(!pe.length||pe.some(me=>I(me.id)))){for(const me of pe)S.add(me.id);b.set(de,[...b.get(de)??[],...pe]),H=!0}}}return[...b].map(([H,j])=>({subtree:j,pool:f(H)}))},yE=(b,S,A,k,I)=>Hh(new Map([[S,[...b]]]),new Set(b.map(L=>L.id)),k,L=>L===A,L=>L===I),zh=b=>{const S=gE(b);if(!S)return null;const A=p(b),k=p(S.flow.source),I=jh(S,b);if(!A||!k||I===void 0)return null;const L=I-eo(A);if(L>=$h){const H=T.get(b).node.participant,j=Po(b,B=>B.x>=A.x);return{groups:yE(j,H,b,S.flow.id,S.flow.source),dx:L}}if(-L>=$h&&ko(S.flow.source)){const H=T.get(S.flow.source).node.participant,j=Po(S.flow.source,B=>B.x>=k.x&&!XN(B.id));return{groups:yE(j,H,S.flow.source,S.flow.id,b),dx:-L}}return null},vE=()=>Hu.map(b=>({id:b,plan:zh(b)})).filter(b=>!!b.plan).sort((b,S)=>Math.min(...b.plan.groups.flatMap(A=>A.subtree.map(k=>k.x)))-Math.min(...S.plan.groups.flatMap(A=>A.subtree.map(k=>k.x)))).map(b=>b.id);for(let b=0;b<3;b++){const S=Jr(),A=[];for(const I of vE()){const L=zh(I);if(!L)continue;const H=Us(L.groups,L.dx);H&&A.push(H)}if(!A.length)break;if(!La(S,Jr()))continue;for(const I of A.reverse())I();let k=!1;for(const I of vE()){const L=zh(I);L&&To(L.groups,L.dx,()=>!0,La)&&(k=!0)}if(!k)break}for(const b of Hu){if(Fh.has(b))continue;const S=T.get(b);if(!S||S.node.lane!==void 0)continue;const A=K(S);if(A===void 0)continue;const k=p(b),I=k?d(k):void 0;if(!k||!I)continue;const L=I.y+J+R(`pool:${S.node.participant??""}`,A)*D,H=L-(k.y+k.height/2);H!==0&&!rt(I,k,k.x+k.width/2,L)&&n.moveElements([k],{x:0,y:H})}const bE=new Set;for(let b=0,S=!0;S&&b<zN;b++){S=!1;for(const A of Hu.flatMap(k=>qs.get(k)??[])){if(bE.has(A.flow.id)||!Fu(A.flow.id))continue;const k=p(A.flow.target);if(!k)continue;const I=f(T.get(A.flow.target).node.participant),L=Po(A.flow.target,W=>W.x>=k.x),H=k.width+F,j=Da(A.flow.id),B=ju(A.flow.id);for(let W=1;W<=dE;W++){const Y=()=>Da(A.flow.id)<j&&ju(A.flow.id)>=B;if(UN(L,I,H*W,Y)){bE.add(A.flow.id),S=!0;break}}}}const Gh=x.map(b=>({id:b.flow.id,source:b.flow.source,target:b.flow.target,preexisting:!1})),xE=new Set(Gh.map(b=>b.id));for(const b of o.filter(S=>S.type==="bpmn:MessageFlow"))xE.has(b.id)||!b.source||!b.target||b.source.type==="bpmn:Participant"!=(b.target.type==="bpmn:Participant")&&Gh.push({id:b.id,source:b.source.id,target:b.target.id,preexisting:!0});for(const b of Gh){if(!Fu(b.id))continue;const S=p(b.source),A=p(b.target);if(!S||!A)continue;let k,I,L;if(b.preexisting){const[j,B]=S.type==="bpmn:Participant"?[A,S]:[S,A];if(k=eo(j),k<B.x||k>B.x+B.width)continue;[I,L]=j.y<B.y?[j.y+j.height,B.y]:[B.y+B.height,j.y]}else{if(S.type==="bpmn:Participant"||A.type==="bpmn:Participant"||(k=S.x+S.width/2,Math.abs(k-(A.x+A.width/2))>15))continue;[I,L]=S.y<A.y?[S.y+S.height,A.y]:[A.y+A.height,S.y]}const H=[...T.values()].map(j=>p(j.node.id)).filter(j=>!!j&&j.id!==S.id&&j.id!==A.id).filter(j=>j.x<=k&&k<=j.x+j.width&&j.y+j.height>I&&j.y<L).sort((j,B)=>j.x-B.x);for(const j of H){const B=(OE=T.get(j.id))==null?void 0:OE.node.participant,W=B?p(B):void 0;if(!B||!W)continue;const Y=[...T.values()].filter(ie=>ie.node.participant===B).map(ie=>ie.node.id),ae=ie=>ie.map(se=>p(se)).filter(se=>!!se),de=[NN(j.id,ie=>{var se;return((se=T.get(ie.id))==null?void 0:se.node.participant)===B}),ae(Y)].filter(ie=>ie.length).map(ie=>[{subtree:ie,pool:W}]);if(b.preexisting){const ie=ae(Y);ie.length&&de.push(Hh(new Map([[B,[...ie]]]),new Set(ie.map(se=>se.id)),b.id,()=>!1,se=>se===S.id||se===A.id))}const pe=j.width+F,me=Da(b.id),Ye=ju(b.id),Ce=()=>Da(b.id)<me&&ju(b.id)>=Ye;let Q=!1;for(const ie of de){for(let se=1;se<=dE;se++)if(To(ie,pe*se,Ce)){Q=!0;break}if(Q)break}if(!Fu(b.id))break}}const zu=()=>{var S;const b=new Set;for(const A of dt(Ze(o)))A.kind!=="edge-crosses-shape"||xE.has(A.edge)||((S=p(A.edge))==null?void 0:S.type)==="bpmn:MessageFlow"&&b.add(`${A.edge}>${A.shape}`);return b},ZN=(b,S)=>Jr().bad>=b&&[...zu()].some(A=>!S.has(A)),_E=b=>{var S,A;return Da(b)===0&&((A=(S=p(b))==null?void 0:S.waypoints)==null?void 0:A.length)===2},QN=(b,S,A)=>{const k=new Set(b.flatMap(L=>L.subtree.map(H=>H.id))),I=[...zu()].filter(L=>!A.has(L)).map(L=>L.split(">")[1]);return[...new Set(I)].filter(L=>k.has(L)&&L!==S.source&&L!==S.target)},JN=(b,S,A,k,I)=>{const L=b.map(W=>({...W,subtree:W.subtree.filter(Y=>!I.includes(Y.id))})).filter(W=>W.subtree.length),H=new Set(L.flatMap(W=>W.subtree.map(Y=>Y.id))),j=()=>I.every(W=>{const Y=p(W);return!!Y&&C.filter(ae=>ae.flow.target===W&&H.has(ae.flow.source)).every(ae=>{const ee=p(ae.flow.source);return!!ee&&ee.x+ee.width<=Y.x})});return To(L,S,()=>_E(A.id)&&[...zu()].every(W=>k.has(W))&&j(),La,!0)};for(const b of x){if(!Fu(b.flow.id))continue;const S=p(b.flow.id);if(((DE=S==null?void 0:S.waypoints)==null?void 0:DE.length)!==2)continue;const A=p(b.flow.source),k=p(b.flow.target);if(!A||!k||A.type==="bpmn:Participant"||k.type==="bpmn:Participant"||!ko(b.flow.source)||!ko(b.flow.target)||Math.abs(eo(A)-eo(k))>GN)continue;const I=eo(A),L=S.waypoints.map(me=>me.y),[H,j]=[Math.min(...L),Math.max(...L)],B=ci(Ze(o)).filter(me=>me.id!==A.id&&me.id!==k.id&&me.x<I&&I<me.x+me.width&&H<me.y+me.height&&me.y<j);if(!B.length)continue;const W=(LE=T.get(b.flow.source))==null?void 0:LE.node.participant,Y=(IE=T.get(b.flow.target))==null?void 0:IE.node.participant;if(!W||!Y)continue;const ae=new Map;for(const[me,Ye,Ce]of[[b.flow.source,A,W],[b.flow.target,k,Y]]){const Q=ae.get(Ce)??[],ie=Po(me,se=>se.x>=Ye.x).filter(se=>!Q.some(ve=>ve.id===se.id));ae.set(Ce,[...Q,...ie])}const ee=new Set([...ae.values()].flat().map(me=>me.id)),de=Hh(ae,ee,b.flow.id,me=>me===b.flow.source||me===b.flow.target,()=>!1),pe=Math.max(...B.map(me=>me.x+me.width));for(const me of VN){const Ye=pe+me-I;if(Ye<=0)continue;const Ce=Jr().bad,Q=zu();let ie=[],se=!0;const ve=()=>!_E(b.flow.id)||se&&(ie=QN(de,b.flow,Q),ie.length)?!1:!ZN(Ce,Q);if(To(de,Ye,ve,La))break;if(ie.length&&(JN(de,Ye,b.flow,Q,ie)||(se=!1,To(de,Ye,ve,La))))break}}{const b=A=>A.y+A.height/2,S=[];for(const A of T.keys()){if(!ko(A))continue;const k=C.filter(H=>H.flow.target===A);if(k.length!==1)continue;const I=p(k[0].flow.source),L=p(A);!I||!L||!T.has(I.id)||Math.abs(b(I)-b(L))>1||L.x-(I.x+I.width)<=F+1||S.push({id:A,pred:I,node:L})}S.sort((A,k)=>A.node.x-k.node.x);for(const{id:A}of S){const k=T.get(A),I=p(A),L=p(C.find(ee=>ee.flow.target===A).flow.source);if(!I||!L)continue;const H=I.x-(L.x+L.width);if(H<=F+1)continue;const j=f(k.node.participant),B=Po(A,ee=>ee.x>=I.x),W=Jr(),Y=WN(B,j,-(H-F));if(!Y)continue;const ae=Jr();(ae.bad>W.bad||ae.crossings>=W.crossings||ae.straight<W.straight)&&Y()}}fE(!0);const e$=10,t$=400,n$=b=>[...b.incoming??[],...b.outgoing??[]].filter(S=>S.type==="bpmn:DataInputAssociation"||S.type==="bpmn:DataOutputAssociation").map(S=>S.source===b?S.target:S.source).filter(S=>!!S&&typeof S.y=="number"),i$=o.filter(b=>b.type==="bpmn:DataStoreReference"&&g.has(b.id)),r$=(b,S)=>{const A=b.x+b.width/2,k=b.y+b.height/2;let I;for(const L of i$){if((d(L)??u())!==S||L.y<b.y+b.height)continue;const H=Math.abs(L.x+L.width/2-A);H>t$||H<L.width||!n$(L).some(B=>B.height===b.height&&Math.abs(B.y+B.height/2-k)<=e$&&L.y>=B.y+B.height)||(!I||H<I.dx||H===I.dx&&L.id<I.id)&&(I={dx:H,id:L.id,cy:L.y+L.height/2})}return I==null?void 0:I.cy};for(const b of m){const S=b.associations??[],A=S.map(L=>L.source===b.dataStore.id?L.target:L.source).map(p).find(Boolean),k=A?d(A)??u():u(),I=A?{x:A.x+A.width/2,y:r$(A,k)??A.y+A.height+110}:{x:200,y:vn+60};n.createShape({type:"bpmn:DataStoreReference",businessObject:i.create("bpmn:DataStoreReference",{id:b.dataStore.id,name:b.dataStore.name})},I,k);for(const L of S)pE(b.dataStore.id,L)}for(const b of v){const A=f(b.association.target).type==="bpmn:DataStoreReference"?b.association.target:b.association.source;pE(A,b.association)}let wE=0;const Oo=10,EE=40,o$=(b,S)=>{const A=S.map(B=>d(B)).filter(B=>!!B);for(const B of A){const W=Oo,Y=B.y,ae=B.y+B.height,ee=B.x,de=B.x+B.width;if(Math.abs(b.y-Y)<W){const pe=Y+W-b.y;b.y+=pe,b.height-=pe}if(Math.abs(b.y+b.height-ae)<W&&(b.height=ae-W-b.y),Math.abs(b.x-ee)<W){const pe=ee+W-b.x;b.x+=pe,b.width-=pe}Math.abs(b.x+b.width-de)<W&&(b.width=de-W-b.x)}if(!A.length)return;const k=Math.min(...A.map(B=>B.y)),I=Math.max(...A.map(B=>B.y+B.height)),L=k-b.y,H=b.y+b.height-I,j=EE-Oo;if(L>0!=H>0)if(L>0&&L<j){const B=L+Oo;b.y+=B,b.height-=B}else H>0&&H<j&&(b.height-=H+Oo)},a$=(b,S)=>{const A=Oo,k=30,I=o.filter(L=>L.type==="bpmn:Group"&&L.id!==S);for(const L of I){const H=L.x,j=L.x+L.width,B=L.y,W=L.y+L.height,Y=b.y<W&&B<b.y+b.height,ae=b.x<j&&H<b.x+b.width;if(Y){if(Math.abs(b.x-j)<A){const ee=Math.min(j+A-b.x,k);ee>0&&b.width-ee>0&&(b.x+=ee,b.width-=ee)}if(Math.abs(b.x+b.width-H)<A){const ee=Math.min(b.x+b.width-(H-A),k);ee>0&&b.width-ee>0&&(b.width-=ee)}}if(ae){if(Math.abs(b.y-W)<A){const ee=Math.min(W+A-b.y,k);ee>0&&b.height-ee>0&&(b.y+=ee,b.height-=ee)}if(Math.abs(b.y+b.height-B)<A){const ee=Math.min(b.y+b.height-(B-A),k);ee>0&&b.height-ee>0&&(b.height-=ee)}}}},Vh=(b,S)=>{const A=EE,k=Math.min(...b.map(B=>B.x))-A,I=Math.min(...b.map(B=>B.y))-A,L=Math.max(...b.map(B=>B.x+B.width))+A,H=Math.max(...b.map(B=>B.y+B.height))+A,j={x:k,y:I,width:L-k,height:H-I};return o$(j,b),a$(j,S),j};for(const b of E){const S=(b.group.members??[]).map(p).filter(I=>!!I);let A;S.length?A=Vh(S,b.group.id):(A={x:300+wE*350,y:40,width:300,height:200},wE++);const k=n.createShape({type:"bpmn:Group",businessObject:i.create("bpmn:Group",{id:b.group.id}),width:A.width,height:A.height},{x:A.x+A.width/2,y:A.y+A.height/2},u());b.group.name&&n.updateLabel(k,b.group.name),(BE=b.group.members)!=null&&BE.length&&O(k,"bwl:Members",{refs:b.group.members.join(" ")})}{const b=o.filter(I=>!!I.waypoints),S=new Map,A=(I,L)=>{!I||!L||(S.has(I)||S.set(I,new Set),S.get(I).add(L))};for(const I of b){const L=(NE=I.source)==null?void 0:NE.id,H=($E=I.target)==null?void 0:$E.id;A(L,H),((FE=I.type)!=null&&FE.includes("DataOutputAssociation")||(jE=I.type)!=null&&jE.includes("DataInputAssociation")||I.type==="bpmn:Association")&&A(H,L)}const k=o.filter(I=>I.type==="bpmn:Group");for(const I of k){const H=(((HE=I.businessObject.extensionElements)==null?void 0:HE.values)??[]).find(Ce=>Ce.$type==="bwl:Members"),j=((H==null?void 0:H.refs)??"").split(" ").filter(Boolean);if(!j.length)continue;const B=new Set(j),W=[...j];for(;W.length;){const Ce=W.shift();for(const Q of S.get(Ce)??[])B.has(Q)||(B.add(Q),W.push(Q))}const Y=I.x,ae=I.x+I.width,ee=I.y,de=I.y+I.height,pe=Ce=>C.filter(Q=>Q.flow.target===Ce).length,me=Ce=>{var ie;const Q=((ie=p(Ce))==null?void 0:ie.type)??"";if(Q==="bpmn:StartEvent"&&pe(Ce)===0)return!1;if(Q.endsWith("Gateway")){const se=C.filter(ve=>ve.flow.target===Ce).map(ve=>ve.flow.source);if(se.length&&se.every(ve=>{var et;return((et=p(ve))==null?void 0:et.type)==="bpmn:StartEvent"&&pe(ve)===0}))return!1}return!0},Ye=o.filter(Ce=>vr(Ce)).filter(Ce=>Ce.type!=="bpmn:Group"&&Ce.type!=="bpmn:Participant"&&Ce.type!=="bpmn:TextAnnotation"&&!B.has(Ce.id)&&ko(Ce.id)&&me(Ce.id)&&Ce.x<ae&&Ce.x+Ce.width>Y&&Ce.y<de&&Ce.y+Ce.height>ee);if(Ye.length)for(const Ce of[-1,1]){const Q=Ye.filter(be=>(be.x+be.width-Y<=ae-be.x?-1:1)===Ce);if(!Q.length)continue;const ie=[];for(const be of Q){const re=ie.find(ye=>ye.some(Ie=>be.y<Ie.y+Ie.height&&be.y+be.height>Ie.y));re?re.push(be):ie.push([be])}const se=new Map;for(const be of ie){let re=Ce<0?Y-Oo:ae+Oo;for(const ye of[...be].sort((Ie,Be)=>Ce<0?Be.x-Ie.x:Ie.x-Be.x)){const Ie=Ce<0?Math.min(ye.x,re-ye.width):Math.max(ye.x,re);re=Ce<0?Ie-Mi:Ie+ye.width+Mi,Ie!==ye.x&&Math.sign(Ie-ye.x)===Ce&&se.set(ye.id,Ie-ye.x)}}const ve=new Map,et=be=>ve.get(be)===be||!ve.get(be)?be:et(ve.get(be));for(const be of Q)ve.set(be.id,be.id);for(const be of x){const re=se.has(be.flow.source)?be.flow.source:void 0,ye=se.has(be.flow.target)?be.flow.target:void 0;if(!re||!ye)continue;const Ie=p(be.flow.id);((zE=Ie==null?void 0:Ie.waypoints)==null?void 0:zE.length)===2&&ve.set(et(re),et(ye))}const Ve=new Map;for(const be of Q){if(!se.has(be.id))continue;const re=et(be.id);Ve.set(re,[...Ve.get(re)??[],be])}const gt=[...Ve.values()].sort((be,re)=>Ce<0?Math.min(...be.map(ye=>ye.x))-Math.min(...re.map(ye=>ye.x)):Math.max(...re.map(ye=>ye.x))-Math.max(...be.map(ye=>ye.x))),Tt=[];let xe=!0;for(const be of gt){const re=be.map(Be=>se.get(Be.id)??0).reduce((Be,we)=>Math.abs(we)>Math.abs(Be)?we:Be,0),ye=new Map;let Ie=!0;for(const Be of be){const we=d(Be);if(!we){Ie=!1;break}ye.has(we.id)||ye.set(we.id,{subtree:[],pool:we}),ye.get(we.id).subtree.push(Be)}Ie&&To([...ye.values()],re,()=>!0,La)?Tt.push({shapes:be,dx:re}):xe=!1}if(!xe)for(const be of Tt.reverse())n.moveElements(be.shapes,{x:-be.dx,y:0})}}}{const b=new Set([...E.map(S=>S.group.id),...Kt(e,"group.update").map(S=>S.id)]);for(const S of o.filter(A=>A.type==="bpmn:Group")){if(b.has(S.id))continue;const k=(((GE=S.businessObject.extensionElements)==null?void 0:GE.values)??[]).find(j=>j.$type==="bwl:Members"),I=((k==null?void 0:k.refs)??"").split(" ").filter(Boolean).map(p).filter(j=>!!j);!I.length||!I.some(j=>{const B=g.get(j.id);return!B||B.x!==j.x||B.y!==j.y})||!I.some(j=>j.x<S.x||j.y<S.y||j.x+j.width>S.x+S.width||j.y+j.height>S.y+S.height)||n.resizeShape(S,Vh(I,S.id))}}{const S=new Map(co(Ze(o)).map(j=>[j.owner,j.rect])),A=o.filter(j=>!!j.waypoints),k=new Map,I=(j,B)=>{!j||!B||(k.has(j)||k.set(j,new Set),k.get(j).add(B))};for(const j of A){const B=(VE=j.source)==null?void 0:VE.id,W=(WE=j.target)==null?void 0:WE.id;I(B,W),((UE=j.type)!=null&&UE.includes("DataOutputAssociation")||(qE=j.type)!=null&&qE.includes("DataInputAssociation")||j.type==="bpmn:Association")&&I(W,B)}const L=j=>C.filter(B=>B.flow.target===j).length,H=j=>{var W;const B=((W=p(j))==null?void 0:W.type)??"";if(B==="bpmn:StartEvent"&&L(j)===0)return!1;if(B.endsWith("Gateway")){const Y=C.filter(ae=>ae.flow.target===j).map(ae=>ae.flow.source);if(Y.length&&Y.every(ae=>{var ee;return((ee=p(ae))==null?void 0:ee.type)==="bpmn:StartEvent"&&L(ae)===0}))return!1}return!0};for(const j of o.filter(B=>B.type==="bpmn:Group")){const W=(((YE=j.businessObject.extensionElements)==null?void 0:YE.values)??[]).find(re=>re.$type==="bwl:Members"),Y=((W==null?void 0:W.refs)??"").split(" ").filter(Boolean);if(!Y.length)continue;const ae=Y.map(p).filter(re=>!!re);if(!ae.length||!(E.some(re=>re.group.id===j.id)||Kt(e,"group.update").some(re=>re.id===j.id)||ae.some(re=>{const ye=g.get(re.id);return!ye||ye.x!==re.x||ye.y!==re.y})))continue;const de=new Set(Y),pe=[...Y];for(;pe.length;){const re=pe.shift();for(const ye of k.get(re)??[])de.has(ye)||(de.add(ye),pe.push(ye))}const me=j.x,Ye=j.x+j.width,Ce=j.y,Q=j.y+j.height,ie=re=>{const ye=S.get(re.id),Ie={x:re.x,y:re.y,width:re.width,height:re.height};return ye?[Ie,{x:ye.x,y:ye.y,width:ye.width,height:ye.height}]:[Ie]},se=ae.flatMap(ie),ve=Math.min(...se.map(re=>re.x)),et=Math.max(...se.map(re=>re.x+re.width)),Ve=Math.min(...se.map(re=>re.y)),gt=Math.max(...se.map(re=>re.y+re.height)),Tt={L:ve-me,R:Ye-et,T:Ve-Ce,B:Q-gt},xe=o.filter(re=>vr(re)).filter(re=>re.type!=="bpmn:Group"&&re.type!=="bpmn:Participant"&&re.type!=="bpmn:TextAnnotation"&&!de.has(re.id)&&H(re.id)&&re.x<Ye&&re.x+re.width>me&&re.y<Q&&re.y+re.height>Ce);if(!xe.length)continue;const be={L:0,R:0,T:0,B:0};for(const re of xe){const ye=ie(re),Ie=Math.min(...ye.map(ke=>ke.x)),Be=Math.max(...ye.map(ke=>ke.x+ke.width)),we=Math.min(...ye.map(ke=>ke.y)),ot=Math.max(...ye.map(ke=>ke.y+ke.height)),Ke={L:Be-me,R:Ye-Ie,T:ot-Ce,B:Q-we},Mt=["L","R","T","B"].filter(ke=>Ke[ke]<=Tt[ke]+.001);if(!Mt.length)continue;const Pe=Mt.reduce((ke,Xe)=>Ke[Xe]<Ke[ke]?Xe:ke,Mt[0]);be[Pe]=Math.max(be[Pe],Math.min(Ke[Pe]+10,Tt[Pe]))}!be.L&&!be.R&&!be.T&&!be.B||n.resizeShape(j,{x:j.x+be.L,y:j.y+be.T,width:j.width-be.L-be.R,height:j.height-be.T-be.B})}}const SE=b=>{const S=b.waypoints;if(S!=null&&S.length){const k=S[Math.floor((S.length-1)/2)];return{x:k.x,y:k.y,width:0,height:0}}const A=b;return{x:A.x,y:A.y,width:A.width,height:A.height}};let Ys=0;const RE=12,CE=14,s$=15,c$=300,l$=b=>{const S=b.split(`
7
7
  `),A=Math.max(...S.map(L=>Vo(L,RE))),k=Math.max(100,Math.min(c$,Math.ceil(A)+CE)),I=S.reduce((L,H)=>L+Math.max(1,Math.ceil((Vo(H,RE)+CE)/k)),0);return{width:k,height:Math.max(30,I*s$+10)}};for(const b of _){const S=b.association,A=((KE=b.placement)==null?void 0:KE.anchor)??(S?S.source===b.annotation.id?S.target:S.source:void 0),k=A?p(A):void 0,I=k?SE(k):void 0,L=l$(b.annotation.text??"");let H;if(I&&b.placement){const[Y,ae]=Cc[b.placement.side],ee=b.placement.offset??50;H={x:I.x+I.width/2+Y*(I.width/2+L.width/2+ee),y:I.y+I.height/2+ae*(I.height/2+L.height/2+ee)}}else I?(H={x:I.x+I.width/2+180+Ys%3*260,y:I.y-110-Ys%2*95},Ys++):(H={x:300+Ys*260,y:60},Ys++);const j=k?d(k)??u():u(),B=j;I&&typeof B.x=="number"&&typeof B.width=="number"&&B.type==="bpmn:Participant"&&(H=Ip(o,I,L,B,b.placement?{placement:b.placement}:{from:H}));const W=n.createShape({type:"bpmn:TextAnnotation",width:L.width,height:L.height,businessObject:i.create("bpmn:TextAnnotation",{id:b.annotation.id,text:b.annotation.text})},H,j);if(S){const Y=ae=>ae===b.annotation.id?W:f(ae);n.connect(Y(S.source),Y(S.target),S.id?{type:"bpmn:Association",businessObject:i.create("bpmn:Association",{id:S.id})}:{type:"bpmn:Association"})}b.placement&&O(W,"bwl:Placement",N(b.placement))}for(const b of Kt(e,"association.add")){const S=b.association;n.connect(f(S.source),f(S.target),S.id?{type:"bpmn:Association",businessObject:i.create("bpmn:Association",{id:S.id})}:{type:"bpmn:Association"})}const ME=()=>new Set(o.getAll().filter(b=>b.type!=="label").map(b=>b.id));for(const b of Kt(e,"node.update")){let S=f(b.id);if(b.type&&Rc(b.type)!==S.type){const A=S.x+S.width/2,k=S.y+S.height/2,I=ME();S=c.replaceElement(S,{type:Rc(b.type),...b.eventDefinition?{eventDefinitionType:ec[b.eventDefinition]}:{}});const L=ME(),H=[...I].filter(W=>W!==b.id&&!L.has(W));if(H.length)throw new Ag({kind:"type-change-drops-elements",opIndex:e.indexOf(b),id:b.id,type:b.type,dropped:H});const j=Math.round(A-(S.x+S.width/2)),B=Math.round(k-(S.y+S.height/2));if(j!==0||B!==0){n.moveShape(S,{x:j,y:B});for(const W of[...S.incoming??[],...S.outgoing??[]])pt(W)}}if(b.name!==void 0&&n.updateProperties(S,{name:b.name??void 0}),b.lane||b.band!==void 0){b.band!==void 0&&n.updateProperties(S,{"bwl:band":b.band});const A=S.y+S.height/2,k=d(S),I=b.lane?f(b.lane):((k==null?void 0:k.children)??[]).find(H=>H.type==="bpmn:Lane"&&A>=H.y&&A<=H.y+H.height);b.band!==void 0&&ht(I==null?void 0:I.id,b.band,k);const L=I?I.y+(b.band===void 0?I.height/2:Math.min(I.height/2,ge)+R(I.id,b.band)*D):b.band!==void 0&&k?k.y+J+R(`pool:${k.id}`,b.band)*D:void 0;if(L!==void 0){const H=L-A;H!==0&&n.moveElements([S],{x:0,y:H})}}}for(const b of Kt(e,"sequenceFlow.update")){const S=f(b.id);if(b.source!==void 0||b.target!==void 0){const A=S,k=b.source!==void 0?f(b.source):A.source,I=b.target!==void 0?f(b.target):A.target,L=B=>({x:B.x+B.width/2,y:B.y+B.height/2});n.reconnect(A,k,I,[L(k),L(I)]);const H=uE.get(A.id),j=I.y+I.height/2;if(H&&I.x>H.exit.x&&Math.abs(j-H.exit.y)>1){n.updateWaypoints(A,[H.exit,{x:H.exit.x,y:j},{x:I.x,y:j}]);const B=A.label;if(B&&H.label){const Y=Math.abs(H.label.y+B.height/2-H.channelY)<=D/5&&H.label.x+B.width>H.exit.x,ae=H.exit.x+6,ee=I.x-6-B.width,de=Y?ee>=ae?{x:Math.max(ae,Math.min(H.label.x,ee)),y:H.label.y+(j-H.channelY)}:void 0:H.label;de&&(de.x!==B.x||de.y!==B.y)&&n.moveElements([B],{x:de.x-B.x,y:de.y-B.y})}}else Math.abs(j-(k.y+k.height/2))>1&&pt(A)}b.name!==void 0&&n.updateProperties(S,{name:b.name??void 0}),b.condition!==void 0&&n.updateProperties(S,{name:((XE=b.condition)==null?void 0:XE.label)??void 0})}for(const b of Kt(e,"messageFlow.update"))b.name!==void 0&&n.updateProperties(f(b.id),{name:b.name??void 0});for(const b of Kt(e,"dataStore.update"))b.name!==void 0&&n.updateProperties(f(b.id),{name:b.name??void 0});for(const b of Kt(e,"annotation.update")){const S=f(b.id);if(b.text!==void 0&&n.updateProperties(S,{text:b.text}),b.placement===null)O(S,"bwl:Placement",null);else if(b.placement){const A=f(b.placement.anchor),k=SE(A),I=d(A)??u(),L=typeof I.x=="number"&&typeof I.width=="number"&&I.type==="bpmn:Participant",[H,j]=Cc[b.placement.side],B=b.placement.offset??50,W={x:k.x+k.width/2+H*(k.width/2+S.width/2+B),y:k.y+k.height/2+j*(k.height/2+S.height/2+B)},Y=L?Ip(o,k,{width:S.width,height:S.height},I,{placement:b.placement,selfId:b.id}):W;n.moveElements([S],{x:Y.x-(S.x+S.width/2),y:Y.y-(S.y+S.height/2)}),O(S,"bwl:Placement",N(b.placement))}}for(const b of Kt(e,"group.update")){const S=f(b.id);if(b.name!==void 0&&n.updateLabel(S,b.name??""),b.members){const A=b.members.map(p).filter(k=>!!k);A.length&&n.resizeShape(S,Vh(A,b.id)),O(S,"bwl:Members",{refs:b.members.join(" ")})}}}function Bp(e){switch(e.kind){case"annotation-over-label":return[e.annotation];case"edge-crosses-shape":return[e.shape];case"shape-outside-container":return[e.shape];case"shape-overlap":return e.shapes;default:return[]}}function KR(e,t,n){var u,p;const{elementRegistry:i}=e,r=e.modeling,o=f=>dt(f).filter(d=>!t.has(lt(d))),a=f=>{var d;return((d=i.get(f))==null?void 0:d.type)==="bpmn:TextAnnotation"},s=Ze(i),c=o(s),l=[...new Set(c.flatMap(Bp))].filter(f=>n.has(f)&&a(f));if(l.length)for(const f of l){const d=i.get(f);if(!d||typeof d.x!="number"||typeof d.width!="number")continue;let g=d.parent,h;for(;g;){if(g.type==="bpmn:Participant"){h=g;break}g=g.parent}if(!h){const ge=d.x+d.width/2,Ae=d.y+d.height/2;h=i.getAll().find(De=>{if(De.type!=="bpmn:Participant")return!1;const qe=De;return typeof qe.x=="number"&&typeof qe.width=="number"&&ge>=qe.x&&ge<=qe.x+qe.width&&Ae>=qe.y&&Ae<=qe.y+qe.height})}if(!h||typeof h.x!="number"||typeof h.width!="number")continue;const C=(((u=d.businessObject.extensionElements)==null?void 0:u.values)??[]).find(ge=>ge.$type==="bwl:Placement"),x=[...d.incoming??[],...d.outgoing??[]].find(ge=>ge.type==="bpmn:Association"),m=(C!=null&&C.anchor?i.get(C.anchor):void 0)??(x?((p=x.source)==null?void 0:p.id)===f?x.target:x.source:void 0);if(!m)continue;const v=m.waypoints,_=v!=null&&v.length?{x:v[Math.floor((v.length-1)/2)].x,y:v[Math.floor((v.length-1)/2)].y,width:0,height:0}:{x:m.x,y:m.y,width:m.width,height:m.height},E={width:d.width,height:d.height},T={x:d.x+d.width/2,y:d.y+d.height/2},O=C==null?void 0:C.side,N=[];O&&O in Cc&&N.push(Ip(i,_,E,h,{placement:{side:O,offset:(C==null?void 0:C.offset)??null},selfId:f}));for(const[ge,Ae]of[[-1,0],[1,0],[0,-1],[0,1]])for(let De=1;De<=YR;De++)N.push({x:T.x+ge*Mg*De,y:T.y+Ae*Mg*De});const P={...s,edges:s.edges.filter(ge=>ge.id!==(x==null?void 0:x.id))},D=o(P),F=D.filter(ge=>Bp(ge).includes(f)).length;if(!F)continue;let J;for(const ge of N){const Ae=ge.x-T.x,De=ge.y-T.y;if(!Ae&&!De||ge.x-E.width/2<h.x||ge.x+E.width/2>h.x+h.width||ge.y-E.height/2<h.y||ge.y+E.height/2>h.y+h.height)continue;const qe={...P,shapes:P.shapes.map(ne=>ne.id===f?{...ne,x:ne.x+Ae,y:ne.y+De}:ne)},rt=o(qe),Me=rt.filter(ne=>Bp(ne).includes(f)).length;if(Me>=F||rt.length>D.length)continue;const X=Math.abs(Ae)+Math.abs(De);if((!J||Me<J.mine||Me===J.mine&&(rt.length<J.all||rt.length===J.all&&X<J.dist))&&(J={x:ge.x,y:ge.y,mine:Me,all:rt.length,dist:X}),J.mine===0&&J.all<D.length)break}J&&r.moveElements([d],{x:J.x-T.x,y:J.y-T.y})}}const XR=60;function Np(e,t,n,i){const r=t.x+t.width,o=[],a=c=>{for(const l of c.children??[])l.type==="bpmn:Lane"&&(o.push(l),a(l))};a(t),e.resizeShape(t,{x:t.x,y:t.y,width:n,height:t.height},void 0,i);const s=t.x+n;for(const c of o)Math.abs(c.x+c.width-r)<1&&e.resizeShape(c,{x:c.x,y:c.y,width:s-c.x,height:c.height},void 0,i)}function ZR(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=u=>dt(u).filter(p=>!t.has(lt(p))),a=u=>u.filter(p=>p.kind==="pool-overlap"),s=new Map(n.shapes.map(u=>[u.id,u])),c=(u,p)=>p.x>=u.x&&p.y>=u.y&&p.x+p.width<=u.x+u.width&&p.y+p.height<=u.y+u.height,l=u=>{if(!s.get(u))return[u];const f=new Set,d=new Set([u]);for(let h=0;h<4;h++){let y=!1;for(const C of n.shapes)C.type!=="bpmn:Group"||f.has(C.id)||[...d].some(x=>{const m=s.get(x);return m&&c(C,m)})&&(f.add(C.id),y=!0);for(const C of n.shapes)C.type!=="bpmn:Participant"||d.has(C.id)||[...f].some(x=>{const m=s.get(x);return m&&c(m,C)})&&(d.add(C.id),y=!0);if(!y)break}const g=n.shapes.filter(h=>!h.parent&&!d.has(h.id)&&!f.has(h.id)&&h.type!=="bpmn:Group"&&h.type!=="bpmn:Participant").filter(h=>[...f].some(y=>{const C=s.get(y);return C&&c(C,h)})).map(h=>h.id);return[...d,...f,...g]};for(let u=0;u<6;u++){const p=Ze(i),f=o(p),d=a(f);if(!d.length)return;const g=new Map(p.shapes.map(v=>[v.id,v]));let h=null;for(const v of d){if(v.kind!=="pool-overlap")continue;const[_,E]=v.pools,T=g.get(_),O=g.get(E);if(!T||!O)continue;const[N,P]=T.x<=O.x?[T,O]:[O,T];if(v.contained)continue;const D=s.get(N.id),F=s.get(P.id),J=D&&F?Math.max(F.x-(D.x+D.width),0):XR,ge=N.x+N.width+J-P.x;if(ge<=0)continue;const Ae=l(P.id).filter(De=>i.get(De));Ae.length&&(!h||ge>h.dx)&&(h={movers:Ae,dx:ge})}if(!h)return;const y=h.movers.map(v=>i.get(v)).filter(v=>!!v&&typeof v.x=="number");if(!y.length)return;const C=f.length,x=d.length;r.moveElements(y,{x:h.dx,y:0});const m=o(Ze(i));if(!(a(m).length<x&&m.length<=C)){r.moveElements(y,{x:-h.dx,y:0});return}}}const Mc=.5,Tg=150;function QR(e,t){const{elementRegistry:n}=e,i=e.modeling,r=t.shapes.filter(m=>m.type==="bpmn:Participant");if(r.length<2)return;const o=r.map(m=>m.x+m.width),a=Math.max(...o);if(a-Math.min(...o)>Mc)return;const s=r.map(m=>n.get(m.id)).filter(m=>!!m&&typeof m.x=="number");if(s.length<2)return;const c=new Map(r.map(m=>[m.id,m.x]));if(s.some(m=>Math.abs(m.x-c.get(m.id))>Mc))return;const l=s.map(m=>m.x+m.width);if(Math.max(...l)-Math.min(...l)<=Mc)return;const u=m=>m.x+m.width,p=m=>!!m&&typeof m.width=="number",f=m=>{const v={shapes:[],edges:[],lanes:[]},_=E=>{for(const T of E.children??[]){if("waypoints"in T&&T.waypoints){v.edges.push(T);continue}T.type!=="label"&&(T.type==="bpmn:Lane"?v.lanes.push(T):v.shapes.push(T),_(T))}};return _(m),v},d=new Map(s.map(m=>[m.id,f(m)]));let g=a;for(const m of s){const{shapes:v}=d.get(m.id),_=v.flatMap(E=>[u(E),...p(E.label)?[u(E.label)]:[]]);_.length&&(g=Math.max(g,Math.max(..._)+Tg))}const h=s.filter(m=>Math.abs(u(m)-g)>Mc);if(!h.length)return;for(const m of h){const v=u(m),{shapes:_,edges:E,lanes:T}=d.get(m.id);if([..._.flatMap(P=>[u(P),...p(P.label)?[u(P.label)]:[]]),...E.flatMap(P=>[...P.waypoints.map(D=>D.x),...p(P.label)?[u(P.label)]:[]])].some(P=>P>g)||[...(m.incoming??[]).map(P=>P.waypoints[P.waypoints.length-1]),...(m.outgoing??[]).map(P=>P.waypoints[0])].some(P=>!P||P.x>g||Math.abs(P.x-v)<1))return;if(g>v){const P={x:v,y:m.y,width:g-v,height:m.height},D=new Set([m.id,..._.map(J=>J.id),...E.map(J=>J.id),...T.map(J=>J.id)]);if(n.getAll().some(J=>{var De;if("waypoints"in J&&J.waypoints||J.type==="bpmn:Group"||!p(J))return!1;const ge=J.type==="label"?(De=J.labelTarget)==null?void 0:De.id:J.id;if(!ge||D.has(ge)||D.has(J.id))return!1;const Ae=J;return Ae.x<P.x+P.width&&Ae.x+Ae.width>P.x&&Ae.y<P.y+P.height&&Ae.y+Ae.height>P.y}))return}}const y=()=>new Set(dt(Ze(n)).map(lt)),C=y(),x=h.map(m=>m.width);for(const m of h)Np(i,m,g-m.x,{layout:!1});[...y()].every(m=>C.has(m))||h.forEach((m,v)=>Np(i,m,x[v],{layout:!1}))}function JR(e,t,n){const{elementRegistry:i}=e,r=e.modeling,o=l=>dt(l).filter(u=>!t.has(lt(u))),a=(l,u)=>u.x>=l.x&&u.y>=l.y&&u.x+u.width<=l.x+l.width&&u.y+u.height<=l.y+l.height,s=l=>({l:Math.min(...l.map(u=>u.x)),t:Math.min(...l.map(u=>u.y)),r:Math.max(...l.map(u=>u.x+u.width)),b:Math.max(...l.map(u=>u.y+u.height))}),c=n.shapes.filter(l=>{var u;return l.type==="bpmn:Group"&&!((u=l.members)!=null&&u.length)});if(c.length)for(const l of c){const u=i.get(l.id);if(!u||typeof u.x!="number")continue;const p=n.shapes.filter(E=>E.id!==l.id&&E.type!=="bpmn:Group"&&a(l,E));if(!p.length)continue;const f=p.map(E=>i.get(E.id)).filter(E=>!!E&&typeof E.x=="number");if(f.length!==p.length)continue;const d=s(p),g=s(f),h=g.l+(l.x-d.l),y=g.t+(l.y-d.t),C=g.r+(l.x+l.width-d.r),x=g.b+(l.y+l.height-d.b),m={x:h,y,width:C-h,height:x-y};if(m.width<=0||m.height<=0||Math.abs(m.x-u.x)<1&&Math.abs(m.y-u.y)<1&&Math.abs(m.width-u.width)<1&&Math.abs(m.height-u.height)<1)continue;const v=o(Ze(i)).length,_={x:u.x,y:u.y,width:u.width,height:u.height};r.resizeShape(u,m),o(Ze(i)).length>v&&r.resizeShape(u,_)}}const Ac=20,Pc=10;function eC(e,t,n,i){var p,f;const{elementRegistry:r}=e,o=e.modeling,a=d=>new Set(dt(d,{includeObservationOnly:!0}).filter(g=>g.kind==="edge-along-group-boundary").map(lt)),s=Ze(r),c=dt(s,{includeObservationOnly:!0}).filter(d=>d.kind==="edge-along-group-boundary"&&!t.has(lt(d)));if(!c.length)return;const l=new Map(n.shapes.map(d=>[d.id,d])),u=new Map;for(const d of c)u.set(d.group,[...u.get(d.group)??[],d]);for(const[d,g]of u){const h=s.shapes.find(Te=>Te.id===d);if(!((p=h==null?void 0:h.members)!=null&&p.length))continue;const y=l.get(d);if(!(!y||Math.abs(y.x-h.x)>=.5||Math.abs(y.y-h.y)>=.5||Math.abs(y.width-h.width)>=.5||Math.abs(y.height-h.height)>=.5))continue;const x=h.members.map(Te=>r.get(Te)).filter(Te=>!!Te&&typeof Te.x=="number");if(!x.length)continue;const m=Math.min(...x.map(Te=>Te.x)),v=Math.min(...x.map(Te=>Te.y)),_=Math.max(...x.map(Te=>Te.x+Te.width)),E=Math.max(...x.map(Te=>Te.y+Te.height)),T=h.x,O=h.y,N=h.x+h.width,P=h.y+h.height;let D=T,F=O,J=N,ge=P;for(const Te of g){const $=s.edges.find(w=>w.id===Te.edge);if(!$)continue;const R=$.endpoints.some(w=>{const G=s.shapes.find(Re=>Re.id===w);if(!G||G.container)return!1;const V=G.x+G.width/2,te=G.y+G.height/2;return T<V&&V<N&&O<te&&te<P});for(const w of gn($)){const G=w.axis==="v"?[O,P]:[T,N];Math.min(w.hi,G[1])-Math.max(w.lo,G[0])<xp||(w.axis==="v"?T<w.at&&w.at<N:O<w.at&&w.at<P)&&R||(w.axis==="v"?(Math.abs(w.at-T)<=Wo&&(D=Math.max(D,w.at+Ac)),Math.abs(w.at-N)<=Wo&&(J=Math.min(J,w.at-Ac))):(Math.abs(w.at-O)<=Wo&&(F=Math.max(F,w.at+Ac)),Math.abs(w.at-P)<=Wo&&(ge=Math.min(ge,w.at-Ac))))}}if(D>m-Pc&&(D=T),F>v-Pc&&(F=O),J<_+Pc&&(J=N),ge<E+Pc&&(ge=P),D===T&&F===O&&J===N&&ge===P)continue;const Ae=r.get(d),De={x:Ae.x,y:Ae.y,width:Ae.width,height:Ae.height},qe=Ze(r),rt=new Set(dt(qe).map(lt)),Me=a(qe);o.resizeShape(Ae,{x:D,y:F,width:J-D,height:ge-F});let X=Ze(r),ne=dt(X).filter(Te=>!rt.has(lt(Te)));const q=[];if(ne.length>0&&ne.every(Te=>Te.kind==="label-over-line"&&!i.has(Te.edge)&&X.edges.some($=>$.id===Te.edge))){for(const Te of ne){if(Te.kind!=="label-over-line")continue;const $=X.edges.find(te=>te.id===Te.edge),R=$&&Op($,X),w=(f=r.get(Te.edge))==null?void 0:f.label;if(!R||!w)continue;const G=R.x-w.x,V=R.y-w.y;o.moveElements([w],{x:G,y:V}),q.push({label:w,dx:G,dy:V})}X=Ze(r),ne=dt(X).filter(Te=>!rt.has(lt(Te)))}const oe=a(X),fe=[...oe].some(Te=>!Me.has(Te));if(ne.length||fe||oe.size>=Me.size){for(const Te of q.reverse())o.moveElements([Te.label],{x:-Te.dx,y:-Te.dy});o.resizeShape(Ae,De)}}}function tC(e,t,n,i){var c;const r=n.getRootElement().businessObject,o=Ju((r==null?void 0:r.$parent)??r),a=Ba(i),s=new Map;for(const l of e.keys()){const u=(c=t.get(l))==null?void 0:c.businessObject;s.set(l,u?{texts:ep(u,i,o),requests:rp(u)}:{texts:{},requests:[]})}return{contexts:()=>[...e].flatMap(([l,u])=>{const p=t.get(l);return p?[{element:p,...u.texts!==void 0?{texts:u.texts}:{},...u.confirm?{confirm:u.confirm}:{},designLocale:i.designLocale,locales:a,...o?{rootLang:o}:{},before:s.get(l)}]:[]})}}function kg(e,t,n={}){var N,P;const{i18n:i,lower:r=Pg}=n,o=Rg(e),a=Ym(o.elementRegistry),s=Sg(t,a,{i18n:i}),c={edgeCrossings:{before:0,after:0,pairs:[],solidPairs:0,dashedPairs:0,mixedPairs:0,crossPoolMessages:0}};if(s.length)return{ok:!1,issues:s,findings:[],stats:c};const l=GR(t,a,i),u=i&&l.writes.size?tC(l.writes,o.elementRegistry,o.canvas,i):void 0,p=Ze(o.elementRegistry),f=new Set(dt(p).map(lt)),d=new Set(dt(p,{includeObservationOnly:!0}).map(lt)),g=new Set(p.edges.map(D=>D.id)),h=new Set(t.flatMap(D=>D.kind==="sequenceFlow.update"&&(D.source!==void 0||D.target!==void 0)?[D.id]:[])),y=new Set(p.shapes.map(D=>D.id)),C=vc(p),x=C.length,m=new Set(C.map(([D,F])=>`${D}|${F}`)),v=new Map;for(const D of o.elementRegistry.filter(F=>"waypoints"in F&&!!F.waypoints))D.label&&v.set(D.id,{wps:D.waypoints.map(F=>({x:F.x,y:F.y})),label:{x:D.label.x,y:D.label.y},source:(N=D.source)==null?void 0:N.id,target:(P=D.target)==null?void 0:P.id});const _=e.get("commandStack");try{Jh(_,()=>{r(l.ops,o);for(const F of(u==null?void 0:u.contexts())??[])_.execute(np,F);ZR(o,f,p),QR(o,p),JR(o,f,p),tg(o,g);const D=Ap(o,f);Qm(o,m,g),pg(o,f,g),rg(o,g),OR(o,g,h),sg(o,f,g),BR(o,f,g),yg(o,f,g),gg(o,g,h),bg(o,y),KR(o,f,y),Ap(o,f,D),eC(o,d,p,g),xg(o,f),mg(o,v)})}catch(D){return{ok:!1,issues:[D instanceof Ag?D.issue:{kind:"lower-failed",message:D instanceof Error?D.message:String(D)}],findings:[],stats:c}}const E=Ze(o.elementRegistry),T=dt(E,{includeObservationOnly:!0}).filter(D=>!d.has(lt(D))),O=$m(E);return{ok:!0,issues:[],findings:T,stats:{edgeCrossings:{before:x,after:O.pairs.length,pairs:O.pairs,solidPairs:O.solidPairs,dashedPairs:O.dashedPairs,mixedPairs:O.mixedPairs,crossPoolMessages:O.crossPoolMessages}}}}function nC(e){const t=e.slice(e.indexOf(":")+1);return t.charAt(0).toLowerCase()+t.slice(1)}function Og(e,t){return typeof e.get=="function"?e.get(t):e[t]}function Dg(e,t){const n=Og(e,t);return typeof n=="number"&&Number.isFinite(n)?n:void 0}function Lg(e,t){var i;return(((i=e.extensionElements)==null?void 0:i.values)??[]).find(r=>(r==null?void 0:r.$type)===t)}function iC(e){return typeof e=="string"&&Yu.includes(e)}function Ti(e){if(typeof e=="string")return e;const t=e==null?void 0:e.id;return typeof t=="string"?t:void 0}function Ig(e,t={}){const n=e.rootElements??[],i=n.find(X=>X.$type==="bpmn:Collaboration"),r=new Map(n.filter(X=>X.$type==="bpmn:Process").map(X=>[X.id,X])),o=[],a=[],s=[],c=[],l=[],u=[],p={poolOrders:{},bands:{},placements:{},afterColumns:{}},f=[],d=[],g=[],h=[],y=[],C=[],x=[],m=new Map,v=new Set,_=new Set,E=X=>{X&&v.add(X)},T=X=>{v.add(X),_.add(X)},O=X=>{const ne=Lg(X,"bwl:Placement");if(!ne)return;const q=typeof ne.anchor=="string"?ne.anchor:void 0;if(!q||!iC(ne.side))return;const K=typeof ne.offset=="number"?ne.offset:void 0;y.push({owner:X.id,anchor:q,side:ne.side,...K!==void 0?{offset:K}:{}})},N=X=>{const ne=Lg(X,"bwl:Members"),q=typeof(ne==null?void 0:ne.refs)=="string"?ne.refs.split(/\s+/).filter(Boolean):[];q.length&&x.push({owner:X.id,refs:q})},P=X=>{var ne;for(const q of X)switch(E(q.id),q.$type){case"bpmn:TextAnnotation":T(q.id),m.set(q.id,q),c.push({id:q.id,text:typeof q.text=="string"?q.text:""}),O(q);break;case"bpmn:Association":g.push({id:q.id,type:q.$type,source:Ti(q.sourceRef),target:Ti(q.targetRef)});break;case"bpmn:Group":{T(q.id),m.set(q.id,q);const K=(ne=q.categoryValueRef)==null?void 0:ne.value;l.push({id:q.id,...typeof K=="string"&&K?{name:K}:{}}),N(q);break}default:u.push({id:q.id,type:q.$type,reason:"type-outside-mvp"})}},D=X=>{for(const ne of X.flowElements??[])E(ne.id),u.push({id:ne.id,type:ne.$type,reason:"inside-container"}),(ne.flowElements??[]).length&&D(ne);for(const ne of X.artifacts??[])E(ne.id),u.push({id:ne.id,type:ne.$type,reason:"inside-container"})},F=(X,ne)=>{const q=X.flowElements??[],K=(X.laneSets??[]).flatMap(fe=>fe.lanes??[]),oe=new Map;for(const fe of K){E(fe.id),m.set(fe.id,fe);for(const Te of fe.flowNodeRef??[]){const $=Ti(Te);$&&oe.set($,fe.id)}}for(const fe of q){if(E(fe.id),m.set(fe.id,fe),fe.$type==="bpmn:SequenceFlow"){f.push({id:fe.id,source:Ti(fe.sourceRef),target:Ti(fe.targetRef),...typeof fe.name=="string"&&fe.name?{name:fe.name}:{}});continue}if(fe.$type==="bpmn:DataStoreReference"){T(fe.id),s.push({id:fe.id,...fe.name?{name:fe.name}:{}});continue}const Te=nC(fe.$type),$=Te==="intermediateCatchEvent"?Uu((fe.eventDefinitions??[]).map(V=>V.$type)):void 0;if(!qh(Te)||Te==="intermediateCatchEvent"&&!$){u.push({id:fe.id,type:fe.$type,reason:"type-outside-mvp"});continue}T(fe.id);const R=Te==="boundaryEvent"?Ti(fe.attachedToRef):void 0;a.push({id:fe.id,type:Te,...fe.name?{name:fe.name}:{},...ne?{participant:ne}:{},...oe.has(fe.id)?{lane:oe.get(fe.id)}:{},...R?{attachedTo:R}:{},...$?{eventDefinition:$}:{}}),Te==="subProcess"&&D(fe);const w=Dg(fe,"bwl:band");w!==void 0&&(p.bands[fe.id]=w);const G=Og(fe,"bwl:afterColumn");typeof G=="string"&&G!==""&&C.push([fe.id,G]);for(const V of fe.dataOutputAssociations??[])E(V.id),h.push({id:V.id,type:V.$type,source:fe.id,target:Ti(V.targetRef)});for(const V of fe.dataInputAssociations??[])E(V.id),h.push({id:V.id,type:V.$type,source:Ti((V.sourceRef??[])[0]),target:fe.id})}P(X.artifacts??[])};if(i){const X=new Set;for(const ne of i.participants??[]){T(ne.id),m.set(ne.id,ne);const q=Ti(ne.processRef);q&&X.add(q);const K=q?r.get(q):void 0,oe=((K==null?void 0:K.laneSets)??[]).flatMap(R=>R.lanes??[]),fe=oe.map(R=>({id:R.id,...R.name?{name:R.name}:{}}));for(const R of fe)T(R.id);const Te=!K||(K.flowElements??[]).length===0&&oe.length===0&&(K.artifacts??[]).length===0;o.push({id:ne.id,...ne.name?{name:ne.name}:{},...Te?{blackBox:!0}:{},...fe.length?{lanes:fe}:{}});const $=Dg(ne,"bwl:poolOrder");$!==void 0&&(p.poolOrders[ne.id]=$),K&&F(K,ne.id)}for(const ne of i.messageFlows??[])E(ne.id),m.set(ne.id,ne),d.push({id:ne.id,source:Ti(ne.sourceRef),target:Ti(ne.targetRef),...typeof ne.name=="string"&&ne.name?{name:ne.name}:{}});P(i.artifacts??[]);for(const[ne,q]of r)!X.has(ne)&&(q.flowElements??[]).length>0&&u.push({id:ne,type:q.$type,reason:"unreachable-process"})}else for(const X of r.values())F(X);const J=[],ge=[],Ae=[],De=[],qe=(X,ne)=>!!X&&!!ne&&_.has(X)&&_.has(ne);for(const X of f){if(!qe(X.source,X.target)){u.push({id:X.id,type:"bpmn:SequenceFlow",reason:"endpoint-outside-mvp"});continue}J.push({id:X.id,source:X.source,target:X.target,...X.name?{name:X.name}:{}}),_.add(X.id)}for(const X of d){if(!qe(X.source,X.target)){u.push({id:X.id,type:"bpmn:MessageFlow",reason:"endpoint-outside-mvp"});continue}ge.push({id:X.id,source:X.source,target:X.target,...X.name?{name:X.name}:{}}),_.add(X.id)}for(const X of h){if(!qe(X.source,X.target)){u.push({id:X.id??"",type:X.type,reason:"endpoint-outside-mvp"});continue}De.push({...X.id?{id:X.id}:{},source:X.source,target:X.target}),X.id&&_.add(X.id)}for(const X of g){if(!qe(X.source,X.target)){u.push({id:X.id??"",type:X.type,reason:"endpoint-outside-mvp"});continue}Ae.push({...X.id?{id:X.id}:{},source:X.source,target:X.target})}const rt=new Map(l.map(X=>[X.id,X]));for(const{owner:X,refs:ne}of x){const q=ne.filter(oe=>v.has(oe)),K=rt.get(X);K&&q.length&&(K.members=q)}for(const X of y)v.has(X.anchor)&&(p.placements[X.owner]={anchor:X.anchor,side:X.side,...X.offset!==void 0?{offset:X.offset}:{}});for(const[X,ne]of C)v.has(ne)&&(p.afterColumns[X]=ne);const Me={...o.length?{participants:o}:{},nodes:a,sequenceFlows:J,...ge.length?{messageFlows:ge}:{},...s.length?{dataStores:s}:{},...De.length?{dataAssociations:De}:{},...c.length?{annotations:c}:{},...Ae.length?{associations:Ae}:{},...l.length?{groups:l}:{}};return t.i18n?{definition:Me,hints:p,omitted:u,i18n:rC(Me,m,e,t.i18n)}:{definition:Me,hints:p,omitted:u}}function rC(e,t,n,i){const r=Ju(n),o=Ba(i),a=[],s=(c,l)=>{const u=t.get(c.id);if(!u)return;const p=ep(u,i,r);Object.keys(p).length&&(c[l]=p);for(const f of rp(u))o.includes(f.locale)&&a.push({id:c.id,...f})};for(const c of e.participants??[]){s(c,"names");for(const l of c.lanes??[])s(l,"names")}for(const c of[e.nodes,e.sequenceFlows,e.messageFlows,e.dataStores,e.groups])for(const l of c??[])s(l,"names");for(const c of e.annotations??[])s(c,"texts");return{designLocale:i.designLocale,companionLocales:o.slice(1),reviewRequests:a}}async function oC(e,t={}){const{definitions:n,warnings:i}=await zo(e);return{...Ig(n,t),warnings:i}}const aC=new Set(["bpmn:ExclusiveGateway","bpmn:ParallelGateway","bpmn:InclusiveGateway","bpmn:EventBasedGateway","bpmn:ComplexGateway"]);function $p(e){if(typeof e=="string")return e;const t=e==null?void 0:e.id;return typeof t=="string"?t:void 0}function sC(e){return $p(e.processRef)!==void 0}function cC(e){const t=new Set,n=r=>{const o=$p(r);o&&t.add(o)},i=r=>{for(const o of r.flowElements??[]){n(o.sourceRef),n(o.targetRef),o.attachedToRef&&(n(o.attachedToRef),t.add(o.id));for(const a of o.dataOutputAssociations??[])t.add(o.id),n(a.targetRef);for(const a of o.dataInputAssociations??[]){t.add(o.id);for(const s of a.sourceRef??[])n(s)}(o.flowElements??[]).length&&i(o)}for(const o of r.artifacts??[])n(o.sourceRef),n(o.targetRef)};for(const r of e.rootElements??[])if(r.$type==="bpmn:Process")i(r);else if(r.$type==="bpmn:Collaboration"){for(const o of r.messageFlows??[])n(o.sourceRef),n(o.targetRef);for(const o of r.artifacts??[])n(o.sourceRef),n(o.targetRef)}return t}function lC(e){const t=[],n=i=>{for(const r of i.flowElements??[])aC.has(r.$type)&&t.push(r),(r.flowElements??[]).length&&n(r)};for(const i of e.rootElements??[])i.$type==="bpmn:Process"&&n(i);return t}function uC(e){if(!e)return!0;const t=(e.laneSets??[]).flatMap(n=>n.lanes??[]);return(e.flowElements??[]).length===0&&t.length===0&&(e.artifacts??[]).length===0}function Fp(e){const t=[],n=e.rootElements??[],i=cC(e);for(const o of lC(e))i.has(o.id)||t.push({ruleId:"CHK-FLOW-1",severity:"warning",targetKind:"flowNode",targetRefs:[o.id],params:{type:o.$type}});const r=n.find(o=>o.$type==="bpmn:Collaboration");if(r){const o=new Map(n.filter(s=>s.$type==="bpmn:Process").map(s=>[s.id,s])),a=[];for(const s of r.participants??[])sC(s)&&uC(o.get($p(s.processRef)))&&a.push(s.id);a.length&&t.push({ruleId:"CHK-POOL-1",severity:"info",targetKind:"participant",targetRefs:a,params:{count:a.length}})}return t}async function pC(e){const{definitions:t,warnings:n}=await zo(e);return{issues:Fp(t),warnings:n}}const fC=.5,dC=8,hC=new Set(["bpmn:Definitions","bpmn:Collaboration","bpmn:Process","bpmn:LaneSet","bpmn:ExtensionElements","bpmn:Documentation","bpmn:Relationship","bpmn:Property","bpmn:Category","bpmn:CategoryValue"]),Zo=e=>typeof e=="number"?e:Number(e??NaN),Tc=e=>{if(typeof e=="string")return e;const t=e==null?void 0:e.id;return typeof t=="string"?t:""};function mC(e){const t=e,n=[],i=typeof t.name=="string"?t.name:typeof t.text=="string"?t.text:"";n.push(`n=${i.replace(/\s+/g," ").trim()}`);for(const o of["sourceRef","targetRef","attachedToRef","processRef","default"])t[o]!==void 0&&n.push(`${o}=${Tc(t[o])}`);if(String(e.$type)==="bpmn:Group"){const o=t.categoryValueRef,a=Array.isArray(o)?o:o==null?[]:[o];n.push(`cat=[${a.map(s=>`${Tc(s)}:${typeof(s==null?void 0:s.value)=="string"?s.value:""}`).sort().join(",")}]`)}Array.isArray(t.flowNodeRef)&&n.push(`lane=[${t.flowNodeRef.map(Tc).sort().join(",")}]`);const r=t.conditionExpression;return r&&typeof r.body=="string"&&n.push(`cond=${r.body}`),n.join("|")}function gC(e){const t=new Map,n=new Map,i=(a,s)=>{a&&t.set(a,[...t.get(a)??[],...s])},r=a=>{const s=a;return s?[Zo(s.x),Zo(s.y),Zo(s.width),Zo(s.height)]:[]},o=a=>{if(Array.isArray(a))return a.forEach(o);if(!a||typeof a!="object")return;const s=a,c=String(s.$type??"");if(c==="bpmndi:BPMNShape"||c==="bpmndi:BPMNEdge"){const l=Tc(s.bpmnElement);if(c==="bpmndi:BPMNShape")i(l,r(s.bounds));else{const p=Array.isArray(s.waypoint)?s.waypoint:[];i(l,p.flatMap(f=>[Zo(f.x),Zo(f.y)]))}const u=s.label;u!=null&&u.bounds&&l&&n.set(l,r(u.bounds).slice(0,2));return}for(const l of Object.values(s))(Array.isArray(l)||l&&typeof l=="object"&&"$type"in l)&&o(l)};return o(e.diagrams),{body:t,labels:n}}function Bg(e){const t=gC(e),n=new Map,i=new Set,r=o=>{if(Array.isArray(o))return o.forEach(r);if(!o||typeof o!="object"||i.has(o))return;i.add(o);const a=o,s=String(a.$type??"");if(s.startsWith("bpmndi:")||s.startsWith("dc:")||s.startsWith("di:"))return;const c=typeof a.id=="string"?a.id:"";c&&s.startsWith("bpmn:")&&!hC.has(s)&&n.set(c,{type:s,props:mC(a),geometry:(t.body.get(c)??[]).join(","),label:(t.labels.get(c)??[]).join(",")});for(const l of Object.values(a))(Array.isArray(l)||l&&typeof l=="object")&&r(l)};return r(e),n}function Ng(e,t,n){if(e===t)return!1;const i=e===""?[]:e.split(",").map(Number),r=t===""?[]:t.split(",").map(Number);return i.length!==r.length?!0:i.some((o,a)=>Math.abs(o-r[a])>n)}function $g(e,t,n={}){const i=n.moveTolerance??fC,r=Bg(e),o=Bg(t),a=[],s=[],c=[];for(const[l,u]of o){const p=r.get(l);if(!p){a.push(l);continue}(p.type!==u.type||p.props!==u.props||Ng(p.geometry,u.geometry,i)||Ng(p.label,u.label,n.labelTolerance??dC))&&c.push(l)}for(const l of r.keys())o.has(l)||s.push(l);return{added:a.sort(),removed:s.sort(),modified:c.sort()}}async function yC(e,t,n={}){const[i,r]=await Promise.all([zo(e),zo(t)]);return{...$g(i.definitions,r.definitions,n),warnings:[...i.warnings,...r.warnings]}}function vC(e){return new Set([...e.added,...e.modified])}function bC(e,t,n,i={}){return{documentId:e,baseVersion:t,ops:[...n],origin:i.origin??"agent",clientOpId:(i.mkClientOpId??(()=>crypto.randomUUID()))()}}async function Fg(e,t,{currentVersion:n,i18n:i}){if(t.baseVersion!==n)return{status:"conflict",baseVersion:t.baseVersion,currentVersion:n};const r=kg(e,t.ops,{i18n:i});if(!r.ok)return{status:"rejected",issues:r.issues};const{xml:o}=await e.saveXML({format:!0});return{status:"applied",version:n+1,xml:o??"",findings:r.findings,stats:r.stats}}const xC=Symbol("bpmn-editor"),jp={geometry:[],semantic:[]};function _C(){const e=he.ref(!1),t=he.ref(!0),n=he.ref(!1),i=he.shallowRef(jp),r=he.shallowRef(void 0),o=he.shallowRef(void 0);let a,s,c,l;const u=()=>{if(f(),!c){i.value=jp;return}const x=dt(Ze(c.get("elementRegistry")),{includeObservationOnly:!0}),m=c.getDefinitions();i.value={geometry:x,semantic:m?Fp(m):[]}};function p(){return(c==null?void 0:c.get("i18nDisplay",!1))??void 0}function f(){const x=p();if(!x||!a){o.value=void 0;return}const m=x.locales(),v={};for(const _ of m)v[_]={untranslated:x.untranslatedCount(_),reviewRequested:x.reviewRequestedCount(_)};o.value={designLocale:a.designLocale,locales:m,displayLocale:x.getDisplayLocale()??a.designLocale,counts:v}}function d(){const x=p();x&&(x.configure(a),a&&s&&(s=x.setDisplayLocale(s)))}const g=()=>{e.value=!0,u()};function h(x,m){x.get("canvas").getContainer().style.pointerEvents=m?"":"none";const v=x.get("keyboard");m?(l&&v.bind(l),l=void 0):l||(l=v.getBinding(),v.unbind())}function y(){if(!c)throw new Error("modeler not attached — 뷰 @ready 후 attach() 필요");return c}function C(){return c==null?void 0:c.get("commandStack")}return{dirty:e,editable:t,agentBusy:n,issues:i,revalidate:u,changeScope:r,i18n:o,configureI18n(x){a=x,d(),f()},setDisplayLocale(x){var v;s=x;const m=(v=p())==null?void 0:v.setDisplayLocale(x);m&&(s=m),f()},setChangeScope(x){r.value=x===void 0?void 0:new Set(x)},requestFocus(x){if(!c)return;const m=c.get("elementRegistry").get(x);m&&(c.get("canvas").scrollToElement(m,180),c.get("selection").select(m))},describeElement(x){const m=c==null?void 0:c.get("elementRegistry").get(x),v=m==null?void 0:m.businessObject;if(!v)return;const _=typeof v.name=="string"&&v.name.trim()!==""?v.name:v.text;return{name:typeof _=="string"&&_.trim()!==""?_.trim():void 0,type:typeof v.$type=="string"?v.$type:""}},attach(x){c&&this.detach(),c=x,c.get("eventBus").on("commandStack.changed",g),t.value||h(c,!1),d(),u()},detach(){c==null||c.get("eventBus").off("commandStack.changed",g),c&&!t.value&&h(c,!0),l=void 0,c=void 0,i.value=jp,r.value=void 0,o.value=void 0},setEditable(x){t.value=x,c&&h(c,x)},async applyAgentBatch(x,m){const v=y();n.value=!0;try{const _=await Fg(v,x,{currentVersion:m,...a?{i18n:{designLocale:a.designLocale,companionLocales:a.companionLocales}}:{}});return _.status==="applied"&&(e.value=!1),_}finally{n.value=!1}},async importXml(x){const{warnings:m}=await y().importXML(x);return e.value=!1,r.value=void 0,u(),{warnings:bp(m)}},async saveXml(){const{xml:x}=await y().saveXML({format:!0});return e.value=!1,x??""},undo:()=>{var x;return(x=C())==null?void 0:x.undo()},redo:()=>{var x;return(x=C())==null?void 0:x.redo()},canUndo:()=>{var x;return((x=C())==null?void 0:x.canUndo())??!1},canRedo:()=>{var x;return((x=C())==null?void 0:x.canRedo())??!1}}}const wC=new RegExp("\\p{Script=Hangul}","u"),EC=/[\p{Script=Hiragana}\p{Script=Katakana}]/u,SC=new RegExp("\\p{Script=Han}","u");function Hp(e){const t=wC.test(e),n=EC.test(e);return t&&n?{script:"mixed"}:t?{script:"hangul",locale:"ko"}:n?{script:"kana",locale:"ja"}:{script:SC.test(e)?"han":"other"}}function jg(e){var t,n;return((t=e==null?void 0:e.get)==null?void 0:t.call(e,"xml:lang"))??((n=e==null?void 0:e.$attrs)==null?void 0:n["xml:lang"])}function Hg(e){var i;const t=new Set,n=[];for(const r of(e==null?void 0:e.diagrams)??[])for(const o of((i=r==null?void 0:r.plane)==null?void 0:i.planeElement)??[]){const a=o==null?void 0:o.bpmnElement;if(!a||t.has(a))continue;t.add(a);const s=ro(a);if(!s)continue;const c=s.target[s.key]??"";c&&n.push({bo:a,name:c,trs:Fo(a).filter(l=>On(l))})}return n}const Va=e=>({id:e.bo.id,type:e.bo.$type,name:e.name});function RC(e){const t=jg(e),n=Hg(e);let i;const r={},o=[],a=[],s=[];for(const g of n){const h=g.trs.filter(y=>(y.body??"")===g.name).map(On);if(h.length){const y=[...h].sort().join("+");r[y]=(r[y]??0)+1,i=i?new Set([...i].filter(C=>h.includes(C))):new Set(h)}else g.trs.some(y=>y.body)?o.push(Va(g)):s.push({e:g,inference:Hp(g.name)});for(const y of g.trs){const C=On(y),x=y.body??"",m=Hp(x);m.locale&&m.locale!==C?a.push({...Va(g),locale:C,script:m.script}):C==="ko"&&m.script==="han"&&g.trs.some(v=>v!==y&&v.body===x)&&a.push({...Va(g),locale:C,script:"han"})}}const c=new Set(s.map(g=>g.inference.locale).filter(Boolean));let l,u;if(t)u="kept";else if(i&&i.size===1)[l,u]=[[...i][0],"matched"];else if(i&&i.size>1){const g=c.size===1?[...c][0]:void 0;g&&i.has(g)?[l,u]=[g,"matched"]:u="ambiguous"}else i?u="mixed":c.size===1?[l,u]=[[...c][0],"script"]:u=c.size>1?"mixed":"no-evidence";const p=t??l,f=[],d=[];for(const{e:g,inference:h}of s)h.locale?h.locale!==p&&f.push({...Va(g),locale:h.locale}):d.push({...Va(g),script:h.script});return{root:{current:t,proposed:l,reason:u},additions:f,undecided:d,drift:o,matchedBy:r,scriptMismatch:a}}function CC(e,t){const n=e.$model;let i=0;if(t.root.proposed&&!jg(e)&&(e.set("xml:lang",t.root.proposed),i++),!t.additions.length)return i;const r=new Map(Hg(e).map(o=>[o.bo.id,o]));for(const{id:o,name:a,locale:s}of t.additions){const c=r.get(o);if(!c||c.name!==a||c.trs.some(f=>f.body))continue;const l=c.trs.find(f=>On(f)===s);if(l){l.body=c.name,i++;continue}let u=c.bo.extensionElements;u||(u=n.create("bpmn:ExtensionElements",{values:[]}),u.$parent=c.bo,c.bo.extensionElements=u);const p=n.create($o,{body:c.name});p.set("xml:lang",s),p.$parent=u,u.get("values").push(p),i++}return i}function Ee(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}function MC(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var zp={exports:{}},zg;function AC(){if(zg)return zp.exports;zg=1;var e=zp.exports=function(t,n){if(n||(n=16),t===void 0&&(t=128),t<=0)return"0";for(var i=Math.log(Math.pow(2,t))/Math.log(n),r=2;i===1/0;r*=2)i=Math.log(Math.pow(2,t/r))/Math.log(n)*r;for(var o=i-Math.floor(i),a="",r=0;r<Math.floor(i);r++){var s=Math.floor(Math.random()*n).toString(n);a=s+a}if(o){var c=Math.pow(n,o),s=Math.floor(Math.random()*c).toString(n);a=s+a}var l=parseInt(a,n);return l!==1/0&&l>=Math.pow(2,t)?e(t,n):a};return e.rack=function(t,n,i){var r=function(a){var s=0;do{if(s++>10)if(i)t+=i;else throw new Error("too many ID collisions, use more bits");var c=e(t,n)}while(Object.hasOwnProperty.call(o,c));return o[c]=a,c},o=r.hats={};return r.get=function(a){return r.hats[a]},r.set=function(a,s){return r.hats[a]=s,r},r.bits=t||128,r.base=n||16,r},zp.exports}var PC=AC(),TC=MC(PC);function Hi(e){if(!(this instanceof Hi))return new Hi(e);e=e||[128,36,1],this._seed=e.length?TC.rack(e[0],e[1],e[2]):e}Hi.prototype.next=function(e){return this._seed(e||!0)},Hi.prototype.nextPrefixed=function(e,t){var n;do n=e+this.next(!0);while(this.assigned(n));return this.claim(n,t),n},Hi.prototype.claim=function(e,t){this._seed.set(e,t||!0)},Hi.prototype.assigned=function(e){return this._seed.get(e)||!1},Hi.prototype.unclaim=function(e){delete this._seed.hats[e]},Hi.prototype.clear=function(){var e=this._seed.hats,t;for(t in e)this.unclaim(t)};const ln={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]};ln.td=ln.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],ln.option=ln.optgroup=[1,'<select multiple="multiple">',"</select>"],ln.thead=ln.tbody=ln.colgroup=ln.caption=ln.tfoot=[1,"<table>","</table>"],ln.polyline=ln.ellipse=ln.polygon=ln.circle=ln.text=ln.line=ln.path=ln.rect=ln.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];function Dt(e,t=globalThis.document){var l;if(typeof e!="string")throw new TypeError("String expected");const n=/^<!--(.*?)-->$/s.exec(e);if(n)return t.createComment(n[1]);const i=(l=/<([\w:]+)/.exec(e))==null?void 0:l[1];if(!i)return t.createTextNode(e);if(e=e.trim(),i==="body"){const u=t.createElement("html");u.innerHTML=e;const{lastChild:p}=u;return p.remove(),p}let[r,o,a]=Object.hasOwn(ln,i)?ln[i]:ln._default,s=t.createElement("div");for(s.innerHTML=o+e+a;r--;)s=s.lastChild;if(s.firstChild===s.lastChild){const{firstChild:u}=s;return u.remove(),u}const c=t.createDocumentFragment();return c.append(...s.childNodes),c}function kC(e,t){return t.forEach(function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach(function(i){if(i!=="default"&&!(i in e)){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}})}),Object.freeze(e)}function $n(e,...t){const n=e.style;return z(t,function(i){i&&z(i,function(r,o){n[o]=r})}),e}function Ln(e,t,n){return arguments.length==2?e.getAttribute(t):n===null?e.removeAttribute(t):(e.setAttribute(t,n),e)}const OC=Object.prototype.toString;function $t(e){return new Sr(e)}function Sr(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}Sr.prototype.add=function(e){return this.list.add(e),this},Sr.prototype.remove=function(e){return OC.call(e)=="[object RegExp]"?this.removeMatching(e):(this.list.remove(e),this)},Sr.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Sr.prototype.toggle=function(e,t){return typeof t<"u"?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Sr.prototype.array=function(){return Array.from(this.list)},Sr.prototype.has=Sr.prototype.contains=function(e){return this.list.contains(e)};function kc(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function lo(e,t,n){var i=n?e:e.parentNode;return i&&typeof i.closest=="function"&&i.closest(t)||null}function DC(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Oc={},Gg;function LC(){if(Gg)return Oc;Gg=1;var e,t,n;function i(){e=window.addEventListener?"addEventListener":"attachEvent",t=window.removeEventListener?"removeEventListener":"detachEvent",n=e!=="addEventListener"?"on":""}return Oc.bind=function(r,o,a,s){return e||i(),r[e](n+o,a,s||!1),a},Oc.unbind=function(r,o,a,s){return t||i(),r[t](n+o,a,s||!1),a},Oc}var Vg=LC(),IC=DC(Vg),Ge=kC({__proto__:null,default:IC},[Vg]),Wg=["focus","blur"];function BC(e,t,n,i,r){return Wg.indexOf(n)!==-1&&(r=!0),Ge.bind(e,n,function(o){var a=o.target||o.srcElement;o.delegateTarget=lo(a,t,!0),o.delegateTarget&&i.call(e,o)},r)}function NC(e,t,n,i){return Wg.indexOf(t)!==-1&&(i=!0),Ge.unbind(e,t,n,i)}var Xn={bind:BC,unbind:NC};function Gp(e,t){return e&&typeof e.matches=="function"&&e.matches(t)||!1}function wt(e,t){return t=t||document,t.querySelector(e)}function Dc(e,t){return t=t||document,t.querySelectorAll(e)}function zi(e){e.parentNode&&e.parentNode.removeChild(e)}function $C(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch{}return e}function FC(e,t){return t.appendChild($C(e,t))}function We(e,t){return FC(t,e),e}var Vp=2,Ug={"alignment-baseline":1,"baseline-shift":1,clip:1,"clip-path":1,"clip-rule":1,color:1,"color-interpolation":1,"color-interpolation-filters":1,"color-profile":1,"color-rendering":1,cursor:1,direction:1,display:1,"dominant-baseline":1,"enable-background":1,fill:1,"fill-opacity":1,"fill-rule":1,filter:1,"flood-color":1,"flood-opacity":1,font:1,"font-family":1,"font-size":Vp,"font-size-adjust":1,"font-stretch":1,"font-style":1,"font-variant":1,"font-weight":1,"glyph-orientation-horizontal":1,"glyph-orientation-vertical":1,"image-rendering":1,kerning:1,"letter-spacing":1,"lighting-color":1,marker:1,"marker-end":1,"marker-mid":1,"marker-start":1,mask:1,opacity:1,overflow:1,"pointer-events":1,"shape-rendering":1,"stop-color":1,"stop-opacity":1,stroke:1,"stroke-dasharray":1,"stroke-dashoffset":1,"stroke-linecap":1,"stroke-linejoin":1,"stroke-miterlimit":1,"stroke-opacity":1,"stroke-width":Vp,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function jC(e,t){return Ug[t]?e.style[t]:e.getAttributeNS(null,t)}function qg(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=Ug[i];r?(r===Vp&&typeof n=="number"&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function HC(e,t){var n=Object.keys(t),i,r;for(i=0,r;r=n[i];i++)qg(e,r,t[r])}function Se(e,t,n){if(typeof t=="string")if(n!==void 0)qg(e,t,n);else return jC(e,t);else HC(e,t);return e}const zC=Object.prototype.toString;function st(e){return new Rr(e)}function Rr(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}Rr.prototype.add=function(e){return this.list.add(e),this},Rr.prototype.remove=function(e){return zC.call(e)=="[object RegExp]"?this.removeMatching(e):(this.list.remove(e),this)},Rr.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Rr.prototype.toggle=function(e,t){return typeof t<"u"?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Rr.prototype.array=function(){return Array.from(this.list)},Rr.prototype.has=Rr.prototype.contains=function(e){return this.list.contains(e)};function Lc(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Yg(e){return e.cloneNode(!0)}var Wp={svg:"http://www.w3.org/2000/svg"},Kg='<svg xmlns="'+Wp.svg+'"';function GC(e){var t=!1;e.substring(0,4)==="<svg"?e.indexOf(Wp.svg)===-1&&(e=Kg+e.substring(4)):(e=Kg+">"+e+"</svg>",t=!0);var n=VC(e);if(!t)return n;for(var i=document.createDocumentFragment(),r=n.firstChild;r.firstChild;)i.appendChild(r.firstChild);return i}function VC(e){var t;return t=new DOMParser,t.async=!1,t.parseFromString(e,"text/xml")}function Oe(e,t){var n;return e=e.trim(),e.charAt(0)==="<"?(n=GC(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(Wp.svg,e),t&&Se(n,t),n}var Up=null;function Xg(){return Up===null&&(Up=Oe("svg")),Up}function Zg(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)e[i]=t[i];return e}function WC(e,t,n,i,r,o){var a=Xg().createSVGMatrix();switch(arguments.length){case 0:return a;case 1:return Zg(a,e);case 6:return Zg(a,{a:e,b:t,c:n,d:i,e:r,f:o})}}function Wa(e){return Xg().createSVGTransform()}var Qg=/([&<>]{1})/g,UC=/([&<>\n\r"]{1})/g,qC={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"'"};function qp(e,t){function n(i,r){return qC[r]||r}return e.replace(t,n)}function Jg(e,t){var n,i,r,o,a;switch(e.nodeType){case 3:t.push(qp(e.textContent,Qg));break;case 1:if(t.push("<",e.tagName),e.hasAttributes())for(r=e.attributes,n=0,i=r.length;n<i;++n)o=r.item(n),t.push(" ",o.name,'="',qp(o.value,UC),'"');if(e.hasChildNodes()){for(t.push(">"),a=e.childNodes,n=0,i=a.length;n<i;++n)Jg(a.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("<!--",qp(e.nodeValue,Qg),"-->");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function YC(e){for(var t=e.firstChild,n=[];t;)Jg(t,n),t=t.nextSibling;return n.join("")}function ey(e,t){return YC(e)}function un(e){var t=e.parentNode;return t&&t.removeChild(e),e}function KC(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function XC(e,t){var n,i;for(e.clear(),n=0;i=t[n];n++)e.appendItem(KC(e,i))}function Ua(e,t){var n=e.transform.baseVal;return t&&(Array.isArray(t)||(t=[t]),XC(n,t)),n.consolidate()}const ZC=/^class[ {]/;function QC(e){return ZC.test(e.toString())}function Yp(e){return Array.isArray(e)}function Kp(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ic(...e){e.length===1&&Yp(e[0])&&(e=e[0]),e=[...e];const t=e.pop();return t.$inject=e,t}const JC=/constructor\s*[^(]*\(\s*([^)]*)\)/m,eM=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,tM=/\/\*([^*]*)\*\//m;function nM(e){if(typeof e!="function")throw new Error(`Cannot annotate "${e}". Expected a function!`);const t=e.toString().match(QC(e)?JC:eM);if(!t)return[];const n=t[1]||t[2];return n&&n.split(",").map(i=>{const r=i.match(tM);return(r&&r[1]||i).trim()})||[]}function ty(e,t){const n=t||{get:function(m,v){if(i.push(m),v===!1)return null;throw s(`No provider for "${m}"!`)}},i=[],r=this._providers=Object.create(n._providers||null),o=this._instances=Object.create(null),a=o.injector=this,s=function(m){const v=i.join(" -> ");return i.length=0,new Error(v?`${m} (Resolving: ${v})`:m)};function c(m,v){if(!r[m]&&m.includes(".")){const _=m.split(".");let E=c(_.shift());for(;_.length;)E=E[_.shift()];return E}if(Kp(o,m))return o[m];if(Kp(r,m)){if(i.indexOf(m)!==-1)throw i.push(m),s("Cannot resolve circular dependency!");return i.push(m),o[m]=r[m][0](r[m][1]),i.pop(),o[m]}return n.get(m,v)}function l(m,v){if(typeof v>"u"&&(v={}),typeof m!="function")if(Yp(m))m=Ic(m.slice());else throw s(`Cannot invoke "${m}". Expected a function!`);const E=(m.$inject||nM(m)).map(T=>Kp(v,T)?v[T]:c(T));return{fn:m,dependencies:E}}function u(m){const{fn:v,dependencies:_}=l(m),E=Function.prototype.bind.call(v,null,..._);return new E}function p(m,v,_){const{fn:E,dependencies:T}=l(m,_);return E.apply(v,T)}function f(m){return Ic(v=>m.get(v))}function d(m,v){if(v&&v.length){const _=Object.create(null),E=Object.create(null),T=[],O=[],N=[];let P,D,F,J;for(let ge in r)P=r[ge],v.indexOf(ge)!==-1&&(P[2]==="private"?(D=T.indexOf(P[3]),D===-1?(F=P[3].createChild([],v),J=f(F),T.push(P[3]),O.push(F),N.push(J),_[ge]=[J,ge,"private",F]):_[ge]=[N[D],ge,"private",O[D]]):_[ge]=[P[2],P[1]],E[ge]=!0),(P[2]==="factory"||P[2]==="type")&&P[1].$scope&&v.forEach(Ae=>{P[1].$scope.indexOf(Ae)!==-1&&(_[ge]=[P[2],P[1]],E[Ae]=!0)});v.forEach(ge=>{if(!E[ge])throw new Error('No provider for "'+ge+'". Cannot use provider from the parent!')}),m.unshift(_)}return new ty(m,a)}const g={factory:p,type:u,value:function(m){return m}};function h(m,v){const _=m.__init__||[];return function(){_.forEach(E=>{typeof E=="string"?v.get(E):v.invoke(E)})}}function y(m){const v=m.__exports__;if(v){const _=m.__modules__,E=Object.keys(m).reduce((D,F)=>(F!=="__exports__"&&F!=="__modules__"&&F!=="__init__"&&F!=="__depends__"&&(D[F]=m[F]),D),Object.create(null)),T=(_||[]).concat(E),O=d(T),N=Ic(function(D){return O.get(D)});v.forEach(function(D){r[D]=[N,D,"private",O]});const P=(m.__init__||[]).slice();return P.unshift(function(){O.init()}),m=Object.assign({},m,{__init__:P}),h(m,O)}return Object.keys(m).forEach(function(_){if(_==="__init__"||_==="__depends__")return;const E=m[_];if(E[2]==="private"){r[_]=E;return}const T=E[0],O=E[1];r[_]=[g[T],iM(T,O),T]}),h(m,a)}function C(m,v){return m.indexOf(v)!==-1||(m=(v.__depends__||[]).reduce(C,m),m.indexOf(v)!==-1)?m:m.concat(v)}function x(m){const v=m.reduce(C,[]).map(y);let _=!1;return function(){_||(_=!0,v.forEach(E=>E()))}}this.get=c,this.invoke=p,this.instantiate=u,this.createChild=d,this.init=x(e)}function iM(e,t){return e!=="value"&&Yp(t)&&(t=Ic(t.slice())),t}var rM=1e3;function nr(e,t){var n=this;t=t||rM,e.on(["render.shape","render.connection"],t,function(i,r){var o=i.type,a=r.element,s=r.gfx,c=r.attrs;if(n.canRender(a))return o==="render.shape"?n.drawShape(s,a,c):n.drawConnection(s,a,c)}),e.on(["render.getShapePath","render.getConnectionPath"],t,function(i,r){if(n.canRender(r))return i.type==="render.getShapePath"?n.getShapePath(r):n.getConnectionPath(r)})}nr.prototype.canRender=function(e){},nr.prototype.drawShape=function(e,t){},nr.prototype.drawConnection=function(e,t){},nr.prototype.getShapePath=function(e){},nr.prototype.getConnectionPath=function(e){};function uo(e){return e.flat().join(",").replace(/,?([A-Za-z]),?/g,"$1")}function oM(e){return["M",e.x,e.y]}function Xp(e){return["L",e.x,e.y]}function aM(e,t,n){return["C",e.x,e.y,t.x,t.y,n.x,n.y]}function sM(e,t){const n=e.length,i=[oM(e[0])];for(let r=1;r<n;r++){const o=e[r-1],a=e[r],s=e[r+1];if(!s||!t){i.push(Xp(a));continue}const c=Math.min(t,Zp(a.x-o.x,a.y-o.y),Zp(s.x-a.x,s.y-a.y));if(!c){i.push(Xp(a));continue}const l=Bc(a,o,c),u=Bc(a,o,c*.5),p=Bc(a,s,c),f=Bc(a,s,c*.5);i.push(Xp(l)),i.push(aM(u,f,p))}return i}function Bc(e,t,n){const i=t.x-e.x,r=t.y-e.y,o=Zp(i,r),a=n/o;return{x:e.x+i*a,y:e.y+r*a}}function Zp(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))}function qa(e,t,n){ze(t)&&(n=t,t=null),t||(t={});const i=Oe("path",t);return ze(n)&&(i.dataset.cornerRadius=String(n)),Qp(i,e)}function Qp(e,t){const n=parseInt(e.dataset.cornerRadius,10)||0;return Se(e,{d:uo(sM(t,n))}),e}function Nc(e){var t=new Set(e);return nt(e,function(n){for(var i=n.parent;i;){if(t.has(i))return!1;i=i.parent}return!0})}function po(e,t,n){n=n||0,Fe(e)||(e=[e]),z(e,function(i,r){var o=t(i,r,n);Fe(o)&&o.length&&po(o,t,n+1)})}function Jp(e,t,n){var i=new Set,r=new Set;return po(e,function(o,a,s){i.add(o);var c=o.children;if(c&&!r.has(c))return r.add(c),c}),Array.from(i)}function Ya(e,t){return Jp(e)}function cM(e,t,n){no(t)&&(t=!0),hn(t)&&(n=t,t=!0),n=n||{};var i=Ka(n.allShapes),r=Ka(n.allConnections),o=Ka(n.enclosedElements),a=Ka(n.enclosedConnections),s=Ka(n.topLevel,t&&Bo(e,function(u){return u.id}));function c(u){s[u.source.id]&&s[u.target.id]&&(s[u.id]=[u]),i[u.source.id]&&i[u.target.id]&&(a[u.id]=o[u.id]=u),r[u.id]=u}function l(u){if(o[u.id]=u,u.waypoints)a[u.id]=r[u.id]=u;else return i[u.id]=u,z(u.incoming,c),z(u.outgoing,c),u.children}return po(e,l),{allShapes:i,allConnections:r,topLevel:s,enclosedConnections:a,enclosedElements:o}}function en(e,t){t=!!t,Fe(e)||(e=[e]);var n,i,r,o;return z(e,function(a){var s=a;a.waypoints&&!t&&(s=en(a.waypoints,!0));var c=s.x,l=s.y,u=s.height||0,p=s.width||0;(c<n||n===void 0)&&(n=c),(l<i||i===void 0)&&(i=l),(c+p>r||r===void 0)&&(r=c+p),(l+u>o||o===void 0)&&(o=l+u)}),{x:n,y:i,height:o-i,width:r-n}}function Qo(e,t){var n={};return z(e,function(i){var r=i;r.waypoints&&(r=en(r)),!ze(t.y)&&r.x>t.x&&(n[i.id]=i),!ze(t.x)&&r.y>t.y&&(n[i.id]=i),r.x>t.x&&r.y>t.y&&(ze(t.width)&&ze(t.height)&&r.width+r.x<t.width+t.x&&r.height+r.y<t.height+t.y||!ze(t.width)||!ze(t.height))&&(n[i.id]=i)}),n}function ny(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}function iy(e){return!!(e&&e.isFrame)}function Ka(e,t){return U({},e||{},t||{})}var lM=1;function Cr(e,t){nr.call(this,e,lM),this.CONNECTION_STYLE=t.style(["no-fill"],{strokeWidth:5,stroke:"fuchsia"}),this.SHAPE_STYLE=t.style({fill:"white",stroke:"fuchsia",strokeWidth:2}),this.FRAME_STYLE=t.style(["no-fill"],{stroke:"fuchsia",strokeDasharray:4,strokeWidth:2})}Ee(Cr,nr),Cr.prototype.canRender=function(){return!0},Cr.prototype.drawShape=function(t,n,i){var r=Oe("rect");return Se(r,{x:0,y:0,width:n.width||0,height:n.height||0}),iy(n)?Se(r,U({},this.FRAME_STYLE,i||{})):Se(r,U({},this.SHAPE_STYLE,i||{})),We(t,r),r},Cr.prototype.drawConnection=function(t,n,i){var r=qa(n.waypoints,U({},this.CONNECTION_STYLE,i||{}));return We(t,r),r},Cr.prototype.getShapePath=function(t){var n=t.x,i=t.y,r=t.width,o=t.height,a=[["M",n,i],["l",r,0],["l",0,o],["l",-r,0],["z"]];return uo(a)},Cr.prototype.getConnectionPath=function(t){var n=t.waypoints,i,r,o=[];for(i=0;r=n[i];i++)r=r.original||r,o.push([i===0?"M":"L",r.x,r.y]);return uo(o)},Cr.$inject=["eventBus","styles"];function uM(){var e={"no-fill":{fill:"none"},"no-border":{strokeOpacity:0},"no-events":{pointerEvents:"none"}},t=this;this.cls=function(n,i,r){var o=this.style(i,r);return U(o,{class:n})},this.style=function(n,i){!Fe(n)&&!i&&(i=n,n=[]);var r=Kn(n,function(o,a){return U(o,e[a]||{})},{});return i?U(r,i):r},this.computeStyle=function(n,i,r){return Fe(i)||(r=i,i=[]),t.style(i||[],U({},r,n||{}))}}const pM={__init__:["defaultRenderer"],defaultRenderer:["type",Cr],styles:["type",uM]};function qt(e,t){if(!e||!t)return-1;var n=e.indexOf(t);return n!==-1&&e.splice(n,1),n}function Xt(e,t,n){if(!(!e||!t)){typeof n!="number"&&(n=-1);var i=e.indexOf(t);if(i!==-1){if(i===n)return;if(n!==-1)e.splice(i,1);else return}n!==-1?e.splice(n,0,t):e.push(t)}}function ef(e,t){return!e||!t?-1:e.indexOf(t)}function Xa(e,t){return!e||!t?-1:Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function tf(e,t,n,i){if(typeof i>"u"&&(i=5),!e||!t||!n)return!1;var r=(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),o=Xa(e,t);return Math.abs(r/o)<=i}var fM=2;function ir(e,t){var n=Array.from(arguments).flat();const i={x:"v",y:"h"};for(const[r,o]of Object.entries(i))if(dM(r,n))return o;return!1}function dM(e,t){const n=t[0];return io(t,function(i){return Math.abs(n[e]-i[e])<=fM})}function ry(e,t,n){return n=n||0,e.x>t.x-n&&e.y>t.y-n&&e.x<t.x+t.width+n&&e.y<t.y+t.height+n}function nf(e,t){return{x:Math.round(e.x+(t.x-e.x)/2),y:Math.round(e.y+(t.y-e.y)/2)}}var hM=/,?([a-z]),?/gi,oy=parseFloat,tn=Math,Mr=tn.PI,Gi=tn.min,Vi=tn.max,ay=tn.pow,Ar=tn.abs,mM=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?[\s]*,?[\s]*)+)/ig,gM=/(-?\d*\.?\d*(?:e[-+]?\d+)?)[\s]*,?[\s]*/ig,sy=Array.isArray||function(e){return e instanceof Array};function yM(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function vM(e,t){for(var n=0,i=e.length;n<i;n++)if(e[n]===t)return e.push(e.splice(n,1)[0])}function bM(e){function t(){var n=Array.prototype.slice.call(arguments,0),i=n.join("␀"),r=t.cache=t.cache||{},o=t.count=t.count||[];return yM(r,i)?(vM(o,i),r[i]):(o.length>=1e3&&delete r[o.shift()],o.push(i),r[i]=e(...arguments),r[i])}return t}function xM(e){if(!e)return null;var t={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},n=[];return String(e).replace(mM,function(i,r,o){var a=[],s=r.toLowerCase();for(o.replace(gM,function(c,l){l&&a.push(+l)}),s=="m"&&a.length>2&&(n.push([r,...a.splice(0,2)]),s="l",r=r=="m"?"l":"L");a.length>=t[s]&&(n.push([r,...a.splice(0,t[s])]),!!t[s]););}),n.toString=of,n}function _M(e){for(var t=0,n=e.length;t<n;t++){var i=e[t][0];if(typeof i=="string"&&i!==i.toUpperCase())return!1}return!0}function wM(e){for(var t=0,n=e.length;t<n;t++){var i=e[t][0];if(i!=="M"&&i!=="C")return!1}return!0}function rf(e,t,n,i){return arguments.length===1&&(t=e.y,n=e.width,i=e.height,e=e.x),{x:e,y:t,width:n,height:i,x2:e+n,y2:t+i}}function of(){return this.join(",").replace(hM,"$1")}function EM(e){for(var t=new Array(e.length),n=0,i=e.length;n<i;n++)for(var r=e[n],o=t[n]=new Array(r.length),a=0,s=r.length;a<s;a++)o[a]=r[a];return t.toString=of,t}function cy(e,t,n,i,r,o,a,s,c){var l=1-c,u=ay(l,3),p=ay(l,2),f=c*c,d=f*c,g=u*e+p*3*c*n+l*3*c*c*r+d*a,h=u*t+p*3*c*i+l*3*c*c*o+d*s;return{x:$c(g),y:$c(h)}}function ly(e){var t=PM(...e);return rf(t.x0,t.y0,t.x1-t.x0,t.y1-t.y0)}function Pr(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function SM(e,t){return e=rf(e),t=rf(t),Pr(t,e.x,e.y)||Pr(t,e.x2,e.y)||Pr(t,e.x,e.y2)||Pr(t,e.x2,e.y2)||Pr(e,t.x,t.y)||Pr(e,t.x2,t.y)||Pr(e,t.x,t.y2)||Pr(e,t.x2,t.y2)||(e.x<t.x2&&e.x>t.x||t.x<e.x2&&t.x>e.x)&&(e.y<t.y2&&e.y>t.y||t.y<e.y2&&t.y>e.y)}function uy(e,t,n,i,r){var o=-3*t+9*n-9*i+3*r,a=e*o+6*t-12*n+6*i;return e*a-3*t+3*n}function py(e,t,n,i,r,o,a,s,c){c==null&&(c=1),c=c>1?1:c<0?0:c;for(var l=c/2,u=12,p=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],f=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],d=0,g=0;g<u;g++){var h=l*p[g]+l,y=uy(h,e,n,r,a),C=uy(h,t,i,o,s),x=y*y+C*C;d+=f[g]*tn.sqrt(x)}return l*d}function RM(e,t,n,i,r,o,a,s){if(!(Vi(e,n)<Gi(r,a)||Gi(e,n)>Vi(r,a)||Vi(t,i)<Gi(o,s)||Gi(t,i)>Vi(o,s))){var c=(e*i-t*n)*(r-a)-(e-n)*(r*s-o*a),l=(e*i-t*n)*(o-s)-(t-i)*(r*s-o*a),u=(e-n)*(o-s)-(t-i)*(r-a);if(u){var p=$c(c/u),f=$c(l/u),d=+p.toFixed(2),g=+f.toFixed(2);if(!(d<+Gi(e,n).toFixed(2)||d>+Vi(e,n).toFixed(2)||d<+Gi(r,a).toFixed(2)||d>+Vi(r,a).toFixed(2)||g<+Gi(t,i).toFixed(2)||g>+Vi(t,i).toFixed(2)||g<+Gi(o,s).toFixed(2)||g>+Vi(o,s).toFixed(2)))return{x:p,y:f}}}}function $c(e){return Math.round(e*1e11)/1e11}function CM(e,t,n){var i=ly(e),r=ly(t);if(!SM(i,r))return[];var o=py(...e),a=py(...t),s=dy(e)?1:~~(o/5)||1,c=dy(t)?1:~~(a/5)||1,l=new Array(s+1),u=new Array(c+1),p={},f=[],d,g;for(d=0;d<s+1;d++){var h=cy(...e,d/s);l[d]={x:h.x,y:h.y,t:d/s}}for(d=0;d<c+1;d++)h=cy(...t,d/c),u[d]={x:h.x,y:h.y,t:d/c};for(d=0;d<s;d++)for(g=0;g<c;g++){var y=l[d],C=l[d+1],x=u[g],m=u[g+1],v=Ar(C.x-y.x)<.01?"y":"x",_=Ar(m.x-x.x)<.01?"y":"x",E=RM(y.x,y.y,C.x,C.y,x.x,x.y,m.x,m.y),T;if(E){if(T=E.x.toFixed(9)+"#"+E.y.toFixed(9),p[T])continue;p[T]=!0;var O=y.t+Ar((E[v]-y[v])/(C[v]-y[v]))*(C.t-y.t),N=x.t+Ar((E[_]-x[_])/(m[_]-x[_]))*(m.t-x.t);O>=0&&O<=1&&N>=0&&N<=1&&f.push({x:E.x,y:E.y,t1:O,t2:N})}}return f}function fy(e,t,n){e=gy(e),t=gy(t);for(var i,r,o,a,s,c,l,u,p,f,d=n?0:[],g=0,h=e.length;g<h;g++){var y=e[g];if(y[0]=="M")i=s=y[1],r=c=y[2];else{y[0]=="C"?(p=[i,r,...y.slice(1)],i=p[6],r=p[7]):(p=[i,r,i,r,s,c,s,c],i=s,r=c);for(var C=0,x=t.length;C<x;C++){var m=t[C];if(m[0]=="M")o=l=m[1],a=u=m[2];else{m[0]=="C"?(f=[o,a,...m.slice(1)],o=f[6],a=f[7]):(f=[o,a,o,a,l,u,l,u],o=l,a=u);var v=CM(p,f);{for(var _=0,E=v.length;_<E;_++)v[_].segment1=g,v[_].segment2=C,v[_].bez1=p,v[_].bez2=f;d=d.concat(v)}}}}}return d}function MM(e){return sy(e)&&sy(e[0])}function AM(e){if(_M(e))return e;var t=new Array(e.length),n=0,i=0,r=0,o=0,a=0,s;e[0][0]=="M"&&(n=+e[0][1],i=+e[0][2],r=n,o=i,a++,t[0]=["M",n,i]);for(var c,l,u=a,p=e.length;u<p;u++){if(l=e[u],s=l[0],t[u]=c=new Array(l.length),s!=s.toUpperCase())switch(c[0]=s.toUpperCase(),c[0]){case"A":c[1]=l[1],c[2]=l[2],c[3]=l[3],c[4]=l[4],c[5]=l[5],c[6]=+l[6]+n,c[7]=+l[7]+i;break;case"V":c[1]=+l[1]+i;break;case"H":c[1]=+l[1]+n;break;case"M":r=+l[1]+n,o=+l[2]+i;default:for(var f=1,d=l.length;f<d;f++)c[f]=+l[f]+(f%2?n:i)}else for(var g=0,h=l.length;g<h;g++)c[g]=l[g];switch(s=s.toUpperCase(),c[0]){case"Z":n=+r,i=+o;break;case"H":n=c[1];break;case"V":i=c[1];break;case"M":r=c[c.length-2],o=c[c.length-1];default:n=c[c.length-2],i=c[c.length-1]}}return t.toString=of,t}function dy(e){return e[0]===e[2]&&e[1]===e[3]&&e[4]===e[6]&&e[5]===e[7]}function Fc(e,t,n,i){return[e,t,n,i,n,i]}function hy(e,t,n,i,r,o){var a=.3333333333333333,s=2/3;return[a*e+s*n,a*t+s*i,a*r+s*n,a*o+s*i,r,o]}function my(e,t,n,i,r,o,a,s,c,l){var u=Mr*120/180,p=Mr/180*(+r||0),f=[],d,g=bM(function($,R,w){var G=$*tn.cos(w)-R*tn.sin(w),V=$*tn.sin(w)+R*tn.cos(w);return{x:G,y:V}});if(l)T=l[0],O=l[1],_=l[2],E=l[3];else{d=g(e,t,-p),e=d.x,t=d.y,d=g(s,c,-p),s=d.x,c=d.y;var h=(e-s)/2,y=(t-c)/2,C=h*h/(n*n)+y*y/(i*i);C>1&&(C=tn.sqrt(C),n=C*n,i=C*i);var x=n*n,m=i*i,v=(o==a?-1:1)*tn.sqrt(Ar((x*m-x*y*y-m*h*h)/(x*y*y+m*h*h))),_=v*n*y/i+(e+s)/2,E=v*-i*h/n+(t+c)/2,T=tn.asin(((t-E)/i).toFixed(9)),O=tn.asin(((c-E)/i).toFixed(9));T=e<_?Mr-T:T,O=s<_?Mr-O:O,T<0&&(T=Mr*2+T),O<0&&(O=Mr*2+O),a&&T>O&&(T=T-Mr*2),!a&&O>T&&(O=O-Mr*2)}var N=O-T;if(Ar(N)>u){var P=O,D=s,F=c;O=T+u*(a&&O>T?1:-1),s=_+n*tn.cos(O),c=E+i*tn.sin(O),f=my(s,c,n,i,r,0,a,D,F,[O,P,_,E])}N=O-T;var J=tn.cos(T),ge=tn.sin(T),Ae=tn.cos(O),De=tn.sin(O),qe=tn.tan(N/4),rt=4/3*n*qe,Me=4/3*i*qe,X=[e,t],ne=[e+rt*ge,t-Me*J],q=[s+rt*De,c-Me*Ae],K=[s,c];if(ne[0]=2*X[0]-ne[0],ne[1]=2*X[1]-ne[1],l)return[ne,q,K].concat(f);f=[ne,q,K].concat(f).join().split(",");for(var oe=[],fe=0,Te=f.length;fe<Te;fe++)oe[fe]=fe%2?g(f[fe-1],f[fe],p).y:g(f[fe],f[fe+1],p).x;return oe}function PM(e,t,n,i,r,o,a,s){for(var c=[],l=[[],[]],u,p,f,d,g,h,y,C,x=0;x<2;++x){if(x==0?(p=6*e-12*n+6*r,u=-3*e+9*n-9*r+3*a,f=3*n-3*e):(p=6*t-12*i+6*o,u=-3*t+9*i-9*o+3*s,f=3*i-3*t),Ar(u)<1e-12){if(Ar(p)<1e-12)continue;d=-f/p,0<d&&d<1&&c.push(d);continue}y=p*p-4*f*u,C=tn.sqrt(y),!(y<0)&&(g=(-p+C)/(2*u),0<g&&g<1&&c.push(g),h=(-p-C)/(2*u),0<h&&h<1&&c.push(h))}for(var m=c.length,v=m,_;m--;)d=c[m],_=1-d,l[0][m]=_*_*_*e+3*_*_*d*n+3*_*d*d*r+d*d*d*a,l[1][m]=_*_*_*t+3*_*_*d*i+3*_*d*d*o+d*d*d*s;return l[0][v]=e,l[1][v]=t,l[0][v+1]=a,l[1][v+1]=s,l[0].length=l[1].length=v+2,{x0:Gi(...l[0]),y0:Gi(...l[1]),x1:Vi(...l[0]),y1:Vi(...l[1])}}function gy(e){if(MM(e)||(e=xM(e)),wM(e))return e;for(var t=EM(AM(e)),n={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i=function(f,d,g){var h,y;if(!f)return["C",d.x,d.y,d.x,d.y,d.x,d.y];switch(!(f[0]in{T:1,Q:1})&&(d.qx=d.qy=null),f[0]){case"M":d.X=f[1],d.Y=f[2];break;case"A":f=["C",...my(d.x,d.y,...f.slice(1))];break;case"S":g=="C"||g=="S"?(h=d.x*2-d.bx,y=d.y*2-d.by):(h=d.x,y=d.y),f=["C",h,y,...f.slice(1)];break;case"T":g=="Q"||g=="T"?(d.qx=d.x*2-d.qx,d.qy=d.y*2-d.qy):(d.qx=d.x,d.qy=d.y),f=["C",...hy(d.x,d.y,d.qx,d.qy,f[1],f[2])];break;case"Q":d.qx=f[1],d.qy=f[2],f=["C",...hy(d.x,d.y,f[1],f[2],f[3],f[4])];break;case"L":f=["C",...Fc(d.x,d.y,f[1],f[2])];break;case"H":f=["C",...Fc(d.x,d.y,f[1],d.y)];break;case"V":f=["C",...Fc(d.x,d.y,d.x,f[1])];break;case"Z":f=["C",...Fc(d.x,d.y,d.X,d.Y)];break}return f},r=function(f,d){if(f[d].length>7){f[d].shift();for(var g=f[d];g.length;)o[d]="A",f.splice(d++,0,["C",...g.splice(0,6)]);f.splice(d,1),l=t.length}},o=[],a="",s="",c=0,l=t.length;c<l;c++){t[c]&&(a=t[c][0]),a!="C"&&(o[c]=a,c&&(s=o[c-1])),t[c]=i(t[c],n,s),o[c]!="A"&&a=="C"&&(o[c]="C"),r(t,c);var u=t[c],p=u.length;n.x=u[p-2],n.y=u[p-1],n.bx=oy(u[p-4])||n.x,n.by=oy(u[p-3])||n.y}return t}function Et(e){return hn(e)&&Yn(e,"waypoints")}function Je(e){return hn(e)&&Yn(e,"labelTarget")}function TM(e){return hn(e)&&Lo(e.parent)}function yy(e){return{x:Math.round(e.x),y:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height)}}function rr(e){return{x:Math.round(e.x),y:Math.round(e.y)}}function Le(e){return{top:e.y,right:e.x+(e.width||0),bottom:e.y+(e.height||0),left:e.x}}function jc(e){return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}function kM(e){return rr({x:e.x+(e.width||0)/2,y:e.y+(e.height||0)/2})}function OM(e){for(var t=e.waypoints,n=t.reduce(function(l,u,p){var f=t[p-1];if(f){var d=l[l.length-1],g=d&&d.endLength||0,h=IM(f,u);l.push({start:f,end:u,startLength:g,endLength:g+h,length:h})}return l},[]),i=n.reduce(function(l,u){return l+u.length},0),r=i/2,o=0,a=n[o];a.endLength<r;)a=n[++o];var s=(r-a.startLength)/a.length,c={x:a.start.x+(a.end.x-a.start.x)*s,y:a.start.y+(a.end.y-a.start.y)*s};return c}function je(e){return Et(e)?OM(e):kM(e)}function Cn(e,t,n){n=n||0,hn(n)||(n={x:n,y:n});var i=Le(e),r=Le(t),o=i.bottom+n.y<=r.top,a=i.left-n.x>=r.right,s=i.top-n.y>=r.bottom,c=i.right+n.x<=r.left,l=o?"top":s?"bottom":null,u=c?"left":a?"right":null;return u&&l?l+"-"+u:u||l||"intersect"}function Za(e,t,n){var i=DM(e,t);return i.length===1||i.length===2&&Xa(i[0],i[1])<1?rr(i[0]):i.length>1?(i=Bi(i,function(r){var o=Math.floor(r.t2*100)||1;return o=100-o,o=(o<10?"0":"")+o,r.segment2+"#"+o}),rr(i[n?0:i.length-1])):null}function DM(e,t){return fy(e,t)}function LM(e){e=e.slice();for(var t=0,n,i,r;e[t];)n=e[t],i=e[t-1],r=e[t+1],Xa(n,r)===0||tf(i,r,n)?e.splice(t,1):t++;return e}function IM(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Hc(e,t){return Math.round(e*t)/t}function vy(e){return ze(e)?e+"px":e}function BM(e){for(;e.parent;)e=e.parent;return e}function NM(e){e=U({},{width:"100%",height:"100%"},e);const t=e.container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container djs-parent"),$n(n,{position:"relative",overflow:"hidden",width:vy(e.width),height:vy(e.height)}),t.appendChild(n),n}function by(e,t,n){const i=Oe("g");st(i).add(t);const r=n!==void 0?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[r]||null),i}const $M="base",xy=0,FM=1,jM={shape:["x","y","width","height"],connection:["waypoints"]};function He(e,t,n,i){this._eventBus=t,this._elementRegistry=i,this._graphicsFactory=n,this._rootsIdx=0,this._layers={},this._planes=[],this._rootElement=null,this._focused=!1,this._init(e||{})}He.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],He.prototype._init=function(e){const t=this._eventBus,n=this._container=NM(e),i=this._svg=Oe("svg");Se(i,{width:"100%",height:"100%"}),Ln(i,"tabindex",0),e.autoFocus&&t.on("element.hover",()=>{this.restoreFocus()}),t.on("element.mousedown",500,o=>{this.focus()}),i.addEventListener("focusin",()=>{this._setFocused(!0)}),i.addEventListener("focusout",()=>{this._setFocused(!1)}),i.addEventListener("mouseover",()=>{this._eventBus.fire("canvas.mouseover")}),i.addEventListener("mouseout",()=>{this._eventBus.fire("canvas.mouseout")}),We(n,i);const r=this._viewport=by(i,"viewport");e.deferUpdate&&(this._viewboxChanged=Qu(this._viewboxChanged,300)),this._restoreFocus=Qu(this._restoreFocus,0),t.on("diagram.init",()=>{t.fire("canvas.init",{svg:i,viewport:r})}),t.on(["shape.added","connection.added","shape.removed","connection.removed","elements.changed","root.set"],()=>{delete this._cachedViewbox}),t.on("diagram.destroy",500,this._destroy,this),t.on("diagram.clear",500,this._clear,this)},He.prototype._destroy=function(){this._restoreFocus.cancel(),this._eventBus.fire("canvas.destroy",{svg:this._svg,viewport:this._viewport});const e=this._container.parentNode;e&&e.removeChild(this._container),delete this._svg,delete this._container,delete this._layers,delete this._planes,delete this._rootElement,delete this._viewport},He.prototype._setFocused=function(e){e!=this._focused&&(this._focused=e,this._eventBus.fire("canvas.focus.changed",{focused:e}))},He.prototype._clear=function(){this._elementRegistry.getAll().forEach(t=>{const n=ny(t);n==="root"?this.removeRootElement(t):this._removeElement(t,n)}),this._planes=[],this._rootElement=null,delete this._cachedViewbox},He.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)},He.prototype.restoreFocus=function(){this._restoreFocus()},He.prototype._restoreFocus=function(){document.activeElement===document.body&&this.focus()},He.prototype.isFocused=function(){return this._focused},He.prototype.getDefaultLayer=function(){return this.getLayer($M,xy)},He.prototype.getLayer=function(e,t){if(!e)throw new Error("must specify a name");let n=this._layers[e];if(n||(n=this._layers[e]=this._createLayer(e,t)),typeof t<"u"&&n.index!==t)throw new Error("layer <"+e+"> already created at index <"+t+">");return n.group},He.prototype._getChildIndex=function(e){return Kn(this._layers,function(t,n){return n.visible&&e>=n.index&&t++,t},0)},He.prototype._createLayer=function(e,t){typeof t>"u"&&(t=FM);const n=this._getChildIndex(t);return{group:by(this._viewport,"layer-"+e,n),index:t,visible:!0}},He.prototype.showLayer=function(e){if(!e)throw new Error("must specify a name");const t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");const n=this._viewport,i=t.group,r=t.index;if(t.visible)return i;const o=this._getChildIndex(r);return n.insertBefore(i,n.childNodes[o]||null),t.visible=!0,i},He.prototype.hideLayer=function(e){if(!e)throw new Error("must specify a name");const t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");const n=t.group;return t.visible&&(un(n),t.visible=!1),n},He.prototype._removeLayer=function(e){const t=this._layers[e];t&&(delete this._layers[e],un(t.group))},He.prototype.getActiveLayer=function(){const e=this._findPlaneForRoot(this.getRootElement());return e?e.layer:null},He.prototype.findRoot=function(e){const t=this._resolveElements(e);let n;for(const i of t){const r=this._findPlaneForRoot(BM(i));if(!r||n&&r.rootElement!==n)return;n=r.rootElement}return n},He.prototype.getRootElements=function(){return this._planes.map(function(e){return e.rootElement})},He.prototype._findPlaneForRoot=function(e){return Pt(this._planes,function(t){return t.rootElement===e})},He.prototype._resolveElement=function(e){return typeof e=="string"?this._elementRegistry.get(e):e},He.prototype._resolveElements=function(e){return Fe(e)||(e=[e]),e.map(t=>this._resolveElement(t)).filter(Boolean)},He.prototype.getContainer=function(){return this._container},He.prototype._updateMarker=function(e,t,n){let i;e=this._resolveElement(e),e.markers=e.markers||new Set,i=this._elementRegistry._elements[e.id],i&&(z([i.gfx,i.secondaryGfx],function(r){r&&(n?(e.markers.add(t),st(r).add(t)):(e.markers.delete(t),st(r).remove(t)))}),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},He.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},He.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},He.prototype.hasMarker=function(e,t){return e=this._resolveElement(e),e.markers?e.markers.has(t):!1},He.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},He.prototype.getRootElement=function(){const e=this._rootElement;return e||this._planes.length?e:this.setRootElement(this.addRootElement(null))},He.prototype.addRootElement=function(e){const t=this._rootsIdx++;e||(e={id:"__implicitroot_"+t,children:[],isImplicit:!0});const n=e.layer="root-"+t;this._ensureValid("root",e);const i=this.getLayer(n,xy);return this.hideLayer(n),this._addRoot(e,i),this._planes.push({rootElement:e,layer:i}),e},He.prototype.removeRootElement=function(e){if(e=this._resolveElement(e),!!this._findPlaneForRoot(e))return this._removeRoot(e),this._removeLayer(e.layer),this._planes=this._planes.filter(function(n){return n.rootElement!==e}),this._rootElement===e&&(this._rootElement=null),e},He.prototype.setRootElement=function(e){if(e===this._rootElement)return e;let t;if(!e)throw new Error("rootElement required");return t=this._findPlaneForRoot(e),t||(e=this.addRootElement(e)),this._setRoot(e),e},He.prototype._removeRoot=function(e){const t=this._elementRegistry,n=this._eventBus;n.fire("root.remove",{element:e}),n.fire("root.removed",{element:e}),t.remove(e)},He.prototype._addRoot=function(e,t){const n=this._elementRegistry,i=this._eventBus;i.fire("root.add",{element:e}),n.add(e,t),i.fire("root.added",{element:e,gfx:t})},He.prototype._setRoot=function(e,t){const n=this._rootElement;n&&(this._elementRegistry.updateGraphics(n,null,!0),this.hideLayer(n.layer)),e&&(t||(t=this._findPlaneForRoot(e).layer),this._elementRegistry.updateGraphics(e,this._svg,!0),this.showLayer(e.layer)),this._rootElement=e,this._eventBus.fire("root.set",{element:e})},He.prototype._ensureValid=function(e,t){if(!t.id)throw new Error("element must have an id");if(this._elementRegistry.get(t.id))throw new Error("element <"+t.id+"> already exists");const n=jM[e];if(!io(n,function(r){return typeof t[r]<"u"}))throw new Error("must supply { "+n.join(", ")+" } with "+e)},He.prototype._setParent=function(e,t,n){Xt(t.children,e,n),e.parent=t},He.prototype._addElement=function(e,t,n,i){n=n||this.getRootElement();const r=this._eventBus,o=this._graphicsFactory;this._ensureValid(e,t),r.fire(e+".add",{element:t,parent:n}),this._setParent(t,n,i);const a=o.create(e,t,i);return this._elementRegistry.add(t,a),o.update(e,t,a),r.fire(e+".added",{element:t,gfx:a}),t},He.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},He.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},He.prototype._removeElement=function(e,t){const n=this._elementRegistry,i=this._graphicsFactory,r=this._eventBus;if(e=n.get(e.id||e),!!e)return r.fire(t+".remove",{element:e}),i.remove(e),qt(e.parent&&e.parent.children,e),e.parent=null,r.fire(t+".removed",{element:e}),n.remove(e),e},He.prototype.removeShape=function(e){return this._removeElement(e,"shape")},He.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},He.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},He.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},He.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},He.prototype.viewbox=function(e){if(e===void 0&&this._cachedViewbox)return structuredClone(this._cachedViewbox);const t=this._viewport,n=this.getSize();let i,r,o,a,s,c,l;if(e)this._changeViewbox(function(){s=Math.min(n.width/e.width,n.height/e.height);const u=this._svg.createSVGMatrix().scale(s).translate(-e.x,-e.y);Ua(t,u)});else return o=this._rootElement?this.getActiveLayer():null,i=o&&o.getBBox()||{},a=Ua(t),r=a?a.matrix:WC(),s=Hc(r.a,1e3),c=Hc(-r.e||0,1e3),l=Hc(-r.f||0,1e3),e=this._cachedViewbox={x:c?c/s:0,y:l?l/s:0,width:n.width/s,height:n.height/s,scale:s,inner:{width:i.width||0,height:i.height||0,x:i.x||0,y:i.y||0},outer:n},e;return e},He.prototype.scroll=function(e){const t=this._viewport;let n=t.getCTM();return e&&this._changeViewbox(function(){e=U({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),_y(t,n)}),{x:n.e,y:n.f}},He.prototype.scrollToElement=function(e,t){let n=100;const i=this._resolveElements(e);if(!i.length)return;const r=this.findRoot(i);if(!r)return;r!==this.getRootElement()&&this.setRootElement(r);const o=i.filter(g=>g!=r);if(!o.length)return;t||(t={}),typeof t=="number"&&(n=t),t={top:t.top||n,right:t.right||n,bottom:t.bottom||n,left:t.left||n};const a=en(o),s=Le(a),c=this.viewbox(),l=this.zoom();let u,p;c.y+=t.top/l,c.x+=t.left/l,c.width-=(t.right+t.left)/l,c.height-=(t.bottom+t.top)/l;const f=Le(c);if(!(a.width<c.width&&a.height<c.height))u=a.x-c.x,p=a.y-c.y;else{const g=Math.max(0,s.right-f.right),h=Math.min(0,s.left-f.left),y=Math.max(0,s.bottom-f.bottom),C=Math.min(0,s.top-f.top);u=g||h,p=y||C}this.scroll({dx:-u*l,dy:-p*l})},He.prototype.zoom=function(e,t){if(!e)return this.viewbox(e).scale;if(e==="fit-viewport")return this._fitViewport(t);let n,i;return this._changeViewbox(function(){typeof t!="object"&&(n=this.viewbox().outer,t={x:n.width/2,y:n.height/2}),i=this._setZoom(e,t)}),Hc(i.a,1e3)};function _y(e,t){const n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}He.prototype._fitViewport=function(e){const t=this.viewbox(),n=t.outer,i=t.inner;let r,o;return i.x>=0&&i.y>=0&&i.x+i.width<=n.width&&i.y+i.height<=n.height&&!e?o={x:0,y:0,width:Math.max(i.width+i.x,n.width),height:Math.max(i.height+i.y,n.height)}:(r=Math.min(1,n.width/i.width,n.height/i.height),o={x:i.x+(e?i.width/2-n.width/r/2:0),y:i.y+(e?i.height/2-n.height/r/2:0),width:n.width/r,height:n.height/r}),this.viewbox(o),this.viewbox(!1).scale},He.prototype._setZoom=function(e,t){const n=this._svg,i=this._viewport,r=n.createSVGMatrix(),o=n.createSVGPoint();let a,s,c,l,u;c=i.getCTM();const p=c.a;return t?(a=U(o,t),s=a.matrixTransform(c.inverse()),l=r.translate(s.x,s.y).scale(1/p*e).translate(-s.x,-s.y),u=c.multiply(l)):u=r.scale(e),_y(this._viewport,u),u},He.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},He.prototype.getAbsoluteBBox=function(e){const t=this.viewbox();let n;e.waypoints?n=this.getGraphics(e).getBBox():n=e;const i=n.x*t.scale-t.x*t.scale,r=n.y*t.scale-t.y*t.scale,o=n.width*t.scale,a=n.height*t.scale;return{x:i,y:r,width:o,height:a}},He.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var Jo="data-element-id";function li(e){this._elements={},this._eventBus=e}li.$inject=["eventBus"],li.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),Se(t,Jo,i),n&&Se(n,Jo,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},li.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(Se(i.gfx,Jo,""),i.secondaryGfx&&Se(i.secondaryGfx,Jo,""),delete t[n])},li.prototype.updateId=function(e,t){this._validateId(t),typeof e=="string"&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t});var n=this.getGraphics(e),i=this.getGraphics(e,!0);this.remove(e),e.id=t,this.add(e,n,i)},li.prototype.updateGraphics=function(e,t,n){var i=e.id||e,r=this._elements[i];return n?r.secondaryGfx=t:r.gfx=t,t&&Se(t,Jo,i),t},li.prototype.get=function(e){var t;typeof e=="string"?t=e:t=e&&Se(e,Jo);var n=this._elements[t];return n&&n.element},li.prototype.filter=function(e){var t=[];return this.forEach(function(n,i){e(n,i)&&t.push(n)}),t},li.prototype.find=function(e){for(var t=this._elements,n=Object.keys(t),i=0;i<n.length;i++){var r=n[i],o=t[r],a=o.element,s=o.gfx;if(e(a,s))return a}},li.prototype.getAll=function(){return this.filter(function(e){return e})},li.prototype.forEach=function(e){var t=this._elements;Object.keys(t).forEach(function(n){var i=t[n],r=i.element,o=i.gfx;return e(r,o)})},li.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},li.prototype._validateId=function(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")};function HM(e,t,n,i){var r=n.inverse;return Object.defineProperty(e,"remove",{value:function(o){var a=this.indexOf(o);return a!==-1&&(this.splice(a,1),t.unset(o,r,i)),o}}),Object.defineProperty(e,"contains",{value:function(o){return this.indexOf(o)!==-1}}),Object.defineProperty(e,"add",{value:function(o,a){var s=this.indexOf(o);if(typeof a>"u"){if(s!==-1)return;a=this.length}s!==-1&&this.splice(s,1),this.splice(a,0,o),s===-1&&t.set(o,r,i)}}),Object.defineProperty(e,"__refs_collection",{value:!0}),e}function zM(e){return e.__refs_collection===!0}function GM(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)}function wy(e,t,n){var i=HM(n[t.name]||[],e,t,n);Object.defineProperty(n,t.name,{enumerable:t.enumerable,value:i}),i.length&&i.forEach(function(r){e.set(r,t.inverse,n)})}function VM(e,t,n){var i=t.inverse,r=n[t.name];Object.defineProperty(n,t.name,{configurable:t.configurable,enumerable:t.enumerable,get:function(){return r},set:function(o){if(o!==r){var a=r;r=null,a&&e.unset(a,i,n),r=o,e.set(r,i,n)}}})}function mi(e,t){if(!(this instanceof mi))return new mi(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}mi.prototype.bind=function(e,t){if(typeof t=="string"){if(!this.props[t])throw new Error("no property <"+t+"> in ref");t=this.props[t]}t.collection?wy(this,t,e):VM(this,t,e)},mi.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return zM(n)||wy(this,t,e),n},mi.prototype.ensureBound=function(e,t){GM(e,t)||this.bind(e,t)},mi.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},mi.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var af=new mi({name:"children",enumerable:!0,collection:!0},{name:"parent"}),Ey=new mi({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),Sy=new mi({name:"attachers",collection:!0},{name:"host"}),Ry=new mi({name:"outgoing",collection:!0},{name:"source"}),Cy=new mi({name:"incoming",collection:!0},{name:"target"});function ea(){Object.defineProperty(this,"businessObject",{writable:!0}),Object.defineProperty(this,"label",{get:function(){return this.labels[0]},set:function(e){var t=this.label,n=this.labels;!e&&t?n.remove(t):n.add(e,0)}}),af.bind(this,"parent"),Ey.bind(this,"labels"),Ry.bind(this,"outgoing"),Cy.bind(this,"incoming")}function Qa(){ea.call(this),af.bind(this,"children"),Sy.bind(this,"host"),Sy.bind(this,"attachers")}Ee(Qa,ea);function My(){ea.call(this),af.bind(this,"children")}Ee(My,Qa);function Ay(){Qa.call(this),Ey.bind(this,"labelTarget")}Ee(Ay,Qa);function Py(){ea.call(this),Ry.bind(this,"source"),Cy.bind(this,"target")}Ee(Py,ea);var WM={connection:Py,shape:Qa,label:Ay,root:My};function UM(e,t){var n=WM[e];if(!n)throw new Error("unknown type: <"+e+">");return U(new n,t)}function qM(e){return e instanceof ea}function or(){this._uid=12}or.prototype.createRoot=function(e){return this.create("root",e)},or.prototype.createLabel=function(e){return this.create("label",e)},or.prototype.createShape=function(e){return this.create("shape",e)},or.prototype.createConnection=function(e){return this.create("connection",e)},or.prototype.create=function(e,t){return t=U({},t||{}),t.id||(t.id=e+"_"+this._uid++),UM(e,t)};var zc="__fn",Ty=1e3,YM=Array.prototype.slice;function Zn(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}Zn.prototype.on=function(e,t,n,i){if(e=Fe(e)?e:[e],mn(t)&&(i=n,n=t,t=Ty),!ze(t))throw new Error("priority must be a number");var r=n;i&&(r=Gn(n,i),r[zc]=n[zc]||n);var o=this;e.forEach(function(a){o._addListener(a,{priority:t,callback:r,next:null})})},Zn.prototype.once=function(e,t,n,i){var r=this;if(mn(t)&&(i=n,n=t,t=Ty),!ze(t))throw new Error("priority must be a number");function o(){o.__isTomb=!0;var a=n.apply(i,arguments);return r.off(e,o),a}o[zc]=n,this.on(e,t,o)},Zn.prototype.off=function(e,t){e=Fe(e)?e:[e];var n=this;e.forEach(function(i){n._removeListener(i,t)})},Zn.prototype.createEvent=function(e){var t=new Ja;return t.init(e),t},Zn.prototype.fire=function(e,t){var n,i,r,o;if(o=YM.call(arguments),typeof e=="object"&&(t=e,e=t.type),!e)throw new Error("no event type specified");if(i=this._listeners[e],!!i){t instanceof Ja?n=t:n=this.createEvent(t),o[0]=n;var a=n.type;e!==a&&(n.type=e);try{r=this._invokeListeners(n,o,i)}finally{e!==a&&(n.type=a)}return r===void 0&&n.defaultPrevented&&(r=!1),r}},Zn.prototype.handleError=function(e){return this.fire("error",{error:e})===!1},Zn.prototype._destroy=function(){this._listeners={}},Zn.prototype._invokeListeners=function(e,t,n){for(var i;n&&!e.cancelBubble;)i=this._invokeListener(e,t,n),n=n.next;return i},Zn.prototype._invokeListener=function(e,t,n){var i;if(n.callback.__isTomb)return i;try{i=KM(n.callback,t),i!==void 0&&(e.returnValue=i,e.stopPropagation()),i===!1&&e.preventDefault()}catch(r){if(!this.handleError(r))throw console.error("unhandled error in event listener",r),r}return i},Zn.prototype._addListener=function(e,t){var n=this._getListeners(e),i;if(!n){this._setListeners(e,t);return}for(;n;){if(n.priority<t.priority){t.next=n,i?i.next=t:this._setListeners(e,t);return}i=n,n=n.next}i.next=t},Zn.prototype._getListeners=function(e){return this._listeners[e]},Zn.prototype._setListeners=function(e,t){this._listeners[e]=t},Zn.prototype._removeListener=function(e,t){var n=this._getListeners(e),i,r,o;if(!t){this._setListeners(e,null);return}for(;n;)i=n.next,o=n.callback,(o===t||o[zc]===t)&&(r?r.next=i:this._setListeners(e,i)),r=n,n=i};function Ja(){}Ja.prototype.stopPropagation=function(){this.cancelBubble=!0},Ja.prototype.preventDefault=function(){this.defaultPrevented=!0},Ja.prototype.init=function(e){U(this,e||{})};function KM(e,t){return e.apply(null,t)}function fo(e){return e.childNodes[0]}function XM(e){return e.parentNode.childNodes[1]}function Gc(e,t,n,i,r){var o=Wa();o.setTranslate(t,n);var a=Wa();a.setRotate(i||0,0,0);var s=Wa();s.setScale(1,1),Ua(e,[o,a,s])}function Mn(e,t,n){var i=Wa();i.setTranslate(t,n),Ua(e,i)}function ky(e,t){var n=Wa();n.setRotate(t,0,0),Ua(e,n)}function ui(e,t){this._eventBus=e,this._elementRegistry=t}ui.$inject=["eventBus","elementRegistry"],ui.prototype._getChildrenContainer=function(e){var t=this._elementRegistry.getGraphics(e),n;return e.parent?(n=XM(t),n||(n=Oe("g"),st(n).add("djs-children"),We(t.parentNode,n))):n=t,n},ui.prototype._clear=function(e){var t=fo(e);return kc(t),t},ui.prototype._createContainer=function(e,t,n,i){var r=Oe("g");st(r).add("djs-group"),typeof n<"u"?ZM(r,t,t.childNodes[n]):We(t,r);var o=Oe("g");st(o).add("djs-element"),st(o).add("djs-"+e),i&&st(o).add("djs-frame"),We(r,o);var a=Oe("g");return st(a).add("djs-visual"),We(o,a),o},ui.prototype.create=function(e,t,n){var i=this._getChildrenContainer(t.parent);return this._createContainer(e,i,n,iy(t))},ui.prototype.updateContainments=function(e){var t=this,n=this._elementRegistry,i;i=Kn(e,function(r,o){return o.parent&&(r[o.parent.id]=o.parent),r},{}),z(i,function(r){var o=r.children;if(o){var a=t._getChildrenContainer(r),s=a.firstChild;z(o,function(c){var l=n.getGraphics(c).parentNode;l===s?s=s.nextSibling:a.insertBefore(l,s)})}})},ui.prototype.drawShape=function(e,t,n={}){var i=this._eventBus;return i.fire("render.shape",{gfx:e,element:t,attrs:n})},ui.prototype.getShapePath=function(e){var t=this._eventBus;return t.fire("render.getShapePath",e)},ui.prototype.drawConnection=function(e,t,n={}){var i=this._eventBus;return i.fire("render.connection",{gfx:e,element:t,attrs:n})},ui.prototype.getConnectionPath=function(e){var t=this._eventBus;return t.fire("render.getConnectionPath",e)},ui.prototype.update=function(e,t,n){if(t.parent){var i=this._clear(n);if(e==="shape")this.drawShape(i,t),Mn(n,t.x,t.y);else if(e==="connection")this.drawConnection(i,t);else throw new Error("unknown type: "+e);t.hidden?Se(n,"display","none"):Se(n,"display","block")}},ui.prototype.remove=function(e){var t=this._elementRegistry.getGraphics(e);un(t.parentNode)};function ZM(e,t,n){var i=n||t.firstChild;e!==i&&t.insertBefore(e,i)}const QM={__depends__:[pM],__init__:["canvas"],canvas:["type",He],elementRegistry:["type",li],elementFactory:["type",or],eventBus:["type",Zn],graphicsFactory:["type",ui]};function JM(e){var t=new ty(e);return t.init(),t}function eA(e){e=e||{};var t={config:["value",e]},n=[t,QM].concat(e.modules||[]);return JM(n)}function Tr(e,t){this._injector=t||eA(e),this.get("eventBus").fire("diagram.init")}Tr.prototype.get=function(e,t){return this._injector.get(e,t)},Tr.prototype.invoke=function(e,t,n){return this._injector.invoke(e,t,n)},Tr.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")},Tr.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};function In(e){return e?"<"+e.$type+(e.id?' id="'+e.id:"")+'" />':"<null>"}function Vn(e,t){return e.$instanceOf(t)}function tA(e){return Pt(e.rootElements,function(t){return Vn(t,"bpmn:Process")||Vn(t,"bpmn:Collaboration")})}function nA(e){var t={},n=[],i={};function r(q,K){return function(oe){q(oe,K)}}function o(q){t[q.id]=q}function a(q){return t[q.id]}function s(q,K){var oe=q.gfx;if(oe)throw new Error(`already rendered ${In(q)}`);return e.element(q,i[q.id],K)}function c(q,K){return e.root(q,i[q.id],K)}function l(q,K){try{var oe=i[q.id]&&s(q,K);return o(q),oe}catch(fe){u(fe.message,{element:q,error:fe}),console.error(`failed to import ${In(q)}`,fe)}}function u(q,K){e.error(q,K)}var p=this.registerDi=function(K){var oe=K.bpmnElement;oe?i[oe.id]?u(`multiple DI elements defined for ${In(oe)}`,{element:oe}):i[oe.id]=K:u(`no bpmnElement referenced in ${In(K)}`,{element:K})};function f(q){d(q.plane)}function d(q){p(q),z(q.planeElement,g)}function g(q){p(q)}this.handleDefinitions=function(K,oe){var fe=K.diagrams;if(oe&&fe.indexOf(oe)===-1)throw new Error("diagram not part of <bpmn:Definitions />");if(!oe&&fe&&fe.length&&(oe=fe[0]),!oe)throw new Error("no diagram to display");i={},f(oe);var Te=oe.plane;if(!Te)throw new Error(`no plane for ${In(oe)}`);var $=Te.bpmnElement;if(!$)if($=tA(K),$)u(`correcting missing bpmnElement on ${In(Te)} to ${In($)}`),Te.bpmnElement=$,p(Te);else throw new Error("no process or collaboration to display");var R=c($,Te);if(Vn($,"bpmn:Process")||Vn($,"bpmn:SubProcess"))y($,R);else if(Vn($,"bpmn:Collaboration"))X($,R),C(K.rootElements,R);else throw new Error(`unsupported bpmnElement for ${In(Te)}: ${In($)}`);h(n)};var h=this.handleDeferred=function(){for(var K;n.length;)K=n.shift(),K()};function y(q,K){qe(q,K),N(q.ioSpecification,K),O(q.artifacts,K),o(q)}function C(q,K){var oe=nt(q,function(fe){return!a(fe)&&Vn(fe,"bpmn:Process")&&fe.laneSets});oe.forEach(r(y,K))}function x(q,K){l(q,K)}function m(q,K){z(q,r(x,K))}function v(q,K){l(q,K)}function _(q,K){l(q,K)}function E(q,K){l(q,K)}function T(q,K){l(q,K)}function O(q,K){z(q,function(oe){Vn(oe,"bpmn:Association")?n.push(function(){T(oe,K)}):T(oe,K)})}function N(q,K){q&&(z(q.dataInputs,r(_,K)),z(q.dataOutputs,r(E,K)))}var P=this.handleSubProcess=function(K,oe){qe(K,oe),O(K.artifacts,oe)};function D(q,K){var oe=l(q,K);Vn(q,"bpmn:SubProcess")&&P(q,oe||K),Vn(q,"bpmn:Activity")&&N(q.ioSpecification,K),n.push(function(){z(q.dataInputAssociations,r(v,K)),z(q.dataOutputAssociations,r(v,K))})}function F(q,K){l(q,K)}function J(q,K){l(q,K)}function ge(q,K){n.push(function(){var oe=l(q,K);q.childLaneSet&&Ae(q.childLaneSet,oe||K),ne(q)})}function Ae(q,K){z(q.lanes,r(ge,K))}function De(q,K){z(q,r(Ae,K))}function qe(q,K){rt(q.flowElements,K),q.laneSets&&De(q.laneSets,K)}function rt(q,K){z(q,function(oe){Vn(oe,"bpmn:SequenceFlow")?n.push(function(){F(oe,K)}):Vn(oe,"bpmn:BoundaryEvent")?n.unshift(function(){D(oe,K)}):Vn(oe,"bpmn:FlowNode")?D(oe,K):Vn(oe,"bpmn:DataObject")||(Vn(oe,"bpmn:DataStoreReference")||Vn(oe,"bpmn:DataObjectReference")?J(oe,K):u(`unrecognized flowElement ${In(oe)} in context ${In(K&&K.businessObject)}`,{element:oe,context:K}))})}function Me(q,K){var oe=l(q,K),fe=q.processRef;fe&&y(fe,oe||K)}function X(q,K){z(q.participants,r(Me,K)),n.push(function(){m(q.messageFlows,K)}),O(q.artifacts,K)}function ne(q){z(q.flowNodeRef,function(K){var oe=K.get("lanes");oe&&oe.push(q)})}}function iA(e,t,n){var i,r,o,a,s=[];function c(l,u){var p={root:function(h,y){return i.add(h,y)},element:function(h,y,C){return i.add(h,y,C)},error:function(h,y){s.push({message:h,context:y})}},f=new nA(p);u=u||l.diagrams&&l.diagrams[0];var d=rA(l,u);if(!d)throw new Error("no diagram to display");z(d,function(h){f.handleDefinitions(l,h)});var g=u.plane.bpmnElement.id;o.setRootElement(o.findRoot(g+"_plane")||o.findRoot(g))}return new Promise(function(l,u){try{return i=e.get("bpmnImporter"),r=e.get("eventBus"),o=e.get("canvas"),r.fire("import.render.start",{definitions:t}),c(t,n),r.fire("import.render.complete",{error:a,warnings:s}),l({warnings:s})}catch(p){return p.warnings=s,u(p)}})}function rA(e,t){if(!(!t||!t.plane)){var n=t.plane.bpmnElement,i=n;!M(n,"bpmn:Process")&&!M(n,"bpmn:Collaboration")&&(i=oA(n));var r;M(i,"bpmn:Collaboration")?r=i:r=Pt(e.rootElements,function(l){if(M(l,"bpmn:Collaboration"))return Pt(l.participants,function(u){return u.processRef===i})});var o=[i];r&&(o=kn(r.participants,function(l){return l.processRef}),o.push(r));var a=Oy(o),s=[t],c=[n];return z(e.diagrams,function(l){if(l.plane){var u=l.plane.bpmnElement;a.indexOf(u)!==-1&&c.indexOf(u)===-1&&(s.push(l),c.push(u))}}),s}}function Oy(e){var t=[];return z(e,function(n){n&&(t.push(n),t=t.concat(Oy(n.flowElements)))}),t}function oA(e){for(var t=e;t;){if(M(t,"bpmn:Process"))return t;t=t.$parent}}var aA='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14.02 5.57" width="53" height="21"><path fill="currentColor" d="M1.88.92v.14c0 .41-.13.68-.4.8.33.14.46.44.46.86v.33c0 .61-.33.95-.95.95H0V0h.95c.65 0 .93.3.93.92zM.63.57v1.06h.24c.24 0 .38-.1.38-.43V.98c0-.28-.1-.4-.32-.4zm0 1.63v1.22h.36c.2 0 .32-.1.32-.39v-.35c0-.37-.12-.48-.4-.48H.63zM4.18.99v.52c0 .64-.31.98-.94.98h-.3V4h-.62V0h.92c.63 0 .94.35.94.99zM2.94.57v1.35h.3c.2 0 .3-.09.3-.37v-.6c0-.29-.1-.38-.3-.38h-.3zm2.89 2.27L6.25 0h.88v4h-.6V1.12L6.1 3.99h-.6l-.46-2.82v2.82h-.55V0h.87zM8.14 1.1V4h-.56V0h.79L9 2.4V0h.56v4h-.64zm2.49 2.29v.6h-.6v-.6zM12.12 1c0-.63.33-1 .95-1 .61 0 .95.37.95 1v2.04c0 .64-.34 1-.95 1-.62 0-.95-.37-.95-1zm.62 2.08c0 .28.13.39.33.39s.32-.1.32-.4V.98c0-.29-.12-.4-.32-.4s-.33.11-.33.4z"/><path fill="currentColor" d="M0 4.53h14.02v1.04H0zM11.08 0h.63v.62h-.63zm.63 4V1h-.63v2.98z"/></svg>',Dy=aA,Ly={verticalAlign:"middle"},Iy={color:"#404040"},sA={zIndex:"1001",position:"fixed",top:"0",left:"0",right:"0",bottom:"0"},cA={width:"100%",height:"100%",background:"rgba(40,40,40,0.2)"},lA={position:"absolute",left:"50%",top:"40%",transform:"translate(-50%)",width:"260px",padding:"10px",background:"white",boxShadow:"0 1px 4px rgba(0,0,0,0.3)",fontFamily:"Helvetica, Arial, sans-serif",fontSize:"14px",display:"flex",lineHeight:"1.3"},uA='<div class="bjs-powered-by-lightbox"><div class="backdrop"></div><div class="notice"><a href="https://bpmn.io" target="_blank" rel="noopener" class="link">'+Dy+'</a><span>Web-based tooling for BPMN, DMN and forms powered by <a href="https://bpmn.io" target="_blank" rel="noopener">bpmn.io</a>.</span></div></div>',Wi;function pA(){Wi=Dt(uA),$n(Wi,sA),$n(wt("svg",Wi),Ly),$n(wt(".backdrop",Wi),cA),$n(wt(".notice",Wi),lA),$n(wt(".link",Wi),Iy,{margin:"15px 20px 15px 10px",alignSelf:"center"})}function fA(){Wi||(pA(),Xn.bind(Wi,".backdrop","click",function(e){document.body.removeChild(Wi)})),document.body.appendChild(Wi)}const Vc=5,By="djs-outline-hidden";function Ht(e){e=U({},hA,e),this._moddle=this._createModdle(e),this._container=this._createContainer(e),this._init(this._container,this._moddle,e),gA(this._container)}Ee(Ht,Tr),Ht.prototype.importXML=async function(t,n){const i=this;function r(a){return i.get("eventBus").createEvent(a)}let o=[];try{t=this._emit("import.parse.start",{xml:t})||t;let a;try{a=await this._moddle.fromXML(t,"bpmn:Definitions")}catch(f){throw this._emit("import.parse.complete",{error:f}),f}let s=a.rootElement;const c=a.references,l=a.warnings,u=a.elementsById;o=o.concat(l),s=this._emit("import.parse.complete",r({error:null,definitions:s,elementsById:u,references:c,warnings:o}))||s;const p=await this.importDefinitions(s,n);return o=o.concat(p.warnings),this._emit("import.done",{error:null,warnings:o}),{warnings:o}}catch(a){let s=a;throw o=o.concat(s.warnings||[]),Wc(s,o),s=dA(s),this._emit("import.done",{error:s,warnings:s.warnings}),s}},Ht.prototype.importDefinitions=async function(t,n){return this._setDefinitions(t),{warnings:(await this.open(n)).warnings}},Ht.prototype.open=async function(t){const n=this._definitions;let i=t;if(!n){const o=new Error("no XML imported");throw Wc(o,[]),o}if(typeof t=="string"&&(i=mA(n,t),!i)){const o=new Error("BPMNDiagram <"+t+"> not found");throw Wc(o,[]),o}try{this.clear()}catch(o){throw Wc(o,[]),o}const{warnings:r}=await iA(this,n,i);return{warnings:r}},Ht.prototype.saveXML=async function(t){t=t||{};let n=this._definitions,i,r;try{if(!n)throw new Error("no definitions loaded");n=this._emit("saveXML.start",{definitions:n})||n,r=(await this._moddle.toXML(n,t)).xml,r=this._emit("saveXML.serialized",{xml:r})||r}catch(a){i=a}const o=i?{error:i}:{xml:r};if(this._emit("saveXML.done",o),i)throw i;return o},Ht.prototype.saveSVG=async function(){this._emit("saveSVG.start");let t,n;try{const i=this.get("canvas"),r=i.getActiveLayer(),o=wt(":scope > defs",i._svg),a=ey(r),s=o?"<defs>"+ey(o)+"</defs>":"",c=i.getContainer();$t(c).add(By);let l;try{l=r.getBBox()}finally{$t(c).remove(By)}const u=l.x-Vc,p=l.y-Vc,f=l.width+Vc*2,d=l.height+Vc*2;t=`<?xml version="1.0" encoding="utf-8"?>
8
8
  <!-- created with bpmn-js / http://bpmn.io -->
9
9
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">